终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

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