From 771a0e7b6b1276087515bbe94de28358cb92963b Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 04 六月 2026 10:32:27 +0800
Subject: [PATCH] 优化老化;

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