procedure TForm1.Timer1Timer(Sender: TObject);
var
ibyteindex:integer;
ibitindex:integer;
errreadoutputpoint:integer;
vdata:olevariant;
datatype:pointdatatypeconstants;
i,j,k,l:integer;
begin
k:=0;
//s7prosim1.ExecuteSingleScan;
for i:=0 to 4 do
begin
for j:=0 to 7 do
begin
ibyteindex:=i;
ibitindex:=j;
datatype:=s7_bit;
errreadoutputpoint:=s7prosim1.ReadOutputPoint(ibyteindex,ibitindex,datatype,vdata);
table1.Edit;
table1.FieldByName('Q'+inttostr(i)+'.'+inttostr(j)).AsInteger:=vdata;
table1.Post;
end;
end;
if table2.FieldByName('Q0.0').AsInteger =1 then
begin
image1.Visible :=true;
end
else
begin
image1.Visible :=false;
end;
if table1.FieldByName('Q0.1').AsInteger =1 then
begin
image2.Visible :=true;
end
else
begin
image2.Visible :=false;
end;
if table1.FieldByName('Q0.2').AsInteger =1 then
begin
image3.Visible :=true;
end
else
begin
image3.Visible :=false;
end;
if table1.FieldByName('Q0.3').AsInteger =1 then
begin
image4.Visible :=true;
end
else
begin
image4.Visible :=false;
end;
if table1.FieldByName('Q0.4').AsInteger =1 then
begin
image5.Visible :=true;
end
else
begin
image5.Visible :=false;
end;
if table1.FieldByName('Q0.5').AsInteger =1 then
begin
image6.Visible :=tru
DELPHI访问PLC输出口
最新推荐文章于 2023-06-25 10:06:05 发布
这段代码展示了如何用Delphi通过定时器Timer1读取PLC的输出点,并根据读取的数据控制图片的可见性。同时,它还读取了一些特定地址的Word数据并进行转换显示。代码询问是否有更直接的方法来访问PLC的输入输出及内部功能。
摘要由CSDN通过智能技术生成