【发布时间】:2021-08-17 06:58:30
【问题描述】:
我在 C# WPF 应用程序中使用 S7.NET 库将我的 PC 连接到 Siemens PLC。有一个属性,isConnected。如果我使用 plc.Open() 连接到 PLC,则属性返回值变为 true。但是,如果我断开 PLC 电缆,属性值仍然为真。为什么?
private void checkPlcConnection()
{
Plc plc = new Plc(CpuType.S71200, "192.168.0.1", 0, 1);
plc.Open(); // Cable was connected when method called
while(true)
{
Thread.Sleep(1000);
Trace.WriteLine(plc.IsConnected); // True, after remove the cable still true
}
}
【问题讨论】:
-
见下面的代码
-
请不要将代码发布为图片,related topic。