From 54f4c75834a9315d527e650126dd9be2de2b8fa2 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Wed, 25 Dec 2024 15:56:56 +0800 Subject: [PATCH] =?UTF-8?q?fix=20-=20=E5=B0=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HighWayIot.Plc/HighWayIot.Plc.csproj | 7 ++--- HighWayIot.Plc/PlcConnect.cs | 33 +++++++++----------- HighWayIot.Plc/packages.config | 5 +++ HighWayIot.Winform/App.config | 14 ++++++++- HighWayIot.Winform/HighWayIot.Winform.csproj | 5 --- 5 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 HighWayIot.Plc/packages.config diff --git a/HighWayIot.Plc/HighWayIot.Plc.csproj b/HighWayIot.Plc/HighWayIot.Plc.csproj index 0dcc92f..dd306dc 100644 --- a/HighWayIot.Plc/HighWayIot.Plc.csproj +++ b/HighWayIot.Plc/HighWayIot.Plc.csproj @@ -32,10 +32,6 @@ 4 - - False - ..\HighWayIot.Library\HslCommunication.dll - @@ -63,5 +59,8 @@ + + + \ No newline at end of file diff --git a/HighWayIot.Plc/PlcConnect.cs b/HighWayIot.Plc/PlcConnect.cs index 7c71b05..46ddacf 100644 --- a/HighWayIot.Plc/PlcConnect.cs +++ b/HighWayIot.Plc/PlcConnect.cs @@ -37,11 +37,7 @@ namespace HighWayIot.Plc IsPersistentConnection = true, }; var a = plc.ConnectServer(); - logHelper.Info($"Plc连接 信息:[{a.Message}] 是否成功:[{a.IsSuccess.ToString()}] 错误代码:[{a.ErrorCode}]"); - if (!reslt.IsSuccess) - { - logHelper.Info("链接失败:"+reslt.Message); - } + logHelper.Info($"Plc连接 信息:[{a.Message}] 是否成功:[{a.IsSuccess.ToString()}] 错误代码:[{a.ErrorCode}]"); } catch (Exception ex) { @@ -54,22 +50,23 @@ namespace HighWayIot.Plc return plc; } - ///// - ///// plc 是不是保持链接 - ///// - //public static bool IsConnect - //{ - // get - // { - // if (MelsecInstance == null) return false; - // var result = MelsecInstance.ReadPlcType(); - // logHelper.Info($"PLC型号:{result.Content}"); - // return result.IsSuccess; - // } - //} + /// + /// plc 是不是保持链接 + /// + public static bool IsConnect + { + get + { + if (MelsecInstance == null) return false; + var result = MelsecInstance.ReadPlcType(); + logHelper.Info($"PLC型号 信息:[{result.Message}] 内容:[{result.Message}]"); + return result.IsSuccess; + } + } public static int Test() { + var s = IsConnect; return MelsecInstance.ReadInt16("D1").Content; } diff --git a/HighWayIot.Plc/packages.config b/HighWayIot.Plc/packages.config new file mode 100644 index 0000000..277ca52 --- /dev/null +++ b/HighWayIot.Plc/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/HighWayIot.Winform/App.config b/HighWayIot.Winform/App.config index 193aecc..98452d4 100644 --- a/HighWayIot.Winform/App.config +++ b/HighWayIot.Winform/App.config @@ -1,6 +1,18 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/HighWayIot.Winform/HighWayIot.Winform.csproj b/HighWayIot.Winform/HighWayIot.Winform.csproj index f042a9b..309ccc6 100644 --- a/HighWayIot.Winform/HighWayIot.Winform.csproj +++ b/HighWayIot.Winform/HighWayIot.Winform.csproj @@ -312,10 +312,5 @@ Always - - - 12.1.3 - - \ No newline at end of file