procedure Tshenchanform.s_timeTimer(Sender: TObject); //砂石 begin if (hgzk.s_jingchen=0) and (hgzk.jinchen=2) then //进程0 begin if (hgzk.panshu_s<hgzk.panshu) and (hgzk.liao_pl[0]) then begin if (hgzk.weight_0 < (strtoint(stringgrid1.Cells[1,1])+round(strtoint(stringgrid1.Cells[1,1])*strtofloat(edit40.Text)))) then // then+round(strtofloat(stringgrid1.Cells[1,1])*hgzk.s_hsl/100))) then begin if ((di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[0])>0) or (chanshuform.CheckBox13.Checked))then begin if chanshuform.CheckBox40.Checked then begin if hgzk.weight_0 <strtoint(stringgrid1.Cells[1,1])-strtoint(chanshuform.Edit72.Text)then begin hgzk.digitaloutput_value[0]:=1; hgzk.digitaloutput_value[18]:=1; do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); image26.Visible :=true; hgzk.baojin_1_1:=''; end else begin hgzk.s_wc_time :=hgzk.s_wc_time+1; if hgzk.s_wc_time<(strtoint(chanshuform.edit45.Text)*20)then begin hgzk.digitaloutput_value[0]:=0; hgzk.digitaloutput_value[18]:=0; do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); image26.Visible :=false; end else begin hgzk.s1_dd_time:=hgzk.s1_dd_time+1; if hgzk.s1_dd_time<(round(strtofloat(chanshuform.edit68.Text)*10)*2)then begin hgzk.digitaloutput_value[18]:=1; do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); image26.Visible :=true; end else begin hgzk.digitaloutput_value[18]:=0; do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); hgzk.s_wc_time :=0; hgzk.s1_dd_time :=0; image26.Visible :=false; end; end; end; end else begin if hgzk.weight_0 < strtoint(stringgrid1.Cells[1,1])-strtoint(chanshuform.Edit13.Text) then hgzk.digitaloutput_value[0]:=1 else hgzk.digitaloutput_value[0]:=0; hgzk.digitaloutput_value[18]:=1; //hgzk.digitaloutput_value[25]:=1; //do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[25],hgzk.digitaloutput_value[25]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); //hgzk.weight_0:=hgzk.weight_0+10; //模拟 image26.Visible :=true; hgzk.baojin_1_1:=''; end; end else begin hgzk.digitaloutput_value[0]:=0; hgzk.digitaloutput_value[18]:=0; //hgzk.digitaloutput_value[25]:=0; //do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[25],hgzk.digitaloutput_value[25]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); image26.Visible :=false; hgzk.baojin_1_1:='石头1放料门被打开无法进行石头1计量'; end; end; if(not(chanshuform.CheckBox1.Checked))and (not(chanshuform.CheckBox40.Checked)) and (hgzk.weight_0>=(strtoint(stringgrid1.Cells[1,1])+round(strtoint(stringgrid1.Cells[1,1])*strtofloat(edit40.Text))-strtoint(chanshuform.Edit1.Text))) then begin hgzk.digitaloutput_value[0]:=0; hgzk.digitaloutput_value[18]:=0; //hgzk.digitaloutput_value[25]:=0; // do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[25],hgzk.digitaloutput_value[25]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); image26.Visible :=false; hgzk.s_wc_time :=0; hgzk.s1_dd_time :=0; hgzk.s_jingchen:=1; end; if (chanshuform.CheckBox40.Checked )and(not(chanshuform.CheckBox1.Checked )) and (hgzk.weight_0>=(strtoint(stringgrid1.Cells[1,1])+round(strtoint(stringgrid1.Cells[1,1])*strtofloat(edit40.Text))-strtoint(chanshuform.edit64.Text))) then begin hgzk.digitaloutput_value[0]:=0; hgzk.digitaloutput_value[18]:=0; //hgzk.digitaloutput_value[25]:=0; // do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[25],hgzk.digitaloutput_value[25]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); image26.Visible :=false; hgzk.s_wc_time :=0; hgzk.s1_dd_time :=0; hgzk.s_jingchen:=1; end; if (chanshuform.CheckBox1.Checked) and (hgzk.weight_0 >= (strtoint(stringgrid1.Cells[1,1])+round(strtoint(stringgrid1.Cells[1,1])*strtofloat(edit40.Text))-hgzk.buchan_1)) then begin hgzk.digitaloutput_value[0]:=0; hgzk.digitaloutput_value[18]:=0; do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); image26.Visible :=false; hgzk.s_wc_time :=0; hgzk.s1_dd_time :=0; hgzk.s_jingchen:=1; end; end else begin hgzk.digitaloutput_value[0]:=0; hgzk.digitaloutput_value[18]:=0; do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]); do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]); image26.Visible :=false; end; if not(hgzk.liao_pl[0]) then begin hgzk.s_jl_wc:=true; hgzk.s_jingchen :=0; end; end; //进料 if (hgzk.s_jingchen=1) and (hgzk.jinchen =2)then //进程1稳称统计 begin hgzk.s_wc_time:=hgzk.s_wc_time+1; if hgzk.s_wc_time> strtoint(chanshuform.edit45.Text)*20 then begin stringgrid1.Cells[2,1]:=inttostr(hgzk.weight_0); stringgrid1.Cells[3,1]:=floattostr(round(((hgzk.weight_0-strtoint(stringgrid1.Cells[1,1]))/strtoint(stringgrid1.Cells[1,1]))*10000)/100); if abs(strtofloat(stringgrid1.Cells[3,1]))>=(strtofloat(chanshuform.edit33.Text))then hgzk.baojin_1:='石头1误差过大' else hgzk.baojin_1:=''; if abs(strtofloat(stringgrid1.Cells[3,1]))>strtofloat(chanshuform.Edit33.Text) then hgzk.zzxl_s:=true; hgzk.buchan_1 :=strtoint(stringgrid1.Cells[2,1])-strtoint(stringgrid1.Cells[1,1])+hgzk.buchan_1; hgzk.s_jl_wc:=true; hgzk.s_wc_time:=0; hgzk.s_jingchen :=2; end; end; if(hgzk.s_jingchen =2)and(hgzk.jinchen =2) then //进程3放料 begin if hgzk.s_fl_wc then begin hgzk.panshu_s:=hgzk.panshu_s+1; hgzk.s_fl_wc:=false; hgzk.s_jl_wc:=false; hgzk.s_jingchen:=0; end; end; end;//这只是其中的某一种流程控制.
procedure Tshenchanform.digitalinput_readTimer(Sender: TObject); begin if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[17])>0 then begin image81.Visible :=false; shape11.Brush.Color:=rgb(255,255,0); end else begin shape11.Brush.Color:=rgb(0,255,0); image81.Visible :=true; end; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[11])>0 then begin label30.Visible :=true; image22.Visible :=false; end else begin label30.Visible :=false; image22.Visible :=true; end; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[12])>0 then label31.Visible :=true else label31.Visible :=false; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[13])>0 then label32.Visible :=true else label32.Visible :=false; if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[5])>0) then begin image41.Visible :=false; shape5.brush.Color:=rgb(255,255,0); end else begin image41.Visible :=true; shape5.brush.Color:=rgb(0,255,0); end; if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[4])>0)then begin image41.Visible :=true; shape5.brush.Color:=rgb(0,255,0); end; if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[16])>0) then begin label55.Caption :='自动'; label55.Font.Color:=rgb(0,255,0); end else begin label55.Caption :='手动'; label55.Font.Color:=rgb(255,255,0); if (hgzk.start_shenchan)then hgzk.zt:=true; end; if (di6405bit(hgzk.base_add_Di,hgzk.digitalinput_add[23])>0 )then begin hgzk.baojin_wx_now :='有人维修,请勿合闸!'; end else begin hgzk.baojin_wx_now :=''; end; if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[1])>0) then begin image27.Visible :=false; shape2.Brush.Color:=rgb(255,255,0); end else begin image27.Visible :=true; shape2.Brush.Color:=rgb(0,255,0); end; if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[2])>0) then begin image28.Visible :=false; shape3.Brush.Color:=rgb(255,255,0); end else begin image28.Visible :=true; shape3.Brush.Color:=rgb(0,255,0); end; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[3])>0 then begin image29.Visible :=false; shape4.Brush.Color:=rgb(255,255,0); end else begin image29.Visible :=true; shape4.Brush.Color:=rgb(0,255,0); end; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[0])>0 then begin image21.Visible :=false; shape1.Brush.Color:=rgb(255,255,0); end else begin image21.Visible :=true; shape1.Brush.Color:=rgb(0,255,0); end; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[6])>0 then begin image42.Visible :=false; shape6.Brush.Color:=rgb(255,255,0); end else begin image42.Visible :=true; shape6.Brush.Color:=rgb(0,255,0); end; if di6405bit(hgzk.base_add_Di,hgzk.digitalinput_add[7])>0 then begin shape7.Brush.Color:=rgb(255,255,0); image43.Visible :=false; end else begin image43.Visible :=true; shape7.Brush.Color:=rgb(0,255,0); end; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[10])>0 then begin image57.Visible :=true; end else begin image57.Visible :=false; end; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[8])>0 then begin image79.Visible :=false; shape8.Brush.Color:=rgb(255,255,0); end else begin image79.Visible :=true; shape8.Brush.Color:=rgb(0,255,0); end; if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[9])>0 then begin shape9.Brush.Color:=rgb(255,255,0); end else begin shape9.Brush.Color:=rgb(0,255,0); end; if di6405bit(hgzk.base_add_DI,digitalinput_add[14])>0 then begin image59.Visible :=true; end else begin image59.Visible :=false; end; if di6405bit(hgzk.base_add_DI,digitalinput_add[15])>0 then begin image56.Visible :=true; end else begin image56.Visible :=false; end; end;//这个过程为数字量检测. procedure Tshenchanform.readdataTimer(Sender: TObject); begin try MSComm1.InputLen:=18; MSComm1.InBufferCount:=0; MSComm1.RThreshold:=18; MSComm1.Output:='READ' + Chr(13) + Chr(10);MSComm2.InputLen:=18; MSComm2.InBufferCount:=0; MSComm2.RThreshold:=18; MSComm2.Output:='READ' + Chr(13) + Chr(10);MSComm3.InputLen:=18; MSComm3.InBufferCount:=0; MSComm3.RThreshold:=18; MSComm3.Output:='READ' + Chr(13) + Chr(10); MSComm5.InputLen:=18; MSComm5.InBufferCount:=0; MSComm5.RThreshold:=18; MSComm5.Output:='READ' + Chr(13) + Chr(10);MSComm6.InputLen:=18; MSComm6.InBufferCount:=0; MSComm6.RThreshold:=18; MSComm6.Output:='READ' + Chr(13) + Chr(10);MSComm7.InputLen:=18; MSComm7.InBufferCount:=0; MSComm7.RThreshold:=18; MSComm7.Output:='READ' + Chr(13) + Chr(10);MSComm8.InputLen:=18; MSComm8.InBufferCount:=0; MSComm8.RThreshold:=18; MSComm8.Output:='READ' + Chr(13) + Chr(10);MSComm9.InputLen:=18; MSComm9.InBufferCount:=0; MSComm9.RThreshold:=18; MSComm9.Output:='READ' + Chr(13) + Chr(10);mscomm4.InputLen:=18; mscomm4.InBufferCount :=0; mscomm4.RThreshold :=18; mscomm4.Output:='READ'+chr(13)+chr(10); except end; end;//这个过程为数据读取指令传送.
begin
if (hgzk.s_jingchen=0) and (hgzk.jinchen=2) then //进程0
begin
if (hgzk.panshu_s<hgzk.panshu) and (hgzk.liao_pl[0]) then
begin
if (hgzk.weight_0 < (strtoint(stringgrid1.Cells[1,1])+round(strtoint(stringgrid1.Cells[1,1])*strtofloat(edit40.Text)))) then // then+round(strtofloat(stringgrid1.Cells[1,1])*hgzk.s_hsl/100))) then
begin
if ((di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[0])>0) or (chanshuform.CheckBox13.Checked))then
begin
if chanshuform.CheckBox40.Checked then
begin
if hgzk.weight_0 <strtoint(stringgrid1.Cells[1,1])-strtoint(chanshuform.Edit72.Text)then
begin
hgzk.digitaloutput_value[0]:=1;
hgzk.digitaloutput_value[18]:=1;
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
image26.Visible :=true;
hgzk.baojin_1_1:='';
end
else
begin
hgzk.s_wc_time :=hgzk.s_wc_time+1;
if hgzk.s_wc_time<(strtoint(chanshuform.edit45.Text)*20)then
begin
hgzk.digitaloutput_value[0]:=0;
hgzk.digitaloutput_value[18]:=0;
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
image26.Visible :=false;
end
else
begin
hgzk.s1_dd_time:=hgzk.s1_dd_time+1;
if hgzk.s1_dd_time<(round(strtofloat(chanshuform.edit68.Text)*10)*2)then
begin
hgzk.digitaloutput_value[18]:=1;
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
image26.Visible :=true;
end
else
begin
hgzk.digitaloutput_value[18]:=0;
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
hgzk.s_wc_time :=0;
hgzk.s1_dd_time :=0;
image26.Visible :=false;
end;
end;
end;
end
else
begin
if hgzk.weight_0 < strtoint(stringgrid1.Cells[1,1])-strtoint(chanshuform.Edit13.Text) then hgzk.digitaloutput_value[0]:=1
else hgzk.digitaloutput_value[0]:=0;
hgzk.digitaloutput_value[18]:=1;
//hgzk.digitaloutput_value[25]:=1;
//do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[25],hgzk.digitaloutput_value[25]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
//hgzk.weight_0:=hgzk.weight_0+10; //模拟
image26.Visible :=true;
hgzk.baojin_1_1:='';
end;
end
else
begin
hgzk.digitaloutput_value[0]:=0;
hgzk.digitaloutput_value[18]:=0;
//hgzk.digitaloutput_value[25]:=0;
//do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[25],hgzk.digitaloutput_value[25]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
image26.Visible :=false;
hgzk.baojin_1_1:='石头1放料门被打开无法进行石头1计量';
end;
end;
if(not(chanshuform.CheckBox1.Checked))and (not(chanshuform.CheckBox40.Checked)) and (hgzk.weight_0>=(strtoint(stringgrid1.Cells[1,1])+round(strtoint(stringgrid1.Cells[1,1])*strtofloat(edit40.Text))-strtoint(chanshuform.Edit1.Text))) then
begin
hgzk.digitaloutput_value[0]:=0;
hgzk.digitaloutput_value[18]:=0;
//hgzk.digitaloutput_value[25]:=0;
// do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[25],hgzk.digitaloutput_value[25]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
image26.Visible :=false;
hgzk.s_wc_time :=0;
hgzk.s1_dd_time :=0;
hgzk.s_jingchen:=1;
end;
if (chanshuform.CheckBox40.Checked )and(not(chanshuform.CheckBox1.Checked )) and (hgzk.weight_0>=(strtoint(stringgrid1.Cells[1,1])+round(strtoint(stringgrid1.Cells[1,1])*strtofloat(edit40.Text))-strtoint(chanshuform.edit64.Text))) then
begin
hgzk.digitaloutput_value[0]:=0;
hgzk.digitaloutput_value[18]:=0;
//hgzk.digitaloutput_value[25]:=0;
// do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[25],hgzk.digitaloutput_value[25]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
image26.Visible :=false;
hgzk.s_wc_time :=0;
hgzk.s1_dd_time :=0;
hgzk.s_jingchen:=1;
end; if (chanshuform.CheckBox1.Checked) and (hgzk.weight_0 >= (strtoint(stringgrid1.Cells[1,1])+round(strtoint(stringgrid1.Cells[1,1])*strtofloat(edit40.Text))-hgzk.buchan_1)) then
begin
hgzk.digitaloutput_value[0]:=0;
hgzk.digitaloutput_value[18]:=0;
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
image26.Visible :=false;
hgzk.s_wc_time :=0;
hgzk.s1_dd_time :=0;
hgzk.s_jingchen:=1;
end;
end
else
begin
hgzk.digitaloutput_value[0]:=0;
hgzk.digitaloutput_value[18]:=0;
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[0],hgzk.digitaloutput_value[0]);
do6407bit(hgzk.base_add_DO,hgzk.digitaloutput_add[18],hgzk.digitaloutput_value[18]);
image26.Visible :=false;
end;
if not(hgzk.liao_pl[0]) then
begin
hgzk.s_jl_wc:=true;
hgzk.s_jingchen :=0;
end;
end; //进料
if (hgzk.s_jingchen=1) and (hgzk.jinchen =2)then //进程1稳称统计
begin
hgzk.s_wc_time:=hgzk.s_wc_time+1;
if hgzk.s_wc_time> strtoint(chanshuform.edit45.Text)*20 then
begin
stringgrid1.Cells[2,1]:=inttostr(hgzk.weight_0);
stringgrid1.Cells[3,1]:=floattostr(round(((hgzk.weight_0-strtoint(stringgrid1.Cells[1,1]))/strtoint(stringgrid1.Cells[1,1]))*10000)/100);
if abs(strtofloat(stringgrid1.Cells[3,1]))>=(strtofloat(chanshuform.edit33.Text))then hgzk.baojin_1:='石头1误差过大'
else hgzk.baojin_1:='';
if abs(strtofloat(stringgrid1.Cells[3,1]))>strtofloat(chanshuform.Edit33.Text) then hgzk.zzxl_s:=true;
hgzk.buchan_1 :=strtoint(stringgrid1.Cells[2,1])-strtoint(stringgrid1.Cells[1,1])+hgzk.buchan_1;
hgzk.s_jl_wc:=true;
hgzk.s_wc_time:=0;
hgzk.s_jingchen :=2;
end;
end;
if(hgzk.s_jingchen =2)and(hgzk.jinchen =2) then //进程3放料
begin
if hgzk.s_fl_wc then
begin
hgzk.panshu_s:=hgzk.panshu_s+1;
hgzk.s_fl_wc:=false;
hgzk.s_jl_wc:=false;
hgzk.s_jingchen:=0;
end;
end;
end;//这只是其中的某一种流程控制.
begin
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[17])>0 then
begin
image81.Visible :=false;
shape11.Brush.Color:=rgb(255,255,0);
end
else
begin
shape11.Brush.Color:=rgb(0,255,0);
image81.Visible :=true;
end;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[11])>0 then
begin
label30.Visible :=true;
image22.Visible :=false;
end
else
begin
label30.Visible :=false;
image22.Visible :=true;
end;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[12])>0 then label31.Visible :=true
else label31.Visible :=false;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[13])>0 then label32.Visible :=true
else label32.Visible :=false;
if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[5])>0) then
begin
image41.Visible :=false;
shape5.brush.Color:=rgb(255,255,0);
end
else
begin
image41.Visible :=true;
shape5.brush.Color:=rgb(0,255,0);
end;
if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[4])>0)then
begin
image41.Visible :=true;
shape5.brush.Color:=rgb(0,255,0);
end;
if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[16])>0) then
begin
label55.Caption :='自动';
label55.Font.Color:=rgb(0,255,0);
end
else
begin
label55.Caption :='手动';
label55.Font.Color:=rgb(255,255,0);
if (hgzk.start_shenchan)then hgzk.zt:=true;
end;
if (di6405bit(hgzk.base_add_Di,hgzk.digitalinput_add[23])>0 )then
begin
hgzk.baojin_wx_now :='有人维修,请勿合闸!';
end
else
begin
hgzk.baojin_wx_now :='';
end;
if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[1])>0) then
begin
image27.Visible :=false;
shape2.Brush.Color:=rgb(255,255,0);
end
else
begin
image27.Visible :=true;
shape2.Brush.Color:=rgb(0,255,0);
end;
if (di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[2])>0) then
begin
image28.Visible :=false;
shape3.Brush.Color:=rgb(255,255,0);
end
else
begin
image28.Visible :=true;
shape3.Brush.Color:=rgb(0,255,0);
end;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[3])>0 then
begin
image29.Visible :=false;
shape4.Brush.Color:=rgb(255,255,0);
end
else
begin
image29.Visible :=true;
shape4.Brush.Color:=rgb(0,255,0);
end;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[0])>0 then
begin
image21.Visible :=false;
shape1.Brush.Color:=rgb(255,255,0);
end
else
begin
image21.Visible :=true;
shape1.Brush.Color:=rgb(0,255,0);
end;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[6])>0 then
begin
image42.Visible :=false;
shape6.Brush.Color:=rgb(255,255,0);
end
else
begin
image42.Visible :=true;
shape6.Brush.Color:=rgb(0,255,0);
end;
if di6405bit(hgzk.base_add_Di,hgzk.digitalinput_add[7])>0 then
begin
shape7.Brush.Color:=rgb(255,255,0);
image43.Visible :=false;
end
else
begin
image43.Visible :=true;
shape7.Brush.Color:=rgb(0,255,0);
end;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[10])>0 then
begin
image57.Visible :=true;
end
else
begin
image57.Visible :=false;
end;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[8])>0 then
begin
image79.Visible :=false;
shape8.Brush.Color:=rgb(255,255,0);
end
else
begin
image79.Visible :=true;
shape8.Brush.Color:=rgb(0,255,0);
end;
if di6405bit(hgzk.base_add_DI,hgzk.digitalinput_add[9])>0 then
begin
shape9.Brush.Color:=rgb(255,255,0);
end
else
begin
shape9.Brush.Color:=rgb(0,255,0);
end;
if di6405bit(hgzk.base_add_DI,digitalinput_add[14])>0 then
begin
image59.Visible :=true;
end
else
begin
image59.Visible :=false;
end;
if di6405bit(hgzk.base_add_DI,digitalinput_add[15])>0 then
begin
image56.Visible :=true;
end
else
begin
image56.Visible :=false;
end;
end;//这个过程为数字量检测.
procedure Tshenchanform.readdataTimer(Sender: TObject);
begin
try
MSComm1.InputLen:=18;
MSComm1.InBufferCount:=0;
MSComm1.RThreshold:=18;
MSComm1.Output:='READ' + Chr(13) + Chr(10);MSComm2.InputLen:=18;
MSComm2.InBufferCount:=0;
MSComm2.RThreshold:=18;
MSComm2.Output:='READ' + Chr(13) + Chr(10);MSComm3.InputLen:=18;
MSComm3.InBufferCount:=0;
MSComm3.RThreshold:=18;
MSComm3.Output:='READ' + Chr(13) + Chr(10);
MSComm5.InputLen:=18;
MSComm5.InBufferCount:=0;
MSComm5.RThreshold:=18;
MSComm5.Output:='READ' + Chr(13) + Chr(10);MSComm6.InputLen:=18;
MSComm6.InBufferCount:=0;
MSComm6.RThreshold:=18;
MSComm6.Output:='READ' + Chr(13) + Chr(10);MSComm7.InputLen:=18;
MSComm7.InBufferCount:=0;
MSComm7.RThreshold:=18;
MSComm7.Output:='READ' + Chr(13) + Chr(10);MSComm8.InputLen:=18;
MSComm8.InBufferCount:=0;
MSComm8.RThreshold:=18;
MSComm8.Output:='READ' + Chr(13) + Chr(10);MSComm9.InputLen:=18;
MSComm9.InBufferCount:=0;
MSComm9.RThreshold:=18;
MSComm9.Output:='READ' + Chr(13) + Chr(10);mscomm4.InputLen:=18;
mscomm4.InBufferCount :=0;
mscomm4.RThreshold :=18;
mscomm4.Output:='READ'+chr(13)+chr(10);
except
end;
end;//这个过程为数据读取指令传送.
QQ:463418145
MSComm1.InputLen:=18;
MSComm1.InBufferCount:=0;
MSComm1.RThreshold:=18;
MSComm1.Output:='READ' + Chr(13) + Chr(10);MSComm2.InputLen:=18;
MSComm2.InBufferCount:=0;
MSComm2.RThreshold:=18;
MSComm2.Output:='READ' + Chr(13) + Chr(10);MSComm3.InputLen:=18;
MSComm3.InBufferCount:=0;
MSComm3.RThreshold:=18;
MSComm3.Output:='READ' + Chr(13) + Chr(10);
MSComm5.InputLen:=18;
MSComm5.InBufferCount:=0;
MSComm5.RThreshold:=18;
MSComm5.Output:='READ' + Chr(13) + Chr(10);MSComm6.InputLen:=18;
MSComm6.InBufferCount:=0;
MSComm6.RThreshold:=18;
MSComm6.Output:='READ' + Chr(13) + Chr(10);MSComm7.InputLen:=18;
MSComm7.InBufferCount:=0;
MSComm7.RThreshold:=18;
MSComm7.Output:='READ' + Chr(13) + Chr(10);MSComm8.InputLen:=18;
MSComm8.InBufferCount:=0;
MSComm8.RThreshold:=18;
MSComm8.Output:='READ' + Chr(13) + Chr(10);MSComm9.InputLen:=18;
MSComm9.InBufferCount:=0;
MSComm9.RThreshold:=18;
MSComm9.Output:='READ' + Chr(13) + Chr(10);mscomm4.InputLen:=18;
mscomm4.InBufferCount :=0;
mscomm4.RThreshold :=18;
mscomm4.Output:='READ'+chr(13)+chr(10);用了这么多MSCOMM32控件,可用数组与子程序的办法简化一下嘛。
编程序有技巧的。
反正你的程序根本就不是多线程,干脆在执行时先将timer关闭,结束再打开procedure Tshenchanform.s_timeTimer(Sender: TObject); //砂石
begin
Timer(Sender).enabled:=False;
try
。
finally
Timer(Sender).enabled:=True;
end;
end;