From 2e889843b4c171f2d6ad8e0d53084040703d11f6 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 13:18:21 +0800
Subject: [PATCH] docs: CAN 总线级应答器 + 硬件调试页多标签多会话 设计规格
---
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