From 68a291231b607efd008d0fde0aaeb20295444dbd Mon Sep 17 00:00:00 2001 From: NXX <447201003@qq> Date: Fri, 11 Nov 2022 17:59:06 +0800 Subject: [PATCH] MorkBF --- BPASmartClient.Model/大炒/FryPotMessages.cs | 83 +++++ .../大炒/LocalFryPotMessage.cs | 14 + .../大炒/RobotActionModel.cs | 32 ++ BPASmartClient.MorkBF/Control_MorkBF.cs | 296 +++++++++++++++++- .../Convert/FryActionToVisibilityConverter.cs | 127 ++++++++ BPASmartClient.MorkBF/GVL_MorkBF.cs | 62 +++- BPASmartClient.MorkBF/Model/BF_Food.cs | 32 +- BPASmartClient.MorkBF/Model/Global.cs | 14 + BPASmartClient.MorkBF/VIew/DebugView.xaml | 38 ++- BPASmartClient.MorkBF/VIew/DebugView.xaml.cs | 10 +- .../VIew/FoodManagerView.xaml | 91 ++++-- .../VIew/FoodManagerView.xaml.cs | 19 +- .../ViewModel/DebugViewModel.cs | 44 ++- .../ViewModel/FoodManagerViewModel.cs | 93 ++++++ .../ViewModel/MonitorViewModel.cs | 2 +- BPASmartClient.MorkF/Control_MorkF.cs | 5 +- BPASmartClient/App.config | 8 +- 17 files changed, 887 insertions(+), 83 deletions(-) create mode 100644 BPASmartClient.Model/大炒/FryPotMessages.cs create mode 100644 BPASmartClient.Model/大炒/LocalFryPotMessage.cs create mode 100644 BPASmartClient.Model/大炒/RobotActionModel.cs create mode 100644 BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs create mode 100644 BPASmartClient.MorkBF/Model/Global.cs create mode 100644 BPASmartClient.MorkBF/ViewModel/FoodManagerViewModel.cs diff --git a/BPASmartClient.Model/大炒/FryPotMessages.cs b/BPASmartClient.Model/大炒/FryPotMessages.cs new file mode 100644 index 00000000..9ab0da81 --- /dev/null +++ b/BPASmartClient.Model/大炒/FryPotMessages.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.大炒 +{ + public class FryPotMessages + { + public string GoodName { get; set; } + public string GoodKey { get; set; } + public List fryPotProcesses { get; set; } = new List(); + } + + public class FryPotProcess + { + /// + /// 步骤 + /// + public int FryTime { get; set; } + /// + /// 动作 + /// + public FryAction fryActions { get; set; } + /// + /// 加热时间 单位s + /// + public int FryDuration { get; set; } = 0; + /// + /// 加热挡位 1-5 + /// + public int FryGear { get; set; } = 0; + /// + /// 搅拌挡位 小炒1-10 大炒1-5 + /// + public int StirGear { get; set; } = 0; + /// + /// 翻转速度0到800 + /// + public int TurnSpeed { get; set; }= 0; + /// + /// 炒制位置1到4 + /// + public int FryPosition { get; set; } + /// + /// 辅料,调料,或者菜品集合 + /// + public List accessories { get; set; } = new List(); + + } + + public class Accessories + { + /// + /// 位置 + /// + public int Loc { get; set; } + /// + /// 重量 + /// + public int Qry { get; set; } + } + + public enum FryAction + { + 冷锅加热, + 热油, + 加调料, + 加辅料, + 炒制菜品, + + } + + public enum FryRepot + { + 开始, + 热锅, + 炒菜, + 出餐, + 完成, + } +} diff --git a/BPASmartClient.Model/大炒/LocalFryPotMessage.cs b/BPASmartClient.Model/大炒/LocalFryPotMessage.cs new file mode 100644 index 00000000..9f318553 --- /dev/null +++ b/BPASmartClient.Model/大炒/LocalFryPotMessage.cs @@ -0,0 +1,14 @@ +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 LocalFryPotMessage + { + public ObservableCollection FryPotMessage { get; set; } = new ObservableCollection(); + } +} diff --git a/BPASmartClient.Model/大炒/RobotActionModel.cs b/BPASmartClient.Model/大炒/RobotActionModel.cs new file mode 100644 index 00000000..b614cd34 --- /dev/null +++ b/BPASmartClient.Model/大炒/RobotActionModel.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.大炒 +{ + public class RobotAction_Pot + { + public int Pot { get; set; } + public RobotActionModel robotActionModel { get; set; } + } + + public enum RobotActionModel + { + 无任务, + 取1号炒锅荤菜盆倒1号炒锅, + 取1号炒锅素菜盆1倒1号炒锅, + 取1号炒锅素菜盆2倒1号炒锅, + 取1号炒锅调料盆倒入1号炒锅, + 取1号炒锅辅料盆1倒入1号炒锅, + 取1号空盆出餐, + + 取2号炒锅荤菜盆1倒2号炒锅 = 20, + 取2号炒锅素菜盆1倒2号炒锅 = 21, + 取2号炒锅素菜盆2倒2号炒锅 =22, + 取2号炒锅调料盆倒入2号炒锅 =23, + 取2号炒锅辅料盆1倒入2号炒锅 =24, + 取2号空盆出餐 =25, + } +} diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 76be2fdf..44c179f1 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -1,10 +1,13 @@ -using BPA.Message; +using BPA.Helper; +using BPA.Message; using BPA.Message.Enum; using BPASmartClient.Business; using BPASmartClient.Device; using BPASmartClient.EventBus; using BPASmartClient.Helper; using BPASmartClient.Model; +using BPASmartClient.Model.大炒; +using BPASmartClient.MorkBF.Model; using BPASmartClient.MorkBF.ViewModel; using System; using System.Collections.Generic; @@ -13,6 +16,9 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using static BPASmartClient.EventBus.EventBus; +using static BPASmartClient.Model.大炒.FryPotMessages; +using ActionManage = BPA.Helper.ActionManage; +using ThreadManage = BPA.Helper.ThreadManage; namespace BPASmartClient.MorkBF { @@ -24,7 +30,8 @@ namespace BPASmartClient.MorkBF public override void DoMain() { - + IsHealth = true; + BPASmartClient.Helper.Json.Read(); MonitorViewModel.DeviceId = DeviceId; CommandRegist();//调试 ServerInit(); @@ -44,8 +51,6 @@ namespace BPASmartClient.MorkBF OrderCount++; DeviceProcessLogShow($"接收到{OrderCount}次订单"); - - } }); @@ -60,7 +65,6 @@ namespace BPASmartClient.MorkBF if (@event is MaterialDeliveryEvent material) { orderMaterialDelivery = material.orderMaterialDelivery; - } }); @@ -132,11 +136,55 @@ namespace BPASmartClient.MorkBF public override void MainTask() { + if(morkBF.FirePan1_Order.Count>0&& morkBF.FirePot1_InitCompleted&&morkBF.FirePot2_IsAuto&&!morkBF.FirePan1_Busy) + { + ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程"); + } + + if(morkBF.RobotActinQueue.Count>0&&! morkBF.Robot_Origin)//机器人在原点为 + { + if( morkBF.RobotActinQueue.TryDequeue(out RobotAction_Pot robotAction)) + { + morkBF.Robot_IsBusy =true; + RobotProcess(robotAction); + } + } } private void FirePot1_Process() { + if(morkBF.FirePan1_Order.TryDequeue(out FryPotMessages result)) + { + morkBF.FirePan1_Busy = true; + foreach (var item in result.fryPotProcesses) + { + switch (item.fryActions) + { + case FryAction.冷锅加热: + FirePot_PotPerHeat(item, 1); + break; + + case FryAction.热油: + FirePot_HeatOil(item,1); + break; + + case FryAction.加调料: + FirePot_AddSeasoning(item, 1); + break; + case FryAction.加辅料: + + break; + case FryAction.炒制菜品: + FirePot_FryFood(item,1); + break; + + default: + break; + } + } + + } } private void FirePot2_Process() @@ -144,6 +192,192 @@ namespace BPASmartClient.MorkBF } + + #region 炒锅流程功能 + /// + /// 冷锅预热 + /// + private void FirePot_PotPerHeat(FryPotProcess item,int i) + { + if(i == 1)//炒锅1 + { + FirePot1_SetFireGear(item.FryGear); + FirePot1_StartFire(true); + + } + else if(i == 2)//炒锅2 + { + FirePot2_SetFireGear(item.FryGear); + FirePot2_StartFire(true); + + } + Thread.Sleep(item.FryDuration); + } + + /// + /// 热油 + /// + private void FirePot_HeatOil(FryPotProcess item, int i) + { + if (item.FryGear != 0) + { + FirePot1_SetFireGear(item.FryGear);//设定加热挡位 + FirePot1_StartFire(true);//开启加热 + } + if (item.StirGear != 0) + { + FirePot1_SetStirGear(item.StirGear);//设定搅拌挡位 + FirePot1_StartFire(true);//开启搅拌 + } + Thread.Sleep(item.FryDuration);//加热时间; + } + + /// + /// 加调料 + /// + private void FirePot_AddSeasoning(FryPotProcess item,int i) + { + if(i == 1) + { + + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot =1,robotActionModel = RobotActionModel.取1号炒锅调料盆倒入1号炒锅}); + Thread.Sleep(item.FryDuration); + + } + + else if(i == 2) + { + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅调料盆倒入2号炒锅 }); + Thread.Sleep(item.FryDuration); + } + + } + + /// + /// 加辅料 + /// + private void FirePot_AddAccessories(FryPotProcess item, int i) + { + if (i == 1) + { + + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = RobotActionModel.取1号炒锅辅料盆1倒入1号炒锅 }); + Thread.Sleep(item.FryDuration); + + } + + else if (i == 2) + { + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅辅料盆1倒入2号炒锅 }); + Thread.Sleep(item.FryDuration); + } + + } + + /// + /// 炒制菜品 + /// + private void FirePot_FryFood(FryPotProcess item, int i) + { + if (i == 1) + { + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = (RobotActionModel)item.accessories[0].Loc }); + while (!morkBF.FirePot1_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成 + { + Thread.Sleep(100); + } + Thread.Sleep(item.FryDuration); + + } + + else if (i == 2) + { + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = (RobotActionModel)(item.accessories[0].Loc+19) });//炒制菜品位置 + while (!morkBF.FirePot2_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成 + { + Thread.Sleep(100); + } + Thread.Sleep(item.FryDuration); + } + } + #endregion + + /// + /// 机器人进程 + /// + /// + private void RobotProcess(RobotAction_Pot robotAction) + { + Robot_Write("GI0",(int)robotAction.robotActionModel); + while (morkBF.Robot_ActionCallback != (int)robotAction.robotActionModel)//机器人动作执行完动作反馈 + { + Thread.Sleep(100); + } + if(robotAction.Pot == 1)//炒锅1 + { + if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐) + { + Robot_Write("GM521", true);//炒锅去投料位置 + while(!morkBF.Robot_ArriveFirePot1)//机器人到位,请求1#炒锅倒菜 + { + Thread.Sleep(100); + } + FirePot_Write("M11.6", true);//炒锅去出餐倒料位置 + while (!morkBF.FirePot1_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈 + { + Thread.Sleep(1000); + } + Thread.Sleep(20 * 1000);//等待20s出餐 + + } + else + { + FirePot_Write("M11.7", true);//炒锅去投料位置 + while (!morkBF.FirePot1_PotOnIntoFoodPosition)//等待炒锅允许倒料 + { + Thread.Sleep(100); + } + Robot_Write("GM520", true);//机器人投料 + } + + } + else if (robotAction.Pot == 2) + { + if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐) + { + Robot_Write("GM531", true);//炒锅去投料位置 + while (!morkBF.Robot_ArriveFirePot2)//机器人到位,请求1#炒锅倒菜 + { + Thread.Sleep(100); + } + FirePot_Write("M16.6", true);//炒锅去出餐倒料位置 + while (!morkBF.FirePot2_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈 + { + Thread.Sleep(1000); + } + Thread.Sleep(20 * 1000);//等待20s出餐 + + } + else + { + FirePot_Write("M16.7", true); + while (!morkBF.FirePot2_PotOnIntoFoodPosition) + { + Thread.Sleep(100); + } + Robot_Write("GM530", true); + } + + } + + while(!morkBF.Robot_Origin) + { + Thread.Sleep(1000); + } + morkBF.Robot_IsBusy = false; + MessageLog.GetInstance.Show($"机器人完成[{robotAction.robotActionModel.ToString()}]任务"); + } + public override void ReadData() { GetStatus("M20.0",new Action((o)=> @@ -228,9 +462,10 @@ namespace BPASmartClient.MorkBF if (o == null) return; if (o is bool[] values && values.Length == 7) { - morkBF.Robot_FirePot1OutMeal = values[0]; - morkBF.Robot_FirePot1OutVegetables1 = values[1]; - morkBF.Robot_FirePot1OutVegetables2 = values[2]; + + morkBF.FirePot1_CompleteSingle[0] = values[0]; + morkBF.FirePot1_CompleteSingle[1] = values[1]; + morkBF.FirePot1_CompleteSingle[2] = values[2]; morkBF.Robot_FirePot1OutSeasoning = values[3]; morkBF.Robot_FirePot1OutAccessories = values[4]; morkBF.Robot_ArriveFirePot1 = values[5]; @@ -243,9 +478,9 @@ namespace BPASmartClient.MorkBF if (o == null) return; if (o is bool[] values && values.Length == 7) { - morkBF.Robot_FirePot2OutMeal = values[0]; - morkBF.Robot_FirePot2OutVegetables1 = values[1]; - morkBF.Robot_FirePot2OutVegetables2 = values[2]; + morkBF.FirePot2_CompleteSingle[0] = values[0]; + morkBF.FirePot2_CompleteSingle[1] = values[1]; + morkBF.FirePot2_CompleteSingle[2] = values[2]; morkBF.Robot_FirePot2OutSeasoning = values[3]; morkBF.Robot_FirePot2OutAccessories = values[4]; morkBF.Robot_ArriveFirePot2 = values[5]; @@ -319,7 +554,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW100", value); } - + Thread.Sleep(200); } /// /// 炒锅1加热启停 @@ -332,6 +567,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("M10.0", value); } + Thread.Sleep(200); } /// /// 炒锅1设置搅拌挡位 @@ -344,6 +580,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW102", value); } + Thread.Sleep(200); } /// /// 炒锅1搅拌启停 @@ -356,6 +593,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("M10.1", value); } + Thread.Sleep(200); } /// /// 设置炒锅1翻转速度 @@ -368,6 +606,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW104", value); } + Thread.Sleep(200); } #endregion @@ -383,7 +622,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW130", value); } - + Thread.Sleep(200); } /// /// 炒锅2加热启停 @@ -396,6 +635,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("M15.0", value); } + Thread.Sleep(200); } /// /// 炒锅2设置搅拌挡位 @@ -408,6 +648,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW132", value); } + Thread.Sleep(200); } /// /// 炒锅2搅拌启停 @@ -420,6 +661,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("M15.1", value); } + Thread.Sleep(200); } /// /// 设置炒锅2翻转速度 @@ -432,6 +674,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW134", value); } + Thread.Sleep(200); } #endregion @@ -476,6 +719,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M15.5", true); } } + Thread.Sleep(200); } /// /// 炒锅去位置1 @@ -495,6 +739,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.2", true); } } + Thread.Sleep(200); } /// /// 炒锅去位置2 @@ -514,6 +759,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.3", true); } } + Thread.Sleep(200); } /// /// 炒锅去位置3 @@ -533,6 +779,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.4", true); } } + Thread.Sleep(200); } /// /// 炒锅去位置4 @@ -552,6 +799,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.5", true); } } + Thread.Sleep(200); } /// /// 炒锅去出餐位置 @@ -571,6 +819,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.6", true); } } + Thread.Sleep(200); } /// /// 炒锅去投料位置 @@ -590,6 +839,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.7", true); } } + Thread.Sleep(200); } /// /// 出餐启动 @@ -610,6 +860,7 @@ namespace BPASmartClient.MorkBF } } + Thread.Sleep(200); } /// /// 清洗 @@ -622,13 +873,15 @@ namespace BPASmartClient.MorkBF { if (i == 1) { - FirePot_Write("M10.7", true); + if(morkBF.FirePot1_OnOrigin) FirePot_Write("M10.7", true); + } else if (i == 2) { - FirePot_Write("M15.7", true); + if (morkBF.FirePot2_OnOrigin) FirePot_Write("M15.7", true); } } + Thread.Sleep(200); } /// /// 抽水启动 @@ -648,6 +901,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.0", true); } } + Thread.Sleep(200); } /// /// 抽油启动 @@ -667,6 +921,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.1", true); } } + Thread.Sleep(200); } #endregion @@ -677,6 +932,7 @@ namespace BPASmartClient.MorkBF private void RobotStart() { Robot_Write("GM600",true); + Thread.Sleep(200); } /// /// 机器人停止 @@ -684,6 +940,7 @@ namespace BPASmartClient.MorkBF private void RobotStop() { Robot_Write("GM601", true); + Thread.Sleep(200); } /// /// 机器人复位 @@ -691,6 +948,7 @@ namespace BPASmartClient.MorkBF private void RobotReset() { Robot_Write("GM602", true); + Thread.Sleep(200); } /// /// 机器人程序重启 @@ -698,6 +956,7 @@ namespace BPASmartClient.MorkBF private void RobotProgramStart() { Robot_Write("GM603", true); + Thread.Sleep(200); } /// /// 1号炒锅允许机器人投料(炒锅在投料位给出) @@ -705,6 +964,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot1AllowInMaterail() { Robot_Write("GM520", true); + Thread.Sleep(200); } /// /// 1号炒锅出餐倒料到减速位 @@ -712,6 +972,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot1OutFoodInSlowDown() { Robot_Write("GM621", true); + Thread.Sleep(200); } /// /// 1号炒锅出餐倒料完成 @@ -719,6 +980,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot1OutFood() { Robot_Write("GM522", true); + Thread.Sleep(200); } /// /// 2号炒锅允许机器人投料(炒锅在投料位给出) @@ -726,6 +988,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot2AllowInMaterail() { Robot_Write("GM530", true); + Thread.Sleep(200); } /// /// 2号炒锅出餐倒料到减速位。开始倒菜 @@ -733,6 +996,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot2OutFoodInSlowDown() { Robot_Write("GM531", true); + Thread.Sleep(200); } /// /// 2号炒锅出餐倒料完成 @@ -740,6 +1004,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot2OutFood() { Robot_Write("GM532", true); + Thread.Sleep(200); } /// /// @@ -751,6 +1016,7 @@ namespace BPASmartClient.MorkBF { Robot_Write("GI0",value); } + Thread.Sleep(200); } #endregion diff --git a/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs b/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs new file mode 100644 index 00000000..b6c17e30 --- /dev/null +++ b/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs @@ -0,0 +1,127 @@ +using BPASmartClient.Model.大炒; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace BPASmartClient.MorkBF.Convert +{ + public class StirToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility visibility = Visibility.Visible; + if (value != null && value is FryAction fryAction) + { + switch (fryAction) + { + case FryAction.冷锅加热: + visibility = Visibility.Collapsed; + break; + case FryAction.热油: + visibility = Visibility.Visible; + break; + case FryAction.加调料: + visibility = Visibility.Collapsed; + break; + case FryAction.加辅料: + visibility = Visibility.Collapsed; + break; + case FryAction.炒制菜品: + visibility = Visibility.Visible; + break; + default: + break; + } + } + return visibility; + } + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public class FirePositionToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility visibility = Visibility.Visible; + if (value != null && value is FryAction fryAction) + { + switch (fryAction) + { + case FryAction.冷锅加热: + visibility = Visibility.Visible; + break; + case FryAction.热油: + visibility = Visibility.Visible; + break; + case FryAction.加调料: + visibility = Visibility.Collapsed; + break; + case FryAction.加辅料: + visibility = Visibility.Collapsed; + break; + case FryAction.炒制菜品: + visibility = Visibility.Visible; + break; + default: + break; + } + } + return visibility; + } + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public class AccessoriesToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility visibility = Visibility.Visible; + if (value != null && value is FryAction fryAction) + { + switch (fryAction) + { + case FryAction.冷锅加热: + visibility = Visibility.Collapsed; + break; + case FryAction.热油: + visibility = Visibility.Collapsed; + break; + case FryAction.加调料: + visibility = Visibility.Visible; + break; + case FryAction.加辅料: + visibility = Visibility.Visible; + break; + case FryAction.炒制菜品: + visibility = Visibility.Visible; + break; + default: + break; + } + } + return visibility; + } + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} + diff --git a/BPASmartClient.MorkBF/GVL_MorkBF.cs b/BPASmartClient.MorkBF/GVL_MorkBF.cs index c802243c..f7a2bcc8 100644 --- a/BPASmartClient.MorkBF/GVL_MorkBF.cs +++ b/BPASmartClient.MorkBF/GVL_MorkBF.cs @@ -1,4 +1,5 @@ using BPASmartClient.Device; +using BPASmartClient.Model.大炒; using BPASmartClient.MorkBF.Model; using System; using System.Collections.Concurrent; @@ -14,11 +15,15 @@ namespace BPASmartClient.MorkBF /// /// 炒锅1订单队列 /// - public ConcurrentQueue FirePan1_Order { get; set; } = new ConcurrentQueue(); + public ConcurrentQueue FirePan1_Order { get; set; } = new ConcurrentQueue(); /// /// 炒锅2订单队列 /// - public ConcurrentQueue FirePan2_Order { get; set; } = new ConcurrentQueue(); + public ConcurrentQueue FirePan2_Order { get; set; } = new ConcurrentQueue(); + /// + /// 机器人队列 + /// + public ConcurrentQueue RobotActinQueue { get; set; } = new ConcurrentQueue(); /// /// 炒锅1忙碌 /// @@ -247,30 +252,39 @@ namespace BPASmartClient.MorkBF #endregion #region 机器人数据读取 + public bool Robot_IsBusy; + + + /// + /// 机器人在原点位 + /// + [VariableMonitor("机器人在原点位", "GM105", "4201")] + public bool Robot_Origin { get; set; } + /// /// 1号锅倒荤菜完成 /// - [VariableMonitor("1号锅倒荤菜完成", "GM500", "4596")] + [VariableMonitor("机器人#1号锅倒荤菜完成", "GM500", "4596")] public bool Robot_FirePot1OutMeal{ get; set; } /// /// 1号炒锅倒素菜1完成 /// - [VariableMonitor("1号炒锅倒素菜1完成", "GM501", "4597")] + [VariableMonitor("机器人#1号炒锅倒素菜1完成", "GM501", "4597")] public bool Robot_FirePot1OutVegetables1{ get; set; } /// /// 1号炒锅倒素菜2完成 /// - [VariableMonitor("1号炒锅倒素菜2完成", "GM502", "4598")] + [VariableMonitor("机器人#1号炒锅倒素菜2完成", "GM502", "4598")] public bool Robot_FirePot1OutVegetables2{ get; set; } /// /// 1号炒锅倒调料完成 /// - [VariableMonitor("1号炒锅倒调料完成", "GM503", "4599")] + [VariableMonitor("机器人#1号炒锅倒调料完成", "GM503", "4599")] public bool Robot_FirePot1OutSeasoning{ get; set; } /// /// 1号炒锅倒辅料完成 /// - [VariableMonitor("1号炒锅倒辅料完成", "GM504", "4600")] + [VariableMonitor("机器人#1号炒锅倒辅料完成", "GM504", "4600")] public bool Robot_FirePot1OutAccessories{ get; set; } /// /// 机器人到位,请求1#炒锅倒菜 @@ -280,7 +294,7 @@ namespace BPASmartClient.MorkBF /// /// 1号炒锅出餐完成 /// - [VariableMonitor("1号炒锅出餐完成", "GM506", "4602")] + [VariableMonitor("机器人#1号炒锅出餐完成", "GM506", "4602")] public bool Robot_FirePot1OutFoodComplete{ get; set; } @@ -290,12 +304,12 @@ namespace BPASmartClient.MorkBF /// /// 2号锅倒荤菜完成 /// - [VariableMonitor("2号锅倒荤菜完成", "GM510", "4606")] + [VariableMonitor("机器人#2号锅倒荤菜完成", "GM510", "4606")] public bool Robot_FirePot2OutMeal { get; set; } /// /// 2号炒锅倒素菜1完成 /// - [VariableMonitor("2号炒锅倒素菜1完成", "GM511", "4607")] + [VariableMonitor("机器人#2号炒锅倒素菜1完成", "GM511", "4607")] public bool Robot_FirePot2OutVegetables1{ get; set; } /// /// 2号炒锅倒素菜2完成 @@ -305,22 +319,22 @@ namespace BPASmartClient.MorkBF /// /// 2号炒锅倒调料完成 /// - [VariableMonitor("2号炒锅倒调料完成", "GM513", "4609")] + [VariableMonitor("机器人#2号炒锅倒调料完成", "GM513", "4609")] public bool Robot_FirePot2OutSeasoning{ get; set; } /// /// 2号炒锅倒辅料完成 /// - [VariableMonitor("2号炒锅倒辅料完成", "GM514", "4610")] + [VariableMonitor("机器人#2号炒锅倒辅料完成", "GM514", "4610")] public bool Robot_FirePot2OutAccessories{ get; set; } /// /// 机器人到位,请求1#炒锅倒菜 /// - [VariableMonitor("机器人到位,请求1#炒锅倒菜", "GM515", "4611")] + [VariableMonitor("机器人#机器人到位,请求1#炒锅倒菜", "GM515", "4611")] public bool Robot_ArriveFirePot2{ get; set; } /// /// 2号炒锅出餐完成 /// - [VariableMonitor("2号炒锅出餐完成", "GM516", "4612")] + [VariableMonitor("机器人#2号炒锅出餐完成", "GM516", "4612")] public bool Robot_FirePot2OutFoodComplete{ get; set; } /// /// 机器人动作反馈 @@ -330,7 +344,27 @@ namespace BPASmartClient.MorkBF #endregion + public Dictionary FirePot1_CompleteSingle { get; set; } + + public Dictionary FirePot2_CompleteSingle { get; set; } + + + public GVL_MorkBF() + { + FirePot1_CompleteSingle = new Dictionary + { + {1,Robot_FirePot1OutMeal }, + {2,Robot_FirePot1OutVegetables1 }, + {3,Robot_FirePot1OutVegetables2 }, + }; + FirePot2_CompleteSingle = new Dictionary + { + {1,Robot_FirePot2OutMeal }, + {2,Robot_FirePot2OutVegetables1 }, + {3,Robot_FirePot2OutVegetables2 }, + }; + } public DateTime FirePan1_Date; public DateTime FirePan2_Date; diff --git a/BPASmartClient.MorkBF/Model/BF_Food.cs b/BPASmartClient.MorkBF/Model/BF_Food.cs index 6891c445..d1d49a4e 100644 --- a/BPASmartClient.MorkBF/Model/BF_Food.cs +++ b/BPASmartClient.MorkBF/Model/BF_Food.cs @@ -17,6 +17,8 @@ namespace BPASmartClient.MorkBF.Model /// public string FoodID { get; set; } + public List PotActions { get; set; } = new List(); + } public class BF_PotAction @@ -40,7 +42,7 @@ namespace BPASmartClient.MorkBF.Model /// /// 动作 /// - public string Actions + public PotAction Actions { get; set; @@ -62,4 +64,32 @@ namespace BPASmartClient.MorkBF.Model set; } } + + + public enum PotAction + { + 加热开启, + 加热关闭, + 搅拌开启, + 搅拌关闭, + + 加调料, + 加菜品, + 加辅料, + 加热时间, + + 抽油启动, + 抽水启动, + 出餐启动, + + 炒锅回原点, + 炒制位置1, + 炒制位置2, + 炒制位置3, + 炒制位置4, + 炒锅去出餐倒料位置, + 炒锅去投料位置, + + + } } diff --git a/BPASmartClient.MorkBF/Model/Global.cs b/BPASmartClient.MorkBF/Model/Global.cs new file mode 100644 index 00000000..4c504caf --- /dev/null +++ b/BPASmartClient.MorkBF/Model/Global.cs @@ -0,0 +1,14 @@ +using BPASmartClient.Model.大炒; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkBF.Model +{ + public class Global + { + public static FryPotMessages GLoFryMessage { get; set; } = new FryPotMessages(); + } +} diff --git a/BPASmartClient.MorkBF/VIew/DebugView.xaml b/BPASmartClient.MorkBF/VIew/DebugView.xaml index 7928442d..2ac694c1 100644 --- a/BPASmartClient.MorkBF/VIew/DebugView.xaml +++ b/BPASmartClient.MorkBF/VIew/DebugView.xaml @@ -21,14 +21,40 @@ + + - - - - +