From 9cb8a9e521237f9ae54300b47ab3af9cbfade0e1 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: Sat, 12 Mar 2022 17:03:52 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BD=8D=E6=9C=BA=E6=A1=86=E6=9E=B6?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../CircuitAttribute.cs | 5 +-
.../HBLConsole.Attributes.csproj | 11 +++
HBLConsole.Business/AlarmHelper.cs | 8 +-
HBLConsole.Business/Devices/MORKD.cs | 47 ++++++++++
HBLConsole.Business/Devices/MORKS.cs | 94 ++++++-------------
HBLConsole.Business/HeartbeatReport.cs | 14 +--
HBLConsole.Business/M2MqttHelper.cs | 2 +-
HBLConsole.Business/MessageServer/Base.cs | 20 ++--
HBLConsole.Business/ServerData.cs | 2 +-
HBLConsole.Communication/ConnectHelper.cs | 47 ++++++++++
HBLConsole.Communication/ModbusTcpHelper.cs | 3 +-
HBLConsole.Communication/MqttHelper.cs | 2 +-
HBLConsole.Factory/HBLConsole.Factory.csproj | 1 +
HBLConsole.Factory/SimpleFactory.cs | 11 ++-
HBLConsole.GVL/{ => Device}/MORKS.cs | 1 +
HBLConsole.GVL/GeneralConfig.cs | 17 +++-
HBLConsole.GVL/HBLConsole.GVL.csproj | 1 +
HBLConsole.GVL/InternetInfo.cs | 30 +++---
HBLConsole.Interface/IControl.cs | 18 ++++
HBLConsole.MainConsole/Main.cs | 22 ++---
.../SerialDeviceBase.cs | 0
.../{ => CommunicationPar}/TcpDeviceBase.cs | 0
.../{ => CommunicationPar}/UniversalBase.cs | 0
HBLConsole.Model/Condition.cs | 25 +++++
HBLConsole.Model/Enums/EDeviceType.cs | 24 +++++
HBLConsole.Model/ProcessConditions.cs | 31 ++++--
.../ProcessData.cs | 16 ++--
HBLConsole.Service/ActionManagerment.cs | 2 +-
HBLConsole.Service/Json.cs | 24 ++---
HBLConsole.sln | 6 ++
HBLConsole/App.config | 2 +-
HBLConsole/App.xaml.cs | 4 +-
.../View/DeviceManagermentSetView.xaml.cs | 4 +-
.../ViewModel/ListDialogViewModel.cs | 14 +--
HBLConsole/View/DebugView.xaml | 2 +-
HBLConsole/ViewModel/DebugViewModel.cs | 23 ++---
HBLConsole/ViewModel/DeviceManageViewModel.cs | 33 ++-----
HBLConsole/ViewModel/MainViewModel.cs | 6 +-
.../ViewModel/ProcessMonitoringViewModel.cs | 25 ++---
39 files changed, 377 insertions(+), 220 deletions(-)
rename {HBLConsole.GVL => HBLConsole.Attribute}/CircuitAttribute.cs (98%)
create mode 100644 HBLConsole.Attribute/HBLConsole.Attributes.csproj
create mode 100644 HBLConsole.Business/Devices/MORKD.cs
create mode 100644 HBLConsole.Communication/ConnectHelper.cs
rename HBLConsole.GVL/{ => Device}/MORKS.cs (99%)
create mode 100644 HBLConsole.Interface/IControl.cs
rename HBLConsole.Model/{ => CommunicationPar}/SerialDeviceBase.cs (100%)
rename HBLConsole.Model/{ => CommunicationPar}/TcpDeviceBase.cs (100%)
rename HBLConsole.Model/{ => CommunicationPar}/UniversalBase.cs (100%)
create mode 100644 HBLConsole.Model/Condition.cs
rename {HBLConsole.GVL => HBLConsole.Model}/ProcessData.cs (66%)
diff --git a/HBLConsole.GVL/CircuitAttribute.cs b/HBLConsole.Attribute/CircuitAttribute.cs
similarity index 98%
rename from HBLConsole.GVL/CircuitAttribute.cs
rename to HBLConsole.Attribute/CircuitAttribute.cs
index 7f5456d..2e1b072 100644
--- a/HBLConsole.GVL/CircuitAttribute.cs
+++ b/HBLConsole.Attribute/CircuitAttribute.cs
@@ -1,10 +1,11 @@
-using System;
+using HBLConsole.Model;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace HBLConsole.GVL
+namespace HBLConsole.Attributes
{
[AttributeUsage(AttributeTargets.Property)]
public class CircuitAttribute : Attribute
diff --git a/HBLConsole.Attribute/HBLConsole.Attributes.csproj b/HBLConsole.Attribute/HBLConsole.Attributes.csproj
new file mode 100644
index 0000000..ec77777
--- /dev/null
+++ b/HBLConsole.Attribute/HBLConsole.Attributes.csproj
@@ -0,0 +1,11 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
diff --git a/HBLConsole.Business/AlarmHelper.cs b/HBLConsole.Business/AlarmHelper.cs
index 44c9331..2b41ca2 100644
--- a/HBLConsole.Business/AlarmHelper.cs
+++ b/HBLConsole.Business/AlarmHelper.cs
@@ -16,7 +16,7 @@ namespace HBLConsole.Business
public static AlarmHelper GetInstance => _Instance ?? (_Instance = new AlarmHelper());
private AlarmHelper()
{
- Json.GetInstance.Read();
+ Json.Read();
colorValue.TryAdd(AlarmLevel.一般报警.ToString(), Color.FromArgb(1, 255, 216, 0));
colorValue.TryAdd(AlarmLevel.严重报警.ToString(), Color.FromArgb(1, 255, 0, 0));
}
@@ -67,10 +67,10 @@ namespace HBLConsole.Business
Alarms.Add(new AlarmInfo() { AlarmInfomation = AlarmInfo, date = DateTime.Now.ToString("HH:mm:ss"), AlarmLevel = alarmLevel.ToString() });
//报警频率计算
- if (Json.GetInstance.Base.AlarmHz.ContainsKey(AlarmInfo))
- Json.GetInstance.Base.AlarmHz[AlarmInfo]++;
+ if (Json.Data.AlarmHz.ContainsKey(AlarmInfo))
+ Json.Data.AlarmHz[AlarmInfo]++;
else
- Json.GetInstance.Base.AlarmHz.TryAdd(AlarmInfo, 1);
+ Json.Data.AlarmHz.TryAdd(AlarmInfo, 1);
if (AddAction != null) AddAction(AlarmInfo);//添加报警通知
if (ChangeAction != null) ChangeAction();//更改报警通知
diff --git a/HBLConsole.Business/Devices/MORKD.cs b/HBLConsole.Business/Devices/MORKD.cs
new file mode 100644
index 0000000..b0df0e9
--- /dev/null
+++ b/HBLConsole.Business/Devices/MORKD.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HBLConsole.Interface;
+
+namespace HBLConsole.Business.Devices
+{
+ public class MORKD : IControl
+ {
+
+ private volatile static MORKD _Instance;
+ public static MORKD GetInstance => _Instance ?? (_Instance = new MORKD());
+ private MORKD() { }
+
+ public void DataParse(T order)
+ {
+
+ }
+
+ public void Init()
+ {
+
+ }
+
+ public void Main()
+ {
+
+ }
+
+ public void ReadData()
+ {
+
+ }
+
+ public void SimOrder()
+ {
+
+ }
+
+ public void ConnectOk()
+ {
+
+ }
+ }
+}
diff --git a/HBLConsole.Business/Devices/MORKS.cs b/HBLConsole.Business/Devices/MORKS.cs
index 469e27d..accfca0 100644
--- a/HBLConsole.Business/Devices/MORKS.cs
+++ b/HBLConsole.Business/Devices/MORKS.cs
@@ -16,7 +16,7 @@ using BPA.Models;
namespace HBLConsole.Business.Devices
{
- public class MORKS : IBusiness
+ public class MORKS : IControl
{
private volatile static MORKS _Instance;
public static MORKS GetInstance => _Instance ?? (_Instance = new MORKS());
@@ -26,47 +26,18 @@ namespace HBLConsole.Business.Devices
public void Init()
{
- //Modbus TCP连接成功
- ActionManagerment.GetInstance.Register(new Action(() =>
- {
- WriteRecipeBoms();
- ReadPlcData();
- DataParse();
- Main();
- //ResetProgram();
- }), "ConnectOk");
-
- //获取物料信息
- SimpleFactory.GetInstance.GetBatchingInfo();
-
- //Modbus Tcp 连接
- //ModbusTcpHelper.GetInstance.ModbusTcpConnect("192.168.1.11", 508);
- ModbusTcpHelper.GetInstance.ModbusTcpConnect("127.0.0.1");
-
//模拟订单
SimOrder();
Test();
- Heartbeat();
- MessageLog.GetInstance.Show("MORKS 设备初始化完成");
}
- List batchingInfos = new List();
-
- ///
- /// 心跳状态
- ///
- private void Heartbeat()
+ public void ConnectOk()
{
- HeartbeatReport.GetInstance.GetMessage = new Action(() =>
- {
- HeartbeatReport.GetInstance.deviceStatus.BatchingInfo = batchingInfos;
-#if test
- HeartbeatReport.GetInstance.deviceStatus.Healthy = DeviceHealthy.UnHealth;
-#else
- HeartbeatReport.GetInstance.deviceStatus.Healthy = mORKS.AllowRun ? DeviceHealthy.UnHealth : DeviceHealthy.Health;
-#endif
-
- });
+ WriteRecipeBoms();
+ ReadData();
+ Main();
+ //ResetProgram();
+ MessageLog.GetInstance.Show("MORKS 设备初始化完成");
}
///
@@ -146,7 +117,7 @@ namespace HBLConsole.Business.Devices
///
/// 数据读取
///
- private void ReadPlcData()
+ public void ReadData()
{
ThreadManagerment.GetInstance.StartLong(new Action(() =>
{
@@ -198,7 +169,7 @@ namespace HBLConsole.Business.Devices
public ushort NoodleLoc { get; set; }
public ushort BowlLoc { get; set; }
- private void SimOrder()
+ public void SimOrder()
{
ActionManagerment.GetInstance.Register(new Action
public void GetBatchingInfo()
{
- GetAbsMessageServer.GetBatchingInfo(InternetInfo.GetInstance.ClientId);
+ GetAbsMessageServer.GetBatchingInfo(InternetInfo.ClientId);
}
///
@@ -72,8 +73,12 @@ namespace HBLConsole.Factory
{
string NameSpace = "HBLConsole.Business";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.Devices.{DeviceType}");
- IBusiness business = (IBusiness)type?.GetProperty("GetInstance").GetValue(null);
+ IControl business = (IControl)type?.GetProperty("GetInstance").GetValue(null);
+ GetBatchingInfo();
business?.Init();
+ ActionManagerment.GetInstance.Register(new Action((o) => { business?.DataParse(o); }), "DataParse");
+ ActionManagerment.GetInstance.Register(new Action(() => { business?.ConnectOk(); }), "ConnectOk");
+ ConnectHelper.GetInstance.Init();
}
public IGvl GetGvl()
diff --git a/HBLConsole.GVL/MORKS.cs b/HBLConsole.GVL/Device/MORKS.cs
similarity index 99%
rename from HBLConsole.GVL/MORKS.cs
rename to HBLConsole.GVL/Device/MORKS.cs
index dea3d6a..e91385b 100644
--- a/HBLConsole.GVL/MORKS.cs
+++ b/HBLConsole.GVL/Device/MORKS.cs
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using HBLConsole.Interface;
using System.Collections.Concurrent;
+using HBLConsole.Attributes;
namespace HBLConsole.GVL
{
diff --git a/HBLConsole.GVL/GeneralConfig.cs b/HBLConsole.GVL/GeneralConfig.cs
index f6940ab..f60deea 100644
--- a/HBLConsole.GVL/GeneralConfig.cs
+++ b/HBLConsole.GVL/GeneralConfig.cs
@@ -3,18 +3,27 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using BPA.Message;
using BPA.Message.Enum;
namespace HBLConsole.GVL
{
public class GeneralConfig
{
+ ///
+ /// 客户端设备类型
+ ///
+ public static DeviceClientType DeviceType { get; set; }
- private volatile static GeneralConfig _Instance;
- public static GeneralConfig GetInstance => _Instance ?? (_Instance = new GeneralConfig());
- private GeneralConfig() { }
+ ///
+ /// 心跳上报的物料信息
+ ///
+ public static List BatchingInfos { get; set; } = new List();
- public DeviceClientType DeviceType { get; set; }
+ ///
+ /// 心跳健康状态
+ ///
+ public static bool Healthy { get; set; }
}
}
diff --git a/HBLConsole.GVL/HBLConsole.GVL.csproj b/HBLConsole.GVL/HBLConsole.GVL.csproj
index 25caeb4..1cebee4 100644
--- a/HBLConsole.GVL/HBLConsole.GVL.csproj
+++ b/HBLConsole.GVL/HBLConsole.GVL.csproj
@@ -13,6 +13,7 @@
+
diff --git a/HBLConsole.GVL/InternetInfo.cs b/HBLConsole.GVL/InternetInfo.cs
index 9a886ab..c147a04 100644
--- a/HBLConsole.GVL/InternetInfo.cs
+++ b/HBLConsole.GVL/InternetInfo.cs
@@ -18,14 +18,14 @@ namespace HBLConsole.GVL
///
public class InternetInfo
{
- private volatile static InternetInfo _Instance;
- public static InternetInfo GetInstance => _Instance ?? (_Instance = new InternetInfo());
- private InternetInfo() { }
+ //private volatile static InternetInfo _Instance;
+ //public static InternetInfo GetInstance => _Instance ?? (_Instance = new InternetInfo());
+ //private InternetInfo() { }
///
/// 配置初始化
///
- public void ConfigInit()
+ public static void ConfigInit()
{
NetworkConnectState = UniversalHelper.GetInstance.GetNetworkState();
while (!NetworkConnectState)
@@ -64,43 +64,43 @@ namespace HBLConsole.GVL
///
/// Consul 地址
///
- public string ConsulAddress { get; set; }
+ public static string ConsulAddress { get; set; }
///
/// 网络连接状态
///
- public bool NetworkConnectState { get; set; }
+ public static bool NetworkConnectState { get; set; }
///
/// 广告地址
///
- public Uri SorbetesAddress { get; set; }
+ public static Uri SorbetesAddress { get; set; }
///
/// 客户端ID
///
- public int ClientId { get; set; }
+ public static int ClientId { get; set; }
#region MQTT连接信息
///
/// mqtt 服务地址
///
- public string MqttAddress { get; set; }
+ public static string MqttAddress { get; set; }
///
/// mqtt 用户名
///
- public string MqttUserName { get; set; }
+ public static string MqttUserName { get; set; }
///
/// mqtt 密码
///
- public string MqttPassword { get; set; }
+ public static string MqttPassword { get; set; }
///
/// mqtt 端口号
///
- public int MqttPort { get; set; }
+ public static int MqttPort { get; set; }
#endregion
#region API地址
@@ -108,17 +108,17 @@ namespace HBLConsole.GVL
///
/// Api 网关地址
///
- public string ApiAddress { get; set; }
+ public static string ApiAddress { get; set; }
///
/// 订单服务
///
- public string OrderServer { get; set; }
+ public static string OrderServer { get; set; }
///
/// 库存服务
///
- public string StockServer { get; set; }
+ public static string StockServer { get; set; }
#endregion
}
diff --git a/HBLConsole.Interface/IControl.cs b/HBLConsole.Interface/IControl.cs
new file mode 100644
index 0000000..94159db
--- /dev/null
+++ b/HBLConsole.Interface/IControl.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HBLConsole.Interface
+{
+ public interface IControl
+ {
+ void Main();
+ void Init();
+ void ReadData();
+ void SimOrder();
+ void DataParse(T order);
+ void ConnectOk();
+ }
+}
diff --git a/HBLConsole.MainConsole/Main.cs b/HBLConsole.MainConsole/Main.cs
index 5cace55..80bb71c 100644
--- a/HBLConsole.MainConsole/Main.cs
+++ b/HBLConsole.MainConsole/Main.cs
@@ -24,14 +24,14 @@ namespace HBLConsole.MainConsole
public void DataInit()
{
- Json.GetInstance.Read();
- Json.GetInstance.Read();
+ Json.Read();
+ Json.Read();
}
public void DataSave()
{
- Json.GetInstance.Save();
- Json.GetInstance.Save();
+ Json.Save();
+ Json.Save();
TextHelper.GetInstance.SaveLogInfo(MessageLog.GetInstance.LogInfo, "LogInfo");
}
@@ -39,11 +39,11 @@ namespace HBLConsole.MainConsole
{
ThreadManagerment.GetInstance.Start(new Action(() =>
{
- InternetInfo.GetInstance.ConfigInit();//从 consul 获取配置数据
+ InternetInfo.ConfigInit();//从 consul 获取配置数据
Topics.Clear();
- Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.GetInstance.DeviceType, InternetInfo.GetInstance.ClientId));
- Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.GetInstance.DeviceType, InternetInfo.GetInstance.ClientId));
+ Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.ClientId));
+ Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.ClientId));
SimpleFactory.GetInstance.DeviceInit();//设备初始化
@@ -67,10 +67,10 @@ namespace HBLConsole.MainConsole
MqttHelper.GetInstance.Reconnection = new Action(() => { MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray()); });
//MQTT 连接
- MqttHelper.GetInstance.MqttInitAsync(InternetInfo.GetInstance.MqttUserName,
- InternetInfo.GetInstance.MqttPassword,
- InternetInfo.GetInstance.MqttAddress,
- InternetInfo.GetInstance.MqttPort,
+ MqttHelper.GetInstance.MqttInitAsync(InternetInfo.MqttUserName,
+ InternetInfo.MqttPassword,
+ InternetInfo.MqttAddress,
+ InternetInfo.MqttPort,
DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
}), "业务逻辑初始化");
}
diff --git a/HBLConsole.Model/SerialDeviceBase.cs b/HBLConsole.Model/CommunicationPar/SerialDeviceBase.cs
similarity index 100%
rename from HBLConsole.Model/SerialDeviceBase.cs
rename to HBLConsole.Model/CommunicationPar/SerialDeviceBase.cs
diff --git a/HBLConsole.Model/TcpDeviceBase.cs b/HBLConsole.Model/CommunicationPar/TcpDeviceBase.cs
similarity index 100%
rename from HBLConsole.Model/TcpDeviceBase.cs
rename to HBLConsole.Model/CommunicationPar/TcpDeviceBase.cs
diff --git a/HBLConsole.Model/UniversalBase.cs b/HBLConsole.Model/CommunicationPar/UniversalBase.cs
similarity index 100%
rename from HBLConsole.Model/UniversalBase.cs
rename to HBLConsole.Model/CommunicationPar/UniversalBase.cs
diff --git a/HBLConsole.Model/Condition.cs b/HBLConsole.Model/Condition.cs
new file mode 100644
index 0000000..4a50e1c
--- /dev/null
+++ b/HBLConsole.Model/Condition.cs
@@ -0,0 +1,25 @@
+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 Condition:ObservableObject
+ {
+ public bool ConditionMet { get { return _mConditionMet; } set { _mConditionMet = value; OnPropertyChanged(); } }
+ private bool _mConditionMet;
+
+ public string propertyIllustrate { get { return _mpropertyIllustrate; } set { _mpropertyIllustrate = value; OnPropertyChanged(); } }
+ private string _mpropertyIllustrate;
+
+ public string ToolTip { get { return _mToolTip; } set { _mToolTip = value; OnPropertyChanged(); } }
+ private string _mToolTip;
+
+
+ public bool IsNot { get; set; }
+
+ }
+}
diff --git a/HBLConsole.Model/Enums/EDeviceType.cs b/HBLConsole.Model/Enums/EDeviceType.cs
index 86652bc..f8cc81f 100644
--- a/HBLConsole.Model/Enums/EDeviceType.cs
+++ b/HBLConsole.Model/Enums/EDeviceType.cs
@@ -8,9 +8,33 @@ namespace HBLConsole.Model
{
public enum EDeviceType
{
+ ///
+ /// 西门子设备
+ ///
Siemens,
+ ///
+ /// Modbus RTU 设备
+ ///
ModbusRtu,
+ ///
+ /// Modbus TCP 设备
+ ///
ModbusTcp,
+ ///
+ /// 串口设备
+ ///
SerialPort,
+ ///
+ /// 博士咖啡机设备
+ ///
+ Coffee,
+ ///
+ /// 冰淇淋设备
+ ///
+ IceCream,
+ ///
+ /// 节卡机器人
+ ///
+ JAKA
}
}
diff --git a/HBLConsole.Model/ProcessConditions.cs b/HBLConsole.Model/ProcessConditions.cs
index 116d37f..8fbacb1 100644
--- a/HBLConsole.Model/ProcessConditions.cs
+++ b/HBLConsole.Model/ProcessConditions.cs
@@ -24,21 +24,32 @@ namespace HBLConsole.Model
}
- public class Condition : ObservableObject
- {
+ //public class Condition : ObservableObject
+ //{
- public bool ConditionMet { get { return _mConditionMet; } set { _mConditionMet = value; OnPropertyChanged(); } }
- private bool _mConditionMet;
+ // public bool ConditionMet { get { return _mConditionMet; } set { _mConditionMet = value; OnPropertyChanged(); } }
+ // private bool _mConditionMet;
- public string ConditionName { get { return _mConditionName; } set { _mConditionName = value; OnPropertyChanged(); } }
- private string _mConditionName;
+ // public string ConditionName { get { return _mConditionName; } set { _mConditionName = value; OnPropertyChanged(); } }
+ // private string _mConditionName;
- public string ToolTip { get { return _mToolTip; } set { _mToolTip = value; OnPropertyChanged(); } }
- private string _mToolTip;
+ // public string ToolTip { get { return _mToolTip; } set { _mToolTip = value; OnPropertyChanged(); } }
+ // private string _mToolTip;
+
+
+ // public bool IsNot { get; set; }
+ //}
+
+ //public class Condition
+ //{
+ // public bool ConditionMet { get; set; }
+ // public string propertyIllustrate { get; set; }
+
+ // public string ToolTip { get; set; }
+ // public bool IsNot { get; set; }
+ //}
- public bool IsNot { get; set; }
- }
}
diff --git a/HBLConsole.GVL/ProcessData.cs b/HBLConsole.Model/ProcessData.cs
similarity index 66%
rename from HBLConsole.GVL/ProcessData.cs
rename to HBLConsole.Model/ProcessData.cs
index dc984ee..8eb1e1f 100644
--- a/HBLConsole.GVL/ProcessData.cs
+++ b/HBLConsole.Model/ProcessData.cs
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
-namespace HBLConsole.GVL
+namespace HBLConsole.Model
{
public class ProcessData
{
@@ -18,12 +18,12 @@ namespace HBLConsole.GVL
}
- public class Condition
- {
- public bool ConditionMet { get; set; }
- public string propertyIllustrate { get; set; }
+ //public class Condition
+ //{
+ // public bool ConditionMet { get; set; }
+ // public string propertyIllustrate { get; set; }
- public string ToolTip { get; set; }
- public bool IsNot { get; set; }
- }
+ // public string ToolTip { get; set; }
+ // public bool IsNot { get; set; }
+ //}
}
diff --git a/HBLConsole.Service/ActionManagerment.cs b/HBLConsole.Service/ActionManagerment.cs
index 44625c6..35cdeda 100644
--- a/HBLConsole.Service/ActionManagerment.cs
+++ b/HBLConsole.Service/ActionManagerment.cs
@@ -26,7 +26,7 @@ namespace HBLConsole.Service
/// 注销委托
///
///
- public void LogOut(string name)
+ public void CancelRegister(string name)
{
if (actions.ContainsKey(name))
{
diff --git a/HBLConsole.Service/Json.cs b/HBLConsole.Service/Json.cs
index f9bd639..ba12f34 100644
--- a/HBLConsole.Service/Json.cs
+++ b/HBLConsole.Service/Json.cs
@@ -10,9 +10,9 @@ namespace HBLConsole.Service
///
public class Json where T : class, new()
{
- private volatile static Json _Instance;
- public static Json GetInstance => _Instance ?? (_Instance = new Json());
- private Json() { }
+ //private volatile static Json _Instance;
+ //public static Json GetInstance => _Instance ?? (_Instance = new Json());
+ //private Json() { }
static string path
{
@@ -23,45 +23,45 @@ namespace HBLConsole.Service
}
}
- public T Base { get; set; } = new T();
+ public static T Data { get; set; } = new T();
///
/// 保存数据
///
- public void Save()
+ public static void Save()
{
- string outjson = JsonConvert.SerializeObject(Base);
+ string outjson = JsonConvert.SerializeObject(Data);
File.WriteAllText(path, outjson);
}
///
/// 获取保存的数据
///
- public void Read()
+ public static void Read()
{
if (File.Exists(path))
{
string JsonString = File.ReadAllText(path);
var result = JsonConvert.DeserializeObject(JsonString);
- if (result != null) { Base = result; }
+ if (result != null) { Data = result; }
}
}
///
/// 保存带接口的对象
///
- public void SaveInterface()
+ public static void SaveInterface()
{
var settings = new JsonSerializerSettings();
settings.TypeNameHandling = TypeNameHandling.Objects;
- string outjson = JsonConvert.SerializeObject(Base, Formatting.Indented, settings);
+ string outjson = JsonConvert.SerializeObject(Data, Formatting.Indented, settings);
File.WriteAllText(path, outjson);
}
///
/// 获取带接口对象的字符串
///
- public void ReadInterface()
+ public static void ReadInterface()
{
if (File.Exists(path))
{
@@ -69,7 +69,7 @@ namespace HBLConsole.Service
settings.TypeNameHandling = TypeNameHandling.Objects;
string JsonString = File.ReadAllText(path);
var result = JsonConvert.DeserializeObject(JsonString, settings);
- if (result != null) { Base = result; }
+ if (result != null) { Data = result; }
}
}
diff --git a/HBLConsole.sln b/HBLConsole.sln
index 6bcc062..d0e3ab3 100644
--- a/HBLConsole.sln
+++ b/HBLConsole.sln
@@ -25,6 +25,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.Abstract", "HBLC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.Factory", "HBLConsole.Factory\HBLConsole.Factory.csproj", "{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HBLConsole.Attributes", "HBLConsole.Attribute\HBLConsole.Attributes.csproj", "{9F022DDD-B69C-4AC9-AFB0-0A688EAA1F64}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -75,6 +77,10 @@ Global
{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B19BE8D-AFB9-4635-B114-8648B0C8BDF7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9F022DDD-B69C-4AC9-AFB0-0A688EAA1F64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9F022DDD-B69C-4AC9-AFB0-0A688EAA1F64}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9F022DDD-B69C-4AC9-AFB0-0A688EAA1F64}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9F022DDD-B69C-4AC9-AFB0-0A688EAA1F64}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/HBLConsole/App.config b/HBLConsole/App.config
index 1e2ee8f..af9f483 100644
--- a/HBLConsole/App.config
+++ b/HBLConsole/App.config
@@ -11,7 +11,7 @@
-
+
diff --git a/HBLConsole/App.xaml.cs b/HBLConsole/App.xaml.cs
index 1feb2a7..b18dcad 100644
--- a/HBLConsole/App.xaml.cs
+++ b/HBLConsole/App.xaml.cs
@@ -26,13 +26,13 @@ namespace HBLConsole
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
- GeneralConfig.GetInstance.DeviceType = DeviceClientType.MORKS;
+ GeneralConfig.DeviceType = DeviceClientType.MORKS;
SystemHelper.GetInstance.AutoStart(false);
SystemHelper.GetInstance.CreateDesktopShortcut();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
MainConsole.Main.GetInstance.DataInit();
mainView.Show();
- if (Json.GetInstance.Base.morkOrderPushes.Count > 0)
+ if (Json.Data.morkOrderPushes.Count > 0)
{
listDialogView = new ListDialogView();
listDialogView.ShowDialog();
diff --git a/HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml.cs b/HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml.cs
index 18b5e13..60ce554 100644
--- a/HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml.cs
+++ b/HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml.cs
@@ -38,7 +38,7 @@ namespace HBLConsole.DialogWindow.View
{
this.Tag = s;
this.DialogResult = false;
- ActionManagerment.GetInstance.LogOut("Cancel");
+ ActionManagerment.GetInstance.CancelRegister("Cancel");
this.Close();
}), "Cancel");
@@ -47,7 +47,7 @@ namespace HBLConsole.DialogWindow.View
{
this.Tag = s;
this.DialogResult = true;
- ActionManagerment.GetInstance.LogOut("Confirm");
+ ActionManagerment.GetInstance.CancelRegister("Confirm");
this.Close();
}), "Confirm");
diff --git a/HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs b/HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs
index 0505f28..01ef5f8 100644
--- a/HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs
+++ b/HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs
@@ -46,14 +46,14 @@ namespace HBLConsole.DialogWindow.ViewModel
CloseCommand = new RelayCommand(() =>
{
- Json.GetInstance.Base.morkOrderPushes.Clear();
+ Json.Data.morkOrderPushes.Clear();
orderStatusLists.Clear();
WeakReferenceMessenger.Default.Send("false", "Close");
});
CancelCommand = new RelayCommand(() =>
{
- Json.GetInstance.Base.morkOrderPushes.Clear();
+ Json.Data.morkOrderPushes.Clear();
orderStatusLists.Clear();
WeakReferenceMessenger.Default.Send("false", "Close");
});
@@ -64,23 +64,23 @@ namespace HBLConsole.DialogWindow.ViewModel
{
if (!item.IsSelected)
{
- var reslut = Json.GetInstance.Base.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == item.OrderPush.SuborderId);
- if (reslut != null) Json.GetInstance.Base.morkOrderPushes.Remove(reslut);
+ var reslut = Json.Data.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == item.OrderPush.SuborderId);
+ if (reslut != null) Json.Data.morkOrderPushes.Remove(reslut);
}
}
- foreach (var item in Json.GetInstance.Base.morkOrderPushes)
+ foreach (var item in Json.Data.morkOrderPushes)
{
orderStatusLists.Add(new OrderData() { IsSelected = true, OrderPush = item.OrderPush, OrderStatus = item.OrderStatus });
}
WeakReferenceMessenger.Default.Send("true", "Close");
});
- foreach (var item in Json.GetInstance.Base.morkOrderPushes)
+ foreach (var item in Json.Data.morkOrderPushes)
{
orderStatusLists.Add(new OrderData() { IsSelected = true, OrderPush = item.OrderPush, OrderStatus = item.OrderStatus });
}
- if (Json.GetInstance.Base.morkOrderPushes.Count > 0)
+ if (Json.Data.morkOrderPushes.Count > 0)
{
ThreadManagerment.GetInstance.Start(new Action(() =>
{
diff --git a/HBLConsole/View/DebugView.xaml b/HBLConsole/View/DebugView.xaml
index 997c2bd..8e1f5aa 100644
--- a/HBLConsole/View/DebugView.xaml
+++ b/HBLConsole/View/DebugView.xaml
@@ -292,7 +292,7 @@
diff --git a/HBLConsole/ViewModel/DebugViewModel.cs b/HBLConsole/ViewModel/DebugViewModel.cs
index 7755469..213e253 100644
--- a/HBLConsole/ViewModel/DebugViewModel.cs
+++ b/HBLConsole/ViewModel/DebugViewModel.cs
@@ -13,6 +13,7 @@ using HBLConsole.Communication;
using HBLConsole.Model;
using System.Reflection;
using System.Collections.Concurrent;
+using HBLConsole.Attributes;
namespace HBLConsole.ViewModel
{
@@ -51,20 +52,20 @@ namespace HBLConsole.ViewModel
{
if (item.CustomAttributes.Count() > 0)
{
- string? propertyInfo = item.GetCustomAttribute()?.PropertyIllustrate;
- string[]? Classifiactions = item.GetCustomAttribute()?.Classifiaction;
+ string? propertyInfo = item.GetCustomAttribute()?.PropertyIllustrate;
+ string[]? Classifiactions = item.GetCustomAttribute()?.Classifiaction;
if (Classifiactions != null)
{
foreach (var itemClassifiactions in Classifiactions)
{
- if (GVL.ProcessData.GetInstance.Conditions.ContainsKey(itemClassifiactions))
+ if (ProcessData.GetInstance.Conditions.ContainsKey(itemClassifiactions))
{
if (propertyInfo != null)
{
- int index = Array.FindIndex(GVL.ProcessData.GetInstance.Conditions[itemClassifiactions].ToArray(), p => p.propertyIllustrate == propertyInfo);
+ int index = Array.FindIndex(ProcessData.GetInstance.Conditions[itemClassifiactions].ToArray(), p => p.propertyIllustrate == propertyInfo);
if (index >= 0)
{
- GVL.ProcessData.GetInstance.Conditions[itemClassifiactions].ElementAt(index).ToolTip = item.Name;
+ ProcessData.GetInstance.Conditions[itemClassifiactions].ElementAt(index).ToolTip = item.Name;
}
}
}
@@ -72,7 +73,7 @@ namespace HBLConsole.ViewModel
}
}
}
- var Conditions = GVL.ProcessData.GetInstance.Conditions;
+ var Conditions = ProcessData.GetInstance.Conditions;
if (Conditions != null)
{
foreach (var item in Conditions)
@@ -81,7 +82,7 @@ namespace HBLConsole.ViewModel
process.ProcessTitl = item.Key;
foreach (var values in item.Value)
{
- process.Conditions.Add(new Condition() { ConditionName = values.propertyIllustrate });
+ process.Conditions.Add(new Condition() { propertyIllustrate = values.propertyIllustrate });
}
processConditions.Add(process);
}
@@ -95,20 +96,20 @@ namespace HBLConsole.ViewModel
{
if (item.CustomAttributes.Count() > 0)
{
- string? propertyInfo = item.GetCustomAttribute()?.PropertyIllustrate;
- string[]? Classifiactions = item.GetCustomAttribute()?.Classifiaction;
+ string? propertyInfo = item.GetCustomAttribute()?.PropertyIllustrate;
+ string[]? Classifiactions = item.GetCustomAttribute()?.Classifiaction;
if (Classifiactions != null)
{
foreach (string? Titles in Classifiactions)
{
if (Titles != null && propertyInfo != null)
{
- bool? isNot = GVL.ProcessData.GetInstance.Conditions[Titles]?.FirstOrDefault(p => p.propertyIllustrate == propertyInfo)?.IsNot;
+ bool? isNot = ProcessData.GetInstance.Conditions[Titles]?.FirstOrDefault(p => p.propertyIllustrate == propertyInfo)?.IsNot;
int index = Array.FindIndex(processConditions.ToArray(), p => p.ProcessTitl == Titles);
if (index >= 0)
{
- int PropertyIndex = Array.FindIndex(processConditions.ElementAt(index).Conditions.ToArray(), p => p.ConditionName == propertyInfo);
+ int PropertyIndex = Array.FindIndex(processConditions.ElementAt(index).Conditions.ToArray(), p => p.propertyIllustrate == propertyInfo);
if (PropertyIndex >= 0)
{
var res = type.GetProperty(item.Name)?.GetValue(MORKS.GetInstance.mORKS, null);
diff --git a/HBLConsole/ViewModel/DeviceManageViewModel.cs b/HBLConsole/ViewModel/DeviceManageViewModel.cs
index a0dc071..fbc89a4 100644
--- a/HBLConsole/ViewModel/DeviceManageViewModel.cs
+++ b/HBLConsole/ViewModel/DeviceManageViewModel.cs
@@ -24,19 +24,19 @@ namespace HBLConsole.ViewModel
ActionManagerment.GetInstance.Register(new Action(() =>
{
- Json.GetInstance.Base.communicationSets.Clear();
+ Json.Data.communicationSets.Clear();
foreach (var item in communicationSets)
{
item.RemoveAction = null;
- Json.GetInstance.Base.communicationSets.Add(item);
+ Json.Data.communicationSets.Add(item);
}
- Json.GetInstance.Save();
+ Json.Save();
}), "DataSave");
- Json.GetInstance.Read();
+ Json.Read();
communicationSets.Clear();
- foreach (var item in Json.GetInstance.Base.communicationSets)
+ foreach (var item in Json.Data.communicationSets)
{
item.RemoveAction = RemoveDevice;
communicationSets.Add(item);
@@ -85,31 +85,10 @@ namespace HBLConsole.ViewModel
{
communicationObj.Device = (IDeviceType)Activator.CreateInstance(type);
}
- communicationObj.DeviceName = ResultTag.DeviceName;
+ communicationObj.DeviceName = $"{ResultTag.DeviceName}【{eDeviceType}】";
communicationObj.deviceType = eDeviceType;
communicationObj.RemoveAction = RemoveDevice;
communicationSets.Add(communicationObj);
-
-
-
- //switch (eDeviceType)
- //{
- // case EDeviceType.Siemens:
- // //communicationObj.CommSiemens = new Siemens();
- // //communicationObj.CommSiemens.IsVisible = true;
- // break;
- // case EDeviceType.ModbusRtu:
- // //communicationObj.CommModbusRtu.IsVisible = true;
- // break;
- // case EDeviceType.ModbusTcp:
- // //communicationObj.CommModbusTcp.IsVisible = true;
- // break;
- // case EDeviceType.SerialPort:
- // break;
- // default:
- // break;
- //}
-
}
}
}
diff --git a/HBLConsole/ViewModel/MainViewModel.cs b/HBLConsole/ViewModel/MainViewModel.cs
index c647d1d..12fb9e5 100644
--- a/HBLConsole/ViewModel/MainViewModel.cs
+++ b/HBLConsole/ViewModel/MainViewModel.cs
@@ -24,9 +24,9 @@ namespace HBLConsole.ViewModel
NavChangedCommand = new RelayCommand(DoNavChanged);
ThreadManagerment.GetInstance.StartLong(new Action(() =>
{
- InternetInfo.GetInstance.NetworkConnectState = UniversalHelper.GetInstance.GetNetworkState();
- NetworkConnectState = InternetInfo.GetInstance.NetworkConnectState;
- OrderCount = Json.GetInstance.Base.morkOrderPushes.Count;
+ InternetInfo.NetworkConnectState = UniversalHelper.GetInstance.GetNetworkState();
+ NetworkConnectState = InternetInfo.NetworkConnectState;
+ OrderCount = Json.Data.morkOrderPushes.Count;
Thread.Sleep(1000);
}), "界面状态监控");
}
diff --git a/HBLConsole/ViewModel/ProcessMonitoringViewModel.cs b/HBLConsole/ViewModel/ProcessMonitoringViewModel.cs
index aa33cf7..e5d74ed 100644
--- a/HBLConsole/ViewModel/ProcessMonitoringViewModel.cs
+++ b/HBLConsole/ViewModel/ProcessMonitoringViewModel.cs
@@ -1,4 +1,5 @@
-using HBLConsole.Business.Devices;
+using HBLConsole.Attributes;
+using HBLConsole.Business.Devices;
using HBLConsole.Model;
using HBLConsole.Service;
using System;
@@ -29,20 +30,20 @@ namespace HBLConsole.ViewModel
{
if (item.CustomAttributes.Count() > 0)
{
- string? propertyInfo = item.GetCustomAttribute()?.PropertyIllustrate;
- string[]? Classifiactions = item.GetCustomAttribute()?.Classifiaction;
+ string? propertyInfo = item.GetCustomAttribute()?.PropertyIllustrate;
+ string[]? Classifiactions = item.GetCustomAttribute()?.Classifiaction;
if (Classifiactions != null)
{
foreach (var itemClassifiactions in Classifiactions)
{
- if (GVL.ProcessData.GetInstance.Conditions.ContainsKey(itemClassifiactions))
+ if (ProcessData.GetInstance.Conditions.ContainsKey(itemClassifiactions))
{
if (propertyInfo != null)
{
- int index = Array.FindIndex(GVL.ProcessData.GetInstance.Conditions[itemClassifiactions].ToArray(), p => p.propertyIllustrate == propertyInfo);
+ int index = Array.FindIndex(ProcessData.GetInstance.Conditions[itemClassifiactions].ToArray(), p => p.propertyIllustrate == propertyInfo);
if (index >= 0)
{
- GVL.ProcessData.GetInstance.Conditions[itemClassifiactions].ElementAt(index).ToolTip = item.Name;
+ ProcessData.GetInstance.Conditions[itemClassifiactions].ElementAt(index).ToolTip = item.Name;
}
}
}
@@ -51,7 +52,7 @@ namespace HBLConsole.ViewModel
}
}
- var Conditions = GVL.ProcessData.GetInstance.Conditions;
+ var Conditions = ProcessData.GetInstance.Conditions;
if (Conditions != null)
{
foreach (var item in Conditions)
@@ -60,7 +61,7 @@ namespace HBLConsole.ViewModel
process.ProcessTitl = item.Key;
foreach (var values in item.Value)
{
- process.Conditions.Add(new Condition() { ConditionName = values.propertyIllustrate });
+ process.Conditions.Add(new Condition() { propertyIllustrate = values.propertyIllustrate });
}
processConditions.Add(process);
}
@@ -74,20 +75,20 @@ namespace HBLConsole.ViewModel
{
if (item.CustomAttributes.Count() > 0)
{
- string? propertyInfo = item.GetCustomAttribute()?.PropertyIllustrate;
- string[]? Classifiactions = item.GetCustomAttribute()?.Classifiaction;
+ string? propertyInfo = item.GetCustomAttribute()?.PropertyIllustrate;
+ string[]? Classifiactions = item.GetCustomAttribute()?.Classifiaction;
if (Classifiactions != null)
{
foreach (string? Titles in Classifiactions)
{
if (Titles != null && propertyInfo != null)
{
- bool? isNot = GVL.ProcessData.GetInstance.Conditions[Titles]?.FirstOrDefault(p => p.propertyIllustrate == propertyInfo)?.IsNot;
+ bool? isNot = ProcessData.GetInstance.Conditions[Titles]?.FirstOrDefault(p => p.propertyIllustrate == propertyInfo)?.IsNot;
int index = Array.FindIndex(processConditions.ToArray(), p => p.ProcessTitl == Titles);
if (index >= 0)
{
- int PropertyIndex = Array.FindIndex(processConditions.ElementAt(index).Conditions.ToArray(), p => p.ConditionName == propertyInfo);
+ int PropertyIndex = Array.FindIndex(processConditions.ElementAt(index).Conditions.ToArray(), p => p.propertyIllustrate == propertyInfo);
if (PropertyIndex >= 0)
{
var res = type.GetProperty(item.Name)?.GetValue(MORKS.GetInstance.mORKS, null);