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 并发验证用例

---
 Plugin.CurrentSensorControl/SingleSensor.xaml.cs |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Plugin.CurrentSensorControl/SingleSensor.xaml.cs b/Plugin.CurrentSensorControl/SingleSensor.xaml.cs
index 9a1b0d3..76ad6ae 100644
--- a/Plugin.CurrentSensorControl/SingleSensor.xaml.cs
+++ b/Plugin.CurrentSensorControl/SingleSensor.xaml.cs
@@ -12,8 +12,8 @@
     [ObservableObject]
     public partial class SingleSensor : UserControl
     {
-        private static Dictionary<string, ModbusRtuOverTcp> clients = new Dictionary<string, ModbusRtuOverTcp>();
-        private static Dictionary<ModbusRtuOverTcp, bool> status = new Dictionary<ModbusRtuOverTcp, bool>();
+        private static Dictionary<string, ModbusTcpNet> clients = new Dictionary<string, ModbusTcpNet>();
+        private static Dictionary<ModbusTcpNet, bool> status = new Dictionary<ModbusTcpNet, bool>();
 
         [ObservableProperty]
         private string sensorName;
@@ -47,7 +47,7 @@
         [ObservableProperty]
         private int channel;
 
-        private ModbusRtuOverTcp client;
+        private ModbusTcpNet client;
 
 
         public SingleSensor()
@@ -63,10 +63,10 @@
             Port = port;
             Address = address;
             Channel = channel;
-            string key = $"{Ip}:{Port}:{Address}";
+            string key = $"{Ip}:{Port}";
             if (!clients.ContainsKey(key))
             {
-                client = new ModbusRtuOverTcp(Ip, Port, (byte)Address);
+                client = new ModbusTcpNet(Ip, Port);
                 clients[key] = client;
             }
             else
@@ -134,16 +134,16 @@
             var sb = status[client];
             if (IsConnected)
             {
-                OperateResult<double[]> res;
+                OperateResult<ushort> res;
                 lock (client)
                 {
-                    res = client.ReadDouble(channel.ToString(), 1);
+                    res = client.ReadUInt16(channel.ToString());
                 }
                 Dispatcher.Invoke(() =>
                 {
                     if (res.IsSuccess)
                     {
-                        Current = res.Content[0].ToString();
+                        Current = (res.Content / 1000d).ToString();
                         ErrMsg = string.Empty;
                     }
                     else

--
Gitblit v1.9.1