Автоматизированная система обработки сигналов, передаваемых датчиками, установленными на магистральном насосном агрегате (Текст программы курсового проекта)

Страницы работы

Фрагмент текста работы

program Project1;

uses

SysUtils,

Forms,

Unit1 in 'Unit1.pas' {Form1},

Unit5 in 'Unit5.pas' {Form5},

Unit2 in 'Unit2.pas' {Form2},

Unit3 in 'Unit3.pas' {Form3},

Unit4 in 'Unit4.pas' {Form4},

Unit6 in 'Unit6.pas' {Form6};

{$R *.res}

begin

Application.Initialize;

Application.CreateForm(TForm1, Form1);

Application.CreateForm(TForm5, Form5);

Application.CreateForm(TForm2, Form2);

Application.CreateForm(TForm3, Form3);

Application.CreateForm(TForm4, Form4);

Application.CreateForm(TForm6, Form6);

Application.Run;

end.


unit Unit1;

interface

uses

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

Dialogs, Unit2, Unit3, Unit4, Unit5, Unit6, Menus, StdCtrls, ExtCtrls;

type

TForm1 = class(TForm)

MainMenu1: TMainMenu;

File1: TMenuItem;

Tools: TMenuItem;

Optoins1: TMenuItem;

Exit1: TMenuItem;

N1: TMenuItem;

SingleLine1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

N9: TMenuItem;

N10: TMenuItem;

COM1: TMenuItem;

N11: TMenuItem;

A1: TEdit;

B1: TEdit;

C1: TEdit;

D1: TEdit;

E1: TEdit;

G1: TEdit;

F1: TEdit;

H1: TEdit;

Image1: TImage;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

Label10: TLabel;

Label11: TLabel;

Label12: TLabel;

Label13: TLabel;

Label14: TLabel;

Label15: TLabel;

Label16: TLabel;

Label17: TLabel;

Label18: TLabel;

Label19: TLabel;

Label20: TLabel;

Label21: TLabel;

Label22: TLabel;

S8: TShape;

S6: TShape;

S2: TShape;

S5: TShape;

S1: TShape;

S4: TShape;

S7: TShape;

S3: TShape;

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure Optoins1Click(Sender: TObject);

procedure Exit1Click(Sender: TObject);

procedure SingleLine1Click(Sender: TObject);

procedure N3Click(Sender: TObject);

procedure N4Click(Sender: TObject);

procedure N10Click(Sender: TObject);

procedure N5Click(Sender: TObject);

procedure N7Click(Sender: TObject);

procedure N8Click(Sender: TObject);

procedure N6Click(Sender: TObject);

procedure N9Click(Sender: TObject);

procedure COM1Click(Sender: TObject);

procedure N11Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

Form_:byte;

HFile: Text;

RecivedStr: String;

Diapp,s : array [1..8] of String;

Menu_:1..8;

Adres,ports: string;

implementation

{$R *.dfm}

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

Form2.timer1.Enabled:=False;

form2.Comport.StopComm;

end;

procedure TForm1.Optoins1Click(Sender: TObject);

begin

Form1.Enabled:=false;

Form2.Visible:=True;

Form2.Enabled:=True;

Form2.show

end;

procedure TForm1.Exit1Click(Sender: TObject);

begin

halt(0);

end;

procedure TForm1.SingleLine1Click(Sender: TObject);

begin

Form2.timer1.Enabled:=False;

Form1.Enabled:=false;

Form3.Visible:=True;

Form3.Enabled:=True;

Form3.show

end;

procedure TForm1.N3Click(Sender: TObject);

var i:byte;

begin

Form2.timer1.Enabled:=False;

Form4.Caption:='Давление на входе';

Form4.Label3.Font.Size:=7;

Form4.Label4.Font.Size:=7;

Form4.Label3.Font.Style:=[];

Form4.Label4.Font.Style:=[];

Form4.Label5.Caption:='2';

Form4.Label6.Caption:='2';

Form4.Label7.Caption:='';

Form4.Label8.Caption:='';

Form4.Label3.Caption:='кгс/см';

Form4.Label4.Caption:='кгс/см';

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

Rewrite(HFile);

CloseFile(HFile);

Form1.Enabled:=false;

Menu_:=1;

Form4.Visible:=True;

Form4.Enabled:=True;

Form4.Show;

end;

procedure TForm1.N4Click(Sender: TObject);

var i:byte;

begin

Form2.timer1.Enabled:=False;

Form4.Caption:='Давление на выходе';

