From 907030d03c2454f1caf270d05f123bb98f0baaf1 Mon Sep 17 00:00:00 2001 From: NXX <447201003@qq> Date: Sat, 3 Dec 2022 17:26:21 +0800 Subject: [PATCH 01/12] morkBF --- BPASmartClient.Model/大炒/FryPotMessages.cs | 26 +- .../大炒/RobotActionModel.cs | 71 ++- BPASmartClient.MorkBF/Control_MorkBF.cs | 449 ++++++------------ .../Convert/FryActionToVisibilityConverter.cs | 12 +- BPASmartClient.MorkBF/GVL_MorkBF.cs | 35 +- BPASmartClient.MorkBF/VIew/DebugView.xaml | 27 +- .../VIew/FoodManagerView.xaml | 8 +- .../VIew/FoodManagerView.xaml.cs | 1 + .../ViewModel/DebugViewModel.cs | 120 ++--- .../ViewModel/FoodManagerViewModel.cs | 14 +- 10 files changed, 319 insertions(+), 444 deletions(-) diff --git a/BPASmartClient.Model/大炒/FryPotMessages.cs b/BPASmartClient.Model/大炒/FryPotMessages.cs index 311010e9..b5ce1c8e 100644 --- a/BPASmartClient.Model/大炒/FryPotMessages.cs +++ b/BPASmartClient.Model/大炒/FryPotMessages.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,15 +12,23 @@ namespace BPASmartClient.Model.大炒 public string GoodName { get; set; } public string GoodKey { get; set; } public List fryPotProcesses { get; set; } = new List(); - public int FryOffStirTime;//关火翻炒时间; + /// + /// 翻转速度0到800 + /// + public int TurnSpeed { get; set; } = 0; + /// + /// 关火翻炒时间; + /// + public int FryOffStirTime; } - public class FryPotProcess + public class FryPotProcess:ObservableObject { /// /// 步骤 /// - public int FryTime { get; set; } + public int FryTime { get { return _fryTime; } set { _fryTime = value; OnPropertyChanged(); } } + private int _fryTime; /// /// 动作 /// @@ -36,10 +45,7 @@ namespace BPASmartClient.Model.大炒 /// 搅拌挡位 小炒1-10 大炒1-5 /// public int StirGear { get; set; } = 0; - /// - /// 翻转速度0到800 - /// - public int TurnSpeed { get; set; }= 0; + /// /// 炒制位置1到4 /// @@ -67,8 +73,8 @@ namespace BPASmartClient.Model.大炒 { 冷锅加热, 热油, - 加调料, - 加辅料, + 机器人加调料, + 通道出调料, 炒制菜品, } diff --git a/BPASmartClient.Model/大炒/RobotActionModel.cs b/BPASmartClient.Model/大炒/RobotActionModel.cs index b614cd34..61863b81 100644 --- a/BPASmartClient.Model/大炒/RobotActionModel.cs +++ b/BPASmartClient.Model/大炒/RobotActionModel.cs @@ -9,24 +9,67 @@ namespace BPASmartClient.Model.大炒 public class RobotAction_Pot { public int Pot { get; set; } - public RobotActionModel robotActionModel { get; set; } + public MainTask MainTask { get; set; } + public SubTask1 subTask1 { get; set; } = 0; + public SubTask2 subTask2 { get; set; } = 0; + public SubTask3 subTask3 { get; set; } = 0; + public SubTask4 subTask4 { get; set; } = 0; } - public enum RobotActionModel + + public enum MainTask + { + 无任务, + 机器人炒制任务, + 机器人补料任务, + } + public enum SubTask1 { 无任务, - 取1号炒锅荤菜盆倒1号炒锅, - 取1号炒锅素菜盆1倒1号炒锅, - 取1号炒锅素菜盆2倒1号炒锅, - 取1号炒锅调料盆倒入1号炒锅, - 取1号炒锅辅料盆1倒入1号炒锅, - 取1号空盆出餐, + 机器人取1号菜盆, + 机器人取2号菜盆, + 机器人取3号菜盆, + 机器人取4号菜盆, + 机器人取5号菜盆, + 机器人取6号菜盆, + 机器人取7号菜盆, + 机器人取8号菜盆, + 机器人取9号菜盆, + 机器人取1号调料, + 机器人取2号调料, + 机器人取3号调料, + 机器人取4号调料, + 机器人取5号调料, + 机器人取6号调料, + 机器人取1号空盆, + 机器人取2号空盆, + 机器人取3号空盆, + 机器人取4号空盆, - 取2号炒锅荤菜盆1倒2号炒锅 = 20, - 取2号炒锅素菜盆1倒2号炒锅 = 21, - 取2号炒锅素菜盆2倒2号炒锅 =22, - 取2号炒锅调料盆倒入2号炒锅 =23, - 取2号炒锅辅料盆1倒入2号炒锅 =24, - 取2号空盆出餐 =25, } + public enum SubTask2 + { + 无任务, + 倒料至1号锅, + 倒料至2号锅, + } + + public enum SubTask3 + { + 无任务, + 机器人上料口取料 + } + public enum SubTask4 + { + 无任务, + 放盆至1号库位, + 放盆至2号库位, + 放盆至3号库位, + 放盆至4号库位, + 放盆至5号库位, + 放盆至6号库位, + 放盆至7号库位, + 放盆至8号库位, + } + } diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 73ce08c1..aec948e1 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -51,6 +51,7 @@ namespace BPASmartClient.MorkBF DataParse();//数据解析 ScreenDataServer();//大屏数据上报 ActionManage.GetInstance.Send("更新菜单"); + ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程"); DeviceProcessLogShow("MORKF 设备初始化完成"); } @@ -64,9 +65,7 @@ namespace BPASmartClient.MorkBF if (order.MorkOrder.GoodBatchings == null) return; OrderCount++; DeviceProcessLogShow($"接收到{OrderCount}次订单"); - } - }); } @@ -122,17 +121,8 @@ namespace BPASmartClient.MorkBF ActionManage.GetInstance.Register(FirePot_PotReversal, "FirePot_PotReversal");//翻转反转 #endregion #region 机器人 - ActionManage.GetInstance.Register(RobotStart, "RobotStart");//机器人启动 - ActionManage.GetInstance.Register(RobotStop, "RobotStop");//机器人停止 - ActionManage.GetInstance.Register(RobotReset, "RobotReset");//复位 - ActionManage.GetInstance.Register(RobotProgramStart, "RobotProgramStart");//程序启动 - ActionManage.GetInstance.Register(Robot_Pot1AllowInMaterail, "Robot_Pot1AllowInMaterail");//1号炒锅允许机器人投料 - ActionManage.GetInstance.Register(Robot_Pot1OutFoodInSlowDown, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料到减速位 - ActionManage.GetInstance.Register(Robot_Pot1OutFood, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料完成 - ActionManage.GetInstance.Register(Robot_Pot2AllowInMaterail, "Robot_Pot2AllowInMaterail");//2号炒锅允许机器人投料 - ActionManage.GetInstance.Register(Robot_Pot2OutFoodInSlowDown, "Robot_Pot2OutFoodInSlowDown");//2号炒锅出餐倒料到减速位 - ActionManage.GetInstance.Register(Robot_Pot2OutFood, "Robot_Pot2OutFood");//2号炒锅出餐倒料完成 - ActionManage.GetInstance.Register(RobotActionStart, "Robot_Pot2OutFood");//2号炒锅出餐倒料完成 + + ActionManage.GetInstance.Register(RobotAction, "RobotAction");//上使能 #endregion @@ -141,12 +131,8 @@ namespace BPASmartClient.MorkBF public override void MainTask() { - if(morkBF.FirePan1_Order.Count>0&& morkBF.FirePot1_InitCompleted&&morkBF.FirePot2_IsAuto&&!morkBF.FirePan1_Busy) - { - ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程"); - } - - if(morkBF.RobotActinQueue.Count>0&&! morkBF.Robot_Origin)//机器人在原点为 + + if(morkBF.RobotActinQueue.Count>0&&! morkBF.Robot_Start)//机器人启动 { if( morkBF.RobotActinQueue.TryDequeue(out RobotAction_Pot robotAction)) { @@ -158,44 +144,48 @@ namespace BPASmartClient.MorkBF private void FirePot1_Process() { - - if(morkBF.FirePan1_Order.TryDequeue(out FryPotMessages result)) + if (morkBF.FirePan1_Order.Count > 0 && morkBF.FirePot1_InitCompleted && morkBF.FirePot2_IsAuto && !morkBF.FirePan1_Busy) { - - morkBF.FirePan1_Busy = true; - morkBF.FryPot1_CurrentProcess = result.fryPotProcesses; - foreach (var item in result.fryPotProcesses) + if (morkBF.FirePan1_Order.TryDequeue(out FryPotMessages result)) { - switch (item.fryActions) + + morkBF.FirePan1_Busy = true; + morkBF.FryPot1_CurrentProcess = result.fryPotProcesses; + foreach (var item in result.fryPotProcesses) { - 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: - break; + 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_RobotGetSeasoning(item, 1); + MessageLog.GetInstance.Show("炒锅1---机器人加调料完成"); + break; + case FryAction.通道出调料: + FirePot_PasswayOutSeasoning(item, 1); + MessageLog.GetInstance.Show("炒锅1---通道出调料完成"); + break; + case FryAction.炒制菜品: + FirePot_FryFood(item, 1); + MessageLog.GetInstance.Show("炒锅1---炒制菜品完成"); + break; + default: + break; + } } + FirePot_StartFire(new object[] { 1, false });//关火 + Thread.Sleep(result.FryOffStirTime*1000);//关火翻炒时间 + FirePot_StartStir(new object[] { 1, false });//关闭搅拌 + Message.MessageLog.GetInstance.Show($"炒锅1炒制{result.GoodName}完成"); + } - - } + } } private void FirePot2_Process() @@ -206,13 +196,21 @@ namespace BPASmartClient.MorkBF #region 炒锅流程功能 - private bool IsRobotNextWork(List currentProcess, int currentFryTime) + /// + /// 判断下个动作是否需要机器人 + /// + /// + /// + /// + private bool IsRobotNextWork(int i, int currentFryTime) { bool res = false; - if(currentProcess.Count> currentFryTime) + List currentProcess = new List(); + currentProcess = i == 1 ? morkBF.FryPot1_CurrentProcess: morkBF.FryPot2_CurrentProcess; + + if (currentProcess.Count> currentFryTime) { - if (currentProcess[currentFryTime + 1].fryActions == FryAction.加调料 || - currentProcess[currentFryTime + 1].fryActions == FryAction.加辅料 || + if (currentProcess[currentFryTime + 1].fryActions == FryAction.机器人加调料 || currentProcess[currentFryTime + 1].fryActions == FryAction.炒制菜品) { res = true; @@ -227,19 +225,11 @@ namespace BPASmartClient.MorkBF 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); - } + + FirePot_SetFireGear(new object[]{ i, item.FryGear});//设定加热挡位 + FirePot_StartFire(new object[] { i, true }); + isRobotWork = IsRobotNextWork(i,item.FryTime);//下个流程动作是否需要机器人 + if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料 else Thread.Sleep(item.FryDuration * 1000); @@ -254,91 +244,66 @@ namespace BPASmartClient.MorkBF bool isRobotWork = false; if (item.FryGear != 0) { - /* FirePot1_SetFireGear(item.FryGear);*///设定加热挡位 - //FirePot1_StartFire(true);//开启加热 - //isRobotWork = IsRobotNextWork(morkBF.FryPot1_CurrentProcess, item.FryTime); + FirePot_SetFireGear(new object[] { i, item.FryGear });//设定加热挡位 + FirePot_StartFire(new object[] { i, true }); } if (item.StirGear != 0) { - //FirePot1_SetStirGear(item.StirGear);//设定搅拌挡位 - //FirePot1_StartFire(true);//开启搅拌 - isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime); + FirePot_SetStirGear(new object[] { i, item.StirGear });//设定搅拌挡位 + FirePot_StartStir(new object[] { i, true }); + } + isRobotWork = IsRobotNextWork(i, item.FryTime); if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料 else Thread.Sleep(item.FryDuration * 1000);//加热时间; } /// - /// 加调料 + /// 通道出调料 /// - private void FirePot_AddSeasoning(FryPotProcess item,int i) + private void FirePot_PasswayOutSeasoning(FryPotProcess item,int i) { - - if(i == 1) - { - - morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot =1,robotActionModel = RobotActionModel.取1号炒锅调料盆倒入1号炒锅}); - Thread.Sleep(item.FryDuration); - - } - - else if(i == 2) + foreach(var acc in item.accessories) { - morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅调料盆倒入2号炒锅 }); - Thread.Sleep(item.FryDuration); + FirePot_StartPassWay(new object[] { i, acc.Loc, acc.Qry }); } - } /// - /// 加辅料 + /// 机器人取调料 /// - private void FirePot_AddAccessories(FryPotProcess item, int i) + private void FirePot_RobotGetSeasoning(FryPotProcess item, int i) { - if (i == 1) - { - - morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = RobotActionModel.取1号炒锅辅料盆1倒入1号炒锅 }); - Thread.Sleep(item.FryDuration); - - } - else if (i == 2) + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { - morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅辅料盆1倒入2号炒锅 }); - Thread.Sleep(item.FryDuration); - } - + Pot = i, + MainTask = BPASmartClient.Model.大炒.MainTask.机器人炒制任务, + subTask1 = (SubTask1)item.accessories[0].Loc + 9, + subTask2 = (SubTask2)i + }); } + + /// /// 炒制菜品 /// private void FirePot_FryFood(FryPotProcess item, int i) { bool isRobotWork = false; - if (i == 1) + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { - morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = (RobotActionModel)item.accessories[0].Loc }); - while (!morkBF.FirePot1_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成 - { - Thread.Sleep(100); - } - isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime); - - - } - - else if (i == 2) + Pot = i, + MainTask = BPASmartClient.Model.大炒.MainTask.机器人炒制任务, + subTask1 = (SubTask1)item.accessories[1].Loc, + subTask2 =(SubTask2)i + }); + while (!morkBF.FirePot1_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成 { - morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = (RobotActionModel)(item.accessories[0].Loc+19) });//炒制菜品位置 - while (!morkBF.FirePot2_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成 - { - Thread.Sleep(100); - } - isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime); - + Thread.Sleep(100); } + isRobotWork = IsRobotNextWork(i, item.FryTime); if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料 else Thread.Sleep(item.FryDuration * 1000);//加热时间; } @@ -350,76 +315,50 @@ namespace BPASmartClient.MorkBF /// private void RobotProcess(RobotAction_Pot robotAction) { - Robot_Write("GI0",(int)robotAction.robotActionModel); - while (morkBF.Robot_ActionCallback != (int)robotAction.robotActionModel)//机器人动作执行完动作反馈 + Robot_Write("GI0", (int)robotAction.MainTask);//设定机器人主要任务 + while(morkBF.Robot_GI0ActionCallback != (int)robotAction.MainTask)//等待主程序完成反馈 { - Thread.Sleep(100); + Thread.Sleep(300); } - if(robotAction.Pot == 1)//炒锅1 + if((int)robotAction.subTask1>0)//任务1 { - if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐) - { - Robot_Write("GM520", true);//机器人去出餐倒料减速位置 - while(!morkBF.Robot_ArriveFirePot1)//机器人到位,请求1#炒锅倒菜 - { - Thread.Sleep(100); - } - FirePot_StartOutFood(1);//炒锅出餐; - while (!morkBF.FirePot1_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈 - { - Thread.Sleep(1000); - } - Thread.Sleep(6 * 1000);//等待6s出餐 - Robot_Write("GM521", true);//机器人出餐到料完成 - - } - else + Robot_Write("GI1", (int)robotAction.subTask1); + Thread.Sleep(1000); + while (morkBF.Robot_GI1ActionCallback != (int)robotAction.subTask1)//等待子程序1完成反馈 { - //FirePot_Write("M11.6", true);//炒锅去投料位置 - while (!morkBF.FirePot1_PotOnIntoFoodPosition)//等待炒锅允许倒料 - { - Thread.Sleep(100); - } - Robot_Write("GM531", true);//机器人投料 + Thread.Sleep(300); } - } - else if (robotAction.Pot == 2) + if ((int)robotAction.subTask2 > 0)//任务2 { - if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐) + Robot_Write("GI2", (int)robotAction.subTask2); + Thread.Sleep(1000); + while (morkBF.Robot_GI2ActionCallback != (int)robotAction.subTask2)//等待子程序2完成反馈 { - Robot_Write("GM522", true);//炒锅去出餐倒料减速位置 - while (!morkBF.Robot_ArriveFirePot2)//机器人到位,请求1#炒锅倒菜 - { - Thread.Sleep(100); - } - FirePot_StartOutFood(2);//炒锅去出餐倒料位置 - while (!morkBF.FirePot2_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈 - { - Thread.Sleep(1000); - } - Thread.Sleep(6 * 1000);//等待20s出餐 - Robot_Write("GM523", true);//机器人出餐倒料完成 - + Thread.Sleep(300); } - else + } + if ((int)robotAction.subTask3 > 0)//任务3 + { + Robot_Write("GI3", (int)robotAction.subTask3); + Thread.Sleep(1000); + while (morkBF.Robot_GI3ActionCallback != (int)robotAction.subTask3)//等待子程序3完成反馈 { - //FirePot_Write("M16.7", true); - while (!morkBF.FirePot2_PotOnIntoFoodPosition) - { - Thread.Sleep(100); - } - Robot_Write("GM531", true); + Thread.Sleep(300); } - } - - while(!morkBF.Robot_Origin) + if ((int)robotAction.subTask4 > 0)//任务4 { + Robot_Write("GI4", (int)robotAction.subTask4); Thread.Sleep(1000); + while (morkBF.Robot_GI4ActionCallback != (int)robotAction.subTask4)//等待主程序4完成反馈 + { + Thread.Sleep(300); + } } - morkBF.Robot_IsBusy = false; - MessageLog.GetInstance.Show($"机器人完成[{robotAction.robotActionModel.ToString()}]任务"); + + + MessageLog.GetInstance.Show($"机器人完成[{robotAction.MainTask.ToString()}]任务"); } public override void ReadData() @@ -501,45 +440,7 @@ namespace BPASmartClient.MorkBF } }), 0); - GetStatus("GM500", new Action((o) => - { - if (o == null) return; - if (o is bool[] values && values.Length == 7) - { - - morkBF.FirePot1_CompleteSingle[0] = values[0]; - morkBF.FirePot1_CompleteSingle[1] = values[1]; - morkBF.FirePot1_CompleteSingle[2] = values[2]; - morkBF.Robot_FirePot1OutSeasoning = values[3]; - morkBF.Robot_FirePot1OutAccessories = values[4]; - morkBF.Robot_ArriveFirePot1 = values[5]; - morkBF.Robot_FirePot1OutFoodComplete = values[6]; - - } - }), 1); - GetStatus("GM510", new Action((o) => - { - if (o == null) return; - if (o is bool[] values && values.Length == 7) - { - morkBF.FirePot2_CompleteSingle[0] = values[0]; - morkBF.FirePot2_CompleteSingle[1] = values[1]; - morkBF.FirePot2_CompleteSingle[2] = values[2]; - morkBF.Robot_FirePot2OutSeasoning = values[3]; - morkBF.Robot_FirePot2OutAccessories = values[4]; - morkBF.Robot_ArriveFirePot2 = values[5]; - morkBF.Robot_FirePot2OutFoodComplete = values[6]; - - } - }), 1); - GetStatus("GI5", new Action((o) => - { - if (o == null) return; - if (o is int[] values && values.Length == 1) - { - morkBF.Robot_ActionCallback = values[0]; - } - }), 1); + GetStatus("VW2250", new Action((o) => { @@ -836,7 +737,6 @@ namespace BPASmartClient.MorkBF { FirePot2_Write("M10.6", true); } - } Thread.Sleep(200); } @@ -971,98 +871,33 @@ namespace BPASmartClient.MorkBF #endregion #region 机器人 - /// - /// 机器人启动 - /// - private void RobotStart() - { - Robot_Write("GM600",true); - Thread.Sleep(200); - } - /// - /// 机器人停止 - /// - private void RobotStop() + private void RobotAction(object[] o) { - Robot_Write("GM601", true); - Thread.Sleep(200); - } - /// - /// 机器人复位 - /// - private void RobotReset() - { - Robot_Write("GM602", true); - Thread.Sleep(200); - } - /// - /// 机器人程序重启 - /// - private void RobotProgramStart() - { - Robot_Write("GM603", true); - Thread.Sleep(200); - } - /// - /// 1号炒锅允许机器人投料(炒锅在投料位给出) - /// - private void Robot_Pot1AllowInMaterail() - { - Robot_Write("GM531", true); - Thread.Sleep(200); - } - /// - /// 1号炒锅出餐倒料到减速位 - /// - private void Robot_Pot1OutFoodInSlowDown() - { - Robot_Write("GM620", true); - Thread.Sleep(200); - } - /// - /// 1号炒锅出餐倒料完成 - /// - private void Robot_Pot1OutFood() - { - Robot_Write("GM521", true); - Thread.Sleep(200); - } - /// - /// 2号炒锅允许机器人投料(炒锅在投料位给出) - /// - private void Robot_Pot2AllowInMaterail() - { - Robot_Write("GM530", true); - Thread.Sleep(200); - } - /// - /// 2号炒锅出餐倒料到减速位。开始倒菜 - /// - private void Robot_Pot2OutFoodInSlowDown() - { - Robot_Write("GM522", true); - Thread.Sleep(200); - } - /// - /// 2号炒锅出餐倒料完成 - /// - private void Robot_Pot2OutFood() - { - Robot_Write("GM523", true); - Thread.Sleep(200); - } - /// - /// - /// - private void RobotActionStart(object o) - { - if (o == null) return; - if(int.TryParse(o.ToString(), out int value)) + if (o[0] is int value) { - Robot_Write("GI0",value); + switch (value) + { + case 0: + Robot_Write("GI0", (ushort)(MainTask)o[1]); + break; + case 1: + Robot_Write("GI1", (ushort)(SubTask1)o[1]); + break; + case 2: + Robot_Write("GI2", (ushort)(SubTask2)o[1]); + break; + case 3: + Robot_Write("GI3", (ushort)(SubTask3)o[1]); + break; + case 4: + Robot_Write("GI4", (ushort)(SubTask4)o[1]); + break; + default: + break; + } } - Thread.Sleep(200); } + #endregion @@ -1082,7 +917,7 @@ namespace BPASmartClient.MorkBF IsRun = IsHealth ? IsRun.运行 : IsRun.停止, WorkStatus_1 = morkBF.FirePot1_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, WorkStatus_2 = morkBF.FirePot2_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, - RobotStatu = morkBF.Robot_ActionCallback == 0? WorkStatus.待机 : WorkStatus.工作, + RobotStatu = WorkStatus.工作, Alarm = new List(), FailuresCount = 0, StatsCount = statsModels, diff --git a/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs b/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs index b6c17e30..d27eb0c1 100644 --- a/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs +++ b/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs @@ -25,10 +25,10 @@ namespace BPASmartClient.MorkBF.Convert case FryAction.热油: visibility = Visibility.Visible; break; - case FryAction.加调料: + case FryAction.机器人加调料: visibility = Visibility.Collapsed; break; - case FryAction.加辅料: + case FryAction.通道出调料: visibility = Visibility.Collapsed; break; case FryAction.炒制菜品: @@ -63,10 +63,10 @@ namespace BPASmartClient.MorkBF.Convert case FryAction.热油: visibility = Visibility.Visible; break; - case FryAction.加调料: + case FryAction.机器人加调料: visibility = Visibility.Collapsed; break; - case FryAction.加辅料: + case FryAction.通道出调料: visibility = Visibility.Collapsed; break; case FryAction.炒制菜品: @@ -101,10 +101,10 @@ namespace BPASmartClient.MorkBF.Convert case FryAction.热油: visibility = Visibility.Collapsed; break; - case FryAction.加调料: + case FryAction.机器人加调料: visibility = Visibility.Visible; break; - case FryAction.加辅料: + case FryAction.通道出调料: visibility = Visibility.Visible; break; case FryAction.炒制菜品: diff --git a/BPASmartClient.MorkBF/GVL_MorkBF.cs b/BPASmartClient.MorkBF/GVL_MorkBF.cs index a19425dc..77d07805 100644 --- a/BPASmartClient.MorkBF/GVL_MorkBF.cs +++ b/BPASmartClient.MorkBF/GVL_MorkBF.cs @@ -284,22 +284,22 @@ namespace BPASmartClient.MorkBF /// 机器人上使能 /// [VariableMonitor("机器人上使能", "GM600.0", "4596")] - public bool Robot_FirePot1OutMeal { get; set; } + public bool Robot_Enable { get; set; } /// /// 机器人复位 /// [VariableMonitor("机器人复位", "GM600.1", "4597")] - public bool Robot_FirePot1OutVegetables1 { get; set; } + public bool Robot_Reset { get; set; } /// /// 机器人启动 /// [VariableMonitor("机器人启动", "GM600.2", "4598")] - public bool Robot_FirePot1OutVegetables2 { get; set; } + public bool Robot_Start { get; set; } /// /// 机器人停止 /// [VariableMonitor("机器人停止", "GM600.3", "4599")] - public bool Robot_FirePot1OutSeasoning { get; set; } + public bool Robot_Stop { get; set; } /// /// 机器人动作反馈GI0 /// @@ -309,22 +309,22 @@ namespace BPASmartClient.MorkBF /// 机器人动作反馈GI1 /// [VariableMonitor("机器人动作反馈GI1", "GI1", "1")] - public int Robot_GI1ActionCallback0 { get; set; } + public int Robot_GI1ActionCallback { get; set; } /// /// 机器人动作反馈GI2 /// [VariableMonitor("机器人动作反馈GI2", "GI2", "2")] - public int Robot_GI2ActionCallback0 { get; set; } + public int Robot_GI2ActionCallback { get; set; } /// /// 机器人动作反馈GI3 /// [VariableMonitor("机器人动作反馈GI3", "GI3", "3")] - public int Robot_GI3ActionCallback0 { get; set; } + public int Robot_GI3ActionCallback { get; set; } /// /// 机器人动作反馈GI4 /// [VariableMonitor("机器人动作反馈GI4", "GI4", "4")] - public int Robot_GI4ActionCallback0 { get; set; } + public int Robot_GI4ActionCallback { get; set; } #endregion @@ -336,18 +336,13 @@ namespace BPASmartClient.MorkBF public GVL_MorkBF() { - FirePot1_CompleteSingle = new Dictionary - { - {1,Robot_FirePot1OutMeal }, - {2,Robot_FirePot1OutVegetables1 }, - {3,Robot_FirePot1OutVegetables2 }, - }; - FirePot2_CompleteSingle = new Dictionary - { - {1,Robot_FirePot2OutMeal }, - {2,Robot_FirePot2OutVegetables1 }, - {3,Robot_FirePot2OutVegetables2 }, - }; + //FirePot1_CompleteSingle = new Dictionary + //{ + // {1,Robot_FirePot1OutMeal }, + // {2,Robot_FirePot1OutVegetables1 }, + // {3,Robot_FirePot1OutVegetables2 }, + //}; + //炒锅1通道完成信号 Fire1_PasswayCompleteSingle = new Dictionary diff --git a/BPASmartClient.MorkBF/VIew/DebugView.xaml b/BPASmartClient.MorkBF/VIew/DebugView.xaml index 6cefcd9b..4f96677a 100644 --- a/BPASmartClient.MorkBF/VIew/DebugView.xaml +++ b/BPASmartClient.MorkBF/VIew/DebugView.xaml @@ -129,16 +129,23 @@ + + - + Header=" 果汁机 "> - - - + + + - - - - - + - - - - + + + + + + + + + + + + + + + 制热 + 制冷 + 缺水 + 童锁 + 使用 + - 预冷温度 - - 回气温度 - + - 环境温度 - - 当前模式 - - 电流 - - 电压 - - - 成型比 - - 故障 - - - 冰淇淋 + 果汁 + + 饮品1 + 饮品2 + 饮品3 + 饮品4 + + + 冷饮 + 热饮 + + + + + + + + + + + + + + + + + + DI输入 + + + + + + + + + + + + + + + DI0 + + + DI1 + + + DI2 + + + DI3 + + + DI4 + + + DI5 + + + DI6 + + + DI7 + + + + + + + + + + + + + + + + + DO输出 + + + + DO0 + DO1 + DO2 + DO3 + DO4 + DO5 + DO6 + DO7 + + + + + + + True + false + + + + diff --git a/BPASmartClient.MorkT/View/DebugView.xaml.cs b/BPASmartClient.MorkT/View/DebugView.xaml.cs index 92aab7f6..192bc9a1 100644 --- a/BPASmartClient.MorkT/View/DebugView.xaml.cs +++ b/BPASmartClient.MorkT/View/DebugView.xaml.cs @@ -17,7 +17,7 @@ using System.Windows.Shapes; namespace BPASmartClient.MorkT.View { /// - /// MorkT_DebugView.xaml 的交互逻辑 + /// DebugView.xaml 的交互逻辑 /// public partial class DebugView : UserControl { @@ -28,8 +28,10 @@ namespace BPASmartClient.MorkT.View private void Dubug_Unloaded(object sender, RoutedEventArgs e) { - //ThreadManage.GetInstance().StopTask("MorkT-状态刷新"); - //ThreadManage.GetInstance().StopTask("MorkT-传感器监视"); + ThreadManage.GetInstance().StopTask("MorkT-状态刷新"); + ThreadManage.GetInstance().StopTask("MorkT-传感器监视"); + } } + } diff --git a/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs index affaa52b..60c3c099 100644 --- a/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs +++ b/BPASmartClient.MorkT/ViewModel/DebugViewModel.cs @@ -8,12 +8,10 @@ using BPASmartClient.LebaiRobot; using BPASmartClient.Message; using BPASmartClient.Model; using BPASmartClient.Model.乐白机器人; -using BPASmartClient.Model.乐白机器人.Enum; using BPASmartClient.Model.冰淇淋.Enum; using BPASmartClient.Model.单片机; using BPASmartClient.Model.单片机.Enum; using BPASmartClient.Model.咖啡机.Enum; -using BPASmartClient.MorkT.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; @@ -21,9 +19,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading; - -namespace BPASmartClient.MorkT.ViewModel -{ +namespace BPASmartClient.MorkT.ViewModel; public class DebugViewModel : ObservableObject { @@ -38,12 +34,6 @@ namespace BPASmartClient.MorkT.ViewModel /// public string RobotMode { get { return _robotMode; } set { _robotMode = value; OnPropertyChanged(); } } private string _robotMode { get; set; } - /// - /// 乐白机器人自嗨时间间隔 - /// - public int TimeInterval { get { return Global.TimeInterval; } set { Global.TimeInterval = value; OnPropertyChanged(); } } - //private int _timeInterval { get; set; } = Global.TimeInterval; - /// /// 机器人控制指令 /// @@ -52,110 +42,32 @@ namespace BPASmartClient.MorkT.ViewModel /// 机器人控制 /// /// - - - public RelayCommand Button_SetValueCommand { get; set; } - - public RelayCommand Button_GoToHomeCommand { 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() }); } - private void Button_GoToHome() - { - //EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { }); - //MessageLog.GetInstance.Show("开始执行乐白机器人回原点"); - //EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_机器人回原点 }); - //MessageLog.GetInstance.Show("开始执行乐白机器人回原点-----"); - } - #endregion - #region 冰淇淋机器 - /// - /// 制作冰淇淋 - /// - public RelayCommand Button_MakeIceCreamCommand { get; set; } - /// - /// 选择冰淇淋模式 - /// - public RelayCommand Button_SetIceCreamModelCommand { get; set; } - + #region 果汁机 /// - /// 冰淇淋连接状态 + /// 果汁机的连接状态 /// - public string IceCreamConnected { get { return _iceCreamConnected; } set { _iceCreamConnected = value; OnPropertyChanged(); } } - private string _iceCreamConnected { get; set; } - /// - /// 预冷温度 - /// - public string YLWD { get { return _yLWD; } set { _yLWD = value; OnPropertyChanged(); } } - private string _yLWD { get; set; } - /// - /// 回气温度 - /// - public string HQWD { get { return _hQWD; } set { _hQWD = value; OnPropertyChanged(); } } - private string _hQWD { get; set; } - /// - /// 环境温度 - /// - public string HJWD { get { return _hJWD; } set { _hJWD = value; OnPropertyChanged(); } } - private string _hJWD { get; set; } - /// - /// 电流 - /// - public string DL { get { return _DL; } set { _DL = value; OnPropertyChanged(); } } - private string _DL { get; set; } - /// - /// 电压 - /// - public string DY { get { return _dy; } set { _dy = value; OnPropertyChanged(); } } - private string _dy { get; set; } - /// - /// 当前模式 - /// - public string CurrentMode { get { return _CurrentMode; } set { _CurrentMode = value; OnPropertyChanged(); } } - private string _CurrentMode; - /// - /// 故障 - /// - public string IceCreamFault { get { return _IceCreamFault; } set { _IceCreamFault = value; OnPropertyChanged(); } } - private string _IceCreamFault { get; set; } - /// - /// 成型比 - /// - public string CXB { get { return _cXB; } set { _cXB = value; OnPropertyChanged(); } } - private string _cXB { get; set; } + public string JuicerConnected { get { return _JuicerConnected; } set { _JuicerConnected = value; OnPropertyChanged(); } } + private string _JuicerConnected { get; set; } + /// - /// 打料完成状态 + /// 果汁机的状态 /// - public string DLCompleted { get { return _dLCompleted; } set { _dLCompleted = value; OnPropertyChanged(); } } - private string _dLCompleted { get; set; } - - public List IceCreamModes { get; set; } = new List(); - public string SelecteIceCreamdMode { get; set; } - - private void Button_MakeIceCream() - { - EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId }); - } - private void Button_SetIceCreamModel() - { - MORKI_MODE mORKI_MODE = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode); - EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = mORKI_MODE }); - } + public string JuicerState { get { return _JuicerState; } set { _JuicerState = value; OnPropertyChanged(); } } + private string _JuicerState { get; set; } + #endregion #region 咖啡机 /// /// 咖啡机连接状态 - /// + /// public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } } private string _coffeeConnected { get; set; } /// @@ -212,55 +124,81 @@ namespace BPASmartClient.MorkT.ViewModel #endregion #region 单片机 - /// - /// 单片机连接状态 - /// - public string SCChipIsConnect { get { return _sCChipIsConnect; } set { _sCChipIsConnect = value; OnPropertyChanged(); } } - private string _sCChipIsConnect { get; set; } - /// - /// 咖啡杯或冰淇淋杯落杯 - /// - public RelayCommand Button_CupControlCommand { get; set; } - /// - /// 单片机冰淇淋机器制冷 - /// - public RelayCommand Button_SCChipRefrigerationCommand { get; set; } - /// - /// 单片机冰淇淋机器打料 - /// - public RelayCommand Button_SCChipDischargeCommand { get; set; } - /// - /// 模拟测试 - /// - public RelayCommand Button_SCChipTestCommand { get; set; } - - private void Button_CupControl(object CupType) + public string MCUConnected { get { return _mcuConnected; } set { _mcuConnected = value; OnPropertyChanged(); } } + private string _mcuConnected { get; set; } + + public RelayCommand Button_MCUOuputCommand { get; set; } + public RelayCommand Button_MCUDOuputCommand { get; set; } + public RelayCommand Button_LebaiDOuputCommand { get; set; } + + public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } } + private int _pwmInputNumber = 1; + + public int MCU_PWM_CH { get { return _choosePWM; } set { _choosePWM = value; OnPropertyChanged(); } } + private int _choosePWM = 1; + + public int MCU_DO_CH { get { return _mcuDO_CH; } set { _mcuDO_CH = value; OnPropertyChanged(); } } + private int _mcuDO_CH = 1; + + public int Lebai_DO_CH { get { return _lebaiDO_CH; } set { _lebaiDO_CH = value; OnPropertyChanged(); } } + private int _lebaiDO_CH = 1; + + public int Lebai_DO_Value { get { return _lebaiDO_Value; } set { _lebaiDO_Value = value; OnPropertyChanged(); } } + private int _lebaiDO_Value = 1; + + private int[] DICH { get { return _diCH; } set { _diCH = value; OnPropertyChanged(); } } + private int[] _diCH = new int[8]; + + public bool MCU_DO_Value { get { return _mcu_DO_Valuer; } set { _mcu_DO_Valuer = value; OnPropertyChanged(); } } + private bool _mcu_DO_Valuer = true; + + public bool MCU_DI0 { get { return _mcu_DI0; }set { _mcu_DI0 = value;OnPropertyChanged(); } } + private bool _mcu_DI0 = true; + public bool MCU_DI1 { get { return _mcu_DI1; } set { _mcu_DI1 = value; OnPropertyChanged(); } } + private bool _mcu_DI1 = true; + public bool MCU_DI2 { get { return _mcu_DI2; } set { _mcu_DI2 = value; OnPropertyChanged(); } } + private bool _mcu_DI2 = true; + public bool MCU_DI3 { get { return _mcu_DI3; } set { _mcu_DI3 = value; OnPropertyChanged(); } } + private bool _mcu_DI3 = true; + public bool MCU_DI4 { get { return _mcu_DI4; } set { _mcu_DI4 = value; OnPropertyChanged(); } } + private bool _mcu_DI4 = true; + public bool MCU_DI5 { get { return _mcu_DI5; } set { _mcu_DI5 = value; OnPropertyChanged(); } } + private bool _mcu_DI5 = true; + public bool MCU_DI6 { get { return _mcu_DI6; } set { _mcu_DI6 = value; OnPropertyChanged(); } } + private bool _mcu_DI6 = true; + public bool MCU_DI7 { get { return _mcu_DI7; } set { _mcu_DI7 = value; OnPropertyChanged(); } } + private bool _mcu_DI7 = true; + /// + /// 单片机舵机输出 + /// + private void Button_McuOutput() { - EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent() { DeviceId = DeviceId, Cup = (IC_CUP)Enum.Parse(typeof(IC_CUP), CupType.ToString()) }); + string sChoosePWM =Convert.ToString(MCU_PWM_CH+1); + new WriteMcu() { TagName = "ServoControl", Address = sChoosePWM, Value = PWMInputNumber }.Publish(); } - - private void Button_SCChipRefrigeration() + /// + /// 单片机DO输出 + /// + private void Button_McuDOutput() { - //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 LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Value = true, Pin = 1 }); - Thread.Sleep(500); - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Value = false, Pin = 1 }); - + string sChooseDO = Convert.ToString(MCU_DO_CH + 1); + new WriteMcu() { TagName = "OutputControl", Address = sChooseDO, Value = MCU_DO_Value }.Publish(); } - - private void Button_SCChipDischarge() + /// + /// 乐白的DO输出 + /// + private void Button_LebaiDOutput() { - EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId, SteeringEngine = IC_SE.SE_2 }); + int sChooseDO = Convert.ToInt16(Lebai_DO_CH); + bool lebai_DO_Value = Convert.ToInt16(Lebai_DO_Value) == 0; + new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Pin = sChooseDO, Value = lebai_DO_Value }.Publish(); } + #endregion - #endregion - - /// - /// 设备ID - /// - public int DeviceId { get; set; } + /// + /// 设备ID + /// + public int DeviceId { get; set; } /// /// 设备数据 /// @@ -269,27 +207,14 @@ namespace BPASmartClient.MorkT.ViewModel public DebugViewModel() { Button_RobotControlCommand = new RelayCommand(Button_RobotControl); - Button_SetValueCommand = new RelayCommand(Button_SetValue); - Button_GoToHomeCommand = new RelayCommand(Button_GoToHome); - - Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); - Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel); - Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee); Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe); Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet); - Button_CupControlCommand = new RelayCommand(Button_CupControl); - Button_SCChipRefrigerationCommand = new RelayCommand(Button_SCChipRefrigeration); - Button_SCChipDischargeCommand = new RelayCommand(Button_SCChipDischarge); - Button_SCChipTestCommand = new RelayCommand(() => - { - Button_SCChipRefrigeration(); - Thread.Sleep(50); - Button_SCChipDischarge(); - }); - - foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) + Button_MCUOuputCommand = new RelayCommand(Button_McuOutput); + Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput); + Button_LebaiDOuputCommand = new RelayCommand(Button_LebaiDOutput); + foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) { Coffees.Add(code.ToString()); } @@ -300,17 +225,14 @@ namespace BPASmartClient.MorkT.ViewModel } SelectedCoffeeCmd = CoffeeCmds[0]; - foreach (MORKI_MODE code in Enum.GetValues(typeof(MORKI_MODE))) - { - IceCreamModes.Add(code.ToString()); - } - SelecteIceCreamdMode = IceCreamModes[0]; - Plugin.GetInstance()?.GetPlugin()?.GetDevices().ForEach(device => { if (device.Name == "MorkT") DeviceId = device.DeviceId ; }); + + + ThreadManage.GetInstance().StartLong(new Action(() => { @@ -318,10 +240,10 @@ namespace BPASmartClient.MorkT.ViewModel if (variableMonitors != null && variableMonitors.Count > 0) { - RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接"; - IceCreamConnected = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接"; CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; - SCChipIsConnect = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + JuicerConnected = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + MCUConnected = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue; @@ -330,19 +252,11 @@ namespace BPASmartClient.MorkT.ViewModel Warning = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机告警").CurrentValue; CaffeeFault = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机故障").CurrentValue; - YLWD = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器预冷温度").CurrentValue; - HQWD = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器回气温度").CurrentValue; - HJWD = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器环境温度").CurrentValue; - DL = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器电流").CurrentValue; - DY = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器电压").CurrentValue; - CurrentMode = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器模式").CurrentValue; - IceCreamFault = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器异常").CurrentValue; - CXB = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器成型比").CurrentValue; - DLCompleted = variableMonitors.FirstOrDefault(p => p.Notes == "冰淇淋机器打料完成")?.CurrentValue == "True" ? "打料完成" : "打料中"; + } Thread.Sleep(500); }), "MorkT-状态刷新"); - } + } } -} + From ac2581373855aa1af09699b26c3da5baa3b0696e Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 5 Dec 2022 17:31:15 +0800 Subject: [PATCH 10/12] 1 --- BPASmartClient.MorkT/Control_MorkT.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs index 5ce7791a..fab7ba56 100644 --- a/BPASmartClient.MorkT/Control_MorkT.cs +++ b/BPASmartClient.MorkT/Control_MorkT.cs @@ -103,7 +103,6 @@ namespace BPASmartClient.MorkT } }); } - MakeCoffeeProcess(); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (o) => { @@ -111,7 +110,7 @@ namespace BPASmartClient.MorkT { if (!resultValue)//取餐口有空余位置 { - //MakeIceCreamProcess(); + MakeIceCreamProcess(); MakeCoffeeComplete(); } } @@ -475,7 +474,9 @@ namespace BPASmartClient.MorkT EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_取咖啡杯 }); //SENCE_取咖啡杯 Wait(); - EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 + // EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Value = true ,Pin = 1}); + Thread.Sleep(500); DeviceProcessLogShow("尝试取咖啡杯!"); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); From 6b136d35ee1f43c293738718d229b754292e208c Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 5 Dec 2022 17:44:24 +0800 Subject: [PATCH 11/12] 1 --- .../乐白机器人/Enum/Lebai_qsqdCode.cs | 8 ++++++++ BPASmartClient.MorkT/Control_MorkT.cs | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs b/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs index 530bb3e5..dd08375c 100644 --- a/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs +++ b/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs @@ -8,6 +8,14 @@ namespace BPASmartClient.Model.乐白机器人.Enum { public class Lebai_qsqdCode { + //取餐口 0 + // + + #region 咖啡流程 + + #endregion + + #region 且时且多设备 public const int SENCE_自嗨 = 10008; public const int SENCE_取咖啡杯 = 10031; diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs index fab7ba56..9b82a3e1 100644 --- a/BPASmartClient.MorkT/Control_MorkT.cs +++ b/BPASmartClient.MorkT/Control_MorkT.cs @@ -111,7 +111,7 @@ namespace BPASmartClient.MorkT if (!resultValue)//取餐口有空余位置 { MakeIceCreamProcess(); - MakeCoffeeComplete(); + //MakeCoffeeComplete(); } } }); @@ -475,7 +475,7 @@ namespace BPASmartClient.MorkT Wait(); // EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 - EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Value = true ,Pin = 1}); + //EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Value = true ,Pin = 1}); Thread.Sleep(500); DeviceProcessLogShow("尝试取咖啡杯!"); From 222c2fd37607cd022cec4ba50e024a1b71392790 Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 5 Dec 2022 17:59:11 +0800 Subject: [PATCH 12/12] 1 --- .../乐白机器人/Enum/Lebai_qsqdCode.cs | 7 +++++-- BPASmartClient.MorkT/Control_MorkT.cs | 10 ++++++++-- BPASmartClient.MorkTM/Control_MorkTM.cs | 1 - 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs b/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs index dd08375c..92e665b4 100644 --- a/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs +++ b/BPASmartClient.Model/乐白机器人/Enum/Lebai_qsqdCode.cs @@ -8,9 +8,12 @@ namespace BPASmartClient.Model.乐白机器人.Enum { public class Lebai_qsqdCode { - //取餐口 0 - // + //取餐口 0 号输入 光电传感器 + + //Tcp 1号输入 手臂传感器 + //落杯器 输出 1号 + //落杯器 输入 1号 #region 咖啡流程 #endregion diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs index 9b82a3e1..55fca7a6 100644 --- a/BPASmartClient.MorkT/Control_MorkT.cs +++ b/BPASmartClient.MorkT/Control_MorkT.cs @@ -475,8 +475,14 @@ namespace BPASmartClient.MorkT Wait(); // EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 - //EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Value = true ,Pin = 1}); - + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Value = true, Pin = 1 }); + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 1 }, (o) => + { + //if (o != null && o.Length > 0 && o[0] is bool resultValue) + //{ + // result = resultValue; + //} + }); Thread.Sleep(500); DeviceProcessLogShow("尝试取咖啡杯!"); EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); diff --git a/BPASmartClient.MorkTM/Control_MorkTM.cs b/BPASmartClient.MorkTM/Control_MorkTM.cs index 6eda755a..7cd367a9 100644 --- a/BPASmartClient.MorkTM/Control_MorkTM.cs +++ b/BPASmartClient.MorkTM/Control_MorkTM.cs @@ -435,7 +435,6 @@ namespace BPASmartClient.MorkTM } } } - public override void SimOrder() {