From 0a78cad7788a53ce0c9834aadd46f3041b2dd345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8E=9F=E5=B7=9D=20=E5=BC=A0?= Date: Thu, 17 Mar 2022 21:36:53 +0800 Subject: [PATCH] tiaoshi --- HBLConsole.MORKIC/Control_MORKIC.cs | 52 +++++-- HBLConsole/App.config | 4 +- HBLConsole/View/DebugView.xaml | 15 ++ HBLConsole/ViewModel/DebugViewModel.cs | 7 + HBLDevice.Coffee/CoffeeMachine.cs | 122 +++++++++++----- HBLDevice.Coffee/MorkCStatus.cs | 6 +- HBLDevice.IceCream/CommandHandler.cs | 14 +- HBLDevice.IceCream/IceCreamMachine.cs | 186 +++++++++++++------------ HBLDevice.IceCream/MorkIStatus.cs | 5 +- 9 files changed, 266 insertions(+), 145 deletions(-) diff --git a/HBLConsole.MORKIC/Control_MORKIC.cs b/HBLConsole.MORKIC/Control_MORKIC.cs index 3b9619d..a928182 100644 --- a/HBLConsole.MORKIC/Control_MORKIC.cs +++ b/HBLConsole.MORKIC/Control_MORKIC.cs @@ -55,6 +55,24 @@ namespace HBLConsole.MORKIC } public void Init() { + ActionOperate.GetInstance.Register(new Action(() => + { + ThreadOperate.GetInstance.Start(new Action(()=> + { + DoIceCream(); + }),"bqllllllll"); + }), "bql"); + ActionOperate.GetInstance.Register(new Action(() => + { + ThreadOperate.GetInstance.Start(new Action(() => + { + DoCoffee(); + }), "cfjkkkkkkk"); + + + }),"cfj"); + + mainMaterialLoc = "1"; //构建所有商品物料信息 @@ -79,7 +97,6 @@ namespace HBLConsole.MORKIC coffeeMachine = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee)); //冰淇淋机创建 iceCreamMachine = new IceCreamMachine(com_IceCream, (BaudRates)Enum.Parse(typeof(BaudRates), baud_IceCream)); - Main(); ReadData(); } @@ -152,9 +169,17 @@ namespace HBLConsole.MORKIC //订单状态改变:开始制作 //SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); //todo:先调用机器人 - LebaiHelper.GetInstance.Scene(10002); + + ThreadOperate.GetInstance.Start(new Action(() => { LebaiHelper.GetInstance.Scene(10002); }), "CCCCC"); + + while (!(lebai.Ok && lebai.Value == 2)) + { + Thread.Sleep(5); + } + MessageLog.GetInstance.Show("机器人到达接咖啡口位置"); new MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); - are.WaitOne(100 * 90); + are.WaitOne(1000 * 90); + MessageLog.GetInstance.Show("咖啡机制作咖啡完成"); LebaiHelper.GetInstance.SetValue(101); //订单状态改变:完成 //SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK); @@ -168,8 +193,14 @@ namespace HBLConsole.MORKIC //订单状态改变:开始制作 //SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); //todo:先调用机器人 - LebaiHelper.GetInstance.Scene(10001); + ThreadOperate.GetInstance.Start(new Action(()=>{ LebaiHelper.GetInstance.Scene(10001); }),"CCCCC"); + + while (!(lebai.Ok&& lebai.Value==1)) + { + Thread.Sleep(5); + } new DischargeEvent().Publish(); + //冰淇淋没有模式切换,强制等待10s Thread.Sleep(10000); LebaiHelper.GetInstance.SetValue(100); @@ -185,7 +216,7 @@ namespace HBLConsole.MORKIC private void IceCreamEndCookHandle(IEvent @event, EventBus.EventCallBackHandle callBack) { - are.Set(); + //are.Set(); } @@ -195,6 +226,8 @@ namespace HBLConsole.MORKIC coffeeMachine.Start(); //冰淇淋机开启主线程 iceCreamMachine.Start(); + new ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); + //开始心跳刷新,根据咖啡机及冰淇淋机来判断 ThreadOperate.GetInstance.StartLong(new Action(() => { @@ -217,10 +250,11 @@ namespace HBLConsole.MORKIC public void SimOrder(T simOrder) { - ThreadOperate.GetInstance.Start(new Action(() => - { - DoIceCream(); - }), "aaa"); + //ThreadOperate.GetInstance.Start(new Action(() => + //{ + // DoIceCream(); + // //DoCoffee(); + //}), "aaa"); } } diff --git a/HBLConsole/App.config b/HBLConsole/App.config index 5d0a235..51ed3fa 100644 --- a/HBLConsole/App.config +++ b/HBLConsole/App.config @@ -19,9 +19,9 @@ - + - + diff --git a/HBLConsole/View/DebugView.xaml b/HBLConsole/View/DebugView.xaml index 4c327d4..d38dc51 100644 --- a/HBLConsole/View/DebugView.xaml +++ b/HBLConsole/View/DebugView.xaml @@ -157,6 +157,7 @@ + @@ -243,7 +244,21 @@ Text="注意:【取面位置范围是:1 -- 5】, 【取浇头位置范围是:6 -- 10】, 【取碗位置范围是:11 -- 12】" /> + +