Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
19
Добавлен:
30.03.2015
Размер:
69.32 Кб
Скачать
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, ComCtrls, Buttons, ExtDlgs, ImgList,
DBCtrls, MPlayer;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N5: TMenuItem;
F11: TMenuItem;
N6: TMenuItem;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
UpDown1: TUpDown;
Edit1: TEdit;
Panel8: TPanel;
Panel9: TPanel;
Panel10: TPanel;
Panel11: TPanel;
cbMex1: TComboBox;
cbMex2: TComboBox;
cbMex3: TComboBox;
cbMex4: TComboBox;
cbOutput1: TEdit;
cbOutput2: TEdit;
mmOutput: TListBox;
play: TSpeedButton;
stop: TSpeedButton;
Image1: TImage;
Image2: TImage;
Image3: TImage;
Image4: TImage;
Timer2: TTimer;
SPA: TSpeedButton;
SPB: TSpeedButton;
SPC: TSpeedButton;
SPD: TSpeedButton;
Next: TSpeedButton;
ImageList1: TImageList;
ImageList2: TImageList;
paus: TSpeedButton;
Image5: TImage;
ImageList3: TImageList;
ImageList4: TImageList;
ImageList5: TImageList;
Image6: TImage;
Image7: TImage;
N7: TMenuItem;
N8: TMenuItem;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N2: TMenuItem;
P1: TPanel;
P2: TPanel;
P3: TPanel;
P4: TPanel;
P5: TPanel;
P6: TPanel;
P7: TPanel;
P8: TPanel;
P9: TPanel;
bbOutputF: TButton;
procedure bbOutputFClick(Sender: TObject);
procedure cbMex1Change(Sender: TObject);
procedure cbMex2Change(Sender: TObject);
procedure cbMex3Change(Sender: TObject);
procedure dubler(Sender: TObject);
procedure cbMex4Change(Sender: TObject);
procedure vivod(Sender: TObject);
procedure ABCD(Sender: TObject);
procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);
procedure mmOutputDblClick(Sender: TObject);
procedure playClick(Sender: TObject);
procedure uravfun(Sender: TObject);
procedure funA(Sender: TObject);
procedure funUP(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure funnA(Sender: TObject);
procedure resh(Sender: TObject);
procedure stopClick(Sender: TObject);
procedure fun1(Sender: TObject);
procedure fun2(Sender: TObject);
procedure fun3(Sender: TObject);
procedure fun4(Sender: TObject);
procedure fun5(Sender: TObject);
procedure fun6(Sender: TObject);
procedure fun7(Sender: TObject);
procedure fun8(Sender: TObject);
procedure fun9(Sender: TObject);
procedure fun10(Sender: TObject);
procedure fun11(Sender: TObject);
procedure fun12(Sender: TObject);
procedure SPAClick(Sender: TObject);
procedure SPBClick(Sender: TObject);
procedure SPCClick(Sender: TObject);
procedure SPDClick(Sender: TObject);
procedure SP(Sender: TObject);
procedure NextClick(Sender: TObject);
procedure pausClick(Sender: TObject);
procedure funTA(Sender: TObject);
procedure funTnA(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure f11Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure N2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Save,Open:TextFile;
TP:integer;
Hfile:THandle;
zn,nz,nz1,mex:array [1..9] of integer;
u,u1,u2:array [1..4,1..5] of integer;
s,uslin:array [0..50] of boolean;
usl1:array [1..3] of boolean;
Form1: TForm1;
ind,ind1,ind2,ind3,ind4: integer;
g,i,j,a,b,c,d,e,k,z,n,m,max,max1,nez,pe,ur,urs: integer;
cod1,cod2,cod3,cod4,top:integer;
x:TObject;
usl,usld,c1,r,uslv,uslv1,uslr,indiv,Err,nex:boolean;
bot:TUDBtnType;
st,st1,st2,ne,alg,load,nam:string;
zu:TImage;
cuc:TImage;
zu1:TPicture;

implementation

uses Unit2, Unit3, Unit4, Unit5;

{$R *.dfm}

procedure TForm1.bbOutputFClick(Sender: TObject);
begin
if bbOutputF.Caption='Сброс'then
begin
bbOutputF.Caption:='Ввод';
cbMex1.ItemIndex:=0;
cbMex2.ItemIndex:=0;
cbMex3.ItemIndex:=0;
cbMex4.ItemIndex:=0;
edit1.Text:='0';
indiv:=true;
usld:=true;
dubler(x);
mmOutput.Enabled:=true;
cbMex1.Enabled:=true;
cbMex2.Enabled:=true;
cbMex3.Enabled:=true;
cbMex4.Enabled:=true;
UpDown1.Enabled:=true;
SPA.Enabled:=true;
SPB.Enabled:=true;
SPC.Enabled:=true;
SPD.Enabled:=true;
end
else
begin
unit2.i:=1;
ABCD(x);
if Form2.ShowModal=mrCancel then;
end;
end;

procedure TForm1.cbMex1Change(Sender: TObject);
begin
k:=cbMex1.ItemIndex;
if indiv then
begin
vivod(x);
u1[1,1]:=ind;
u1[1,2]:=ind1;
u1[1,3]:=ind2;
u1[1,4]:=ind4;
SPAClick(x);
end;
if cbMex1.ItemIndex<>mex[1] then
begin
indiv:=true;
uslD:=true;
mex[1]:=cbMex1.ItemIndex;
cbOutput1.Clear;
mmOutput.items.Clear;
dubler(x);
play.Enabled:=false;
next.Enabled:=false;
f11.Enabled:=false;
n6.Enabled:=false;
N8.Enabled:=false;
Unit2.open:=false;
Unit3.open:=false;
unit3.op:=0;
end;
ABCD(x);
end;

procedure TForm1.cbMex2Change(Sender: TObject);
begin
k:=cbMex2.ItemIndex;
if indiv then
begin
vivod(x);
u1[2,1]:=ind;
u1[2,2]:=ind1;
u1[2,3]:=ind2;
u1[2,4]:=ind4;
SPBClick(x);
end;
if cbMex2.ItemIndex<>mex[2] then
begin
indiv:=true;
uslD:=true;
mex[2]:=cbMex2.ItemIndex;
cbOutput1.Clear;
mmOutput.items.Clear;
dubler(x);
play.Enabled:=false;
next.Enabled:=false;
f11.Enabled:=false;
n6.Enabled:=false;
N8.Enabled:=false;
Unit2.open:=false;
Unit3.open:=false;
unit3.op:=0;
end;
ABCD(x);
end;

procedure TForm1.cbMex3Change(Sender: TObject);
begin
k:=cbMex3.ItemIndex;
if indiv then
begin
vivod(x);
u1[3,1]:=ind;
u1[3,2]:=ind1;
u1[3,3]:=ind2;
u1[3,4]:=ind4;
SPCClick(x);
end;
if cbMex3.ItemIndex<>mex[3] then
begin
indiv:=true;
uslD:=true;
mex[3]:=cbMex3.ItemIndex;
cbOutput1.Clear;
mmOutput.items.Clear;
dubler(x);
play.Enabled:=false;
next.Enabled:=false;
f11.Enabled:=false;
n6.Enabled:=false;
N8.Enabled:=false;
Unit2.open:=false;
Unit3.open:=false;
unit3.op:=0;
end;
ABCD(x);
end;

procedure TForm1.cbMex4Change(Sender: TObject);
begin
k:=cbMex4.ItemIndex;
if indiv then
begin
vivod(x);
u1[4,1]:=ind;
u1[4,2]:=ind1;
u1[4,3]:=ind2;
u1[4,4]:=ind4;
SPDClick(x);
end;
if cbMex4.ItemIndex<>mex[4]then
begin
indiv:=true;
uslD:=true;
mex[4]:=cbMex4.ItemIndex;
cbOutput1.Clear;
mmOutput.items.Clear;
dubler(x);
play.Enabled:=false;
next.Enabled:=false;
f11.Enabled:=false;
n6.Enabled:=false;
N8.Enabled:=false;
Unit2.open:=false;
Unit3.open:=false;
unit3.op:=0;
end;

k:=0;
ABCD(x);
end;

procedure TForm1.dubler(Sender: TObject);
begin
if uslD then
for j:=0 to 5 do
for i:=0 to 12 do
form3.tabl.Cells[i,j]:='';
for i:=0 to 9 do
s[i]:=false;
if usld then
for i:=0 to 21 do
for j:=0 to 50 do
unit3.oper[i,j]:=0;
i:=0;
j:=0;
g:=1;
ind:=0;
ind1:=0;
ind2:=0;
ind3:=0;
ind4:=0;
cbMex1Change(x);
inc(g);
cbMex2Change(x);
inc(g);
cbMex3Change(x);
inc(g);
cbMex4Change(x);
UpDown1Click(x,bot);
indiv:=false;
end;

procedure TForm1.vivod(Sender: TObject);
begin
case k of
0: begin
c:=0;
end;
1: Begin
inc(ind);
if usld then
c:=mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
end;
2: Begin
inc(ind);
if usld then
c:=mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
end;
3: Begin
inc(ind);
if usld then
c:=mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
inc(ind2);
form3.tabl.Cells[i,j]:='SP'+inttostr(ind2);
nz1[ind2]:=ind3;
inc(i);
inc(ind3);

end;
4: Begin
inc(ind);
if usld then
c:=mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
inc(ind);
if usld then
mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
end;
5: Begin
inc(ind);
if usld then
c:=mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
inc(ind);
if usld then
mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
end;
6: Begin
inc(ind);
if usld then
c:=mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind2);
form3.tabl.Cells[i,j]:='SP'+inttostr(ind2);
nz1[ind2]:=ind3;
inc(i);
inc(ind3);
inc(ind2);
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
form3.tabl.Cells[i,j]:='SP'+inttostr(ind2);
nz1[ind2]:=ind3;
inc(i);
inc(ind3);
end;
7: Begin
inc(ind1);
if usld then
c:=mmOutput.items.Add('K'+inttostr(ind1)+'=');
s[ind3]:=true;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
end;
8: Begin
inc(ind1);
if usld then
c:=mmOutput.items.Add('K'+inttostr(ind1)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
end;
9: Begin
inc(ind1);
if usld then
c:=mmOutput.items.Add('K'+inttostr(ind1)+'=');
inc(ind);
if usld then
mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
end;
10: Begin
inc(ind1);
if usld then
c:=mmOutput.items.Add('K'+inttostr(ind1)+'=');
s[ind3]:=true;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
inc(ind1);
if usld then
mmOutput.items.Add('K'+inttostr(ind1)+'=');
end;
11: Begin
inc(ind1);
if usld then
c:=mmOutput.items.Add('K'+inttostr(ind1)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind1);
if usld then
mmOutput.items.Add('K'+inttostr(ind1)+'=');
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
inc(ind3);
end;
12: Begin
inc(ind1);
if usld then
c:=mmOutput.items.Add('K'+inttostr(ind1)+'=');
inc(ind);
if usld then
mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=true;
if uslin[g-1] then
s[ind3]:=false;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
inc(ind);
if usld then
mmOutput.items.Add('Y'+inttostr(ind)+'=');
s[ind3]:=false;
if uslin[g-1] then
s[ind3]:=true;
inc(ind4);
form3.tabl.Cells[i,j]:='S'+inttostr(ind4);
nz[ind4]:=ind3;
inc(i);
inc(ind3);
end;
end;

end;

procedure TForm1.ABCD(Sender: TObject);
begin
if cbMex1.ItemIndex<>0 Then
begin
Form2.bbOutputA.Enabled:=true;
Form2.bbOutputnA.Enabled:=true;
Unit2.ok1:=False;
Unit2.ok2:=False;
end
else
begin
Form2.bbOutputA.Enabled:=False;
Form2.bbOutputnA.Enabled:=False;
Unit2.ok1:=True;
Unit2.ok2:=True;
end;
if cbMex2.ItemIndex<>0 Then
begin
Form2.bbOutputB.Enabled:=true;
Form2.bbOutputnB.Enabled:=true;
Unit2.ok3:=False;
Unit2.ok4:=False;
end
else
begin
Form2.bbOutputB.Enabled:=False;
Form2.bbOutputnB.Enabled:=False;
Unit2.ok3:=True;
Unit2.ok4:=True;
end;
if cbMex3.ItemIndex<>0 Then
begin
Form2.bbOutputC.Enabled:=true;
Form2.bbOutputnC.Enabled:=true;
Unit2.ok5:=False;
Unit2.ok6:=False;
end
else
begin
Form2.bbOutputC.Enabled:=False;
Form2.bbOutputnC.Enabled:=False;
Unit2.ok5:=True;
Unit2.ok6:=True;
end;
if cbMex4.ItemIndex<>0 Then
begin
Form2.bbOutputD.Enabled:=true;
Form2.bbOutputnD.Enabled:=true;
Unit2.ok7:=False;
Unit2.ok8:=False;
end
else
begin
Form2.bbOutputD.Enabled:=False;
Form2.bbOutputnD.Enabled:=False;
Unit2.ok7:=True;
Unit2.ok8:=True;
end;
end;

procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
max:=0;
n:=i-1;
m:=0;
P1.Visible:=false;P2.Visible:=false;P3.Visible:=false;P4.Visible:=false;
P5.Visible:=false;P6.Visible:=false;P7.Visible:=false;P8.Visible:=false;
P9.Visible:=false;
if UpDown1.position <> 0 then
if indiv then
begin
While max<>UpDown1.position do
begin
inc(n);
max:=max+1;
if usld then
mmOutput.items.Add('P'+inttostr(max)+'=');
case max of
1:P1.Visible:=true;
2:P2.Visible:=true;
3:P3.Visible:=true;
4:P4.Visible:=true;
5:P5.Visible:=true;
6:P6.Visible:=true;
7:P7.Visible:=true;
8:P8.Visible:=true;
9:P9.Visible:=true;
end;

form3.tabl.Cells[n,j]:='P'+inttostr(max);
s[ind3]:=false;
zn[max]:=ind3;
inc(ind3);
if n>10 then
inc(j);
if n>10 then
n:=-1;
end;
end;
if UpDown1.position<>mex[5] then
begin
indiv:=true;
uslD:=true;
mex[5]:=UpDown1.position;
mmOutput.items.Clear;
cbOutput1.Clear;
dubler(x);
play.Enabled:=false;
next.Enabled:=false;
f11.Enabled:=false;
n6.Enabled:=false;
N8.Enabled:=false;
Unit2.open:=false;
Unit3.open:=false;
unit3.op:=0;
end;
end;

procedure TForm1.mmOutputDblClick(Sender: TObject);
begin
nez:=0;
Form3.Edit1.Text:=mmOutput.Items[mmOutput.ItemIndex];
if Form3.ShowModal=mrCancel then;
end;

procedure TForm1.playClick(Sender: TObject);
begin

n2.Enabled:=true;
N8.Enabled:=true;
if not(stop.Enabled) then
begin
rewrite(save);
if not(stop.Enabled) then
begin
For i:=1 to 4 do
writeln(save,mex[i]);
writeln(save,max);
writeln(save,cbOutput1.text);
for i:=0 to mmOutput.Count-1 do
begin
writeln(save,mmOutput.items[i]);
for j:=0 to 49 do
begin
writeln(save,unit3.oper[i,j]);
end;
end;

end;
end;

Err:=false;
indiv:=true;
if not(stop.Enabled) then
begin
uslD:=false;
dubler(x);
g:=0;
end;
stop.Enabled:=true;
Paus.Enabled:=true;
play.Enabled:=false;
f11.Enabled:=false;
N6.Enabled:=true;
bbOutputF.Enabled:=false;
mmOutput.Enabled:=false;
cbMex1.Enabled:=false;
cbMex2.Enabled:=false;
cbMex3.Enabled:=false;
cbMex4.Enabled:=false;
UpDown1.Enabled:=false;
SPA.Enabled:=false;
SPB.Enabled:=false;
SPC.Enabled:=false;
SPD.Enabled:=false;

a:=0;
i:=-1;
st:=cbOutput1.Text+'-';
if cbMex1.ItemIndex<>0 then
begin
alg:='A';
k:=cbMex1.ItemIndex;
zu:=image1;
b:=1;
a:=1;
inc(i);
resh(x);
if Err then
begin
g:=MessageDlg('Недопустимое состояние '+st1+' механизма A',MtError,[mbOk],0);
exit;
end;
end;

if cbMex2.ItemIndex<>0 then
begin
alg:='B';
k:=cbMex2.ItemIndex;
zu:=image2;
b:=2;
a:=2;
inc(i);
resh(x);
if Err then
begin
g:=MessageDlg('Недопустимое состояние '+st1+' механизма B',MtError,[mbOk],0);
exit;
end;
end;

if cbMex3.ItemIndex<>0 then
begin
alg:='C';
k:=cbMex3.ItemIndex;
zu:=image3;
b:=3;
a:=3;
inc(i);
resh(x);
if Err then
begin
g:=MessageDlg('Недопустимое состояние '+st1+' механизма C',MtError,[mbOk],0);
exit;
end;
end;

if cbMex4.ItemIndex<>0 then
begin
alg:='D';
k:=cbMex4.ItemIndex;
zu:=image4;
b:=4;
a:=4;
inc(i);
resh(x);
if Err then
begin
g:=MessageDlg('Недопустимое состояние '+st1+' механизма D',MtError,[mbOk],0);
exit;
end;
end;


if UpDown1.position<>0 then
begin
inc(i);
funUP(x);
end;



if ((not(paus.Down))and(play.Down))or(nex) then
timer2.Enabled:=true;
end;

procedure TForm1.resh(Sender: TObject);
begin
if mmOutput.Count>i then
case k of
0: g:=1;
1:fun1(x);
2:fun2(x);
3:fun3(x);
4:fun4(x);
5:fun5(x);
6:fun6(x);
7:fun7(x);
8:fun8(x);
9:fun9(x);
10:fun10(x);
11:fun11(x);
12:fun12(x);
end;
end;

procedure TForm1.uravfun(Sender: TObject);
begin
urs:=0;
for n:=0 to 50 do
if (unit3.oper[i,n]>20)and(unit3.oper[i,n]<100) then
if urs<unit3.oper[i,n] then
urs:=unit3.oper[i,n];
if urs<>0 then
repeat
for n:=0 to 50 do
if urs=unit3.oper[i,n] then
break;
inc(n);

repeat
ur:=unit3.oper[i,n];
if ur=100 then
r:=false
else
if ur=200 then
r:=true
else
r:=s[ur];
inc(n);
ur:=unit3.oper[i,n];
if ur=250 then
begin
r:=not(r);
inc(n);
ur:=unit3.oper[i,n];
end;
if ur=230 then repeat
inc(n);
ur:=unit3.oper[i,n];
if ur=100 then
c1:=false
else
if ur=200 then
c1:=true
else
c1:=s[ur];
inc(n);
ur:=unit3.oper[i,n];
if ur=250 then
begin
c1:=not(c1);
inc(n);
ur:=unit3.oper[i,n];
end;
r:=r and c1;
until not(ur=230);
if ur=urs then break;
if ur=240 then usl:=usl or r;
inc(n);
until false;
r:=r or usl;
s[urs]:=r;
dec(urs);
until urs=20;


ur:=0;
n:=0;
usl:=false;
repeat
ur:=unit3.oper[i,n];
urs:=n+1;
if (ur>20)and(ur<100) then
for n:=urs to 50 do
if ur=unit3.oper[i,n] then
break;
if ur=100 then
r:=false
else
if ur=200 then
r:=true
else
r:=s[ur];
inc(n);
ur:=unit3.oper[i,n];
if ur=250 then begin
r:=not(r);
inc(n);
ur:=unit3.oper[i,n];
end;
if ur=230 then repeat
inc(n);
ur:=unit3.oper[i,n];
urs:=n+1;
if (ur>20)and(ur<100) then
for n:=urs to 50 do
if ur=unit3.oper[i,n] then
break;
if ur=100 then
c1:=false
else
if ur=200 then
c1:=true
else
c1:=s[ur];
inc(n);
ur:=unit3.oper[i,n];
if ur=250 then
begin
c1:=not(c1);
inc(n);
ur:=unit3.oper[i,n];
end;
r:=r and c1;
until not(ur=230);
if ur=252 then break;
if ur=240 then usl:=usl or r;
inc(n);
until false;
r:=r or usl;

end;

procedure TForm1.FormActivate(Sender: TObject);
begin
image1.Picture.LoadFromFile('Нет.bmp');
image2.Picture.LoadFromFile('Нет.bmp');
image3.Picture.LoadFromFile('Нет.bmp');
image4.Picture.LoadFromFile('Нет.bmp');
AssignFile(Save,'test.txt');
if Form5.ShowModal=mrCancel then;
end;





procedure TForm1.stopClick(Sender: TObject);
begin
closeFile(Save);
cbOutput2.Clear;
play.Down:=false;
indiv:=true;
dubler(x);
play.Enabled:=true;
bbOutputF.Enabled:=true;
paus.Enabled:=false;
Next.Enabled:=true;
stop.Enabled:=false;
f11.Enabled:=true;
n6.Enabled:=false;
//n4.Enabled:=true;
timer2.Enabled:=false;
if st=st2 then
g:=MessageDlg('Заданный алгоритм успешно реализован',MtInformation,[mbOk],0)
else
mmOutput.Enabled:=true;
end;

procedure TForm1.fun1(Sender: TObject);
begin

uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if r then
begin
if u[a,1]<>65 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,1]=65 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe+1]:=true;
end;
end;
end
else
begin
if u[a,1]<>25 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe+1]:=false;
if u[a,1]=25 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=true;
end;
end;
end;
end;



