unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, PortIO, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
MainMenu1: TMainMenu;
N1: TMenuItem;
N11: TMenuItem;
N21: TMenuItem;
N31: TMenuItem;
N41: TMenuItem;
N51: TMenuItem;
N61: TMenuItem;
N71: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N12: TMenuItem;
N22: TMenuItem;
N32: TMenuItem;
N42: TMenuItem;
N52: TMenuItem;
N62: TMenuItem;
N72: TMenuItem;
Label8: TLabel;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Panel1: TPanel;
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
DLPortIO1: TDLPortIO;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
procedure N72Click(Sender: TObject);
procedure N62Click(Sender: TObject);
procedure N52Click(Sender: TObject);
procedure N42Click(Sender: TObject);
procedure N32Click(Sender: TObject);
procedure N22Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N71Click(Sender: TObject);
procedure N61Click(Sender: TObject);
procedure N51Click(Sender: TObject);
procedure N41Click(Sender: TObject);
procedure N31Click(Sender: TObject);
procedure N21Click(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
Procedure c1_7;
Procedure c7_5;
Procedure c5_5;
Procedure c5_2;
Procedure c2_3;
Procedure c3_5;
Procedure c5_1;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
z1,z2,z3,z4,z5,z6,z7:integer;
x1,x2,x3,x4,x5,x6,x7:integer;
DataPort: Word; // Порт для данных
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
// Запускаем драйвер порта из директории с программой
DLPortIO1.DriverPath:=ExtractFileDir(ParamStr(0));
// Открываем DriverLINX driver
DLPortIO1.OpenDriver();
if (not DLPortIO1.ActiveHW) then
begin
MessageDlg('Не могу открыть DriverLINX driver.', mtError, [mbOK], 0);
end;
end;
procedure TForm1.N11Click(Sender: TObject);
begin
CheckBox1.Checked:=False;
end;
procedure TForm1.N12Click(Sender: TObject);
begin
CheckBox1.Checked:=True;
end;
procedure TForm1.N21Click(Sender: TObject);
begin
CheckBox2.Checked:=False;
end;
procedure TForm1.N22Click(Sender: TObject);
begin
CheckBox2.Checked:=True;
end;
procedure TForm1.N2Click(Sender: TObject);
begin
CheckBox1.Checked:=True;
CheckBox2.Checked:=True;
CheckBox3.Checked:=True;
CheckBox4.Checked:=True;
CheckBox5.Checked:=True;
CheckBox6.Checked:=True;
CheckBox7.Checked:=True;
end;
procedure TForm1.N31Click(Sender: TObject);
begin
CheckBox3.Checked:=False;
end;
procedure TForm1.N32Click(Sender: TObject);
begin
CheckBox3.Checked:=True;
end;
procedure TForm1.N41Click(Sender: TObject);
begin
CheckBox4.Checked:=False;
end;
procedure TForm1.N42Click(Sender: TObject);
begin
CheckBox4.Checked:=True;
end;
procedure TForm1.N51Click(Sender: TObject);
begin
CheckBox5.Checked:=False;
end;
procedure TForm1.N52Click(Sender: TObject);
begin
CheckBox5.Checked:=True;
end;
procedure TForm1.N61Click(Sender: TObject);
begin
CheckBox6.Checked:=False;
end;
procedure TForm1.N62Click(Sender: TObject);
begin
CheckBox6.Checked:=True;
end;
procedure TForm1.N71Click(Sender: TObject);
begin
CheckBox7.Checked:=False;
end;
procedure TForm1.N72Click(Sender: TObject);
begin
CheckBox7.Checked:=True;
end;
Procedure TForm1.c1_7;
var
i: integer;
begin
for i:= 1 to 7 do
TShape(FindComponent('Shape'+ inttostr(i))).Brush.Color:= clWhite;
// Получаем адрес порта данных
try
DataPort:= Word($378);
except
MessageDlg('Вы определили недействительный порт.'+#13+
'Действие не выполнено.',
mtError, [mbOK], 0);
Exit;
end;
for i := 1 to x1 do
begin
// Напишите данные
DLPortIO1.Port[DataPort]:= $8;
Sleep(z1);
// Напишите данные
DLPortIO1.Port[DataPort]:= $4;
Sleep(z1);
// Напишите данные
DLPortIO1.Port[DataPort]:= $2;
Sleep(z1);
// Напишите данные
DLPortIO1.Port[DataPort]:= $1;
Sleep(z1);
case i of
1: Shape1.Brush.Color:= clRed;
1940: begin
Shape1.Brush.Color:= clWhite;
Shape2.Brush.Color:= clRed;
end;
3880: begin
Shape2.Brush.Color:= clWhite;
Shape3.Brush.Color:= clRed;
end;
5820: begin
Shape3.Brush.Color:= clWhite;
Shape4.Brush.Color:= clRed;
end;
7760: begin
Shape4.Brush.Color:= clWhite;
Shape5.Brush.Color:= clRed;
end;
9700: begin
Shape5.Brush.Color:= clWhite;
Shape6.Brush.Color:= clRed;
end;
11640: begin
Shape6.Brush.Color:= clWhite;
Shape7.Brush.Color:= clRed;
end;
end;
Application.ProcessMessages;
end;
end;
Procedure TForm1.c7_5;
var
i: integer;
begin
for i:= 1 to 7 do
TShape(FindComponent('Shape'+ inttostr(i))).Brush.Color:= clWhite;
// Получаем адрес порта данных
try
DataPort:= Word($378);
except
MessageDlg('Вы определили недействительный порт.'+#13+
'Действие не выполнено.',
mtError, [mbOK], 0);
Exit;
end;
for i := 1 to x2 do
begin
// Напишите данные
DLPortIO1.Port[DataPort]:= $1;
Sleep(z2);
// Напишите данные
DLPortIO1.Port[DataPort]:= $2;
Sleep(z2);
// Напишите данные
DLPortIO1.Port[DataPort]:= $4;
Sleep(z2);
// Напишите данные
DLPortIO1.Port[DataPort]:= $8;
Sleep(z2);
case i of
1: Shape7.Brush.Color:= clRed;
1940: begin
Shape7.Brush.Color:= clWhite;
Shape6.Brush.Color:= clRed;
end;
3880: begin
Shape6.Brush.Color:= clWhite;
Shape5.Brush.Color:= clRed;
end;
end;
Application.ProcessMessages;
end;
end;
Procedure TForm1.c5_5;
var
i: integer;
begin
for i:= 1 to 7 do
TShape(FindComponent('Shape'+ inttostr(i))).Brush.Color:= clWhite;
// Получаем адрес порта данных
try
DataPort:= Word($378);
except
MessageDlg('Вы определили недействительный порт.'+#13+
'Действие не выполнено.',
mtError, [mbOK], 0);
Exit;
end;
// Напишите данные
DLPortIO1.Port[DataPort]:= $0;
Sleep(z3);
Shape5.Brush.Color:= clRed;
Application.ProcessMessages;
end;
Procedure TForm1.c5_2;
var
i: integer;
begin
for i:= 1 to 7 do
TShape(FindComponent('Shape'+ inttostr(i))).Brush.Color:= clWhite;
// Получаем адрес порта данных
try
DataPort:= Word($378);
except
MessageDlg('Вы определили недействительный порт.'+#13+
'Действие не выполнено.',
mtError, [mbOK], 0);
Exit;
end;
for i := 1 to x4 do
begin
// Напишите данные
DLPortIO1.Port[DataPort]:= $1;
Sleep(z4);
// Напишите данные
DLPortIO1.Port[DataPort]:= $2;
Sleep(z4);
// Напишите данные
DLPortIO1.Port[DataPort]:= $4;
Sleep(z4);
// Напишите данные
DLPortIO1.Port[DataPort]:= $8;
Sleep(z4);
case i of
1: Shape5.Brush.Color:= clRed;
1940: begin
Shape5.Brush.Color:= clWhite;
Shape4.Brush.Color:= clRed;
end;
3880: begin
Shape4.Brush.Color:= clWhite;
Shape3.Brush.Color:= clRed;
end;
5820: begin
Shape3.Brush.Color:= clWhite;
Shape2.Brush.Color:= clRed;
end;
end;
Application.ProcessMessages;
end;
end;
Procedure TForm1.c2_3;
var
i: integer;
begin
for i:= 1 to 7 do
TShape(FindComponent('Shape'+ inttostr(i))).Brush.Color:= clWhite;
// Получаем адрес порта данных
try
DataPort:= Word($378);
except
MessageDlg('Вы определили недействительный порт.'+#13+
'Действие не выполнено.',
mtError, [mbOK], 0);
Exit;
end;
for i := 1 to x5 do
begin
// Напишите данные
DLPortIO1.Port[DataPort]:= $8;
Sleep(z5);
// Напишите данные
DLPortIO1.Port[DataPort]:= $4;
Sleep(z5);
// Напишите данные
DLPortIO1.Port[DataPort]:= $2;
Sleep(z5);
// Напишите данные
DLPortIO1.Port[DataPort]:= $1;
Sleep(z5);
case i of
1: Shape2.Brush.Color:= clRed;
1940: begin
Shape2.Brush.Color:= clWhite;
Shape3.Brush.Color:= clRed;
end;
end;
Application.ProcessMessages;
end;
end;
Procedure TForm1.c3_5;
var
i: integer;
begin
for i:= 1 to 7 do
TShape(FindComponent('Shape'+ inttostr(i))).Brush.Color:= clWhite;
// Получаем адрес порта данных
try
DataPort:= Word($378);
except
MessageDlg('Вы определили недействительный порт.'+#13+
'Действие не выполнено.',
mtError, [mbOK], 0);
Exit;
end;
for i := 1 to x6 do
begin
// Напишите данные
DLPortIO1.Port[DataPort]:= $8;
Sleep(z6);
// Напишите данные
DLPortIO1.Port[DataPort]:= $4;
Sleep(z6);
// Напишите данные
DLPortIO1.Port[DataPort]:= $2;
Sleep(z6);
// Напишите данные
DLPortIO1.Port[DataPort]:= $1;
Sleep(z6);
case i of
1: Shape3.Brush.Color:= clRed;
1940: begin
Shape3.Brush.Color:= clWhite;
Shape4.Brush.Color:= clRed;
end;
3880: begin
Shape4.Brush.Color:= clWhite;
Shape5.Brush.Color:= clRed;
end;
end;
Application.ProcessMessages;
end;
end;
Procedure TForm1.c5_1;
var
i: integer;
begin
for i:= 1 to 7 do
TShape(FindComponent('Shape'+ inttostr(i))).Brush.Color:= clWhite;
// Получаем адрес порта данных
try
DataPort:= Word($378);
except
MessageDlg('Вы определили недействительный порт.'+#13+
'Действие не выполнено.',
mtError, [mbOK], 0);
Exit;
end;
for i := 1 to x7 do
begin
// Напишите данные
DLPortIO1.Port[DataPort]:= $1;
Sleep(z7);
// Напишите данные
DLPortIO1.Port[DataPort]:= $2;
Sleep(z7);
// Напишите данные
DLPortIO1.Port[DataPort]:= $4;
Sleep(z7);
// Напишите данные
DLPortIO1.Port[DataPort]:= $8;
Sleep(z7);
case i of
1: Shape5.Brush.Color:= clRed;
1940: begin
Shape5.Brush.Color:= clWhite;
Shape4.Brush.Color:= clRed;
end;
3880: begin
Shape4.Brush.Color:= clWhite;
Shape3.Brush.Color:= clRed;
end;
5820: begin
Shape3.Brush.Color:= clWhite;
Shape2.Brush.Color:= clRed;
end;
7760: begin
Shape2.Brush.Color:= clWhite;
Shape1.Brush.Color:= clRed;
end;
end;
Application.ProcessMessages;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
z1:=StrToInt(Edit1.Text); x1:=StrToInt(Edit8.Text);
z2:=StrToInt(Edit2.Text); x2:=StrToInt(Edit9.Text);
z3:=StrToInt(Edit3.Text); x3:=StrToInt(Edit10.Text);
z4:=StrToInt(Edit4.Text); x4:=StrToInt(Edit11.Text);
z5:=StrToInt(Edit5.Text); x5:=StrToInt(Edit12.Text);
z6:=StrToInt(Edit6.Text); x6:=StrToInt(Edit13.Text);
z7:=StrToInt(Edit7.Text); x7:=StrToInt(Edit14.Text);
if CheckBox1.Checked=True then c1_7;
if CheckBox2.Checked=True then c7_5;
if CheckBox3.Checked=True then c5_5;
if CheckBox4.Checked=True then c5_2;
if CheckBox5.Checked=True then c2_3;
if CheckBox6.Checked=True then c3_5;
if CheckBox7.Checked=True then c5_1;
// Получаем адрес порта данных
try
DataPort:= Word($378);
except
MessageDlg('Вы определили недействительный порт.'+#13+
'Действие не выполнено.',
mtError, [mbOK], 0);
Exit;
end;
// Напишите данные
DLPortIO1.Port[DataPort]:= $0;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DLPortIO1.CloseDriver();
end;
end.
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.