测试
This commit is contained in:
17
头罩视野slove/头罩视野/ModbusHelper.cs
Normal file
17
头罩视野slove/头罩视野/ModbusHelper.cs
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user