Form4.Label3.Font.Size:=7;

Form4.Label4.Font.Size:=7;

Form4.Label3.Font.Style:=[];

Form4.Label4.Font.Style:=[];

Form4.Label5.Caption:='2';

Form4.Label6.Caption:='2';

Form4.Label7.Caption:='';

Form4.Label8.Caption:='';

Form4.Label3.Caption:='кгс/см';

Form4.Label4.Caption:='кгс/см';

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

Rewrite(HFile);

CloseFile(HFile);

Form1.Enabled:=false;

Menu_:=2;

Form4.Visible:=True;

Form4.Enabled:=True;

Form4.Show;

end;

procedure TForm1.N10Click(Sender: TObject);

var i:byte;

begin

Form2.timer1.Enabled:=False;

Form4.Caption:='Давление масла в маслосистеме';

Form4.Label3.Font.Size:=7;

Form4.Label4.Font.Size:=7;

Form4.Label3.Font.Style:=[];

Form4.Label4.Font.Style:=[];

Form4.Label5.Caption:='2';

Form4.Label6.Caption:='2';

Form4.Label7.Caption:='';

Form4.Label8.Caption:='';

Form4.Label3.Caption:='кгс/см';

Form4.Label4.Caption:='кгс/см';

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

Rewrite(HFile);

CloseFile(HFile);

Form1.Enabled:=false;

Menu_:=3;

Form4.Visible:=True;

Form4.Enabled:=True;

Form4.Show;

end;

procedure TForm1.N5Click(Sender: TObject);

var i:byte;

begin

Form2.timer1.Enabled:=False;

Form4.Caption:='Температура масла в маслосистеме';

Form4.Label3.Font.Size:=9;

Form4.Label4.Font.Size:=9;

Form4.Label3.Font.Style:=[];

Form4.Label4.Font.Style:=[];

Form4.Label7.Caption:='o';

Form4.Label8.Caption:='o';

Form4.Label5.Caption:='';

Form4.Label6.Caption:='';

Form4.Label3.Caption:='C';

Form4.Label4.Caption:='C';

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

Rewrite(HFile);

CloseFile(HFile);

Form1.Enabled:=false;

Menu_:=4;

Form4.Visible:=True;

Form4.Enabled:=True;

Form4.Show;

end;

procedure TForm1.N7Click(Sender: TObject);

var i:byte;

begin

Form2.timer1.Enabled:=False;

Form4.Caption:='Температура в насосной';

Form4.Label3.Font.Size:=9;

Form4.Label4.Font.Size:=9;

Form4.Label3.Font.Style:=[];

Form4.Label4.Font.Style:=[];

Form4.Label7.Caption:='o';

Form4.Label8.Caption:='o';

Form4.Label5.Caption:='';

Form4.Label6.Caption:='';

Form4.Label3.Caption:='C';

Form4.Label4.Caption:='C';

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

Rewrite(HFile);

CloseFile(HFile);

Form1.Enabled:=false;

Menu_:=5;

Form4.Visible:=True;

Form4.Enabled:=True;

Form4.Show;

end;

procedure TForm1.N8Click(Sender: TObject);

var i:byte;

begin

Form2.timer1.Enabled:=False;

Form4.Caption:='Загазованность в насосной';

Form4.Label3.Font.Size:=7;

Form4.Label4.Font.Size:=7;

Form4.Label3.Font.Style:=[fsBold];

Form4.Label4.Font.Style:=[fsBold];

Form4.Label7.Caption:='';

Form4.Label8.Caption:='';

Form4.Label5.Caption:='';

Form4.Label6.Caption:='';

Form4.Label3.Caption:='%';

Form4.Label4.Caption:='%';

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

Rewrite(HFile);

CloseFile(HFile);

Form1.Enabled:=false;

Menu_:=6;

Form4.Visible:=True;

Form4.Enabled:=True;

Form4.Show;

end;

procedure TForm1.N6Click(Sender: TObject);

var i:byte;

begin

Form2.timer1.Enabled:=False;

Form4.Caption:='Температура корпуса агрегата';

Form4.Label3.Font.Size:=9;

Form4.Label4.Font.Size:=9;

Form4.Label7.Caption:='o';

Form4.Label8.Caption:='o';

Form4.Label5.Caption:='';

Form4.Label6.Caption:='';

Form4.Label3.Caption:='C';

Form4.Label4.Caption:='C';

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

Rewrite(HFile);

CloseFile(HFile);

Form1.Enabled:=false;

Menu_:=7;

