From edef6d6bedf137ee4270fe360fd865f1bb4178c0 Mon Sep 17 00:00:00 2001 From: NXX <447201003@qq> Date: Thu, 12 Jan 2023 11:26:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=82=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.Model/GlobalFoodMenu.cs | 14 -- .../小炒机/MaterialAndFryingTime.cs | 15 +++ .../BPASmartClient.MorkBF.csproj | 1 + BPASmartClient.MorkBF/Control_MorkBF.cs | 25 ++-- .../BPASmartClient.MorkF.csproj | 1 + BPASmartClient.MorkF/Control_MorkF.cs | 123 +++++++++--------- BPASmartClient.MorkF/View/DebugView.xaml | 12 +- BPASmartClient.MorkF/View/LocalMenu.xaml | 22 ++-- BPASmartClient.MorkF/View/LocalMenu.xaml.cs | 2 +- .../ViewModel/DebugViewModel.cs | 3 +- .../ViewModel/LocalMenuViewModel.cs | 77 ++++++----- BPASmartClient.ViewModel/FoodMenuViewModel.cs | 11 +- BPASmartClient/Control/FoodMenuView.xaml | 10 +- BPASmartClient/Control/FoodMenuView.xaml.cs | 4 +- 14 files changed, 174 insertions(+), 146 deletions(-) delete mode 100644 BPASmartClient.Model/GlobalFoodMenu.cs create mode 100644 BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs diff --git a/BPASmartClient.Model/GlobalFoodMenu.cs b/BPASmartClient.Model/GlobalFoodMenu.cs deleted file mode 100644 index 73bdd544..00000000 --- a/BPASmartClient.Model/GlobalFoodMenu.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.Model -{ - public class GlobalFoodMenu - { - public static ObservableCollection LocalFoodMenus = new ObservableCollection(); - } -} diff --git a/BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs b/BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs new file mode 100644 index 00000000..dba43182 --- /dev/null +++ b/BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs @@ -0,0 +1,15 @@ +using BPA.Models; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.小炒机 +{ + public class MaterialAndFryingTime + { + public Dictionary> materials { get; set; } = new Dictionary>(); + } +} diff --git a/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj b/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj index 14337820..163b8885 100644 --- a/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj +++ b/BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj @@ -13,6 +13,7 @@ + diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 3f586713..0bd4ab2f 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -9,6 +9,7 @@ using BPASmartClient.Model; using BPASmartClient.Model.大炒; using BPASmartClient.MorkBF.Model; using BPASmartClient.MorkBF.ViewModel; +using BPASmartClient.ViewModel; using System; using System.Collections.Generic; using System.Linq; @@ -34,18 +35,18 @@ namespace BPASmartClient.MorkBF IsHealth = true; BPASmartClient.Helper.Json.Read(); MonitorViewModel.DeviceId = DeviceId; - ActionManage.GetInstance.Register(new Action(() => - { - GlobalFoodMenu.LocalFoodMenus.Clear(); - if(BPASmartClient.Helper.Json.Data.FryPotMessage.Count>0) - { - foreach (var item in BPASmartClient.Helper.Json.Data.FryPotMessage) - { - GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName }); - } - } + //ActionManage.GetInstance.Register(new Action(() => + //{ + // FoodMenuViewModel.GetInstance().FoodMenus.Clear(); + // if(BPASmartClient.Helper.Json.Data.FryPotMessage.Count>0) + // { + // foreach (var item in BPASmartClient.Helper.Json.Data.FryPotMessage) + // { + // FoodMenuViewModel.GetInstance().FoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName }); + // } + // } - }), "更新菜单"); + //}), "更新菜单"); CommandRegist();//调试 ServerInit(); DataParse();//数据解析 @@ -927,7 +928,7 @@ namespace BPASmartClient.MorkBF WorkStatus_1 = morkBF.FirePot1_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, WorkStatus_2 = morkBF.FirePot2_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, RobotStatu = WorkStatus.工作, - Alarm = new List(), + Alarm = new List(), FailuresCount = 0, StatsCount = statsModels, MaxWok_Dishes_1 = "满汉全席", diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj index e7ac07e7..5b3cc3dc 100644 --- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj +++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj @@ -18,6 +18,7 @@ + diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index cf742f12..0d1ee202 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -16,6 +16,8 @@ using System.Windows.Documents; using BPASmartClient.Business; using Microsoft.CodeAnalysis; using BPASmartClient.MorkF.ViewModel; +using BPASmartClient.ViewModel; +using System.Windows; namespace BPASmartClient.MorkF { @@ -50,13 +52,13 @@ namespace BPASmartClient.MorkF /// /// 菜品盒下移高度,相对于坐标系 /// - private const int materialBoxHigh = 4080; + //private const int materialBoxHigh = 4080; - //菜品库出餐高度 - private const int materialHigh = 33000; + ////菜品库出餐高度 + //private const int materialHigh = 33000; - //传感器到菜品库的高度(坐标系) - private const int materialLaserHigh = 34500; + ////传感器到菜品库的高度(坐标系) + //private const int materialLaserHigh = 34500; /// /// 菜品盒坐标系高度 @@ -64,26 +66,26 @@ namespace BPASmartClient.MorkF private const int materialBoxHeight = 9700; //传感器1到菜品库的高度(厘米) - private const int materialLaserHighCM_1 = 22; + //private const int materialLaserHighCM_1 = 22; - //传感器2到菜品库的高度(厘米) - private const int materialLaserHighCM_2 = 27; + ////传感器2到菜品库的高度(厘米) + //private const int materialLaserHighCM_2 = 27; - //传感器3到菜品库的高度(厘米) - private const int materialLaserHighCM_3 = 31; + ////传感器3到菜品库的高度(厘米) + //private const int materialLaserHighCM_3 = 31; /// /// 传感器到隔板的距离(坐标系) /// private const int clapboardLaserHigh = 10000; - //炒锅1倒菜的xy坐标 - private const int materialPutPositionXFry1 = 70000; - private const int materialPutPositionYFry1 = 40000; + ////炒锅1倒菜的xy坐标 + //private const int materialPutPositionXFry1 = 70000; + //private const int materialPutPositionYFry1 = 40000; - //炒锅2倒菜的xy坐标 - private const int materialPutPositionXFry2 = 70000; - private const int materialPutPositionYFry2 = 40000; + ////炒锅2倒菜的xy坐标 + //private const int materialPutPositionXFry2 = 70000; + //private const int materialPutPositionYFry2 = 40000; //菜品库机械爪放置菜品距离 private const int materialToFryDistance = 10000; @@ -146,7 +148,7 @@ namespace BPASmartClient.MorkF /// /// 告警列表 /// - private List alarmModel = new List(); + private List alarmModel = new List(); /// /// @@ -201,7 +203,7 @@ namespace BPASmartClient.MorkF MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2; MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight; MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX; - MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX; + MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX; MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX; } ////菜品库编号与坐标系对象存储 @@ -404,7 +406,6 @@ namespace BPASmartClient.MorkF ActionManage.GetInstance.Register(PLCInite, "InitCommand"); ActionManage.GetInstance.Register(StartOrder, "StartOrder"); ActionManage.GetInstance.Register(StartOrderMain, "开始下单"); - ActionManage.GetInstance.Register(StartLocalOrder, "StartLocalOrder"); ActionManage.GetInstance.Register(StopLocalOrder, "StopLocalOrder"); ActionManage.GetInstance.Register(new Action((o) => { @@ -725,7 +726,7 @@ namespace BPASmartClient.MorkF } /// - /// 本地菜单下单 + /// 根据菜品ID下单 /// private void StartOrder(object o) { @@ -749,44 +750,42 @@ namespace BPASmartClient.MorkF } /// - /// 本地菜单下单 + /// 主界面本地菜单下单 /// private void StartOrderMain(object o) { if (o == null) return; - if (o is string goodId) + if (o is FoodMenuModel good) { - var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey.ToString() == goodId);//匹配订单对应制作流程 - if (res != null) - { - /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程 - if (StirFryGoodsQuenes.Count > 0) return; - StirFryGoodsQuenes.Enqueue(new OrderLocInfo() - { - SuborderId = Guid.NewGuid().ToString(), - StirPotActions = res.StirPotActions, - GoodName = "本地菜品" - }); - MessageLog.GetInstance.Show($"添加本地订单{res.GoodsKey}"); - } + NewStartLocalOrder(good.GoodName); } - } - private void StartLocalOrder() - { - if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 - if (Json.Data.LocalstirFryGoods.StirPotActions.Count > 0) - { - StirFryGoodsQuenes.Enqueue(new OrderLocInfo() - { - SuborderId = Guid.NewGuid().ToString(), - StirPotActions = Json.Data.LocalstirFryGoods.StirPotActions, - GoodName = "本地菜品" - }); - MessageLog.GetInstance.Show($"添加本地模拟的订单{Json.Data.LocalstirFryGoods.GoodsKey}"); - } + + //if (o == null) return; + //if (o is string goodId) + //{ + // var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey.ToString() == goodId);//匹配订单对应制作流程 + // if (res != null) + // { + // /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程 + // if (StirFryGoodsQuenes.Count > 0) return; + // StirFryGoodsQuenes.Enqueue(new OrderLocInfo() + // { + // SuborderId = Guid.NewGuid().ToString(), + // StirPotActions = res.StirPotActions, + // GoodName = "本地菜品" + // }); + // MessageLog.GetInstance.Show($"添加本地订单{res.GoodsKey}"); + // } + //} } + + + /// + /// 本地配置的订单 + /// + /// private void NewStartLocalOrder(string materialName) { //if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 @@ -821,6 +820,7 @@ namespace BPASmartClient.MorkF GoodName = materialName }); MessageLog.GetInstance.Show($"添加本地模拟的订单{Json.Data.LocalstirFryGoods.GoodsKey}"); + MessageBox.Show("下单成功"); } } @@ -1525,7 +1525,7 @@ namespace BPASmartClient.MorkF return false; } - WriteSpeed(50000); + WriteSpeed(50000);//移动速度 //ThreadManage.GetInstance().Start(new Action(() => //{ // //收缩爪子 @@ -2292,11 +2292,7 @@ namespace BPASmartClient.MorkF GoodsKey = item.GoodsKey, StirPotActions = OrderSort(item.StirPotActions), }); - GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel - { - GoodKey = item.GoodsKey.ToString(), - GoodName = "", - }); + } } @@ -2433,9 +2429,9 @@ namespace BPASmartClient.MorkF /// /// /// - private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) + private void OrderChange(string Id , string goodName, ORDER_STATUS oRDER_STATUS,int deviceId) { - EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid }); + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, GoodName = goodName,DeviceId = deviceId, SubOrderId =Id }); } /// @@ -2563,13 +2559,14 @@ namespace BPASmartClient.MorkF if (morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete && ml_morkf.InitialComplete && !morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&菜品库初始化&&是否在炒菜中 { - Thread.Sleep(5000); + Thread.Sleep(4000); lock(lock_MainProcessExcute) { //待炒小炒队列出队列 if (StirFryGoodsQuenes.TryDequeue(out var res)) { + OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.WAIT, DeviceId = i); //设置当前炒制菜品 nowStirFryGood[i] = res; //炒锅工作状态置为正在工作中 @@ -2595,7 +2592,7 @@ namespace BPASmartClient.MorkF bool ret = true; MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}"); - + OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.COOKING, DeviceId = i); morkFs[i].GoodName = res.GoodName; Coordinate myCoordinate = new Coordinate(); @@ -2764,7 +2761,7 @@ namespace BPASmartClient.MorkF ret = OutFood(i, out error, true); if(ret == false) { - alarmModel.Add(new AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); + alarmModel.Add(new BPA.Message.AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); } break; case nameof(StirFryPotActionEnum.炒制菜品): @@ -2782,7 +2779,7 @@ namespace BPASmartClient.MorkF } if (ret == false) { - alarmModel.Add(new AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); + alarmModel.Add(new BPA.Message.AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); } MessageLog.GetInstance.Show(potActions.Actions); break; @@ -2799,9 +2796,9 @@ namespace BPASmartClient.MorkF Thread.Sleep(3000); //回原点位 StirArmGoOrigin(i); - + OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.COMPLETED_COOK, DeviceId = i); //同时只能允许有一个出餐 - lock(lock_OutMeal) + lock (lock_OutMeal) { //出餐启动 OutMeal(i); diff --git a/BPASmartClient.MorkF/View/DebugView.xaml b/BPASmartClient.MorkF/View/DebugView.xaml index 186c5233..e6baed2a 100644 --- a/BPASmartClient.MorkF/View/DebugView.xaml +++ b/BPASmartClient.MorkF/View/DebugView.xaml @@ -55,16 +55,16 @@ -