procedure TForm1.fun2(Sender: TObject);
begin

uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if r then
begin
if u[a,1]<>60 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,1]=60 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe]:=true;
end;
end;
end
else
begin
if u[a,1]<>20 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
zu.Visible:=false;
zu.Visible:=true;
s[pe]:=false;
if u[a,1]=20 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=true;
end;
end;
end;
end;

procedure TForm1.fun3(Sender: TObject);
begin

uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if r then
begin
if u[a,1]<>65 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
//s[pe]:=false;
if u[a,1]=65 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe]:=true;
end;
end;
end
else
begin
if u[a,1]<>25 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
zu.Visible:=false;
zu.Visible:=true;

if u[a,1]=25 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=false;
end;
end;
end;

end;

procedure TForm1.fun4(Sender: TObject);
begin

uravfun(x);
uslv:=r;
inc(i);
uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if uslv then
if u[a,1]<>62 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
zu.Visible:=false;
zu.Visible:=true;
s[pe]:=false;
if u[a,1]=62 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe+1]:=true;
end;
end;


if r then
if u[a,1]<>22 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe+1]:=false;
if u[a,1]=22 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=true;
end;
end;
if not(uslv)and(not(r)) then
begin
imageList3.Draw(image5.Canvas,0,-64,0,true);
zu.Canvas.Draw(18,90,image5.Picture.Bitmap);
imageList3.Draw(image5.Canvas,0,-64,0,true);
zu.Canvas.Draw(106,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,165,126,u1[a,1]+20,true);
imageList4.Draw(zu.Canvas,77,126,u1[a,1]+19,true);
end;