Form4.Visible:=True;

Form4.Enabled:=True;

Form4.Show;

end;

procedure TForm1.N9Click(Sender: TObject);

var i:byte;

begin

Form2.timer1.Enabled:=False;

Form4.Caption:='Вибрация на подшипниках';

Form4.Label3.Font.Size:=7;

Form4.Label4.Font.Size:=7;

Form4.Label7.Caption:='';

Form4.Label8.Caption:='';

Form4.Label5.Caption:='';

Form4.Label6.Caption:='';

Form4.Label3.Caption:='мм/с';

Form4.Label4.Caption:='мм/с';

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

Rewrite(HFile);

CloseFile(HFile);

Form1.Enabled:=false;

Menu_:=8;

Form4.Visible:=True;

Form4.Enabled:=True;

Form4.Show;

end;

procedure TForm1.COM1Click(Sender: TObject);

begin

Form2.timer1.Enabled:=False;

Form1.Enabled:=false;

Form5.Visible:=True;

Form5.Enabled:=True;

Form5.show

end;

procedure TForm1.N11Click(Sender: TObject);

begin

Form2.timer1.Enabled:=False;

Form1.Enabled:=false;

Form6.Visible:=True;

Form6.Enabled:=True;

Form6.show

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

A1.Text:='ERROR!!!';

B1.Text:='ERROR!!!';

C1.Text:='ERROR!!!';

D1.Text:='ERROR!!!';

E1.Text:='ERROR!!!';

F1.Text:='ERROR!!!';

G1.Text:='ERROR!!!';

H1.Text:='ERROR!!!';

end;

end.


unit Unit2;

interface

uses

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

Dialogs, StdCtrls, ExtCtrls, Comm32;

type

TForm2 = class(TForm)

A: TEdit;

B: TEdit;

C: TEdit;

D: TEdit;

E: TEdit;

F: TEdit;

G: TEdit;

H: TEdit;

Check1: TCheckBox;

Check2: TCheckBox;

Check3: TCheckBox;

Check4: TCheckBox;

Check5: TCheckBox;

Check6: TCheckBox;

Check7: TCheckBox;

Check0: TCheckBox;

Run: TButton;

Stop: TButton;

Exit: TButton;

SelAll: TButton;

ClrAll: TButton;

Timer1: TTimer;

Comport: TComm32;

Label1: TLabel;

Label2: TLabel;

procedure RunClick(Sender: TObject);

procedure ExitClick(Sender: TObject);

procedure ComportReceiveData(Sender: TObject; Buffer: Pointer;

BufferLength: Word);

procedure Run1;

procedure Run2;

procedure Run3;

