|
|
|
@ -27,22 +27,22 @@ namespace DataBlockHelper
|
|
|
|
|
SiemensPLCS siemensPLCS = SiemensPLCS.S1500;
|
|
|
|
|
SiemensS7Net s7 = new SiemensS7Net(siemensPLCS);
|
|
|
|
|
s7.SetPersistentConnection();
|
|
|
|
|
// s7.IpAddress = "172.18.4.100";
|
|
|
|
|
s7.IpAddress = "172.18.4.100";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s7.IpAddress = "192.168.1.110";
|
|
|
|
|
//s7.IpAddress = "192.168.1.110";
|
|
|
|
|
s7.Port = 102;
|
|
|
|
|
var su = s7.ConnectServer();
|
|
|
|
|
|
|
|
|
|
if (!su.IsSuccess)
|
|
|
|
|
{
|
|
|
|
|
//s7.IpAddress = "192.168.0.100";
|
|
|
|
|
//s7.Port = 7788;
|
|
|
|
|
//var fn = s7.ConnectServer();
|
|
|
|
|
//if (!fn.IsSuccess)
|
|
|
|
|
//{
|
|
|
|
|
// return new SiemensS7Net(siemensPLCS);
|
|
|
|
|
//}
|
|
|
|
|
s7.IpAddress = "192.168.0.100";
|
|
|
|
|
s7.Port = 7788;
|
|
|
|
|
var fn = s7.ConnectServer();
|
|
|
|
|
if (!fn.IsSuccess)
|
|
|
|
|
{
|
|
|
|
|
return new SiemensS7Net(siemensPLCS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return s7;
|
|
|
|
|