if (uslv)and(r) then
begin
Err:=true;
st1:='электромагнитов Y';
imageList3.Draw(image5.Canvas,0,-96,0,true);
zu.Canvas.Draw(18,90,image5.Picture.Bitmap);
imageList3.Draw(image5.Canvas,0,-96,0,true);
zu.Canvas.Draw(106,90,image5.Picture.Bitmap);
imageList5.Draw(zu.Canvas,77,126,u1[a,1]+19,true);
imageList5.Draw(zu.Canvas,165,126,u1[a,1]+20,true);
end;
end;

procedure TForm1.fun5(Sender: TObject);
begin

uravfun(x);
uslv:=r;
inc(i);
uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if uslv then
if u[a,1]<>65 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,1]=65 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe+1]:=true;
end;
end;

if r then
if u[a,1]<>25 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe+1]:=false;
if u[a,1]=25 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=true;
end;
end;

if not(uslv)and(not(r)) then
begin
imageList4.Draw(zu.Canvas,20,118,u1[a,1]+19,true);
imageList4.Draw(zu.Canvas,110,118,u1[a,1]+20,true);
zu.Visible:=false;
zu.Visible:=true;
end;

if (uslv)and(r) then
begin
Err:=true;
st1:='электромагнитов Y';
imageList3.Draw(image5.Canvas,0,-32,0,true);
zu.Canvas.Draw(44,90,image5.Picture.Bitmap);
imageList5.Draw(zu.Canvas,121,77,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,20,118,u1[a,1]+19,true);
imageList5.Draw(zu.Canvas,110,118,u1[a,1]+20,true);
end;
end;

procedure TForm1.fun6(Sender: TObject);
begin
uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if r then
begin
if u[a,1]<>67 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,1]=67 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe+1]:=true;
end;
end;
end
else
begin
if u[a,1]<>27 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe+1]:=false;
if u[a,1]=27 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=true;
end;
end;
end;
end;

