procedure TFmain.Comm1ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word); var t_B:ARRAY[1..8192] oF CHAR ; i:word; beginmove(buffer^,t_b,bufferlength); if start then begin for i:=1 to bufferlength do begin ReceiveText.Text:=ReceiveText.Text+' '+inttohex(ord(t_b[i]),2); end; end; end;procedure TFmain.AReceiveExecute(Sender: TObject); begin try comm1.StartComm; Start:=true; Areceive.Enabled:=false; asetcom.Enabled:=false; astop.Enabled:=true; Statusbar.Panels[1].Text:=Tostr(); Statusbar.Panels[0].Text:='接收状态...'; except Error($100); end; end;procedure TFmain.AstopExecute(Sender: TObject); begin try comm1.StopComm; start:=false; astop.Enabled:=false; asetcom.Enabled:=true; Areceive.Enabled:=true; Statusbar.Panels[1].Text:='串口状态未知'; Statusbar.Panels[0].Text:='停止状态...';except Error($101); end; end;procedure TFmain.AfontExecute(Sender: TObject); begin if FontDialog.Execute then begin ReceiveText.Font:=FontDialog.Font; end; end;procedure TFmain.AcolorExecute(Sender: TObject); begin if ColorDialog.Execute then begin ReceiveText.Color:=ColorDialog.Color; end; end;
先发送读数据申请,PLC返回确认,再发送读数据指令,然后才返回所要的数据(两次写操作) 2>读VD104 地址的数据:也是和上面的一样的,只是地址不一样而已
3>读VD108 地址的数据:也是和上面的一样的,只是地址不一样而已
要用到线程吗?请问怎么做????
BufferLength: Word);
var t_B:ARRAY[1..8192] oF CHAR ;
i:word;
beginmove(buffer^,t_b,bufferlength);
if start then
begin
for i:=1 to bufferlength do
begin
ReceiveText.Text:=ReceiveText.Text+' '+inttohex(ord(t_b[i]),2);
end;
end;
end;procedure TFmain.AReceiveExecute(Sender: TObject);
begin
try
comm1.StartComm;
Start:=true;
Areceive.Enabled:=false;
asetcom.Enabled:=false;
astop.Enabled:=true;
Statusbar.Panels[1].Text:=Tostr();
Statusbar.Panels[0].Text:='接收状态...';
except
Error($100);
end;
end;procedure TFmain.AstopExecute(Sender: TObject);
begin
try
comm1.StopComm;
start:=false;
astop.Enabled:=false;
asetcom.Enabled:=true;
Areceive.Enabled:=true;
Statusbar.Panels[1].Text:='串口状态未知';
Statusbar.Panels[0].Text:='停止状态...';except
Error($101);
end;
end;procedure TFmain.AfontExecute(Sender: TObject);
begin
if FontDialog.Execute then
begin
ReceiveText.Font:=FontDialog.Font;
end;
end;procedure TFmain.AcolorExecute(Sender: TObject);
begin
if ColorDialog.Execute then
begin
ReceiveText.Color:=ColorDialog.Color;
end;
end;
--------------------
我的程序要读一个PLC的三个地址的数据,是不是要用到线程?定时器可以吗?? 1>读VD100 地址的数据:
先发送读数据申请,PLC返回确认,再发送读数据指令,然后才返回所要的数据(两次写操作) 2>读VD104 地址的数据:也是和上面的一样的,只是地址不一样而已
3>读VD108 地址的数据:也是和上面的一样的,只是地址不一样而已
要用到线程吗?请问怎么做????