|
|
|
@ -36,14 +36,15 @@ namespace HighWayIot.Plc
|
|
|
|
|
SocketKeepAliveTime = -1,
|
|
|
|
|
IsPersistentConnection = true,
|
|
|
|
|
};
|
|
|
|
|
plc.ConnectServer();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("初始化PLC服务器发生错误!", ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string s = IsConnect ? "正常" : "异常";
|
|
|
|
|
logHelper.Info($"PLC连接:{s}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return plc;
|
|
|
|
|
}
|
|
|
|
@ -55,6 +56,7 @@ namespace HighWayIot.Plc
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (MelsecInstance == null) return false;
|
|
|
|
|
var result = MelsecInstance.ReadPlcType();
|
|
|
|
|
logHelper.Info($"PLC型号:{result.Content}");
|
|
|
|
|
return result.IsSuccess;
|
|
|
|
|