From 64a1465de4b4223a5a419a71b01b87a62c8d0634 Mon Sep 17 00:00:00 2001 From: NXX <447201003@qq> Date: Tue, 8 Nov 2022 17:24:48 +0800 Subject: [PATCH] morkBF --- BPASmartClient.Business/Plugin/LocalMqtt.cs | 61 ++++++++ BPASmartClient.Model/FoodMenuModel.cs | 15 ++ BPASmartClient.MorkBF/Control_MorkBF.cs | 25 +--- BPASmartClient.MorkBF/GVL_MorkBF.cs | 133 ++++++++++-------- BPASmartClient.MorkBF/VIew/DebugView.xaml | 1 + BPASmartClient.ViewModel/FoodMenuViewModel.cs | 30 ++++ BPASmartClient/Control/FoodMenuView.xaml | 59 ++++++++ BPASmartClient/Control/FoodMenuView.xaml.cs | 26 ++++ BPASmartClient/MainWindow.xaml | 3 +- 9 files changed, 270 insertions(+), 83 deletions(-) create mode 100644 BPASmartClient.Business/Plugin/LocalMqtt.cs create mode 100644 BPASmartClient.Model/FoodMenuModel.cs create mode 100644 BPASmartClient.ViewModel/FoodMenuViewModel.cs create mode 100644 BPASmartClient/Control/FoodMenuView.xaml create mode 100644 BPASmartClient/Control/FoodMenuView.xaml.cs diff --git a/BPASmartClient.Business/Plugin/LocalMqtt.cs b/BPASmartClient.Business/Plugin/LocalMqtt.cs new file mode 100644 index 00000000..a59670ec --- /dev/null +++ b/BPASmartClient.Business/Plugin/LocalMqtt.cs @@ -0,0 +1,61 @@ +using BPASmartClient.MQTT; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Business.Plugin +{ + public class LocalMqtt : IPlugin + { + + //客户端ID + private int clientId; + //运行标识 + private bool running = false; + //MQTT 代理 + private MQTTProxy mqttProxy = new MQTTProxy(); + + public void Dispose() + { + + } + + public void Initialize() + { + + } + + public void Start() + { + running = true; + //主题初始化 + TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin().GetDevices()); + //MQTT 连接成功 + mqttProxy.Connected = new Action(() => + { + mqttProxy.Subscrib(); + }); + //MQTT 连接成功 + mqttProxy.LostConnect = new Action(() => + { + mqttProxy.Subscrib(); + }); + + + //MQTT 初始化 + mqttProxy.Connect(); + } + + /// + /// MQTT消息推送 + /// + /// 主题 + /// 消息体 + public void Publish(string topic, string message) + { + mqttProxy.Publish(topic, message); + } + } +} diff --git a/BPASmartClient.Model/FoodMenuModel.cs b/BPASmartClient.Model/FoodMenuModel.cs new file mode 100644 index 00000000..3c15e4dc --- /dev/null +++ b/BPASmartClient.Model/FoodMenuModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public class FoodMenuModel + { + public string GoodName { get; set; } + + public string GoodKey { get; set; } + } +} diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 0b775b40..92c2b468 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -129,37 +129,16 @@ namespace BPASmartClient.MorkBF public override void MainTask() { - if(morkBF.FirePan1_Order.Count == 0&&!morkBF.FirePan1_Busy) - { - ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1主进程"); - } - - if (morkBF.FirePan2_Order.Count == 0 && !morkBF.FirePan2_Busy) - { - ThreadManage.GetInstance().Start(FirePot2_Process, "炒锅2主进程"); - } } private void FirePot1_Process() { - morkBF.FirePan1_Busy = true; - morkBF.FirePan1_Date = DateTime.Now; - while (morkBF.FirePan1_Date.AddMinutes(1)> DateTime.Now) - { - Thread.Sleep(500); - } - ThreadManage.GetInstance().StopTask("炒锅1主进程"); + } private void FirePot2_Process() { - morkBF.FirePan2_Busy = true; - morkBF.FirePan2_Date = DateTime.Now; - while (morkBF.FirePan2_Date.AddMinutes(1) > DateTime.Now) - { - Thread.Sleep(500); - } - ThreadManage.GetInstance().StopTask("炒锅2主进程"); + } public override void ReadData() diff --git a/BPASmartClient.MorkBF/GVL_MorkBF.cs b/BPASmartClient.MorkBF/GVL_MorkBF.cs index b232e8f0..c802243c 100644 --- a/BPASmartClient.MorkBF/GVL_MorkBF.cs +++ b/BPASmartClient.MorkBF/GVL_MorkBF.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace BPASmartClient.MorkBF { - internal class GVL_MorkBF + internal class GVL_MorkBF : IStatus { /// /// 炒锅1订单队列 @@ -33,108 +33,108 @@ namespace BPASmartClient.MorkBF /// 炒锅1锅低温度 /// [VariableMonitor("炒锅1锅低温度", "VW120","160")] - public int FirePot1_Temperature; + public int FirePot1_Temperature { get; set; } /// /// 炒锅1脉冲值 /// [VariableMonitor("炒锅1脉冲值", "VW122", "161")] - public int FirePot1_Pulse; + public int FirePot1_Pulse { get; set; } /// /// 炒锅1初始化完成 /// [VariableMonitor("炒锅1初始化完成", "M20.0", "480")] - public bool FirePot1_InitCompleted = false; + public bool FirePot1_InitCompleted { get; set; } = false; /// /// 炒锅1手动自动模式 /// [VariableMonitor("炒锅1手动自动模式", "M20.1", "481")] - public bool FirePot1_IsAuto; + public bool FirePot1_IsAuto { get; set; } /// /// 炒锅1急停 /// [VariableMonitor("炒锅1急停", "M20.2", "482")] - public bool FirePot1_Emergencystop; + public bool FirePot1_Emergencystop{ get; set; } /// /// 1#炒锅荤菜盆有无检测 /// [VariableMonitor("1#炒锅1锅低温度", "M20.3", "483")] - public bool FirePot1_MealTubExist; + public bool FirePot1_MealTubExist{ get; set; } /// /// 1#炒锅素菜盆1有无检测 /// [VariableMonitor("炒锅素菜盆1有无检测", "M20.4", "484")] - public bool FirePot1_VegetablesTub1Exist; + public bool FirePot1_VegetablesTub1Exist{ get; set; } /// /// 1#炒锅素菜盆2有无检测 /// [VariableMonitor("1#炒锅素菜盆2有无检测", "M20.5", "485")] - public bool FirePot1_VegetablesTub2Exist; + public bool FirePot1_VegetablesTub2Exist{ get; set; } /// /// 1#炒锅调料盆1有无检测 /// [VariableMonitor("1#炒锅调料盆1有无检测", "M20.6", "486")] - public bool FirePot1_Seasoning1Exist; + public bool FirePot1_Seasoning1Exist{ get; set; } /// /// 1#炒锅调料盆2有无检测 /// [VariableMonitor("1#炒锅调料盆2有无检测", "M20.7", "487")] - public bool FirePot1_Seasoning2Exist; + public bool FirePot1_Seasoning2Exist{ get; set; } /// /// 1#炒锅辅料盆1有无检测 /// [VariableMonitor("1#炒锅辅料盆1有无检测", "M21.0", "488")] - public bool FirePot1_Accessories1Exist; + public bool FirePot1_Accessories1Exist{ get; set; } /// /// 1#炒锅辅料盆2有无检测 /// [VariableMonitor("1#炒锅辅料盆2有无检测", "M21.1", "489")] - public bool FirePot1_Accessories2Exist; + public bool FirePot1_Accessories2Exist{ get; set; } /// /// 1#炒锅出餐空盆有无检测 /// [VariableMonitor("1#炒锅出餐空盆有无检测", "M21.2", "490")] - public bool FirePot1_OutFoodTubExist; + public bool FirePot1_OutFoodTubExist{ get; set; } /// /// 1#炒锅在原点反馈 /// [VariableMonitor("1#炒锅在原点反馈", "M21.3", "491")] - public bool FirePot1_OnOrigin; + public bool FirePot1_OnOrigin{ get; set; } /// /// 1#炒制位置1反馈 /// [VariableMonitor("1#炒制位置1反馈", "M21.4", "492")] - public bool FirePot1_FirePosition1; + public bool FirePot1_FirePosition1{ get; set; } /// /// 1#炒制位置2反馈 /// [VariableMonitor("1#炒制位置2反馈", "M21.5", "493")] - public bool FirePot1_FirePosition2; + public bool FirePot1_FirePosition2{ get; set; } /// /// 1#炒制位置3反馈 /// [VariableMonitor("1#炒制位置3反馈", "M21.6", "494")] - public bool FirePot1_FirePosition3; + public bool FirePot1_FirePosition3{ get; set; } /// /// 1#炒制位置4反馈 /// [VariableMonitor("1#炒制位置4反馈", "M21.7", "495")] - public bool FirePot1_FirePosition4; + public bool FirePot1_FirePosition4{ get; set; } /// /// 1#炒锅在出餐倒料位置反馈 /// [VariableMonitor("1#炒锅在出餐倒料位置反馈", "M22.0", "496")] - public bool FirePot1_PotOnOutFoodPosition; + public bool FirePot1_PotOnOutFoodPosition{ get; set; } /// /// 1#炒锅在投料位置反馈、 /// [VariableMonitor("1#炒锅在投料位置反馈", "M22.1", "497")] - public bool FirePot1_PotOnIntoFoodPosition; + public bool FirePot1_PotOnIntoFoodPosition{ get; set; } /// /// 1#炒锅在洗锅位置反馈 /// [VariableMonitor("1#炒锅在洗锅位置反馈", "M22.2", "498")] - public bool FirePot1_PotOnCleanPosition; + public bool FirePot1_PotOnCleanPosition{ get; set; } #endregion #region 炒锅2读取数据 @@ -142,139 +142,146 @@ namespace BPASmartClient.MorkBF /// 炒锅2锅低温度 /// [VariableMonitor("炒锅2锅低温度", "VW150", "175")] - public int FirePot2_Temperature; + public int FirePot2_Temperature{ get; set; } /// /// 炒锅2脉冲值 /// [VariableMonitor("炒锅2脉冲值", "VW152", "176")] - public int FirePot2_Pulse; + public int FirePot2_Pulse{ get; set; } /// /// 炒锅2初始化完成 /// [VariableMonitor("炒锅2初始化完成", "M25.0", "520")] - public bool FirePot2_InitCompleted = false; + public bool FirePot2_InitCompleted { get; set; } = false; /// /// 炒锅2手动自动模式 /// [VariableMonitor("炒锅2手动自动模式", "M25.1", "521")] - public bool FirePot2_IsAuto; + public bool FirePot2_IsAuto{ get; set; } /// /// 炒锅2急停 /// [VariableMonitor("炒锅2急停", "M25.2", "522")] - public bool FirePot2_Emergencystop; + public bool FirePot2_Emergencystop{ get; set; } /// /// 2#炒锅荤菜盆有无检测 /// [VariableMonitor("2#炒锅荤菜盆有无检测", "M25.3", "523")] - public bool FirePot2_MealTubExist; + public bool FirePot2_MealTubExist{ get; set; } /// /// 2#炒锅素菜盆1有无检测 /// [VariableMonitor("2#炒锅素菜盆1有无检测", "M25.4", "524")] - public bool FirePot2_VegetablesTub1Exist; + public bool FirePot2_VegetablesTub1Exist{ get; set; } /// /// 2#炒锅素菜盆2有无检测 /// [VariableMonitor("2#炒锅素菜盆2有无检测", "M25.5", "525")] - public bool FirePot2_VegetablesTub2Exist; + public bool FirePot2_VegetablesTub2Exist{ get; set; } /// /// 2#炒锅调料盆1有无检测 /// [VariableMonitor("2#炒锅调料盆1有无检测", "M25.6", "526")] - public bool FirePot2_Seasoning1Exist; + public bool FirePot2_Seasoning1Exist{ get; set; } /// /// 2#炒锅调料盆2有无检测 /// [VariableMonitor("2#炒锅调料盆2有无检测", "M25.7", "527")] - public bool FirePot2_Seasoning2Exist; + public bool FirePot2_Seasoning2Exist{ get; set; } /// /// 2#炒锅辅料盆1有无检测 /// [VariableMonitor("2#炒锅1锅低温度", "M26.0", "528")] - public bool FirePot2_Accessories1Exist; + public bool FirePot2_Accessories1Exist{ get; set; } /// /// 2#炒锅辅料盆2有无检测 /// [VariableMonitor("2#炒锅辅料盆2有无检测", "M26.1", "529")] - public bool FirePot2_Accessories2Exist; + public bool FirePot2_Accessories2Exist{ get; set; } /// /// 2#炒锅出餐空盆有无检测 /// [VariableMonitor("2#炒锅出餐空盆有无检测", "M26.2", "530")] - public bool FirePot2_OutFoodTubExist; + public bool FirePot2_OutFoodTubExist{ get; set; } /// /// 2#炒锅在原点反馈 /// [VariableMonitor("2#炒锅在原点反馈", "M26.3", "531")] - public bool FirePot2_OnOrigin; + public bool FirePot2_OnOrigin{ get; set; } /// /// 2#炒制位置1反馈 /// [VariableMonitor("2#炒制位置1反馈", "M26.4", "532")] - public bool FirePot2_FirePosition1; + public bool FirePot2_FirePosition1{ get; set; } /// /// 2#炒制位置2反馈 /// [VariableMonitor("2#炒制位置2反馈", "M26.5", "533")] - public bool FirePot2_FirePosition2; + public bool FirePot2_FirePosition2{ get; set; } /// /// 2#炒制位置3反馈 /// [VariableMonitor("2#炒制位置3反馈", "M26.6", "534")] - public bool FirePot2_FirePosition3; + public bool FirePot2_FirePosition3{ get; set; } /// /// 2#炒制位置4反馈 /// [VariableMonitor("2#炒制位置4反馈", "M26.7", "535")] - public bool FirePot2_FirePosition4; + public bool FirePot2_FirePosition4{ get; set; } /// /// 2#炒锅在出餐倒料位置反馈 /// [VariableMonitor("2#炒锅在出餐倒料位置反馈", "M27.0", "536")] - public bool FirePot2_PotOnOutFoodPosition; + public bool FirePot2_PotOnOutFoodPosition{ get; set; } /// /// 2#炒锅在投料位置反馈、 /// [VariableMonitor("2#炒锅在投料位置反馈", "M27.1", "537")] - public bool FirePot2_PotOnIntoFoodPosition; + public bool FirePot2_PotOnIntoFoodPosition{ get; set; } /// /// 2#炒锅在洗锅位置反馈 /// [VariableMonitor("2#炒锅在洗锅位置反馈", "M27.2", "538")] - public bool FirePot2_PotOnCleanPosition; + public bool FirePot2_PotOnCleanPosition{ get; set; } #endregion #region 机器人数据读取 /// /// 1号锅倒荤菜完成 /// - public bool Robot_FirePot1OutMeal; + [VariableMonitor("1号锅倒荤菜完成", "GM500", "4596")] + public bool Robot_FirePot1OutMeal{ get; set; } /// /// 1号炒锅倒素菜1完成 /// - public bool Robot_FirePot1OutVegetables1; + [VariableMonitor("1号炒锅倒素菜1完成", "GM501", "4597")] + public bool Robot_FirePot1OutVegetables1{ get; set; } /// /// 1号炒锅倒素菜2完成 /// - public bool Robot_FirePot1OutVegetables2; + [VariableMonitor("1号炒锅倒素菜2完成", "GM502", "4598")] + public bool Robot_FirePot1OutVegetables2{ get; set; } /// /// 1号炒锅倒调料完成 /// - public bool Robot_FirePot1OutSeasoning; + [VariableMonitor("1号炒锅倒调料完成", "GM503", "4599")] + public bool Robot_FirePot1OutSeasoning{ get; set; } /// /// 1号炒锅倒辅料完成 /// - public bool Robot_FirePot1OutAccessories; + [VariableMonitor("1号炒锅倒辅料完成", "GM504", "4600")] + public bool Robot_FirePot1OutAccessories{ get; set; } /// /// 机器人到位,请求1#炒锅倒菜 /// - public bool Robot_ArriveFirePot1; + [VariableMonitor("机器人到位,请求1#炒锅倒菜", "GM505", "4601")] + public bool Robot_ArriveFirePot1{ get; set; } /// /// 1号炒锅出餐完成 /// - public bool Robot_FirePot1OutFoodComplete; + [VariableMonitor("1号炒锅出餐完成", "GM506", "4602")] + public bool Robot_FirePot1OutFoodComplete{ get; set; } @@ -283,35 +290,43 @@ namespace BPASmartClient.MorkBF /// /// 2号锅倒荤菜完成 /// - public bool Robot_FirePot2OutMeal; + [VariableMonitor("2号锅倒荤菜完成", "GM510", "4606")] + public bool Robot_FirePot2OutMeal { get; set; } /// /// 2号炒锅倒素菜1完成 /// - public bool Robot_FirePot2OutVegetables1; + [VariableMonitor("2号炒锅倒素菜1完成", "GM511", "4607")] + public bool Robot_FirePot2OutVegetables1{ get; set; } /// /// 2号炒锅倒素菜2完成 /// - public bool Robot_FirePot2OutVegetables2; + [VariableMonitor("2号炒锅倒素菜2完成", "GM512", "4608")] + public bool Robot_FirePot2OutVegetables2{ get; set; } /// /// 2号炒锅倒调料完成 /// - public bool Robot_FirePot2OutSeasoning; + [VariableMonitor("2号炒锅倒调料完成", "GM513", "4609")] + public bool Robot_FirePot2OutSeasoning{ get; set; } /// /// 2号炒锅倒辅料完成 - /// - public bool Robot_FirePot2OutAccessories; + /// + [VariableMonitor("2号炒锅倒辅料完成", "GM514", "4610")] + public bool Robot_FirePot2OutAccessories{ get; set; } /// /// 机器人到位,请求1#炒锅倒菜 /// - public bool Robot_ArriveFirePot2; + [VariableMonitor("机器人到位,请求1#炒锅倒菜", "GM515", "4611")] + public bool Robot_ArriveFirePot2{ get; set; } /// /// 2号炒锅出餐完成 /// - public bool Robot_FirePot2OutFoodComplete; + [VariableMonitor("2号炒锅出餐完成", "GM516", "4612")] + public bool Robot_FirePot2OutFoodComplete{ get; set; } /// /// 机器人动作反馈 /// - public int Robot_ActionCallback; + [VariableMonitor("机器人动作反馈", "GI5", "5")] + public int Robot_ActionCallback{ get; set; } #endregion diff --git a/BPASmartClient.MorkBF/VIew/DebugView.xaml b/BPASmartClient.MorkBF/VIew/DebugView.xaml index 09a396e5..7928442d 100644 --- a/BPASmartClient.MorkBF/VIew/DebugView.xaml +++ b/BPASmartClient.MorkBF/VIew/DebugView.xaml @@ -6,6 +6,7 @@ xmlns:local="clr-namespace:BPASmartClient.MorkBF.VIew" xmlns:vm="clr-namespace:BPASmartClient.MorkBF.ViewModel" mc:Ignorable="d" + Name="调试界面" d:DesignHeight="900" d:DesignWidth="1600"> diff --git a/BPASmartClient.ViewModel/FoodMenuViewModel.cs b/BPASmartClient.ViewModel/FoodMenuViewModel.cs new file mode 100644 index 00000000..255cd3d5 --- /dev/null +++ b/BPASmartClient.ViewModel/FoodMenuViewModel.cs @@ -0,0 +1,30 @@ +using BPASmartClient.Helper; +using BPASmartClient.Model; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.ViewModel +{ + public class FoodMenuViewModel: ObservableObject + { + public ObservableCollection FoodMenus { get; set; } = new ObservableCollection(); + + public RelayCommand StartOrder { get; set; } + + public FoodMenuViewModel() + { + FoodMenus.Add(new FoodMenuModel { GoodKey = "1111", GoodName = "小炒肉" }); + FoodMenus.Add(new FoodMenuModel { GoodKey = "222", GoodName = "大炒肉大炒肉大炒肉" }); + StartOrder = new RelayCommand((o) => + { + ActionManage.GetInstance.Send("开始下单", o); + }); + } + } +} diff --git a/BPASmartClient/Control/FoodMenuView.xaml b/BPASmartClient/Control/FoodMenuView.xaml new file mode 100644 index 00000000..7e2efe5b --- /dev/null +++ b/BPASmartClient/Control/FoodMenuView.xaml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +