From 921c32d139a6497b36664826b337f78656f011c2 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, 11 Mar 2022 18:02:34 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E4=BB=A3=E6=9C=BA=E6=A1=86=E6=9E=B6?=
=?UTF-8?q?=E6=90=AD=E5=BB=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
HBLConsole.Business/Devices/MORKS.cs | 107 ++--
HBLConsole.Business/MessageServer/Base.cs | 21 +
HBLConsole.GVL/CircuitAttribute.cs | 2 -
HBLConsole.GVL/MORKS.cs | 1 +
HBLConsole.Interface/IDeviceType.cs | 13 +
.../CommunicationPar/CommunicationPar.cs | 16 +
.../CommunicationPar/CommunicationSet.cs | 58 +++
.../CommunicationPar/ModbusRtu.cs | 50 ++
.../CommunicationPar/ModbusTcp.cs | 19 +
HBLConsole.Model/CommunicationPar/Siemens.cs | 45 ++
HBLConsole.Model/DeviceManagermentResult.cs | 14 +
HBLConsole.Model/Enums/DisplayFormat.cs | 15 +
HBLConsole.Model/Enums/EAlarmType.cs | 29 ++
HBLConsole.Model/Enums/EAlongTriggerType.cs | 24 +
HBLConsole.Model/Enums/EAnalogAlarmType.cs | 19 +
HBLConsole.Model/Enums/EDataType.cs | 22 +
HBLConsole.Model/Enums/EDeviceType.cs | 16 +
HBLConsole.Model/Enums/EOperatorType.cs | 39 ++
HBLConsole.Model/Enums/EParity.cs | 15 +
HBLConsole.Model/Enums/ESiemensPlcType.cs | 16 +
HBLConsole.Model/HBLConsole.Model.csproj | 5 +
HBLConsole.Model/SerialDeviceBase.cs | 41 ++
HBLConsole.Model/SimOrderData.cs | 3 +-
HBLConsole.Model/TcpDeviceBase.cs | 21 +
HBLConsole.Model/UniversalBase.cs | 17 +
HBLConsole.PryUserControl/BeveledButton.xaml | 34 --
HBLConsole.PryUserControl/Quadrilateral.xaml | 20 +
.../Quadrilateral.xaml.cs | 96 ++++
HBLConsole.PryUserControl/TitleTextBlock.xaml | 27 +
.../TitleTextBlock.xaml.cs | 38 ++
HBLConsole.Service/ActionManagerment.cs | 13 +-
HBLConsole.Service/Json.cs | 12 +
HBLConsole/App.config | 2 +-
HBLConsole/Converter/VisibleConvert.cs | 32 ++
.../View/DeviceManagermentSetView.xaml | 196 +++++++
.../View/DeviceManagermentSetView.xaml.cs | 84 +++
.../DeviceManagermentSetViewModel.cs | 68 +++
HBLConsole/HBLConsole.csproj | 6 -
HBLConsole/Resources/Fonts/iconfont.ttf | Bin 2432 -> 5348 bytes
.../ResourceDictionarys/BasicStyle.xaml | 465 ++++++++++++++++-
HBLConsole/View/DebugView.xaml | 40 +-
HBLConsole/View/DeviceManageView.xaml | 489 ++++++++++++++++++
HBLConsole/View/DeviceManageView.xaml.cs | 28 +
HBLConsole/View/MainView.xaml | 14 +-
HBLConsole/View/ProcessMonitoringView.xaml | 12 +
HBLConsole/View/ProcessMonitoringView.xaml.cs | 28 +
HBLConsole/ViewModel/DebugViewModel.cs | 24 +-
HBLConsole/ViewModel/DeviceManageViewModel.cs | 132 +++++
.../ViewModel/ProcessMonitoringViewModel.cs | 123 +++++
49 files changed, 2470 insertions(+), 141 deletions(-)
create mode 100644 HBLConsole.Interface/IDeviceType.cs
create mode 100644 HBLConsole.Model/CommunicationPar/CommunicationPar.cs
create mode 100644 HBLConsole.Model/CommunicationPar/CommunicationSet.cs
create mode 100644 HBLConsole.Model/CommunicationPar/ModbusRtu.cs
create mode 100644 HBLConsole.Model/CommunicationPar/ModbusTcp.cs
create mode 100644 HBLConsole.Model/CommunicationPar/Siemens.cs
create mode 100644 HBLConsole.Model/DeviceManagermentResult.cs
create mode 100644 HBLConsole.Model/Enums/DisplayFormat.cs
create mode 100644 HBLConsole.Model/Enums/EAlarmType.cs
create mode 100644 HBLConsole.Model/Enums/EAlongTriggerType.cs
create mode 100644 HBLConsole.Model/Enums/EAnalogAlarmType.cs
create mode 100644 HBLConsole.Model/Enums/EDataType.cs
create mode 100644 HBLConsole.Model/Enums/EDeviceType.cs
create mode 100644 HBLConsole.Model/Enums/EOperatorType.cs
create mode 100644 HBLConsole.Model/Enums/EParity.cs
create mode 100644 HBLConsole.Model/Enums/ESiemensPlcType.cs
create mode 100644 HBLConsole.Model/SerialDeviceBase.cs
create mode 100644 HBLConsole.Model/TcpDeviceBase.cs
create mode 100644 HBLConsole.Model/UniversalBase.cs
create mode 100644 HBLConsole.PryUserControl/Quadrilateral.xaml
create mode 100644 HBLConsole.PryUserControl/Quadrilateral.xaml.cs
create mode 100644 HBLConsole.PryUserControl/TitleTextBlock.xaml
create mode 100644 HBLConsole.PryUserControl/TitleTextBlock.xaml.cs
create mode 100644 HBLConsole/Converter/VisibleConvert.cs
create mode 100644 HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml
create mode 100644 HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml.cs
create mode 100644 HBLConsole/DialogWindow/ViewModel/DeviceManagermentSetViewModel.cs
create mode 100644 HBLConsole/View/DeviceManageView.xaml
create mode 100644 HBLConsole/View/DeviceManageView.xaml.cs
create mode 100644 HBLConsole/View/ProcessMonitoringView.xaml
create mode 100644 HBLConsole/View/ProcessMonitoringView.xaml.cs
create mode 100644 HBLConsole/ViewModel/DeviceManageViewModel.cs
create mode 100644 HBLConsole/ViewModel/ProcessMonitoringViewModel.cs
diff --git a/HBLConsole.Business/Devices/MORKS.cs b/HBLConsole.Business/Devices/MORKS.cs
index b45a1dd..469e27d 100644
--- a/HBLConsole.Business/Devices/MORKS.cs
+++ b/HBLConsole.Business/Devices/MORKS.cs
@@ -24,25 +24,6 @@ namespace HBLConsole.Business.Devices
public GVL.MORKS mORKS { get; set; } = new GVL.MORKS();
- ///
- /// 写入配方数据到 PLC
- ///
- private void WriteRecipeBoms()
- {
- List recipeBoms = new List();
- foreach (var item in Json.GetInstance.Base.recipeBoms.RecipeIds)
- {
- foreach (var rec in item.Recipes)
- {
- recipeBoms.Add((ushort)rec);
- }
- }
- if (ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray()))
- {
- MessageLog.GetInstance.Show("成功写入配方数据");
- }
- }
-
public void Init()
{
//Modbus TCP连接成功
@@ -60,9 +41,7 @@ namespace HBLConsole.Business.Devices
//Modbus Tcp 连接
//ModbusTcpHelper.GetInstance.ModbusTcpConnect("192.168.1.11", 508);
- // ModbusTcpHelper.GetInstance.ModbusTcpConnect("127.0.0.1");
- // Action action;
- //action.inv
+ ModbusTcpHelper.GetInstance.ModbusTcpConnect("127.0.0.1");
//模拟订单
SimOrder();
@@ -73,6 +52,9 @@ namespace HBLConsole.Business.Devices
List batchingInfos = new List();
+ ///
+ /// 心跳状态
+ ///
private void Heartbeat()
{
HeartbeatReport.GetInstance.GetMessage = new Action(() =>
@@ -225,24 +207,21 @@ namespace HBLConsole.Business.Devices
if (o is SimOrderData simOrderData)
{
string subId = Guid.NewGuid().ToString();
- if (simOrderData.IsEnableRandom)
- {
+ if (simOrderData.NoodleIsEnableRandom)
NoodleLoc = (ushort)(new Random().Next(1, 6));
- BowlLoc = (ushort)(new Random().Next(10, 12));
- }
else
- {
NoodleLoc = (ushort)simOrderData.NoodleLoc;
- BowlLoc = (ushort)simOrderData.BowlLoc;
- }
+
+ if (simOrderData.BowlIsEnableRandom)
+ BowlLoc = (ushort)(new Random().Next(10, 12));
+ else
+ BowlLoc = (ushort)simOrderData.BowlLoc;
mORKS.RBTakeNoodleTask.Enqueue(new GVL.OrderLocInfo() { Loc = NoodleLoc, SuborderId = subId });
mORKS.TakeBowlTask.Enqueue(new GVL.OrderLocInfo() { Loc = BowlLoc, SuborderId = subId });
MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】,碗位置【{BowlLoc}】");
}
}
-
-
}), "SimOrder");
}
@@ -311,12 +290,10 @@ namespace HBLConsole.Business.Devices
{
mORKS.AllowRun = mORKS.InitComplete && !mORKS.TemperatureReached;
- if (mORKS.AllowRun)
- {
- TakeBowlTask();
+ TakeBowlTask();
+
+ TakeNoodleTask();
- TakeNoodleTask();
- }
OutNoodleTask();
SingleDetect();
@@ -333,7 +310,7 @@ namespace HBLConsole.Business.Devices
///
private void TakeBowlTask()
{
- if (mORKS.TakeBowlTask.Count > 0 && !mORKS.TakeBowlIdle && !mORKS.TakeBowlInterlock)
+ if (mORKS.AllowRun && mORKS.TakeBowlTask.Count > 0 && !mORKS.TakeBowlIdle && !mORKS.TakeBowlInterlock)
{
if (mORKS.TakeBowlTask.TryDequeue(out GVL.OrderLocInfo orderLocInfo))
{
@@ -398,25 +375,30 @@ namespace HBLConsole.Business.Devices
private void TakeNoodleTask()
{
//取面控制
- if (mORKS.RobotIdle && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0)
+ if (mORKS.AllowRun && mORKS.RobotIdle && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0)
{
- if (mORKS.RBTakeNoodleTask.TryDequeue(out GVL.OrderLocInfo orderLocInfo))
+ int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置
+ if (loc >= 0 && loc <= 5)
{
- //设置转台位置
- SetTurntableLoc(orderLocInfo.Loc);
- //设置倒面位置
- int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置
- if (loc >= 0 && loc <= 5)
+ if (mORKS.RBTakeNoodleTask.TryDequeue(out GVL.OrderLocInfo orderLocInfo))
{
+ //设置转台位置
+ SetTurntableLoc(orderLocInfo.Loc);
+ //设置倒面位置
+
+ //if (loc >= 0 && loc <= 5)
+ //{
CookNodelId[loc] = orderLocInfo.SuborderId;
SetFallNoodleLoc((ushort)(loc + 1));
+ //}
+ //机器人开始取面
+ RobotTakeNoodle();
+ SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING);
+ MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,转台:[{orderLocInfo}],煮面栏:[{loc + 1}]");
+ mORKS.TakeNoodleInterlock = true;
}
- //机器人开始取面
- RobotTakeNoodle();
- SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING);
- MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,转台:[{orderLocInfo}],煮面栏:[{loc + 1}]");
- mORKS.TakeNoodleInterlock = true;
}
+
}
}
@@ -500,11 +482,33 @@ namespace HBLConsole.Business.Devices
int OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count;
int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count;
mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0);
-
}
#region PLC 控制函数
+
+ ///
+ /// 写入配方数据到 PLC
+ ///
+ private void WriteRecipeBoms()
+ {
+ List recipeBoms = new List();
+ foreach (var item in Json.GetInstance.Base.recipeBoms.RecipeIds)
+ {
+ foreach (var rec in item.Recipes)
+ {
+ recipeBoms.Add((ushort)rec);
+ }
+ }
+ if (recipeBoms.Count > 0)
+ {
+ if (ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray()))
+ {
+ MessageLog.GetInstance.Show("成功写入配方数据");
+ }
+ }
+ }
+
///
/// 转台移动
///
@@ -531,8 +535,9 @@ namespace HBLConsole.Business.Devices
{
ushort addRess = (ushort)(1136 + num - 1);
ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false);
+ MessageLog.GetInstance.Show($"{num}号煮面口占用复位");
}
- MessageLog.GetInstance.Show($"{num}号煮面口占用复位");
+
}
///
diff --git a/HBLConsole.Business/MessageServer/Base.cs b/HBLConsole.Business/MessageServer/Base.cs
index 6530b54..805d101 100644
--- a/HBLConsole.Business/MessageServer/Base.cs
+++ b/HBLConsole.Business/MessageServer/Base.cs
@@ -32,15 +32,25 @@ namespace HBLConsole.Business.MessageServer
}
}
+ ///
+ /// 接收来自MQTT 推送的物料信息
+ ///
+ ///
+ ///
public override void GetBatchingInfo(T batchingInfo)
{
if (batchingInfo == null) return;
if (batchingInfo is OrderMaterialDelivery BatchingInfos)
{
Json.GetInstance.Base.orderMaterialDelivery = BatchingInfos;
+ MessageLog.GetInstance.Show("收到推送的物料信息");
}
}
+ ///
+ /// 通过接口获取物料信息
+ ///
+ ///
public override void GetBatchingInfo(int ClientId)
{
string result = string.Empty;
@@ -64,6 +74,11 @@ namespace HBLConsole.Business.MessageServer
});
}
+ ///
+ /// 接收MQTT 推送过来的辅料信息
+ ///
+ ///
+ ///
public override void GetRecipeBom(T recipeBomInfo)
{
if (recipeBomInfo == null) return;
@@ -74,6 +89,12 @@ namespace HBLConsole.Business.MessageServer
MessageLog.GetInstance.Show("接收到辅料信息");
}
+ ///
+ /// 订单状态改变
+ ///
+ ///
+ ///
+ ///
public override bool OrderStatusChange(string subOrderId, ORDER_STATUS status)
{
string result = string.Empty;
diff --git a/HBLConsole.GVL/CircuitAttribute.cs b/HBLConsole.GVL/CircuitAttribute.cs
index 284c6e2..7f5456d 100644
--- a/HBLConsole.GVL/CircuitAttribute.cs
+++ b/HBLConsole.GVL/CircuitAttribute.cs
@@ -55,8 +55,6 @@ namespace HBLConsole.GVL
{
ProcessData.GetInstance.Conditions[item].Add(new Condition() { propertyIllustrate = propertyIllustrate });
}
-
-
}
}
diff --git a/HBLConsole.GVL/MORKS.cs b/HBLConsole.GVL/MORKS.cs
index 6d269be..dea3d6a 100644
--- a/HBLConsole.GVL/MORKS.cs
+++ b/HBLConsole.GVL/MORKS.cs
@@ -39,6 +39,7 @@ namespace HBLConsole.GVL
///
/// 允许运行
///
+ [Circuit(new string[] { "机器人取面", "取碗控制" }, "允许运行")]
public bool AllowRun { get; set; }
///
diff --git a/HBLConsole.Interface/IDeviceType.cs b/HBLConsole.Interface/IDeviceType.cs
new file mode 100644
index 0000000..992a368
--- /dev/null
+++ b/HBLConsole.Interface/IDeviceType.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HBLConsole.Interface
+{
+ public interface IDeviceType
+ {
+ //void Init();
+ }
+}
diff --git a/HBLConsole.Model/CommunicationPar/CommunicationPar.cs b/HBLConsole.Model/CommunicationPar/CommunicationPar.cs
new file mode 100644
index 0000000..b2663d8
--- /dev/null
+++ b/HBLConsole.Model/CommunicationPar/CommunicationPar.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HBLConsole.Model
+{
+ ///
+ /// 通讯参数
+ ///
+ public class CommunicationPar
+ {
+ public List communicationSets = new List();
+ }
+}
diff --git a/HBLConsole.Model/CommunicationPar/CommunicationSet.cs b/HBLConsole.Model/CommunicationPar/CommunicationSet.cs
new file mode 100644
index 0000000..1b5d105
--- /dev/null
+++ b/HBLConsole.Model/CommunicationPar/CommunicationSet.cs
@@ -0,0 +1,58 @@
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using Microsoft.Toolkit.Mvvm.Input;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HBLConsole.Interface;
+
+
+namespace HBLConsole.Model
+{
+ public class CommunicationSet : ObservableObject
+ {
+ public CommunicationSet()
+ {
+ RemoveCommand = new RelayCommand