Вы находитесь на странице: 1из 7

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;

ami.Picture:=nil; //AMI

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

ami.Canvas.Pen.Color:=clblue;

manch.Picture:=nil;

sumbu(manch,x1,y1,400,80); //M

manch.Canvas.Pen.Color:=clblue;

b.Picture:=nil; //HDB3

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

end

else begin
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;

manch.Canvas.LineTo(x2,y1+40); //MANC

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

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

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

if tnd2=0 then begin //B8Z5

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;

if tnd2=0 then begin

tnd2:=1;

end

else begin

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

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

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

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

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

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

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

if tnd2=0 then //B8Z5


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

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

if tnd2=0 then

end;

end;

end;

end;

procedure Tfrmsinyal.Button1Click(Sender: TObject);

begin

frmsinyal.Close;

end;

end.

Вам также может понравиться