procedure StopClick(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure SelAllClick(Sender: TObject);

procedure ClrAllClick(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure FormShow(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form2: TForm2;

iRun,lab : Boolean;

Numedit,i : integer;

NumTr,write_,cod,cod1 : string;

Fcode : Text;

implementation

uses Unit1, Unit3, Unit5;

{$R *.dfm}

procedure TForm2.Run1;

begin

cod:='$'+InttoHex(StrtoInt(Adres),2)+'5'+cod;

Comport.WriteCommData(PChar(cod+#13#10), Length(cod)+2);

end;

procedure TForm2.Run2;

begin

write_:='#'+InttoHex(StrtoInt(Adres),2)+IntToStr(Numedit);

Comport.WriteCommData(PChar(write_+#13#10), Length(write_)+2);

end;

procedure TForm2.Run3;

begin

write_:='$'+InttoHex(StrtoInt(Adres),2)+'6';

Comport.WriteCommData(PChar(write_+#13#10), Length(write_)+2);

end;

procedure TForm2.RunClick(Sender: TObject);

begin

Numedit:=0;

Run.Enabled:=False;

Stop.Enabled:=True;

timer1.Enabled:=True;

end;

procedure TForm2.ComportReceiveData(Sender: TObject; Buffer: Pointer;

BufferLength: Word);

var

Tr : Boolean;

index,ma,mi : string;

Rec : Currency;

begin

RecivedStr:=PChar(Buffer);

case Form_ of

1: if iRun then

begin

iRun:=False;

Delete(RecivedStr,1,3);

Delete(RecivedStr,Length(RecivedStr),1);

RecivedStr:='-'+RecivedStr;

AssignFile(Fcode,'cod.ini');

Reset(Fcode);

for i:=1 to 256 do

begin

index:='';

Readln(Fcode,index);

if RecivedStr=copy(index,length(index)-2,3) then

begin

cod:=copy(index,1,length(index)-3);

break;

end;

end;

CloseFile(Fcode);

for i:=1 to length(cod) do

begin

case cod[i] of

'0': Check0.Checked:=True;

'1': Check1.Checked:=True;

'2': Check2.Checked:=True;

'3': Check3.Checked:=True;

'4': Check4.Checked:=True;

'5': Check5.Checked:=True;

'6': Check6.Checked:=True;

'7': Check7.Checked:=True;

end

end;

end

else

begin

Delete(RecivedStr,1,2);

if length(RecivedStr)>1 then

if RecivedStr[2]='0' then delete(RecivedStr,1,1);

if length(RecivedStr)>4 then

RecivedStr:=Copy(RecivedStr,1,5)

else

Delete(RecivedStr,Length(RecivedStr),1);

for i:=1 to Length(RecivedStr) do

begin

if RecivedStr[i]='.'

then RecivedStr[i]:=',';

end;

if length(RecivedStr)>0 then

case Numedit of

0: begin

A.Text:=RecivedStr;

i:=3;

ma:='';

mi:='';

while Diapp[1,i]<>' ' do

begin

mi:=mi+Diapp[1,i];

inc(i);

end;

while i<=Length(Diapp[1]) do

begin

ma:=ma+Diapp[1,i];

inc(i);

end;

Rec:=(StrToCurr(RecivedStr)/10)*(StrToFloat(ma)-StrToFloat(mi))+StrToFloat(mi);

if (Rec>0.8) then

Form1.S1.Brush.Color:=clLime

else

if (Rec<0.8)and(Rec>0.5) then

Form1.S1.Brush.Color:=clYellow

else

Form1.S1.Brush.Color:=clRed;

Form1.A1.Text:=FloatToStr(Rec);

end;

1: begin

B.Text:=RecivedStr;

i:=3;

ma:='';

mi:='';

while Diapp[2,i]<>' ' do

begin

mi:=mi+Diapp[2,i];

inc(i);

end;

while i<=Length(Diapp[2]) do

begin

ma:=ma+Diapp[2,i];

inc(i);

end;

Rec:=(StrToCurr(RecivedStr)/10)*(StrToFloat(ma)-StrToFloat(mi))+StrToFloat(mi);

if (Rec<62) then

Form1.S2.Brush.Color:=clLime

else

if (Rec>62)and(Rec<64) then

Form1.S2.Brush.Color:=clYellow

else

Form1.S2.Brush.Color:=clRed;

Form1.B1.Text:=FloatToStr(Rec);

end;

2: begin

C.Text:=RecivedStr;

i:=3;

ma:='';

mi:='';

while Diapp[3,i]<>' ' do

begin

mi:=mi+Diapp[3,i];

inc(i);

end;

while i<=Length(Diapp[3]) do

begin

ma:=ma+Diapp[3,i];

inc(i);

end;

Rec:=(StrToCurr(RecivedStr)/10)*(StrToFloat(ma)-StrToFloat(mi))+StrToFloat(mi);

if (Rec>0.3) then

Form1.S3.Brush.Color:=clLime

else

if (Rec<0.3)and(Rec>0.25) then

Form1.S3.Brush.Color:=clYellow

else

Form1.S3.Brush.Color:=clRed;

Form1.C1.Text:=FloatToStr(Rec);

end;

3: begin

D.Text:=RecivedStr;

i:=3;

ma:='';

mi:='';

while Diapp[4,i]<>' ' do

begin

mi:=mi+Diapp[4,i];

inc(i);

end;

while i<=Length(Diapp[4]) do

begin

ma:=ma+Diapp[4,i];

inc(i);

end;

Rec:=(StrToCurr(RecivedStr)/10)*(StrToFloat(ma)-StrToFloat(mi))+StrToFloat(mi);

if (Rec<40) then

Form1.S4.Brush.Color:=clLime

else

if (Rec>40)and(Rec<45) then

Form1.S4.Brush.Color:=clYellow

else

Form1.S4.Brush.Color:=clRed;

Form1.D1.Text:=FloatToStr(Rec);

end;

4: begin

E.Text:=RecivedStr;

i:=3;

ma:='';

mi:='';

while Diapp[5,i]<>' ' do

begin

mi:=mi+Diapp[5,i];

inc(i);

end;

while i<=Length(Diapp[5]) do

begin

ma:=ma+Diapp[5,i];

inc(i);

end;

Rec:=(StrToCurr(RecivedStr)/10)*(StrToFloat(ma)-StrToFloat(mi))+StrToFloat(mi);

if (Rec>10)and(Rec<60) then

Form1.S5.Brush.Color:=clLime

else

if (Rec>5)and(Rec<70) then

Form1.S5.Brush.Color:=clYellow

else

Form1.S5.Brush.Color:=clRed;

Form1.E1.Text:=FloatToStr(Rec);

end;

5: begin

F.Text:=RecivedStr;

i:=3;

ma:='';

mi:='';

while Diapp[6,i]<>' ' do

begin

mi:=mi+Diapp[6,i];

inc(i);

end;

while i<=Length(Diapp[6]) do

begin

ma:=ma+Diapp[6,i];

inc(i);

end;

Rec:=(StrToCurr(RecivedStr)/10)*(StrToFloat(ma)-StrToFloat(mi))+StrToFloat(mi);

if (Rec<20) then

Form1.S6.Brush.Color:=clLime

else

if (Rec>20)and(Rec<30) then

Form1.S6.Brush.Color:=clYellow

else

Form1.S6.Brush.Color:=clRed;

Form1.F1.Text:=FloatToStr(Rec);

end;

6: begin

G.Text:=RecivedStr;

i:=3;

ma:='';

mi:='';

while Diapp[7,i]<>' ' do

begin

mi:=mi+Diapp[7,i];

inc(i);

end;

while i<=Length(Diapp[7]) do

begin

ma:=ma+Diapp[7,i];

inc(i);

end;

Rec:=(StrToCurr(RecivedStr)/10)*(StrToFloat(ma)-StrToFloat(mi))+StrToFloat(mi);

if (Rec<60) then

Form1.S7.Brush.Color:=clLime

else

if (Rec>60)and(Rec<70) then

Form1.S7.Brush.Color:=clYellow

else

Form1.S7.Brush.Color:=clRed;

Form1.G1.Text:=FloatToStr(Rec);

end;

7: begin

H.Text:=RecivedStr;

i:=3;

ma:='';

mi:='';

while Diapp[8,i]<>' ' do

begin

mi:=mi+Diapp[8,i];

inc(i);

end;

while i<=Length(Diapp[8]) do

begin

ma:=ma+Diapp[8,i];

inc(i);

end;

Rec:=(StrToCurr(RecivedStr)/10)*(StrToFloat(ma)-StrToFloat(mi))+StrToFloat(mi);

if (Rec<6.5) then

Form1.S8.Brush.Color:=clLime

else

if (Rec>6.5)and(Rec<7.1) then

Form1.S8.Brush.Color:=clYellow

else

Form1.S8.Brush.Color:=clRed;

Form1.H1.Text:=FloatToStr(Rec);

end;

end;

if length(NumTr)>0 then

repeat

if Numedit=7

then begin

Numedit:=0;

if lab=true then

begin

Label2.Visible:=True;

Label1.Visible:=False;

lab:=false;

end

else

begin

Label1.Visible:=True;

Label2.Visible:=False;

lab:=True;

end

end

else Numedit:=Numedit+1;

index:=IntToStr(Numedit);

Tr:=false;

for i:=1 to length(NumTr) do

if (NumTr[i]=index)

then begin

Tr:=true;

break;

end;

until Tr;

end;

2: Form3.ComportReceiveData;

end;

end;

procedure TForm2.ExitClick(Sender: TObject);

begin

Form2.Close;

end;

procedure TForm2.StopClick(Sender: TObject);

begin

Timer1.Enabled:=False;

Run.Enabled:=True;

Stop.Enabled:=False;

end;

procedure TForm2.Timer1Timer(Sender: TObject);

var index: string;

kol : 0..9;

begin

cod:='';

kol:=0;

if Check0.Checked=true then

begin

cod:=cod+'0';

inc(kol);

A.Visible:=true;

Form1.A1.Font.Color:=clBlack;

end

else

begin

A.Visible:=false;

Form1.A1.Font.Style:=[fsBold];

Form1.A1.Font.Color:=clRed;

Form1.A1.Text:='ERROR!!!';

end;

if Check1.Checked=true then

begin

cod:=cod+'1';

inc(kol);

B.Visible:=true;

Form1.B1.Font.Color:=clBlack;

end

else

begin

B.Visible:=false;

Form1.B1.Font.Style:=[fsBold];

Form1.B1.Font.Color:=clRed;

Form1.B1.Text:='ERROR!!!';

end;

if Check2.Checked=true then

begin

cod:=cod+'2';

inc(kol);

C.Visible:=true;

Form1.C1.Font.Color:=clBlack;

end

else

begin

C.Visible:=false;

Form1.C1.Font.Style:=[fsBold];

Form1.C1.Font.Color:=clRed;

Form1.C1.Text:='ERROR!!!';

end;

if Check3.Checked=true then

begin

cod:=cod+'3';

inc(kol);

D.Visible:=true;

Form1.D1.Font.Color:=clBlack;

end

else

begin

D.Visible:=false;

Form1.D1.Font.Style:=[fsBold];

Form1.D1.Font.Color:=clRed;

Form1.D1.Text:='ERROR!!!';

end;

if Check4.Checked=true then

begin

cod:=cod+'4';

inc(kol);

E.Visible:=true;

Form1.E1.Font.Color:=clBlack;

end

else

begin

E.Visible:=false;

Form1.E1.Font.Style:=[fsBold];

Form1.E1.Font.Color:=clRed;

Form1.E1.Text:='ERROR!!!';

end;

if Check5.Checked=true then

begin

cod:=cod+'5';

inc(kol);

F.Visible:=true;

Form1.F1.Font.Color:=clBlack;

end

else

begin

F.Visible:=false;

Form1.F1.Font.Style:=[fsBold];

Form1.F1.Font.Color:=clRed;

Form1.F1.Text:='ERROR!!!';

end;

if Check6.Checked=true then

begin

cod:=cod+'6';

inc(kol);

G.Visible:=true;

Form1.G1.Font.Color:=clBlack;

end

else

begin

G.Visible:=false;

Form1.G1.Font.Style:=[fsBold];

Form1.G1.Font.Color:=clRed;

Form1.G1.Text:='ERROR!!!';

end;

if Check7.Checked=true then

begin

cod:=cod+'7';

inc(kol);

H.Visible:=true;

Form1.H1.Font.Color:=clBlack;

end

else

begin

H.Visible:=false;

Form1.H1.Font.Style:=[fsBold];

Form1.H1.Font.Color:=clRed;

Form1.H1.Text:='ERROR!!!';

end;

if kol=0 then

begin

Label2.Visible:=True;

Label1.Visible:=False;

lab:=false;

end;

NumTr:=cod;

cod:=cod+'-';

inc(kol);

AssignFile(Fcode,'cod.ini');

Reset(Fcode);

for i:=1 to 256 do

begin

index:='';

Readln(Fcode,index);

if cod=copy(index,1,kol) then

begin

cod:=copy(index,kol+1,2);

break;

end;

end;

CloseFile(Fcode);

if iRun then

Run3

else

if (cod1<>cod) then

begin

cod1:=cod;

run1;

end

else run2;

end;

procedure TForm2.SelAllClick(Sender: TObject);

begin

Check0.Checked:=True;

Check1.Checked:=True;

Check2.Checked:=True;

Check3.Checked:=True;

Check4.Checked:=True;

Check5.Checked:=True;

Check6.Checked:=True;

Check7.Checked:=True;

end;

procedure TForm2.ClrAllClick(Sender: TObject);

begin

Label2.Visible:=True;

Label1.Visible:=False;

lab:=false;

Check0.Checked:=False;

Check1.Checked:=False;

Check2.Checked:=False;

Check3.Checked:=False;

Check4.Checked:=False;

Check5.Checked:=False;

Check6.Checked:=False;

Check7.Checked:=False;

end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);

begin

Form1.Enabled:=True;

end;

procedure TForm2.FormShow(Sender: TObject);

begin

A.Text:='';

B.Text:='';

C.Text:='';

D.Text:='';

E.Text:='';

F.Text:='';

G.Text:='';

H.Text:='';

Form_:=1;

iRun:=True;

Numedit:=0;

Run.Enabled:=False;

Stop.Enabled:=True;

timer1.Enabled:=True;

end;

procedure TForm2.FormCreate(Sender: TObject);

begin

SelAllClick(Sender);

if (Form5.Co2.Items[Form5.Co2.ItemIndex]<>'') and (Form5.Co1.Items[Form5.Co1.ItemIndex]<>'')

then begin

Comport.BaudRate:=StrtoInt(Form5.Co2.Items[Form5.Co2.ItemIndex]);

Comport.CommPort:=Form5.Co1.Items[Form5.Co1.ItemIndex];

end;

Comport.StartComm;

AssignFile(HFile,'Diap.ini');

Reset(HFile);

for i:=1 to 8 do

if not eof(Hfile)

then Readln(HFile,Diapp[i]);

CloseFile(HFile);

Form_:=1;

iRun:=True;

Numedit:=0;

Run.Enabled:=False;

Stop.Enabled:=True;

timer1.Enabled:=True;

end; 

end.


unit Unit3;

interface

uses

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

Dialogs, StdCtrls,unit2, Buttons;

type

TForm3 = class(TForm)

Edit1: TEdit;

Edit2: TEdit;

Label1: TLabel;

Label2: TLabel;

Go: TButton;

Exit: TButton;

memo1: TMemo;

procedure GoClick(Sender: TObject);

procedure ComportReceiveData;

procedure ExitClick(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure FormShow(Sender: TObject);

procedure Edit1Change(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form3: TForm3;

TexttoWrite: string;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm3.GoClick(Sender: TObject);

begin

Go.Enabled:=False;

Edit2.Text:='';

TexttoWrite:=Edit1.Text;

Form2.Comport.WriteCommData(PChar(TexttoWrite+#13#10),length(TexttoWrite)+2);

if Edit2.Text='' then

begin

Edit2.Text:='No Response';

Memo1.Lines.Add('No Response');

Memo1.Lines.Add('');

end;

end;

procedure TForm3.ComportReceiveData;

begin

delete(RecivedStr,length(RecivedStr),1);

if (Copy(RecivedStr,1,1)='?') then

begin

Edit2.Text:='No Response';

Memo1.Lines.Add('No Response');

Memo1.Lines.Add('');

end

else

begin

Edit2.Text:=RecivedStr;

Memo1.Lines.Delete(Memo1.Lines.Count-2);

Memo1.Lines.Delete(Memo1.Lines.Count-1);

Memo1.Lines.Add(RecivedStr);

Memo1.Lines.Add('');

end;

Go.Enabled:=True;

end;

procedure TForm3.ExitClick(Sender: TObject);

begin

Form3.Close;

end;

procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);

begin

Form1.Enabled:=True;

Form2.Timer1.Enabled:=True;

end;

procedure TForm3.FormShow(Sender: TObject);

var i : integer;

begin

Edit1.SetFocus;

Go.Enabled:=False;

Edit1.Text:='';

Edit2.Text:='';

memo1.Lines.Clear;

Form_:=2;

end;

procedure TForm3.Edit1Change(Sender: TObject);

begin

if Length(Edit1.Text)=0 then

Go.Enabled:=False

else

Go.Enabled:=True;

end;

end.


unit Unit4;

interface

uses

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

Dialogs, StdCtrls;

type

TForm4 = class(TForm)

Button1: TButton;

Button2: TButton;

Button3: TButton;

Edit1: TEdit;

Edit2: TEdit;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label5: TLabel;

Label4: TLabel;

Label6: TLabel;

Label7: TLabel;

Label8: TLabel;

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure FormShow(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form4: TForm4;

implementation

uses Unit1, Unit2;

{$R *.dfm}

procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);

var i:byte;

begin

Edit1.Text:='';

Edit2.Text:='';

AssignFile(HFile,'Diap.ini');

Append(HFile);

for i:=1 to 8 do

Writeln(HFile,s[i]);

CloseFile(HFile);

Diapp:=s;

Form2.Timer1.Enabled:=True;

Form1.Enabled:=True;

end;

procedure TForm4.Button1Click(Sender: TObject);

var min,max: Currency;

begin

if  ((Length(Edit1.Text)>0)and(Length(Edit2.Text)>0)and(StrtoCurr(Edit1.Text)<StrtoCurr(Edit2.Text)))then

begin

s[Menu_]:=InttoStr(Menu_)+' '+Edit1.Text+' '+Edit2.Text;

Form4.Close;

end

else

begin

Application.MessageBox('Введены неправильные значения','Ошибка!!!',0);

Form4.Edit1.SetFocus;

end;

end;

procedure TForm4.Button2Click(Sender: TObject);

begin

if s[Menu_]='' then

begin

Application.MessageBox('Сведения отсутствуют!!! Введите значения','Ошибка!!!',0);

Form4.Edit1.SetFocus;

exit;

end;

Form4.Close;

end;

procedure TForm4.Button3Click(Sender: TObject);

begin

if s[Menu_]='' then

begin

Application.MessageBox('Сведения отсутствуют!!! Введите значения','Ошибка!!!',0);

Form4.Edit1.SetFocus;

exit;

end;

Form4.Close;

end;

procedure TForm4.FormShow(Sender: TObject);

var i:byte;

begin

Form4.Edit1.SetFocus;

s:=Diapp;

if length(Diapp[Menu_])=0 then

begin

case Menu_ of

1: Application.MessageBox('Диапазон давления на входе отсутствует',

'Отсутствие данных',0);

2: Application.MessageBox('Диапазон давления на выходе отсутствует',

'Отсутствие данных',0);

3: Application.MessageBox('Диапазон давления масла в маслосистеме отсутствует',

'Отсутствие данных',0);

4: Application.MessageBox('Диапазон температур масла в маслосистеме отсутствует',

'Отсутствие данных',0);

5: Application.MessageBox('Диапазон температур в насосной отсутствует',

'Отсутствие данных',0);

6: Application.MessageBox('Диапазон загазованности в насосной отсутствует',

'Отсутствие данных',0);

7: Application.MessageBox('Диапазон температур корпуса агрегата отсутствует',

'Отсутствие данных',0);

8: Application.MessageBox('Диапазон вибрации на подшипниках отсутствует',

'Отсутствие данных',0);

end;

exit;

end;

i:=3;

while Diapp[Menu_,i]<>' ' do

begin

Edit1.Text:=Edit1.Text+Diapp[Menu_,i];

inc(i);

end;

inc(i);

while i<=Length(Diapp[Menu_]) do

begin

Edit2.Text:=edit2.Text+Diapp[Menu_,i];

inc(i);

end;

end;

end.

unit Unit5;

interface

uses

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

Dialogs, StdCtrls;

type

TForm5 = class(TForm)

Co1: TComboBox;

Label1: TLabel;

Co2: TComboBox;

Label2: TLabel;

Button1: TButton;

Button2: TButton;

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure FormCreate(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure FormShow(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form5: TForm5;

Portt: Text;

comb:string;

Baudrr,Commp :integer;

Exitt : boolean;

implementation

uses Unit1, Unit2;

{$R *.dfm}

procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction);

begin

Co1.SetFocus;

if Exitt=False then

begin

Co1.ItemIndex:=Baudrr;

Co2.ItemIndex:=Commp;

end;

Form2.Timer1.Enabled:=True; 

Form1.Enabled:=True;

end;

procedure TForm5.FormCreate(Sender: TObject);

var i: integer;

begin

for i:=1 to 255 do

Co1.AddItem('COM'+InttoStr(i),Sender);

i:=1200;

while i<=38400 do

begin

Co2.AddItem(InttoStr(i),Sender);

i:=i*2;

end;

i:=57600;

while i<=921600 do

begin

Co2.AddItem(InttoStr(i),Sender);

i:=i*2;

end;

AssignFile(Portt,'Port.ini');

Reset(Portt);

Readln(Portt,Ports);

Readln(Portt,Adres);

CloseFile(Portt);

if Adres=#$1A then

Adres:='1';

i:=1;

if Ports='' then exit;

Comb:='';

while Ports[i]<>',' do

begin

Comb:=Comb+Ports[i];

inc(i);

end;

inc(i);

Co1.ItemIndex:=StrtoInt(Comb);

Comb:='';

while Length(Ports)>=i do

begin

Comb:=Comb+Ports[i];

inc(i);

end;

Co2.ItemIndex:=StrToInt(Comb);

end;

procedure TForm5.Button1Click(Sender: TObject);

var i   : integer;

qtr : boolean;

begin

if ((Length(Co1.Text)=0) or (Length(Co2.Text)=0)) then

begin

Application.MessageBox('Отсутствует одно из значений!','Ошибка!!!',0);

exit;

end;

AssignFile(Portt,'Port.ini');

Append(Portt);

Rewrite(Portt);

Comb:=IntToStr(Co1.ItemIndex)+','+IntToStr(Co2.ItemIndex);

Writeln(Portt,Comb);

Writeln(Portt,Adres);

CloseFile(Portt);

Exitt:=True;

Form2.Comport.BaudRate:=StrToInt(Co2.Items[Co2.ItemIndex]);

Form2.Comport.CommPort:=Co1.Items[Co1.ItemIndex];

Form2.Comport.StartComm;

Form5.Close;

end;

procedure TForm5.Button2Click(Sender: TObject);

begin

if (Baudrr<>-1) and (Commp<>-1)

then begin

Co1.ItemIndex:=Baudrr;

Co2.ItemIndex:=Commp;

end

else

begin

Application.MessageBox('Отсутствуют значения порта

Похожие материалы

Информация о работе