unit ThreadUnit2;
interface
uses
Classes,sysutils,mmsystem;
type
MyThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
end;
implementation
uses Unit1, MainForm, chartviewform, chartform, runselectform;
procedure MyThread.Execute;
var
i:byte;
//chartview:array of Tchartview;
begin
freeOnTerminate := true;
setlength(send40,10);
setlength(recv40,5400);
while( not terminated)do
//我这里是个死循环。第一次执行没有问题,第二次到这里就报那个错误
begin
send40[0]:=3;
send40[1]:=0;
send40[2]:=40;
SendData(lsn[2],send40);
RecvData(lsn[2],recv40);
if (recv40[2]=40) and (recv40[3]=1) then
for i:=0 to high(chartview1)do
begin
if chartview1<>nil then
//这是一个窗体的多实例
chartview1.Timer1.Enabled:=true;
end;
{加载就绪请求启动时钟*******} //都是指一时钟
if recv40[173]=1 then
begin
send40[0]:=5;
send40[1]:=0;
send40[2]:=37;
send40[3]:=1;
send40[4]:=1;
SendData(lsn[2],send40);
RecvData(lsn[2],recv40);
if comflag40=21 then
senddata21;
end;
{动踏步降频请求}
if recv40[173]=2 then
begin
send40[0]:=5;
send40[1]:=0;
send40[2]:=37;
send40[3]:=1;
send40[4]:=2;
SendData(lsn[2],send40);
RecvData(lsn[2],recv40);
end;
{静力实验保持时间到请求加载下一谱段******}
if recv40[173]=4 then
begin
send40[0]:=5;
send40[1]:=0;
send40[2]:=37;
send40[3]:=1;
send40[4]:=4;
SendData(lsn[2],send40);
RecvData(lsn[2],recv40);
end;
{静踏步保持?}
if recv40[173]=6 then
begin
send40[0]:=5;
send40[1]:=0;
send40[2]:=31;
send40[3]:=1;
send40[4]:=1;
SendData(lsn[2],send40);
// RecvData(lsn[2],recv40);
end;
{静踏步卸载}
if recv40[173]=8 then
begin
send40[0]:=5;
send40[1]:=0;
send40[2]:=30;
send40[3]:=1;
send40[4]:=0;
SendData(lsn[2],send40);
RecvData(lsn[2],recv40);
end;
{卸载启动时钟*******}
if recv40[173]=9 then
begin
send40[0]:=5;
send40[1]:=0;
send40[2]:=37;
send40[3]:=1;
send40[4]:=5;
SendData(lsn[2],send40);
RecvData(lsn[2],recv40);
end;
{卸载完成***********}
if recv40[170] = 4 then
begin
i:=1;
saveend(i);
end;
sleep(200);
end;
end;
end.