@@ -15,9 +15,11 @@ namespace BPASmartClient.MorkF | |||||
public class Control_MorkF : BaseDevice | public class Control_MorkF : BaseDevice | ||||
{ | { | ||||
public override DeviceClientType DeviceType => DeviceClientType.MORKSF; | public override DeviceClientType DeviceType => DeviceClientType.MORKSF; | ||||
public AutoResetEvent minorReset = new AutoResetEvent(false); | |||||
public AutoResetEvent mainReset = new AutoResetEvent(false); | |||||
GVL_MorkF morkF = new GVL_MorkF();//全局对象声明 | GVL_MorkF morkF = new GVL_MorkF();//全局对象声明 | ||||
public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象 | public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象 | ||||
List<int> resultorder = new List<int>();//调试变量 | List<int> resultorder = new List<int>();//调试变量 | ||||
public static readonly object taskLock = new object(); | public static readonly object taskLock = new object(); | ||||
/// <summary> | /// <summary> | ||||
@@ -62,19 +64,16 @@ namespace BPASmartClient.MorkF | |||||
} | } | ||||
//流程 | //流程 | ||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } }); | stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } }); | ||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 25 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | |||||
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.大火持续, StirFryPotAction.低速旋转 }, During = 5 }); | |||||
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.快速旋转 }, During = 50 }); | |||||
//stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, PotActions = new List<StirFryPotAction>() { StirFryPotAction.大火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 25 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, PotActions = new List<StirFryPotAction>() { StirFryPotAction.大火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 15 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List<StirFryPotAction>() { StirFryPotAction.大火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.大火持续 }, During = 5 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 6 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.停止火力, StirFryPotAction.搅拌臂上位 } });//加A料 | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 6 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料 | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 9 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料 | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | ||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } }); | stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } }); | ||||
} | } | ||||
@@ -117,29 +116,28 @@ namespace BPASmartClient.MorkF | |||||
} | } | ||||
//流程 | //流程 | ||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } }); | stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } }); | ||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 5 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 5 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油 }, During = 12 }); | stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油 }, During = 12 }); | ||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加A料 | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 25 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 25 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料 | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 30 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料 | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 }); | |||||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } }); | stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } }); | ||||
} | } | ||||
public void TakePot() | public void TakePot() | ||||
{ | { | ||||
WriteData("M14.0", true); | WriteData("M14.0", true); | ||||
} | } | ||||
public void TakePotReset() | public void TakePotReset() | ||||
{ | { | ||||
WriteData("M14.0", false); | WriteData("M14.0", false); | ||||
} | } | ||||
public void TakeOff() | public void TakeOff() | ||||
@@ -163,7 +161,7 @@ namespace BPASmartClient.MorkF | |||||
} | } | ||||
public void ThreeBlock() | 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 }); | WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false }); | ||||
} | } | ||||
public void OverTurnOff() | public void OverTurnOff() | ||||
@@ -226,6 +224,7 @@ namespace BPASmartClient.MorkF | |||||
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = 3 });//C料 | morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = 3 });//C料 | ||||
morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId }); | morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId }); | ||||
resultorder.AddRange(new int[] { 1, 2, 3 }); | resultorder.AddRange(new int[] { 1, 2, 3 }); | ||||
morkF.listStirBom.Add(stirFryBom); | |||||
} | } | ||||
#endregion | #endregion | ||||
@@ -348,6 +347,7 @@ namespace BPASmartClient.MorkF | |||||
{ | { | ||||
if (ushort.TryParse(res.BatchingLoc, out ushort loc)) | if (ushort.TryParse(res.BatchingLoc, out ushort loc)) | ||||
{ | { | ||||
//if (morkF.TakeMaterialQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) | //if (morkF.TakeMaterialQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) | ||||
//将一个商品的ABC料位置存入队列 | //将一个商品的ABC料位置存入队列 | ||||
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId, MaterialLoc = ushort.Parse(res.BatchingLoc) }); | 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(); | TakePlatelTask(); | ||||
TurntableControl(); | TurntableControl(); | ||||
ProcessExecute(); | |||||
MainProcessExecute(); | |||||
MinorProcessExcute(); | |||||
SingleProcess(); | 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(() => | 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}"); | MessageLog.GetInstance.Show($"执行流程{res.Time}"); | ||||
//机器人线程 | //机器人线程 | ||||
@@ -415,12 +539,10 @@ namespace BPASmartClient.MorkF | |||||
TakeBurdenATask();//执行取A料操作 | TakeBurdenATask();//执行取A料操作 | ||||
break; | break; | ||||
case StirFryRobotAction.加入B料: | case StirFryRobotAction.加入B料: | ||||
// TakeBurdenBTask();//执行取B料操作 | |||||
TakeBurdenATask();//执行取B料操作 | TakeBurdenATask();//执行取B料操作 | ||||
break; | break; | ||||
case StirFryRobotAction.加入C料: | case StirFryRobotAction.加入C料: | ||||
//TakeBurdenCTask();//执行取C料操作 | |||||
TakeBurdenATask();//执行取C料操作 | |||||
TakeBurdenCTask();//执行取C料操作 | |||||
break; | break; | ||||
case StirFryRobotAction.灶取锅: | case StirFryRobotAction.灶取锅: | ||||
OutDishTask();//执行出餐操作 | OutDishTask();//执行出餐操作 | ||||
@@ -458,7 +580,7 @@ namespace BPASmartClient.MorkF | |||||
KitchenAdjustGears(5); | KitchenAdjustGears(5); | ||||
break; | break; | ||||
case StirFryPotAction.大火持续: | case StirFryPotAction.大火持续: | ||||
KitchenAdjustGears(6); | |||||
KitchenAdjustGears(7); | |||||
break; | break; | ||||
case StirFryPotAction.停止火力: | case StirFryPotAction.停止火力: | ||||
KitchenAdjustGears(0);//关闭灶加热 | KitchenAdjustGears(0);//关闭灶加热 | ||||
@@ -481,14 +603,26 @@ namespace BPASmartClient.MorkF | |||||
} | } | ||||
} | } | ||||
})); | })); | ||||
Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束 | 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 | 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.TakePlateLock = false; | ||||
morkF.TakePotLock = false; | |||||
morkF.PotInPlace = false; | morkF.PotInPlace = false; | ||||
morkF.ProcessExcuteLock = false; | |||||
morkF.MinorProcessExcuteLock = false; | |||||
morkF.MinorOrderMaterialCom = false; | |||||
} | } | ||||
} | } | ||||
@@ -567,8 +709,9 @@ namespace BPASmartClient.MorkF | |||||
StartTakePlate(); | StartTakePlate(); | ||||
morkF.CurrentOrderId = order.SuborderId; | morkF.CurrentOrderId = order.SuborderId; | ||||
morkF.TakePlateLock = true; //订单完成后置false | 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}】执行取碗控制"); | MessageLog.GetInstance.Show($"订单【{ morkF.CurrentOrderId}】执行取碗控制"); | ||||
} | } | ||||
} | } | ||||
@@ -580,7 +723,11 @@ namespace BPASmartClient.MorkF | |||||
/// <exception cref="NotImplementedException"></exception> | /// <exception cref="NotImplementedException"></exception> | ||||
private void TakePotTask() | 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(); | Task.Delay(5).Wait(); | ||||
} | } | ||||
@@ -590,6 +737,7 @@ namespace BPASmartClient.MorkF | |||||
} | } | ||||
TakePotToKitchen(); | TakePotToKitchen(); | ||||
WriteData("M1.5", false);//清洗模组1完成复位 | WriteData("M1.5", false);//清洗模组1完成复位 | ||||
WriteData("M2.0", false);//清洗模组2完成复位 | |||||
MessageLog.GetInstance.Show($"订单【{ morkF.CurrentOrderId}】执行取锅到灶台控制"); | MessageLog.GetInstance.Show($"订单【{ morkF.CurrentOrderId}】执行取锅到灶台控制"); | ||||
while (!morkF.PutPotToKitchenComlete) | while (!morkF.PutPotToKitchenComlete) | ||||
{ | { | ||||
@@ -642,13 +790,10 @@ namespace BPASmartClient.MorkF | |||||
{ | { | ||||
Task.Delay(5).Wait(); | Task.Delay(5).Wait(); | ||||
} | } | ||||
morkF.MainOrderMaterialCom = false; | |||||
WriteData("M14.1", false);//机器人取料完成复位 | WriteData("M14.1", false);//机器人取料完成复位 | ||||
morkF.TurnTableLock = false;//转台互锁解除 | morkF.TurnTableLock = false;//转台互锁解除 | ||||
while (!morkF.FallMaterialComplete)//等待倒料完成 | |||||
{ | |||||
Task.Delay(5).Wait(); | |||||
} | |||||
MessageLog.GetInstance.Show($"订单【{ order.SuborderId}】,转台{loc}配料倒料完成"); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -672,14 +817,14 @@ namespace BPASmartClient.MorkF | |||||
{ | { | ||||
Task.Delay(5).Wait(); | Task.Delay(5).Wait(); | ||||
} | } | ||||
morkF.MainOrderMaterialCom = false; | |||||
WriteData("M14.1", false);//机器人取料完成复位 | WriteData("M14.1", false);//机器人取料完成复位 | ||||
morkF.TurnTableLock = 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料倒料完成"); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 取调味品C料 | /// 取调味品C料 | ||||
@@ -704,13 +849,15 @@ namespace BPASmartClient.MorkF | |||||
{ | { | ||||
Task.Delay(5).Wait(); | Task.Delay(5).Wait(); | ||||
} | } | ||||
morkF.MainOrderMaterialCom = false; | |||||
WriteData("M14.1", false);//机器人取料完成复位 | WriteData("M14.1", false);//机器人取料完成复位 | ||||
morkF.TurnTableLock = 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料倒料完成"); | |||||
//} | //} | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -718,10 +865,15 @@ namespace BPASmartClient.MorkF | |||||
/// </summary> | /// </summary> | ||||
private void OutDishTask() | 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(); | Task.Delay(5).Wait(); | ||||
} | } | ||||
if (morkF.TakePlateQueue.Count == 0) | if (morkF.TakePlateQueue.Count == 0) | ||||
{ | { | ||||
WriteData("M0.7", false);//无订单关闭抽风机 | WriteData("M0.7", false);//无订单关闭抽风机 | ||||
@@ -737,17 +889,24 @@ namespace BPASmartClient.MorkF | |||||
/// </summary> | /// </summary> | ||||
private void CleanPotTask() | private void CleanPotTask() | ||||
{ | { | ||||
while (!morkF.PlaceRinseTableComplete || morkF.CleanModule) | while (!morkF.PlaceRinseTableComplete || morkF.CleanModule) | ||||
{ | { | ||||
Task.Delay(5).Wait(); | Task.Delay(5).Wait(); | ||||
} | } | ||||
MessageLog.GetInstance.Show($"订单【{morkF.CurrentOrderId}】出餐完成"); | MessageLog.GetInstance.Show($"订单【{morkF.CurrentOrderId}】出餐完成"); | ||||
WriteData("M14.2", false);//机器人出餐完成复位 | WriteData("M14.2", false);//机器人出餐完成复位 | ||||
//OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK); | |||||
//OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK); | |||||
CleanModuleControl("Start"); | CleanModuleControl("Start"); | ||||
if (morkF.MainProcessStatus)//主流程 | |||||
{ | |||||
morkF.MainProcessFlag = false; | |||||
minorReset.Set(); | |||||
} | |||||
else if (morkF.MinorProessStatus)//辅流程 | |||||
{ | |||||
morkF.MinorProcessFlag = false; | |||||
mainReset.Set(); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 任务复位重启 | /// 任务复位重启 | ||||
@@ -788,7 +947,14 @@ namespace BPASmartClient.MorkF | |||||
} | } | ||||
WriteData("M8.3", false);//下降完成复位 | WriteData("M8.3", false);//下降完成复位 | ||||
MessageLog.GetInstance.Show($"翻转机下降完成"); | MessageLog.GetInstance.Show($"翻转机下降完成"); | ||||
//if (morkF.MaterialCount == 3 && morkF.MainProcessStatus) | |||||
//{ | |||||
// morkF.MainProcessWait = true; | |||||
//} | |||||
//else if (morkF.MaterialCount == 3 && morkF.MinorProessStatus) | |||||
//{ | |||||
// morkF.MinorProcessWait = true; | |||||
//} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -806,6 +972,59 @@ namespace BPASmartClient.MorkF | |||||
Task.Delay(5).Wait(); | Task.Delay(5).Wait(); | ||||
} | } | ||||
WriteData("M8.1", false);//上升完成复位 | 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("翻转机上升完成"); | MessageLog.GetInstance.Show("翻转机上升完成"); | ||||
} | } | ||||
@@ -931,7 +1150,7 @@ namespace BPASmartClient.MorkF | |||||
} | } | ||||
WriteData("M2.7", true);//加油 | WriteData("M2.7", true);//加油 | ||||
WriteData("M0.7",true);//打开抽风机 | |||||
WriteData("M0.7", true);//打开抽风机 | |||||
MessageLog.GetInstance.Show("开始注油"); | MessageLog.GetInstance.Show("开始注油"); | ||||
while (!morkF.FallOilComplete) | while (!morkF.FallOilComplete) | ||||
{ | { | ||||
@@ -1,4 +1,5 @@ | |||||
using System; | |||||
using BPA.Models; | |||||
using System; | |||||
using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -25,14 +26,29 @@ namespace BPASmartClient.MorkF | |||||
/// 清洗模组1状态 忙碌1 空闲0 | /// 清洗模组1状态 忙碌1 空闲0 | ||||
/// </summary> | /// </summary> | ||||
public bool CleanModule { get; set; } | public bool CleanModule { get; set; } | ||||
/// <summary> | |||||
/// 清洗模组2状态 忙碌1 空闲0 | |||||
/// </summary> | |||||
public bool SecondCleanModule { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 清洗模组1完成状态 | /// 清洗模组1完成状态 | ||||
/// </summary> | /// </summary> | ||||
public bool CleanComplete { get; set; } | public bool CleanComplete { get; set; } | ||||
// <summary> | |||||
/// 清洗模组2完成状态 | |||||
/// </summary> | |||||
public bool SecondCleanComplete { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 锅灶1状态 忙碌1 空闲0 | /// 锅灶1状态 忙碌1 空闲0 | ||||
/// </summary> | /// </summary> | ||||
public bool KitchenOneStatus { get; set; } | public bool KitchenOneStatus { get; set; } | ||||
/// <summary> | |||||
/// 锅灶1状态 忙碌1 空闲0 | |||||
/// </summary> | |||||
public bool KitchenSecondStatus { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 注油完成状态 | /// 注油完成状态 | ||||
/// </summary> | /// </summary> | ||||
@@ -159,17 +175,68 @@ namespace BPASmartClient.MorkF | |||||
/// 转台互锁 | /// 转台互锁 | ||||
/// </summary> | /// </summary> | ||||
public bool TurnTableLock { get; set; } | public bool TurnTableLock { get; set; } | ||||
public bool ProcessExcuteLock { get; set; } | |||||
/// <summary> | |||||
/// 主流程自锁 | |||||
/// </summary> | |||||
public bool MainProcessExcuteLock { get; set; } | |||||
/// <summary> | |||||
/// 辅流程自锁 | |||||
/// </summary> | |||||
public bool MinorProcessExcuteLock { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 开始取料标志 | /// 开始取料标志 | ||||
/// </summary> | /// </summary> | ||||
public bool AllowTakeMaterial { get; set; } | public bool AllowTakeMaterial { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 当前订单完成标志 | |||||
/// 主流程订单完成标志 | |||||
/// </summary> | |||||
public bool MainOutMealComplete { get; set; } | |||||
/// <summary> | |||||
/// 辅流程订单完成标志 | |||||
/// </summary> | |||||
public bool MinorOutMealComplete { get; set; } | |||||
/// <summary> | |||||
/// 主流程订单取料结束 | |||||
/// </summary> | /// </summary> | ||||
public bool OutMealComplete { get; set; } | |||||
public bool MainOrderMaterialCom { get; set; } | |||||
/// <summary> | |||||
/// 主流程等待 | |||||
/// </summary> | |||||
public bool MainProcessWait { get; set; } | |||||
/// <summary> | |||||
/// 辅流程等待 | |||||
/// </summary> | |||||
public bool MinorProcessWait { get; set; } | |||||
/// <summary> | |||||
/// 辅流程订单取料结束 | |||||
/// </summary> | |||||
public bool MinorOrderMaterialCom { get; set; } | |||||
/// <summary> | |||||
/// 存储订单对应流程对象 | |||||
/// </summary> | |||||
public List<StirFryBom> listStirBom=new List<StirFryBom>(); | |||||
/// <summary> | |||||
/// 下配料次数 | |||||
/// </summary> | |||||
public int MaterialCount { get; set; } | |||||
/// <summary> | |||||
/// 允许执行辅流程标识 | |||||
/// </summary> | |||||
public bool MinorProcessFlag { get; set; } | |||||
/// <summary> | |||||
/// 辅流程执行状态 | |||||
/// </summary> | |||||
public bool MinorProessStatus { get; set; } | |||||
/// <summary> | |||||
/// 允许执行主流程标识 | |||||
/// </summary> | |||||
public bool MainProcessFlag { get; set; } = true; | |||||
/// <summary> | |||||
/// 主流程执行状态 | |||||
/// </summary> | |||||
public bool MainProcessStatus { get; set; } | |||||
} | } | ||||
} | } | ||||
@@ -13,6 +13,8 @@ using BPASmartClient.EventBus; | |||||
using static BPASmartClient.EventBus.EventBus; | using static BPASmartClient.EventBus.EventBus; | ||||
using BPASmartClient.MorkS.ViewModel; | using BPASmartClient.MorkS.ViewModel; | ||||
using BPASmartClient.MorkM.Model; | using BPASmartClient.MorkM.Model; | ||||
using System.Collections.ObjectModel; | |||||
using BPASmartClient.Model.PLC; | |||||
namespace BPASmartClient.MorkM | namespace BPASmartClient.MorkM | ||||
{ | { | ||||
@@ -44,10 +46,10 @@ namespace BPASmartClient.MorkM | |||||
// string guid = new Guid().ToString(); | // string guid = new Guid().ToString(); | ||||
// mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid }); | // 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 }); | // mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid }); | ||||
// MessageLog.GetInstance.Show($"添加订单:碗位置【{BowlLoc}】"); | |||||
// DeviceProcessLogShow($"添加订单:碗位置【{BowlLoc}】"); | |||||
// Thread.Sleep(60000); | // Thread.Sleep(60000); | ||||
// }), "ForOrder"); | // }), "ForOrder"); | ||||
// }), "EnableForOrder"); | // }), "EnableForOrder"); | ||||
@@ -61,7 +63,7 @@ namespace BPASmartClient.MorkM | |||||
// })); | // })); | ||||
// }), "StopForOrder"); | // }), "StopForOrder"); | ||||
// MessageLog.GetInstance.Show("MORKM 设备初始化完成"); | |||||
// DeviceProcessLogShow("MORKM 设备初始化完成"); | |||||
//} | //} | ||||
//private void ResetProgram() | //private void ResetProgram() | ||||
@@ -192,12 +194,12 @@ namespace BPASmartClient.MorkM | |||||
// { | // { | ||||
// orders.Add(new OrderLocInfo() { Loc = item, SuborderId = subId, MakeType = false }); | // orders.Add(new OrderLocInfo() { Loc = item, SuborderId = subId, MakeType = false }); | ||||
// //mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = item, SuborderId = subId }); | // //mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = item, SuborderId = subId }); | ||||
// //MessageLog.GetInstance.Show($"添加订单:面条位置【{item}】"); | |||||
// //DeviceProcessLogShow($"添加订单:面条位置【{item}】"); | |||||
// } | // } | ||||
// if (item >= 10 && item <= 11) | // if (item >= 10 && item <= 11) | ||||
// { | // { | ||||
// mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = item, SuborderId = subId, MakeType = false }); | // mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = item, SuborderId = subId, MakeType = false }); | ||||
// MessageLog.GetInstance.Show($"添加订单:碗位置【{item}】"); | |||||
// DeviceProcessLogShow($"添加订单:碗位置【{item}】"); | |||||
// } | // } | ||||
// } | // } | ||||
// mORKS.DishNumber = orders.Count;//订单中配菜的数量 | // mORKS.DishNumber = orders.Count;//订单中配菜的数量 | ||||
@@ -242,7 +244,7 @@ namespace BPASmartClient.MorkM | |||||
//{ | //{ | ||||
// if (broadcast != null && broadcast is IOTCommandModel iOTCommand) | // 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) | // switch (iOTCommand.CommandName) | ||||
// { | // { | ||||
// case 0://控制类 | // case 0://控制类 | ||||
@@ -286,85 +288,95 @@ namespace BPASmartClient.MorkM | |||||
///// <summary> | ///// <summary> | ||||
///// 数据解析 | ///// 数据解析 | ||||
///// </summary> | ///// </summary> | ||||
//public void DataParse<T>(T order) | |||||
//{ | |||||
// OrderCount++; | |||||
// MessageLog.GetInstance.Show($"接收到{OrderCount}次订单"); | |||||
// if (order is MorkOrderPush morkOrderPush) | |||||
// { | |||||
// OrderInformation newOrder = new OrderInformation();//2022.4.30 修改 | |||||
// List<OrderLocInfo> locs = new List<OrderLocInfo>(); | |||||
// foreach (var item in morkOrderPush.GoodBatchings) | |||||
// { | |||||
// var res = Json<BatchingInfoPar>.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<BatchingInfoPar>.Data.recipeBoms != null) | |||||
// { | |||||
// index = Array.FindIndex(Json<BatchingInfoPar>.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<DoOrderEvent>(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<OrderLocInfo> locs = new List<OrderLocInfo>(); | |||||
foreach (var item in order.MorkOrder.GoodBatchings) | |||||
{ | |||||
var res = Json<BatchingInfoPar>.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<BatchingInfoPar>.Data.recipeBoms != null) | |||||
{ | |||||
index = Array.FindIndex(Json<BatchingInfoPar>.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<string, OrderInformation> dic = new Dictionary<string, OrderInformation>(); | |||||
// 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<string, OrderInformation> dic = new Dictionary<string, OrderInformation>(); | |||||
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() | public void Main() | ||||
{ | { | ||||
@@ -401,8 +413,8 @@ namespace BPASmartClient.MorkM | |||||
mORKS.OutMealType = orderLocInfo.MakeType;//新增冒菜干拌or加汤 | mORKS.OutMealType = orderLocInfo.MakeType;//新增冒菜干拌or加汤 | ||||
TakeBowlControl(orderLocInfo.Loc); | TakeBowlControl(orderLocInfo.Loc); | ||||
SetRecipeNumber(orderLocInfo.RecipeNumber); | 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; | mORKS.TakeBowlInterlock = true; | ||||
} | } | ||||
@@ -413,24 +425,24 @@ namespace BPASmartClient.MorkM | |||||
/// </summary> | /// </summary> | ||||
private void TurntableControl() | 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) | if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) | ||||
@@ -445,7 +457,7 @@ namespace BPASmartClient.MorkM | |||||
TurntableStart(mORKS.TurntableFeedbackloc); | TurntableStart(mORKS.TurntableFeedbackloc); | ||||
mORKS.TurntableLocLists.Clear(); | mORKS.TurntableLocLists.Clear(); | ||||
mORKS.AllowTakeNoodle = true; | mORKS.AllowTakeNoodle = true; | ||||
MessageLog.GetInstance.Show($"控制机器人去转台【{mORKS.TurntableFeedbackloc}】号位置取面"); | |||||
DeviceProcessLogShow($"控制机器人去转台【{mORKS.TurntableFeedbackloc}】号位置取面"); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -458,7 +470,7 @@ namespace BPASmartClient.MorkM | |||||
if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) | if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) | ||||
{ | { | ||||
TurntableStart(loc); | TurntableStart(loc); | ||||
MessageLog.GetInstance.Show($"没有物料检测的启动转台控制,转台位置:[{loc}]"); | |||||
DeviceProcessLogShow($"没有物料检测的启动转台控制,转台位置:[{loc}]"); | |||||
break; | break; | ||||
} | } | ||||
else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc); | 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.CurrentLoc = 0; | ||||
mORKS.TurntableInterlock = false; | mORKS.TurntableInterlock = false; | ||||
MessageLog.GetInstance.Show("转台到位检测"); | |||||
DeviceProcessLogShow("转台到位检测"); | |||||
} | } | ||||
//补料完成检测 | //补料完成检测 | ||||
@@ -486,7 +498,7 @@ namespace BPASmartClient.MorkM | |||||
{ | { | ||||
mORKS.TurntableLocLists.Clear(); | mORKS.TurntableLocLists.Clear(); | ||||
mORKS.TurntableInterlock = false; | mORKS.TurntableInterlock = false; | ||||
MessageLog.GetInstance.Show("补料完成检测"); | |||||
DeviceProcessLogShow("补料完成检测"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -512,7 +524,7 @@ namespace BPASmartClient.MorkM | |||||
//机器人开始取面 | //机器人开始取面 | ||||
RobotTakeNoodle(); | RobotTakeNoodle(); | ||||
// SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); | // SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); | ||||
MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); | |||||
DeviceProcessLogShow($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); | |||||
//写入煮菜时间 | //写入煮菜时间 | ||||
List<ushort> values = new List<ushort>(); | List<ushort> values = new List<ushort>(); | ||||
@@ -520,13 +532,14 @@ namespace BPASmartClient.MorkM | |||||
{ | { | ||||
values.Add(2);//分 | values.Add(2);//分 | ||||
values.Add(0);//秒 | 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 //荤菜 | else //荤菜 | ||||
{ | { | ||||
values.Add(4);//分 | values.Add(4);//分 | ||||
values.Add(0);//秒 | 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.CookNodelId[loc] = string.Empty; | ||||
mORKS.orderLocInfos[location] = null; | mORKS.orderLocInfos[location] = null; | ||||
MessageLog.GetInstance.Show($"{location + 1}号位置出餐控制"); | |||||
DeviceProcessLogShow($"{location + 1}号位置出餐控制"); | |||||
mORKS.OutNoodleing = true; | mORKS.OutNoodleing = true; | ||||
mORKS.Count++; | mORKS.Count++; | ||||
CheckLastDish(); | CheckLastDish(); | ||||
@@ -613,7 +626,7 @@ namespace BPASmartClient.MorkM | |||||
// mORKS.CookNodelId[loc] = string.Empty; | // mORKS.CookNodelId[loc] = string.Empty; | ||||
mORKS.orderLocInfos[location] = null; | mORKS.orderLocInfos[location] = null; | ||||
// mORKS.Count++; | // mORKS.Count++; | ||||
MessageLog.GetInstance.Show($"{location + 1}号位置出餐控制"); | |||||
DeviceProcessLogShow($"{location + 1}号位置出餐控制"); | |||||
mORKS.OutNoodleing = true; | mORKS.OutNoodleing = true; | ||||
mORKS.CountMeat++; | mORKS.CountMeat++; | ||||
CheckLastDish(); | CheckLastDish(); | ||||
@@ -649,7 +662,7 @@ namespace BPASmartClient.MorkM | |||||
if (mORKS.OutMealType) | if (mORKS.OutMealType) | ||||
{ | { | ||||
AddSoup();//加汤 | AddSoup();//加汤 | ||||
MessageLog.GetInstance.Show("正在加汤"); | |||||
DeviceProcessLogShow("正在加汤"); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -690,8 +703,8 @@ namespace BPASmartClient.MorkM | |||||
mORKS.IngredientsCompleteId = mORKS.TakeBowlId; | mORKS.IngredientsCompleteId = mORKS.TakeBowlId; | ||||
// mORKS.TakeBowlId = string.Empty; | // mORKS.TakeBowlId = string.Empty; | ||||
// MessageLog.GetInstance.Show("碗到位,允许到面"); | |||||
MessageLog.GetInstance.Show($"碗到位,允许到面,{mORKS.IngredientsCompleteId}"); | |||||
// DeviceProcessLogShow("碗到位,允许到面"); | |||||
DeviceProcessLogShow($"碗到位,允许到面,{mORKS.IngredientsCompleteId}"); | |||||
// mORKS.TakeBowlInterlock = false; | // mORKS.TakeBowlInterlock = false; | ||||
} | } | ||||
@@ -699,16 +712,16 @@ namespace BPASmartClient.MorkM | |||||
if (RTrig.GetInstance("CompleteChange").Start(mORKS.RbOutMealComplete)) | 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; | mORKS.OutNoodleing = false; | ||||
} | } | ||||
//取餐完成逻辑处理 | //取餐完成逻辑处理 | ||||
if (DelayRTrig.GetInstance("CompleteChange1").Start(mORKS.RbOutMealComplete && !mORKS.TakeMealDetect, 2)) | 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(); | ResetCookComplete(); | ||||
mORKS.OutMealId = string.Empty; | mORKS.OutMealId = string.Empty; | ||||
} | } | ||||
@@ -719,7 +732,7 @@ namespace BPASmartClient.MorkM | |||||
mORKS.TakeNoodleInterlock = false; | mORKS.TakeNoodleInterlock = false; | ||||
mORKS.AllowTakeNoodle = false; | mORKS.AllowTakeNoodle = false; | ||||
mORKS.TurntableInterlock = false; | mORKS.TurntableInterlock = false; | ||||
MessageLog.GetInstance.Show("机器人取面完成信号检测"); | |||||
DeviceProcessLogShow("机器人取面完成信号检测"); | |||||
TakeNoodleCompleteReset(); | TakeNoodleCompleteReset(); | ||||
} | } | ||||
@@ -777,12 +790,12 @@ namespace BPASmartClient.MorkM | |||||
} | } | ||||
if (recipeBoms.Count > 0) | 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("配方数据为空"); } | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -790,7 +803,7 @@ namespace BPASmartClient.MorkM | |||||
/// </summary> | /// </summary> | ||||
private void TakeNoodleCompleteReset() | private void TakeNoodleCompleteReset() | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(1124, WriteType.Coils, false); | |||||
////ModbusTcpHelper.GetInstance.Write(1124, WriteType.Coils, false); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -802,8 +815,8 @@ namespace BPASmartClient.MorkM | |||||
if (num >= 1 && num <= 6) | if (num >= 1 && num <= 6) | ||||
{ | { | ||||
ushort addRess = (ushort)(1136 + num - 1); | 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 | |||||
/// <param name="num"></param> | /// <param name="num"></param> | ||||
private void SetRecipeNumber(ushort num) | private void SetRecipeNumber(ushort num) | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, num); | |||||
//ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, num); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -826,8 +839,8 @@ namespace BPASmartClient.MorkM | |||||
mORKS.CurrentLoc = loc; | mORKS.CurrentLoc = loc; | ||||
mORKS.TurntableInterlock = true; | mORKS.TurntableInterlock = true; | ||||
mORKS.TurntableLocLists.Add(loc); | 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); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -836,7 +849,7 @@ namespace BPASmartClient.MorkM | |||||
/// <param name="loc"></param> | /// <param name="loc"></param> | ||||
private void SetFallNoodleLoc(ushort loc) | private void SetFallNoodleLoc(ushort loc) | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, loc); | |||||
//ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, loc); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -845,7 +858,7 @@ namespace BPASmartClient.MorkM | |||||
/// <param name="loc"></param> | /// <param name="loc"></param> | ||||
private void SetTakeNoodleLoc(ushort loc) | private void SetTakeNoodleLoc(ushort loc) | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, loc); | |||||
//ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, loc); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -856,11 +869,11 @@ namespace BPASmartClient.MorkM | |||||
{ | { | ||||
if (loc == 10)//小碗 | if (loc == 10)//小碗 | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); | |||||
//ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); | |||||
} | } | ||||
else if (loc == 11)//大碗 | 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 | |||||
/// </summary> | /// </summary> | ||||
private void RobotTakeNoodle() | private void RobotTakeNoodle() | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true); | |||||
//ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -877,13 +890,13 @@ namespace BPASmartClient.MorkM | |||||
/// </summary> | /// </summary> | ||||
private void RobotOutMeal() | 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); | |||||
// } | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -891,7 +904,7 @@ namespace BPASmartClient.MorkM | |||||
/// </summary> | /// </summary> | ||||
private void ResetCookComplete() | private void ResetCookComplete() | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(1126, WriteType.Coils, false); | |||||
//ModbusTcpHelper.GetInstance.Write(1126, WriteType.Coils, false); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -899,7 +912,7 @@ namespace BPASmartClient.MorkM | |||||
/// </summary> | /// </summary> | ||||
private void ResetAllowFallNoodle() | private void ResetAllowFallNoodle() | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(1123, WriteType.Coils, false); | |||||
//ModbusTcpHelper.GetInstance.Write(1123, WriteType.Coils, false); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -907,9 +920,9 @@ namespace BPASmartClient.MorkM | |||||
/// </summary> | /// </summary> | ||||
public async void DeviceInit() | public async void DeviceInit() | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true); | |||||
//ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true); | |||||
await Task.Delay(1000); | 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 | |||||
/// </summary> | /// </summary> | ||||
public void CookComplete() | 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 }); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -926,7 +940,8 @@ namespace BPASmartClient.MorkM | |||||
/// </summary> | /// </summary> | ||||
public void AddSoup() | 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() | private void ServerInit() | ||||
@@ -987,7 +1002,10 @@ namespace BPASmartClient.MorkM | |||||
}), "WriteBools"); | }), "WriteBools"); | ||||
ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice"); | 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() | public override void ResetProgram() | ||||
{ | { | ||||
mORKS = null; | mORKS = null; | ||||
@@ -1,4 +1,5 @@ | |||||
using System; | |||||
using BPA.Message; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -13,6 +14,7 @@ namespace BPASmartClient.MorkM | |||||
public ushort RecipeNumber { get; set; } | public ushort RecipeNumber { get; set; } | ||||
public int BatchingId { get; set; } | public int BatchingId { get; set; } | ||||
public string GoodName { get; set; } | public string GoodName { get; set; } | ||||
public bool MakeType { get; set; } | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -24,6 +26,7 @@ namespace BPASmartClient.MorkM | |||||
public int DishNum { get; set; } | public int DishNum { get; set; } | ||||
// public GoodsMakeType MakeType { get; set; } | |||||
// public GoodsMakeType MakeType { get; set; } | |||||
} | } | ||||
} | } |
@@ -61,7 +61,7 @@ | |||||
</Device>-->--> | </Device>-->--> | ||||
<!--<Device Name="MorkF" Module="BPASmartClient.MorkF.Control_MorkF" DeviceId="2"> | |||||
<Device Name="MorkF" Module="BPASmartClient.MorkF.Control_MorkF" DeviceId="2"> | |||||
<Peripherals> | <Peripherals> | ||||
<Peripheral Module="BPASmartClient.PLC.PLCMachine"> | <Peripheral Module="BPASmartClient.PLC.PLCMachine"> | ||||
<Parameters> | <Parameters> | ||||
@@ -71,7 +71,7 @@ | |||||
</Parameters> | </Parameters> | ||||
</Peripheral> | </Peripheral> | ||||
</Peripherals> | </Peripherals> | ||||
</Device>--> | |||||
</Device> | |||||
<Device Name="Morks" Module="BPASmartClient.MorkS.Control_Morks" DeviceId="100"> | <Device Name="Morks" Module="BPASmartClient.MorkS.Control_Morks" DeviceId="100"> | ||||
<Peripherals> | <Peripherals> | ||||
@@ -84,6 +84,6 @@ | |||||
</Parameters> | </Parameters> | ||||
</Peripheral> | </Peripheral> | ||||
</Peripherals> | </Peripherals> | ||||
</Device> | |||||
</Device>-->--> | |||||
</BPADevices> | </BPADevices> |