procedure TForm1.fun7(Sender: TObject);
begin

uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if r then
begin
funA(x);
if u[a,5]<=10 then
begin
u[a,2]:=u[a,2]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]-1,7,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],7,true);
u[a,4]:=u[a,4]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]+1,11,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],11,true);
end;
if (u[a,5]<22)and(u[a,5]>10) then
begin
u[a,2]:=u[a,2]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]+1,7,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],7,true);
u[a,4]:=u[a,4]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]-1,11,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],11,true);
end;
u[a,5]:=u[a,5]+1;
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,2]=u[a,4] then
begin
if usl1[1] then
begin
usl1[1]:=false;
cbOutput2.Text:=cbOutput2.Text+alg;
funTA(x);
end
else
begin
usl1[1]:=true;
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
funTA(x);
end;
s[pe]:=true;
u[a,5]:=0;
end;
end;


if not(r) then
begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(20,92,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,55,82,u1[a,2]+28,true);
end;
end;

procedure TForm1.fun8(Sender: TObject);
begin

uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if (r)and(usl1[2]) then
begin
funA(x);
if u[a,5]=0 then
u[a,4]:=u[a,2];
if u[a,5]<=8 then
begin
u[a,2]:=u[a,2]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]-1,10,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],10,true);
u[a,4]:=u[a,4]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]+1,8,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],8,true);
end;
if u[a,5]=11 then
imageList2.Draw(zu.Canvas,u[a,1],u[a,4],8,true);
if (u[a,5]<21)and(u[a,5]>10) then
begin
if u[a,5]=11 then
u[a,2]:=u[a,2]-3;
u[a,2]:=u[a,2]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]+1,7,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],7,true);
if u[a,5]=11 then
u[a,4]:=u[a,4]-5;
u[a,4]:=u[a,4]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]-1,9,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],9,true);
end;
u[a,5]:=u[a,5]+1;
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,5]=21 then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
funTA(x);
zu.Visible:=false;
zu.Visible:=true;
s[pe+1]:=true;
u[a,5]:=0;
usl1[2]:=false;
r:=false;
end;
end;

if (r)and(not(usl1[2])) then
begin
funnA(x);
if u[a,5]=0 then
u[a,4]:=u[a,2];
if u[a,5]<=8 then
begin
u[a,2]:=u[a,2]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]-1,7,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],7,true);
u[a,4]:=u[a,4]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]+1,9,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],9,true);
end;
if u[a,5]=11 then
imageList2.Draw(zu.Canvas,u[a,1],u[a,2],7,true);
if (u[a,5]<20)and(u[a,5]>10) then
begin
if u[a,5]=11 then
u[a,2]:=u[a,2]+4;
u[a,2]:=u[a,2]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]+1,10,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],10,true);
if u[a,5]=11 then
u[a,4]:=u[a,4]+3;
u[a,4]:=u[a,4]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]-1,8,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],8,true);
end;
u[a,5]:=u[a,5]+1;
//zu.Visible:=false;
//zu.Visible:=true;
s[pe+1]:=false;
if u[a,5]=20 then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
funTnA(x);
s[pe]:=true;
u[a,5]:=0;
usl1[2]:=true;
r:=false;
end;
end;


if not(r) then
begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(20,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,56,92,u1[a,2]+28,true);
end;

end;

procedure TForm1.fun9(Sender: TObject);
begin

uravfun(x);
uslv:=r;
inc(i);
uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if uslv then
begin
if (r)and(usl1[3]) then
begin
funA(x);
if u[a,5]=0 then
u[a,4]:=u[a,2];
if u[a,5]<=8 then
begin
u[a,2]:=u[a,2]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]-1,10,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],10,true);
u[a,4]:=u[a,4]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]+1,8,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],8,true);
end;
if u[a,5]=11 then
imageList2.Draw(zu.Canvas,u[a,1],u[a,4],8,true);
if (u[a,5]<21)and(u[a,5]>10) then
begin
if u[a,5]=11 then
u[a,2]:=u[a,2]-3;
u[a,2]:=u[a,2]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]+1,7,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],7,true);
if u[a,5]=11 then
u[a,4]:=u[a,4]-5;
u[a,4]:=u[a,4]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]-1,9,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],9,true);
end;
u[a,5]:=u[a,5]+1;
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,5]=21 then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
funTA(x);
s[pe+1]:=true;
u[a,5]:=0;
usl1[3]:=false;
r:=false;
end;
end;

if (r)and(not(usl1[3])) then
begin
funnA(x);
if u[a,5]=0 then
u[a,4]:=u[a,2];
if u[a,5]<=8 then
begin
u[a,2]:=u[a,2]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]-1,7,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],7,true);
u[a,4]:=u[a,4]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]+1,9,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],9,true);
end;
if u[a,5]=11 then
imageList2.Draw(zu.Canvas,u[a,1],u[a,2],7,true);
if (u[a,5]<20)and(u[a,5]>10) then
begin
if u[a,5]=11 then
u[a,2]:=u[a,2]+4;
u[a,2]:=u[a,2]-1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,2]+1,10,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],10,true);
if u[a,5]=11 then
u[a,4]:=u[a,4]+3;
u[a,4]:=u[a,4]+1;
imageList2.Draw(zu.Canvas,u[a,1],u[a,4]-1,8,true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,4],8,true);
end;
u[a,5]:=u[a,5]+1;
//zu.Visible:=false;
//zu.Visible:=true;
s[pe+1]:=false;
if u[a,5]=20 then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
funTnA(x);
s[pe]:=true;
u[a,5]:=0;
usl1[3]:=true;
r:=false;
end;
end;
end;

if not(uslv) then
begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(20,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,56,92,u1[a,2]+28,true);
end;

if not(r) then
begin
imageList4.Draw(zu.Canvas,70,36,u1[a,1]+20,true);
end;

end;

procedure TForm1.fun10(Sender: TObject);
begin

uravfun(x);
uslv:=r;
inc(i);
uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if uslv then
if u[a,1]<>138 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;

s[pe]:=false;
if u[a,1]=138 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe]:=true;
end;
end;

if r then
if u[a,1]<>106 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
zu.Visible:=false;
zu.Visible:=true;
s[pe]:=false;
if u[a,1]=106 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=true;
end;
end;

if not(uslv) then
begin
imageList3.Draw(image6.Canvas,-65,-68,0,true);
zu.Canvas.Draw(46,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,21,87,u1[a,2]+27,true);
end;

if not(r) then
begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(67,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,101,87,u1[a,2]+28,true);
end;

if (uslv)and(r) then
begin
Err:=true;
st1:='реле прямого и обратного движения K';
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(67,102,image6.Picture.Bitmap);
imageList3.Draw(image6.Canvas,-97,-68,0,true);
zu.Canvas.Draw(46,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,130,92,u1[a,4],true);
imageList5.Draw(zu.Canvas,21,87,u1[a,2]+27,true);
imageList5.Draw(zu.Canvas,101,87,u1[a,2]+28,true);
end;

end;

procedure TForm1.fun11(Sender: TObject);
begin

uravfun(x);
uslv:=r;
inc(i);
uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';

if uslv then
if u[a,1]<>133 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,1]=133 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe+1]:=true;
end;
end;

if r then
if u[a,1]<>101 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe+1]:=false;
if u[a,1]=101 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=true;
end;
end;

if not(uslv) then
begin
imageList3.Draw(image6.Canvas,-65,-68,0,true);
zu.Canvas.Draw(41,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,16,87,u1[a,2]+27,true);
end;

if not(r) then
begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(62,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,96,87,u1[a,2]+28,true);
end;

if (uslv)and(r) then
begin
Err:=true;
st1:='реле прямого и обратного движения K';
imageList3.Draw(image6.Canvas,-97,-68,0,true);
zu.Canvas.Draw(41,102,image6.Picture.Bitmap);
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(62,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,16,87,u1[a,2]+27,true);
imageList5.Draw(zu.Canvas,96,87,u1[a,2]+28,true);
end;

end;

procedure TForm1.fun12(Sender: TObject);
begin

uravfun(x);
uslv:=r;
inc(i);
uravfun(x);
uslv1:=r;
inc(i);
uravfun(x);
if (k<>2)and(k<>7)and(k<>10) then
pe:=nz[u1[b,4]-1]
else
pe:=nz[u1[b,4]];
if k=3 then
pe:=nz1[u1[b,3]];
if k=13 then
pe:=nz1[u1[b,3]-1];
if b=1 then
ne:='A';
if b=2 then
ne:='B';
if b=3 then
ne:='C';
if b=4 then
ne:='D';


