?? econv230p.~pas
字號(hào):
comm_status := not comm_status;
end;
//----------------------選擇通訊協(xié)議-------------------------
procedure TMainForm.MODBUSRTU1Click(Sender: TObject);
begin
if (comm_status) then exit; //通訊進(jìn)行時(shí)不進(jìn)行端口設(shè)置
(sender as TMenuItem).Checked := true;
case (sender as TMenuItem).tag of
0: econfile.comm.mode := 'RTU';
1: econfile.comm.mode := 'ASCII';
2: econfile.comm.mode := 'CDT'
else econfile.comm.mode := 'RTU'
end;
end;
//----------------------程序關(guān)閉處理--------------------------
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
vacomm1.close;
econfile.Free;
end;
//----------------------選擇通訊端口-------------------------
procedure TMainForm.COM11Click(Sender: TObject);
begin
if (comm_status) then exit; //通訊進(jìn)行時(shí)不進(jìn)行端口設(shè)置
(sender as TMenuItem).Checked := true;
econfile.comm.portnum := (sender as TMenuItem).tag;
vacomm1.portnum := changportnum(econfile.comm.portnum);
end;
//----------------------選擇波特率---------------------------
procedure TMainForm.b110Click(Sender: TObject);
begin
if (comm_status) then exit; // 通訊中不進(jìn)行設(shè)置
(sender as tmenuitem).checked := true; // 顯示被選中
case (sender as tmenuitem).tag of
0: econfile.comm.baudrate := 110;
1: econfile.comm.baudrate := 300;
2: econfile.comm.baudrate := 600;
3: econfile.comm.baudrate := 1200;
4: econfile.comm.baudrate := 2400;
5: econfile.comm.baudrate := 4800;
6: econfile.comm.baudrate := 9600;
7: econfile.comm.baudrate := 14400;
8: econfile.comm.baudrate := 19200;
9: econfile.comm.baudrate := 38400;
10: econfile.comm.baudrate := 56000;
11: econfile.comm.baudrate := 57600;
12: econfile.comm.baudrate := 115200;
13: econfile.comm.baudrate := 128000;
14: econfile.comm.baudrate := 256000;
15: econfile.comm.baudrate := -1;
else econfile.comm.baudrate := -1 //用戶定義波特率
end;
if (econfile.comm.baudrate>=0) then
vacomm1.baudrate := changbaudrate(econfile.comm.baudrate)
else
begin
vacomm1.baudrate := bruser;
vacomm1.UserBaudrate := econfile.comm.userbaud;
end;
end;
//----------------------選擇終端地址-------------------------
procedure TMainForm.address1Click(Sender: TObject);
var
temp: string;
i: integer;
begin
if (comm_status) then exit; // 通訊中不進(jìn)行設(shè)置
(sender as tmenuitem).checked := true; // 顯示被選中
temp := (sender as tmenuitem).caption;
i := pos('&', temp);
delete(temp, i, 1);
econfile.comm.rtuaddress := strtointdef(temp, 1);
end;
//----------------------選擇奇偶校驗(yàn)-------------------------
procedure TMainForm.paritynoneClick(Sender: TObject);
begin
if (comm_status) then exit;
(sender as TMenuItem).Checked := true;
econfile.comm.parity := (sender as TMenuItem).tag;
vacomm1.Parity := changparity(econfile.comm.parity);
end;
//----------------------數(shù)據(jù)文件另存-------------------------
procedure TMainForm.saveasClick(Sender: TObject);
begin
if save1.Execute then
begin
getfilename := save1.FileName;
datamemo.Lines.SaveToFile(getfilename);
end;
end;
//----------------------遙控繼電器輸出-----------------------
procedure TMainForm.coilstategridSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
case acol of
0: begin
coilstategrid.Options :=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := false;
end
else
begin
coilstategrid.Options:=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := true;
smindex := arow;
tempform.show;
tempform.UpDown1.Position := ord(econfile.coilstatearray[smindex].value);
tempform.tempedit.text := inttostr(ord(econfile.coilstatearray[smindex].value));
tempform.Caption := '控制第 ' + inttostr(smindex) + ' 路繼電器';
end;
end;
end;
//----------------------修改保持寄存器-----------------------
procedure TMainForm.holdregistergridSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
case acol of
0: begin
coilstategrid.Options :=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := false;
end
else
begin
coilstategrid.Options:=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := true;
smindex := arow;
// tempform.UpDown1.Position :=strtointdef(econfile.holdregisterarray[smindex].value, 0);
tempform.show;
tempform.tempedit.text := econfile.holdregisterarray[smindex].value;
tempform.Caption := '修改' + holdregistergrid.Cells[1,smindex];
end;
end;
end;
//----------------------修改電度值---------------------------
procedure TMainForm.PowerGridSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
i: integer;
j: longword;
begin
case acol of
0: begin
coilstategrid.Options :=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := false;
end
else
begin
coilstategrid.Options:=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := true;
smindex := arow;
i := strtointdef(econfile.setpowerarray[smindex].address1, 0);
j := strtointdef(econfile.holdregisterarray[i].value, 0);
i := strtointdef(econfile.setpowerarray[smindex].address2, 0);
j := strtoint64def(econfile.holdregisterarray[i].value, 0)*65536 + j;
tempform.show;
tempform.tempedit.text := inttostr(j);
tempform.updown1.Visible := false;
// tempform.UpDown1.Position := j;
tempform.Caption := '設(shè)置' + powergrid.Cells[1,smindex];
end;
end;
end;
//----------------------修改保護(hù)參數(shù)-------------------------
procedure TMainForm.protectgridSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
i:integer;
begin
case acol of
0,1,2,4,6:
begin
coilstategrid.Options :=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := false;
end;
3: begin
protectgrid.Options :=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := true;
smindex := strtointdef(econfile.setprotectarray[arow].address1,0);
i := strtoint(econfile.holdregisterarray[smindex].value);
tempform.show;
tempform.UpDown1.Position := ord(i >= $8000);
tempform.tempedit.text := inttostr(ord(i >= $8000));
tempform.Caption := '設(shè)定' + holdregistergrid.Cells[1,smindex];
end;
5: begin
protectgrid.Options :=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect:=true;
smindex := strtointdef(econfile.setprotectarray[arow].address2, 0);
tempform.show;
tempform.UpDown1.Position := strtointdef(econfile.holdregisterarray[smindex].value, 0);
tempform.tempedit.text := econfile.holdregisterarray[smindex].value;
tempform.Caption := '修改' + holdregistergrid.Cells[1, smindex];
end;
7: begin
protectgrid.Options:=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := true;
smindex := strtointdef(econfile.setprotectarray[arow].address3, 0);
tempform.show;
tempform.UpDown1.Position := strtointdef(econfile.holdregisterarray[smindex].value, 0);
tempform.tempedit.text := econfile.holdregisterarray[smindex].value;
tempform.Caption := '修改' + holdregistergrid.Cells[1, smindex];
end;
8: begin
protectgrid.Options:=
[goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine];
CanSelect := true;
smindex := strtointdef(econfile.setprotectarray[arow].address1, 0);
i := strtointdef(econfile.holdregisterarray[smindex].value, 0);
tempform.show;
tempform.UpDown1.Position := i mod $8000 ;
tempform.tempedit.text := inttostr(i mod $8000);
tempform.Caption := '設(shè)定' + econfile.setprotectarray[arow].name
+ '動(dòng)作繼電器';
end;
end;
end;
//----------------------讀保持寄存器-------------------------
procedure TMainForm.readholdtimerTimer(Sender: TObject);
begin
readholdregister(econfile);
end;
//----------------------讀fifo-------------------------------
procedure TMainForm.readfifotimerTimer(Sender: TObject);
begin
readfifo(econfile);
end;
//----------------------接收標(biāo)志處理-------------------------
procedure TMainForm.VaComm1RxFlag(Sender: TObject);
begin
timeoutcount := 0;
timerout1.Enabled := False;
end;
//----------------------顯示關(guān)于窗口-------------------------
procedure TMainForm.m_aboutClick(Sender: TObject);
begin
aboutform.showmodal;
end;
//----------------------修改輸入寄存器對(duì)應(yīng)系數(shù)----------------
procedure TMainForm.inputregistergridSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
i,j: integer;
begin
coilstategrid.Options :=
[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
CanSelect := true;
j := arow;
smindex := -1;
for i:=1 to econfile.setpartotal do
begin
if (strtointdef(econfile.setpararray[i].address1,-1)=j)
then
begin
smindex := strtointdef(econfile.setpararray[i].address2,-1);
break;
end;
end;
if smindex=-1 then exit;
tempform.show;
tempform.tempedit.text := econfile.holdregisterarray[smindex].value;
tempform.Caption := '修改' + holdregistergrid.Cells[1,smindex];
end;
//----------------------保存幫助文件-------------------------
procedure TMainForm.save2Click(Sender: TObject);
begin
helpmemo.Lines.SaveToFile('help.txt');
end;
//----------------------保存測(cè)試報(bào)告文件---------------------
procedure TMainForm.saverptbtnClick(Sender: TObject);
var tempfile: string;
begin
if save1.Execute then
begin
tempfile:=save1.FileName;
testrptmemo.Lines.SaveToFile(tempfile);
end;
end;
//----------------------生成報(bào)告文件------------------------
procedure TMainForm.rptbtnClick(Sender: TObject);
var
i: integer;
s: string;
begin
testrptmemo.Lines.Add(' ');
testrptmemo.Lines.Add(' ');
testrptmemo.Lines.Add
(' ==============='+econfile.filename+'測(cè)試報(bào)告=============== ');
testrptmemo.Lines.Add(' ');
S := '產(chǎn)品編號(hào): ' + '測(cè)試日期: '
+ DateToStr(Date) + ' ' + '質(zhì)檢編號(hào): ';
testrptmemo.Lines.Add(S);
testrptmemo.Lines.Add(' ');
if econfile.coilstatetotal>0 then
begin
testrptmemo.Lines.Add(' ');
s := '開(kāi)關(guān)量輸出測(cè)試結(jié)果';
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -