diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index 51d6a30b..292ac789 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -15,9 +15,11 @@ namespace BPASmartClient.MorkF public class Control_MorkF : BaseDevice { public override DeviceClientType DeviceType => DeviceClientType.MORKSF; - + public AutoResetEvent minorReset = new AutoResetEvent(false); + public AutoResetEvent mainReset = new AutoResetEvent(false); GVL_MorkF morkF = new GVL_MorkF();//全局对象声明 public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象 + List resultorder = new List();//调试变量 public static readonly object taskLock = new object(); /// @@ -62,19 +64,16 @@ namespace BPASmartClient.MorkF } //流程 stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List() { StirFryRobotAction.清洗槽取锅 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 25 }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); - //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.大火持续, StirFryPotAction.低速旋转 }, During = 5 }); - //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.快速旋转 }, During = 50 }); - //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, RobotActions = new List() { StirFryRobotAction.加入A料 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, PotActions = new List() { StirFryPotAction.大火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 25 }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List() { StirFryRobotAction.加入B料 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, PotActions = new List() { StirFryPotAction.大火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 15 }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, RobotActions = new List() { StirFryRobotAction.加入C料 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List() { StirFryPotAction.大火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List() { StirFryPotAction.大火持续 }, During = 5 }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, RobotActions = new List() { StirFryRobotAction.加入A料 }, PotActions = new List() { StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 6 }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.停止火力, StirFryPotAction.搅拌臂上位 } });//加A料 + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List() { StirFryRobotAction.加入B料 }, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 6 }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料 + + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List() { StirFryRobotAction.加入C料 }, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 9 }); + + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料 + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 }); stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List() { StirFryRobotAction.灶取锅 } }); } @@ -117,29 +116,28 @@ namespace BPASmartClient.MorkF } //流程 stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List() { StirFryRobotAction.清洗槽取锅 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 5 }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, RobotActions = new List() { StirFryRobotAction.加入A料 }, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 5 }); stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List() { StirFryPotAction.加油 }, During = 12 }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List() { StirFryRobotAction.加入A料 } }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加A料 + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, RobotActions = new List() { StirFryRobotAction.加入B料 }, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 25 }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 25 }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料 - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, RobotActions = new List() { StirFryRobotAction.加入B料 } }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 30 }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List() { StirFryRobotAction.加入C料 }, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 }); - stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料 + stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 }); stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List() { StirFryRobotAction.灶取锅 } }); } public void TakePot() { - + WriteData("M14.0", true); } public void TakePotReset() { - + WriteData("M14.0", false); } public void TakeOff() @@ -163,7 +161,7 @@ namespace BPASmartClient.MorkF } public void ThreeBlock() { - // WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0001 + // WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0001 WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false }); } public void OverTurnOff() @@ -226,6 +224,7 @@ namespace BPASmartClient.MorkF morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = 3 });//C料 morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId }); resultorder.AddRange(new int[] { 1, 2, 3 }); + morkF.listStirBom.Add(stirFryBom); } #endregion @@ -348,6 +347,7 @@ namespace BPASmartClient.MorkF { if (ushort.TryParse(res.BatchingLoc, out ushort loc)) { + //if (morkF.TakeMaterialQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) //将一个商品的ABC料位置存入队列 morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId, MaterialLoc = ushort.Parse(res.BatchingLoc) }); @@ -372,7 +372,7 @@ namespace BPASmartClient.MorkF } } - //根据ID 查找对应制作流程 + //根据ID 查找对应制作流程, } }); @@ -385,20 +385,144 @@ namespace BPASmartClient.MorkF { TakePlatelTask(); TurntableControl(); - ProcessExecute(); + MainProcessExecute(); + MinorProcessExcute(); SingleProcess(); } - //机器人,锅灶流程执行 - public void ProcessExecute() + //辅流程执行 + private void MinorProcessExcute() { - if (!morkF.ProcessExcuteLock) + if (!morkF.MinorProcessExcuteLock) { - morkF.ProcessExcuteLock = true; + morkF.MinorProcessExcuteLock = true; + Task.Run(() => + { + if (morkF.MinorProcessFlag && !morkF.RoobotIdle && morkF.TakeMaterialQueue.Count > 0) + { + morkF.MinorProessStatus = true; + morkF.MainProcessStatus = false; + StirFryBom bom = morkF.listStirBom.ElementAt(0); + morkF.listStirBom.RemoveAt(0); + foreach (var res in bom.StirFryActions) + { + MessageLog.GetInstance.Show($"执行流程{res.Time}"); + //机器人线程 + Task taskRobot = Task.Run(new Action(() => + { + foreach (var temp in res.RobotActions) + { + switch (temp) + { + case StirFryRobotAction.清洗槽取锅: + TakePotTask();//执行取锅操作 + break; + case StirFryRobotAction.加入A料: + TakeBurdenATask();//执行取A料操作 + break; + case StirFryRobotAction.加入B料: + TakeBurdenATask();//执行取B料操作 + break; + case StirFryRobotAction.加入C料: + TakeBurdenCTask();//执行取C料操作 + break; + case StirFryRobotAction.灶取锅: + OutDishTask();//执行出餐操作 + CleanPotTask();//洗锅操作 + break; + } + + } + + })); + //炒锅线程操作 + Task taskPot = Task.Run(new Action(() => + { + foreach (var temp in res.PotActions) + { + switch (temp) + { + case StirFryPotAction.NONE: + break; + case StirFryPotAction.大火t1s: + KitchenAdjustGears(3); + Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作 + break; + case StirFryPotAction.加油: + AddOil();//注油//执行加油操作 + break; + case StirFryPotAction.中火t2s: + KitchenAdjustGears(2); + Task.Delay(2000).Wait();//执行操作 + break; + case StirFryPotAction.小火持续: + KitchenAdjustGears(1); + break; + case StirFryPotAction.中火持续: + KitchenAdjustGears(5); + break; + case StirFryPotAction.大火持续: + KitchenAdjustGears(7); + break; + case StirFryPotAction.停止火力: + KitchenAdjustGears(0);//关闭灶加热 + break; + case StirFryPotAction.搅拌臂上位: + TurnUpStatusDetect();//执行搅拌臂上位操作 + break; + case StirFryPotAction.搅拌臂下位: + TurnDownStatusDetect();//执行搅拌臂下位操作 + break; + case StirFryPotAction.低速旋转: + TurnMachineGearsControl(1);//执行搅拌臂速度1挡操作 + break; + case StirFryPotAction.快速旋转: + TurnMachineGearsControl(2);//执行搅拌臂速度3挡操作 + break; + case StirFryPotAction.停止旋转: + TurnMachineGearsControl(0);//执行搅拌臂速度0挡操作 + break; + } + } + })); + Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束 + Task.Delay(res.During * 1000).Wait();//当前流程延迟 + if (morkF.MainProcessWait) + { + + KitchenAdjustGears(0);//关闭灶加热 + morkF.MinorProessStatus = false; + morkF.MainProcessStatus = true; + //阻塞辅流程 + minorReset.WaitOne(); + } + morkF.MinorProessStatus = true; + morkF.MainProcessStatus = false; + } + morkF.MinorOutMealComplete = true; + } + else + { + morkF.MinorProcessExcuteLock = false;//解除辅流程自锁 + } + }); + } + } + + //机器人,锅灶主流程执行 + public void MainProcessExecute() + { + if (!morkF.MainProcessExcuteLock) + { + morkF.MainProcessExcuteLock = true; Task.Run(new Action(() => { - if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakeMaterialQueue.Count > 0) + if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakeMaterialQueue.Count > 0 && morkF.MainProcessFlag) { - foreach (var res in stirFryBom.StirFryActions)//遍历所有流程 + morkF.MainProcessStatus = true; + morkF.MinorProessStatus = false; + StirFryBom bom = morkF.listStirBom.ElementAt(0); + morkF.listStirBom.RemoveAt(0); + foreach (var res in bom.StirFryActions)//遍历所有流程 { MessageLog.GetInstance.Show($"执行流程{res.Time}"); //机器人线程 @@ -415,12 +539,10 @@ namespace BPASmartClient.MorkF TakeBurdenATask();//执行取A料操作 break; case StirFryRobotAction.加入B料: - // TakeBurdenBTask();//执行取B料操作 TakeBurdenATask();//执行取B料操作 break; case StirFryRobotAction.加入C料: - //TakeBurdenCTask();//执行取C料操作 - TakeBurdenATask();//执行取C料操作 + TakeBurdenCTask();//执行取C料操作 break; case StirFryRobotAction.灶取锅: OutDishTask();//执行出餐操作 @@ -458,7 +580,7 @@ namespace BPASmartClient.MorkF KitchenAdjustGears(5); break; case StirFryPotAction.大火持续: - KitchenAdjustGears(6); + KitchenAdjustGears(7); break; case StirFryPotAction.停止火力: KitchenAdjustGears(0);//关闭灶加热 @@ -481,14 +603,26 @@ namespace BPASmartClient.MorkF } } })); + Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束 - Task.Delay(res.During * 1000).Wait();//当前流程延迟 + Task.Delay(res.During * 1000).Wait();//当前流程延迟 + if (morkF.MinorProcessWait) + { + KitchenAdjustGears(0);//关闭灶加热 + morkF.MinorProessStatus = true; + morkF.MainProcessStatus = false; + //阻塞主流程 + mainReset.WaitOne(); + } + morkF.MinorProessStatus = false; + morkF.MainProcessStatus = true; + } - morkF.OutMealComplete = true; + morkF.MainOutMealComplete = true; } else { - morkF.ProcessExcuteLock = false;//解除流程互锁 + morkF.MainProcessExcuteLock = false;//解除流程自锁 } })); } @@ -502,12 +636,20 @@ namespace BPASmartClient.MorkF //出餐完成,相应变量复位 - if (morkF.OutMealComplete) + if (morkF.MainOutMealComplete) + { + morkF.TakePlateLock = false; + morkF.PotInPlace = false; + morkF.MainProcessExcuteLock = false; + morkF.MainOrderMaterialCom = false; + } + + if (morkF.MinorOutMealComplete) { morkF.TakePlateLock = false; - morkF.TakePotLock = false; morkF.PotInPlace = false; - morkF.ProcessExcuteLock = false; + morkF.MinorProcessExcuteLock = false; + morkF.MinorOrderMaterialCom = false; } } @@ -567,8 +709,9 @@ namespace BPASmartClient.MorkF StartTakePlate(); morkF.CurrentOrderId = order.SuborderId; morkF.TakePlateLock = true; //订单完成后置false - morkF.OutMealComplete = false; - // OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COOKING); + morkF.MainOutMealComplete = false; + morkF.MinorOutMealComplete = false; + // OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COOKING); MessageLog.GetInstance.Show($"订单【{ morkF.CurrentOrderId}】执行取碗控制"); } } @@ -580,7 +723,11 @@ namespace BPASmartClient.MorkF /// private void TakePotTask() { - while (!(!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete))//等待清洗1准备就绪 + //while (!((!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete) || (!morkF.SecondCleanModule && !morkF.KitchenSecondStatus && morkF.SecondCleanComplete))) + //{ + // Task.Delay(5).Wait(); + //} + while (!(!morkF.CleanModule||!morkF.SecondCleanModule)&&(!morkF.KitchenOneStatus||!morkF.KitchenSecondStatus)&&(morkF.CleanComplete|| morkF.SecondCleanComplete))//等待取锅条件满足 { Task.Delay(5).Wait(); } @@ -590,6 +737,7 @@ namespace BPASmartClient.MorkF } TakePotToKitchen(); WriteData("M1.5", false);//清洗模组1完成复位 + WriteData("M2.0", false);//清洗模组2完成复位 MessageLog.GetInstance.Show($"订单【{ morkF.CurrentOrderId}】执行取锅到灶台控制"); while (!morkF.PutPotToKitchenComlete) { @@ -642,13 +790,10 @@ namespace BPASmartClient.MorkF { Task.Delay(5).Wait(); } + morkF.MainOrderMaterialCom = false; WriteData("M14.1", false);//机器人取料完成复位 morkF.TurnTableLock = false;//转台互锁解除 - while (!morkF.FallMaterialComplete)//等待倒料完成 - { - Task.Delay(5).Wait(); - } - MessageLog.GetInstance.Show($"订单【{ order.SuborderId}】,转台{loc}配料倒料完成"); + } /// @@ -672,14 +817,14 @@ namespace BPASmartClient.MorkF { Task.Delay(5).Wait(); } - + morkF.MainOrderMaterialCom = false; WriteData("M14.1", false);//机器人取料完成复位 morkF.TurnTableLock = false;//转台互锁解除 - while (!morkF.FallMaterialComplete)//等待倒料完成 - { - Task.Delay(5).Wait(); - } - MessageLog.GetInstance.Show($"订单【{ order.SuborderId}】,B料倒料完成"); + //while (!morkF.FallMaterialComplete)//等待倒料完成 + //{ + // Task.Delay(5).Wait(); + //} + //MessageLog.GetInstance.Show($"订单【{ order.SuborderId}】,B料倒料完成"); } /// /// 取调味品C料 @@ -704,13 +849,15 @@ namespace BPASmartClient.MorkF { Task.Delay(5).Wait(); } + morkF.MainOrderMaterialCom = false; WriteData("M14.1", false);//机器人取料完成复位 morkF.TurnTableLock = false;//转台互锁解除 - while (!morkF.FallMaterialComplete) - { - Task.Delay(5).Wait(); - } - MessageLog.GetInstance.Show($"订单【{ order.SuborderId}】,C料倒料完成"); + //while (!morkF.FallMaterialComplete) + //{ + // Task.Delay(5).Wait(); + //} + //morkF.SingelOrderMaterialCom = true; + //MessageLog.GetInstance.Show($"订单【{ order.SuborderId}】,C料倒料完成"); //} } /// @@ -718,10 +865,15 @@ namespace BPASmartClient.MorkF /// private void OutDishTask() { - while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足 + //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足 + //{ + // Task.Delay(5).Wait(); + //} + while (morkF.RoobotIdle || (!morkF.CleanComplete && !morkF.SecondCleanComplete) || !morkF.ProvidePlateComplete)//等待条件满足 { Task.Delay(5).Wait(); } + if (morkF.TakePlateQueue.Count == 0) { WriteData("M0.7", false);//无订单关闭抽风机 @@ -737,17 +889,24 @@ namespace BPASmartClient.MorkF /// private void CleanPotTask() { - - while (!morkF.PlaceRinseTableComplete || morkF.CleanModule) { Task.Delay(5).Wait(); } MessageLog.GetInstance.Show($"订单【{morkF.CurrentOrderId}】出餐完成"); WriteData("M14.2", false);//机器人出餐完成复位 - //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK); - + //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK); CleanModuleControl("Start"); + if (morkF.MainProcessStatus)//主流程 + { + morkF.MainProcessFlag = false; + minorReset.Set(); + } + else if (morkF.MinorProessStatus)//辅流程 + { + morkF.MinorProcessFlag = false; + mainReset.Set(); + } } /// /// 任务复位重启 @@ -788,7 +947,14 @@ namespace BPASmartClient.MorkF } WriteData("M8.3", false);//下降完成复位 MessageLog.GetInstance.Show($"翻转机下降完成"); - + //if (morkF.MaterialCount == 3 && morkF.MainProcessStatus) + //{ + // morkF.MainProcessWait = true; + //} + //else if (morkF.MaterialCount == 3 && morkF.MinorProessStatus) + //{ + // morkF.MinorProcessWait = true; + //} } /// @@ -806,6 +972,59 @@ namespace BPASmartClient.MorkF Task.Delay(5).Wait(); } WriteData("M8.1", false);//上升完成复位 + if (morkF.MainProcessStatus)//代表主流程执行的操作 + { + if (!morkF.MainOrderMaterialCom) + { + WriteData("M14.3", true);//倒料 + while (!morkF.FallMaterialComplete)//等待倒料完成 + { + Task.Delay(5).Wait(); + } + morkF.MaterialCount++; + WriteData("M14.3", false);//倒料复位 + if (morkF.MaterialCount == 3) + { + //允许执行下一个订单流程 + morkF.MaterialCount = 0; + morkF.MinorProcessFlag = true; + + } + morkF.MainOrderMaterialCom = true; + MessageLog.GetInstance.Show($"订单【{ morkF.CurrentOrderId}】,配料倒料完成"); + } + else //主流程准备阻塞 + { + morkF.MainProcessWait = true; + } + } + else if (morkF.MinorProessStatus)//代表辅流程执行的操作 + { + if (!morkF.MinorOrderMaterialCom) + { + WriteData("M14.3", true);//倒料 + while (!morkF.FallMaterialComplete)//等待倒料完成 + { + Task.Delay(5).Wait(); + } + morkF.MaterialCount++; + WriteData("M14.3", false);//倒料复位 + if (morkF.MaterialCount == 3) + { + //允许执行下一个订单流程 + morkF.MaterialCount = 0; + morkF.MainProcessFlag = true; + + } + morkF.MinorOrderMaterialCom = true; + MessageLog.GetInstance.Show($"订单【{ morkF.CurrentOrderId}】,配料倒料完成"); + } + else //辅流程准备阻塞 + { + morkF.MinorProcessWait = true; + } + } + MessageLog.GetInstance.Show("翻转机上升完成"); } @@ -931,7 +1150,7 @@ namespace BPASmartClient.MorkF } WriteData("M2.7", true);//加油 - WriteData("M0.7",true);//打开抽风机 + WriteData("M0.7", true);//打开抽风机 MessageLog.GetInstance.Show("开始注油"); while (!morkF.FallOilComplete) { diff --git a/BPASmartClient.MorkF/GVL_MorkF.cs b/BPASmartClient.MorkF/GVL_MorkF.cs index b08a3621..773f54ed 100644 --- a/BPASmartClient.MorkF/GVL_MorkF.cs +++ b/BPASmartClient.MorkF/GVL_MorkF.cs @@ -1,4 +1,5 @@ -using System; +using BPA.Models; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; @@ -25,14 +26,29 @@ namespace BPASmartClient.MorkF /// 清洗模组1状态 忙碌1 空闲0 /// public bool CleanModule { get; set; } + + /// + /// 清洗模组2状态 忙碌1 空闲0 + /// + public bool SecondCleanModule { get; set; } /// /// 清洗模组1完成状态 /// public bool CleanComplete { get; set; } + + // + /// 清洗模组2完成状态 + /// + public bool SecondCleanComplete { get; set; } /// /// 锅灶1状态 忙碌1 空闲0 /// public bool KitchenOneStatus { get; set; } + + /// + /// 锅灶1状态 忙碌1 空闲0 + /// + public bool KitchenSecondStatus { get; set; } /// /// 注油完成状态 /// @@ -159,17 +175,68 @@ namespace BPASmartClient.MorkF /// 转台互锁 /// public bool TurnTableLock { get; set; } - - public bool ProcessExcuteLock { get; set; } + /// + /// 主流程自锁 + /// + public bool MainProcessExcuteLock { get; set; } + /// + /// 辅流程自锁 + /// + public bool MinorProcessExcuteLock { get; set; } /// /// 开始取料标志 /// public bool AllowTakeMaterial { get; set; } /// - /// 当前订单完成标志 + /// 主流程订单完成标志 + /// + public bool MainOutMealComplete { get; set; } + /// + /// 辅流程订单完成标志 + /// + public bool MinorOutMealComplete { get; set; } + /// + /// 主流程订单取料结束 /// - public bool OutMealComplete { get; set; } + public bool MainOrderMaterialCom { get; set; } + /// + /// 主流程等待 + /// + public bool MainProcessWait { get; set; } + /// + /// 辅流程等待 + /// + public bool MinorProcessWait { get; set; } + /// + /// 辅流程订单取料结束 + /// + public bool MinorOrderMaterialCom { get; set; } + /// + /// 存储订单对应流程对象 + /// + public List listStirBom=new List(); + + /// + /// 下配料次数 + /// + public int MaterialCount { get; set; } + /// + /// 允许执行辅流程标识 + /// + public bool MinorProcessFlag { get; set; } + /// + /// 辅流程执行状态 + /// + public bool MinorProessStatus { get; set; } + /// + /// 允许执行主流程标识 + /// + public bool MainProcessFlag { get; set; } = true; + /// + /// 主流程执行状态 + /// + public bool MainProcessStatus { get; set; } } } diff --git a/BPASmartClient.MorkM/Control_MORKM.cs b/BPASmartClient.MorkM/Control_MORKM.cs index 27eb253a..69357e64 100644 --- a/BPASmartClient.MorkM/Control_MORKM.cs +++ b/BPASmartClient.MorkM/Control_MORKM.cs @@ -13,6 +13,8 @@ using BPASmartClient.EventBus; using static BPASmartClient.EventBus.EventBus; using BPASmartClient.MorkS.ViewModel; using BPASmartClient.MorkM.Model; +using System.Collections.ObjectModel; +using BPASmartClient.Model.PLC; namespace BPASmartClient.MorkM { @@ -44,10 +46,10 @@ namespace BPASmartClient.MorkM // string guid = new Guid().ToString(); // mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid }); - // MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】"); + // DeviceProcessLogShow($"添加订单:面条位置【{NoodleLoc}】"); // mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid }); - // MessageLog.GetInstance.Show($"添加订单:碗位置【{BowlLoc}】"); + // DeviceProcessLogShow($"添加订单:碗位置【{BowlLoc}】"); // Thread.Sleep(60000); // }), "ForOrder"); // }), "EnableForOrder"); @@ -61,7 +63,7 @@ namespace BPASmartClient.MorkM // })); // }), "StopForOrder"); - // MessageLog.GetInstance.Show("MORKM 设备初始化完成"); + // DeviceProcessLogShow("MORKM 设备初始化完成"); //} //private void ResetProgram() @@ -192,12 +194,12 @@ namespace BPASmartClient.MorkM // { // orders.Add(new OrderLocInfo() { Loc = item, SuborderId = subId, MakeType = false }); // //mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = item, SuborderId = subId }); - // //MessageLog.GetInstance.Show($"添加订单:面条位置【{item}】"); + // //DeviceProcessLogShow($"添加订单:面条位置【{item}】"); // } // if (item >= 10 && item <= 11) // { // mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = item, SuborderId = subId, MakeType = false }); - // MessageLog.GetInstance.Show($"添加订单:碗位置【{item}】"); + // DeviceProcessLogShow($"添加订单:碗位置【{item}】"); // } // } // mORKS.DishNumber = orders.Count;//订单中配菜的数量 @@ -242,7 +244,7 @@ namespace BPASmartClient.MorkM //{ // if (broadcast != null && broadcast is IOTCommandModel iOTCommand) // { - // MessageLog.GetInstance.Show($"IOT 广播消息命令 {iOTCommand.deviceName} 设备命令 {iOTCommand.CommandName} 控制变量{iOTCommand.CommandValue.Keys.First()}{iOTCommand.CommandValue[iOTCommand.CommandValue.Keys.First()]}"); + // DeviceProcessLogShow($"IOT 广播消息命令 {iOTCommand.deviceName} 设备命令 {iOTCommand.CommandName} 控制变量{iOTCommand.CommandValue.Keys.First()}{iOTCommand.CommandValue[iOTCommand.CommandValue.Keys.First()]}"); // switch (iOTCommand.CommandName) // { // case 0://控制类 @@ -286,85 +288,95 @@ namespace BPASmartClient.MorkM ///// ///// 数据解析 ///// - //public void DataParse(T order) - //{ - // OrderCount++; - // MessageLog.GetInstance.Show($"接收到{OrderCount}次订单"); - // if (order is MorkOrderPush morkOrderPush) - // { - // OrderInformation newOrder = new OrderInformation();//2022.4.30 修改 - // List locs = new List(); - // foreach (var item in morkOrderPush.GoodBatchings) - // { - // var res = Json.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); - // if (res != null) - // { - // if (ushort.TryParse(res.BatchingLoc, out ushort loc)) - // { - // if (loc >= 1 && loc <= 5) - // { - // locs.Add(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = res.BatchingId, MakeType = morkOrderPush.MakeID == "2" }); //新增冒菜干拌or加汤 - // } - // else if (loc >= 10 && loc <= 11) - // { - // int index = 0; - // if (Json.Data.recipeBoms != null) - // { - // index = Array.FindIndex(Json.Data.recipeBoms?.RecipeIds.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); - // index++; - // } - // if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == morkOrderPush.SuborderId) == null) - // mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() - // { - // Loc = 11, - // SuborderId = morkOrderPush.SuborderId, - // RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 - // }); - // } - // } - // } - // } - // //手动供碗 调试用 - // mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() - // { - // Loc = 11, - // SuborderId = morkOrderPush.SuborderId, - // MakeType = morkOrderPush.MakeID == "2" - // }); - // mORKS.DishNumber = locs.Count;//订单中配菜的数量 2022.4.30 修改 - // while (locs.Count > 0) - // { - // for (int i = 0; i < locs.Count; i++) - // { - // var res = locs.FirstOrDefault(p => p.Loc % 2 != 0); - // if (res != null) - // { - // //if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == res.SuborderId) == null) - // mORKS.RBTakeNoodleTask.Enqueue(res); - // locs.Remove(res); + public void DataParse() + { + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + if (@event == null) return; + if (@event is DoOrderEvent order) + { + mORKS.doOrderEvents.Add(order); + if (order.MorkOrder.GoodBatchings == null) return; + OrderCount++; + OrderChange(order.MorkOrder.SuborderId, ORDER_STATUS.WAIT); + DeviceProcessLogShow($"接收到{OrderCount}次订单"); + //if (order is MorkOrderPush morkOrderPush) + //{ + OrderInformation newOrder = new OrderInformation();//2022.4.30 修改 + List locs = new List(); + foreach (var item in order.MorkOrder.GoodBatchings) + { + var res = Json.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + if (res != null) + { + if (ushort.TryParse(res.BatchingLoc, out ushort loc)) + { + if (loc >= 1 && loc <= 5) + { + locs.Add(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId, MakeType = order.MorkOrder.MakeID == "2" }); //新增冒菜干拌or加汤 + } + else if (loc >= 10 && loc <= 11) + { + int index = 0; + if (Json.Data.recipeBoms != null) + { + index = Array.FindIndex(Json.Data.recipeBoms?.RecipeIds.ToArray(), p => p.RecipeId == order.MorkOrder.RecipeId); + index++; + } + if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() + { + Loc = 11, + SuborderId = order.MorkOrder.SuborderId, + RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 + }); + } + } + } + } + //手动供碗 调试用 + mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() + { + Loc = 11, + SuborderId = order.MorkOrder.SuborderId, + MakeType = order.MorkOrder.MakeID == "2" + }); + mORKS.DishNumber = locs.Count;//订单中配菜的数量 2022.4.30 修改 + while (locs.Count > 0) + { + for (int i = 0; i < locs.Count; i++) + { + var res = locs.FirstOrDefault(p => p.Loc % 2 != 0); + if (res != null) + { + //if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == res.SuborderId) == null) + mORKS.RBTakeNoodleTask.Enqueue(res); + locs.Remove(res); - // } - // else - // { - // //if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == locs[i].SuborderId) == null) - // mORKS.RBTakeNoodleTask.Enqueue(locs[i]); - // mORKS.VegtabNum++; - // locs.RemoveAt(i); + } + else + { + //if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == locs[i].SuborderId) == null) + mORKS.RBTakeNoodleTask.Enqueue(locs[i]); + mORKS.VegtabNum++; + locs.RemoveAt(i); - // } - // } - // } + } + } + } - // Dictionary dic = new Dictionary(); - // newOrder.DishNum = mORKS.DishNumber; - // newOrder.VegatableNumber = mORKS.VegtabNum; - // //newOrder.MakeType = morkOrderPush.MakeType; - // dic.Add(morkOrderPush.SuborderId, newOrder); - // mORKS.Conqueue.Enqueue(dic); - // mORKS.VegtabNum = 0; - // mORKS.DishNumber = 0; - // } - //} + Dictionary dic = new Dictionary(); + newOrder.DishNum = mORKS.DishNumber; + newOrder.VegatableNumber = mORKS.VegtabNum; + //newOrder.MakeType = morkOrderPush.MakeType; + dic.Add(order.MorkOrder.SuborderId, newOrder); + mORKS.Conqueue.Enqueue(dic); + mORKS.VegtabNum = 0; + mORKS.DishNumber = 0; + //} + } + }); + } public void Main() { @@ -401,8 +413,8 @@ namespace BPASmartClient.MorkM mORKS.OutMealType = orderLocInfo.MakeType;//新增冒菜干拌or加汤 TakeBowlControl(orderLocInfo.Loc); SetRecipeNumber(orderLocInfo.RecipeNumber); - SimpleFactory.GetInstance.OrderChanged(mORKS.TakeBowlId, ORDER_STATUS.COOKING); - MessageLog.GetInstance.Show($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]"); + OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING); + DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]"); } mORKS.TakeBowlInterlock = true; } @@ -413,24 +425,24 @@ namespace BPASmartClient.MorkM /// private void TurntableControl() { - if (GeneralConfig.EnableLocalSimOrder) - { - //不做轮询,直接取面,模拟订单使用 - if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) - { - if (mORKS.TurntableLowerLimit) - { - TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); - if (mORKS.RBTakeNoodleTask.ElementAt(0).Loc == mORKS.TurntableFeedbackloc) - { - mORKS.TurntableLocLists.Clear(); - mORKS.AllowTakeNoodle = true; - MessageLog.GetInstance.Show($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面"); - } - } - } - } - else + //if (GeneralConfig.EnableLocalSimOrder) + //{ + // //不做轮询,直接取面,模拟订单使用 + // if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) + // { + // if (mORKS.TurntableLowerLimit) + // { + // TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); + // if (mORKS.RBTakeNoodleTask.ElementAt(0).Loc == mORKS.TurntableFeedbackloc) + // { + // mORKS.TurntableLocLists.Clear(); + // mORKS.AllowTakeNoodle = true; + // DeviceProcessLogShow($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面"); + // } + // } + // } + //} + //else { //正常轮询 if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) @@ -445,7 +457,7 @@ namespace BPASmartClient.MorkM TurntableStart(mORKS.TurntableFeedbackloc); mORKS.TurntableLocLists.Clear(); mORKS.AllowTakeNoodle = true; - MessageLog.GetInstance.Show($"控制机器人去转台【{mORKS.TurntableFeedbackloc}】号位置取面"); + DeviceProcessLogShow($"控制机器人去转台【{mORKS.TurntableFeedbackloc}】号位置取面"); } else { @@ -458,7 +470,7 @@ namespace BPASmartClient.MorkM if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) { TurntableStart(loc); - MessageLog.GetInstance.Show($"没有物料检测的启动转台控制,转台位置:[{loc}]"); + DeviceProcessLogShow($"没有物料检测的启动转台控制,转台位置:[{loc}]"); break; } else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc); @@ -467,7 +479,7 @@ namespace BPASmartClient.MorkM } } } - else MessageLog.GetInstance.Show("未找到可用的物料信息"); + else DeviceProcessLogShow("未找到可用的物料信息"); } } @@ -476,7 +488,7 @@ namespace BPASmartClient.MorkM { mORKS.CurrentLoc = 0; mORKS.TurntableInterlock = false; - MessageLog.GetInstance.Show("转台到位检测"); + DeviceProcessLogShow("转台到位检测"); } //补料完成检测 @@ -486,7 +498,7 @@ namespace BPASmartClient.MorkM { mORKS.TurntableLocLists.Clear(); mORKS.TurntableInterlock = false; - MessageLog.GetInstance.Show("补料完成检测"); + DeviceProcessLogShow("补料完成检测"); } } } @@ -512,7 +524,7 @@ namespace BPASmartClient.MorkM //机器人开始取面 RobotTakeNoodle(); // SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); - MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); + DeviceProcessLogShow($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); //写入煮菜时间 List values = new List(); @@ -520,13 +532,14 @@ namespace BPASmartClient.MorkM { values.Add(2);//分 values.Add(0);//秒 - ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray()); + // //ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray()); + EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address =$"VW{ 116 + (loc * 6) }" , Value = values.ToArray() }); } else //荤菜 { values.Add(4);//分 values.Add(0);//秒 - ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray()); + EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = $"VW{ 116 + (loc * 6) }", Value = values.ToArray() }); } @@ -588,7 +601,7 @@ namespace BPASmartClient.MorkM // mORKS.CookNodelId[loc] = string.Empty; mORKS.orderLocInfos[location] = null; - MessageLog.GetInstance.Show($"{location + 1}号位置出餐控制"); + DeviceProcessLogShow($"{location + 1}号位置出餐控制"); mORKS.OutNoodleing = true; mORKS.Count++; CheckLastDish(); @@ -613,7 +626,7 @@ namespace BPASmartClient.MorkM // mORKS.CookNodelId[loc] = string.Empty; mORKS.orderLocInfos[location] = null; // mORKS.Count++; - MessageLog.GetInstance.Show($"{location + 1}号位置出餐控制"); + DeviceProcessLogShow($"{location + 1}号位置出餐控制"); mORKS.OutNoodleing = true; mORKS.CountMeat++; CheckLastDish(); @@ -649,7 +662,7 @@ namespace BPASmartClient.MorkM if (mORKS.OutMealType) { AddSoup();//加汤 - MessageLog.GetInstance.Show("正在加汤"); + DeviceProcessLogShow("正在加汤"); } else { @@ -690,8 +703,8 @@ namespace BPASmartClient.MorkM mORKS.IngredientsCompleteId = mORKS.TakeBowlId; // mORKS.TakeBowlId = string.Empty; - // MessageLog.GetInstance.Show("碗到位,允许到面"); - MessageLog.GetInstance.Show($"碗到位,允许到面,{mORKS.IngredientsCompleteId}"); + // DeviceProcessLogShow("碗到位,允许到面"); + DeviceProcessLogShow($"碗到位,允许到面,{mORKS.IngredientsCompleteId}"); // mORKS.TakeBowlInterlock = false; } @@ -699,16 +712,16 @@ namespace BPASmartClient.MorkM if (RTrig.GetInstance("CompleteChange").Start(mORKS.RbOutMealComplete)) { - SimpleFactory.GetInstance.OrderChanged(mORKS.OutMealId, ORDER_STATUS.COMPLETED_COOK); - MessageLog.GetInstance.Show($"订单【{mORKS.OutMealId}】制作完成"); + OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_COOK); + DeviceProcessLogShow($"订单【{mORKS.OutMealId}】制作完成"); mORKS.OutNoodleing = false; } //取餐完成逻辑处理 if (DelayRTrig.GetInstance("CompleteChange1").Start(mORKS.RbOutMealComplete && !mORKS.TakeMealDetect, 2)) { - SimpleFactory.GetInstance.OrderChanged(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); - MessageLog.GetInstance.Show($"订单【{mORKS.OutMealId}】取餐完成"); + OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); + DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成"); ResetCookComplete(); mORKS.OutMealId = string.Empty; } @@ -719,7 +732,7 @@ namespace BPASmartClient.MorkM mORKS.TakeNoodleInterlock = false; mORKS.AllowTakeNoodle = false; mORKS.TurntableInterlock = false; - MessageLog.GetInstance.Show("机器人取面完成信号检测"); + DeviceProcessLogShow("机器人取面完成信号检测"); TakeNoodleCompleteReset(); } @@ -777,12 +790,12 @@ namespace BPASmartClient.MorkM } if (recipeBoms.Count > 0) { - if (ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray())) - { - MessageLog.GetInstance.Show("成功写入配方数据"); - } + //if (//ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray())) + //{ + // DeviceProcessLogShow("成功写入配方数据"); + //} } - else { MessageLog.GetInstance.Show("配方数据为空"); } + else { DeviceProcessLogShow("配方数据为空"); } } /// @@ -790,7 +803,7 @@ namespace BPASmartClient.MorkM /// private void TakeNoodleCompleteReset() { - ModbusTcpHelper.GetInstance.Write(1124, WriteType.Coils, false); + ////ModbusTcpHelper.GetInstance.Write(1124, WriteType.Coils, false); } /// @@ -802,8 +815,8 @@ namespace BPASmartClient.MorkM if (num >= 1 && num <= 6) { ushort addRess = (ushort)(1136 + num - 1); - ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false); - MessageLog.GetInstance.Show($"{num}号煮面口占用复位"); + //ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false); + DeviceProcessLogShow($"{num}号煮面口占用复位"); } } @@ -814,7 +827,7 @@ namespace BPASmartClient.MorkM /// private void SetRecipeNumber(ushort num) { - ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, num); + //ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, num); } /// @@ -826,8 +839,8 @@ namespace BPASmartClient.MorkM mORKS.CurrentLoc = loc; mORKS.TurntableInterlock = true; mORKS.TurntableLocLists.Add(loc); - ModbusTcpHelper.GetInstance.Write(101, WriteType.HoldingRegisters, loc); - ModbusTcpHelper.GetInstance.Write(325, WriteType.Coils, true); + //ModbusTcpHelper.GetInstance.Write(101, WriteType.HoldingRegisters, loc); + //ModbusTcpHelper.GetInstance.Write(325, WriteType.Coils, true); } /// @@ -836,7 +849,7 @@ namespace BPASmartClient.MorkM /// private void SetFallNoodleLoc(ushort loc) { - ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, loc); + //ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, loc); } /// @@ -845,7 +858,7 @@ namespace BPASmartClient.MorkM /// private void SetTakeNoodleLoc(ushort loc) { - ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, loc); + //ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, loc); } /// @@ -856,11 +869,11 @@ namespace BPASmartClient.MorkM { if (loc == 10)//小碗 { - ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); + //ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); } else if (loc == 11)//大碗 { - ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); + //ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); } } @@ -869,7 +882,7 @@ namespace BPASmartClient.MorkM /// private void RobotTakeNoodle() { - ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true); + //ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true); } /// @@ -877,13 +890,13 @@ namespace BPASmartClient.MorkM /// private void RobotOutMeal() { - ModbusTcpHelper.GetInstance.Write(324, WriteType.Coils, true); - var result = ModbusTcpHelper.GetInstance.Read(324, ReadType.Coils); - if (result is bool res) - while (!res) - { - ModbusTcpHelper.GetInstance.Write(324, WriteType.Coils, true); - } + // ModbusTcpHelper.GetInstance.Write(324, WriteType.Coils, true); + // var result = ModbusTcpHelper.GetInstance.Read(324, ReadType.Coils); + //if (result is bool res) + // while (!res) + // { + //ModbusTcpHelper.GetInstance.Write(324, WriteType.Coils, true); + // } } /// @@ -891,7 +904,7 @@ namespace BPASmartClient.MorkM /// private void ResetCookComplete() { - ModbusTcpHelper.GetInstance.Write(1126, WriteType.Coils, false); + //ModbusTcpHelper.GetInstance.Write(1126, WriteType.Coils, false); } /// @@ -899,7 +912,7 @@ namespace BPASmartClient.MorkM /// private void ResetAllowFallNoodle() { - ModbusTcpHelper.GetInstance.Write(1123, WriteType.Coils, false); + //ModbusTcpHelper.GetInstance.Write(1123, WriteType.Coils, false); } /// @@ -907,9 +920,9 @@ namespace BPASmartClient.MorkM /// public async void DeviceInit() { - ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true); + //ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true); await Task.Delay(1000); - ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, false); + //ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, false); } @@ -918,7 +931,8 @@ namespace BPASmartClient.MorkM /// public void CookComplete() { - ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M0.6"), WriteType.Coils, true); + ////ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M0.6"), WriteType.Coils, true); + EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = "M0.6", Value = true }); } /// @@ -926,7 +940,8 @@ namespace BPASmartClient.MorkM /// public void AddSoup() { - ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M0.7"), WriteType.Coils, true); + ////ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M0.7"), WriteType.Coils, true); + EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = "M0.7", Value = true }); } private void ServerInit() @@ -987,7 +1002,10 @@ namespace BPASmartClient.MorkM }), "WriteBools"); ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice"); } - + private void WriteData(string address, object value) + { + EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value }); + } public override void ResetProgram() { mORKS = null; diff --git a/BPASmartClient.MorkM/OrderLocInfo.cs b/BPASmartClient.MorkM/OrderLocInfo.cs index 40eda077..ba5367a3 100644 --- a/BPASmartClient.MorkM/OrderLocInfo.cs +++ b/BPASmartClient.MorkM/OrderLocInfo.cs @@ -1,4 +1,5 @@ -using System; +using BPA.Message; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,6 +14,7 @@ namespace BPASmartClient.MorkM public ushort RecipeNumber { get; set; } public int BatchingId { get; set; } public string GoodName { get; set; } + public bool MakeType { get; set; } } /// @@ -24,6 +26,7 @@ namespace BPASmartClient.MorkM public int DishNum { get; set; } - // public GoodsMakeType MakeType { get; set; } + + // public GoodsMakeType MakeType { get; set; } } } diff --git a/BPASmartClient/DeviceInfo.xml b/BPASmartClient/DeviceInfo.xml index b490afb3..fa1fd9db 100644 --- a/BPASmartClient/DeviceInfo.xml +++ b/BPASmartClient/DeviceInfo.xml @@ -61,7 +61,7 @@ -->--> - + @@ -84,6 +84,6 @@ - + -->-->