From b544d5cccd76735e034c8055918a50927b437474 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期二, 10 十一月 2026 08:29:04 +0800
Subject: [PATCH] fix: 维护模式重复进入失败与按钮灰死 + Broker 并发验证用例

---
 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