Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

unit Un_RZ;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls;

type

Tfrmsinyal = class(TForm)

rz: TImage;

Edit1: TEdit;

keluar: TButton;

uni: TImage;

nrzl: TImage;

nrzi: TImage;

manc: TImage;

dm: TImage;

ami: TImage;

b: TImage;

hdb: TImage;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

procedure Edit1Change(Sender: TObject);

procedure keluarClick(Sender: TObject);

private

{ Private declarations }
public

{ Public declarations }

end;

var

frmsinyal: Tfrmsinyal;

implementation

{$R *.dfm}

procedure sumbu (image:Timage;ax,ay,b,c:integer);

begin

image.Canvas.Pen.Color:=clblack;

image.Canvas.MoveTo(ax,ay);

image.Canvas.LineTo(ax+b,ay);

image.Canvas.MoveTo(ax,ay);

image.Canvas.LineTo(ax,ay-c);

image.Canvas.MoveTo(ax,ay);

image.Canvas.LineTo(ax,ay+c);

image.Canvas.Pen.Width:=3;

end;

procedure Tfrmsinyal.Edit1Change(Sender: TObject);

var

x1,x2,y1,y2,i,tnd1,tnd2,n:integer;

data:string;

pnjg:double;

begin

x1:=0;

y1:=40;

if length(Edit1.Text)=0 then

begin

showmessage('masukan input data biner');

Edit1.SetFocus;

end
else begin

data:=Edit1.Text;

n:=length(Edit1.Text);

uni.Picture:=nil; //UNIPOLAR

sumbu(uni,x1,y1,400,80);

uni.Canvas.Pen.Color:=clblue;

rz.Picture:=nil; //RZ

sumbu(rz,x1,y1,400,80);

rz.Canvas.Pen.Color:=clblue;

nrzl.Picture:=nil; //NRZL

sumbu(nrzl,x1,y1,400,80);

nrzl.Canvas.Pen.Color:=clblue;

nrzi.Picture:=nil; //NRZI

sumbu(nrzi,x1,y1,400,80);

nrzi.Canvas.Pen.Color:=clblue;

ami.Picture:=nil; //AMI

sumbu(ami,x1,y1,400,80);

ami.Canvas.Pen.Color:=clblue;

manc.Picture:=nil; //MANC

sumbu(manc,x1,y1,400,80);

manc.Canvas.Pen.Color:=clblue;

dm.Picture:=nil;

sumbu(dm,x1,y1,400,80); //DM

dm.Canvas.Pen.Color:=clblue;

hdb.Picture:=nil; //HDB3

sumbu(hdb,x1,y1,400,80);

hdb.Canvas.Pen.Color:=clblue;

b.Picture:=nil; //B8ZS

sumbu(b,x1,y1,400,80);

b.Canvas.Pen.Color:=clblue;

//............gambar gelombang RZ.............


tnd1:=1; tnd2:=1;

pnjg:=round(rz.Width/round(2*n));

for i:=0 to n do

begin //..............JIKA i = SATU..............

if data[i] = '1' then

begin

x2:=round((2*i*pnjg)-(2*pnjg));

uni.Canvas.LineTo(x2,y1-40); //UNIPOLAR

uni.Canvas.LineTo(round(x2+pnjg*2),y1-40);

rz.Canvas.MoveTo(x2,y1-1); //RZ

rz.Canvas.LineTo(x2,y1-40);

rz.Canvas.LineTo(round(x2+pnjg),y1-40);

rz.Canvas.LineTo(round(x2+pnjg),y1-1);

rz.Canvas.LineTo(round(x2+2*pnjg),y1-1);

nrzl.Canvas.LineTo(x2,y1+40);

nrzl.Canvas.LineTo(round(x2+pnjg*2),y1+40); //NRZL

if tnd1=0 then begin //NRZI

nrzi.Canvas.MoveTo(x2,y1+40);

nrzi.Canvas.LineTo(x2,y1-40);

nrzi.Canvas.LineTo(round(x2+pnjg*2),y1-40);

tnd1:=1;

end

else begin

nrzi.Canvas.MoveTo(x2,y1-40);

nrzi.Canvas.LineTo(x2,y1+40);

nrzi.Canvas.LineTo(round(x2+pnjg*2),y1+40);

tnd1:=0;

end;

if tnd2=0 then begin //AMI

ami.Canvas.MoveTo(x2,y1);

ami.Canvas.LineTo(x2,y1+40);
ami.Canvas.LineTo(round(x2+pnjg*2),y1+40);

ami.Canvas.LineTo(round(x2+pnjg*2),y1);

tnd2:=1;

end

else begin

ami.Canvas.MoveTo(x2,y1);

