终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

685 line
26 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using BPA.Message.Enum;
  4. using BPASmartClient.Device;
  5. using BPASmartClient.EventBus;
  6. using BPASmartClient.Model;
  7. using BPASmartClient.Peripheral;
  8. using static BPASmartClient.EventBus.EventBus;
  9. using BPASmartClient.Helper;
  10. using System.Threading;
  11. using BPASmartClient.Message;
  12. using BPA.Message;
  13. using System.Linq;
  14. using BPASmartClient.Model.PLC;
  15. using System.Threading.Tasks;
  16. using System.Reflection;
  17. namespace BPASmartClient.MorkS
  18. {
  19. public class Control_Morks : BaseDevice
  20. {
  21. public override DeviceClientType DeviceType => DeviceClientType.MORKS;
  22. GVL_MORKS mORKS = new GVL_MORKS();
  23. Alarm alarm = new Alarm();
  24. public override void DoMain()
  25. {
  26. ServerInit();
  27. DataParse();
  28. ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice");
  29. }
  30. public override void ResetProgram()
  31. {
  32. mORKS = null;
  33. mORKS = new GVL_MORKS();
  34. }
  35. public override void Stop()
  36. {
  37. }
  38. private void ServerInit()
  39. {
  40. //物料信息
  41. EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  42. {
  43. if (@event == null) return;
  44. if (@event is MaterialDeliveryEvent material)
  45. {
  46. orderMaterialDelivery = material.orderMaterialDelivery;
  47. }
  48. });
  49. //配方数据信息
  50. EventBus.EventBus.GetInstance().Subscribe<RecipeBomEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  51. {
  52. if (@event == null) return;
  53. if (@event is RecipeBomEvent recipe)
  54. {
  55. recipeBoms = recipe.recipeBoms;
  56. WriteRecipeBoms();
  57. }
  58. });
  59. }
  60. private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
  61. {
  62. var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid);
  63. string goodName = string.Empty;
  64. if (res != null) goodName = res.MorkOrder.GoodsName;
  65. EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
  66. }
  67. private void ReadData(string address, ushort len = 1, Action<bool[]> action = null)
  68. {
  69. EventBus.EventBus.GetInstance().Publish(new ReadModel() { DeviceId = DeviceId, Address = address, Length = len }, (o) =>
  70. {
  71. if (o != null && o.Length > 0 && o[0] is bool[] bools)
  72. {
  73. action(bools);
  74. }
  75. });
  76. }
  77. private void GetStatus(string key, Action<bool[]> action)
  78. {
  79. if (peripheralStatus.ContainsKey(key))
  80. {
  81. if (peripheralStatus[key] is bool[] bools)
  82. {
  83. action?.Invoke(bools);
  84. }
  85. //action((bool[])peripheralStatus[key]);
  86. }
  87. }
  88. public override void ReadData()
  89. {
  90. GetStatus("M230.0", new Action<bool[]>((bools) =>
  91. {
  92. alarm.MachineLeftLowTemperature = bools[0];
  93. alarm.MachineRightLowTemperature = bools[1];
  94. alarm.Supply1_LossBowl = bools[2];
  95. alarm.Supply2_LossBowl = bools[3];
  96. alarm.Supply1_ErrorOutBowl = bools[4];
  97. alarm.Supply2_ErrorOutBowl = bools[5];
  98. alarm.PushBowlCylinderError = bools[6];
  99. alarm.NoodleMacCommunicateError = bools[7];
  100. alarm.DosingMacCommunicateError = bools[8];
  101. alarm.RobotMacCommunicateError = bools[9];
  102. alarm.DeviceEstop = bools[10];
  103. alarm.RobotInitError = bools[11];
  104. alarm.RobotUrgentStop = bools[12];
  105. alarm.RobotNotInRemoteMode = bools[13];
  106. alarm.RobotNotInReady = bools[14];
  107. alarm.RobotSelfInException = bools[15];
  108. alarm.LeftLackWater = bools[16];
  109. alarm.RightLackWater = bools[17];
  110. alarm.SvrewInitFail = bools[18];
  111. alarm.TurntableInitFail = bools[19];
  112. alarm.RobotInitFail = bools[20];
  113. alarm.NoodleCookerInitFail = bools[21];
  114. alarm.PushBowlInitFail1 = bools[22];
  115. alarm.PushBowlInitFail2 = bools[23];
  116. }));
  117. GetStatus("M0.3", new Action<bool[]>((bools) =>
  118. {
  119. mORKS.RobotTakeNoodle = bools[0];
  120. mORKS.RobotOutMeal = bools[1];
  121. mORKS.MoveTurntable = bools[2];
  122. }));
  123. GetStatus("M100.0", new Action<bool[]>((bools) =>
  124. {
  125. mORKS.InitComplete = bools[0];
  126. mORKS.TakeBowlIdle = bools[1];
  127. mORKS.TemperatureReached = bools[2];
  128. mORKS.AllowFallNoodle = bools[3];
  129. mORKS.RbTakeNoodleComplete = bools[4];
  130. mORKS.RbFallNoodleComplete = bools[5];
  131. mORKS.RbOutMealComplete = bools[6];
  132. mORKS.RobotIdle = bools[7];
  133. mORKS.TakeMealDetect = bools[8];
  134. mORKS.MissingBowl = bools[9];
  135. Initing = bools[10];
  136. mORKS.TurntableLowerLimit = bools[11];
  137. mORKS.MissingBowlSignal2 = bools[12];
  138. mORKS.TurntableUpLimit = bools[13];
  139. mORKS.FeedComplete = bools[14];
  140. mORKS.TurntableMoveInPlace = bools[15];
  141. }));
  142. GetStatus("M235.0", new Action<bool[]>((bools) =>
  143. {
  144. mORKS.Error = bools[0];
  145. }));
  146. GetStatus("M102.0", new Action<bool[]>((bools) =>
  147. {
  148. for (int i = 0; i < 6; i++)
  149. {
  150. mORKS.NoodleCookerStatus[i] = bools[i];
  151. }
  152. mORKS.Feeding = bools[6];
  153. }));
  154. GetStatus("M103.0", new Action<bool[]>((bools) =>
  155. {
  156. for (int i = 0; i < 6; i++)
  157. {
  158. mORKS.CookNoodlesComplete[i] = bools[i];
  159. }
  160. }));
  161. //EventBus.EventBus.GetInstance().Publish(new ReadModel() { DeviceId = DeviceId, Address = "VW372", Length = 1 }, (o) =>
  162. //{
  163. // if (o != null && o.Length > 0 && o[0] is ushort value)
  164. // {
  165. // mORKS.TurntableFeedbackloc = value;
  166. // }
  167. //});
  168. }
  169. /// <summary>
  170. /// 数据解析
  171. /// </summary>
  172. private void DataParse()
  173. {
  174. EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
  175. {
  176. if (@event == null) return;
  177. if (@event is DoOrderEvent order)
  178. {
  179. mORKS.doOrderEvents.Add(order);
  180. if (order.MorkOrder.GoodBatchings == null) return;
  181. OrderCount++;
  182. DeviceProcessLogShow($"接收到{OrderCount}次订单");
  183. foreach (var item in order.MorkOrder.GoodBatchings)
  184. {
  185. var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
  186. if (res != null)
  187. {
  188. if (ushort.TryParse(res.BatchingLoc, out ushort loc))
  189. {
  190. if (loc >= 1 && loc <= 5)
  191. {
  192. if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  193. mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { GoodName = order.MorkOrder.GoodsName, Loc = ushort.Parse(res.BatchingLoc), SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId });
  194. }
  195. else if (loc >= 10 && loc <= 11)
  196. {
  197. int index = 0;
  198. if (recipeBoms != null)
  199. {
  200. index = Array.FindIndex(recipeBoms.RecipeIds?.ToArray(), p => p.RecipeId == order.MorkOrder.RecipeId);
  201. index++;
  202. }
  203. if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  204. mORKS.TakeBowlTask.Enqueue(new OrderLocInfo()
  205. {
  206. BatchingId = res.BatchingId,
  207. GoodName = order.MorkOrder.GoodsName,
  208. Loc = ushort.Parse(res.BatchingLoc),
  209. SuborderId = order.MorkOrder.SuborderId,
  210. RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0
  211. });
  212. }
  213. }
  214. }
  215. }
  216. }
  217. });
  218. }
  219. public override void MainTask()
  220. {
  221. mORKS.AllowRun = mORKS.InitComplete;
  222. IsHealth = mORKS.Error && mORKS.InitComplete;
  223. //IsHealth = true;
  224. if (mORKS.AllowRun)
  225. {
  226. TakeBowlTask();
  227. TakeNoodleTask();
  228. OutNoodleTask();
  229. SingleDetect();
  230. TurntableControl();
  231. }
  232. }
  233. private void BowlControl(OrderLocInfo orderLocInfo)
  234. {
  235. if (orderLocInfo.Loc >= 10 && orderLocInfo.Loc <= 11)
  236. {
  237. mORKS.TakeBowlId = orderLocInfo.SuborderId;
  238. TakeBowlControl(orderLocInfo.Loc);
  239. SetRecipeNumber(orderLocInfo.RecipeNumber);
  240. OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING);
  241. DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
  242. mORKS.TakeBowlInterlock = true;
  243. }
  244. }
  245. /// <summary>
  246. /// 取碗控制
  247. /// </summary>
  248. private void TakeBowlTask()
  249. {
  250. if (mORKS.AllowRun && mORKS.TakeBowlTask.Count > 0 && !mORKS.TakeBowlIdle && !mORKS.TakeBowlInterlock)
  251. {
  252. //if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo))
  253. //{
  254. ushort BowLoc = 0;
  255. var res = orderMaterialDelivery?.BatchingInfo?.Where(p => p.BatchingId == mORKS.TakeBowlTask.ElementAt(0).BatchingId).ToList();
  256. if (res == null || res?.Count == 0)
  257. {
  258. if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) BowlControl(orderLocInfo);
  259. }
  260. else
  261. {
  262. foreach (var item in res)
  263. {
  264. if (ushort.TryParse(item.BatchingLoc, out ushort loc))
  265. {
  266. DeviceProcessLogShow($"位置:={loc},检测开关1:{alarm.Supply1_LossBowl},检测开关1:{alarm.Supply2_LossBowl}");
  267. if (loc == 10 && !alarm.Supply1_LossBowl)
  268. {
  269. BowLoc = loc;
  270. break;
  271. }
  272. else if (loc == 11 && !alarm.Supply2_LossBowl)
  273. {
  274. BowLoc = loc;
  275. break;
  276. }
  277. }
  278. }
  279. if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo))
  280. {
  281. orderLocInfo.Loc = BowLoc;
  282. BowlControl(orderLocInfo);
  283. }
  284. }
  285. //if (BowLoc >= 10 && BowLoc <= 11)
  286. //{
  287. // mORKS.TakeBowlInterlock = true;
  288. // mORKS.TakeBowlId = orderLocInfo.SuborderId;
  289. // TakeBowlControl(BowLoc);
  290. // SetRecipeNumber(orderLocInfo.RecipeNumber);
  291. // OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING);
  292. // DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
  293. //}
  294. //之前版本
  295. //mORKS.TakeBowlId = orderLocInfo.SuborderId;
  296. //TakeBowlControl(orderLocInfo.Loc);
  297. //SetRecipeNumber(orderLocInfo.RecipeNumber);
  298. //OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING);
  299. //DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
  300. //mORKS.TakeBowlInterlock = true;
  301. //}
  302. }
  303. }
  304. /// <summary>
  305. /// 转台控制
  306. /// </summary>
  307. private void TurntableControl()
  308. {
  309. //if (GeneralConfig.EnableLocalSimOrder)
  310. //{
  311. // //不做轮询,直接取面,模拟订单使用
  312. // if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
  313. // {
  314. // if (mORKS.TurntableLowerLimit)
  315. // {
  316. // TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc);
  317. // mORKS.TurntableLocLists.Clear();
  318. // mORKS.AllowTakeNoodle = true;
  319. // DeviceProcessLogShow($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面");
  320. // }
  321. // }
  322. //}
  323. //else
  324. {
  325. //正常轮询
  326. if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
  327. {
  328. var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList();
  329. if (result != null)
  330. {
  331. var res = result.FirstOrDefault(P => P.BatchingLoc == mORKS.TurntableFeedbackloc.ToString());
  332. if (mORKS.TurntableLowerLimit && res != null)
  333. {
  334. TurntableStart(mORKS.TurntableFeedbackloc);
  335. mORKS.TurntableLocLists.Clear();
  336. mORKS.AllowTakeNoodle = true;
  337. DeviceProcessLogShow($"控制机器人去转台【{mORKS.TurntableFeedbackloc}】号位置取面");
  338. }
  339. else
  340. {
  341. if (!mORKS.TurntableInterlock)
  342. {
  343. foreach (var item in result)
  344. {
  345. if (ushort.TryParse(item.BatchingLoc, out ushort loc))
  346. {
  347. if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc))
  348. {
  349. TurntableStart(loc);
  350. DeviceProcessLogShow($"没有物料检测的启动转台控制,转台位置:[{loc}]");
  351. break;
  352. }
  353. else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc);
  354. }
  355. }
  356. }
  357. }
  358. }
  359. else DeviceProcessLogShow("未找到可用的物料信息");
  360. }
  361. }
  362. //补料中检测
  363. if (RTrig.GetInstance("mORKS.Feeding").Start(mORKS.Feeding))
  364. {
  365. mORKS.AllowTakeNoodle = false;
  366. mORKS.TakeNoodleInterlock = false;
  367. }
  368. //转台到位检测
  369. if (RTrig.GetInstance("TurntableInPlace").Start(mORKS.TurntableMoveInPlace && mORKS.CurrentLoc == mORKS.TurntableFeedbackloc))
  370. {
  371. mORKS.CurrentLoc = 0;
  372. mORKS.TurntableInterlock = false;
  373. DeviceProcessLogShow("转台到位检测");
  374. }
  375. //补料完成检测
  376. if (RTrig.GetInstance("FeedComplete").Start(mORKS.FeedComplete))
  377. {
  378. if (!mORKS.AllowTakeNoodle && mORKS.TurntableLocLists.Count > 0)
  379. {
  380. mORKS.TurntableLocLists.Clear();
  381. mORKS.TurntableInterlock = false;
  382. DeviceProcessLogShow("补料完成检测");
  383. }
  384. }
  385. }
  386. /// <summary>
  387. /// 取面任务
  388. /// </summary>
  389. private void TakeNoodleTask()
  390. {
  391. //取面控制
  392. if (mORKS.AllowRun && mORKS.RobotIdle && !mORKS.Feeding && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0)
  393. {
  394. int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置
  395. if (loc >= 0 && loc <= 5)
  396. {
  397. if (mORKS.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo))
  398. {
  399. mORKS.CookNodelId[loc] = orderLocInfo.SuborderId;
  400. SetFallNoodleLoc((ushort)(loc + 1));
  401. //机器人开始取面
  402. RobotTakeNoodle();
  403. OrderChange(orderLocInfo.SuborderId, ORDER_STATUS.COOKING);
  404. DeviceProcessLogShow($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏");
  405. //写入煮面时间
  406. //List<ushort> values = new List<ushort>();
  407. //values.Add(Json<KeepDataBase>.Data.parSets.ElementAt(loc).Minute);
  408. //values.Add(Json<KeepDataBase>.Data.parSets.ElementAt(loc).Second);
  409. //ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray());
  410. mORKS.TakeNoodleInterlock = true;
  411. }
  412. }
  413. }
  414. }
  415. /// <summary>
  416. /// 出餐控制
  417. /// </summary>
  418. private void OutNoodleTask()
  419. {
  420. if (mORKS.AllowFallNoodle && mORKS.RobotTaskInterlock && !mORKS.TakeNoodleInterlock && mORKS.RobotIdle && !mORKS.TakeMealDetect)
  421. {
  422. int loc = Array.FindIndex(mORKS.CookNodelId, p => p == mORKS.IngredientsCompleteId && p.Length > 0);
  423. if (loc >= 0 && loc <= 5)
  424. {
  425. if (mORKS.CookNoodlesComplete[loc])
  426. {
  427. SetTakeNoodleLoc((ushort)(loc + 1));
  428. RobotOutMeal();
  429. CookNoodleStatusReset((ushort)(loc + 1));
  430. ResetAllowFallNoodle();
  431. mORKS.OutMealId = mORKS.IngredientsCompleteId;
  432. mORKS.IngredientsCompleteId = string.Empty;
  433. mORKS.CookNodelId[loc] = string.Empty;
  434. DeviceProcessLogShow($"{loc + 1}号位置出餐控制");
  435. mORKS.OutNoodleing = true;
  436. }
  437. }
  438. }
  439. }
  440. /// <summary>
  441. /// 信号检测
  442. /// </summary>
  443. private void SingleDetect()
  444. {
  445. //允许倒面信号检测
  446. if (RTrig.GetInstance("AllowFallNoodle").Start(mORKS.AllowFallNoodle))
  447. {
  448. mORKS.IngredientsCompleteId = mORKS.TakeBowlId;
  449. mORKS.TakeBowlId = string.Empty;
  450. DeviceProcessLogShow($"碗到位,允许到面,{mORKS.IngredientsCompleteId}");
  451. mORKS.TakeBowlInterlock = false;
  452. }
  453. //出餐完成信号检测
  454. if (RTrig.GetInstance("CompleteChange").Start(mORKS.RbOutMealComplete))
  455. {
  456. OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_COOK);
  457. DeviceProcessLogShow($"订单【{mORKS.OutMealId}】制作完成");
  458. mORKS.OutNoodleing = false;
  459. }
  460. //取餐完成逻辑处理
  461. if (DelayRTrig.GetInstance("CompleteChange1").Start(mORKS.RbOutMealComplete && !mORKS.TakeMealDetect, 2))
  462. {
  463. OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE);
  464. DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成");
  465. ResetCookComplete();
  466. mORKS.OutMealId = string.Empty;
  467. }
  468. //机器人取面完成信号检测
  469. if (RTrig.GetInstance("TakeNoodleComplete").Start(mORKS.RbTakeNoodleComplete))
  470. {
  471. mORKS.TakeNoodleInterlock = false;
  472. mORKS.AllowTakeNoodle = false;
  473. mORKS.TurntableInterlock = false;
  474. DeviceProcessLogShow("机器人取面完成信号检测");
  475. TakeNoodleCompleteReset();
  476. }
  477. int OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count;
  478. int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count;
  479. mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0);
  480. }
  481. #region PLC 控制函数
  482. private void WriteData(string address, object value)
  483. {
  484. EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
  485. }
  486. /// <summary>
  487. /// 写入配方数据到 PLC
  488. /// </summary>
  489. private void WriteRecipeBoms()
  490. {
  491. List<ushort> recipeBoms = new List<ushort>();
  492. if (this.recipeBoms == null) return;
  493. foreach (var item in this.recipeBoms.RecipeIds)
  494. {
  495. foreach (var rec in item.Recipes)
  496. {
  497. recipeBoms.Add((ushort)rec);
  498. }
  499. }
  500. if (recipeBoms.Count > 0)
  501. {
  502. //配方数据地址范围:VW2000 - VW2278
  503. WriteData("VW2000", recipeBoms.ToArray());
  504. DeviceProcessLogShow("写配方成功");
  505. }
  506. else { DeviceProcessLogShow("配方数据为空"); }
  507. }
  508. /// <summary>
  509. /// 取面完成复位
  510. /// </summary>
  511. private void TakeNoodleCompleteReset()
  512. {
  513. WriteData("M100.4", false);
  514. }
  515. /// <summary>
  516. /// 指定煮面口状态复位
  517. /// </summary>
  518. /// <param name="num"></param>
  519. private void CookNoodleStatusReset(int num)
  520. {
  521. if (num >= 1 && num <= 6)
  522. {
  523. WriteData($"102.{num - 1}", false);
  524. DeviceProcessLogShow($"{num}号煮面口占用复位");
  525. }
  526. }
  527. /// <summary>
  528. /// 写配方编号
  529. /// </summary>
  530. /// <param name="num"></param>
  531. private void SetRecipeNumber(ushort num)
  532. {
  533. WriteData("VW0", num);
  534. }
  535. /// <summary>
  536. /// 启动转台
  537. /// </summary>
  538. /// <param name="loc"></param>
  539. private void TurntableStart(ushort loc)
  540. {
  541. mORKS.CurrentLoc = loc;
  542. mORKS.TurntableInterlock = true;
  543. mORKS.TurntableLocLists.Add(loc);
  544. WriteData("VW2", loc);
  545. WriteData("M0.5", true);
  546. }
  547. /// <summary>
  548. /// 设置倒面位置
  549. /// </summary>
  550. /// <param name="loc"></param>
  551. private void SetFallNoodleLoc(ushort loc)
  552. {
  553. WriteData("VW4", loc);
  554. }
  555. /// <summary>
  556. /// 设置取面位置
  557. /// </summary>
  558. /// <param name="loc"></param>
  559. private void SetTakeNoodleLoc(ushort loc)
  560. {
  561. WriteData("VW6", loc);
  562. }
  563. /// <summary>
  564. /// 取碗控制
  565. /// </summary>
  566. /// <param name="loc"></param>
  567. private void TakeBowlControl(ushort loc)
  568. {
  569. if (loc == 10)//小碗
  570. {
  571. WriteData("M0.1", true);
  572. }
  573. else if (loc == 11)//大碗
  574. {
  575. WriteData("M0.2", true);
  576. }
  577. }
  578. /// <summary>
  579. /// 机器人取面
  580. /// </summary>
  581. private void RobotTakeNoodle()
  582. {
  583. WriteData("M0.3", true);
  584. }
  585. /// <summary>
  586. /// 机器人取餐
  587. /// </summary>
  588. private void RobotOutMeal()
  589. {
  590. WriteData("M0.4", true);
  591. }
  592. /// <summary>
  593. /// 制作完成信号复位
  594. /// </summary>
  595. private void ResetCookComplete()
  596. {
  597. WriteData("M100.6", false);
  598. }
  599. /// <summary>
  600. /// 复位允许取面信号
  601. /// </summary>
  602. private void ResetAllowFallNoodle()
  603. {
  604. WriteData("M100.3", false);
  605. }
  606. /// <summary>
  607. /// 设备初始化
  608. /// </summary>
  609. public async void DeviceInit()
  610. {
  611. WriteData("M0.0", true);
  612. await Task.Delay(1000);
  613. WriteData("M0.0", false);
  614. }
  615. #endregion
  616. }
  617. }