diff --git a/BPASmartClient.MorkCL/Control_MorkCL.cs b/BPASmartClient.MorkCL/Control_MorkCL.cs index 38678d16..c3e86d6e 100644 --- a/BPASmartClient.MorkCL/Control_MorkCL.cs +++ b/BPASmartClient.MorkCL/Control_MorkCL.cs @@ -31,6 +31,18 @@ namespace BPASmartClient.MorkCL /// ConcurrentDictionary TaskList { get; set; } = new(); + /// + /// 炒锅1任务队列。 + /// + ConcurrentQueue FryingPan1TaskLsit { get;set; }=new(); + /// + /// 炒锅2任务队列。 + /// + ConcurrentQueue FryingPan2TaskLsit { get; set; } = new(); + /// + /// 高压锅任务队列。 + /// + ConcurrentQueue PressureCookerTaskLsit { get; set; } = new(); public override void DoMain() { MonitorViewModel.DeviceId = DeviceId; @@ -47,6 +59,8 @@ namespace BPASmartClient.MorkCL DeviceProcessLogShow($"接收到一个新配方任务。"); if (o != null && o is ControlData cd) { + + morkCL.cds.Enqueue(cd); DeviceProcessLogShow($"新配方任务{cd.Id}解析完成,已加入配方队列。"); } @@ -70,39 +84,65 @@ namespace BPASmartClient.MorkCL //devices[EDeviceType.压力锅].Init(Json.Data.PressureCookerIP); //devices[EDeviceType.外部设备].Init(Json.Data.PPortName); - ManualActionRegiester(); + #endif + ManualActionRegiester(); } public override void MainTask() { - if (morkCL.cds.Count > 0 && !TaskList.ContainsKey(morkCL.cds.ElementAt(0).DeviceType)) + //检查到有任务完成后将对已完成的任务进行清理 + var res = TaskList.FirstOrDefault(p => p.Value.IsComplete).Key; + if (TaskList.ContainsKey(res)) + TaskList.TryRemove(res, out _); + + if (morkCL.cds.Count > 0) { - if (morkCL.cds.TryDequeue(out ControlData cd)) + var dishType = morkCL.cds.ElementAt(0).DishType; + var devieceType = EDeviceType.无; + if (dishType == Model.Recipe.EDishType.炒菜) { - if (cd.DishType == Model.Recipe.EDishType.炒菜) + //如果任务队列里,炒锅1已经有任务了,就看炒锅2是否有任务,没任务就设置为炒锅2执行,如果两个锅都有任务则返回该次任务。 + if (TaskList.ContainsKey(EDeviceType.炒锅1)) { - //TODO:暂定为炒锅1 ,实际是哪个空闲找哪个,需要添加一个空闲信号。 - cd.DeviceType = EDeviceType.炒锅1; + if (TaskList.ContainsKey(EDeviceType.炒锅2)) + { + return; + } + else + { devieceType=EDeviceType.炒锅2; } } else { - cd.DeviceType = EDeviceType.压力锅; + devieceType = EDeviceType.炒锅1; + } + } + else + { + devieceType = EDeviceType.压力锅; + } + + //这里判定主要是针对压力锅。 + if (!TaskList.ContainsKey(devieceType)) + { + if (morkCL.cds.TryDequeue(out ControlData cd)) + { + cd.DeviceType = devieceType; + + TaskList.TryAdd(cd.DeviceType, new TaskServer()); + TaskList[cd.DeviceType].TaskName = $"{cd.DeviceType.ToString()}-{cd.Name}"; + TaskList[cd.DeviceType].RunTask = new Task(new Action(() => { FryingPanControl(cd.DeviceType, cd); })); + TaskList[cd.DeviceType].RunTask.Start(); } - TaskList.TryAdd(cd.DeviceType, new TaskServer()); - TaskList[cd.DeviceType].TaskName = $"{cd.DeviceType.ToString()}-{cd.Name}"; - TaskList[cd.DeviceType].RunTask = new Task(new Action(() => { FryingPanControl(cd.DeviceType, cd); })); - TaskList[cd.DeviceType].RunTask.Start(); } + } - //检查到有任务完成后将对已完成的任务进行清理 - var res = TaskList.FirstOrDefault(p => p.Value.IsComplete).Key; - if (TaskList.ContainsKey(res)) TaskList.TryRemove(res, out _); + } private async void FryingPanControl(EDeviceType et, ControlData cd) { - DeviceProcessLogShow($"开始执行-{cd.Name} 任务"); + DeviceProcessLogShow($"【{et}】开始执行-{cd.Name} 任务"); if (TaskList.ContainsKey(et) && TaskList[et].Cts.IsCancellationRequested) return; while (cd.ControlFuncs.Count > 0) { @@ -115,10 +155,12 @@ namespace BPASmartClient.MorkCL switch (fm.eFunc) { case EFunc.搅拌启动: + device.StirStartOrStop = false; + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入搅拌频率-{fm.funcPars.ElementAt(0).ParValue.ToString()}HZ。"); device.MixingFrequencySet(fm.funcPars.ElementAt(0).ParValue.ToString()); DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入搅拌频率-{fm.funcPars.ElementAt(0).ParValue.ToString()}HZ完成。"); - + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入开始搅拌。"); device.StirStartOrStop = true; DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入开始搅拌完成。"); @@ -130,6 +172,8 @@ namespace BPASmartClient.MorkCL DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入停止搅拌完成。"); break; case EFunc.加热启动: + device.HeatStartOrStop = false; + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热挡位-【{fm.funcPars.ElementAt(0).ParValue.ToString()}】。"); device.HeatingGearSet(fm.funcPars.ElementAt(0).ParValue.ToString()); DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热挡位完成,设置加热启动。"); @@ -147,20 +191,19 @@ namespace BPASmartClient.MorkCL var Seasoning = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id); if (Seasoning != null) { - //TODO:应该为下料完成就关闭。 device.CuttingControl(Seasoning.Loc.ToString(), fm.funcPars.ElementAt(1).ParValue.ToString()); DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-执行下料,下料位置:{Seasoning.Loc.ToString()},下料重量:【{fm.funcPars.ElementAt(1).ParValue.ToString()}】。"); - - } + } else { - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找调料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】调料。"); + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找调料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】调料。任务取消。"); + TaskList[et].Cts.Cancel(); } break; case EFunc.添加主料: DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料【{fm.funcPars.ElementAt(0).Id}】。"); - //var ingredientes = SqliteHelper.GetInstance.GetIngredientsInfo(fm.funcPars.ElementAt(0).Id); + if (float.TryParse(fm.funcPars.ElementAt(1).ParValue.ToString(),out float weight)) { //查找主料库位符合条件的物料库位,主要根据物料ID和物料重量查找。 @@ -170,31 +213,33 @@ namespace BPASmartClient.MorkCL { //device.CuttingControl(Seasoning.Loc.ToString(), fm.funcPars.ElementAt(1).ParValue.ToString()); var ingredientes = Json.Data.IngredientsStorage[ingre_index]; - //TODO:机器人下发取料 + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-执行下料,控制取{ingre_index+1}库物料,下料名称:{ingredientes.Name.ToString()},下料重量:【{fm.funcPars.ElementAt(1).ParValue.ToString()}】。"); - + device.FryingPanFeedingLoc = false; + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{ingre_index+1.ToString()}】,子任务【{et}】。"); + robot.RobotTaskControl(ingre_index+1.ToString(), et); DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{ingre_index+1.ToString()}】,子任务【{et}】完成。"); - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点。"); - device.FryingPanHome = true; - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点完成。"); + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回投料位置。"); + device.FryingPanFeedingLoc = true; + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回投料位置完成。"); DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。"); device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置 - device.FryingPanHome = false; + device.FryingPanFeedingLoc = false; DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成。"); DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。"); - robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置 + robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置也就是发出倒料请求。 DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置完成。"); - - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。"); - robot.AllowPourVegetables(et);//允许机器人开始投料 - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。"); + //目前程序在炒锅在投料位置时,会自动发出允许倒料信息。 + //DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。"); + //robot.AllowPourVegetables(et);//允许机器人开始投料 + //DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。"); DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-开始等待机器人投料完成。"); robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成 @@ -206,40 +251,54 @@ namespace BPASmartClient.MorkCL } else { - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】主料。"); + //TODO:暂定为直接取消任务,后期再说。 + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】主料。任务取消。"); + TaskList[et].Cts.Cancel(); } } break; case EFunc.添加辅料: MaterialBase mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id); - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{(mb.Loc+12).ToString()}】,子任务【{et}】。"); - robot.RobotTaskControl((mb.Loc+12).ToString(), et); - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{(mb.Loc+12).ToString()}】,子任务【{et}】完成。"); + if (mb != null) + { + //先复位变量。防止上一次是异常结束,设为True时,不会响应。 + device.FryingPanFeedingLoc = false; - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点。"); - device.FryingPanHome = true; - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点完成。"); + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{(mb.Loc + 12).ToString()}】,子任务【{et}】。"); + robot.RobotTaskControl((mb.Loc + 12).ToString(), et); + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{(mb.Loc + 12).ToString()}】,子任务【{et}】完成。"); - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。"); - device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置 - device.FryingPanHome = false; - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成。"); + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回投料位置。"); + device.FryingPanFeedingLoc = true; + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回投料位置完成。"); + + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。"); + device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置 + device.FryingPanFeedingLoc = false; + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成。"); - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。"); - robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置 - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置完成。"); + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。"); + robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置 + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置完成。"); - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。"); - //robot.AllowPourVegetables(et);//允许机器人开始投料 - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。"); + //DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。"); + //robot.AllowPourVegetables(et);//允许机器人开始投料 + //DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。"); - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-开始等待机器人投料完成。"); - robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成 - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人投料完成。"); + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-开始等待机器人投料完成。"); + robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成 + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人投料完成。"); + + } + else + { + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】辅料。任务取消。"); + TaskList[et].Cts.Cancel(); + } break; case EFunc.炒锅回原点位: - + device.FryingPanHome = false; DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点。"); device.FryingPanHome = true; DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点完成。"); @@ -270,11 +329,13 @@ namespace BPASmartClient.MorkCL DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-出餐完成。"); //回到投料位置就复位。 - Thread.Sleep(500); + Thread.Sleep(50); device.FeedingLocFB.Wait(Cts: TaskList[et].Cts); device.DiningOutStart = false; break; case EFunc.炒锅清洗: + device.FryingPanClear = false; + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅清洗。"); device.FryingPanClear = true; DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅清洗已写入。"); @@ -284,15 +345,17 @@ namespace BPASmartClient.MorkCL device.FryingPanClear = false; break; case EFunc.炒锅回调料投料位置: + device.FryingPanToSeasoningLoc = false; + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置。"); - device.FryingPanFeedingLoc = true; + device.FryingPanToSeasoningLoc = true; DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置完成。"); //回到投料位置就复位。 - Thread.Sleep(500); - device.FeedingLocFB.Wait(Cts: TaskList[et].Cts); - device.DiningOutStart = false; + Thread.Sleep(50); + device.FeedingSeasoningLocFB.Wait(Cts: TaskList[et].Cts); + device.FryingPanToSeasoningLoc = false; break; case EFunc.去指定炒制位: DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置去指定炒制位。"); @@ -300,9 +363,13 @@ namespace BPASmartClient.MorkCL DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置去指定炒制位【{fm.funcPars.ElementAt(0).ParValue.ToString()}】完成。"); break; case EFunc.炒制: - DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒制。"); + if (int.TryParse(fm.funcPars.ElementAt(0).ParValue.ToString(), out int time)) + { + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒制【{time}】秒。"); Task.Delay(time * 1000).Wait(TaskList[et].Cts.Token); + } + DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒制完成。"); break; default: @@ -310,7 +377,7 @@ namespace BPASmartClient.MorkCL } } } - DeviceProcessLogShow($"任务-{cd.Name} 执行完成"); + DeviceProcessLogShow($"【{et}】任务-{cd.Name} 执行完成"); } @@ -335,6 +402,8 @@ namespace BPASmartClient.MorkCL morkCL.OutDinningFinsh2 = fryingPan2.OutDinningFinsh; morkCL.OutDinningSlowDownFlag1 = fryingPan1.OutDinningSlowDownFlag; morkCL.OutDinningSlowDownFlag2 = fryingPan2.OutDinningSlowDownFlag; + + morkCL.IsIdle=robot.IsIdle; #if !FORMAL if (fryingPan1.FeedingLocFB) { diff --git a/BPASmartClient.MorkCL/GVL_MorkCL.cs b/BPASmartClient.MorkCL/GVL_MorkCL.cs index f43f5ba1..f9134bb4 100644 --- a/BPASmartClient.MorkCL/GVL_MorkCL.cs +++ b/BPASmartClient.MorkCL/GVL_MorkCL.cs @@ -246,6 +246,13 @@ namespace BPASmartClient.MorkCL [VariableMonitor("机器人-机器人程序运行中")] public bool ProgramRuning { get; set; } + + /// + /// 机器人空闲中 + /// + [VariableMonitor("机器人-机器人空闲中")] + public bool IsIdle { get; set; } + /// /// 机器人任务反馈 /// diff --git a/BPASmartClient.MorkCL/Model/Control/FryingPanSet.cs b/BPASmartClient.MorkCL/Model/Control/FryingPanSet.cs index 30ba5a46..6f6b7474 100644 --- a/BPASmartClient.MorkCL/Model/Control/FryingPanSet.cs +++ b/BPASmartClient.MorkCL/Model/Control/FryingPanSet.cs @@ -32,10 +32,11 @@ namespace BPASmartClient.MorkCL.Model.Control { byte[] VWOffset = new byte[3] { 3, 4, 5 }; byte[] LBOffset = new byte[3] { 6, 7, 8 }; + MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), false); MyModbus.Write($"LW{VWOffset[ChannelNum - 1]}".ToModbusAdd(), value); MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), true); //扫描周期较短,不等下料完成读为0,就已经过了,添加一个延时。 - Task.Delay(500).Wait(); + Task.Delay(50).Wait(); ChannelDisCom[ChannelNum - 1].Wait(); MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), false); } @@ -50,9 +51,10 @@ namespace BPASmartClient.MorkCL.Model.Control if (ushort.TryParse(value, out ushort Gear)) if (Gear >= 1 && Gear <= 8) { + MyModbus.Write($"LB9".ToModbusAdd(), false); MyModbus.Write($"LW0".ToModbusAdd(), Gear); MyModbus.Write($"LB9".ToModbusAdd(), true); - MyModbus.Write($"LB9".ToModbusAdd(), false); + //MyModbus.Write($"LB9".ToModbusAdd(), false); } } @@ -65,9 +67,10 @@ namespace BPASmartClient.MorkCL.Model.Control if (ushort.TryParse(value, out ushort Frequency)) if (Frequency >= 0 && Frequency <= 50) { + MyModbus.Write($"LB10".ToModbusAdd(), false); MyModbus.Write($"LW1".ToModbusAdd(), Frequency*100); MyModbus.Write($"LB10".ToModbusAdd(), true); - MyModbus.Write($"LB10".ToModbusAdd(), false); + //MyModbus.Write($"LB10".ToModbusAdd(), false); } } @@ -80,9 +83,10 @@ namespace BPASmartClient.MorkCL.Model.Control if (ushort.TryParse(value, out ushort Frequency)) if (Frequency >= 0 && Frequency <= 50) { + MyModbus.Write($"LB11".ToModbusAdd(), false); MyModbus.Write($"LW2".ToModbusAdd(), Frequency); MyModbus.Write($"LB11".ToModbusAdd(), true); - MyModbus.Write($"LB11".ToModbusAdd(), false); + //MyModbus.Write($"LB11".ToModbusAdd(), false); } } @@ -102,12 +106,12 @@ namespace BPASmartClient.MorkCL.Model.Control public bool FryingPanClear { get { return default; } set { MyModbus.Write("LB14".ToModbusAdd(), value); } } /// - /// 炒锅到主料调料投料位置 + /// 炒锅到主料辅料投料位置 /// public bool FryingPanFeedingLoc { get { return default; } set { MyModbus.Write("LB15".ToModbusAdd(), value); } } /// - /// 炒锅到主料调料投料位置 + /// 炒锅到调料投料位置 /// public bool FryingPanToSeasoningLoc { get { return default; } set { MyModbus.Write("LB16".ToModbusAdd(), value); } } @@ -120,8 +124,9 @@ namespace BPASmartClient.MorkCL.Model.Control if (ushort.TryParse(value, out ushort loc)) if (loc >= 1 && loc <= 3) { + MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), false); MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), true); - Task.Delay(500).Wait(); + Task.Delay(50).Wait(); StirFryingLocFB[loc - 1].Wait(); MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), false); } diff --git a/BPASmartClient.MorkCL/Model/Control/RobotGet.cs b/BPASmartClient.MorkCL/Model/Control/RobotGet.cs index d4f511e5..da3ffeb7 100644 --- a/BPASmartClient.MorkCL/Model/Control/RobotGet.cs +++ b/BPASmartClient.MorkCL/Model/Control/RobotGet.cs @@ -49,9 +49,12 @@ namespace BPASmartClient.MorkCL.Model.Control /// /// 机器人程序运行中 /// - public bool ProgramRuning { get { - return TaskFeedback == RobotMainTask.无任务 && Home; - } } + public bool ProgramRuning; + + /// + /// 机器人空闲中 + /// + public bool IsIdle; /// /// 机器人任务反馈 diff --git a/BPASmartClient.MorkCL/Model/Control/RobotSet.cs b/BPASmartClient.MorkCL/Model/Control/RobotSet.cs index b00b0c4e..397c9da0 100644 --- a/BPASmartClient.MorkCL/Model/Control/RobotSet.cs +++ b/BPASmartClient.MorkCL/Model/Control/RobotSet.cs @@ -18,6 +18,7 @@ namespace BPASmartClient.MorkCL.Model.Control if (ushort.TryParse(MainTask, out ushort mainTask)) if (mainTask >= 0 && mainTask <= 24) { + IsIdle.Wait(); MyModbus.Write("GI1".ToModbusAdd(), (ushort)SubTask); MyModbus.Write("GI0".ToModbusAdd(), mainTask); } @@ -30,7 +31,13 @@ namespace BPASmartClient.MorkCL.Model.Control public void WarehousingControl(string Loc) { if (ushort.TryParse(Loc, out ushort loc)) - if (loc >= 1 && loc <= 12) MyModbus.Write("GI0".ToModbusAdd(), (ushort)(loc + 29)); + { + if (loc >= 1 && loc <= 12) + { + IsIdle.Wait(); + MyModbus.Write("GI0".ToModbusAdd(), (ushort)(loc + 29)); + } + } } /// diff --git a/BPASmartClient.MorkCL/Server/RobotServer.cs b/BPASmartClient.MorkCL/Server/RobotServer.cs index 56cbc7f4..b2e11d47 100644 --- a/BPASmartClient.MorkCL/Server/RobotServer.cs +++ b/BPASmartClient.MorkCL/Server/RobotServer.cs @@ -36,6 +36,7 @@ namespace BPASmartClient.MorkCL.Server MyModbus.Read("GI5".ToModbusAdd(), 1).OnSuccess(s => { TaskFeedback = (RobotMainTask)s; }); + IsIdle = (TaskFeedback == RobotMainTask.无任务 && Home); Thread.Sleep(10); }), $"机器人服务-{IP}", true); }); diff --git a/BPASmartClient.MorkCL/View/EditRecipeView.xaml b/BPASmartClient.MorkCL/View/EditRecipeView.xaml index 6d96828e..e4ea1f9d 100644 --- a/BPASmartClient.MorkCL/View/EditRecipeView.xaml +++ b/BPASmartClient.MorkCL/View/EditRecipeView.xaml @@ -60,9 +60,9 @@ Text="配方名称:" /> diff --git a/BPASmartClient.MorkCL/View/ItemStorageView.xaml b/BPASmartClient.MorkCL/View/ItemStorageView.xaml index 4bbfbce6..016a54f7 100644 --- a/BPASmartClient.MorkCL/View/ItemStorageView.xaml +++ b/BPASmartClient.MorkCL/View/ItemStorageView.xaml @@ -8,8 +8,8 @@ xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel" Name="库位状态" - d:DesignHeight="450" - d:DesignWidth="800" + d:DesignHeight="900" + d:DesignWidth="1200" mc:Ignorable="d">