ami.Canvas.LineTo(x2,y1-40);

ami.Canvas.LineTo(round(x2+pnjg*2),y1-40);

ami.Canvas.LineTo(round(x2+pnjg*2),y1);

tnd2:=0;

end;

manc.Canvas.MoveTo(x2,y1-1); //MANC

manc.Canvas.LineTo(x2,y1+40);

manc.Canvas.LineTo(round(x2+pnjg),y1+40);

manc.Canvas.LineTo(round(x2+pnjg),y1-1);

manc.Canvas.LineTo(round(x2+2*pnjg),y1-1);

dm.Canvas.LineTo(x2,y1-40); //DMANC

dm.Canvas.LineTo(round(x2+pnjg),y1-40);

dm.Canvas.LineTo(round(x2+pnjg),y1+40);

dm.Canvas.LineTo(round(x2+2*pnjg),y1+40);

if tnd2=0 then begin //HDB3

hdb.Canvas.MoveTo(x2,y1+1);

hdb.Canvas.LineTo(x2,y1+40);

hdb.Canvas.LineTo(round(x2+2*pnjg),y1+40);

hdb.Canvas.LineTo(round(x2+2*pnjg),y1+40);

hdb.Canvas.LineTo(round(x2+2*pnjg),y1-1);

tnd2:=1;

end

else begin

hdb.Canvas.MoveTo(x2,y1-1);

hdb.Canvas.LineTo(x2,y1-40);
hdb.Canvas.LineTo(round(x2+2*pnjg),y1-40);

hdb.Canvas.LineTo(round(x2+2*pnjg),y1-40);

hdb.Canvas.LineTo(round(x2+2*pnjg),y1+1);

tnd2:=0;

end;

if tnd2=0 then begin

b.Canvas.MoveTo(x2,y1-1);

b.Canvas.LineTo(x2,y1-40);

b.Canvas.LineTo(round(x2+2*pnjg),y1-40);

b.Canvas.LineTo(round(x2+2*pnjg),y1-40);

b.Canvas.LineTo(round(x2+2*pnjg),y1-1);

tnd2:=1;

end

else begin

b.Canvas.MoveTo(x2,y1+1);

b.Canvas.LineTo(x2,y1+40);

b.Canvas.LineTo(round(x2+2*pnjg),y1+40);

b.Canvas.LineTo(round(x2+2*pnjg),y1+40);

b.Canvas.LineTo(round(x2+2*pnjg),y1-1);

tnd2:=0;

end;

end

//..............JIKA i = NOL..............

else begin

x2:=round((2*i*pnjg)-(2*pnjg));

uni.Canvas.LineTo(x2,y1); //UNIPOLAR

uni.Canvas.LineTo(round(x2+pnjg*2),y1);

rz.Canvas.MoveTo(x2,y1-1);

rz.Canvas.LineTo(x2,y1+40); //RZ

rz.Canvas.LineTo(round(x2+pnjg),y1+40);

rz.Canvas.LineTo(round(x2+pnjg),y1-1);
rz.Canvas.LineTo(round(x2+2*pnjg),y1-1);

nrzl.Canvas.LineTo(x2,y1-40); //NRZL

nrzl.Canvas.LineTo(round(x2+pnjg*2),y1-40);

if tnd1=0 then

nrzi.Canvas.LineTo(round(x2+pnjg*2),y1+40) //NRZI

else nrzi.Canvas.LineTo(round(x2+pnjg*2),y1-40);

ami.Canvas.MoveTo(x2,y1); //AMI

ami.Canvas.LineTo(round(x2+pnjg*2),y1);

manc.Canvas.MoveTo(x2,y1-1);

manc.Canvas.LineTo(x2,y1-40); //MANC

manc.Canvas.LineTo(round(x2+pnjg),y1-40);

manc.Canvas.LineTo(round(x2+pnjg),y1-1);

manc.Canvas.LineTo(round(x2+2*pnjg),y1-1);

dm.Canvas.LineTo(x2,y1+40); //DMANC

dm.Canvas.LineTo(round(x2+pnjg),y1+40);

dm.Canvas.LineTo(round(x2+pnjg),y1-40);

dm.Canvas.LineTo(round(x2+2*pnjg),y1-40);

if tnd2=0 then //HDB3

hdb.Canvas.MoveTo(x2,y1-1)

else hdb.Canvas.LineTo(round(x2+pnjg*2),y1-1);

if tnd2=0 then

b.Canvas.MoveTo(x2,y1-1)

else b.Canvas.LineTo(round(x2+pnjg*2),y1-1);

end;

end;

end;

end;

procedure Tfrmsinyal.keluarClick(Sender: TObject);

begin

frmsinyal.Close;

end;
end.

You might also like