终端一体化运控平台
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.
 
 
 

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