if uslv then
begin
if uslv1 then
if u[a,1]<>138 then
begin
funA(x);
u[a,1]:=u[a,1]+1;
imageList2.Draw(zu.Canvas,u[a,1]-1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe]:=false;
if u[a,1]=138 then
//if not(uslin[a-1]) then
begin
cbOutput2.Text:=cbOutput2.Text+alg;
uslin[a-1]:=true;
funTA(x);
s[pe+1]:=true;
end;
end;

if r then
if u[a,1]<>106 then
begin
funnA(x);
u[a,1]:=u[a,1]-1;
imageList2.Draw(zu.Canvas,u[a,1]+1,u[a,2],u[a,3],true);
imageList1.Draw(zu.Canvas,u[a,1],u[a,2],u[a,3],true);
//zu.Visible:=false;
//zu.Visible:=true;
s[pe+1]:=false;
if u[a,1]=106 then
//if uslin[a-1] then
begin
cbOutput2.Text:=cbOutput2.Text+'n'+alg;
uslin[a-1]:=false;
funTnA(x);
s[pe]:=true;
end;
end;
end;

if not(uslv1) then
imageList4.Draw(zu.Canvas,55,17,u1[a,1]+19,true);

if not(r) then
imageList4.Draw(zu.Canvas,86,17,u1[a,1]+20,true);

if not(uslv) then
begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(10,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,63,87,u1[a,2]+28,true);
end;

if (uslv1)and(r) then
begin
Err:=true;
st1:='функций реверса Y';
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(10,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,135,102,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,55,17,u1[a,1]+19,true);
imageList5.Draw(zu.Canvas,86,17,u1[a,1]+20,true);
end;

zu.Visible:=false;
zu.Visible:=true;
end;

procedure TForm1.funUP(Sender: TObject);
begin
c:=1;
repeat
uravfun(x);
if r then
begin
s[zn[c]]:=true;
case c of
1:P1.Font.Color:=clred;
2:P2.Font.Color:=clred;
3:P3.Font.Color:=clred;
4:P4.Font.Color:=clred;
5:P5.Font.Color:=clred;
6:P6.Font.Color:=clred;
7:P7.Font.Color:=clred;
8:P8.Font.Color:=clred;
9:P9.Font.Color:=clred;
end;
inc(i);
end
else
begin
s[zn[c]]:=false;
case c of
1:P1.Font.Color:=clblack;
2:P2.Font.Color:=clblack;
3:P3.Font.Color:=clblack;
4:P4.Font.Color:=clblack;
5:P5.Font.Color:=clblack;
6:P6.Font.Color:=clblack;
7:P7.Font.Color:=clblack;
8:P8.Font.Color:=clblack;
9:P9.Font.Color:=clblack;
end;
inc(i);
end;
inc(c);
until mmOutput.Count=i;

end;

procedure TForm1.funA(Sender: TObject);
begin
case k of
0:begin
zu.Picture.LoadFromFile('Нет.bmp');
end;
1:begin
imageList3.Draw(image5.Canvas,0,-32,0,true);
zu.Canvas.Draw(44,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,121,77,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,20,87,u1[a,1]+20,true);
end;
2:begin
imageList3.Draw(image5.Canvas,0,-32,0,true);
zu.Canvas.Draw(44,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,141,77,u1[a,4],true);
imageList5.Draw(zu.Canvas,20,87,u1[a,1]+20,true);
end;
3:begin
imageList3.Draw(image5.Canvas,0,-32,0,true);
zu.Canvas.Draw(94,90,image5.Picture.Bitmap);
imageList5.Draw(zu.Canvas,75,126,u1[a,1]+20,true);
end;
4:begin
imageList3.Draw(image5.Canvas,0,-96,0,true);
zu.Canvas.Draw(18,90,image5.Picture.Bitmap);
imageList3.Draw(image5.Canvas,0,-64,0,true);
zu.Canvas.Draw(106,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,125,50,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,77,126,u1[a,1]+19,true);
imageList4.Draw(zu.Canvas,165,126,u1[a,1]+20,true);
end;
5:begin
imageList3.Draw(image5.Canvas,0,-32,0,true);
zu.Canvas.Draw(44,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,121,77,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,20,118,u1[a,1]+19,true);
imageList4.Draw(zu.Canvas,110,118,u1[a,1]+20,true);
end;
6:begin
imageList3.Draw(image6.Canvas,-65,-98,0,true);
zu.Canvas.Draw(142,82,image6.Picture.Bitmap);
imageList3.Draw(image5.Canvas,0,-32,0,true);
zu.Canvas.Draw(69,102,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,160,115,u1[a,3]+11,true);
imageList4.Draw(zu.Canvas,10,115,u1[a,3]+12,true);
imageList5.Draw(zu.Canvas,55,135,u1[a,1]+20,true);
end;
7:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(20,92,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,142,108,u1[a,4],true);
imageList5.Draw(zu.Canvas,55,82,u1[a,2]+28,true);
end;
8:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(20,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,149,102,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,56,92,u1[a,2]+28,true);
end;
9:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(20,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,149,102,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,70,36,u1[a,1]+20,true);
imageList5.Draw(zu.Canvas,56,92,u1[a,2]+28,true);
end;
10:begin
imageList3.Draw(image6.Canvas,-97,-68,0,true);
zu.Canvas.Draw(46,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,130,92,u1[a,4],true);
imageList5.Draw(zu.Canvas,21,87,u1[a,2]+27,true);
imageList4.Draw(zu.Canvas,101,87,u1[a,2]+28,true);
end;
11:begin
imageList3.Draw(image6.Canvas,-97,-68,0,true);
zu.Canvas.Draw(41,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,130,92,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,16,87,u1[a,2]+27,true);
imageList4.Draw(zu.Canvas,96,87,u1[a,2]+28,true);
end;
12:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(10,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,135,102,u1[a,4]-1,true);
imageList5.Draw(zu.Canvas,55,17,u1[a,1]+19,true);
imageList4.Draw(zu.Canvas,86,17,u1[a,1]+20,true);
imageList5.Draw(zu.Canvas,63,87,u1[a,2]+28,true);
end;
end;

end;

procedure TForm1.funnA(Sender: TObject);
begin
case k of
0:begin
zu.Picture.LoadFromFile('Нет.bmp');
end;
1:begin
imageList3.Draw(image5.Canvas,0,0,0,true);
zu.Canvas.Draw(44,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,161,77,u1[a,4],true);
imageList4.Draw(zu.Canvas,20,87,u1[a,1]+20,true);
end;
2:begin
imageList3.Draw(image5.Canvas,0,0,0,true);
zu.Canvas.Draw(44,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,141,77,u1[a,4],true);
imageList4.Draw(zu.Canvas,20,87,u1[a,1]+20,true);
end;
3:begin
imageList3.Draw(image5.Canvas,0,0,0,true);
zu.Canvas.Draw(94,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,75,126,u1[a,1]+20,true);
end;
4:begin
imageList3.Draw(image5.Canvas,0,-64,0,true);
zu.Canvas.Draw(18,90,image5.Picture.Bitmap);
imageList3.Draw(image5.Canvas,0,-96,0,true);
zu.Canvas.Draw(106,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,165,50,u1[a,4],true);
imageList4.Draw(zu.Canvas,77,126,u1[a,1]+19,true);
imageList5.Draw(zu.Canvas,165,126,u1[a,1]+20,true);
end;
5:begin
imageList3.Draw(image5.Canvas,0,0,0,true);
zu.Canvas.Draw(44,90,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,161,77,u1[a,4],true);
imageList4.Draw(zu.Canvas,20,118,u1[a,1]+19,true);
imageList5.Draw(zu.Canvas,110,118,u1[a,1]+20,true);
end;
6:begin
imageList3.Draw(image6.Canvas,-65,-2,0,true);
zu.Canvas.Draw(24,82,image6.Picture.Bitmap);
imageList3.Draw(image5.Canvas,0,0,0,true);
zu.Canvas.Draw(69,102,image5.Picture.Bitmap);
imageList4.Draw(zu.Canvas,160,115,u1[a,3]+11,true);
imageList4.Draw(zu.Canvas,10,115,u1[a,3]+12,true);
imageList4.Draw(zu.Canvas,55,135,u1[a,1]+20,true);
end;
7:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(20,92,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,142,108,u1[a,4],true);
imageList5.Draw(zu.Canvas,55,82,u1[a,2]+28,true);
end;
8:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(20,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,149,22,u1[a,4],true);
imageList5.Draw(zu.Canvas,56,92,u1[a,2]+28,true);
end;
9:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(20,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,149,22,u1[a,4],true);
imageList5.Draw(zu.Canvas,70,36,u1[a,1]+20,true);
imageList5.Draw(zu.Canvas,56,92,u1[a,2]+28,true);
end;
10:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(67,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,130,92,u1[a,4],true);
imageList4.Draw(zu.Canvas,21,87,u1[a,2]+27,true);
imageList5.Draw(zu.Canvas,101,87,u1[a,2]+28,true);
end;
11:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(62,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,163,92,u1[a,4],true);
imageList4.Draw(zu.Canvas,16,87,u1[a,2]+27,true);
imageList5.Draw(zu.Canvas,96,87,u1[a,2]+28,true);
end;
12:begin
imageList3.Draw(image6.Canvas,-97,-36,0,true);
zu.Canvas.Draw(10,102,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,160,102,u1[a,4],true);
imageList4.Draw(zu.Canvas,55,17,u1[a,1]+19,true);
imageList5.Draw(zu.Canvas,86,17,u1[a,1]+20,true);
imageList5.Draw(zu.Canvas,63,87,u1[a,2]+28,true);
end;
end;
end;

