From 559890c482f5973f06aafdfec9550fee5ba3c7f2 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 17:02:15 +0800
Subject: [PATCH] feat: CAN 模拟器 TCP 化 + 多设备并发调试 + 后台生命周期管理

---
 ModBusTcpController/ModBusTcpController.cs |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/ModBusTcpController/ModBusTcpController.cs b/ModBusTcpController/ModBusTcpController.cs
index e431966..835e542 100644
--- a/ModBusTcpController/ModBusTcpController.cs
+++ b/ModBusTcpController/ModBusTcpController.cs
@@ -48,23 +48,39 @@
             return res?.IsSuccess == true;
         }
 
-        public bool ReadDIInt(string address, out int res, out string msg)
+        public bool ReadDIInt16(string address, out int res, out string msg)
         {
-            var result = client?.ReadInt32($"x=2;{address}");
+            var result = client?.ReadInt16($"x=2;{address}");
             msg = result?.Message;
             res = result?.Content ?? 0;
             return result?.IsSuccess == true;
         }
 
-        public bool ReadDOInt(string address, out int res, out string msg)
+        public bool ReadDOInt16(string address, out int res, out string msg)
         {
-            var result = client?.ReadInt32(address);
+            var result = client?.ReadInt16(address);
             msg = result?.Message;
             res = result?.Content ?? 0;
             return result?.IsSuccess == true;
         }
 
-        public bool WriteInt(string address, int value, out string msg)
+        public bool WriteInt16(string address, short value, out string msg)
+        {
+            msg = string.Empty;
+            var res = client?.Write(address, value);
+            msg = res.Message;
+            return res?.IsSuccess == true;
+        }
+
+        public bool ReadUInt16(string address, out ushort res, out string msg)
+        {
+            var result = client?.ReadUInt16(address);
+            msg = result?.Message;
+            res = result?.Content ?? 0;
+            return result?.IsSuccess == true;
+        }
+
+        public bool WriteUInt16(string address, ushort value, out string msg)
         {
             msg = string.Empty;
             var res = client?.Write(address, value);

--
Gitblit v1.9.1