From aafaeabb0e5532594bf04b0780fefb10bf3ba136 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: Fri, 8 Apr 2022 11:34:48 +0800
Subject: [PATCH] =?UTF-8?q?IOT=E4=B8=8A=E6=8A=A5=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../HardwareStatusAttribute.cs | 28 ++++++
HBLConsole.Business/IotReport.cs | 40 ++++++---
HBLConsole.Factory/SimpleFactory.cs | 7 +-
HBLConsole.Interface/IHardwareStatus.cs | 15 ++++
HBLConsole.MORKS/Alarm.cs | 22 +++++
HBLConsole.MORKS/Control_MORKS.cs | 6 +-
HBLConsole.MORKS/HardwareStatus.cs | 19 ++++
HBLConsole/ViewModel/AlarmViewModel.cs | 38 ++++++++
HBLConsole/ViewModel/MainViewModel.cs | 86 ++++++++++++-------
.../ViewModel/VariableMonitorViewModel.cs | 26 +++---
10 files changed, 230 insertions(+), 57 deletions(-)
create mode 100644 HBLConsole.Attribute/HardwareStatusAttribute.cs
create mode 100644 HBLConsole.Interface/IHardwareStatus.cs
create mode 100644 HBLConsole.MORKS/Alarm.cs
create mode 100644 HBLConsole.MORKS/HardwareStatus.cs
diff --git a/HBLConsole.Attribute/HardwareStatusAttribute.cs b/HBLConsole.Attribute/HardwareStatusAttribute.cs
new file mode 100644
index 0000000..b3eacc6
--- /dev/null
+++ b/HBLConsole.Attribute/HardwareStatusAttribute.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HBLConsole.Attributes
+{
+ public class HardwareStatusAttribute : Attribute
+ {
+ public HardwareStatusAttribute(string describe, string address)
+ {
+ Describe = describe;
+ this.Address = address;
+ }
+
+ ///
+ /// 描述
+ ///
+ public string Describe { get; set; }
+
+
+ ///
+ /// 地址
+ ///
+ public string Address { get; set; }
+ }
+}
diff --git a/HBLConsole.Business/IotReport.cs b/HBLConsole.Business/IotReport.cs
index 889ce84..71adcff 100644
--- a/HBLConsole.Business/IotReport.cs
+++ b/HBLConsole.Business/IotReport.cs
@@ -35,6 +35,13 @@ namespace HBLConsole.Business
/// 属性状态
///
public string NodeStatus = "{\"data\":[{\"Id\":0,\"VarName\":\"InitComplete\",\"PLCAddress\":\"M100.0\",\"Notes\":\"初始化完成\",\"ModbusTcpAddress\":\"1120\",\"CurrentValue\":\"False\"},{\"Id\":1,\"VarName\":\"TurntableInPlace\",\"PLCAddress\":\"M100.1\",\"Notes\":\"转台到位\",\"ModbusTcpAddress\":\"1121\",\"CurrentValue\":\"False\"},{\"Id\":2,\"VarName\":\"RBTakeNoodleComplete\",\"PLCAddress\":\"M100.2\",\"Notes\":\"机器人取面完成\",\"ModbusTcpAddress\":\"1122\",\"CurrentValue\":\"False\"},{\"Id\":3,\"VarName\":\"AxisIdle_1\",\"PLCAddress\":\"M100.3\",\"Notes\":\"轴空闲_1\",\"ModbusTcpAddress\":\"1123\",\"CurrentValue\":\"False\"},{\"Id\":4,\"VarName\":\"AxisIdle_2\",\"PLCAddress\":\"M100.4\",\"Notes\":\"轴空闲_2\",\"ModbusTcpAddress\":\"1124\",\"CurrentValue\":\"False\"},{\"Id\":5,\"VarName\":\"AxisAllowInvertedNoodle_1\",\"PLCAddress\":\"M100.5\",\"Notes\":\"轴允许倒面_1\",\"ModbusTcpAddress\":\"1125\",\"CurrentValue\":\"False\"},{\"Id\":6,\"VarName\":\"AxisAllowInvertedNoodle_2\",\"PLCAddress\":\"M100.6\",\"Notes\":\"轴允许倒面_2\",\"ModbusTcpAddress\":\"1126\",\"CurrentValue\":\"False\"},{\"Id\":7,\"VarName\":\"AxisAllowInvertedSoup_1\",\"PLCAddress\":\"M101.0\",\"Notes\":\"轴允许倒浇头_1\",\"ModbusTcpAddress\":\"1127\",\"CurrentValue\":\"False\"},{\"Id\":8,\"VarName\":\"AxisAllowInvertedSoup_2\",\"PLCAddress\":\"M101.0\",\"Notes\":\"轴允许倒浇头_2\",\"ModbusTcpAddress\":\"1128\",\"CurrentValue\":\"False\"},{\"Id\":9,\"VarName\":\"SoupHeatComplete_1\",\"PLCAddress\":\"M101.1\",\"Notes\":\"浇头加热完成_1\",\"ModbusTcpAddress\":\"1129\",\"CurrentValue\":\"False\"},{\"Id\":10,\"VarName\":\"SoupHeatComplete_2\",\"PLCAddress\":\"M101.2\",\"Notes\":\"浇头加热完成_2\",\"ModbusTcpAddress\":\"1130\",\"CurrentValue\":\"False\"},{\"Id\":11,\"VarName\":\"CookNoodleBasketIdle_1\",\"PLCAddress\":\"M101.3\",\"Notes\":\"煮面篮空闲_1\",\"ModbusTcpAddress\":\"1131\",\"CurrentValue\":\"False\"},{\"Id\":12,\"VarName\":\"CookNoodleBasketIdle_2\",\"PLCAddress\":\"M101.4\",\"Notes\":\"煮面篮空闲_2\",\"ModbusTcpAddress\":\"1132\",\"CurrentValue\":\"False\"},{\"Id\":13,\"VarName\":\"CookNoodleBasketIdle_3\",\"PLCAddress\":\"M101.5\",\"Notes\":\"煮面篮空闲_3\",\"ModbusTcpAddress\":\"1133\",\"CurrentValue\":\"False\"},{\"Id\":14,\"VarName\":\"CookNoodleBasketIdle_4\",\"PLCAddress\":\"M101.6\",\"Notes\":\"煮面篮空闲_4\",\"ModbusTcpAddress\":\"1134\",\"CurrentValue\":\"False\"},{\"Id\":15,\"VarName\":\"CookNoodleBasketIdle_5\",\"PLCAddress\":\"M101.7\",\"Notes\":\"煮面篮空闲_5\",\"ModbusTcpAddress\":\"1135\",\"CurrentValue\":\"False\"},{\"Id\":16,\"VarName\":\"CookNoodleBasketIdle_6\",\"PLCAddress\":\"M101.8\",\"Notes\":\"煮面篮空闲_6\",\"ModbusTcpAddress\":\"1136\",\"CurrentValue\":\"False\"},{\"Id\":17,\"VarName\":\"CookNoodleComplete_1\",\"PLCAddress\":\"M102.1\",\"Notes\":\"煮面完成_1\",\"ModbusTcpAddress\":\"1137\",\"CurrentValue\":\"False\"},{\"Id\":18,\"VarName\":\"CookNoodleComplete_2\",\"PLCAddress\":\"M102.2\",\"Notes\":\"煮面完成_2\",\"ModbusTcpAddress\":\"1138\",\"CurrentValue\":\"False\"},{\"Id\":19,\"VarName\":\"CookNoodleComplete_3\",\"PLCAddress\":\"M102.3\",\"Notes\":\"煮面完成_3\",\"ModbusTcpAddress\":\"1139\",\"CurrentValue\":\"False\"},{\"Id\":20,\"VarName\":\"CookNoodleComplete_4\",\"PLCAddress\":\"M102.4\",\"Notes\":\"煮面完成_4\",\"ModbusTcpAddress\":\"1140\",\"CurrentValue\":\"False\"},{\"Id\":21,\"VarName\":\"CookNoodleComplete_5\",\"PLCAddress\":\"M102.5\",\"Notes\":\"煮面完成_5\",\"ModbusTcpAddress\":\"1141\",\"CurrentValue\":\"False\"},{\"Id\":22,\"VarName\":\"CookNoodleComplete_6\",\"PLCAddress\":\"M102.6\",\"Notes\":\"煮面完成_6\",\"ModbusTcpAddress\":\"1142\",\"CurrentValue\":\"False\"},{\"Id\":23,\"VarName\":\"TakeNoodleRobotIdle\",\"PLCAddress\":\"M102.7\",\"Notes\":\"取面机器人空闲状态\",\"ModbusTcpAddress\":\"1143\",\"CurrentValue\":\"False\"},{\"Id\":24,\"VarName\":\"TakeSoupRobotIdle\",\"PLCAddress\":\"M103.0\",\"Notes\":\"取浇头机器人空闲状态\",\"ModbusTcpAddress\":\"1144\",\"CurrentValue\":\"False\"},{\"Id\":25,\"VarName\":\"BreakMechanismIdle_1\",\"PLCAddress\":\"M103.1\",\"Notes\":\"破口机构空闲_1\",\"ModbusTcpAddress\":\"1145\",\"CurrentValue\":\"False\"},{\"Id\":26,\"VarName\":\"BreakMechanismIdle_2\",\"PLCAddress\":\"M103.2\",\"Notes\":\"破口机构空闲_2\",\"ModbusTcpAddress\":\"1146\",\"CurrentValue\":\"False\"},{\"Id\":27,\"VarName\":\"TakeSoupComplete\",\"PLCAddress\":\"M103.3\",\"Notes\":\"取浇头完成\",\"ModbusTcpAddress\":\"1147\",\"CurrentValue\":\"False\"},{\"Id\":28,\"VarName\":\"PutNoodleTakeMealComplete\",\"PLCAddress\":\"M103.4\",\"Notes\":\"放面至取餐口完成\",\"ModbusTcpAddress\":\"1148\",\"CurrentValue\":\"False\"},{\"Id\":29,\"VarName\":\"Initing\",\"PLCAddress\":\"M103.5\",\"Notes\":\"设备初始化中\",\"ModbusTcpAddress\":\"1149\",\"CurrentValue\":\"False\"},{\"Id\":30,\"VarName\":\"TurntableFeedbackloc\",\"PLCAddress\":\"VW1240\",\"Notes\":\"转台反馈位置\",\"ModbusTcpAddress\":\"720\",\"CurrentValue\":\"0\"},{\"Id\":31,\"VarName\":\"TurntableLowerLimit\",\"PLCAddress\":\"M120.0\",\"Notes\":\"转台下限位\",\"ModbusTcpAddress\":\"1280\",\"CurrentValue\":\"False\"},{\"Id\":32,\"VarName\":\"TurntableUpLimit\",\"PLCAddress\":\"M120.1\",\"Notes\":\"转台上限位\",\"ModbusTcpAddress\":\"1281\",\"CurrentValue\":\"False\"},{\"Id\":33,\"VarName\":\"SoupMaterialShortage_1\",\"PLCAddress\":\"M120.2\",\"Notes\":\"浇头缺料_1\",\"ModbusTcpAddress\":\"1282\",\"CurrentValue\":\"False\"},{\"Id\":34,\"VarName\":\"SoupMaterialShortage_2\",\"PLCAddress\":\"M120.3\",\"Notes\":\"浇头缺料_2\",\"ModbusTcpAddress\":\"1283\",\"CurrentValue\":\"False\"},{\"Id\":35,\"VarName\":\"SoupMaterialShortage_3\",\"PLCAddress\":\"M120.4\",\"Notes\":\"浇头缺料_3\",\"ModbusTcpAddress\":\"1284\",\"CurrentValue\":\"False\"},{\"Id\":36,\"VarName\":\"SoupMaterialShortage_4\",\"PLCAddress\":\"M120.5\",\"Notes\":\"浇头缺料_4\",\"ModbusTcpAddress\":\"1285\",\"CurrentValue\":\"False\"},{\"Id\":37,\"VarName\":\"SoupMaterialShortage_5\",\"PLCAddress\":\"M120.6\",\"Notes\":\"浇头缺料_5\",\"ModbusTcpAddress\":\"1286\",\"CurrentValue\":\"False\"},{\"Id\":38,\"VarName\":\"OutMealDetect_1\",\"PLCAddress\":\"M121.0\",\"Notes\":\"出餐口检测_1\",\"ModbusTcpAddress\":\"1287\",\"CurrentValue\":\"False\"},{\"Id\":39,\"VarName\":\"OutMealDetect_2\",\"PLCAddress\":\"M121.0\",\"Notes\":\"出餐口检测_2\",\"ModbusTcpAddress\":\"1288\",\"CurrentValue\":\"False\"},{\"Id\":40,\"VarName\":\"OutMealDetect_3\",\"PLCAddress\":\"M121.0\",\"Notes\":\"出餐口检测_3\",\"ModbusTcpAddress\":\"1289\",\"CurrentValue\":\"False\"},{\"Id\":41,\"VarName\":\"TemperatureReached\",\"PLCAddress\":\"M121.2\",\"Notes\":\"温度到达\",\"ModbusTcpAddress\":\"1290\",\"CurrentValue\":\"False\"},{\"Id\":42,\"VarName\":\"AllowPutSoup\",\"PLCAddress\":\"\",\"Notes\":\"允许倒浇头\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"},{\"Id\":43,\"VarName\":\"AllowTakeSoup\",\"PLCAddress\":\"\",\"Notes\":\"允许取浇头\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"},{\"Id\":44,\"VarName\":\"PutNoodleLoc\",\"PLCAddress\":\"\",\"Notes\":\"放面位置\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"0\"},{\"Id\":45,\"VarName\":\"AxisIdleIndex\",\"PLCAddress\":\"\",\"Notes\":\"轴空闲位置\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"-1\"},{\"Id\":46,\"VarName\":\"AxisIdleLockIndex\",\"PLCAddress\":\"\",\"Notes\":\"轴空闲互锁位置\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"0\"},{\"Id\":47,\"VarName\":\"TurntableLoc\",\"PLCAddress\":\"\",\"Notes\":\"转台位置\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"0\"},{\"Id\":48,\"VarName\":\"RobotTaskInterlock\",\"PLCAddress\":\"\",\"Notes\":\"机器人任务互锁信号\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"},{\"Id\":49,\"VarName\":\"TakeBowlInterlock\",\"PLCAddress\":\"\",\"Notes\":\"取碗互锁信号\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"},{\"Id\":50,\"VarName\":\"TakeNoodleInterlock\",\"PLCAddress\":\"\",\"Notes\":\"取面互锁信号\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"},{\"Id\":51,\"VarName\":\"OutNoodleing\",\"PLCAddress\":\"\",\"Notes\":\"出面中\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"},{\"Id\":52,\"VarName\":\"AllowTakeNoodle\",\"PLCAddress\":\"\",\"Notes\":\"允许取面\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"},{\"Id\":53,\"VarName\":\"TurntableInterlock\",\"PLCAddress\":\"\",\"Notes\":\"转台互锁信号\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"},{\"Id\":54,\"VarName\":\"CookNodeState_1\",\"PLCAddress\":null,\"Notes\":\"煮面炉互锁_1\",\"ModbusTcpAddress\":null,\"CurrentValue\":\"False\"},{\"Id\":55,\"VarName\":\"CookNodeState_2\",\"PLCAddress\":null,\"Notes\":\"煮面炉互锁_2\",\"ModbusTcpAddress\":null,\"CurrentValue\":\"False\"},{\"Id\":56,\"VarName\":\"CookNodeState_3\",\"PLCAddress\":null,\"Notes\":\"煮面炉互锁_3\",\"ModbusTcpAddress\":null,\"CurrentValue\":\"False\"},{\"Id\":57,\"VarName\":\"CookNodeState_4\",\"PLCAddress\":null,\"Notes\":\"煮面炉互锁_4\",\"ModbusTcpAddress\":null,\"CurrentValue\":\"False\"},{\"Id\":58,\"VarName\":\"CookNodeState_5\",\"PLCAddress\":null,\"Notes\":\"煮面炉互锁_5\",\"ModbusTcpAddress\":null,\"CurrentValue\":\"False\"},{\"Id\":59,\"VarName\":\"CookNodeState_6\",\"PLCAddress\":null,\"Notes\":\"煮面炉互锁_6\",\"ModbusTcpAddress\":null,\"CurrentValue\":\"False\"},{\"Id\":60,\"VarName\":\"AxisIdleLock_1\",\"PLCAddress\":null,\"Notes\":\"轴空闲互锁_1\",\"ModbusTcpAddress\":null,\"CurrentValue\":\"False\"},{\"Id\":61,\"VarName\":\"AxisIdleLock_2\",\"PLCAddress\":null,\"Notes\":\"轴空闲互锁_2\",\"ModbusTcpAddress\":null,\"CurrentValue\":\"False\"},{\"Id\":62,\"VarName\":\"AllowRun\",\"PLCAddress\":\"\",\"Notes\":\"允许运行\",\"ModbusTcpAddress\":\"\",\"CurrentValue\":\"False\"}]}";
+
+ ///
+ /// 硬件状态
+ ///
+ public string HardwareStatus;
+
+ public TargetIOT targetIOT { get; set; } = new TargetIOT();
#endregion
#region IOT上报公共调用
@@ -45,13 +52,13 @@ namespace HBLConsole.Business
///
public void SendAlarmMessage(AlarmTable alarmTable)
{
- if (IOTDevServer.client != null && IOTDevServer.client.IsConnected && device!=null)
+ if (IOTDevServer.client != null && IOTDevServer.client.IsConnected && device != null)
{
alarmTable.ClientId = InternetInfo.ClientId.ToString();
alarmTable.devicename = device.devicename;
string json = Tools.JsonConvertTools>(new IotModel { @params = new AlarmIOT { GJXX = Tools.JsonConvertTools(alarmTable) } });
- IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,json);
- }
+ IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic, json);
+ }
}
///
@@ -66,7 +73,7 @@ namespace HBLConsole.Business
logTable.devicename = device.devicename;
logTable.ClientId = InternetInfo.ClientId.ToString();
string json = Tools.JsonConvertTools>(new IotModel { @params = new LogIOT { SZXX = Tools.JsonConvertTools(logTable) } });
- IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,json);
+ IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic, json);
}
}
@@ -85,6 +92,9 @@ namespace HBLConsole.Business
NodeStatus = json;
}
+
+
+
///
/// 上报属性状态
/// 调用示例:SendTargetMessage();
@@ -98,8 +108,8 @@ namespace HBLConsole.Business
bool IsAllowRun = false;
bool TemperatureReached = false;
#endregion
- string kzsx = Tools.JsonConvertTools(new DevSX{ data = new List { new DevSXBase { SXMC="", SXLX="" } }});
-
+ string kzsx = Tools.JsonConvertTools(new DevSX { data = new List { new DevSXBase { SXMC = "", SXLX = "" } } });
+
string jbsx = Tools.JsonConvertTools(new DevSX
{
data = new List
@@ -159,8 +169,8 @@ namespace HBLConsole.Business
default:
break;
}
- string jsonstr = Tools.JsonConvertTools>(new IotModel { @params = new TargetIOT { JBSX = jbsx,KZSX = kzsx,NodeStatus= NodeStatus } });
- IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,jsonstr);
+ string jsonstr = Tools.JsonConvertTools>(new IotModel { @params = new TargetIOT { JBSX = jbsx, KZSX = kzsx, NodeStatus = NodeStatus } });
+ IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic, jsonstr);
}
}
#endregion
@@ -171,7 +181,7 @@ namespace HBLConsole.Business
///
public bool Initialize()
{
- if (!IOTDevServer.GetInstance().CreateLinks(InternetInfo.ClientId,out device))
+ if (!IOTDevServer.GetInstance().CreateLinks(InternetInfo.ClientId, out device))
{
MessageLog.GetInstance.Show($"设备{InternetInfo.ClientId}阿里云上没有该设备。");
return false;
@@ -217,11 +227,16 @@ namespace HBLConsole.Business
///
private T GetTypeValue(string str)
{
- return (T)SimpleFactory.GetInstance.GVL?.GetType().GetProperty(str)?.GetValue(SimpleFactory.GetInstance.GVL,null);
+ return (T)SimpleFactory.GetInstance.GVL?.GetType().GetProperty(str)?.GetValue(SimpleFactory.GetInstance.GVL, null);
}
#endregion
}
+ public class IOTNode
+ {
+ public T data { get; set; }
+ }
+
///
/// 日志上报
///
@@ -260,5 +275,10 @@ namespace HBLConsole.Business
/// 属性状态
///
public string NodeStatus { get; set; }
+
+ ///
+ /// 硬件状态
+ ///
+ public string HardwareStatus { get; set; }
}
}
diff --git a/HBLConsole.Factory/SimpleFactory.cs b/HBLConsole.Factory/SimpleFactory.cs
index 50f31e9..0916f5b 100644
--- a/HBLConsole.Factory/SimpleFactory.cs
+++ b/HBLConsole.Factory/SimpleFactory.cs
@@ -96,6 +96,7 @@ namespace HBLConsole.Factory
public IControl control { get; set; }
public IGvl GVL { get; set; }
public IAlarm Alarm { get; set; }
+ public IHardwareStatus HardwareStatus { get; set; }
public ControlAbstract controlAbstract { get; set; }
///
@@ -116,6 +117,7 @@ namespace HBLConsole.Factory
ActionManage.GetInstance.Register(new Action