|
@@ -354,6 +354,10 @@ namespace BPASmartClient.Device |
|
|
{ |
|
|
{ |
|
|
if (RTrig.GetInstance($"ResetProgram:{DeviceId}").Start(Initing)) |
|
|
if (RTrig.GetInstance($"ResetProgram:{DeviceId}").Start(Initing)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
DeviceProcessLogShow("启动初始化"); |
|
|
|
|
|
//记录监控数据 |
|
|
|
|
|
DeviceProcessLogShow($"监控数据:【 {variableMonitors.ToJSON()} 】"); |
|
|
|
|
|
|
|
|
TaskManage.GetInstance.StopTask($"MainTask:{DeviceId}", new Action(() => |
|
|
TaskManage.GetInstance.StopTask($"MainTask:{DeviceId}", new Action(() => |
|
|
{ |
|
|
{ |
|
|
TaskManage.GetInstance.StopTask($"ReadData:{DeviceId}", new Action(() => |
|
|
TaskManage.GetInstance.StopTask($"ReadData:{DeviceId}", new Action(() => |
|
@@ -406,6 +410,7 @@ namespace BPASmartClient.Device |
|
|
private void GetMonitorData(IStatus status) |
|
|
private void GetMonitorData(IStatus status) |
|
|
{ |
|
|
{ |
|
|
if (status == null) return; |
|
|
if (status == null) return; |
|
|
|
|
|
List<VariableMonitor> vm = new List<VariableMonitor>(); |
|
|
foreach (var item in status.GetType().GetProperties()) |
|
|
foreach (var item in status.GetType().GetProperties()) |
|
|
{ |
|
|
{ |
|
|
if (item.CustomAttributes.Count() > 0) |
|
|
if (item.CustomAttributes.Count() > 0) |
|
@@ -425,7 +430,7 @@ namespace BPASmartClient.Device |
|
|
{ |
|
|
{ |
|
|
for (int i = 0; i < arr.Length; i++) |
|
|
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) |
|
|
if (res == null) |
|
|
{ |
|
|
{ |
|
|
string[] plc = plcadd?.Substring(1).Split('.'); |
|
|
string[] plc = plcadd?.Substring(1).Split('.'); |
|
@@ -448,9 +453,9 @@ namespace BPASmartClient.Device |
|
|
TempPlcAddress = $"M{plc[0]}.{plc[1]}"; |
|
|
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}", |
|
|
VarName = $"{item.Name}_{i + 1}", |
|
|
Notes = $"{notes}_{i + 1}", |
|
|
Notes = $"{notes}_{i + 1}", |
|
|
ModbusTcpAddress = $"{int.Parse(modadd) + i}", |
|
|
ModbusTcpAddress = $"{int.Parse(modadd) + i}", |
|
@@ -468,12 +473,12 @@ namespace BPASmartClient.Device |
|
|
{ |
|
|
{ |
|
|
for (int i = 0; i < arr.Length; i++) |
|
|
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) |
|
|
if (res == null) |
|
|
{ |
|
|
{ |
|
|
variableMonitors.Add(new VariableMonitor() |
|
|
|
|
|
|
|
|
vm.Add(new VariableMonitor() |
|
|
{ |
|
|
{ |
|
|
Id = variableMonitors.Count, |
|
|
|
|
|
|
|
|
Id = vm.Count, |
|
|
VarName = $"{item.Name}_{i + 1}", |
|
|
VarName = $"{item.Name}_{i + 1}", |
|
|
Notes = $"{notes}_{i + 1}", |
|
|
Notes = $"{notes}_{i + 1}", |
|
|
|
|
|
|
|
@@ -485,12 +490,12 @@ namespace BPASmartClient.Device |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
var res = variableMonitors.FirstOrDefault(p => p.VarName == item.Name); |
|
|
|
|
|
|
|
|
var res = vm.FirstOrDefault(p => p.VarName == item.Name); |
|
|
if (res == null) |
|
|
if (res == null) |
|
|
{ |
|
|
{ |
|
|
variableMonitors.Add(new VariableMonitor() |
|
|
|
|
|
|
|
|
vm.Add(new VariableMonitor() |
|
|
{ |
|
|
{ |
|
|
Id = variableMonitors.Count, |
|
|
|
|
|
|
|
|
Id = vm.Count, |
|
|
VarName = item.Name, |
|
|
VarName = item.Name, |
|
|
Notes = notes, |
|
|
Notes = notes, |
|
|
ModbusTcpAddress = modadd, |
|
|
ModbusTcpAddress = modadd, |
|
@@ -502,6 +507,10 @@ namespace BPASmartClient.Device |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//监控列表排序 |
|
|
|
|
|
vm.OrderBy(p => p.VarName).ToList().ForEach(item => { variableMonitors.Add(item); }); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|