diff --git a/BPASmartClient.Helper/ActionManage.cs b/BPASmartClient.Helper/ActionManage.cs index a300fc6a..f406b589 100644 --- a/BPASmartClient.Helper/ActionManage.cs +++ b/BPASmartClient.Helper/ActionManage.cs @@ -44,7 +44,8 @@ namespace BPASmartClient.Helper public void Send(string key, object par, Action Callback = null) { lock (SendLock) - if (actions.ContainsKey(key)) actions[key].ActionPar.Invoke(par, Callback); + if (actions.ContainsKey(key)) + actions[key].ActionPar.Invoke(par, Callback); } public async void SendAsync(string key, object par, Action Callback = null) diff --git a/BPASmartClient.Model/大炒/FryPotMessages.cs b/BPASmartClient.Model/大炒/FryPotMessages.cs index 9ab0da81..311010e9 100644 --- a/BPASmartClient.Model/大炒/FryPotMessages.cs +++ b/BPASmartClient.Model/大炒/FryPotMessages.cs @@ -11,6 +11,7 @@ namespace BPASmartClient.Model.大炒 public string GoodName { get; set; } public string GoodKey { get; set; } public List fryPotProcesses { get; set; } = new List(); + public int FryOffStirTime;//关火翻炒时间; } public class FryPotProcess diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 44c179f1..c326a5d5 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -1,10 +1,10 @@ -using BPA.Helper; -using BPA.Message; +using BPA.Message; using BPA.Message.Enum; using BPASmartClient.Business; using BPASmartClient.Device; using BPASmartClient.EventBus; using BPASmartClient.Helper; +using BPASmartClient.Message; using BPASmartClient.Model; using BPASmartClient.Model.大炒; using BPASmartClient.MorkBF.Model; @@ -17,8 +17,6 @@ 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 { @@ -28,15 +26,30 @@ namespace BPASmartClient.MorkBF public override DeviceClientType DeviceType => DeviceClientType.MORKCS; + int RobotLeadTime = 5;//机器人提前动作时间 s + public override void DoMain() { 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 }); + } + } + + }), "更新菜单"); CommandRegist();//调试 ServerInit(); DataParse();//数据解析 ScreenDataServer();//大屏数据上报 + ActionManage.GetInstance.Send("更新菜单"); DeviceProcessLogShow("MORKF 设备初始化完成"); } @@ -109,7 +122,7 @@ namespace BPASmartClient.MorkBF ActionManage.GetInstance.Register(FirePot_PotGotoP2, "FirePot_PotGotoP2");//炒锅去位置2 ActionManage.GetInstance.Register(FirePot_PotGotoP3, "FirePot_PotGotoP3");//炒锅去位置3 ActionManage.GetInstance.Register(FirePot_PotGotoP4, "FirePot_PotGotoP4");//炒锅去位置4 - ActionManage.GetInstance.Register(FirePot_PotGotoOutFoodPositiong, "FirePot_PotGotoOutFoodPositiong");//炒锅去出餐位置 + //ActionManage.GetInstance.Register(FirePot_PotGotoOutFoodPosition, "FirePot_PotGotoOutFoodPositiong");//炒锅去出餐位置 ActionManage.GetInstance.Register(FirePot_PotGotoInFoodPosition, "FirePot_PotGotoInFoodPosition");//炒锅去投料位置 ActionManage.GetInstance.Register(FirePot_StartOutFood, "FirePot_StartOutFood");//出餐启动 ActionManage.GetInstance.Register(FirePot_Clean, "FirePot_Clean");//清洗 @@ -156,27 +169,33 @@ namespace BPASmartClient.MorkBF if(morkBF.FirePan1_Order.TryDequeue(out FryPotMessages result)) { + morkBF.FirePan1_Busy = true; + morkBF.FryPot1_CurrentProcess = result.fryPotProcesses; foreach (var item in result.fryPotProcesses) { switch (item.fryActions) { case FryAction.冷锅加热: FirePot_PotPerHeat(item, 1); + MessageLog.GetInstance.Show("炒锅1---冷锅加热完成"); break; case FryAction.热油: FirePot_HeatOil(item,1); + MessageLog.GetInstance.Show("炒锅1---热油完成"); break; - case FryAction.加调料: FirePot_AddSeasoning(item, 1); + MessageLog.GetInstance.Show("炒锅1---加调料完成"); break; case FryAction.加辅料: - + FirePot_AddAccessories(item,1); + MessageLog.GetInstance.Show("炒锅1---加辅料完成"); break; case FryAction.炒制菜品: FirePot_FryFood(item,1); + MessageLog.GetInstance.Show("炒锅1---炒制菜品完成"); break; default: @@ -194,24 +213,45 @@ namespace BPASmartClient.MorkBF #region 炒锅流程功能 + + private bool IsRobotNextWork(List currentProcess, int currentFryTime) + { + bool res = false; + if(currentProcess.Count> currentFryTime) + { + if (currentProcess[currentFryTime + 1].fryActions == FryAction.加调料 || + currentProcess[currentFryTime + 1].fryActions == FryAction.加辅料 || + currentProcess[currentFryTime + 1].fryActions == FryAction.炒制菜品) + { + res = true; + } + } + return res; + } + /// /// 冷锅预热 /// private void FirePot_PotPerHeat(FryPotProcess item,int i) { + bool isRobotWork = false; if(i == 1)//炒锅1 { FirePot1_SetFireGear(item.FryGear); + Thread.Sleep(200); FirePot1_StartFire(true); - + isRobotWork = IsRobotNextWork(morkBF.FryPot1_CurrentProcess,item.FryTime); } else if(i == 2)//炒锅2 { FirePot2_SetFireGear(item.FryGear); FirePot2_StartFire(true); - + isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime); } - Thread.Sleep(item.FryDuration); + if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料 + else Thread.Sleep(item.FryDuration * 1000); + + } /// @@ -219,17 +259,21 @@ namespace BPASmartClient.MorkBF /// private void FirePot_HeatOil(FryPotProcess item, int i) { + bool isRobotWork = false; if (item.FryGear != 0) { FirePot1_SetFireGear(item.FryGear);//设定加热挡位 FirePot1_StartFire(true);//开启加热 + isRobotWork = IsRobotNextWork(morkBF.FryPot1_CurrentProcess, item.FryTime); } if (item.StirGear != 0) { FirePot1_SetStirGear(item.StirGear);//设定搅拌挡位 FirePot1_StartFire(true);//开启搅拌 + isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime); } - Thread.Sleep(item.FryDuration);//加热时间; + if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料 + else Thread.Sleep(item.FryDuration * 1000);//加热时间; } /// @@ -237,6 +281,7 @@ namespace BPASmartClient.MorkBF /// private void FirePot_AddSeasoning(FryPotProcess item,int i) { + if(i == 1) { @@ -260,7 +305,7 @@ namespace BPASmartClient.MorkBF { if (i == 1) { - + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = RobotActionModel.取1号炒锅辅料盆1倒入1号炒锅 }); Thread.Sleep(item.FryDuration); @@ -279,6 +324,7 @@ namespace BPASmartClient.MorkBF /// private void FirePot_FryFood(FryPotProcess item, int i) { + bool isRobotWork = false; if (i == 1) { morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = (RobotActionModel)item.accessories[0].Loc }); @@ -286,7 +332,8 @@ namespace BPASmartClient.MorkBF { Thread.Sleep(100); } - Thread.Sleep(item.FryDuration); + isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime); + } @@ -297,8 +344,11 @@ namespace BPASmartClient.MorkBF { Thread.Sleep(100); } - Thread.Sleep(item.FryDuration); + isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime); + } + if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料 + else Thread.Sleep(item.FryDuration * 1000);//加热时间; } #endregion @@ -317,27 +367,28 @@ namespace BPASmartClient.MorkBF { if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐) { - Robot_Write("GM521", true);//炒锅去投料位置 + Robot_Write("GM520", true);//机器人去出餐倒料减速位置 while(!morkBF.Robot_ArriveFirePot1)//机器人到位,请求1#炒锅倒菜 { Thread.Sleep(100); } - FirePot_Write("M11.6", true);//炒锅去出餐倒料位置 + FirePot_StartOutFood(1);//炒锅出餐; while (!morkBF.FirePot1_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈 { Thread.Sleep(1000); } - Thread.Sleep(20 * 1000);//等待20s出餐 + Thread.Sleep(6 * 1000);//等待6s出餐 + Robot_Write("GM521", true);//机器人出餐到料完成 } else { - FirePot_Write("M11.7", true);//炒锅去投料位置 + FirePot_Write("M11.6", true);//炒锅去投料位置 while (!morkBF.FirePot1_PotOnIntoFoodPosition)//等待炒锅允许倒料 { Thread.Sleep(100); } - Robot_Write("GM520", true);//机器人投料 + Robot_Write("GM531", true);//机器人投料 } } @@ -345,17 +396,18 @@ namespace BPASmartClient.MorkBF { if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐) { - Robot_Write("GM531", true);//炒锅去投料位置 + Robot_Write("GM522", true);//炒锅去出餐倒料减速位置 while (!morkBF.Robot_ArriveFirePot2)//机器人到位,请求1#炒锅倒菜 { Thread.Sleep(100); } - FirePot_Write("M16.6", true);//炒锅去出餐倒料位置 + FirePot_StartOutFood(2);//炒锅去出餐倒料位置 while (!morkBF.FirePot2_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈 { Thread.Sleep(1000); } - Thread.Sleep(20 * 1000);//等待20s出餐 + Thread.Sleep(6 * 1000);//等待20s出餐 + Robot_Write("GM523", true);//机器人出餐倒料完成 } else @@ -365,7 +417,7 @@ namespace BPASmartClient.MorkBF { Thread.Sleep(100); } - Robot_Write("GM530", true); + Robot_Write("GM531", true); } } @@ -550,9 +602,9 @@ namespace BPASmartClient.MorkBF private void FirePot1_SetFireGear(object o) { if (o == null) return; - if (o is int value) + if (int.TryParse(o.ToString(), out int value)) { - FirePot_Write("VW100", value); + FirePot_Write("VW100", (ushort)value); } Thread.Sleep(200); } @@ -563,11 +615,12 @@ namespace BPASmartClient.MorkBF private void FirePot1_StartFire(object o) { if (o == null) return; - if (o is bool value) + if (bool.TryParse(o.ToString(), out bool value)) { FirePot_Write("M10.0", value); } Thread.Sleep(200); + FirePot_Write("M10.2", true); } /// /// 炒锅1设置搅拌挡位 @@ -576,11 +629,12 @@ namespace BPASmartClient.MorkBF private void FirePot1_SetStirGear(object o) { if (o == null) return; - if (o is int value) + if (int.TryParse(o.ToString(), out int value)) { - FirePot_Write("VW102", value); + FirePot_Write("VW102", (ushort)value); } Thread.Sleep(200); + FirePot_Write("M10.3", true); } /// /// 炒锅1搅拌启停 @@ -589,7 +643,7 @@ namespace BPASmartClient.MorkBF private void FirePot1_StartStir(object o) { if (o == null) return; - if (o is bool value) + if (bool.TryParse(o.ToString(), out bool value)) { FirePot_Write("M10.1", value); } @@ -602,11 +656,13 @@ namespace BPASmartClient.MorkBF private void FirePot1_SetTurnSpeed(object o) { if (o == null) return; - if (o is int value) + if (int.TryParse(o.ToString(), out int value)) { - FirePot_Write("VW104", value); + FirePot_Write("VW104", (ushort)value); } Thread.Sleep(200); + FirePot_Write("M10.4", true); + Thread.Sleep(200); } #endregion @@ -618,11 +674,12 @@ namespace BPASmartClient.MorkBF private void FirePot2_SetFireGear(object o) { if (o == null) return; - if (o is int value) + if (int.TryParse(o.ToString(), out int value)) { - FirePot_Write("VW130", value); + FirePot_Write("VW130", (ushort)value); } Thread.Sleep(200); + FirePot_Write("M15.2", true); } /// /// 炒锅2加热启停 @@ -646,9 +703,11 @@ namespace BPASmartClient.MorkBF if (o == null) return; if (o is int value) { - FirePot_Write("VW132", value); + FirePot_Write("VW132", (ushort)value); } Thread.Sleep(200); + FirePot_Write("M15.3", true); + Thread.Sleep(200); } /// /// 炒锅2搅拌启停 @@ -672,9 +731,11 @@ namespace BPASmartClient.MorkBF if (o == null) return; if (o is int value) { - FirePot_Write("VW134", value); + FirePot_Write("VW134", (ushort)value); } Thread.Sleep(200); + FirePot_Write("M15.4", true); + Thread.Sleep(200); } #endregion @@ -687,7 +748,7 @@ namespace BPASmartClient.MorkBF private void FirePot_Reset(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -708,7 +769,7 @@ namespace BPASmartClient.MorkBF private void FirePot_PotGotoOrigin(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -728,7 +789,7 @@ namespace BPASmartClient.MorkBF private void FirePot_PotGotoP1(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -748,7 +809,7 @@ namespace BPASmartClient.MorkBF private void FirePot_PotGotoP2(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -768,7 +829,7 @@ namespace BPASmartClient.MorkBF private void FirePot_PotGotoP3(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -788,7 +849,7 @@ namespace BPASmartClient.MorkBF private void FirePot_PotGotoP4(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -801,26 +862,26 @@ namespace BPASmartClient.MorkBF } Thread.Sleep(200); } - /// - /// 炒锅去出餐位置 - /// - /// - private void FirePot_PotGotoOutFoodPositiong(object o) - { - if (o == null) return; - if (o is int i) - { - if (i == 1) - { - FirePot_Write("M11.6", true); - } - else if (i == 2) - { - FirePot_Write("M16.6", true); - } - } - Thread.Sleep(200); - } + ///// + ///// 炒锅去出餐位置 + ///// + ///// + //private void FirePot_PotGotoOutFoodPositiong(object o) + //{ + // if (o == null) return; + // if (o is int i) + // { + // if (i == 1) + // { + // FirePot_Write("M11.6", true); + // } + // else if (i == 2) + // { + // FirePot_Write("M16.6", true); + // } + // } + // Thread.Sleep(200); + //} /// /// 炒锅去投料位置 /// @@ -828,15 +889,15 @@ namespace BPASmartClient.MorkBF private void FirePot_PotGotoInFoodPosition(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString() ,out int i)) { if (i == 1) { - FirePot_Write("M11.7", true); + FirePot_Write("M11.6", true); } else if (i == 2) { - FirePot_Write("M16.7", true); + FirePot_Write("M16.6", true); } } Thread.Sleep(200); @@ -848,7 +909,7 @@ namespace BPASmartClient.MorkBF private void FirePot_StartOutFood(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -869,7 +930,7 @@ namespace BPASmartClient.MorkBF private void FirePot_Clean(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -890,7 +951,7 @@ namespace BPASmartClient.MorkBF private void FirePot_StartPumpWater(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -910,7 +971,7 @@ namespace BPASmartClient.MorkBF private void FirePot_StartPumpOil(object o) { if (o == null) return; - if (o is int i) + if (int.TryParse(o.ToString(), out int i)) { if (i == 1) { @@ -963,7 +1024,7 @@ namespace BPASmartClient.MorkBF /// private void Robot_Pot1AllowInMaterail() { - Robot_Write("GM520", true); + Robot_Write("GM531", true); Thread.Sleep(200); } /// @@ -971,7 +1032,7 @@ namespace BPASmartClient.MorkBF /// private void Robot_Pot1OutFoodInSlowDown() { - Robot_Write("GM621", true); + Robot_Write("GM620", true); Thread.Sleep(200); } /// @@ -979,7 +1040,7 @@ namespace BPASmartClient.MorkBF /// private void Robot_Pot1OutFood() { - Robot_Write("GM522", true); + Robot_Write("GM521", true); Thread.Sleep(200); } /// @@ -995,7 +1056,7 @@ namespace BPASmartClient.MorkBF /// private void Robot_Pot2OutFoodInSlowDown() { - Robot_Write("GM531", true); + Robot_Write("GM522", true); Thread.Sleep(200); } /// @@ -1003,7 +1064,7 @@ namespace BPASmartClient.MorkBF /// private void Robot_Pot2OutFood() { - Robot_Write("GM532", true); + Robot_Write("GM523", true); Thread.Sleep(200); } /// @@ -1012,7 +1073,7 @@ namespace BPASmartClient.MorkBF private void RobotActionStart(object o) { if (o == null) return; - if(o is int value) + if(int.TryParse(o.ToString(), out int value)) { Robot_Write("GI0",value); } diff --git a/BPASmartClient.MorkBF/GVL_MorkBF.cs b/BPASmartClient.MorkBF/GVL_MorkBF.cs index f7a2bcc8..6f65fabf 100644 --- a/BPASmartClient.MorkBF/GVL_MorkBF.cs +++ b/BPASmartClient.MorkBF/GVL_MorkBF.cs @@ -32,6 +32,15 @@ namespace BPASmartClient.MorkBF /// 炒锅2忙碌 /// public bool FirePan2_Busy = false; + /// + /// 炒锅1当前流程 + /// + public List FryPot1_CurrentProcess; + /// + /// 炒锅2当前流程 + /// + public List FryPot2_CurrentProcess; + #region 炒锅1读取数据 /// diff --git a/BPASmartClient.MorkBF/VIew/DebugView.xaml b/BPASmartClient.MorkBF/VIew/DebugView.xaml index 2ac694c1..9c30fa9d 100644 --- a/BPASmartClient.MorkBF/VIew/DebugView.xaml +++ b/BPASmartClient.MorkBF/VIew/DebugView.xaml @@ -21,13 +21,11 @@ - - -