procedure TForm1.funTA(Sender: TObject);
begin
case k of
0:begin
zu.Picture.LoadFromFile('Нет.bmp');
end;
1:begin
imageList5.Draw(zu.Canvas,161,77,u1[a,4],true);
end;
2:begin
imageList5.Draw(zu.Canvas,141,77,u1[a,4],true);
end;
3:begin
imageList3.Draw(image6.Canvas,-97,-2,0,true);
zu.Canvas.Draw(33,92,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,10,126,u1[a,3]+12,true);
end;
4:begin
imageList5.Draw(zu.Canvas,165,50,u1[a,4],true);
end;
5:begin
imageList5.Draw(zu.Canvas,161,77,u1[a,4],true);
end;
6:begin
imageList3.Draw(image6.Canvas,-97,-2,0,true);
zu.Canvas.Draw(24,82,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,10,115,u1[a,3]+12,true);
end;
7:begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(20,92,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,142,108,u1[a,4],true);
imageList4.Draw(zu.Canvas,55,82,u1[a,2]+28,true);
end;
8:begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(20,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,149,22,u1[a,4],true);
imageList4.Draw(zu.Canvas,56,92,u1[a,2]+28,true);
end;
9:begin
imageList5.Draw(zu.Canvas,149,22,u1[a,4],true);
imageList4.Draw(zu.Canvas,70,36,u1[a,1]+20,true);
end;
10:begin
imageList3.Draw(image6.Canvas,-65,-68,0,true);
zu.Canvas.Draw(46,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,130,92,u1[a,4],true);
imageList4.Draw(zu.Canvas,21,87,u1[a,2]+27,true);
end;
11:begin
imageList3.Draw(image6.Canvas,-65,-68,0,true);
zu.Canvas.Draw(41,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,163,92,u1[a,4],true);
imageList4.Draw(zu.Canvas,16,87,u1[a,2]+27,true);
end;
12:begin
imageList5.Draw(zu.Canvas,160,102,u1[a,4],true);
imageList4.Draw(zu.Canvas,55,17,u1[a,1]+19,true);
end;
end;
nex:=false;
end;


procedure TForm1.funTnA(Sender: TObject);
begin
case k of
0:begin
zu.Picture.LoadFromFile('Нет.bmp');
end;
1:begin
imageList5.Draw(zu.Canvas,121,77,u1[a,4]-1,true);
end;
2:begin
imageList5.Draw(zu.Canvas,141,77,u1[a,4],true);
end;
3:begin
imageList3.Draw(image6.Canvas,-65,-2,0,true);
zu.Canvas.Draw(33,92,image6.Picture.Bitmap);
imageList4.Draw(zu.Canvas,10,126,u1[a,3]+12,true);
end;
4:begin
imageList5.Draw(zu.Canvas,125,50,u1[a,4]-1,true);
end;
5:begin
imageList5.Draw(zu.Canvas,121,77,u1[a,4]-1,true);
end;
6:begin
imageList3.Draw(image6.Canvas,-97,-98,0,true);
zu.Canvas.Draw(142,82,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,160,115,u1[a,3]+11,true);
end;
7:begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(20,92,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,142,108,u1[a,4],true);
imageList4.Draw(zu.Canvas,55,82,u1[a,2]+28,true);
end;
8:begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(20,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,149,102,u1[a,4]-1,true);
imageList4.Draw(zu.Canvas,56,92,u1[a,2]+28,true);
end;
9:begin
imageList5.Draw(zu.Canvas,149,102,u1[a,4]-1,true);
imageList4.Draw(zu.Canvas,70,36,u1[a,1]+20,true);
end;
10:begin
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(67,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,130,92,u1[a,4],true);
imageList4.Draw(zu.Canvas,101,87,u1[a,2]+28,true);
end;
11:begin;
imageList3.Draw(image6.Canvas,-65,-36,0,true);
zu.Canvas.Draw(62,102,image6.Picture.Bitmap);
imageList5.Draw(zu.Canvas,130,92,u1[a,4]-1,true);
imageList4.Draw(zu.Canvas,96,87,u1[a,2]+28,true);
end;
12:begin
imageList5.Draw(zu.Canvas,135,102,u1[a,4]-1,true);
imageList4.Draw(zu.Canvas,86,17,u1[a,1]+20,true);
end;
end;
nex:=false;
end;

procedure TForm1.SPAClick(Sender: TObject);
begin
a:=1;
c1:=SPA.Down;
k:=cbMex1.ItemIndex;
cuc:=image1;
zu:=image1;
if not(SPA.Down) then
begin
SPA.Caption:='A';
uslin[0]:=false;
uslin[4]:=false;
sp(X);
funnA(x);
funTnA(x);
end;
if SPA.Down then
begin
SPA.Caption:='nA';
uslin[0]:=true;
uslin[4]:=true;
SP(X);
funA(x);
funTA(x);
end;
end;

procedure TForm1.SPBClick(Sender: TObject);
begin
a:=2;
c1:=SPB.Down;
k:=cbMex2.ItemIndex;
cuc:=image2;
zu:=image2;
if not(SPB.Down) then
begin
SPB.Caption:='B';
uslin[1]:=false;
uslin[4]:=false;
SP(x);
funnA(x);
funTnA(x);
end;
if SPB.Down then
begin
SPB.Caption:='nB';
uslin[1]:=true;
uslin[4]:=true;
SP(x);
funA(x);
funTA(x);
end;
end;

procedure TForm1.SPCClick(Sender: TObject);
begin
a:=3;
c1:=SPC.Down;
k:=cbMex3.ItemIndex;
cuc:=image3;
zu:=image3;
if not(SPC.Down) then
begin
SPC.Caption:='C';
uslin[2]:=false;
uslin[4]:=false;
SP(x);
funnA(x);
funTnA(x);
end;
if SPC.Down then
begin
SPC.Caption:='nC';
uslin[2]:=true;
uslin[4]:=true;
SP(x);
funA(x);
funTA(x);
end;
end;

procedure TForm1.SPDClick(Sender: TObject);
begin
a:=4;
c1:=SPD.Down;
k:=cbMex4.ItemIndex;
cuc:=image4;
zu:=image4;
if not(SPD.Down) then
begin
SPD.Caption:='D';
uslin[3]:=false;
uslin[4]:=false;
SP(x);
funnA(x);
funTnA(x);
end;
if SPD.Down then
begin
SPD.Caption:='nD';
uslin[3]:=true;
uslin[4]:=true;
SP(x);
funA(x);
funTA(x);
end;
end;

