diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 5ab4bd64..d712bfdf 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -12,6 +12,7 @@ + @@ -172,6 +173,7 @@ + diff --git a/BPASmartClient.DRCoffee/CoffeeMachine.cs b/BPASmartClient.DRCoffee/CoffeeMachine.cs index e897453f..e1874dd0 100644 --- a/BPASmartClient.DRCoffee/CoffeeMachine.cs +++ b/BPASmartClient.DRCoffee/CoffeeMachine.cs @@ -141,14 +141,13 @@ namespace BPASmartClient.DRCoffee /// public void ProcessPackage(DrCoffeePackage package) { - + lastRefreshTime = DateTime.Now; + IsConnected = OnLine; + status["CoffeeIsConnected"] = OnLine; if (((DrCoffeeStatus)status["CoffeeStatus"]) == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running) { status["CoffeeStatus"] = package.Status; - lastRefreshTime = DateTime.Now; - IsConnected = OnLine; - status["CoffeConnected"] = OnLine; - new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }.Publish(); + EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }); } else status["CoffeeStatus"] = package.Status; status["CoffeeAppStatus"] = package.ApplicationStatus; diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index 8055356d..60943f21 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -325,7 +325,7 @@ namespace BPASmartClient.Device { MainTask(); Thread.Sleep(10); - }), $"MainTask:{DeviceId}"); + }) ,$"MainTask:{DeviceId}",true); #endregion #region 设备状态监控 diff --git a/BPASmartClient.IoT/DataVClient.cs b/BPASmartClient.IoT/DataVClient.cs index c4ca8862..a0315030 100644 --- a/BPASmartClient.IoT/DataVClient.cs +++ b/BPASmartClient.IoT/DataVClient.cs @@ -35,8 +35,7 @@ namespace BPASmartClient.IoT public DataVClient() { DataVApiAddress = InternetInfo.DataVApiAddress; - //ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); - ClientId = Plugin.GetInstance().GetPlugin().ClientId.ToString(); + ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"].ToString(); ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"].ToString(); DeviceSecret = System.Configuration.ConfigurationManager.AppSettings["DeviceSecret"].ToString(); diff --git a/BPASmartClient.Lebai/LebaiRobot.cs b/BPASmartClient.Lebai/LebaiRobot.cs index 721cc893..945029ea 100644 --- a/BPASmartClient.Lebai/LebaiRobot.cs +++ b/BPASmartClient.Lebai/LebaiRobot.cs @@ -48,7 +48,7 @@ namespace BPASmartClient.Lebai status["RobotIsConnected"] = LebaiHelper.GetInstance().IsConnected; status["RobotOK"] = LebaiHelper.GetInstance().GetValueAsync().Ok; status["RobotValue"] = LebaiHelper.GetInstance().GetValueAsync().Value; - if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode; + if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] =(ELebaiRModel)LebaiHelper.GetInstance().robotData.RobotMode.Mode; LebaiHelper.GetInstance().GetRobotModeStatus(); Thread.Sleep(10); },"获取乐白机器人数据"); diff --git a/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj b/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj index 08d23ce9..e3705e10 100644 --- a/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj +++ b/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj @@ -9,6 +9,7 @@ + diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs index 53d67dd1..247f2c7e 100644 --- a/BPASmartClient.MorkT/Control_MorkT.cs +++ b/BPASmartClient.MorkT/Control_MorkT.cs @@ -45,7 +45,7 @@ namespace BPASmartClient.MorkT morkT.MakeCoffeeOrder.OrderStatus = 1; }); int i = 0; - + EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); MessageLog.GetInstance.Show("MORKT 设备初始化完成"); @@ -71,7 +71,21 @@ namespace BPASmartClient.MorkT public override void MainTask() { - + if (morkT.waitMorkOrder != null)//更新订单取走状态 + { + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (o) => + { + if (o != null && o.Length > 0 && o[0] is bool res) + { + if (!res) + { + OrderChange(morkT.waitMorkOrder.SuborderId, ORDER_STATUS.COMPLETED_TAKE); + DeviceProcessLogShow("订单取餐完成"); + morkT.waitMorkOrder = null; + } + } + }); + } MakeCoffeeProcess(); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=> { @@ -84,7 +98,8 @@ namespace BPASmartClient.MorkT } } }); - + + } public override void ReadData() @@ -371,6 +386,7 @@ namespace BPASmartClient.MorkT { DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); GetAndCheeckCoffe(orderLoc);//取咖啡杯 + if (!morkT.GetCoffeeCup) return; EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点 Wait(); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); @@ -380,6 +396,7 @@ namespace BPASmartClient.MorkT } } + } @@ -411,6 +428,7 @@ namespace BPASmartClient.MorkT EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); //订单状态改变:完成 OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); + morkT.waitMorkOrder = order; DeviceProcessLogShow($"{order.GoodsName}等待取餐"); //WaitTakeMealOrder.Enqueue(order); @@ -454,6 +472,7 @@ namespace BPASmartClient.MorkT EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点 Wait(); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + morkT.GetCoffeeCup = false; return; } DeviceProcessLogShow("执行二次取咖啡杯"); @@ -464,6 +483,7 @@ namespace BPASmartClient.MorkT count++; goto p; } + morkT.GetCoffeeCup = true; DeviceProcessLogShow("取咖啡杯完成"); } @@ -482,40 +502,45 @@ namespace BPASmartClient.MorkT /// private void MakeIceCreamProcess() { - if (IceCreamCanMake()) - { - if(peripheralStatus.ContainsKey("IceCreamCurrentMode")) - { - if ((MORKI_MODE)peripheralStatus["IceCreamCurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); - } - - if(peripheralStatus.ContainsKey("IceCreamCXB")) - { - if ((byte)peripheralStatus["IceCreamCXB"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 - { - bool result = true; - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => - { - if (res[0] is bool resultValue) - { - result = resultValue; - } - }); - if (result) - { - if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡"); - morkT.IceIsOK = false; - } - else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) - { - morkT.IceIsOK = true; - DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]"); - DoIceCream(order); - } - } - } - - } + //if (IceCreamCanMake()) + //{ + if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) + { + DoIceCream(order); + } + + //if(peripheralStatus.ContainsKey("IceCreamCurrentMode")) + //{ + // if ((MORKI_MODE)peripheralStatus["IceCreamCurrentMode"] != MORKI_MODE.制冷模式) EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); + //} + + //if(peripheralStatus.ContainsKey("IceCreamCXB")) + //{ + // if ((byte)peripheralStatus["IceCreamCXB"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 + // { + // bool result = true; + // EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => + // { + // if (res[0] is bool resultValue) + // { + // result = resultValue; + // } + // }); + // if (result) + // { + // if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡"); + // morkT.IceIsOK = false; + // } + // else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) + // { + // morkT.IceIsOK = true; + // DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]"); + // DoIceCream(order); + // } + // } + //} + + //} } @@ -526,8 +551,12 @@ namespace BPASmartClient.MorkT { GetIceCreamCup(); CheckICeCreaCup(); - GetIceCream(order); - PutIceCream(order); + if(morkT.GetIceCreamCup) + { + GetIceCream(order); + PutIceCream(order); + } + } /// @@ -572,6 +601,7 @@ namespace BPASmartClient.MorkT EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点 Wait(); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + morkT.GetIceCreamCup = false; return; } DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); @@ -582,6 +612,7 @@ namespace BPASmartClient.MorkT count++; goto p; } + morkT.GetIceCreamCup = true; DeviceProcessLogShow("冰淇淋杯检测完成"); } @@ -592,34 +623,43 @@ namespace BPASmartClient.MorkT private void GetIceCream(OrderLocInfo order) { //制冷模式 - EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); + //EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); OrderChange(order.SuborderId, ORDER_STATUS.COOKING); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10039 }); //SENCE_接1号冰淇淋 Wait(); bool doItResult = true; + //出料 - EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId },(o)=> - { - doItResult = (bool)o[0]; - }); - if (doItResult) - { - IceCreamCookCheck(); - } - else - { - int count_1 = 0; + EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = true }); + Thread.Sleep(500); + EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = false }); + EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId ,SteeringEngine = IC_SE.SE_2 });//冰淇淋出料 + DeviceProcessLogShow("开始等待6s"); + Thread.Sleep(6000); - while ((byte)peripheralStatus["IceCreamCXB"] <= 86) - { - Thread.Sleep(5); - count_1++; - if (count_1 >= 2000) - break; - } - IceCreamCookCheck(); - } + //出料 + //EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId },(o)=> + //{ + // doItResult = (bool)o[0]; + //}); + //if (doItResult) + //{ + // IceCreamCookCheck(); + //} + //else + //{ + // int count_1 = 0; + + // while ((byte)peripheralStatus["IceCreamCXB"] <= 86) + // { + // Thread.Sleep(5); + // count_1++; + // if (count_1 >= 2000) + // break; + // } + // IceCreamCookCheck(); + //} EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); } @@ -629,21 +669,25 @@ namespace BPASmartClient.MorkT /// private void PutIceCream(OrderLocInfo order) { - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) => + bool resultValue = true; + while (resultValue) { - if (res[0] is bool resultValue) + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) => { - while (resultValue) + if (res[0] is bool b) { - Thread.Sleep(500); + resultValue = b; } - } - }); + }); + Thread.Sleep(500); + } + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10043 }); //SENCE_放冰淇淋位置 Wait(); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); //订单状态改变:完成 OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); + morkT.waitMorkOrder = order; DeviceProcessLogShow($"{order.GoodsName}等待取餐"); //WaitTakeMealOrder.Enqueue(order); diff --git a/BPASmartClient.MorkT/GLV_MorkT.cs b/BPASmartClient.MorkT/GLV_MorkT.cs index c825bbd2..f124da95 100644 --- a/BPASmartClient.MorkT/GLV_MorkT.cs +++ b/BPASmartClient.MorkT/GLV_MorkT.cs @@ -25,6 +25,10 @@ namespace BPASmartClient.MorkT /// public ConcurrentQueue morkOrderPushesIceCream = new ConcurrentQueue(); /// + /// 等待取餐订单 + /// + public OrderLocInfo waitMorkOrder = null; + /// /// 物料存放位置 /// public Dictionary batchings = new Dictionary(); @@ -44,6 +48,14 @@ namespace BPASmartClient.MorkT /// 冰淇淋机器出料口传感器检测 /// public bool IceIsOK = true; + /// + /// 去咖啡杯成功 + /// + public bool GetCoffeeCup; + /// + /// 取冰淇淋杯成功 + /// + public bool GetIceCreamCup; #region diff --git a/BPASmartClient.MorkT/View/DebugView.xaml b/BPASmartClient.MorkT/View/DebugView.xaml index 5a23087b..db1ee199 100644 --- a/BPASmartClient.MorkT/View/DebugView.xaml +++ b/BPASmartClient.MorkT/View/DebugView.xaml @@ -6,7 +6,7 @@ xmlns:vm ="clr-namespace:BPASmartClient.MorkT.ViewModel" mc:Ignorable="d" Name="调试界面" - d:DesignHeight="450" d:DesignWidth="1000" > + d:DesignHeight="500" d:DesignWidth="1000" Unloaded="Dubug_Unloaded"> @@ -20,12 +20,13 @@ - - + + - - + + + - @@ -172,7 +173,7 @@ - @@ -203,13 +204,13 @@ 咖啡机状态 - + Text="{Binding CoffeeStatus}" Height="23" /> 应用状态 + Text="{Binding AppStatus}" Height="23"/> 告警信息 + + + +