This commit is contained in:
2026-04-21 13:36:09 +08:00
parent 68959ce119
commit 54c92d9644
11 changed files with 81 additions and 523 deletions

View File

@@ -0,0 +1,17 @@
using System.Net.Sockets;
using .Services.Data;
public static class ModbusHelper
{
// 全局唯一连接,所有页面共用
public static TcpClient TcpClient => ModbusResourceManager.Instance.TcpClient;
// 统一连接方法(全项目只调用一次)
public static bool Connect(string ip, int port = 502)
{
return ModbusResourceManager.Instance.Init(ip, port);
}
// 判断是否连接成功
public static bool IsConnected => TcpClient != null && TcpClient.Connected;
}