procedure TForm1.SP(Sender: TObject);
begin
if not(c1) then
begin
case k of
0:begin
cuc.Picture.LoadFromFile('Нет.bmp');
end;
1:begin
cuc.Picture.LoadFromFile('Механизм 1.bmp');
imageList1.Draw(cuc.Canvas,25,10,0,true);
imageList4.Draw(cuc.Canvas,121,77,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,161,77,u1[a,4],true);
imageList4.Draw(cuc.Canvas,20,87,u1[a,1]+20,true);
u[a,1]:=25;
u[a,2]:=10;
u[a,3]:=0;
u[a,5]:=0;
end;
2:begin
cuc.Picture.LoadFromFile('Механизм 2.bmp');
imageList1.Draw(cuc.Canvas,20,9,1,true);
imageList4.Draw(cuc.Canvas,141,77,u1[a,4],true);
imageList4.Draw(cuc.Canvas,20,87,u1[a,1]+20,true);
u[a,1]:=20;
u[a,2]:=9;
u[a,3]:=1;
u[a,5]:=0;
end;
3:begin
cuc.Picture.LoadFromFile('Механизм 3.bmp');
imageList1.Draw(cuc.Canvas,25,9,2,true);
imageList4.Draw(cuc.Canvas,10,126,u1[a,3]+12,true);
imageList4.Draw(cuc.Canvas,75,126,u1[a,1]+20,true);
u[a,1]:=25;
u[a,2]:=9;
u[a,3]:=2;
u[a,5]:=0;
end;
4:begin
cuc.Picture.LoadFromFile('Механизм 4.bmp');
imageList1.Draw(cuc.Canvas,22,8,0,true);
imageList4.Draw(cuc.Canvas,125,50,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,165,50,u1[a,4],true);
imageList4.Draw(cuc.Canvas,77,126,u1[a,1]+19,true);
imageList4.Draw(cuc.Canvas,165,126,u1[a,1]+20,true);
u[a,1]:=22;
u[a,2]:=8;
u[a,3]:=0;
u[a,5]:=0;
end;
5:begin
cuc.Picture.LoadFromFile('Механизм 5.bmp');
imageList1.Draw(cuc.Canvas,25,10,0,true);
imageList4.Draw(cuc.Canvas,121,77,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,161,77,u1[a,4],true);
imageList4.Draw(cuc.Canvas,20,118,u1[a,1]+19,true);
imageList4.Draw(cuc.Canvas,110,118,u1[a,1]+20,true);
u[a,1]:=25;
u[a,2]:=10;
u[a,3]:=0;
u[a,5]:=0;
end;
6:begin
cuc.Picture.LoadFromFile('Механизм 6.bmp');
imageList1.Draw(cuc.Canvas,27,9,2,true);
imageList4.Draw(cuc.Canvas,160,115,u1[a,3]+11,true);
imageList4.Draw(cuc.Canvas,10,115,u1[a,3]+12,true);
imageList4.Draw(cuc.Canvas,55,135,u1[a,1]+20,true);
u[a,1]:=27;
u[a,2]:=9;
u[a,3]:=2;
u[a,5]:=0;
end;
7:begin
cuc.Picture.LoadFromFile('Механизм 7.bmp');
imageList1.Draw(cuc.Canvas,136,41,3,true);
imageList4.Draw(cuc.Canvas,142,108,u1[a,4],true);
imageList4.Draw(cuc.Canvas,55,82,u1[a,2]+28,true);
u[a,1]:=136;
u[a,2]:=41;
u[a,3]:=3;
u[a,4]:=41;
u[a,5]:=0;
usl1[1]:=true;
end;
8:begin
cuc.Picture.LoadFromFile('Механизм 8.bmp');
imageList1.Draw(cuc.Canvas,136,54,4,true);
imageList4.Draw(cuc.Canvas,149,102,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,149,22,u1[a,4],true);
imageList4.Draw(cuc.Canvas,56,92,u1[a,2]+28,true);
u[a,1]:=136;
u[a,2]:=54;
u[a,3]:=4;
u[a,4]:=54;
u[a,5]:=0;
usl1[2]:=true;
end;
9:begin
cuc.Picture.LoadFromFile('Механизм 9.bmp');
imageList1.Draw(cuc.Canvas,136,54,4,true);
imageList4.Draw(cuc.Canvas,149,102,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,149,22,u1[a,4],true);
imageList4.Draw(cuc.Canvas,70,36,u1[a,1]+20,true);
imageList4.Draw(cuc.Canvas,56,92,u1[a,2]+28,true);
u[a,1]:=136;
u[a,2]:=54;
u[a,3]:=4;
u[a,4]:=54;
u[a,5]:=0;
usl1[3]:=true;
end;
10:begin
cuc.Picture.LoadFromFile('Механизм 10.bmp');
imageList1.Draw(cuc.Canvas,106,20,5,true);
imageList4.Draw(cuc.Canvas,130,92,u1[a,4],true);
imageList4.Draw(cuc.Canvas,21,87,u1[a,2]+27,true);
imageList4.Draw(cuc.Canvas,101,87,u1[a,2]+28,true);
u[a,1]:=106;
u[a,2]:=20;
u[a,3]:=5;
u[a,5]:=0;
end;
11:begin
cuc.Picture.LoadFromFile('Механизм 11.bmp');
imageList1.Draw(cuc.Canvas,101,20,6,true);
imageList4.Draw(cuc.Canvas,130,92,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,163,92,u1[a,4],true);
imageList4.Draw(cuc.Canvas,16,87,u1[a,2]+27,true);
imageList4.Draw(cuc.Canvas,96,87,u1[a,2]+28,true);
u[a,1]:=101;
u[a,2]:=20;
u[a,3]:=6;
u[a,5]:=0;
end;
12:begin
cuc.Picture.LoadFromFile('Механизм 12.bmp');
imageList1.Draw(cuc.Canvas,106,30,6,true);
imageList4.Draw(cuc.Canvas,135,102,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,160,102,u1[a,4],true);
imageList4.Draw(cuc.Canvas,55,17,u1[a,1]+19,true);
imageList4.Draw(cuc.Canvas,86,17,u1[a,1]+20,true);
imageList4.Draw(cuc.Canvas,63,87,u1[a,2]+28,true);
u[a,1]:=106;
u[a,2]:=30;
u[a,3]:=6;
u[a,5]:=0;
end;
end;
end;
if c1 then
begin
case k of
0:begin
cuc.Picture.LoadFromFile('Нет.bmp');
end;
1:begin
cuc.Picture.LoadFromFile('Механизм 1.bmp');
imageList1.Draw(cuc.Canvas,65,10,0,true);
imageList4.Draw(cuc.Canvas,121,77,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,161,77,u1[a,4],true);
imageList4.Draw(cuc.Canvas,20,87,u1[a,1]+20,true);
u[a,1]:=65;
u[a,2]:=10;
u[a,3]:=0;
u[a,5]:=0;
end;
2:begin
cuc.Picture.LoadFromFile('Механизм 2.bmp');
imageList1.Draw(cuc.Canvas,60,9,1,true);
imageList4.Draw(cuc.Canvas,141,77,u1[a,4],true);
imageList4.Draw(cuc.Canvas,20,87,u1[a,1]+20,true);
u[a,1]:=60;
u[a,2]:=9;
u[a,3]:=1;
u[a,5]:=0;
end;
3:begin
cuc.Picture.LoadFromFile('Механизм 3.bmp');
imageList1.Draw(cuc.Canvas,65,9,2,true);
imageList4.Draw(cuc.Canvas,10,126,u1[a,3]+12,true);
imageList4.Draw(cuc.Canvas,75,126,u1[a,1]+20,true);
u[a,1]:=65;
u[a,2]:=9;
u[a,3]:=2;
u[a,5]:=0;
end;
4:begin
cuc.Picture.LoadFromFile('Механизм 4.bmp');
imageList1.Draw(cuc.Canvas,62,8,0,true);
imageList4.Draw(cuc.Canvas,125,50,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,165,50,u1[a,4],true);
imageList4.Draw(cuc.Canvas,77,126,u1[a,1]+19,true);
imageList4.Draw(cuc.Canvas,165,126,u1[a,1]+20,true);
u[a,1]:=62;
u[a,2]:=8;
u[a,3]:=0;
u[a,5]:=0;
end;
5:begin
cuc.Picture.LoadFromFile('Механизм 5.bmp');
imageList1.Draw(cuc.Canvas,65,10,0,true);
imageList4.Draw(cuc.Canvas,121,77,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,161,77,u1[a,4],true);
imageList4.Draw(cuc.Canvas,20,118,u1[a,1]+19,true);
imageList4.Draw(cuc.Canvas,110,118,u1[a,1]+20,true);
u[a,1]:=65;
u[a,2]:=10;
u[a,3]:=0;
u[a,5]:=0;
end;
6:begin
cuc.Picture.LoadFromFile('Механизм 6.bmp');
imageList1.Draw(cuc.Canvas,67,9,2,true);
imageList4.Draw(cuc.Canvas,160,115,u1[a,3]+11,true);
imageList4.Draw(cuc.Canvas,10,115,u1[a,3]+12,true);
imageList4.Draw(cuc.Canvas,55,135,u1[a,1]+20,true);
u[a,1]:=67;
u[a,2]:=9;
u[a,3]:=2;
u[a,5]:=0;
end;
7:begin
cuc.Picture.LoadFromFile('Механизм 7.bmp');
imageList1.Draw(cuc.Canvas,136,41,3,true);
imageList4.Draw(cuc.Canvas,142,108,u1[a,4],true);
imageList4.Draw(cuc.Canvas,55,82,u1[a,2]+28,true);
u[a,1]:=136;
u[a,2]:=41;
u[a,3]:=0;
u[a,4]:=41;
u[a,5]:=0;
usl1[1]:=true;
end;
8:begin
cuc.Picture.LoadFromFile('Механизм 8.bmp');
imageList1.Draw(cuc.Canvas,136,50,12,true);
imageList4.Draw(cuc.Canvas,149,102,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,149,22,u1[a,4],true);
imageList4.Draw(cuc.Canvas,56,92,u1[a,2]+28,true);
u[a,1]:=136;
u[a,2]:=50;
u[a,3]:=0;
u[a,4]:=50;
u[a,5]:=0;
usl1[2]:=false;
end;
9:begin
cuc.Picture.LoadFromFile('Механизм 9.bmp');
imageList1.Draw(cuc.Canvas,136,50,12,true);
imageList4.Draw(cuc.Canvas,149,102,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,149,22,u1[a,4],true);
imageList4.Draw(cuc.Canvas,70,36,u1[a,1]+20,true);
imageList4.Draw(cuc.Canvas,56,92,u1[a,2]+28,true);
u[a,1]:=136;
u[a,2]:=50;
u[a,3]:=0;
u[a,4]:=50;
u[a,5]:=0;
usl1[3]:=false;
end;
10:begin
cuc.Picture.LoadFromFile('Механизм 10.bmp');
imageList1.Draw(cuc.Canvas,138,20,5,true);
imageList4.Draw(cuc.Canvas,130,92,u1[a,4],true);
imageList4.Draw(cuc.Canvas,21,87,u1[a,2]+27,true);
imageList4.Draw(cuc.Canvas,101,87,u1[a,2]+28,true);
u[a,1]:=138;
u[a,2]:=20;
u[a,3]:=5;
u[a,5]:=0;
end;
11:begin
cuc.Picture.LoadFromFile('Механизм 11.bmp');
imageList1.Draw(cuc.Canvas,133,20,6,true);
imageList4.Draw(cuc.Canvas,130,92,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,163,92,u1[a,4],true);
imageList4.Draw(cuc.Canvas,16,87,u1[a,2]+27,true);
imageList4.Draw(cuc.Canvas,96,87,u1[a,2]+28,true);
u[a,1]:=133;
u[a,2]:=20;
u[a,3]:=6;
u[a,5]:=0;
end;
12:begin
cuc.Picture.LoadFromFile('Механизм 12.bmp');
imageList1.Draw(cuc.Canvas,138,30,6,true);
imageList4.Draw(cuc.Canvas,135,102,u1[a,4]-1,true);
imageList4.Draw(cuc.Canvas,160,102,u1[a,4],true);
imageList4.Draw(cuc.Canvas,55,17,u1[a,1]+19,true);
imageList4.Draw(cuc.Canvas,86,17,u1[a,1]+20,true);
imageList4.Draw(cuc.Canvas,63,87,u1[a,2]+28,true);
u[a,1]:=138;
u[a,2]:=30;
u[a,3]:=6;
u[a,5]:=0;
end;
end;
end;
end;



