diff --git a/HBLConsole.Attribute/VariableMonitorAttribute.cs b/HBLConsole.Attribute/VariableMonitorAttribute.cs
new file mode 100644
index 0000000..d75265c
--- /dev/null
+++ b/HBLConsole.Attribute/VariableMonitorAttribute.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HBLConsole.Attributes
+{
+ public class VariableMonitorAttribute : Attribute
+ {
+ public VariableMonitorAttribute(string Notes, string PLCAddress = "", string ModbusTcpAddress = "")
+ {
+ this.PLCAddress = PLCAddress;
+ this.ModbusTcpAddress = ModbusTcpAddress;
+ this.Notes = Notes;
+ }
+
+ public string PLCAddress { get; set; }
+ public string ModbusTcpAddress { get; set; }
+ public string Notes { get; set; }
+
+ }
+}
diff --git a/HBLConsole.MORKD/GVL_MORKD.cs b/HBLConsole.MORKD/GVL_MORKD.cs
index 3a74533..7e5f437 100644
--- a/HBLConsole.MORKD/GVL_MORKD.cs
+++ b/HBLConsole.MORKD/GVL_MORKD.cs
@@ -134,6 +134,7 @@ namespace HBLConsole.MORKD
/// ModbusTcp --> 1120
///
[Circuit(new string[] { "允许运行", "转台控制" }, "初始化完成")]
+ [VariableMonitor("初始化完成", "M100.0", "1120")]
public bool InitComplete { get; set; }
///
@@ -142,6 +143,7 @@ namespace HBLConsole.MORKD
/// ModbusTcp --> 1121
///
[Circuit("取面任务", "转台到位检测")]
+ [VariableMonitor("转台到位", "M100.1", "1121")]
public bool TurntableInPlace { get; set; }
///
@@ -149,6 +151,7 @@ namespace HBLConsole.MORKD
/// PLC --> M100.2
/// ModbusTcp --> 1122
///
+ [VariableMonitor("机器人取面完成", "M100.2", "1122")]
public bool RBTakeNoodleComplete { get; set; }
///
@@ -156,6 +159,7 @@ namespace HBLConsole.MORKD
/// PLC --> M100.3 -- M100.04
/// ModbusTcp --> 1123 -- 1124
///
+ [VariableMonitor("轴空闲", "M100.3", "1123")]
public bool[] AxisIdle { get; set; } = new bool[2] { false, false };
///
@@ -163,6 +167,7 @@ namespace HBLConsole.MORKD
/// PLC --> M100.5 -- M100.06
/// ModbusTcp --> 1125 -- 1126
///
+ [VariableMonitor("轴允许倒面", "M100.5", "1125")]
public bool[] AxisAllowInvertedNoodle { get; set; } = new bool[2] { false, false };
///
@@ -170,6 +175,7 @@ namespace HBLConsole.MORKD
/// PLC --> M100.7 -- M101.00
/// ModbusTcp --> 1127 -- 1128
///
+ [VariableMonitor("轴允许倒浇头", "M100.7", "1127")]
public bool[] AxisAllowInvertedSoup { get; set; } = new bool[2] { false, false };
///
@@ -177,6 +183,7 @@ namespace HBLConsole.MORKD
/// PLC --> M101.1 -- M101.02
/// ModbusTcp --> 1129 -- 1130
///
+ [VariableMonitor("浇头加热完成", "M101.1", "1129")]
public bool[] SoupHeatComplete { get; set; } = new bool[2] { false, false };
///
@@ -184,6 +191,7 @@ namespace HBLConsole.MORKD
/// PLC --> M101.3 -- M102.0
/// ModbusTcp --> 1131 -- 1136
///
+ [VariableMonitor("煮面篮空闲", "M101.3", "1131")]
public bool[] CookNoodleBasketIdle { get; set; } = new bool[6] { false, false, false, false, false, false };
///
@@ -191,6 +199,7 @@ namespace HBLConsole.MORKD
/// PLC --> M102.1 -- M102.6
/// ModbusTcp --> 1137 -- 1142
///
+ [VariableMonitor("煮面完成", "M102.1", "1137")]
public bool[] CookNoodleComplete { get; set; } = new bool[6] { false, false, false, false, false, false };
///
@@ -199,6 +208,7 @@ namespace HBLConsole.MORKD
/// ModbusTcp --> 1143
///
[Circuit(new string[] { "取面任务", "出餐控制" }, "取面机器人空闲")]
+ [VariableMonitor("取面机器人空闲状态", "M102.7", "1143")]
public bool TakeNoodleRobotIdle { get; set; }
///
@@ -207,6 +217,7 @@ namespace HBLConsole.MORKD
/// ModbusTcp --> 1144
///
[Circuit(new string[] { "取浇头控制", "出浇头控制" }, "取浇头机器人空闲状态")]
+ [VariableMonitor("取浇头机器人空闲状态", "M103.0", "1144")]
public bool TakeSoupRobotIdle { get; set; }
///
@@ -214,6 +225,7 @@ namespace HBLConsole.MORKD
/// PLC --> M103.1 -- M103.02
/// ModbusTcp --> 1145 -- 1146
///
+ [VariableMonitor("破口机构空闲", "M103.1", "1145")]
public bool[] BreakMechanismIdle { get; set; } = new bool[2] { false, false };
///
@@ -221,6 +233,7 @@ namespace HBLConsole.MORKD
/// PLC --> M103.3
/// ModbusTcp --> 1147
///
+ [VariableMonitor("取浇头完成", "M103.3", "1147")]
public bool TakeSoupComplete { get; set; }
///
@@ -228,6 +241,7 @@ namespace HBLConsole.MORKD
/// PLC --> M103.4
/// ModbusTcp --> 1148
///
+ [VariableMonitor("放面至取餐口完成", "M103.4", "1148")]
public bool PutNoodleTakeMealComplete { get; set; }
///
@@ -235,6 +249,7 @@ namespace HBLConsole.MORKD
/// PLC --> M103.5
/// ModbusTcp --> 1149
///
+ [VariableMonitor("设备初始化中", "M103.5", "1149")]
public bool Initing { get; set; }
///
@@ -242,6 +257,7 @@ namespace HBLConsole.MORKD
/// PLC -> VW372
/// ModbusTcp -> 286
///
+ [VariableMonitor("设备初始化中", "VW372", "286")]
public ushort TurntableFeedbackloc { get; set; }
#endregion
@@ -251,6 +267,7 @@ namespace HBLConsole.MORKD
/// PLC --> M120.0
/// ModbusTcp --> 1200
///
+ [VariableMonitor("转台下限位", "M120.0", "1200")]
public bool TurntableLowerLimit { get; set; }
///
@@ -258,6 +275,7 @@ namespace HBLConsole.MORKD
/// PLC --> M120.1
/// ModbusTcp --> 1201
///
+ [VariableMonitor("转台上限位", "M120.1", "1201")]
public bool TurntableUpLimit { get; set; }
///
@@ -265,6 +283,7 @@ namespace HBLConsole.MORKD
/// PLC --> M120.2 -- M120.6
/// ModbusTcp --> 1202 -- 1206
///
+ [VariableMonitor("浇头缺料", "M120.2", "1202")]
public bool[] SoupMaterialShortage { get; set; } = new bool[5] { false, false, false, false, false };
///
@@ -272,6 +291,7 @@ namespace HBLConsole.MORKD
/// PLC --> M120.7 -- M121.1
/// ModbusTcp --> 1207 -- 1209
///
+ [VariableMonitor("出餐口检测", "M120.7", "1207")]
public bool[] OutMealDetect { get; set; } = new bool[3] { false, false, false };
///
@@ -279,6 +299,7 @@ namespace HBLConsole.MORKD
/// PLC --> M121.2
/// ModbusTcp --> 1210
///
+ [VariableMonitor("温度到达", "M121.2", "1210")]
public bool TemperatureReached { get; set; }
#endregion
@@ -288,71 +309,84 @@ namespace HBLConsole.MORKD
/// 允许倒浇头
///
[Circuit(new string[] { "出浇头控制" }, "允许倒浇头", new bool[] { true })]
+ [VariableMonitor("允许倒浇头")]
public bool AllowPutSoup { get; set; }
///
/// 允许取浇头
///
[Circuit(new string[] { "取浇头控制", "出浇头控制" }, "允许取浇头", new bool[] { true, true })]
+ [VariableMonitor("允许取浇头")]
public bool AllowTakeSoup { get; set; }
///
/// 放面位置
///
+ [VariableMonitor("放面位置")]
public int PutNoodleLoc { get; set; }
///
/// 轴空闲位置
///
+ [VariableMonitor("轴空闲位置")]
public int AxisIdleIndex { get; set; }
///
/// 轴空闲互锁位置
///
+ [VariableMonitor("轴空闲互锁位置")]
public int AxisIdleLockIndex { get; set; }
///
/// 转台位置
///
+ [VariableMonitor("转台位置")]
public ushort TurntableLoc { get; set; }
///
/// 机器人任务互锁信号
///
[Circuit(new string[] { "取面任务", "出餐控制" }, "机器人任务互锁", new bool[] { true, false })]
+ [VariableMonitor("机器人任务互锁信号")]
public bool RobotTaskInterlock { get; set; }
///
/// 取碗互锁信号
///
+ [VariableMonitor("取碗互锁信号")]
public bool TakeBowlInterlock { get; set; }
///
/// 取面互锁信号
///
[Circuit(new string[] { "出餐控制" }, "取面互锁信号", new bool[] { true })]
+ [VariableMonitor("取面互锁信号")]
public bool TakeNoodleInterlock { get; set; }
///
/// 出面中
///
[Circuit(new string[] { "取面任务" }, "出面中", new bool[] { true })]
+ [VariableMonitor("出面中")]
public bool OutNoodleing { get; set; }
///
/// 允许取面
///
[Circuit(new string[] { "转台控制", "取面任务" }, "允许取面", new bool[] { true, false })]
+ [VariableMonitor("允许取面")]
public bool AllowTakeNoodle { get; set; }
///
/// 转台互锁信号
///
[Circuit(new string[] { "转台控制" }, "转台互锁信号", new bool[] { true })]
+ [VariableMonitor("转台互锁信号")]
public bool TurntableInterlock { get; set; }
///
/// 轴空闲互锁
///
+ [VariableMonitor("轴空闲互锁")]
public bool[] AxisIdleLock { get; set; } = new bool[2] { false, false };
///
@@ -364,6 +398,7 @@ namespace HBLConsole.MORKD
/// 允许运行
///
[Circuit(new string[] { "取面任务", "取浇头控制" }, "允许运行")]
+ [VariableMonitor("允许运行")]
public bool AllowRun { get; set; }
///
diff --git a/HBLConsole.Model/ViewModel/VariableMonitor.cs b/HBLConsole.Model/ViewModel/VariableMonitor.cs
new file mode 100644
index 0000000..c42603d
--- /dev/null
+++ b/HBLConsole.Model/ViewModel/VariableMonitor.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+
+namespace HBLConsole.Model
+{
+ public class VariableMonitor : ObservableObject
+ {
+
+ public int Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } }
+ private int _mId;
+
+
+ public string VarName { get { return _mVarName; } set { _mVarName = value; OnPropertyChanged(); } }
+ private string _mVarName;
+
+
+ public string PLCAddress { get { return _mPLCAddress; } set { _mPLCAddress = value; OnPropertyChanged(); } }
+ private string _mPLCAddress;
+
+
+ public string Notes { get { return _mNotes; } set { _mNotes = value; OnPropertyChanged(); } }
+ private string _mNotes;
+
+
+ public string ModbusTcpAddress { get { return _mModbusTcpAddress; } set { _mModbusTcpAddress = value; OnPropertyChanged(); } }
+ private string _mModbusTcpAddress;
+
+
+ public string CurrentValue { get { return _mCurrentValue; } set { _mCurrentValue = value; OnPropertyChanged(); } }
+ private string _mCurrentValue;
+
+
+ }
+}
diff --git a/HBLConsole/App.xaml.cs b/HBLConsole/App.xaml.cs
index 58c9401..61c03fa 100644
--- a/HBLConsole/App.xaml.cs
+++ b/HBLConsole/App.xaml.cs
@@ -43,14 +43,11 @@ namespace HBLConsole
///
private void NoCompleteOrderInit()
{
- //if (Json.Data.orderLists.ContainsKey(GeneralConfig.DeviceType.ToString()))
- //{
if (Json.Data.orderLists.Count > 0)
{
listDialogView = new ListDialogView();
listDialogView.ShowDialog();
}
- //}
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
diff --git a/HBLConsole/View/MainView.xaml b/HBLConsole/View/MainView.xaml
index c7c33a0..0c6333f 100644
--- a/HBLConsole/View/MainView.xaml
+++ b/HBLConsole/View/MainView.xaml
@@ -13,7 +13,7 @@
Height="850"
AllowsTransparency="True"
Background="{x:Null}"
- Topmost="False"
+ Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">
@@ -297,6 +297,13 @@
Content="变量管理"
Style="{StaticResource ParallelogramRadioButtonStyle}" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HBLConsole/View/VariableMonitorView.xaml.cs b/HBLConsole/View/VariableMonitorView.xaml.cs
new file mode 100644
index 0000000..132d639
--- /dev/null
+++ b/HBLConsole/View/VariableMonitorView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace HBLConsole.View
+{
+ ///
+ /// VariableMonitorView.xaml 的交互逻辑
+ ///
+ public partial class VariableMonitorView : UserControl
+ {
+ public VariableMonitorView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/HBLConsole/ViewModel/ProcessMonitoringViewModel.cs b/HBLConsole/ViewModel/ProcessMonitoringViewModel.cs
index 406f7f0..bce1023 100644
--- a/HBLConsole/ViewModel/ProcessMonitoringViewModel.cs
+++ b/HBLConsole/ViewModel/ProcessMonitoringViewModel.cs
@@ -17,36 +17,15 @@ namespace HBLConsole.ViewModel
{
public class ProcessMonitoringViewModel : ViewModelBase
{
- //static Type type;
- //static IGvl InterfaceGVL;
public ProcessMonitoringViewModel()
{
WindowName = "流程监控";
- //if (type == null)
- //{
- // InterfaceGVL = SimpleFactory.GetInstance.GVL;
- // type = InterfaceGVL?.GetType();
- // if (ProcessData.GetInstance.Conditions?.Count <= 0)
- // {
- // if (InterfaceGVL != null && type != null)
- // {
- // GetProcessInfo();
- // UpdateProcess();
- // }
- // }
- //}
-
}
static ProcessMonitoringViewModel()
{
- //InterfaceGVL = SimpleFactory.GetInstance.GVL;
- //type = InterfaceGVL?.GetType();
-
GetProcessInfo();
UpdateProcess();
-
-
}
///
@@ -54,6 +33,7 @@ namespace HBLConsole.ViewModel
///
private static void GetProcessInfo()
{
+ if (SimpleFactory.GetInstance.GVL == null) return;
//添加流程监控信息
foreach (var item in SimpleFactory.GetInstance.GVL.GetType().GetProperties())
{
@@ -102,6 +82,7 @@ namespace HBLConsole.ViewModel
///
private static void UpdateProcess()
{
+ if (SimpleFactory.GetInstance.GVL == null) return;
ThreadOperate.GetInstance.StartLong(new Action(() =>
{
foreach (var item in SimpleFactory.GetInstance.GVL.GetType().GetProperties())
diff --git a/HBLConsole/ViewModel/VariableMonitorViewModel.cs b/HBLConsole/ViewModel/VariableMonitorViewModel.cs
new file mode 100644
index 0000000..002f4ca
--- /dev/null
+++ b/HBLConsole/ViewModel/VariableMonitorViewModel.cs
@@ -0,0 +1,142 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Collections.ObjectModel;
+using HBLConsole.Model;
+using HBLConsole.Factory;
+using HBLConsole.Attributes;
+using System.Reflection;
+
+namespace HBLConsole.ViewModel
+{
+ public class VariableMonitorViewModel : ViewModelBase
+ {
+ public VariableMonitorViewModel()
+ {
+ WindowName = "变量监控";
+ }
+
+ static VariableMonitorViewModel()
+ {
+ AddMonitorData();
+ UpdateValue();
+ }
+
+ private static void AddMonitorData()
+ {
+ if (SimpleFactory.GetInstance.GVL == null) return;
+ foreach (var item in SimpleFactory.GetInstance.GVL.GetType().GetProperties())
+ {
+ if (item.CustomAttributes.Count() > 0)
+ {
+ var plcadd = item.GetCustomAttribute()?.PLCAddress;
+ var modadd = item.GetCustomAttribute()?.ModbusTcpAddress;
+ var notes = item.GetCustomAttribute()?.Notes;
+
+ if (item.PropertyType?.BaseType?.Name == "Array" && plcadd?.Length > 0)
+ {
+ var arrayRes = item.GetValue(SimpleFactory.GetInstance.GVL, null);
+ if (arrayRes != null && arrayRes is Array arr)
+ {
+ for (int i = 0; i < arr.Length; i++)
+ {
+ var res = VariableMonitors.FirstOrDefault(p => p.VarName == $"{item.Name}_{i + 1}");
+ if (res == null)
+ {
+ string[] plc = plcadd?.Substring(1).Split('.');
+ string TempPlcAddress = string.Empty;
+ if (plc?.Length == 2)
+ {
+ int add = int.Parse(plc[1]);
+ int firstAdd = int.Parse(plc[0]);
+ if (add >= 0 && add < 7)
+ {
+ add += i;
+ }
+ else if (add >= 7)
+ {
+ add = 0;
+ firstAdd++;
+ }
+ plc[0] = firstAdd.ToString();
+ plc[1] = add.ToString();
+ TempPlcAddress = $"M{plc[0]}.{plc[1]}";
+ }
+
+ VariableMonitors.Add(new VariableMonitor()
+ {
+ Id = VariableMonitors.Count,
+ VarName = $"{item.Name}_{i + 1}",
+ Notes = $"{notes}_{i + 1}",
+ ModbusTcpAddress = $"{int.Parse(modadd) + i}",
+ PLCAddress = TempPlcAddress,
+
+ });
+ }
+ }
+ }
+ }
+ else
+ {
+ var res = VariableMonitors.FirstOrDefault(p => p.VarName == item.Name);
+ if (res == null)
+ {
+ VariableMonitors.Add(new VariableMonitor()
+ {
+ Id = VariableMonitors.Count,
+ VarName = item.Name,
+ Notes = notes,
+ ModbusTcpAddress = modadd,
+ PLCAddress = plcadd,
+
+ });
+ }
+ }
+
+ }
+ }
+ }
+
+ private static void UpdateValue()
+ {
+ if (SimpleFactory.GetInstance.GVL == null) return;
+
+ foreach (var item in SimpleFactory.GetInstance.GVL.GetType().GetProperties())
+ {
+ if (item.CustomAttributes.Count() > 0)
+ {
+ if (item.PropertyType?.BaseType?.Name == "Array")
+ {
+ var arrayRes = item.GetValue(SimpleFactory.GetInstance.GVL);
+ if (arrayRes != null && arrayRes is Array arr)
+ {
+ for (int i = 0; i < arr.Length; i++)
+ {
+ int index = Array.FindIndex(VariableMonitors.ToArray(), p => p.VarName == $"{item.Name}_{i + 1}");
+ if (index >= 0 && index < VariableMonitors.Count)
+ {
+ VariableMonitors.ElementAt(index).CurrentValue = arr.GetValue(i)?.ToString();
+ }
+ }
+ }
+ }
+ else
+ {
+ int index = Array.FindIndex(VariableMonitors.ToArray(), p => p.VarName == item.Name);
+ if (index >= 0 && index < VariableMonitors.Count)
+ {
+ VariableMonitors.ElementAt(index).CurrentValue = item.GetValue(SimpleFactory.GetInstance.GVL)?.ToString();
+ }
+ }
+
+ }
+ }
+ }
+
+
+ public static ObservableCollection VariableMonitors { get; set; } = new ObservableCollection();
+
+ }
+}