终端一体化运控平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

2353 行
107 KiB

  1. using BPA.Message;
  2. using BPA.Message.Enum;
  3. using BPASmartClient.Device;
  4. using BPASmartClient.EventBus;
  5. using BPASmartClient.Helper;
  6. using BPASmartClient.Message;
  7. using BPASmartClient.Model;
  8. using BPASmartClient.Model.PLC;
  9. using BPA.Models;
  10. using static BPASmartClient.EventBus.EventBus;
  11. using BPASmartClient.Model.小炒机;
  12. using BPASmartClient.MorkF.Model;
  13. namespace BPASmartClient.MorkF
  14. {
  15. public class Control_MorkF : BaseDevice
  16. {
  17. public override DeviceClientType DeviceType => DeviceClientType.MORKCS;
  18. public AutoResetEvent minorReset = new AutoResetEvent(false);
  19. public AutoResetEvent mainReset = new AutoResetEvent(false);
  20. GVL_MorkF morkF = new GVL_MorkF();//全局对象声明
  21. public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象
  22. List<StirFryGoods> stirFryGoods = new List<StirFryGoods>();//创建商品对象
  23. List<int> resultorder = new List<int>();//调试变量
  24. /// <summary>
  25. /// 入口
  26. /// </summary>
  27. public override void DoMain()
  28. {
  29. CommandRegist();//调试
  30. ServerInit();
  31. DataParse();//数据解析
  32. DeviceProcessLogShow("MORKF 设备初始化完成");
  33. }
  34. #region 调试代码
  35. public void CommandRegist()
  36. {
  37. ActionManage.GetInstance.Register(PLCInite, "InitCommand");
  38. ActionManage.GetInstance.Register(InitialData, "SimultaorOrder");
  39. ActionManage.GetInstance.Register(MaterialOne, "MaterialOne");
  40. ActionManage.GetInstance.Register(MaterialTwo, "MaterialTwo");
  41. ActionManage.GetInstance.Register(MaterialThree, "MaterialThree");
  42. ActionManage.GetInstance.Register(MaterialFour, "MaterialFour");
  43. ActionManage.GetInstance.Register(MaterialFive, "MaterialFive");
  44. ActionManage.GetInstance.Register(ManualOpenExhaust, "OpenExhaust");
  45. ActionManage.GetInstance.Register(CloseExhaust, "CloaseExhaust");
  46. ActionManage.GetInstance.Register(StartQX, "StartQXOne");
  47. ActionManage.GetInstance.Register(StartQX, "StartQXTwo");
  48. ActionManage.GetInstance.Register(ShreddCabbage, "ShreddCabbage");
  49. ActionManage.GetInstance.Register(FryPork, "FryPork");
  50. ActionManage.GetInstance.Register(XingBaoGu, "XingBaoGu");
  51. ActionManage.GetInstance.Register(TakePot, "TakePot");
  52. ActionManage.GetInstance.Register(TakePotReset, "TakePotReset");
  53. ActionManage.GetInstance.Register(TakeMaterial, "TakeMaterial");
  54. ActionManage.GetInstance.Register(ManualOutMeal, "OutMeal");
  55. ActionManage.GetInstance.Register<Action>(AddOil, "AddOil");
  56. ActionManage.GetInstance.Register(TakeOff, "TakeOff");
  57. ActionManage.GetInstance.Register(OneBlock, "OneBlock");
  58. ActionManage.GetInstance.Register(TwoBlock, "TwoBlock");
  59. ActionManage.GetInstance.Register(ThreeBlock, "ThreeBlock");
  60. ActionManage.GetInstance.Register(OverTurnOff, "OverTurnOff");
  61. ActionManage.GetInstance.Register(OverOneBlock, "OverOneBlock");
  62. ActionManage.GetInstance.Register(OverTwoBlock, "OverTwoBlock");
  63. ActionManage.GetInstance.Register(OverThreeBlock, "OverThreeBlock");
  64. ActionManage.GetInstance.Register(OverGoOn, "OverGoOn");
  65. ActionManage.GetInstance.Register(OverGoDown, "OverGoDown");
  66. ActionManage.GetInstance.Register(AutoModel, "AutoModel");
  67. ActionManage.GetInstance.Register(ManualModel, "ManualModel");
  68. ActionManage.GetInstance.Register<Action>(AddOil, "SecAddOil");
  69. ActionManage.GetInstance.Register(TakeOff, "SecTakeOff");
  70. ActionManage.GetInstance.Register(OneBlock, "SecOneBlock");
  71. ActionManage.GetInstance.Register(TwoBlock, "SecTwoBlock");
  72. ActionManage.GetInstance.Register(ThreeBlock, "SecThreeBlock");
  73. ActionManage.GetInstance.Register(OverTurnOff, "SecOverTurnOff");
  74. ActionManage.GetInstance.Register(OverOneBlock, "SecOverOneBlock");
  75. ActionManage.GetInstance.Register(OverTwoBlock, "SecOverTwoBlock");
  76. ActionManage.GetInstance.Register(OverThreeBlock, "SecOverThreeBlock");
  77. ActionManage.GetInstance.Register(OverGoOn, "SecOverGoOn");
  78. ActionManage.GetInstance.Register(OverGoDown, "SecOverGoDown");
  79. ActionManage.GetInstance.Register(AutoModel, "SecAutoModel");
  80. ActionManage.GetInstance.Register(ManualModel, "SecManualModel");
  81. }
  82. /// <summary>
  83. /// 手撕包菜流程
  84. /// </summary>
  85. public void ShreddCabbage()
  86. {
  87. if (stirFryBom.StirFryActions.Count > 0)
  88. {
  89. stirFryBom.StirFryActions.Clear();
  90. }
  91. //流程
  92. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
  93. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.大火持续 }, During = 5 });
  94. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 6 });
  95. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.停止火力, StirFryPotAction.搅拌臂上位 } });//加A料
  96. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 6 });
  97. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料
  98. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 9 });
  99. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
  100. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
  101. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
  102. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
  103. }
  104. /// <summary>
  105. /// 盐煎肉流程
  106. /// </summary>
  107. public void FryPork()
  108. {
  109. if (stirFryBom.StirFryActions.Count > 0)
  110. {
  111. stirFryBom.StirFryActions.Clear();
  112. }
  113. //流程
  114. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
  115. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 15 });
  116. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.停止火力 }, During = 19 });
  117. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
  118. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 } });
  119. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 20 });
  120. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力 }, During = 35 });
  121. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位, } });
  122. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 } });
  123. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 22 });
  124. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
  125. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T12, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 } });
  126. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T13, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 70 });
  127. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T14, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
  128. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T15, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
  129. }
  130. /// <summary>
  131. /// 酱烧杏鲍菇流程
  132. /// </summary>
  133. public void XingBaoGu()
  134. {
  135. if (stirFryBom.StirFryActions.Count > 0)
  136. {
  137. stirFryBom.StirFryActions.Clear();
  138. }
  139. //流程
  140. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
  141. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 5 });
  142. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油 }, During = 12 });
  143. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加A料
  144. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 25 });
  145. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料
  146. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
  147. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
  148. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 });
  149. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
  150. }
  151. public void StartQX(object obj)
  152. {
  153. if ((int)obj == 1)
  154. WriteData("M1.4", true);
  155. if ((int)obj == 2)
  156. WriteData("M1.7", true);
  157. }
  158. public void ManualOpenExhaust()
  159. {
  160. WriteData("M0.7", true);
  161. }
  162. public void CloseExhaust()
  163. {
  164. WriteData("M0.7", false);
  165. }
  166. public void TakeMaterial()
  167. {
  168. WriteData("M14.1", true);
  169. }
  170. public void ManualOutMeal()
  171. {
  172. WriteData("M14.2", true);
  173. }
  174. public void MaterialOne()
  175. {
  176. WriteData("M13.0", true);
  177. }
  178. public void MaterialTwo()
  179. {
  180. WriteData("M13.1", true);
  181. }
  182. public void MaterialThree()
  183. {
  184. WriteData("M13.2", true);
  185. }
  186. public void MaterialFour()
  187. {
  188. WriteData("M13.3", true);
  189. }
  190. public void MaterialFive()
  191. {
  192. WriteData("M13.4", true);
  193. }
  194. public void AutoModel(object obj)
  195. {
  196. WriteData("0.3", true);
  197. }
  198. public void ManualModel()
  199. {
  200. WriteData("0.2", true);
  201. }
  202. public void AddOil(object obj)
  203. {
  204. if ((int)obj == 1)
  205. {
  206. Task.Run(() => { WriteData("M2.7", true); Task.Delay(4000).Wait(); WriteData("M2.7", false); });
  207. }
  208. if ((int)obj == 2)
  209. {
  210. Task.Run(() => { WriteData("M3.1", true); Task.Delay(4000).Wait(); WriteData("M3.1", false); });
  211. }
  212. }
  213. public void TakePot(object obj)
  214. {
  215. WriteData("M14.0", true);
  216. }
  217. public void TakePotReset(object obj)
  218. {
  219. WriteData("M14.0", false);
  220. }
  221. public void TakeOff(object obj)
  222. {
  223. if ((int)obj == 1)
  224. WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  225. if ((int)obj == 2)
  226. WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  227. }
  228. public void OneBlock(object obj)
  229. {
  230. if ((int)obj == 1)
  231. WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  232. if ((int)obj == 2)
  233. WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  234. }
  235. public void TwoBlock(object obj)
  236. {
  237. if ((int)obj == 1)
  238. WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  239. if ((int)obj == 2)
  240. WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  241. }
  242. public void ThreeBlock(object obj)
  243. {
  244. if ((int)obj == 1)
  245. WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  246. if ((int)obj == 2)
  247. WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  248. }
  249. public void OverTurnOff(object obj)
  250. {
  251. if ((int)obj == 1)
  252. WriteData("M7.0", true);
  253. if ((int)obj == 2)
  254. WriteData("M7.4", true);
  255. }
  256. public void OverOneBlock(object obj)
  257. {
  258. if ((int)obj == 1)
  259. WriteData("M7.1", true);
  260. if ((int)obj == 2)
  261. WriteData("M7.5", true);
  262. }
  263. public void OverTwoBlock(object obj)
  264. {
  265. if ((int)obj == 1)
  266. WriteData("M7.2", true);
  267. if ((int)obj == 2)
  268. WriteData("M7.6", true);
  269. }
  270. public void OverThreeBlock(object obj)
  271. {
  272. if ((int)obj == 1)
  273. WriteData("M7.3", true);
  274. if ((int)obj == 2)
  275. WriteData("M7.7", true);
  276. }
  277. public void OverGoOn(object obj)
  278. {
  279. if ((int)obj == 1)
  280. WriteData("M8.0", true);
  281. if ((int)obj == 2)
  282. WriteData("M8.4", true);
  283. }
  284. public void OverGoDown(object obj)
  285. {
  286. if ((int)obj == 1)
  287. WriteData("M8.2", true);
  288. if ((int)obj == 2)
  289. WriteData("M8.6", true);
  290. }
  291. public void FlowInite()
  292. {
  293. }
  294. /// <summary>
  295. /// 订单初始化
  296. /// </summary>
  297. private void InitialData()
  298. {
  299. //单个订单
  300. string subId = Guid.NewGuid().ToString();
  301. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 1 } });//A料
  302. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 2 } });//B料
  303. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 3 } });//C料
  304. morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
  305. resultorder.AddRange(new int[] { 1, 2, 3 });
  306. morkF.listStirBom.Add(stirFryBom);
  307. //多个订单
  308. //string subId = Guid.NewGuid().ToString();
  309. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 1 } });//A料
  310. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 2 } });//B料
  311. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 3 } });//C料
  312. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 1 } });//A料
  313. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 2 } });//B料
  314. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 3 } });//C料
  315. //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
  316. //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1 });
  317. //resultorder.AddRange(new int[] { 1, 2, 3 });
  318. //resultorder.AddRange(new int[] { 1, 2, 3 });
  319. //morkF.listStirBom.Add(stirFryBom);
  320. //morkF.listStirBom.Add(stirFryBom);
  321. }
  322. #endregion
  323. public override void ResetProgram()
  324. {
  325. morkF = null;
  326. morkF = new GVL_MorkF();
  327. }
  328. /// <summary>
  329. /// PLC数据读取
  330. /// </summary>
  331. public override void ReadData()
  332. {
  333. GetStatus("M0.1", new Action<bool[]>((bools) =>
  334. {
  335. Initing = bools[0];
  336. morkF.InitialComplete = Initing;
  337. }));
  338. GetStatus("M1.0", new Action<bool[]>((bools) =>
  339. {
  340. morkF.ProvidePlateModule = bools[0];
  341. morkF.ProvidePlateComplete = bools[2];
  342. morkF.CleanModule = bools[3];
  343. morkF.CleanComplete = bools[5];
  344. }));
  345. GetStatus("M2.0", new Action<bool[]>((bools) =>
  346. {
  347. morkF.KitchenOneStatus = bools[1];
  348. morkF.KitchenSecondStatus = bools[4];
  349. morkF.FallOilComplete = bools[8];
  350. }));
  351. GetStatus("M8.0", new Action<bool[]>((bools) =>
  352. {
  353. morkF.TurnMachineUpComplete = bools[1];
  354. morkF.TurnMachineDownComplete = bools[3];
  355. }));
  356. GetStatus("M13.5", new Action<bool[]>((bools) =>
  357. {
  358. morkF.MaterialArriveComplete = bools[0];
  359. }));
  360. GetStatus("M16.0", new Action<bool[]>((bools) =>
  361. {
  362. morkF.PutPotToKitchenComlete = bools[1];
  363. morkF.TakeMaterialComplete = bools[2];
  364. morkF.FallMaterialComplete = bools[3];
  365. morkF.PlaceRinseTableComplete = bools[5];
  366. morkF.RoobotIdle = bools[6];
  367. }));
  368. }
  369. private void ServerInit()
  370. {
  371. //物料信息
  372. EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  373. {
  374. if (@event == null) return;
  375. if (@event is MaterialDeliveryEvent material)
  376. {
  377. orderMaterialDelivery = material.orderMaterialDelivery;
  378. }
  379. });
  380. //配方数据信息
  381. EventBus.EventBus.GetInstance().Subscribe<RecipeBomEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  382. {
  383. if (@event == null) return;
  384. if (@event is RecipeBomEvent recipe)
  385. {
  386. recipeBoms = recipe.recipeBoms;
  387. WriteRecipeBoms();
  388. }
  389. });
  390. //小炒流程信息
  391. EventBus.EventBus.GetInstance().Subscribe<StirFryGoodsEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callback)
  392. {
  393. if (@event == null) return;
  394. if (@event is StirFryGoodsEvent stirFry)
  395. {
  396. stirFryGoods = stirFry.stirFrymessage.stirFryGoods;
  397. MessageLog.GetInstance.Show("接收到小炒流程信息");
  398. //流程解析
  399. foreach (var item in stirFryGoods)
  400. {
  401. MessageLog.GetInstance.ShowEx($"执行菜谱{item.GoodsKey}");
  402. // morkF.listStirBom.Add(item.StirFryBomInfo);//添加订单制作流程
  403. foreach (var items in item.StirFryBomInfo.StirFryActions)
  404. {
  405. MessageLog.GetInstance.Show($"执行流程{items.Time}");
  406. foreach (var pro in items.RobotActions)
  407. {
  408. switch (pro)
  409. {
  410. case StirFryRobotAction.等待:
  411. MessageLog.GetInstance.Show($"等待");
  412. break;
  413. case StirFryRobotAction.清洗槽取锅:
  414. MessageLog.GetInstance.Show($"清洗槽取锅");
  415. break;
  416. case StirFryRobotAction.灶放锅:
  417. MessageLog.GetInstance.Show($"灶放锅");
  418. break;
  419. case StirFryRobotAction.清洗槽放锅:
  420. MessageLog.GetInstance.Show($"清洗槽放锅");
  421. break;
  422. case StirFryRobotAction.取A料:
  423. MessageLog.GetInstance.Show($"取A料");
  424. break;
  425. case StirFryRobotAction.取B料:
  426. MessageLog.GetInstance.Show($"取B料");
  427. break;
  428. case StirFryRobotAction.取C料:
  429. MessageLog.GetInstance.Show($"取C料");
  430. break;
  431. case StirFryRobotAction.加入A料:
  432. MessageLog.GetInstance.Show($"加入A料");
  433. break;
  434. case StirFryRobotAction.加入B料:
  435. MessageLog.GetInstance.Show($"加入B料");
  436. break;
  437. case StirFryRobotAction.加入C料:
  438. MessageLog.GetInstance.Show($"加入C料");
  439. break;
  440. case StirFryRobotAction.切换快速:
  441. MessageLog.GetInstance.Show($"切换快速");
  442. break;
  443. case StirFryRobotAction.切换中速:
  444. MessageLog.GetInstance.Show($"切换中速");
  445. break;
  446. case StirFryRobotAction.丢料盒:
  447. MessageLog.GetInstance.Show($"丢料盒");
  448. break;
  449. case StirFryRobotAction.倒菜:
  450. MessageLog.GetInstance.Show($"倒菜");
  451. break;
  452. case StirFryRobotAction.灶取锅:
  453. MessageLog.GetInstance.Show($"灶取锅");
  454. break;
  455. }
  456. }
  457. foreach (var pro in items.PotActions)
  458. {
  459. switch (pro)
  460. {
  461. case StirFryPotAction.NONE:
  462. break;
  463. case StirFryPotAction.加热:
  464. MessageLog.GetInstance.Show($"加热");
  465. break;
  466. case StirFryPotAction.大火t1s:
  467. MessageLog.GetInstance.Show($"大火1s");
  468. break;
  469. case StirFryPotAction.加油:
  470. MessageLog.GetInstance.Show($"加油");
  471. break;
  472. case StirFryPotAction.中火t2s:
  473. MessageLog.GetInstance.Show($"中火2s");
  474. break;
  475. case StirFryPotAction.小火持续:
  476. MessageLog.GetInstance.Show($"小火持续");
  477. break;
  478. case StirFryPotAction.中火持续:
  479. MessageLog.GetInstance.Show($"中火持续");
  480. break;
  481. case StirFryPotAction.大火持续:
  482. MessageLog.GetInstance.Show($"大火持续");
  483. break;
  484. case StirFryPotAction.停止火力:
  485. MessageLog.GetInstance.Show($"停止火力");
  486. break;
  487. case StirFryPotAction.搅拌臂上位:
  488. MessageLog.GetInstance.Show($"搅拌臂上位");
  489. break;
  490. case StirFryPotAction.搅拌臂中位:
  491. MessageLog.GetInstance.Show($"搅拌臂中位");
  492. break;
  493. case StirFryPotAction.搅拌臂下位:
  494. MessageLog.GetInstance.Show($"搅拌臂下位");
  495. break;
  496. case StirFryPotAction.低速旋转:
  497. MessageLog.GetInstance.Show($"低速旋转");
  498. break;
  499. case StirFryPotAction.快速旋转:
  500. MessageLog.GetInstance.Show($"快速旋转");
  501. break;
  502. case StirFryPotAction.停止旋转:
  503. MessageLog.GetInstance.Show($"停止旋转");
  504. break;
  505. }
  506. }
  507. }
  508. }
  509. }
  510. });
  511. }
  512. /// <summary>
  513. /// 订单状态发布
  514. /// </summary>
  515. /// <param name="subid"></param>
  516. /// <param name="oRDER_STATUS"></param>
  517. private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
  518. {
  519. EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid });
  520. }
  521. /// <summary>
  522. /// 数据解析
  523. /// </summary>
  524. private void DataParse()
  525. {
  526. EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
  527. {
  528. if (@event == null) return;
  529. if (@event is DoOrderEvent order)
  530. {
  531. if (order.MorkOrder.GoodBatchings == null) return;
  532. OrderCount++;
  533. DeviceProcessLogShow($"接收到{OrderCount}次订单");
  534. var res = stirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.RecipeId);//匹配订单对应制作流程
  535. if (res != null)
  536. {
  537. morkF.listStirBom.Add(res.StirFryBomInfo);//添加订单制作流程
  538. if (morkF.TakeMaterialQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  539. {
  540. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.ALoc });
  541. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.BLoc });
  542. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.CLoc });
  543. }
  544. //foreach (var item in order.MorkOrder.GoodBatchings)
  545. //{
  546. if (morkF.TakePlateQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  547. {
  548. morkF.TakePlateQueue.Enqueue(new OrderLocInfo()
  549. {
  550. SuborderId = order.MorkOrder.SuborderId,
  551. });
  552. }
  553. //}
  554. }
  555. }
  556. });
  557. }
  558. //}
  559. /// <summary>
  560. /// 主任务
  561. /// </summary>
  562. public override void MainTask()
  563. {
  564. TakePlatelTask();
  565. TurntableControl();
  566. MainProcessExecute();
  567. MinorProcessExcute();
  568. SingleProcess();
  569. }
  570. //辅流程执行
  571. private void MinorProcessExcute()
  572. {
  573. if (!morkF.MinorProcessExcuteLock)
  574. {
  575. morkF.MinorProcessExcuteLock = true;
  576. Task.Run(() =>
  577. {
  578. if (morkF.MinorProcessFlag && !morkF.RoobotIdle && morkF.TakeMaterialQueue.Count > 0 && morkF.listStirBom.Count > 0 )
  579. {
  580. morkF.MinorProessStatus = true;
  581. morkF.MainProcessStatus = false;
  582. StirFryBom bom = morkF.listStirBom.ElementAt(0);
  583. morkF.listStirBom.RemoveAt(0);
  584. foreach (var res in bom.StirFryActions)
  585. {
  586. DeviceProcessLogShow($"执行流程{res.Time}");
  587. //机器人线程
  588. Task taskRobot = Task.Run(new Action(() =>
  589. {
  590. foreach (var temp in res.RobotActions)
  591. {
  592. switch (temp)
  593. {
  594. case StirFryRobotAction.清洗槽取锅:
  595. TakePotTask();//执行取锅操作
  596. break;
  597. case StirFryRobotAction.取A料:
  598. TakeBurdenATask();//执行取A料操作
  599. break;
  600. case StirFryRobotAction.取B料:
  601. TakeBurdenATask();//执行取B料操作
  602. break;
  603. case StirFryRobotAction.取C料:
  604. TakeBurdenCTask();//执行取C料操作
  605. break;
  606. case StirFryRobotAction.灶取锅:
  607. MinorProcessOutDishTask();//执行出餐操作
  608. MinorProcessCleanPotTask();//洗锅操作
  609. break;
  610. }
  611. }
  612. }));
  613. //炒锅线程操作
  614. Task taskPot = Task.Run(new Action(() =>
  615. {
  616. foreach (var temp in res.PotActions)
  617. {
  618. switch (temp)
  619. {
  620. case StirFryPotAction.NONE:
  621. break;
  622. case StirFryPotAction.大火t1s:
  623. MinorProcessKitchenAdjustGears(3);
  624. // Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
  625. break;
  626. case StirFryPotAction.加油:
  627. AddOil();//注油//执行加油操作
  628. break;
  629. case StirFryPotAction.中火t2s:
  630. MinorProcessKitchenAdjustGears(2);
  631. Task.Delay(2000).Wait();//执行操作
  632. break;
  633. case StirFryPotAction.小火持续:
  634. MinorProcessKitchenAdjustGears(1);
  635. break;
  636. case StirFryPotAction.中火持续:
  637. MinorProcessKitchenAdjustGears(5);
  638. break;
  639. case StirFryPotAction.大火持续:
  640. MinorProcessKitchenAdjustGears(7);
  641. break;
  642. case StirFryPotAction.停止火力:
  643. MinorProcessKitchenAdjustGears(0);//关闭灶加热
  644. break;
  645. case StirFryPotAction.搅拌臂上位:
  646. MinorProcessTurnUpStatusDetect();//执行搅拌臂上位操作
  647. break;
  648. case StirFryPotAction.搅拌臂下位:
  649. MinorProcessTurnDownStatusDetect();//执行搅拌臂下位操作
  650. break;
  651. case StirFryPotAction.低速旋转:
  652. MinorProcessTurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
  653. break;
  654. case StirFryPotAction.快速旋转:
  655. MinorProcessTurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
  656. break;
  657. case StirFryPotAction.停止旋转:
  658. MinorProcessTurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
  659. break;
  660. }
  661. }
  662. }));
  663. Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
  664. Task.Delay(res.During * 1000).Wait();//当前流程延迟
  665. if (morkF.MainProcessWait)
  666. {
  667. if (morkF.MainHasTakeMaterial)
  668. {
  669. }
  670. else
  671. {
  672. MinorProcessKitchenAdjustGears(0);//关闭灶加热
  673. //阻塞辅流程
  674. minorReset.WaitOne();
  675. //morkF.MinorProessStatus = true;
  676. //morkF.MainProcessStatus = false;
  677. }
  678. }
  679. }
  680. morkF.MinorOutMealComplete = true;
  681. }
  682. else
  683. {
  684. morkF.MinorProcessExcuteLock = false;//解除辅流程自锁
  685. }
  686. });
  687. }
  688. }
  689. //机器人,锅灶主流程执行
  690. public void MainProcessExecute()
  691. {
  692. if (!morkF.MainProcessExcuteLock)
  693. {
  694. morkF.MainProcessExcuteLock = true;
  695. Task.Run(new Action(() =>
  696. {
  697. if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakeMaterialQueue.Count > 0 && morkF.MainProcessFlag&& morkF.listStirBom.Count > 0)
  698. {
  699. morkF.MainProcessStatus = true;
  700. morkF.MinorProessStatus = false;
  701. StirFryBom bom = morkF.listStirBom.ElementAt(0);
  702. morkF.listStirBom.RemoveAt(0);
  703. foreach (var res in bom.StirFryActions)//遍历所有流程
  704. {
  705. DeviceProcessLogShow($"执行流程{res.Time}");
  706. //机器人线程
  707. Task taskRobot = Task.Run(new Action(() =>
  708. {
  709. foreach (var temp in res.RobotActions)
  710. {
  711. switch (temp)
  712. {
  713. case StirFryRobotAction.清洗槽取锅:
  714. TakePotTask();//执行取锅操作
  715. break;
  716. case StirFryRobotAction.取A料:
  717. TakeBurdenATask();//执行取A料操作
  718. break;
  719. case StirFryRobotAction.取B料:
  720. TakeBurdenATask();//执行取B料操作
  721. break;
  722. case StirFryRobotAction.取C料:
  723. TakeBurdenCTask();//执行取C料操作
  724. break;
  725. case StirFryRobotAction.灶取锅:
  726. MainProcessOutDishTask();//执行出餐操作
  727. MainProcessCleanPotTask();//洗锅操作
  728. break;
  729. }
  730. }
  731. }));
  732. //炒锅线程操作
  733. Task taskPot = Task.Run(new Action(() =>
  734. {
  735. foreach (var temp in res.PotActions)
  736. {
  737. switch (temp)
  738. {
  739. case StirFryPotAction.NONE:
  740. break;
  741. case StirFryPotAction.大火t1s:
  742. MainProcessKitchenAdjustGears(3);
  743. // Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
  744. break;
  745. case StirFryPotAction.加油:
  746. AddOil();//注油//执行加油操作
  747. break;
  748. case StirFryPotAction.中火t2s:
  749. MainProcessKitchenAdjustGears(2);
  750. Task.Delay(2000).Wait();//执行操作
  751. break;
  752. case StirFryPotAction.小火持续:
  753. MainProcessKitchenAdjustGears(1);
  754. break;
  755. case StirFryPotAction.中火持续:
  756. MainProcessKitchenAdjustGears(5);
  757. break;
  758. case StirFryPotAction.大火持续:
  759. MainProcessKitchenAdjustGears(7);
  760. break;
  761. case StirFryPotAction.停止火力:
  762. MainProcessKitchenAdjustGears(0);//关闭灶加热
  763. break;
  764. case StirFryPotAction.搅拌臂上位:
  765. MainProcessTurnUpStatusDetect();//执行搅拌臂上位操作
  766. break;
  767. case StirFryPotAction.搅拌臂下位:
  768. MainProcessTurnDownStatusDetect();//执行搅拌臂下位操作
  769. break;
  770. case StirFryPotAction.低速旋转:
  771. MainProcessTurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
  772. break;
  773. case StirFryPotAction.快速旋转:
  774. MainProcessTurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
  775. break;
  776. case StirFryPotAction.停止旋转:
  777. MainProcessTurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
  778. break;
  779. }
  780. }
  781. }));
  782. Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
  783. Task.Delay(res.During * 1000).Wait();//当前流程延迟
  784. #region 两口锅逻辑
  785. //if (morkF.MinorProcessWait)
  786. //{
  787. // if (morkF.MinorHasTakeMaterial)//针对主流程准备出餐但辅流程机器人忙碌情况下,辅流程不阻塞
  788. // {
  789. // }
  790. // else
  791. // {
  792. // MainProcessKitchenAdjustGears(0);//关闭灶加热
  793. // //阻塞主流程
  794. // mainReset.WaitOne();
  795. // //morkF.MinorProessStatus = false;
  796. // //morkF.MainProcessStatus = true;
  797. // }
  798. //}
  799. #endregion
  800. }
  801. morkF.MainOutMealComplete = true;
  802. }
  803. else
  804. {
  805. morkF.MainProcessExcuteLock = false;//解除流程自锁
  806. }
  807. }));
  808. }
  809. }
  810. /// <summary>
  811. /// 信号处理
  812. /// </summary>
  813. private void SingleProcess()
  814. {
  815. //主流程出餐完成,相应变量复位
  816. if (morkF.MainOutMealComplete)
  817. {
  818. morkF.MainOutMealComplete = false;
  819. morkF.TakePlateLock = false;
  820. morkF.MainProcessExcuteLock = false;
  821. morkF.MainOrderMaterialCom = false;
  822. morkF.MainProcessWait = false;//主流程出餐完成取消辅流程线程阻塞
  823. #region 单口锅逻辑
  824. morkF.PotInPlace = false;
  825. #endregion
  826. #region 两口锅逻辑
  827. //if (morkF.MainProcessPotLoc == 1)
  828. //{
  829. // morkF.PotInPlace = false;
  830. //}
  831. //else if (morkF.MainProcessPotLoc == 2)
  832. //{
  833. // morkF.SecondPotInPlace = false;
  834. //}
  835. #endregion
  836. }
  837. //辅流程出餐完成,相应变量复位
  838. if (morkF.MinorOutMealComplete)
  839. {
  840. morkF.MinorOutMealComplete = false;
  841. morkF.TakePlateLock = false;
  842. morkF.MinorProcessExcuteLock = false;
  843. morkF.MinorOrderMaterialCom = false;
  844. morkF.MinorProcessWait = false;//辅流程出餐完成取消主流程线程阻塞
  845. if (morkF.MinorProcessPotLoc == 1)
  846. {
  847. morkF.PotInPlace = false;
  848. }
  849. else if (morkF.MinorProcessPotLoc == 2)
  850. {
  851. morkF.SecondPotInPlace = false;
  852. }
  853. }
  854. }
  855. /// <summary>
  856. /// 转台控制
  857. /// </summary>
  858. private void TurntableControl()
  859. {
  860. //模拟订单
  861. if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock && General_Config.SimOrderAllow)
  862. {
  863. if (resultorder != null)
  864. {
  865. TurnMaterialStore(resultorder[0]);
  866. DeviceProcessLogShow($"转台转到【{resultorder[0]}】位置");
  867. resultorder.RemoveAt(0);
  868. morkF.TurnTableLock = true; //取料完成后置false
  869. }
  870. else
  871. {
  872. DeviceProcessLogShow("当前订单未找到可用的物料信息");
  873. }
  874. }
  875. //正式订单
  876. if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock)
  877. {
  878. //var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == morkF.TakeMaterialQueue.ElementAt(0).BatchingId).ToList();
  879. var materialLoc = morkF.TakeMaterialQueue.ElementAt(0).MaterialLoc;
  880. if (materialLoc.Count != 0)
  881. {
  882. TurnMaterialStore(materialLoc[0]);
  883. DeviceProcessLogShow($"转台转到【{materialLoc[0]}】位置");
  884. morkF.TurnTableLock = true; //取料完成后置false
  885. }
  886. else
  887. {
  888. DeviceProcessLogShow("当前订单未找到可用的物料信息");
  889. }
  890. }
  891. }
  892. /// <summary>
  893. /// 供盘
  894. /// </summary>
  895. /// <exception cref="NotImplementedException"></exception>
  896. private void TakePlatelTask()
  897. {
  898. if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakePlateQueue.Count > 0 && !morkF.ProvidePlateModule && !morkF.TakePlateLock)
  899. {
  900. if (morkF.TakePlateQueue.TryDequeue(out OrderLocInfo order))
  901. {
  902. StartTakePlate();
  903. #region 两口锅逻辑
  904. //if (morkF.MainProcessStatus)
  905. // morkF.MainCurrentOrderId = order.SuborderId;
  906. //if (morkF.MinorProessStatus)
  907. // morkF.MinorCurrentOrderId = order.SuborderId;
  908. #endregion
  909. #region 单口锅逻辑
  910. morkF.CurrentOrderId = order.SuborderId;
  911. #endregion
  912. morkF.TakePlateLock = true; //订单完成后置false
  913. DeviceProcessLogShow($"订单【{order.SuborderId}】执行取碗控制");
  914. }
  915. }
  916. }
  917. /// <summary>
  918. /// 取锅到灶台
  919. /// </summary>
  920. /// <exception cref="NotImplementedException"></exception>
  921. private void TakePotTask()
  922. {
  923. while (morkF.CleanModule || morkF.KitchenOneStatus || !morkF.CleanComplete || morkF.RoobotIdle)//等待取锅条件满足
  924. {
  925. Task.Delay(5).Wait();
  926. }
  927. #region 单口锅逻辑
  928. //if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete)
  929. //{
  930. //取1号锅到1号灶台
  931. TakePotToKitchen(1);
  932. WriteData("M1.5", false);//清洗模组1完成复位
  933. DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到灶台控制");
  934. while (!morkF.PutPotToKitchenComlete)
  935. {
  936. Task.Delay(5).Wait();
  937. }
  938. morkF.PotInPlace = true;//锅到位
  939. WriteData("M14.0", false);//机器人取锅完成复位
  940. //}
  941. #endregion
  942. #region 两口锅逻辑
  943. //while (!((!morkF.CleanModule || !morkF.SecondCleanModule) && (!morkF.KitchenOneStatus || !morkF.KitchenSecondStatus) && (morkF.CleanComplete || morkF.SecondCleanComplete)))//等待取锅条件满足
  944. //{
  945. // Task.Delay(5).Wait();
  946. //}
  947. //while (morkF.RoobotIdle)//等待机器人空闲
  948. //{
  949. // Task.Delay(5).Wait();
  950. //}
  951. //if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete)
  952. //{
  953. // //取1号锅到1号灶台
  954. // TakePotToKitchen(1);
  955. // morkF.CurrentPutPotLoc = 1;
  956. // WriteData("M1.5", false);//清洗模组1完成复位
  957. // DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到灶台控制");
  958. //}
  959. //else if (!morkF.SecondCleanModule && !morkF.KitchenOneStatus && morkF.SecondCleanComplete)
  960. //{
  961. // //取2号锅到1号灶台
  962. // TakePotToKitchen(1);
  963. // morkF.CurrentPutPotLoc = 1;
  964. // WriteData("M2.0", false);//清洗模组2完成复位
  965. //}
  966. //if (!morkF.SecondCleanModule && !morkF.KitchenSecondStatus && morkF.SecondCleanComplete)
  967. //{
  968. // //取2号锅到2号灶台
  969. // TakePotToKitchen(2);
  970. // morkF.CurrentPutPotLoc = 2;
  971. // WriteData("M2.0", false);//清洗模组2完成复位
  972. //}
  973. //else if (!morkF.CleanModule && !morkF.KitchenSecondStatus && morkF.CleanComplete)
  974. //{
  975. // //取1号锅到2号灶台
  976. // TakePotToKitchen(2);
  977. // morkF.CurrentPutPotLoc = 2;
  978. // WriteData("M2.0", false);//清洗模组1完成复位
  979. //}
  980. //if (morkF.MainProcessStatus)
  981. //{
  982. // morkF.MainProcessPotLoc = morkF.CurrentPutPotLoc;
  983. // DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行取锅到灶台控制");
  984. //}
  985. //if (morkF.MinorProessStatus)
  986. //{
  987. // morkF.MinorProcessPotLoc = morkF.CurrentPutPotLoc;
  988. // DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行取锅到灶台控制");
  989. //}
  990. //if (morkF.CurrentPutPotLoc == 1)
  991. //{
  992. // while (!morkF.PutPotToKitchenComlete)
  993. // {
  994. // Task.Delay(5).Wait();
  995. // }
  996. // morkF.PotInPlace = true;//锅到位
  997. // WriteData("M14.0", false);//机器人取锅完成复位
  998. //}
  999. //if (morkF.CurrentPutPotLoc == 2)
  1000. //{
  1001. // while (!morkF.PutPotToSecondKitchenComlete)
  1002. // {
  1003. // Task.Delay(5).Wait();
  1004. // }
  1005. // morkF.SecondPotInPlace = true;
  1006. // WriteData("M14.4", false);//机器人取锅完成复位
  1007. //}
  1008. #endregion
  1009. Thread.Sleep(2000);
  1010. }
  1011. /// <summary>
  1012. /// 写入配方数据到 PLC
  1013. /// </summary>
  1014. private void WriteRecipeBoms()
  1015. {
  1016. //List<ushort> recipeBoms = new List<ushort>();
  1017. //if (this.recipeBoms == null) return;
  1018. //foreach (var item in this.recipeBoms.RecipeIds)
  1019. //{
  1020. // foreach (var rec in item.Recipes)
  1021. // {
  1022. // recipeBoms.Add((ushort)rec);
  1023. // }
  1024. //}
  1025. //if (recipeBoms.Count > 0)
  1026. //{
  1027. // //配方数据地址范围:VW2000 - VW2278
  1028. // WriteData("VW2000", recipeBoms.ToArray());
  1029. //}
  1030. //else {DeviceProcessLogShow("配方数据为空"); }
  1031. }
  1032. /// <summary>
  1033. /// 转台复位
  1034. /// </summary>
  1035. /// <param name="loc"></param>
  1036. public void TurnReset(int loc)
  1037. {
  1038. switch (loc)
  1039. {
  1040. case 1: WriteData("M13.0", false); break;
  1041. case 2: WriteData("M13.1", false); break;
  1042. case 3: WriteData("M13.2", false); break;
  1043. case 4: WriteData("M13.3", false); break;
  1044. case 5: WriteData("M13.4", false); break;
  1045. }
  1046. }
  1047. /// <summary>
  1048. /// 取素菜A料
  1049. /// </summary>
  1050. private void TakeBurdenATask()
  1051. {
  1052. int loc = 0;
  1053. #region 单口锅逻辑
  1054. while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1055. {
  1056. Task.Delay(5).Wait();
  1057. }
  1058. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1059. {
  1060. loc = order.MaterialLoc[0];
  1061. TakeBurden();
  1062. TurnReset(loc);//转台复位
  1063. DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1064. }
  1065. //等待取料完成
  1066. while (!morkF.TakeMaterialComplete)
  1067. {
  1068. Task.Delay(5).Wait();
  1069. }
  1070. WriteData("M14.1", false);//机器人取料完成复位
  1071. #endregion
  1072. #region 两口锅逻辑
  1073. //if (morkF.MainProcessStatus)
  1074. //{
  1075. // if (morkF.MainProcessPotLoc == 1)
  1076. // {
  1077. // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1078. // {
  1079. // Task.Delay(5).Wait();
  1080. // }
  1081. // }
  1082. // else
  1083. // {
  1084. // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1085. // {
  1086. // Task.Delay(5).Wait();
  1087. // }
  1088. // }
  1089. // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1090. // {
  1091. // loc = order.MaterialLoc[0];
  1092. // TakeBurden();
  1093. // TurnReset(loc);//转台复位
  1094. // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1095. // }
  1096. // //等待取料完成
  1097. // while (!morkF.TakeMaterialComplete)
  1098. // {
  1099. // Task.Delay(5).Wait();
  1100. // }
  1101. // morkF.MainOrderMaterialCom = false;
  1102. // morkF.MainHasTakeMaterial = true;
  1103. // WriteData("M14.1", false);//机器人取料完成复位
  1104. //}
  1105. //if (morkF.MinorProessStatus)
  1106. //{
  1107. // if (morkF.MinorProcessPotLoc == 1)
  1108. // {
  1109. // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1110. // {
  1111. // Task.Delay(5).Wait();
  1112. // }
  1113. // }
  1114. // else
  1115. // {
  1116. // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1117. // {
  1118. // Task.Delay(5).Wait();
  1119. // }
  1120. // }
  1121. // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1122. // {
  1123. // loc = order.MaterialLoc[0];
  1124. // TakeBurden();
  1125. // TurnReset(loc);//转台复位
  1126. // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1127. // }
  1128. // //等待取料完成
  1129. // while (!morkF.TakeMaterialComplete)
  1130. // {
  1131. // Task.Delay(5).Wait();
  1132. // }
  1133. // morkF.MinorOrderMaterialCom = false;
  1134. // morkF.MinorHasTakeMaterial = true;
  1135. // WriteData("M14.5", false);//机器人取料完成复位
  1136. //}
  1137. #endregion
  1138. morkF.TurnTableLock = false;//转台互锁解除
  1139. }
  1140. /// <summary>
  1141. /// 取素菜B料
  1142. /// </summary>
  1143. private void TakeBurdenBTask()
  1144. {
  1145. int loc = 0;
  1146. //while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位
  1147. //{
  1148. // Task.Delay(5).Wait();
  1149. //}
  1150. if (morkF.MainProcessStatus)
  1151. {
  1152. if (morkF.MainProcessPotLoc == 1)
  1153. {
  1154. while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1155. {
  1156. Task.Delay(5).Wait();
  1157. }
  1158. }
  1159. else
  1160. {
  1161. while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1162. {
  1163. Task.Delay(5).Wait();
  1164. }
  1165. }
  1166. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1167. {
  1168. loc = order.MaterialLoc[0];
  1169. TakeBurden();
  1170. TurnReset(loc);//转台复位
  1171. DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1172. }
  1173. //等待取料完成
  1174. while (!morkF.TakeMaterialComplete)
  1175. {
  1176. Task.Delay(5).Wait();
  1177. }
  1178. morkF.MainOrderMaterialCom = false;
  1179. morkF.MainHasTakeMaterial = true;
  1180. WriteData("M14.1", false);//机器人取料完成复位
  1181. }
  1182. if (morkF.MinorProessStatus)
  1183. {
  1184. if (morkF.MinorProcessPotLoc == 1)
  1185. {
  1186. while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1187. {
  1188. Task.Delay(5).Wait();
  1189. }
  1190. }
  1191. else
  1192. {
  1193. while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1194. {
  1195. Task.Delay(5).Wait();
  1196. }
  1197. }
  1198. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1199. {
  1200. loc = order.MaterialLoc[0];
  1201. TakeBurden();
  1202. TurnReset(loc);//转台复位
  1203. DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1204. }
  1205. //等待取料完成
  1206. while (!morkF.TakeMaterialComplete)
  1207. {
  1208. Task.Delay(5).Wait();
  1209. }
  1210. morkF.MinorOrderMaterialCom = false;
  1211. morkF.MinorHasTakeMaterial = true;
  1212. WriteData("M14.5", false);//机器人取料完成复位
  1213. }
  1214. morkF.TurnTableLock = false;//转台互锁解除
  1215. }
  1216. /// <summary>
  1217. /// 取调味品C料
  1218. /// </summary>
  1219. /// <exception cref="NotImplementedException"></exception>
  1220. private void TakeBurdenCTask()
  1221. {
  1222. #region 单口锅逻辑
  1223. int loc = 0;
  1224. while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1225. {
  1226. Task.Delay(5).Wait();
  1227. }
  1228. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1229. {
  1230. loc = order.MaterialLoc[0];
  1231. TakeBurden();
  1232. TurnReset(loc);//转台复位
  1233. DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1234. }
  1235. //等待取料完成
  1236. while (!morkF.TakeMaterialComplete)
  1237. {
  1238. Task.Delay(5).Wait();
  1239. }
  1240. WriteData("M14.1", false);//机器人取料完成复位
  1241. morkF.TurnTableLock = false;//转台互锁解除
  1242. #endregion
  1243. #region 两口锅逻辑
  1244. //int loc = 0;
  1245. //if (morkF.MainProcessStatus)
  1246. //{
  1247. // if (morkF.MainProcessPotLoc == 1)
  1248. // {
  1249. // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1250. // {
  1251. // Task.Delay(5).Wait();
  1252. // }
  1253. // }
  1254. // else
  1255. // {
  1256. // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1257. // {
  1258. // Task.Delay(5).Wait();
  1259. // }
  1260. // }
  1261. // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1262. // {
  1263. // loc = order.MaterialLoc[0];
  1264. // TakeBurden();
  1265. // TurnReset(loc);//转台复位
  1266. // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1267. // }
  1268. // //等待取料完成
  1269. // while (!morkF.TakeMaterialComplete)
  1270. // {
  1271. // Task.Delay(5).Wait();
  1272. // }
  1273. // morkF.MainOrderMaterialCom = false;
  1274. // morkF.MainHasTakeMaterial = true;
  1275. // WriteData("M14.1", false);//机器人取料完成复位
  1276. //}
  1277. //if (morkF.MinorProessStatus)
  1278. //{
  1279. // if (morkF.MinorProcessPotLoc == 1)
  1280. // {
  1281. // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1282. // {
  1283. // Task.Delay(5).Wait();
  1284. // }
  1285. // }
  1286. // else
  1287. // {
  1288. // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1289. // {
  1290. // Task.Delay(5).Wait();
  1291. // }
  1292. // }
  1293. // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1294. // {
  1295. // loc = order.MaterialLoc[0];
  1296. // TakeBurden();
  1297. // TurnReset(loc);//转台复位
  1298. // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1299. // }
  1300. // //等待取料完成
  1301. // while (!morkF.TakeMaterialComplete)
  1302. // {
  1303. // Task.Delay(5).Wait();
  1304. // }
  1305. // morkF.MinorOrderMaterialCom = false;
  1306. // morkF.MinorHasTakeMaterial = true;
  1307. // WriteData("M14.5", false);//机器人取料完成复位
  1308. //}
  1309. //morkF.TurnTableLock = false;//转台互锁解除
  1310. #endregion
  1311. }
  1312. /// <summary>
  1313. /// 主流程出餐
  1314. /// </summary>
  1315. private void MainProcessOutDishTask()
  1316. {
  1317. //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
  1318. //{
  1319. // Task.Delay(5).Wait();
  1320. //}
  1321. #region 单口锅逻辑
  1322. while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
  1323. {
  1324. Task.Delay(5).Wait();
  1325. }
  1326. if (morkF.TakePlateQueue.Count == 0)
  1327. {
  1328. WriteData("M0.7", false);//无订单关闭抽风机
  1329. }
  1330. MainProcessRobotOutMeal();
  1331. WriteData("M1.2", false);//供盘复位
  1332. DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到清洗台控制");
  1333. #endregion
  1334. #region 两口锅逻辑
  1335. //while (morkF.RoobotIdle || (morkF.CleanModule && morkF.SecondCleanModule) || !morkF.ProvidePlateComplete)//等待条件满足
  1336. //{
  1337. // Task.Delay(5).Wait();
  1338. //}
  1339. //if (morkF.TakePlateQueue.Count == 0)
  1340. //{
  1341. // WriteData("M0.7", false);//无订单关闭抽风机
  1342. //}
  1343. //MainProcessRobotOutMeal();
  1344. //WriteData("M1.2", false);//供盘复位
  1345. //DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行取锅到清洗台控制");
  1346. #endregion
  1347. }
  1348. /// <summary>
  1349. /// 复流程流程出餐
  1350. /// </summary>
  1351. private void MinorProcessOutDishTask()
  1352. {
  1353. //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
  1354. //{
  1355. // Task.Delay(5).Wait();
  1356. //}
  1357. while (morkF.RoobotIdle || (morkF.CleanModule && morkF.SecondCleanModule) || !morkF.ProvidePlateComplete)//等待条件满足
  1358. {
  1359. Task.Delay(5).Wait();
  1360. }
  1361. if (morkF.TakePlateQueue.Count == 0)
  1362. {
  1363. WriteData("M0.7", false);//无订单关闭抽风机
  1364. }
  1365. MinorProcessRobotOutMeal();
  1366. WriteData("M1.2", false);//供盘复位
  1367. DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行取锅到清洗台控制");
  1368. }
  1369. /// <summary>
  1370. /// 主流程洗锅放锅
  1371. /// </summary>
  1372. private void MainProcessCleanPotTask()
  1373. {
  1374. #region 单口锅逻辑
  1375. while (!morkF.PlaceRinseTableComplete || morkF.CleanModule)
  1376. {
  1377. Task.Delay(5).Wait();
  1378. }
  1379. WriteData("M14.2", false);//机器人出餐完成复位
  1380. CleanModuleControl("Start", 1);
  1381. DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行清洗操作");
  1382. #endregion
  1383. #region 两口锅逻辑
  1384. //while ((!morkF.PlaceRinseTableComplete || morkF.CleanModule) && (!morkF.PlaceRinseSecondTableComplete || morkF.SecondCleanModule))
  1385. //{
  1386. // Task.Delay(5).Wait();
  1387. //}
  1388. //WriteData("M14.2", false);//机器人出餐完成复位
  1389. //if (morkF.PlaceRinseTableComplete && !morkF.CleanModule)
  1390. //{
  1391. // CleanModuleControl("Start", 1);
  1392. //}
  1393. //if (morkF.PlaceRinseSecondTableComplete && !morkF.SecondCleanModule)
  1394. //{
  1395. // CleanModuleControl("Start", 2);
  1396. //}
  1397. //DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行清洗操作");
  1398. //morkF.MainProcessFlag = false;
  1399. //minorReset.Set();
  1400. #endregion
  1401. //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK);
  1402. }
  1403. /// <summary>
  1404. /// 辅流程洗锅放锅
  1405. /// </summary>
  1406. private void MinorProcessCleanPotTask()
  1407. {
  1408. while ((!morkF.PlaceRinseTableComplete || morkF.CleanModule) && (!morkF.PlaceRinseSecondTableComplete || morkF.SecondCleanModule))
  1409. {
  1410. Task.Delay(5).Wait();
  1411. }
  1412. WriteData("M14.6", false);//机器人出餐完成复位
  1413. if (morkF.PlaceRinseTableComplete && !morkF.CleanModule)
  1414. {
  1415. CleanModuleControl("Start", 1);
  1416. }
  1417. if (morkF.PlaceRinseSecondTableComplete && !morkF.SecondCleanModule)
  1418. {
  1419. CleanModuleControl("Start", 2);
  1420. }
  1421. DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行清洗操作");
  1422. morkF.MinorProcessFlag = false;
  1423. mainReset.Set();
  1424. //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK);
  1425. }
  1426. /// <summary>
  1427. /// 任务复位重启
  1428. /// </summary>
  1429. //private void ResetProgram()
  1430. //{
  1431. // ThreadManage.GetInstance().StartLong(new Action(() =>
  1432. // {
  1433. // if (RTrig.GetInstance("ResetProgram").Start(morkF.DevicDataInite))
  1434. // {
  1435. // ThreadManage.GetInstance().StopTask("MainTask", new Action(() =>
  1436. // {
  1437. // ThreadManage.GetInstance().StopTask("ReadPLCData", new Action(() =>
  1438. // {
  1439. // morkF = null;
  1440. // morkF = new GVL_MorkF();
  1441. // ActionManage.GetInstance.Send("ResetProgram");
  1442. // ActionManage.GetInstance.Send("ClearOrders");
  1443. // ReadData();
  1444. // Main();
  1445. // }));
  1446. // }));
  1447. // }
  1448. // Thread.Sleep(10);
  1449. // }), "ResetProgram");
  1450. //}
  1451. /// <summary>
  1452. /// 主流程翻转机下降及状态检测
  1453. /// </summary>
  1454. public void MainProcessTurnDownStatusDetect()
  1455. {
  1456. int potLoc = MainProcessTurnMachineOrientControl("Down");
  1457. if (potLoc == 1)
  1458. {
  1459. while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
  1460. {
  1461. Task.Delay(5).Wait();
  1462. }
  1463. WriteData("M8.3", false);//下降完成复位
  1464. }
  1465. if (potLoc == 2)
  1466. {
  1467. while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成
  1468. {
  1469. Task.Delay(5).Wait();
  1470. }
  1471. WriteData("M8.7", false);//下降完成复位
  1472. }
  1473. DeviceProcessLogShow($"翻转机下降完成");
  1474. }
  1475. /// <summary>
  1476. /// 辅流程翻转机下降及状态检测
  1477. /// </summary>
  1478. public void MinorProcessTurnDownStatusDetect()
  1479. {
  1480. int potLoc = MinorProcessTurnMachineOrientControl("Down");
  1481. if (potLoc == 1)
  1482. {
  1483. while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
  1484. {
  1485. Task.Delay(5).Wait();
  1486. }
  1487. WriteData("M8.3", false);//下降完成复位
  1488. }
  1489. if (potLoc == 2)
  1490. {
  1491. while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成
  1492. {
  1493. Task.Delay(5).Wait();
  1494. }
  1495. WriteData("M8.7", false);//下降完成复位
  1496. }
  1497. DeviceProcessLogShow($"翻转机下降完成");
  1498. //if (morkF.MaterialCount == 3 && morkF.MainProcessStatus)
  1499. //{
  1500. // morkF.MainProcessWait = true;
  1501. //}
  1502. //else if (morkF.MaterialCount == 3 && morkF.MinorProessStatus)
  1503. //{
  1504. // morkF.MinorProcessWait = true;
  1505. //}
  1506. }
  1507. /// <summary>
  1508. /// 主流程翻转机上升及状态检测
  1509. /// </summary>
  1510. public void MainProcessTurnUpStatusDetect()
  1511. {
  1512. //while (morkF.RoobotIdle)//机器人忙碌
  1513. //{
  1514. // Task.Delay(5).Wait();
  1515. //}
  1516. MainProcessTurnMachineOrientControl("Top");//翻转机上升
  1517. #region 单口锅逻辑
  1518. while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1519. {
  1520. Task.Delay(5).Wait();
  1521. }
  1522. WriteData("M8.1", false);//上升完成复位
  1523. WriteData("M14.3", true);//倒料
  1524. while (!morkF.FallMaterialComplete)//等待倒料完成
  1525. {
  1526. Task.Delay(5).Wait();
  1527. }
  1528. WriteData("M14.3", false);//倒料复位
  1529. DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】,配料倒料完成");
  1530. #endregion
  1531. #region 两口锅逻辑
  1532. //if (morkF.MainProcessPotLoc == 1)
  1533. //{
  1534. // while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1535. // {
  1536. // Task.Delay(5).Wait();
  1537. // }
  1538. // WriteData("M8.1", false);//上升完成复位
  1539. // if (!morkF.MainOrderMaterialCom)
  1540. // {
  1541. // WriteData("M14.3", true);//倒料
  1542. // while (!morkF.FallMaterialComplete)//等待倒料完成
  1543. // {
  1544. // Task.Delay(5).Wait();
  1545. // }
  1546. // morkF.MaterialCount++;
  1547. // WriteData("M14.3", false);//倒料复位
  1548. // if (morkF.MaterialCount == 3)
  1549. // {
  1550. // //允许执行下一个订单流程
  1551. // morkF.MaterialCount = 0;
  1552. // morkF.MinorProcessFlag = true;
  1553. // }
  1554. // morkF.MainOrderMaterialCom = true;
  1555. // morkF.MainHasTakeMaterial = false;
  1556. // DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】,配料倒料完成");
  1557. // }
  1558. // else //辅程准备阻塞
  1559. // {
  1560. // morkF.MainProcessWait = true;
  1561. // }
  1562. //}
  1563. //if (morkF.MainProcessPotLoc == 2)
  1564. //{
  1565. // while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1566. // {
  1567. // Task.Delay(5).Wait();
  1568. // }
  1569. // WriteData("M8.5", false);//上升完成复位
  1570. // if (!morkF.MainOrderMaterialCom)
  1571. // {
  1572. // WriteData("M14.7", true);//倒料
  1573. // while (!morkF.SecondFallMaterialComplete)//等待倒料完成
  1574. // {
  1575. // Task.Delay(5).Wait();
  1576. // }
  1577. // morkF.MaterialCount++;
  1578. // WriteData("M14.7", false);//倒料复位
  1579. // if (morkF.MaterialCount == 3)
  1580. // {
  1581. // //允许执行下一个订单流程
  1582. // morkF.MaterialCount = 0;
  1583. // morkF.MinorProcessFlag = true;
  1584. // }
  1585. // morkF.MainOrderMaterialCom = true;
  1586. // morkF.MainHasTakeMaterial = false;
  1587. // DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】,配料倒料完成");
  1588. // }
  1589. // else //辅流程准备阻塞
  1590. // {
  1591. // morkF.MainProcessWait = true;
  1592. // }
  1593. //}
  1594. #endregion
  1595. DeviceProcessLogShow("翻转机上升完成");
  1596. }
  1597. /// <summary>
  1598. /// 辅流程翻转机上升及状态检测
  1599. /// </summary>
  1600. public void MinorProcessTurnUpStatusDetect()
  1601. {
  1602. while (morkF.RoobotIdle)//机器人忙碌
  1603. {
  1604. Task.Delay(5).Wait();
  1605. }
  1606. MinorProcessTurnMachineOrientControl("Top");//翻转机上升
  1607. if (morkF.MinorProcessPotLoc == 1)
  1608. {
  1609. while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1610. {
  1611. Task.Delay(5).Wait();
  1612. }
  1613. WriteData("M8.1", false);//上升完成复位
  1614. if (!morkF.MinorOrderMaterialCom)
  1615. {
  1616. WriteData("M14.3", true);//倒料
  1617. while (!morkF.FallMaterialComplete)//等待倒料完成
  1618. {
  1619. Task.Delay(5).Wait();
  1620. }
  1621. morkF.MaterialCount++;
  1622. WriteData("M14.3", false);//倒料复位
  1623. if (morkF.MaterialCount == 3)
  1624. {
  1625. //允许执行下一个订单流程
  1626. morkF.MaterialCount = 0;
  1627. morkF.MainProcessFlag = true;
  1628. }
  1629. morkF.MinorOrderMaterialCom = true;
  1630. morkF.MinorHasTakeMaterial = false;
  1631. DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】,配料倒料完成");
  1632. }
  1633. else //主程准备阻塞
  1634. {
  1635. morkF.MinorProcessWait = true;
  1636. }
  1637. }
  1638. if (morkF.MinorProcessPotLoc == 2)
  1639. {
  1640. while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1641. {
  1642. Task.Delay(5).Wait();
  1643. }
  1644. WriteData("M8.5", false);//上升完成复位
  1645. if (!morkF.MinorOrderMaterialCom)
  1646. {
  1647. WriteData("M14.7", true);//倒料
  1648. while (!morkF.SecondFallMaterialComplete)//等待倒料完成
  1649. {
  1650. Task.Delay(5).Wait();
  1651. }
  1652. morkF.MaterialCount++;
  1653. WriteData("M14.7", false);//倒料复位
  1654. if (morkF.MaterialCount == 3)
  1655. {
  1656. //允许执行下一个订单流程
  1657. morkF.MaterialCount = 0;
  1658. morkF.MainProcessFlag = true;
  1659. }
  1660. morkF.MinorOrderMaterialCom = true;
  1661. morkF.MinorHasTakeMaterial = false;
  1662. DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】,配料倒料完成");
  1663. }
  1664. else //主流程准备阻塞
  1665. {
  1666. morkF.MinorProcessWait = true;
  1667. }
  1668. }
  1669. DeviceProcessLogShow("翻转机上升完成");
  1670. }
  1671. private void GetStatus(string key, Action<bool[]> action)
  1672. {
  1673. if (peripheralStatus.ContainsKey(key))
  1674. {
  1675. action((bool[])peripheralStatus[key]);//获取PLC指定地址的状态值
  1676. }
  1677. }
  1678. /// <summary>
  1679. /// 写数据
  1680. /// </summary>
  1681. /// <param name="address"></param>
  1682. /// <param name="value"></param>
  1683. private void WriteData(string address, object value)
  1684. {
  1685. EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
  1686. }
  1687. public void FirstPotGears(int number)
  1688. {
  1689. switch (number)
  1690. {
  1691. case 0:
  1692. //if (morkF.MainProcessStatus && morkF.PotInPlace)
  1693. WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  1694. //if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
  1695. // WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  1696. break;
  1697. case 1:
  1698. // if (morkF.MainProcessStatus)
  1699. WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  1700. //if (morkF.MinorProessStatus)
  1701. // WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  1702. break;
  1703. case 2:
  1704. //if (morkF.MainProcessStatus)
  1705. WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  1706. //if (morkF.MinorProessStatus)
  1707. // WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  1708. break;
  1709. case 3:
  1710. //if (morkF.MainProcessStatus)
  1711. WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  1712. //if (morkF.MinorProessStatus)
  1713. // WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  1714. break;
  1715. case 4:
  1716. // if (morkF.MainProcessStatus)
  1717. WriteData("M4.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
  1718. //if (morkF.MinorProessStatus)
  1719. // WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
  1720. break;
  1721. case 5:
  1722. if (morkF.MainProcessStatus)
  1723. WriteData("M4.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
  1724. //if (morkF.MinorProessStatus)
  1725. // WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
  1726. break;
  1727. case 6:
  1728. // if (morkF.MainProcessStatus)
  1729. WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
  1730. //if (morkF.MinorProessStatus)
  1731. // WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
  1732. break;
  1733. case 7:
  1734. // if (morkF.MainProcessStatus)
  1735. WriteData("M4.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
  1736. //if (morkF.MinorProessStatus)
  1737. // WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
  1738. break;
  1739. case 8:
  1740. //if (morkF.MainProcessStatus)
  1741. WriteData("M4.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
  1742. //if (morkF.MinorProessStatus)
  1743. // WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
  1744. break;
  1745. case 9:
  1746. //if (morkF.MainProcessStatus)
  1747. WriteData("M4.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
  1748. //if (morkF.MinorProessStatus)
  1749. // WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
  1750. break;
  1751. }
  1752. }
  1753. public void SecondPotGears(int number)
  1754. {
  1755. switch (number)
  1756. {
  1757. case 0:
  1758. //if (morkF.MainProcessStatus && morkF.PotInPlace)
  1759. WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  1760. //if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
  1761. // WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  1762. break;
  1763. case 1:
  1764. // if (morkF.MainProcessStatus)
  1765. WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  1766. //if (morkF.MinorProessStatus)
  1767. // WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  1768. break;
  1769. case 2:
  1770. //if (morkF.MainProcessStatus)
  1771. WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  1772. //if (morkF.MinorProessStatus)
  1773. // WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  1774. break;
  1775. case 3:
  1776. //if (morkF.MainProcessStatus)
  1777. WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  1778. //if (morkF.MinorProessStatus)
  1779. // WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  1780. break;
  1781. case 4:
  1782. // if (morkF.MainProcessStatus)
  1783. WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
  1784. //if (morkF.MinorProessStatus)
  1785. // WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
  1786. break;
  1787. case 5:
  1788. if (morkF.MainProcessStatus)
  1789. WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
  1790. //if (morkF.MinorProessStatus)
  1791. // WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
  1792. break;
  1793. case 6:
  1794. // if (morkF.MainProcessStatus)
  1795. WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
  1796. //if (morkF.MinorProessStatus)
  1797. // WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
  1798. break;
  1799. case 7:
  1800. // if (morkF.MainProcessStatus)
  1801. WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
  1802. //if (morkF.MinorProessStatus)
  1803. // WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
  1804. break;
  1805. case 8:
  1806. //if (morkF.MainProcessStatus)
  1807. WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
  1808. //if (morkF.MinorProessStatus)
  1809. // WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
  1810. break;
  1811. case 9:
  1812. //if (morkF.MainProcessStatus)
  1813. WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
  1814. //if (morkF.MinorProessStatus)
  1815. // WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
  1816. break;
  1817. }
  1818. }
  1819. /// <summary>
  1820. /// 主流程灶台档位调节
  1821. /// </summary>
  1822. public void MainProcessKitchenAdjustGears(int number)
  1823. {
  1824. #region 单口锅逻辑
  1825. while (!morkF.PotInPlace)
  1826. {
  1827. Task.Delay(5).Wait();
  1828. }
  1829. FirstPotGears(number);
  1830. DeviceProcessLogShow($"灶台【{morkF.CurrentOrderId}】档位调节至【{number}】挡");
  1831. #endregion
  1832. #region 两口锅逻辑
  1833. //if (morkF.MainProcessPotLoc == 1)
  1834. //{
  1835. // while (!morkF.PotInPlace)
  1836. // {
  1837. // Task.Delay(5).Wait();
  1838. // }
  1839. // FirstPotGears(number);
  1840. //}
  1841. //if (morkF.MainProcessPotLoc == 2)
  1842. //{
  1843. // while (!morkF.SecondPotInPlace)
  1844. // {
  1845. // Task.Delay(5).Wait();
  1846. // }
  1847. // SecondPotGears(number);
  1848. //}
  1849. //DeviceProcessLogShow($"灶台【{morkF.MainProcessPotLoc}】档位调节至【{number}】挡");
  1850. #endregion
  1851. }
  1852. /// <summary>
  1853. /// 辅流程灶台档位调节
  1854. /// </summary>
  1855. public void MinorProcessKitchenAdjustGears(int number)
  1856. {
  1857. if (morkF.MinorProcessPotLoc == 1)
  1858. {
  1859. while (!morkF.PotInPlace)
  1860. {
  1861. Task.Delay(5).Wait();
  1862. }
  1863. FirstPotGears(number);
  1864. }
  1865. if (morkF.MinorProcessPotLoc == 2)
  1866. {
  1867. while (!morkF.SecondPotInPlace)
  1868. {
  1869. Task.Delay(5).Wait();
  1870. }
  1871. SecondPotGears(number);
  1872. }
  1873. DeviceProcessLogShow($"灶台【{morkF.MinorProcessPotLoc}】档位调节至【{number}】挡");
  1874. }
  1875. /// <summary>
  1876. /// PLC转台控制
  1877. /// </summary>
  1878. /// <param name="loc"></param>
  1879. public void TurnMaterialStore(int loc)
  1880. {
  1881. switch (loc)
  1882. {
  1883. case 1:
  1884. WriteData("M13.0", true);
  1885. break;
  1886. case 2:
  1887. WriteData("M13.1", true);
  1888. break;
  1889. case 3:
  1890. WriteData("M13.2", true);
  1891. break;
  1892. case 4:
  1893. WriteData("M13.3", true);
  1894. break;
  1895. case 5:
  1896. WriteData("M13.4", true);
  1897. break;
  1898. }
  1899. }
  1900. public void PLCInite()
  1901. {
  1902. WriteData("M0.0", true);
  1903. }
  1904. /// <summary>
  1905. /// 供盘启动
  1906. /// </summary>
  1907. public void StartTakePlate()
  1908. {
  1909. WriteData("M1.1", true);
  1910. }
  1911. /// <summary>
  1912. /// 取锅到灶台
  1913. /// </summary>
  1914. public void TakePotToKitchen(int loc)
  1915. {
  1916. if (loc == 1)
  1917. WriteData("M14.0", true);
  1918. if (loc == 2)
  1919. WriteData("M14.4", true);
  1920. }
  1921. /// <summary>
  1922. /// 主流程机器人出餐并将锅放置清洗台位置
  1923. /// </summary>
  1924. public void MainProcessRobotOutMeal()
  1925. {
  1926. #region 单口锅逻辑
  1927. WriteData("M14.2", true);//1号锅出餐
  1928. #endregion
  1929. #region 两口锅逻辑
  1930. //if (morkF.MainProcessPotLoc == 1)
  1931. //{
  1932. // WriteData("M14.2", true);//1号锅出餐
  1933. //}
  1934. //else if (morkF.MainProcessPotLoc == 2)
  1935. //{
  1936. // WriteData("M14.6", true);//2号锅出餐
  1937. //}
  1938. #endregion
  1939. }
  1940. /// <summary>
  1941. /// 复流程机器人出餐并将锅放置清洗台位置
  1942. /// </summary>
  1943. public void MinorProcessRobotOutMeal()
  1944. {
  1945. if (morkF.MinorProcessPotLoc == 1)
  1946. {
  1947. WriteData("M14.2", true);//1号锅出餐
  1948. }
  1949. else if (morkF.MinorProcessPotLoc == 2)
  1950. {
  1951. WriteData("M14.6", true);//2号锅出餐
  1952. }
  1953. }
  1954. public void OpenDraft()
  1955. {
  1956. WriteData("M0.7", true);//打开抽风机
  1957. }
  1958. /// <summary>
  1959. /// 注油
  1960. /// </summary>
  1961. public void AddOil()
  1962. {
  1963. #region 单口锅逻辑
  1964. while (!morkF.PotInPlace)
  1965. {
  1966. Task.Delay(5).Wait();
  1967. }
  1968. WriteData("M2.7", true);//加油
  1969. OpenDraft();
  1970. DeviceProcessLogShow("开始注油");
  1971. while (!morkF.FallOilComplete)
  1972. {
  1973. Task.Delay(5).Wait();
  1974. }
  1975. #endregion
  1976. #region 两口锅逻辑
  1977. //if (morkF.MainProcessStatus)
  1978. //{
  1979. // if (morkF.MainProcessPotLoc == 1)
  1980. // {
  1981. // while (!morkF.PotInPlace)
  1982. // {
  1983. // Task.Delay(5).Wait();
  1984. // }
  1985. // WriteData("M2.7", true);//加油
  1986. // OpenDraft();
  1987. // DeviceProcessLogShow("开始注油");
  1988. // while (!morkF.FallOilComplete)
  1989. // {
  1990. // Task.Delay(5).Wait();
  1991. // }
  1992. // }
  1993. // if (morkF.MainProcessPotLoc == 2)
  1994. // {
  1995. // while (!morkF.SecondPotInPlace)
  1996. // {
  1997. // Task.Delay(5).Wait();
  1998. // }
  1999. // WriteData("M3.1", true);//加油
  2000. // OpenDraft();
  2001. // DeviceProcessLogShow("开始注油");
  2002. // while (!morkF.SecondOilComplete)
  2003. // {
  2004. // Task.Delay(5).Wait();
  2005. // }
  2006. // }
  2007. //}
  2008. //if (morkF.MinorProessStatus)
  2009. //{
  2010. // if (morkF.MinorProcessPotLoc == 1)
  2011. // {
  2012. // while (!morkF.PotInPlace)
  2013. // {
  2014. // Task.Delay(5).Wait();
  2015. // }
  2016. // WriteData("M2.7", true);//加油
  2017. // OpenDraft();
  2018. // DeviceProcessLogShow("开始注油");
  2019. // while (!morkF.FallOilComplete)
  2020. // {
  2021. // Task.Delay(5).Wait();
  2022. // }
  2023. // }
  2024. // if (morkF.MinorProcessPotLoc == 2)
  2025. // {
  2026. // while (!morkF.SecondPotInPlace)
  2027. // {
  2028. // Task.Delay(5).Wait();
  2029. // }
  2030. // WriteData("M3.1", true);//加油
  2031. // OpenDraft();
  2032. // DeviceProcessLogShow("开始注油");
  2033. // while (!morkF.SecondOilComplete)
  2034. // {
  2035. // Task.Delay(5).Wait();
  2036. // }
  2037. // }
  2038. //}
  2039. #endregion
  2040. //while (!morkF.FallOilComplete || !morkF.SecondOilComplete)
  2041. //{
  2042. // Task.Delay(5).Wait();
  2043. //}
  2044. DeviceProcessLogShow("注油完成");
  2045. }
  2046. public void FirstPotTurnMachine(string orientation)
  2047. {
  2048. switch (orientation)
  2049. {
  2050. case "Top": WriteData("M8.0", true); break;
  2051. case "Down": WriteData("M8.2", true); break;
  2052. }
  2053. }
  2054. public void SecondPotTurnMachine(string orientation)
  2055. {
  2056. switch (orientation)
  2057. {
  2058. case "Top": WriteData("M8.4", true); break;
  2059. case "Down": WriteData("M8.6", true); break;
  2060. }
  2061. }
  2062. /// <summary>
  2063. /// 主流程翻转机方向控制
  2064. /// </summary>
  2065. /// <param name="orientation"></param>
  2066. public int MainProcessTurnMachineOrientControl(string orientation)
  2067. {
  2068. int potLoc = 0;
  2069. #region 单口锅逻辑
  2070. FirstPotTurnMachine(orientation);
  2071. potLoc = 1;
  2072. #endregion
  2073. #region 两口锅逻辑
  2074. //if (morkF.MainProcessPotLoc == 1)
  2075. //{
  2076. // FirstPotTurnMachine(orientation);
  2077. // potLoc = 1;
  2078. //}
  2079. //if (morkF.MainProcessPotLoc == 2)
  2080. //{
  2081. // SecondPotTurnMachine(orientation);
  2082. // potLoc = 2;
  2083. //}
  2084. #endregion
  2085. DeviceProcessLogShow($"翻转机执行{orientation}操作");
  2086. return potLoc;
  2087. }
  2088. /// <summary>
  2089. /// 辅流程翻转机方向控制
  2090. /// </summary>
  2091. /// <param name="orientation"></param>
  2092. public int MinorProcessTurnMachineOrientControl(string orientation)
  2093. {
  2094. int potLoc = 0;
  2095. if (morkF.MinorProcessPotLoc == 1)
  2096. {
  2097. FirstPotTurnMachine(orientation);
  2098. potLoc = 1;
  2099. }
  2100. if (morkF.MinorProcessPotLoc == 2)
  2101. {
  2102. SecondPotTurnMachine(orientation);
  2103. potLoc = 2;
  2104. }
  2105. DeviceProcessLogShow($"翻转机执行{orientation}操作");
  2106. return potLoc;
  2107. }
  2108. public void FirstPotTurnMachine(int gear)
  2109. {
  2110. while (!morkF.PotInPlace)
  2111. {
  2112. Task.Delay(5).Wait();
  2113. }
  2114. switch (gear)
  2115. {
  2116. case 0: WriteData("M7.0", true); Task.Delay(1000).Wait(); break;//关闭翻炒机
  2117. case 1: WriteData("M7.1", true); break;//翻炒机1挡
  2118. case 2: WriteData("M7.2", true); break;//翻炒机2挡
  2119. case 3: WriteData("M7.3", true); break;//翻炒机3挡
  2120. }
  2121. }
  2122. public void SecondPotTurnMachine(int gear)
  2123. {
  2124. while (!morkF.SecondPotInPlace)
  2125. {
  2126. Task.Delay(5).Wait();
  2127. }
  2128. switch (gear)
  2129. {
  2130. case 0: WriteData("M7.4", true); Task.Delay(1000).Wait(); break;//关闭翻炒机
  2131. case 1: WriteData("M7.5", true); break;//翻炒机1挡
  2132. case 2: WriteData("M7.6", true); break;//翻炒机2挡
  2133. case 3: WriteData("M7.7", true); break;//翻炒机3挡
  2134. }
  2135. }
  2136. /// <summary>
  2137. /// 主流程翻转机档位控制
  2138. /// </summary>
  2139. public void MainProcessTurnMachineGearsControl(int gear)
  2140. {
  2141. #region 单口锅逻辑
  2142. FirstPotTurnMachine(gear);
  2143. DeviceProcessLogShow($"炒锅【{morkF.CurrentOrderId}】翻转机档位调至{gear}挡");
  2144. #endregion
  2145. #region 两口锅逻辑
  2146. //if (morkF.MainProcessPotLoc == 1)
  2147. //{
  2148. // FirstPotTurnMachine(gear);
  2149. //}
  2150. //if (morkF.MainProcessPotLoc == 2)
  2151. //{
  2152. // SecondPotTurnMachine(gear);
  2153. //}
  2154. //DeviceProcessLogShow($"炒锅【{morkF.MainProcessPotLoc}】翻转机档位调至{gear}挡");
  2155. #endregion
  2156. }
  2157. /// <summary>
  2158. /// 辅流程翻转机档位控制
  2159. /// </summary>
  2160. public void MinorProcessTurnMachineGearsControl(int gear)
  2161. {
  2162. if (morkF.MinorProcessPotLoc == 1)
  2163. {
  2164. FirstPotTurnMachine(gear);
  2165. }
  2166. if (morkF.MinorProcessPotLoc == 2)
  2167. {
  2168. SecondPotTurnMachine(gear);
  2169. }
  2170. DeviceProcessLogShow($"炒锅【{morkF.MinorProcessPotLoc}】翻转机档位调至{gear}挡");
  2171. }
  2172. /// <summary>
  2173. /// 取A,B,C料
  2174. /// </summary>
  2175. public void TakeBurden()
  2176. {
  2177. #region 单口锅逻辑
  2178. WriteData("M14.1", true);//机器人取料至1号锅
  2179. #endregion
  2180. #region 两口锅逻辑
  2181. //if (morkF.PotInPlace)
  2182. // WriteData("M14.1", true);//机器人取料至1号锅
  2183. //if (morkF.SecondPotInPlace)
  2184. // WriteData("M14.5", true);//机器人取料至2号锅
  2185. #endregion
  2186. }
  2187. /// <summary>
  2188. /// 清洗模组1启停控制
  2189. /// </summary>
  2190. public void CleanModuleControl(string status, int loc)
  2191. {
  2192. if (loc == 1)
  2193. {
  2194. if (status == "Start")
  2195. {
  2196. WriteData("M1.4", true);
  2197. }
  2198. if (status == "Stop")
  2199. {
  2200. WriteData("M1.4", false);
  2201. }
  2202. DeviceProcessLogShow($"清洗模组1执行【{status}】操作");
  2203. }
  2204. if (loc == 2)
  2205. {
  2206. if (status == "Start")
  2207. {
  2208. WriteData("M1.7", true);
  2209. }
  2210. if (status == "Stop")
  2211. {
  2212. WriteData("M1.7", false);
  2213. }
  2214. DeviceProcessLogShow($"清洗模组2执行【{status}】操作");
  2215. }
  2216. }
  2217. public override void Stop()
  2218. {
  2219. }
  2220. public override void SimOrder()
  2221. {
  2222. }
  2223. }
  2224. }