procedure TForm1.NextClick(Sender: TObject);
begin
nex:=true;
playclick(x);
//timer2.Enabled:=true;
end;

procedure TForm1.pausClick(Sender: TObject);
begin
if paus.Down then
begin
//Next.Enabled:=true;
end;
if not(paus.Down) then
begin
Timer2.Enabled:=true;
play.Down:=true;
//Next.Enabled:=false;
end;
end;



procedure TForm1.Timer2Timer(Sender: TObject);
begin
timer2.Enabled:=false;

if Length(cbOutput2.Text)<>g then
begin
cbOutput2.Text:=cbOutput2.Text+'-';
g:=Length(cbOutput2.Text);
end;

if Length(cbOutput1.Text)<Length(cbOutput2.Text) then
begin
inc(tp);
if tp>2 then tp:=0;
if tp=2 then
st2:=cbOutput2.Text;
cbOutput2.Clear;
g:=0
end;

if not(stop.Down) then
playClick(x);
end;

procedure TForm1.f11Click(Sender: TObject);
begin
Play.Down:=true;
playClick(x);
end;

procedure TForm1.N6Click(Sender: TObject);
begin
stopClick(x);
end;

procedure TForm1.N11Click(Sender: TObject);
begin
unit2.i:=1;
ABCD(x);
Form2.ShowModal;
end;

procedure TForm1.N10Click(Sender: TObject);
begin
if Form4.ShowModal=mrOK then
end;



procedure TForm1.N7Click(Sender: TObject);
begin
bbOutputF.Caption:='Сброс';
OpenDialog1.InitialDir:='c:\Мои документы\';
if OpenDialog1.Execute and FileExists(OpenDialog1.FileName) then
begin

AssignFile(Open,OpenDialog1.FileName);
Reset(Open);
readln(open,Load);
cbMex1.ItemIndex:=strtoint(load);
readln(open,Load);
cbMex2.ItemIndex:=strtoint(load);
readln(open,Load);
cbMex3.ItemIndex:=strtoint(load);
readln(open,Load);
cbMex4.ItemIndex:=strtoint(load);
readln(open,Load);
UpDown1.position:=strtoint(load);
indiv:=true;

dubler(x);
readln(Open,load);

cbOutput1.text:=load;
a:=mmOutput.Count-1;
mmOutput.Clear;
for i:=0 to a do
begin
readln(Open,Load);
mmOutput.items[i]:=load;
//readln(save,Load);
for j:=0 to 49 do
begin
readln(Open,Load);
unit3.oper[i,j]:=strtoint(load);

end;
end;

closefile(Open);
play.Enabled:=true;
Next.Enabled:=true;
f11.Enabled:=true;
end;
end;
procedure TForm1.N8Click(Sender: TObject);
begin

SaveDialog1.InitialDir:='c:\Мои документы\';
//AssignFile(save,ExpandFilename('test.txt'));
//nam:=ExtractFilepath('test.txt');
if savedialog1.Execute then
begin
AssignFile(open,SaveDialog1.FileName);


reset(save);
rewrite(open);
While not eof(save) do
begin
readln(save,load);
writeln(open,load);
end;
closeFile(save);
closeFile(open);
end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if deleteFile('test.txt') then
Form1.Close;
end;

procedure TForm1.N2Click(Sender: TObject);
begin
bbOutputF.Caption:='Сброс';
Reset(save);
readln(save,Load);
cbMex1.ItemIndex:=strtoint(load);
readln(save,Load);
cbMex2.ItemIndex:=strtoint(load);
readln(save,Load);
cbMex3.ItemIndex:=strtoint(load);
readln(save,Load);
cbMex4.ItemIndex:=strtoint(load);
readln(save,Load);
UpDown1.position:=strtoint(load);
indiv:=true;
dubler(x);
readln(save,load);
cbOutput1.text:=load;
a:=mmOutput.Count-1;
mmOutput.Clear;
for i:=0 to a do
begin
readln(save,Load);
mmOutput.items[i]:=load;
//readln(save,Load);
for j:=0 to 49 do
begin
readln(save,Load);
unit3.oper[i,j]:=strtoint(load);

end;
end;

closefile(save);
play.Enabled:=true;
Next.Enabled:=true;
f11.Enabled:=true;
end;


end.
Соседние файлы в папке Синтез4
  • #
    30.03.2015503 б19Project1.~dpr
  • #
    30.03.20151.15 Кб20test.txt
  • #
    30.03.201583.92 Кб20Unit1.dcu
  • #
    30.03.201551 б19Unit1.ddp
  • #
    30.03.20153.39 Mб19Unit1.dfm
  • #
    30.03.201569.32 Кб19Unit1.pas
  • #
    30.03.201551 б19Unit1.~ddp
  • #
    30.03.20153.39 Mб19Unit1.~dfm
  • #
    30.03.201569.19 Кб19Unit1.~pas
  • #
    30.03.201510.01 Кб19Unit2.dcu
  • #
    30.03.201551 б19Unit2.ddp