From 034cbbdbf24e842251969ef694639d4eba57d772 Mon Sep 17 00:00:00 2001 From: NXX <447201003@qq> Date: Thu, 26 May 2022 18:20:34 +0800 Subject: [PATCH] MorktTIAOSHI --- BPASmartClient.GSIceCream/IceCreamMachine.cs | 12 +++-- BPASmartClient.MorkT/Control_MorkT.cs | 45 +++++++++++++++---- BPASmartClient.MorkT/GLV_MorkT.cs | 5 ++- .../ViewModel/DebugViewModel.cs | 32 ++++++------- 4 files changed, 64 insertions(+), 30 deletions(-) diff --git a/BPASmartClient.GSIceCream/IceCreamMachine.cs b/BPASmartClient.GSIceCream/IceCreamMachine.cs index b7baa092..972a4b12 100644 --- a/BPASmartClient.GSIceCream/IceCreamMachine.cs +++ b/BPASmartClient.GSIceCream/IceCreamMachine.cs @@ -88,6 +88,12 @@ namespace BPASmartClient.GSIceCream ThreadManage.GetInstance().StartLong(new Action(() => { + status["test"] = 0; + for (int i = 0; i < 1000; i++) + { + status["test"] = (int)status["test"] + 1; + Thread.Sleep(1000); + } ResolveMsg(); }), "冰淇淋解析线程"); } @@ -181,9 +187,9 @@ namespace BPASmartClient.GSIceCream status["YLWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L,heartUpMsg.YLWD_H },0); status["HQWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L,heartUpMsg.HQWD_H },0); status["HJWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HJWD_L,heartUpMsg.HJWD_H },0); - status["DL"] = BitConverter.ToInt16(new byte[] { heartUpMsg.DL_L,heartUpMsg.DL_H },0); + status["DL"] = BitConverter.ToInt16(new byte[] { heartUpMsg.DL_L, heartUpMsg.DL_H }, 0); status["Fault"] = (MORKI_FAULT)BitConverter.ToInt16(new byte[] { heartUpMsg.GZ_L,heartUpMsg.GZ_H },0); - status["CXB"] = heartUpMsg.CXB; + status["CXB"] = heartUpMsg.CXB; status["DLCompleted"] = (heartUpMsg.DLTJ >> 4 & 1) == 1; if (RTrig.GetInstance("打料完成检测").Start((bool)status["DLCompleted"])) @@ -195,7 +201,7 @@ namespace BPASmartClient.GSIceCream { MessageLog.GetInstance.Show("打料中"); } - Thread.Sleep(1000); + Thread.Sleep(100); } private void ProcessModeUp(ICMSG_MODE_UP modeUpMsg) diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs index a2c3237e..675eafab 100644 --- a/BPASmartClient.MorkT/Control_MorkT.cs +++ b/BPASmartClient.MorkT/Control_MorkT.cs @@ -39,7 +39,12 @@ namespace BPASmartClient.MorkT if (morkT.MakeCoffeeOrder != null) morkT.MakeCoffeeOrder.OrderStatus = 1; }); - + int i = 0; + ////ThreadManage.GetInstance().StartLong(new Action(() => + ////{ + //// i = (int)Status.status["GSIceCream.IceCreamMachine.test"]; + + ////}),"test"); MessageLog.GetInstance.Show("MORKT 设备初始化完成"); @@ -51,8 +56,31 @@ namespace BPASmartClient.MorkT morkT = new GLV_MorkT(); } + + private void GetStatus(string key, Action action) + { + if (peripheralStatus.ContainsKey(key)) + { + if (peripheralStatus[key] != null) + { + action?.Invoke(peripheralStatus[key]); + } + } + } + public override void MainTask() { + + GetStatus("RobotMode", new Action((o) => + { + + + })); + + + + + MakeCoffeeProcess(); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=> { @@ -60,7 +88,6 @@ namespace BPASmartClient.MorkT { if(!resultValue)//取餐口有空余位置 { - MakeIceCreamProcess(); MakeCoffeeComplete(); } @@ -196,7 +223,7 @@ namespace BPASmartClient.MorkT private void Wait(int value = 101) { - while (!((bool)Status.status["OK"] && (int)Status.status["Value"] == value)) + while (!((bool)Status.status["Lebai.LebaiRobot.OK"] && (int)Status.status["Lebai.LebaiRobot.Value"] == value)) { Thread.Sleep(5); } @@ -284,7 +311,7 @@ namespace BPASmartClient.MorkT Thread.Sleep(500); DeviceProcessLogShow("尝试取咖啡杯!"); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); - int count = 2; + int count = 1; bool result = true; p: EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10033 }); //SENCE_咖啡杯检测 @@ -337,14 +364,14 @@ namespace BPASmartClient.MorkT { if (IceCreamCanMake()) { - if(Status.status.ContainsKey("CurrentMode")) + if(Status.status.ContainsKey("GSIceCream.IceCreamMachine.CurrentMode")) { - if ((MORKI_MODE)Status.status["CurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); + if ((MORKI_MODE)Status.status["GSIceCream.IceCreamMachine.CurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); } - if(Status.status.ContainsKey("CBX")) + if(Status.status.ContainsKey("GSIceCream.IceCreamMachine.CBX")) { - if ((short)Status.status["CBX"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 + if ((short)Status.status["GSIceCream.IceCreamMachine.CBX"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 { bool result = true; EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => @@ -464,7 +491,7 @@ namespace BPASmartClient.MorkT { int count_1 = 0; - while ((short)Status.status["CBX"] <= 86) + while ((short)Status.status["GSIceCream.IceCreamMachine.CBX"] <= 86) { Thread.Sleep(5); count_1++; diff --git a/BPASmartClient.MorkT/GLV_MorkT.cs b/BPASmartClient.MorkT/GLV_MorkT.cs index e7280c8a..ae54fd74 100644 --- a/BPASmartClient.MorkT/GLV_MorkT.cs +++ b/BPASmartClient.MorkT/GLV_MorkT.cs @@ -1,4 +1,5 @@ -using Robotc; +using BPASmartClient.Device; +using Robotc; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -8,7 +9,7 @@ using System.Threading.Tasks; namespace BPASmartClient.MorkT { - public class GLV_MorkT + public class GLV_MorkT:IStatus { /// /// 咖啡订单队列 diff --git a/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs index 11e10381..df711d38 100644 --- a/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs +++ b/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs @@ -197,25 +197,25 @@ namespace BPASmartClient.MorkT.ViewModel if (CurrentData != null && CurrentData.Count != 0) { RobotConnected = (bool)CurrentData["Lebai.LebaiRobot.IsConnected"] ? "已连接" : "未连接"; - IceCreamConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接"; - CoffeeConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接"; + //IceCreamConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接"; + //CoffeeConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接"; RobotMode = (ELebaiRModel)CurrentData["Lebai.LebaiRobot.RobotMode"]; - CoffeeStatus = (DrCoffeeStatus)CurrentData["DRCoffee.CoffeeMachine.Status"]; - AppStatus = (DrCoffeeAppStatus)CurrentData["DRCoffee.CoffeeMachine.AppStatus"]; - Warning = (DrCoffeeWarning)CurrentData["DRCoffee.CoffeeMachine.Warning"]; - CaffeeFault = (DrCoffeeFault)CurrentData["DRCoffee.CoffeeMachine.Fault"]; - - YLWD = (short)CurrentData["GSIceCream.IceCreamMachine.YLWD"]; - HQWD = (short)CurrentData["GSIceCream.IceCreamMachine.HQWD"]; - HJWD = (short)CurrentData["GSIceCream.IceCreamMachine.HJWD"]; - DL = (short)CurrentData["GSIceCream.IceCreamMachine.DL"]; - DY = (short)CurrentData["GSIceCream.IceCreamMachine.DY"]; - CurrentMode = (MORKI_MODE)CurrentData["GSIceCream.IceCreamMachine.CurrentMode"]; - IceCreamFault = (MORKI_FAULT)CurrentData["GSIceCream.IceCreamMachine.Fault"]; - CXB = (byte)CurrentData["GSIceCream.IceCreamMachine.CXB"]; - DLCompleted = (bool)CurrentData["GSIceCream.IceCreamMachine.DLCompleted"] ? "打料完成" : "打料中"; + //CoffeeStatus = (DrCoffeeStatus)CurrentData["DRCoffee.CoffeeMachine.Status"]; + //AppStatus = (DrCoffeeAppStatus)CurrentData["DRCoffee.CoffeeMachine.AppStatus"]; + //Warning = (DrCoffeeWarning)CurrentData["DRCoffee.CoffeeMachine.Warning"]; + //CaffeeFault = (DrCoffeeFault)CurrentData["DRCoffee.CoffeeMachine.Fault"]; + + //YLWD = (short)CurrentData["GSIceCream.IceCreamMachine.YLWD"]; + //HQWD = (short)CurrentData["GSIceCream.IceCreamMachine.HQWD"]; + //HJWD = (short)CurrentData["GSIceCream.IceCreamMachine.HJWD"]; + //DL = (short)CurrentData["GSIceCream.IceCreamMachine.DL"]; + //DY = (short)CurrentData["GSIceCream.IceCreamMachine.DY"]; + //CurrentMode = (MORKI_MODE)CurrentData["GSIceCream.IceCreamMachine.CurrentMode"]; + //IceCreamFault = (MORKI_FAULT)CurrentData["GSIceCream.IceCreamMachine.Fault"]; + //CXB = (byte)CurrentData["GSIceCream.IceCreamMachine.CXB"]; + //DLCompleted = (bool)CurrentData["GSIceCream.IceCreamMachine.DLCompleted"] ? "打料完成" : "打料中"; } Thread.Sleep(500);