diff --git a/BPASmartClient.Lebai/LebaiRobot.cs b/BPASmartClient.Lebai/LebaiRobot.cs index 97ac0220..9c1f7e48 100644 --- a/BPASmartClient.Lebai/LebaiRobot.cs +++ b/BPASmartClient.Lebai/LebaiRobot.cs @@ -90,7 +90,7 @@ namespace BPASmartClient.Lebai if (@event == null) return; if (@event is LebaiRobot_SetValueEvent SetValueEvent) { - LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue); + callBack?.Invoke(LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue)); } }); //控制机器人 diff --git a/BPASmartClient.LebaiRobot/LebaiHelper.cs b/BPASmartClient.LebaiRobot/LebaiHelper.cs index 48d7d45b..91f68806 100644 --- a/BPASmartClient.LebaiRobot/LebaiHelper.cs +++ b/BPASmartClient.LebaiRobot/LebaiHelper.cs @@ -43,7 +43,7 @@ namespace BPASmartClient.LebaiRobot } } StartRobot(); - + Thread.Sleep(500); MessageLog.GetInstance.Show("乐百机器人连接成功!"); } /// @@ -70,12 +70,14 @@ namespace BPASmartClient.LebaiRobot try { - robotData = client.GetRobotData().Result; } + robotData = client.GetRobotData().Result; + } catch (Exception) { robotData = null; // throw; } + Thread.Sleep(10); } MessageLog.GetInstance.Show("乐白机器人断开连接,准备重连"); int num = 0; @@ -246,6 +248,7 @@ namespace BPASmartClient.LebaiRobot signalValue.Index = index; signalValue.Value = value; return client.SetSignal(signalValue).Result; + } /// diff --git a/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs b/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs index 00274358..42d7557e 100644 --- a/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs +++ b/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs @@ -28,6 +28,10 @@ namespace BPASmartClient.Model.乐白机器人.Enum public const int SENCE_咖啡杯回原点 = 10050; public const int SENCE_冰淇淋杯回原点 = 10049; public const int SENCE_取咖啡出餐 = 10052; + + // 单片机冰淇淋机器场景 + public const int SENCE_单片机接冰淇淋 = 10055; + public const int SENCE_单片机放冰淇淋位置 = 10056; #endregion } } diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs index 247f2c7e..a9a6bbee 100644 --- a/BPASmartClient.MorkT/Control_MorkT.cs +++ b/BPASmartClient.MorkT/Control_MorkT.cs @@ -13,6 +13,7 @@ using BPASmartClient.Model.冰淇淋.Enum; using BPASmartClient.Model.单片机; using BPASmartClient.Model.单片机.Enum; using BPASmartClient.Peripheral; +using Robotc; using System; using System.Collections.Generic; using System.Linq; @@ -231,6 +232,13 @@ namespace BPASmartClient.MorkT morkT.CaffeeFault = coffeeFault; } })); + GetStatus("SCChipIsConnect", new Action((o) => + { + if (o is bool b) + { + morkT.SCChipIsConnect = b; + } + })); } @@ -389,7 +397,7 @@ namespace BPASmartClient.MorkT 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 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() {DeviceId = DeviceId, DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) });//接咖啡控制 DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!"); morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc; @@ -425,7 +433,7 @@ namespace BPASmartClient.MorkT { EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10052 }); //SENCE_取咖啡出餐 Wait(); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); //订单状态改变:完成 OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); morkT.waitMorkOrder = order; @@ -440,7 +448,7 @@ namespace BPASmartClient.MorkT /// private void GetAndCheeckCoffe(OrderLocInfo order) { - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 },(o)=>{ }); OrderChange(order.SuborderId, ORDER_STATUS.COOKING); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10031 }); //SENCE_取咖啡杯 @@ -448,13 +456,13 @@ namespace BPASmartClient.MorkT EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId= DeviceId ,Cup = IC_CUP.CUP_COFFEE});//落碗控制 Thread.Sleep(500); DeviceProcessLogShow("尝试取咖啡杯!"); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); int count = 1; bool result = true; p: EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10033 }); //SENCE_咖啡杯检测 Wait(); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o)=> { if(o != null && o.Length > 0 && o[0] is bool resultValue) @@ -471,7 +479,7 @@ namespace BPASmartClient.MorkT DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!"); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点 Wait(); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); morkT.GetCoffeeCup = false; return; } @@ -479,7 +487,7 @@ namespace BPASmartClient.MorkT EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10035 }); //SENCE_二次取咖啡杯 Wait(); EventBus.EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); count++; goto p; } @@ -564,7 +572,8 @@ namespace BPASmartClient.MorkT /// private void GetIceCreamCup() { - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); + MessageLog.GetInstance.Show("准备开始制作冰淇淋"); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { }); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10032 }); //SENCE_取冰淇淋杯 Wait(); EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制 @@ -580,11 +589,30 @@ namespace BPASmartClient.MorkT { int count = 2; bool result = true; - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); p: EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10034 }); //SENCE_冰淇淋杯检测 Wait(); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + Thread.Sleep(500); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => + { + if (o != null && o.Length > 0 && o[0] is SignalResult res) + { + MessageLog.GetInstance.Show(res.ToString()); + } + }); + while((int)peripheralStatus["RobotValue"] != 0) + { + Thread.Sleep(10); + } + MessageLog.GetInstance.Show($"乐白机器人信号值{peripheralStatus["RobotValue"].ToString()}"); + + //while ((ELebaiRModel)peripheralStatus["RobotMode"] !=ELebaiRModel.空闲状态) + //{ + // EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + // Thread.Sleep(500); + //} + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o) => { if (o != null && o.Length > 0 && o[0] is bool resultValue) @@ -600,7 +628,7 @@ namespace BPASmartClient.MorkT DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!"); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点 Wait(); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 },(o) => { }); morkT.GetIceCreamCup = false; return; } @@ -608,7 +636,7 @@ namespace BPASmartClient.MorkT EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10036 }); //SENCE_二次取冰淇淋杯 EventBus.EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制 Wait(); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); count++; goto p; } @@ -624,9 +652,9 @@ namespace BPASmartClient.MorkT { //制冷模式 //EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { }); OrderChange(order.SuborderId, ORDER_STATUS.COOKING); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10039 }); //SENCE_接1号冰淇淋 + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10055 }); //SENCE_接1号冰淇淋 Wait(); bool doItResult = true; @@ -634,9 +662,10 @@ namespace BPASmartClient.MorkT 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 });//冰淇淋出料 + Thread.Sleep(500); + EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId, SteeringEngine = IC_SE.SE_2 });//冰淇淋出料 DeviceProcessLogShow("开始等待6s"); - Thread.Sleep(6000); + Thread.Sleep(5000); //出料 //EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId },(o)=> @@ -660,7 +689,7 @@ namespace BPASmartClient.MorkT // } // IceCreamCookCheck(); //} - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); } /// @@ -682,9 +711,9 @@ namespace BPASmartClient.MorkT Thread.Sleep(500); } - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10043 }); //SENCE_放冰淇淋位置 + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10056 }); //SENCE_放冰淇淋位置 Wait(); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); //订单状态改变:完成 OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); morkT.waitMorkOrder = order; diff --git a/BPASmartClient.MorkT/GLV_MorkT.cs b/BPASmartClient.MorkT/GLV_MorkT.cs index f124da95..e9590531 100644 --- a/BPASmartClient.MorkT/GLV_MorkT.cs +++ b/BPASmartClient.MorkT/GLV_MorkT.cs @@ -110,6 +110,9 @@ namespace BPASmartClient.MorkT [VariableMonitor("咖啡机故障")] public DrCoffeeFault CaffeeFault { get; set; } + [VariableMonitor("单片机连接状态")] + public bool SCChipIsConnect { get; set; } + #endregion } } diff --git a/BPASmartClient.MorkT/View/DebugView.xaml b/BPASmartClient.MorkT/View/DebugView.xaml index db1ee199..d872528a 100644 --- a/BPASmartClient.MorkT/View/DebugView.xaml +++ b/BPASmartClient.MorkT/View/DebugView.xaml @@ -25,7 +25,7 @@ - + @@ -82,7 +82,7 @@ - @@ -172,7 +172,50 @@ + --> + + + + + + + + + + + + + + + + + + + /// + + public RelayCommand Button_SetValueCommand { get; set; } + + private void Button_SetValue() + { + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + } private void Button_RobotControl(object o) { EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() }); @@ -187,6 +194,11 @@ namespace BPASmartClient.MorkT.ViewModel #region 单片机 /// + /// 单片机连接状态 + /// + public string SCChipIsConnect { get { return _sCChipIsConnect; } set { _sCChipIsConnect = value; OnPropertyChanged(); } } + private string _sCChipIsConnect { get; set; } + /// /// 咖啡杯或冰淇淋杯落杯 /// public RelayCommand Button_CupControlCommand { get; set; } @@ -235,6 +247,8 @@ namespace BPASmartClient.MorkT.ViewModel public DebugViewModel() { Button_RobotControlCommand = new RelayCommand(Button_RobotControl); + Button_SetValueCommand = new RelayCommand(Button_SetValue); + Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel); @@ -274,9 +288,6 @@ namespace BPASmartClient.MorkT.ViewModel if (device.Name == "MorkT") DeviceId = device.DeviceId ; }); - - - ThreadManage.GetInstance().StartLong(new Action(() => { @@ -287,6 +298,7 @@ namespace BPASmartClient.MorkT.ViewModel RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接"; IceCreamConnected = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋连接状态").CurrentValue == "True" ? "已连接" : "未连接"; CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + SCChipIsConnect = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue; diff --git a/BPASmartClient.MorkT_HQ/BPASmartClient.MorkT_HQ.csproj b/BPASmartClient.MorkT_HQ/BPASmartClient.MorkT_HQ.csproj new file mode 100644 index 00000000..58a91183 --- /dev/null +++ b/BPASmartClient.MorkT_HQ/BPASmartClient.MorkT_HQ.csproj @@ -0,0 +1,54 @@ + + + + net6.0-windows + enable + true + bin\ + portable + + + + + + + + + + + + + + + + + + + + + Code + + + Code + + + Code + + + + + + $(DefaultXamlRuntime) + Designer + + + $(DefaultXamlRuntime) + Designer + + + $(DefaultXamlRuntime) + Designer + + + + diff --git a/BPASmartClient.MorkT_HQ/Control_MorkT.cs b/BPASmartClient.MorkT_HQ/Control_MorkT.cs new file mode 100644 index 00000000..a9a6bbee --- /dev/null +++ b/BPASmartClient.MorkT_HQ/Control_MorkT.cs @@ -0,0 +1,762 @@ +using BPA.Message.Enum; +using BPASmartClient.Device; +using BPASmartClient.DRCoffee; +using BPASmartClient.EventBus; +using BPASmartClient.GSIceCream; +using BPASmartClient.Helper; +using BPASmartClient.Lebai; +using BPASmartClient.LebaiRobot; +using BPASmartClient.Message; +using BPASmartClient.Model; +using BPASmartClient.Model.乐白机器人; +using BPASmartClient.Model.冰淇淋.Enum; +using BPASmartClient.Model.单片机; +using BPASmartClient.Model.单片机.Enum; +using BPASmartClient.Peripheral; +using Robotc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using static BPASmartClient.EventBus.EventBus; + +namespace BPASmartClient.MorkT +{ + public class Control_MorkT : BaseDevice + { + public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } } + + GLV_MorkT morkT = new GLV_MorkT(); + + + public override void DoMain() + { + if(Json.Data.IsVerify) + { + IsHealth = true; + } + IsHealth = true; + ServerInit(); + DataParse(); + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (morkT.MakeCoffeeOrder != null) + morkT.MakeCoffeeOrder.OrderStatus = 1; + }); + int i = 0; + EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); + + MessageLog.GetInstance.Show("MORKT 设备初始化完成"); + + } + + public override void ResetProgram() + { + morkT = null; + 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() + { + 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)=> + { + if(o != null && o.Length > 0 && o[0] is bool resultValue) + { + if(!resultValue)//取餐口有空余位置 + { + MakeIceCreamProcess(); + MakeCoffeeComplete(); + } + } + }); + + + } + + public override void ReadData() + { + GetStatus("RobotIsConnected", new Action((o) => + { + if (o is bool b) + { + morkT.RobotIsConnected = b; + } + })); + + GetStatus("RobotMode", new Action((o) => + { + if (o is ELebaiRModel eLebaiRModel) + { + morkT.RobotMode = eLebaiRModel; + } + })); + + + GetStatus("IceCreamIsConnected", new Action((o) => + { + if (o is bool b) + { + morkT.IceCreamIsConnected = b; + } + })); + + GetStatus("IceCreamYLWD", new Action((o) => + { + if (o is short s) + { + morkT.YLWD = s; + } + })); + + GetStatus("IceCreamHQWD", new Action((o) => + { + if (o is short s) + { + morkT.HQWD = s; + } + })); + + GetStatus("IceCreamDL", new Action((o) => + { + if (o is short s) + { + morkT.DL = s; + } + })); + + GetStatus("IceCreamDY", new Action((o) => + { + if (o is short s) + { + morkT.DY = s; + } + })); + + GetStatus("IceCreamCXB", new Action((o) => + { + if (o is byte bt) + { + morkT.CBX = bt; + } + })); + + GetStatus("IceCreamCurrentMode", new Action((o) => + { + if (o is MORKI_MODE mORKI_MODE) + { + morkT.IceCreamMode = mORKI_MODE; + } + })); + + GetStatus("IceCreamFault", new Action((o) => + { + if (o is MORKI_FAULT mORKI_FAULT) + { + morkT.IceCreamFault = mORKI_FAULT; + } + })); + + GetStatus("IceCreamDLCompleted", new Action((o) => + { + if (o is bool b) + { + morkT.DLCompleted = b; + } + })); + + GetStatus("CoffeeIsConnected", new Action((o) => + { + if (o is bool b) + { + morkT.CoffeeIsConnected = b; + } + })); + + GetStatus("CoffeeStatus", new Action((o) => + { + if (o is DrCoffeeStatus coffeeStatus) + { + morkT.DrCoffeeStatus = coffeeStatus; + } + })); + + GetStatus("CoffeeAppStatus", new Action((o) => + { + if (o is DrCoffeeAppStatus appStatus) + { + morkT.CoffeeAppStatus = appStatus; + } + })); + + GetStatus("CoffeeWarning", new Action((o) => + { + if (o is DrCoffeeWarning coffeeWarning) + { + morkT.CoffeeWarning = coffeeWarning; + } + })); + GetStatus("CoffeeFault", new Action((o) => + { + if (o is DrCoffeeFault coffeeFault) + { + morkT.CaffeeFault = coffeeFault; + } + })); + GetStatus("SCChipIsConnect", new Action((o) => + { + if (o is bool b) + { + morkT.SCChipIsConnect = b; + } + })); + } + + + + public override void Stop() + { + } + + + private void ServerInit() + { + //物料信息 + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (@event == null) return; + if (@event is MaterialDeliveryEvent material) + { + orderMaterialDelivery = material.orderMaterialDelivery; + } + }); + + //配方数据信息 + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (@event == null) return; + if (@event is RecipeBomEvent recipe) + { + recipeBoms = recipe.recipeBoms; + } + }); + } + + /// + /// 数据解析 + /// + private void DataParse() + { + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + if (@event == null) return; + if (@event is DoOrderEvent order) + { + if (order.MorkOrder.GoodBatchings == null) return; + OrderCount++; + DeviceProcessLogShow($"接收到{OrderCount}次订单"); + //构建所有商品物料信息 + morkT.batchings = PolymerBatching.BuildAll(); + //商品类型 + GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER; + + foreach (var item in order.MorkOrder.GoodBatchings) + { + var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + if (res != null) + { + //验证商品是咖啡还是冰淇淋 + if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER) + { + //获取当前物料所属商品类型 + currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); + } + string loc_Goods = string.Empty; + //获取主料和容器位置 + if (morkT.batchings[res.BatchingLoc].BatchingClass == BATCHING_CLASS.MAIN_MATERIAL) loc_Goods = res.BatchingLoc; + if (!string.IsNullOrEmpty(loc_Goods)) + { + switch (currentGoodsType) + { + case GOODS_TYPE.COFFEE: + if (morkT.morkOrderPushesCoffee.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + { + morkT.morkOrderPushesCoffee.Enqueue(new OrderLocInfo() + { + SuborderId = order.MorkOrder.SuborderId, + BatchingId = res.BatchingId, + Loc = loc_Goods, + GoodsName = order.MorkOrder.GoodsName, + SortNum = order.MorkOrder.SortNum + }); + } + break; + case GOODS_TYPE.ICECREAM: + if (morkT.morkOrderPushesIceCream.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + { + morkT.morkOrderPushesIceCream.Enqueue(new OrderLocInfo() + { + SuborderId = order.MorkOrder.SuborderId, + BatchingId = res.BatchingId, + Loc = loc_Goods, + GoodsName = order.MorkOrder.GoodsName, + SortNum = order.MorkOrder.SortNum + }); + } + break; + case GOODS_TYPE.NEITHER: + DeviceProcessLogShow("未知的商品类型"); + break; + } + } + + } + } + + } + }); + } + /// + /// 验证当前是做咖啡还是做冰淇淋 + /// + /// 物料位置 + private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc) + { + if (morkT.batchings.ContainsKey(batchingLoc)) + return morkT.batchings[batchingLoc].GoodsType; + return GOODS_TYPE.NEITHER; + } + + + + + private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) + { + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); + } + + private void Wait(int value = 101) + { + while (!((bool)peripheralStatus["RobotOK"] && (int)peripheralStatus["RobotValue"] == value)) + { + Thread.Sleep(5); + } + } + + /// + /// 是否可以开始制作咖啡 + /// + /// + private bool CoffeeCanMake() + { + bool canMake = (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsCoffeeMake) ? true : false; + return canMake; + + } + + /// + /// 制作咖啡流程 + /// + private void MakeCoffeeProcess() + { + if (CoffeeCanMake()) + { + if (morkT.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc)) + { + 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 }, (o) => { }); + EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() {DeviceId = DeviceId, DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) });//接咖啡控制 + DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!"); + morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc; + } + + } + + + + } + /// + /// 咖啡机制作完咖啡,取走并放到取餐口,最后回原点 + /// + private void MakeCoffeeComplete() + { + if (morkT.IsCoffeeMake && IsHealth) + { + if (morkT.MakeCoffeeOrder != null && morkT.MakeCoffeeOrder.OrderStatus == 1) + { + DeviceProcessLogShow($"将咖啡移动到取餐位 [咖啡] 订单[{morkT.MakeCoffeeOrder.SortNum}]"); + DoCoffeeQC(morkT.MakeCoffeeOrder); + morkT.MakeCoffeeOrder = null; + morkT.IsCoffeeMake = false; + } + } + } + + + /// + /// 将咖啡杯从咖啡机 取走到 取餐口 + /// + private void DoCoffeeQC(OrderLocInfo order) + { + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10052 }); //SENCE_取咖啡出餐 + Wait(); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); + //订单状态改变:完成 + OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); + morkT.waitMorkOrder = order; + DeviceProcessLogShow($"{order.GoodsName}等待取餐"); + //WaitTakeMealOrder.Enqueue(order); + + } + + /// + /// 取咖啡杯&&咖啡杯检测 若检测失败机器人回原点 + /// + /// + private void GetAndCheeckCoffe(OrderLocInfo order) + { + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 },(o)=>{ }); + OrderChange(order.SuborderId, ORDER_STATUS.COOKING); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10031 }); //SENCE_取咖啡杯 + + Wait(); + EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId= DeviceId ,Cup = IC_CUP.CUP_COFFEE});//落碗控制 + Thread.Sleep(500); + DeviceProcessLogShow("尝试取咖啡杯!"); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); + int count = 1; + bool result = true; + p: + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10033 }); //SENCE_咖啡杯检测 + Wait(); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o)=> + { + if(o != null && o.Length > 0 && o[0] is bool resultValue) + { + result = resultValue; + } + }); + + if (!result) + { + if (count >= 3) + { + //退出循环回到初始位置 + DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!"); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点 + Wait(); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); + morkT.GetCoffeeCup = false; + return; + } + DeviceProcessLogShow("执行二次取咖啡杯"); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10035 }); //SENCE_二次取咖啡杯 + Wait(); + EventBus.EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); + count++; + goto p; + } + morkT.GetCoffeeCup = true; + DeviceProcessLogShow("取咖啡杯完成"); + } + + /// + /// 冰淇淋是否可以开始制作 + /// + /// + private bool IceCreamCanMake() + { + bool canMake = (IsHealth && morkT.morkOrderPushesIceCream.Count > 0) ? true : false; + return canMake; + } + + /// + /// 制作冰淇淋流程 + /// + private void MakeIceCreamProcess() + { + //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); + // } + // } + //} + + //} + } + + + /// + /// 做冰淇淋 + /// + private void DoIceCream(OrderLocInfo order) + { + GetIceCreamCup(); + CheckICeCreaCup(); + if(morkT.GetIceCreamCup) + { + GetIceCream(order); + PutIceCream(order); + } + + } + + /// + /// 取冰淇淋杯 + /// + private void GetIceCreamCup() + { + MessageLog.GetInstance.Show("准备开始制作冰淇淋"); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10032 }); //SENCE_取冰淇淋杯 + Wait(); + EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制 + Thread.Sleep(500); + DeviceProcessLogShow("尝试取冰淇淋杯!"); + + } + + /// + /// 冰淇淋杯检测,失败后机器人回到原点 + /// + private void CheckICeCreaCup() + { + int count = 2; + bool result = true; + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); + p: + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10034 }); //SENCE_冰淇淋杯检测 + Wait(); + Thread.Sleep(500); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => + { + if (o != null && o.Length > 0 && o[0] is SignalResult res) + { + MessageLog.GetInstance.Show(res.ToString()); + } + }); + while((int)peripheralStatus["RobotValue"] != 0) + { + Thread.Sleep(10); + } + MessageLog.GetInstance.Show($"乐白机器人信号值{peripheralStatus["RobotValue"].ToString()}"); + + //while ((ELebaiRModel)peripheralStatus["RobotMode"] !=ELebaiRModel.空闲状态) + //{ + // EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); + // Thread.Sleep(500); + //} + + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o) => + { + if (o != null && o.Length > 0 && o[0] is bool resultValue) + { + result = resultValue; + } + }); + if (!result) + { + if (count >= 3) + { + //退出循环回到初始位置 + DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!"); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点 + Wait(); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 },(o) => { }); + morkT.GetIceCreamCup = false; + return; + } + DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10036 }); //SENCE_二次取冰淇淋杯 + EventBus.EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制 + Wait(); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); + count++; + goto p; + } + morkT.GetIceCreamCup = true; + DeviceProcessLogShow("冰淇淋杯检测完成"); + } + + /// + /// 机器人取接冰淇淋 + /// + /// + private void GetIceCream(OrderLocInfo order) + { + //制冷模式 + //EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { }); + OrderChange(order.SuborderId, ORDER_STATUS.COOKING); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10055 }); //SENCE_接1号冰淇淋 + Wait(); + bool doItResult = true; + + //出料 + 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 }); + Thread.Sleep(500); + EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId, SteeringEngine = IC_SE.SE_2 });//冰淇淋出料 + DeviceProcessLogShow("开始等待6s"); + Thread.Sleep(5000); + + //出料 + //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 }, (o) => { }); + } + + /// + /// 把冰淇淋放到取餐位后回原点 + /// + /// + private void PutIceCream(OrderLocInfo order) + { + bool resultValue = true; + while (resultValue) + { + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) => + { + if (res[0] is bool b) + { + resultValue = b; + } + }); + Thread.Sleep(500); + } + + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10056 }); //SENCE_放冰淇淋位置 + Wait(); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); + //订单状态改变:完成 + OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); + morkT.waitMorkOrder = order; + DeviceProcessLogShow($"{order.GoodsName}等待取餐"); + //WaitTakeMealOrder.Enqueue(order); + + } + + /// + /// 冰淇淋机器制作冰淇淋 + /// + public void IceCreamCookCheck() + { + bool result = false; + int retry = 3; + DateTime beginTime = DateTime.Now; + + while (!result) + { + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => + { + if (res[0] is bool resultValue) + { + result = resultValue; + } + }); + if (retry <= 0 || DateTime.Now.Subtract(beginTime).TotalSeconds >= 10) + { + DeviceProcessLogShow("超时未出料,重试次数用尽"); + break; + } + if (DateTime.Now.Subtract(beginTime).TotalSeconds > 5) + { + DeviceProcessLogShow("超时未出料,重新发送打料指令"); + EventBus.EventBus.GetInstance().Publish( new GSIceCream_ModeSetEvent() { DeviceId =DeviceId, Mode = MORKI_MODE.打料 }); + beginTime = DateTime.Now; + retry--; + } + Thread.Sleep(10); + } + DeviceProcessLogShow("开始等待6s"); + Thread.Sleep(5000); + + } + } +} diff --git a/BPASmartClient.MorkT_HQ/GLV_MorkT.cs b/BPASmartClient.MorkT_HQ/GLV_MorkT.cs new file mode 100644 index 00000000..e9590531 --- /dev/null +++ b/BPASmartClient.MorkT_HQ/GLV_MorkT.cs @@ -0,0 +1,118 @@ +using BPASmartClient.Device; +using BPASmartClient.DRCoffee; +using BPASmartClient.GSIceCream; +using BPASmartClient.LebaiRobot; +using BPASmartClient.Model.冰淇淋.Enum; +using Robotc; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkT +{ + public class GLV_MorkT:IStatus + { + /// + /// 咖啡订单队列 + /// + public ConcurrentQueue morkOrderPushesCoffee = new ConcurrentQueue(); + + /// + /// 冰淇淋订单队列 + /// + public ConcurrentQueue morkOrderPushesIceCream = new ConcurrentQueue(); + /// + /// 等待取餐订单 + /// + public OrderLocInfo waitMorkOrder = null; + /// + /// 物料存放位置 + /// + public Dictionary batchings = new Dictionary(); + + /// + /// 当前正在制作咖啡 + /// + public OrderLocInfo MakeCoffeeOrder = new OrderLocInfo(); + + + + /// + /// 咖啡机位置是否有咖啡在制作中 + /// + public bool IsCoffeeMake = false; + /// + /// 冰淇淋机器出料口传感器检测 + /// + public bool IceIsOK = true; + /// + /// 去咖啡杯成功 + /// + public bool GetCoffeeCup; + /// + /// 取冰淇淋杯成功 + /// + public bool GetIceCreamCup; + + #region + + [VariableMonitor("机器人连接状态")] + public bool RobotIsConnected { get; set; } + + [VariableMonitor("机器人状态")] + public ELebaiRModel RobotMode { get; set; } + + [VariableMonitor("冰淇淋连接状态")] + public bool IceCreamIsConnected { get; set; } + + [VariableMonitor("冰淇淋机器预冷温度")] + public short YLWD { get; set; } + + [VariableMonitor("冰淇淋机器回气温度")] + public short HQWD { get; set; } + + [VariableMonitor("冰淇淋机器环境温度")] + public short HJWD { get; set; } + + [VariableMonitor("冰淇淋机器电流")] + public short DL { get; set; } + + [VariableMonitor("冰淇淋机器电压")] + public short DY { get; set; } + + [VariableMonitor("冰淇淋机器成型比")] + public byte CBX { get; set; } + + [VariableMonitor("冰淇淋机器模式")] + public MORKI_MODE IceCreamMode { get; set; } + + [VariableMonitor("冰淇淋机器故障")] + public MORKI_FAULT IceCreamFault { get; set; } + + [VariableMonitor("冰淇淋机器打料完成")] + public bool DLCompleted { get; set; } + + [VariableMonitor("咖啡机连接状态")] + public bool CoffeeIsConnected { get; set; } + + [VariableMonitor("咖啡机状态")] + public DrCoffeeStatus DrCoffeeStatus { get; set; } + + [VariableMonitor("咖啡机应用状态")] + public DrCoffeeAppStatus CoffeeAppStatus { get; set; } + + [VariableMonitor("咖啡机告警")] + public DrCoffeeWarning CoffeeWarning { get; set; } + + [VariableMonitor("咖啡机故障")] + public DrCoffeeFault CaffeeFault { get; set; } + + [VariableMonitor("单片机连接状态")] + public bool SCChipIsConnect { get; set; } + + #endregion + } +} diff --git a/BPASmartClient.MorkT_HQ/OrderLocInfo.cs b/BPASmartClient.MorkT_HQ/OrderLocInfo.cs new file mode 100644 index 00000000..adcbcf98 --- /dev/null +++ b/BPASmartClient.MorkT_HQ/OrderLocInfo.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkT +{ + public class OrderLocInfo + { + public string SuborderId { get; set; } + public string GoodsName { get; set; } + public string Loc { get; set; } + public int SortNum { get; set; } + public int BatchingId { get; set; } + + public int OrderStatus { get; set; } + + + public OrderLocInfo() + { + OrderStatus = 0; + } + } +} diff --git a/BPASmartClient.MorkT_HQ/PolymerBatching.cs b/BPASmartClient.MorkT_HQ/PolymerBatching.cs new file mode 100644 index 00000000..8774449c --- /dev/null +++ b/BPASmartClient.MorkT_HQ/PolymerBatching.cs @@ -0,0 +1,123 @@ + +using BPASmartClient.Lebai; +using BPASmartClient.LebaiRobot; +using BPASmartClient.Model.单片机.Enum; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkT +{ + public enum GOODS_TYPE + { + NEITHER, + COFFEE, + ICECREAM, + } + + public enum BATCHING_CLASS + { + HOLDER, + MAIN_MATERIAL, + } + + public class PolymerBatching + { + internal const string ICE_MAIN_BATCHIN1_LOC = "52"; + internal const string ICE_MAIN_BATCHIN2_LOC = "53"; + internal const string ICE_MAIN_BATCHIN3_LOC = "54"; + internal const string COFFEE_HOLDER_LOC = "30"; + internal const string ICE_HOLDER_LOC = "51"; + public static Dictionary GOODS_TYPES = new Dictionary() { + {"1", GOODS_TYPE.COFFEE}, + {"2", GOODS_TYPE.COFFEE}, + {"3", GOODS_TYPE.COFFEE}, + {"4", GOODS_TYPE.COFFEE}, + {"5", GOODS_TYPE.COFFEE}, + {"6", GOODS_TYPE.COFFEE}, + {"7", GOODS_TYPE.COFFEE}, + {"8", GOODS_TYPE.COFFEE}, + {"9", GOODS_TYPE.COFFEE}, + {"10",GOODS_TYPE.COFFEE}, + {"11",GOODS_TYPE.COFFEE}, + {"12",GOODS_TYPE.COFFEE}, + {"13",GOODS_TYPE.COFFEE}, + {"14",GOODS_TYPE.COFFEE}, + {"15",GOODS_TYPE.COFFEE}, + {"16",GOODS_TYPE.COFFEE}, + {"17",GOODS_TYPE.COFFEE}, + {"18",GOODS_TYPE.COFFEE}, + {"19",GOODS_TYPE.COFFEE}, + {"20",GOODS_TYPE.COFFEE}, + {"21",GOODS_TYPE.COFFEE}, + {"22",GOODS_TYPE.COFFEE}, + {"23",GOODS_TYPE.COFFEE}, + {"24",GOODS_TYPE.COFFEE}, + {"25",GOODS_TYPE.COFFEE}, + {"30",GOODS_TYPE.COFFEE}, + {"51",GOODS_TYPE.ICECREAM}, + {ICE_MAIN_BATCHIN1_LOC,GOODS_TYPE.ICECREAM}, + {ICE_MAIN_BATCHIN2_LOC,GOODS_TYPE.ICECREAM}, + {ICE_MAIN_BATCHIN3_LOC,GOODS_TYPE.ICECREAM}, + }; + + public GOODS_TYPE GoodsType { get; set; } + public BATCHING_CLASS BatchingClass { get; set; } + private string loc; + + public string Loc + { + get { return loc; } + set + { + loc = value; + if (GOODS_TYPES.ContainsKey(loc)) + GoodsType = GOODS_TYPES[loc]; + switch (loc) + { + case COFFEE_HOLDER_LOC: + case ICE_HOLDER_LOC: + BatchingClass = BATCHING_CLASS.HOLDER; + break; + default: + BatchingClass = BATCHING_CLASS.MAIN_MATERIAL; + break; + } + } + } + + internal static Dictionary BuildAll() + { + Dictionary temp = new Dictionary(); + foreach (var item in GOODS_TYPES) + { + temp.Add(item.Key, new PolymerBatching() { Loc = item.Key }); + } + return temp; + } + + //internal static IC_SE GetIceCreamSE(string loc, out int sence) + //{ + // switch (loc) + // { + // case ICE_MAIN_BATCHIN1_LOC: + // sence = LebaiHelper.SENCE_接1号冰淇淋; + // return IC_SE.SE_1; + + // case ICE_MAIN_BATCHIN2_LOC: + // sence = LebaiHelper.SENCE_接2号冰淇淋; + // return IC_SE.SE_2; + + // case ICE_MAIN_BATCHIN3_LOC: + // sence = LebaiHelper.SENCE_接3号冰淇淋; + // return IC_SE.SE_3; + + // default: + // sence = LebaiHelper.SENCE_接1号冰淇淋; + // return IC_SE.SE_1; + // } + //} + } +} diff --git a/BPASmartClient.MorkT_HQ/View/DebugView.xaml b/BPASmartClient.MorkT_HQ/View/DebugView.xaml new file mode 100644 index 00000000..d872528a --- /dev/null +++ b/BPASmartClient.MorkT_HQ/View/DebugView.xaml @@ -0,0 +1,307 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +