From fb560fc9c6f372758fe65decbeee0233ae7b46d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Thu, 17 Aug 2023 14:30:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E6=8E=A7=E7=8A=B6=E6=80=81=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.Device/BaseDevice.cs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index c19bcca2..217c180e 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -354,6 +354,10 @@ namespace BPASmartClient.Device { if (RTrig.GetInstance($"ResetProgram:{DeviceId}").Start(Initing)) { + DeviceProcessLogShow("启动初始化"); + //记录监控数据 + DeviceProcessLogShow($"监控数据:【 {variableMonitors.ToJSON()} 】"); + TaskManage.GetInstance.StopTask($"MainTask:{DeviceId}", new Action(() => { TaskManage.GetInstance.StopTask($"ReadData:{DeviceId}", new Action(() => @@ -406,6 +410,7 @@ namespace BPASmartClient.Device private void GetMonitorData(IStatus status) { if (status == null) return; + List vm = new List(); foreach (var item in status.GetType().GetProperties()) { if (item.CustomAttributes.Count() > 0) @@ -425,7 +430,7 @@ namespace BPASmartClient.Device { for (int i = 0; i < arr.Length; i++) { - var res = variableMonitors.FirstOrDefault(p => p.VarName == $"{item.Name}_{i + 1}"); + var res = vm.FirstOrDefault(p => p.VarName == $"{item.Name}_{i + 1}"); if (res == null) { string[] plc = plcadd?.Substring(1).Split('.'); @@ -448,9 +453,9 @@ namespace BPASmartClient.Device TempPlcAddress = $"M{plc[0]}.{plc[1]}"; } - variableMonitors.Add(new VariableMonitor() + vm.Add(new VariableMonitor() { - Id = variableMonitors.Count, + Id = vm.Count, VarName = $"{item.Name}_{i + 1}", Notes = $"{notes}_{i + 1}", ModbusTcpAddress = $"{int.Parse(modadd) + i}", @@ -468,12 +473,12 @@ namespace BPASmartClient.Device { for (int i = 0; i < arr.Length; i++) { - var res = variableMonitors.FirstOrDefault(p => p.VarName == $"{item.Name}_{i + 1}"); + var res = vm.FirstOrDefault(p => p.VarName == $"{item.Name}_{i + 1}"); if (res == null) { - variableMonitors.Add(new VariableMonitor() + vm.Add(new VariableMonitor() { - Id = variableMonitors.Count, + Id = vm.Count, VarName = $"{item.Name}_{i + 1}", Notes = $"{notes}_{i + 1}", @@ -485,12 +490,12 @@ namespace BPASmartClient.Device } else { - var res = variableMonitors.FirstOrDefault(p => p.VarName == item.Name); + var res = vm.FirstOrDefault(p => p.VarName == item.Name); if (res == null) { - variableMonitors.Add(new VariableMonitor() + vm.Add(new VariableMonitor() { - Id = variableMonitors.Count, + Id = vm.Count, VarName = item.Name, Notes = notes, ModbusTcpAddress = modadd, @@ -502,6 +507,10 @@ namespace BPASmartClient.Device } } + + //监控列表排序 + vm.OrderBy(p => p.VarName).ToList().ForEach(item => { variableMonitors.Add(item); }); + } ///