diff --git a/HighWayIot.Plc/HighWayIot.Plc.csproj b/HighWayIot.Plc/HighWayIot.Plc.csproj
index fd0970d..b6e2b18 100644
--- a/HighWayIot.Plc/HighWayIot.Plc.csproj
+++ b/HighWayIot.Plc/HighWayIot.Plc.csproj
@@ -32,9 +32,6 @@
4
-
- ..\HighWayIot.Library\HslCommunication.dll
-
@@ -62,5 +59,10 @@
+
+
+ 12.1.3
+
+
\ No newline at end of file
diff --git a/HighWayIot.Plc/PlcConnect.cs b/HighWayIot.Plc/PlcConnect.cs
index 551442c..72a95b1 100644
--- a/HighWayIot.Plc/PlcConnect.cs
+++ b/HighWayIot.Plc/PlcConnect.cs
@@ -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;
diff --git a/HighWayIot.Winform/HighWayIot.Winform.csproj b/HighWayIot.Winform/HighWayIot.Winform.csproj
index c1fb5dc..f042a9b 100644
--- a/HighWayIot.Winform/HighWayIot.Winform.csproj
+++ b/HighWayIot.Winform/HighWayIot.Winform.csproj
@@ -36,7 +36,6 @@
-
@@ -313,6 +312,10 @@
Always
-
+
+
+ 12.1.3
+
+
\ No newline at end of file
diff --git a/HighWayIot.Winform/Program.cs b/HighWayIot.Winform/Program.cs
index adc471e..30a819c 100644
--- a/HighWayIot.Winform/Program.cs
+++ b/HighWayIot.Winform/Program.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
+using HighWayIot.Plc;
namespace HighWayIot.Winform
{
@@ -30,6 +31,8 @@ namespace HighWayIot.Winform
//Console.OutputEncoding = System.Text.Encoding.UTF8;
//Console.InputEncoding = System.Text.Encoding.UTF8;
+
+
AllocConsole();//调用系统API,调用控制台窗口
// 设置控制台编码为系统默认编码(解决乱码问题)
Application.EnableVisualStyles();