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

Control_MorkT_BarCounter.cs 46 KiB

vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Threading;
  6. using System.Collections.Concurrent;
  7. using System.Diagnostics;
  8. using System.Threading.Tasks;
  9. using BPASmartClient.Device;
  10. using BPA.Message.Enum;
  11. using BPA.Message;
  12. using BPASmartClient.Helper;
  13. using BPASmartClient.Model.咖啡机.Enum;
  14. using BPASmartClient.Model;
  15. using BPASmartClient.EventBus;
  16. using static BPASmartClient.EventBus.EventBus;
  17. using BPASmartClient.Message;
  18. using BPASmartClient.Model.乐白机器人;
  19. using BPASmartClient.Model.单片机;
  20. using BPASmartClient.Model.PLC;
  21. using BPASmartClient.DRCoffee;
  22. using BPASmartClient.LebaiRobot;
  23. namespace BPASmartClient.MorkT_BarCounter
  24. {
  25. /*
  26. * 冰淇淋咖啡机组合套装
  27. * 物料位置:
  28. * 1:冰淇料
  29. * 2:冰淇淋杯
  30. * 5:咖啡
  31. * 6:咖啡杯
  32. * 9: 茶
  33. * 10: 茶杯
  34. */
  35. public class Control_MorkT_BarCounter : BaseDevice
  36. {
  37. private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>();
  38. //容器位置
  39. private string holderLoc;
  40. //主料位置
  41. private string mainMaterialLoc;
  42. public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } }
  43. GVL_MorkT morkTLebaiJC =new GVL_MorkT();
  44. /// <summary>
  45. /// 果汁机做法,true:热饮,false:冷饮
  46. /// </summary>
  47. private bool GuMake = false;
  48. /// <summary>
  49. /// 订单是否加冰
  50. /// </summary>
  51. private bool IsAddIce = false;
  52. public override void DoMain()
  53. {
  54. if (Json<KeepDataBase>.Data.IsVerify)
  55. {
  56. IsHealth = true;
  57. }
  58. IsHealth = true;
  59. serverInit();
  60. DataParse();
  61. ActionManage.GetInstance.Register(new Action<object>((o) => { SimOrder(o); }), "SimOrder");//模拟订单委托注册
  62. }
  63. private void serverInit()
  64. {
  65. EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  66. {
  67. if (@event == null) return;
  68. if (@event is MaterialDeliveryEvent material)
  69. {
  70. orderMaterialDelivery = material.orderMaterialDelivery;
  71. }
  72. });
  73. }
  74. private void DataParse()
  75. {
  76. EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
  77. {
  78. if (@event == null) return;
  79. if (@event is DoOrderEvent order)
  80. {
  81. if (order.MorkOrder.GoodBatchings == null) return;
  82. OrderCount++;
  83. DeviceProcessLogShow($"接收到{OrderCount}次订单");
  84. batchings = PolymerBatching.BuildAll();
  85. //商品类型
  86. GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER;
  87. foreach (var item in order.MorkOrder.GoodBatchings)
  88. {
  89. var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
  90. if (res != null)
  91. {
  92. //验证商品是做的某种饮料
  93. if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER)
  94. {
  95. //获取当前物料所属商品类型
  96. currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc);
  97. }
  98. switch (batchings[res.BatchingLoc].BatchingClass)
  99. {
  100. case BATCHING_CLASS.HOLDER:
  101. holderLoc = res.BatchingLoc;
  102. break;
  103. case BATCHING_CLASS.MAIN_MATERIAL:
  104. mainMaterialLoc = res.BatchingLoc;
  105. break;
  106. }
  107. //根据商品类型执行具体制作流程
  108. switch (currentGoodsType)
  109. {
  110. case GOODS_TYPE.COFFEE:
  111. if (morkTLebaiJC.morkOrderPushesCoffee.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  112. {
  113. morkTLebaiJC.morkOrderPushesCoffee.Enqueue(new OrderLocInfo()
  114. {
  115. SuborderId = order.MorkOrder.SuborderId,
  116. BatchingId = res.BatchingId,
  117. Loc = ushort.Parse( mainMaterialLoc),
  118. GoodName = order.MorkOrder.GoodsName,
  119. });
  120. }
  121. break;
  122. case GOODS_TYPE.JUICE:
  123. if (morkTLebaiJC.morkOrderPushesJuicer.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  124. {
  125. morkTLebaiJC.morkOrderPushesJuicer.Enqueue(new OrderLocInfo()
  126. {
  127. SuborderId = order.MorkOrder.SuborderId,
  128. BatchingId = res.BatchingId,
  129. Loc = ushort.Parse(mainMaterialLoc),
  130. GoodName = order.MorkOrder.GoodsName,
  131. makeID = order.MorkOrder.MakeID,
  132. });
  133. }
  134. break;
  135. case GOODS_TYPE.TEA:
  136. if (morkTLebaiJC.morkOrderPushesTea.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  137. {
  138. morkTLebaiJC.morkOrderPushesTea.Enqueue(new OrderLocInfo()
  139. {
  140. SuborderId = order.MorkOrder.SuborderId,
  141. BatchingId = res.BatchingId,
  142. Loc = ushort.Parse(mainMaterialLoc),
  143. GoodName = order.MorkOrder.GoodsName,
  144. });
  145. }
  146. break;
  147. case GOODS_TYPE.WATER:
  148. if (morkTLebaiJC.morkOrderPushesWater.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  149. {
  150. morkTLebaiJC.morkOrderPushesWater.Enqueue(new OrderLocInfo()
  151. {
  152. SuborderId = order.MorkOrder.SuborderId,
  153. BatchingId = res.BatchingId,
  154. Loc = ushort.Parse(mainMaterialLoc),
  155. GoodName = order.MorkOrder.GoodsName,
  156. });
  157. }
  158. break;
  159. case GOODS_TYPE.NEITHER:
  160. DeviceProcessLogShow("未知的商品类型");
  161. break;
  162. }
  163. }
  164. }
  165. }
  166. });
  167. }
  168. /// <summary>
  169. /// 将空杯放好到接饮料的地方的标志位
  170. /// </summary>
  171. private bool bFirstTrig_TeaWater = false;
  172. private bool bFirstTrig_Coffee = false;
  173. private bool bFirstTrig_Juice = false;
  174. /// <summary>
  175. /// 延迟的超时时间
  176. /// </summary>
  177. DateTime delayTimeOut_Water;
  178. DateTime delayTimeOut_Coffee;
  179. DateTime delayTimeOut_Juice;
  180. public override void MainTask()
  181. {
  182. EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  183. {
  184. if (morkTLebaiJC.IsHaveCoffeeCup && morkTLebaiJC.MakeCoffeeEnd != true)
  185. morkTLebaiJC.MakeCoffeeEnd = true;
  186. });
  187. if (morkTLebaiJC.IsHaveCoffeeCup && morkTLebaiJC.MakeCoffeeEnd != true)
  188. {
  189. if (!bFirstTrig_Coffee)
  190. {
  191. bFirstTrig_Coffee = true;
  192. delayTimeOut_Coffee = DateTime.Now;
  193. }
  194. else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 18 && bFirstTrig_Coffee == true)
  195. {
  196. DeviceProcessLogShow("接咖啡超时,接咖啡结束,等待取咖啡");
  197. bFirstTrig_Coffee = false;
  198. if (morkTLebaiJC.IsHaveCoffeeCup)
  199. morkTLebaiJC.MakeCoffeeEnd = true;
  200. }
  201. }
  202. if (morkTLebaiJC.IsHaveJuiceCup && morkTLebaiJC.MakeJuiceEnd != true)
  203. {
  204. var Juicestate = GetStatus<int[]>("GetDeviceStatus");
  205. if (Juicestate != null)
  206. {
  207. if (Juicestate.Length > 0)
  208. {
  209. var Juicestate1 = Convert.ToString(Juicestate[0], 2);
  210. var Juicestate2 = Juicestate[1];
  211. if (Juicestate1.IndexOf("0") == 1 && Juicestate2 == 0)
  212. {
  213. morkTLebaiJC.MakeJuiceEnd = true;
  214. bFirstTrig_Juice = false;
  215. }
  216. }
  217. }
  218. if (!morkTLebaiJC.MakeJuiceEnd)
  219. {
  220. //若无状态返回 则加延迟
  221. if (!bFirstTrig_Juice)
  222. {
  223. bFirstTrig_Juice = true;
  224. delayTimeOut_Juice = DateTime.Now;
  225. }
  226. else if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 3 && bFirstTrig_Juice == true)
  227. {
  228. DeviceProcessLogShow("接果汁超时,接果汁结束,等待取果汁");
  229. bFirstTrig_Juice = false;
  230. morkTLebaiJC.MakeJuiceEnd = true;
  231. }
  232. }
  233. }
  234. if (morkTLebaiJC.IsHaveTeaWaterCup && morkTLebaiJC.MakeTeaEnd != true)
  235. {
  236. if (!bFirstTrig_TeaWater)
  237. {
  238. bFirstTrig_TeaWater = true;
  239. delayTimeOut_Water = DateTime.Now;//开启接水信号后,记录当前时间
  240. }
  241. else if (DateTime.Now.Subtract(delayTimeOut_Water).TotalSeconds >= 5 && bFirstTrig_TeaWater == true)//接水超过50s后,启动接水完成标志,开启接水程序
  242. {
  243. DeviceProcessLogShow("接茶或水延迟时间结束");
  244. bFirstTrig_TeaWater = false;
  245. morkTLebaiJC.MakeTeaEnd = true;
  246. }
  247. }
  248. DoCoffee();
  249. DoJuice();
  250. DoBoiledTea();
  251. DoBoiledWater();
  252. }
  253. /// <summary>
  254. /// 订单状态改变
  255. /// </summary>
  256. /// <param name="subid"></param>
  257. /// <param name="oRDER_STATUS"></param>
  258. private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
  259. {
  260. EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
  261. }
  262. /// <summary>
  263. /// 验证商品是做的某种饮料
  264. /// </summary>
  265. /// <param name="batchingLoc">物料位置</param>
  266. private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc)
  267. {
  268. if (batchings.ContainsKey(batchingLoc))
  269. return batchings[batchingLoc].GoodsType;
  270. return GOODS_TYPE.NEITHER;
  271. }
  272. /// <summary>
  273. /// 乐白的场景结束等待
  274. /// </summary>
  275. /// <param name="value"></param>
  276. private void Wait(int value = 101)
  277. {
  278. while (!((bool)peripheralStatus["RobotOK"] && (int)peripheralStatus["RobotValue"] == value))
  279. {
  280. Thread.Sleep(5);
  281. }
  282. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  283. }
  284. /// <summary>
  285. /// 乐白的场景
  286. /// </summary>
  287. /// <param name="sen"></param>
  288. private void Sence(int sen)
  289. {
  290. new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = sen }.Publish();
  291. }
  292. /// <summary>
  293. /// 乐白的数字量输出
  294. /// </summary>
  295. /// <param name="value"></param>
  296. /// <param name="pin"></param>
  297. private void Output(bool value,int pin)
  298. {
  299. new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Pin = pin,Value=value }.Publish();
  300. }
  301. private T GetStatus<T>(string key)
  302. {
  303. if (peripheralStatus.ContainsKey(key))
  304. {
  305. if (peripheralStatus[key] != null)
  306. {
  307. return (T)(peripheralStatus[key]);
  308. }
  309. }
  310. return default;
  311. }
  312. int[] devStatusBy = new int[2] { 0, 0 };
  313. bool outCupCheck = false;//放纸杯位置有无判断
  314. /// <summary>
  315. /// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确
  316. /// </summary>
  317. int bSensorInput;
  318. /// <summary>
  319. /// 判断是否有咖啡订单
  320. /// </summary>
  321. /// <returns></returns>
  322. private bool IsMakeCoffee()
  323. {
  324. bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesCoffee.Count > 0 && !morkTLebaiJC.IsHaveCoffeeCup) ? true : false;
  325. return bMake;
  326. }
  327. /// <summary>
  328. /// 判断是否有果汁订单
  329. /// </summary>
  330. /// <returns></returns>
  331. private bool IsMakeJuice()
  332. {
  333. bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesJuicer.Count > 0 && !morkTLebaiJC.IsHaveJuiceCup) ? true : false;
  334. return bMake;
  335. }
  336. /// <summary>
  337. /// 判断是否有茶订单
  338. /// </summary>
  339. /// <returns></returns>
  340. private bool IsMakeTeaWater()
  341. {
  342. bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesTea.Count > 0 && !morkTLebaiJC.IsHaveTeaWaterCup) ? true : false;
  343. return bMake;
  344. }
  345. /// <summary>
  346. /// 判断是否有开水订单
  347. /// </summary>
  348. /// <returns></returns>
  349. private bool IsMakeWater()
  350. {
  351. bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesWater.Count > 0 && !morkTLebaiJC.IsHaveTeaWaterCup) ? true : false;
  352. return bMake;
  353. }
  354. /// <summary>
  355. /// 做咖啡流程
  356. /// </summary>
  357. private void DoCoffee()
  358. {
  359. if (IsMakeCoffee())
  360. {
  361. PickUpCoffee();//接咖啡
  362. morkTLebaiJC.IsHaveCoffeeCup = true;
  363. }
  364. else if(morkTLebaiJC.MakeCoffeeEnd)
  365. {
  366. try
  367. {
  368. PutCoffeeCup();
  369. morkTLebaiJC.MakeCoffeeEnd = false;
  370. morkTLebaiJC.IsHaveCoffeeCup = false;
  371. morkTLebaiJC.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc);
  372. }
  373. catch (Exception ex)
  374. {
  375. MessageLog.GetInstance.ShowEx(ex.ToString());
  376. }
  377. }
  378. }
  379. private void DoJuice()
  380. {
  381. if (IsMakeJuice())
  382. {
  383. switch (morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).makeID)
  384. {
  385. case "1":
  386. GuMake = true;
  387. IsAddIce = false;
  388. break;
  389. case "2":
  390. GuMake = false;
  391. IsAddIce = false;
  392. break;
  393. case "3":
  394. GuMake = false;
  395. IsAddIce = true;
  396. break;
  397. default:
  398. break;
  399. }
  400. PickUpJuicer();
  401. morkTLebaiJC.IsHaveJuiceCup = true;
  402. }
  403. else if (morkTLebaiJC.MakeJuiceEnd)
  404. {
  405. try
  406. {
  407. Thread.Sleep(5000);//延迟五秒,防止饮料口滴饮料
  408. putJuice();
  409. morkTLebaiJC.IsHaveJuiceCup = false;
  410. morkTLebaiJC.MakeJuiceEnd = false;
  411. morkTLebaiJC.morkOrderPushesJuicer.TryDequeue(out OrderLocInfo orderLoc);
  412. }
  413. catch (Exception ex)
  414. {
  415. MessageLog.GetInstance.ShowEx(ex.ToString());
  416. }
  417. }
  418. }
  419. public bool DoTeaOrWater;
  420. private void DoBoiledTea()
  421. {
  422. if (IsMakeTeaWater())
  423. {
  424. PickUpTea();
  425. morkTLebaiJC.IsHaveTeaWaterCup = true;
  426. DoTeaOrWater = true;
  427. }
  428. else if (morkTLebaiJC.MakeTeaEnd && morkTLebaiJC.morkOrderPushesTea.Count > 0 && DoTeaOrWater)
  429. {
  430. try
  431. {
  432. PutWaterCup();
  433. OrderChange(morkTLebaiJC.morkOrderPushesTea.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
  434. DeviceProcessLogShow("-------------茶 制作完成------------");
  435. morkTLebaiJC.IsHaveTeaWaterCup = false;
  436. morkTLebaiJC.MakeTeaEnd = false;
  437. morkTLebaiJC.morkOrderPushesTea.TryDequeue(out OrderLocInfo orderLoc);
  438. }
  439. catch (Exception ex)
  440. {
  441. MessageLog.GetInstance.ShowEx(ex.ToString());
  442. }
  443. }
  444. }
  445. private void DoBoiledWater()
  446. {
  447. if (IsMakeWater())
  448. {
  449. PickUpWater();
  450. morkTLebaiJC.IsHaveTeaWaterCup = true;
  451. DoTeaOrWater = false;
  452. }
  453. else if (morkTLebaiJC.MakeTeaEnd && morkTLebaiJC.morkOrderPushesWater.Count > 0 && DoTeaOrWater == false)
  454. {
  455. try
  456. {
  457. PutWaterCup();
  458. OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
  459. DeviceProcessLogShow("-------------开水 制作完成------------");
  460. morkTLebaiJC.IsHaveTeaWaterCup = false;
  461. morkTLebaiJC.MakeTeaEnd = false;
  462. morkTLebaiJC.morkOrderPushesWater.TryDequeue(out OrderLocInfo orderLoc);
  463. }
  464. catch (Exception ex)
  465. {
  466. MessageLog.GetInstance.ShowEx(ex.ToString());
  467. }
  468. }
  469. }
  470. #region 做咖啡流程
  471. /// <summary>
  472. /// 接咖啡
  473. /// </summary>
  474. private void PickUpCoffee()
  475. {
  476. if (!morkTLebaiJC.IsHaveCoffeeCup)
  477. {
  478. outCupCheck = false;
  479. OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
  480. int resultTakeCup = takeCup();
  481. if (resultTakeCup == 1)
  482. {
  483. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  484. Sence(GVL_MorkT.机器人安全位);
  485. //Wait();
  486. WritePLCData("",2);//将轴移动到接咖啡的位置
  487. DeviceProcessLogShow("伺服电机移动到接咖啡的位置");
  488. DeviceProcessLogShow("咖啡杯取杯完成");
  489. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  490. Sence(GVL_MorkT.接咖啡);
  491. //Wait();
  492. new DRCoffee_MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).Loc)}.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
  493. }
  494. else
  495. {
  496. /*DeviceProcessLogShow("取杯失败 回到初始位,请及时处理!!");
  497. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  498. Sence(GVL_MorkT.机器人初始位);
  499. //Wait();*/
  500. }
  501. }
  502. }
  503. /// <summary>
  504. /// 咖啡杯接好,放咖啡杯
  505. /// </summary>
  506. private void PutCoffeeCup()
  507. {
  508. while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品
  509. {
  510. if (!outCupCheck)
  511. DeviceProcessLogShow("成品处有纸杯存在,请取走!!");
  512. outCupCheck = true;
  513. }
  514. outCupCheck = false;
  515. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  516. Sence(GVL_MorkT.机器人安全位);
  517. //Wait();
  518. WritePLCData("", 2);//将轴移动到接咖啡的位置
  519. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  520. Sence(GVL_MorkT.放咖啡杯);
  521. //Wait();
  522. OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
  523. DeviceProcessLogShow($"-------------{morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).GoodName}制作完成------------");
  524. }
  525. #endregion
  526. #region 做开水流程
  527. /// <summary>
  528. /// 接开水
  529. /// </summary>
  530. private void PickUpWater()
  531. {
  532. #region 接水流程
  533. if (!morkTLebaiJC.IsHaveTeaWaterCup)
  534. {
  535. OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
  536. int resultTakeCup = takeCup();
  537. if (resultTakeCup == 1)
  538. {
  539. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  540. Sence(GVL_MorkT.接开水);
  541. //Wait();
  542. Output(false, 1);
  543. Output(false, 0);
  544. Thread.Sleep(100);
  545. Output(true, 0);
  546. Thread.Sleep(3000);
  547. Output(false, 0);
  548. Thread.Sleep(100);
  549. Output(false, 1);
  550. Thread.Sleep(100);
  551. Output(true, 1);
  552. Thread.Sleep(500);
  553. Output(false, 1);
  554. }
  555. else
  556. {
  557. return;
  558. }
  559. }
  560. #endregion
  561. }
  562. #endregion
  563. #region 做茶流程
  564. /// <summary>
  565. /// 做茶
  566. /// </summary>
  567. private void PickUpTea()
  568. {
  569. #region 接茶流程
  570. if (!morkTLebaiJC.IsHaveTeaWaterCup)
  571. {
  572. OrderChange(morkTLebaiJC.morkOrderPushesTea.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
  573. int resultTakeCup = takeCup();
  574. if (resultTakeCup == 1)
  575. {
  576. DeviceProcessLogShow("取茶杯完成");
  577. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  578. Sence(GVL_MorkT.接茶叶);
  579. //Wait();
  580. new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 90 }.Publish();
  581. Thread.Sleep(1000);
  582. new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 150 }.Publish();
  583. Thread.Sleep(1000);
  584. new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 90 }.Publish();
  585. Thread.Sleep(3000);
  586. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  587. Sence(GVL_MorkT.接茶水);
  588. //Wait();
  589. Output(false, 1);
  590. Output(false, 0);
  591. Thread.Sleep(100);
  592. Output(true, 0);
  593. Thread.Sleep(3000);
  594. Output(false, 0);
  595. Thread.Sleep(100);
  596. Output(false, 1);
  597. Thread.Sleep(100);
  598. Output(true, 1);
  599. Thread.Sleep(500);
  600. Output(false, 1);
  601. morkTLebaiJC.IsHaveTeaWaterCup = true;
  602. }
  603. else
  604. {
  605. return;
  606. }
  607. }
  608. #endregion
  609. }
  610. /// <summary>
  611. /// 放水杯流程
  612. /// </summary>
  613. private void PutWaterCup()
  614. {
  615. while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品
  616. {
  617. if (!outCupCheck)
  618. DeviceProcessLogShow("成品处有纸杯存在,请取走!!");
  619. outCupCheck = true;
  620. }
  621. outCupCheck = false;
  622. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  623. Sence(GVL_MorkT.放水杯);
  624. }
  625. #endregion
  626. #region 做果汁流程
  627. /// <summary>
  628. /// 果汁机控制信号
  629. /// </summary>
  630. private byte JuicerNum;
  631. private void getIce()
  632. {
  633. IsAddIceNow = IsAddIce;
  634. if (IsAddIce)
  635. {
  636. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  637. Sence(GVL_MorkT.取杯位_机器人安全位);
  638. //Wait();
  639. WritePLCData("",3);//将模组移动到接冰的位置
  640. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  641. Sence(GVL_MorkT.接冰块);
  642. //Wait();
  643. if (Math.Pow(1, GetStatus<byte>("GetMakeIceDeviceStatus")) == 0)//制冰机在待机状态才可以制作冰
  644. {
  645. new StartMakeIce() { }.Publish();
  646. }
  647. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  648. Sence(GVL_MorkT.接冰_机器人安全位);
  649. //Wait();
  650. }
  651. }
  652. /// <summary>
  653. /// 当前订单是否加冰
  654. /// </summary>
  655. private bool IsAddIceNow = false;
  656. private int JuiceCH;
  657. /// <summary>
  658. /// 接果汁
  659. /// </summary>
  660. private void PickUpJuicer()
  661. {
  662. #region 接果汁流程
  663. if (!morkTLebaiJC.IsHaveJuiceCup)
  664. {
  665. OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
  666. int resultTakeCup = takeCup();
  667. JuiceCH = morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).Loc;
  668. if (resultTakeCup == 1)
  669. {
  670. getIce();
  671. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  672. Sence(GVL_MorkT.机器人安全位);
  673. //Wait();
  674. WritePLCData("", 3);//将模组移动到接冰的位置
  675. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  676. Sence(GVL_MorkT.接果汁过渡位);
  677. //Wait();
  678. switch (JuiceCH)
  679. {
  680. case 52:
  681. if (GuMake)
  682. JuicerNum = 0x00;
  683. else
  684. JuicerNum = 0x01;
  685. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  686. Sence(GVL_MorkT.接果汁1);
  687. //Wait();
  688. break;
  689. case 53:
  690. if (GuMake)
  691. JuicerNum = 0x02;
  692. else
  693. JuicerNum = 0x03;
  694. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  695. Sence(GVL_MorkT.接果汁2);
  696. //Wait();
  697. break;
  698. case 54:
  699. if (GuMake)
  700. JuicerNum = 0x04;
  701. else
  702. JuicerNum = 0x05;
  703. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  704. Sence(GVL_MorkT.接果汁3);
  705. //Wait();
  706. break;
  707. case 55:
  708. if (GuMake)
  709. JuicerNum = 0x06;
  710. else
  711. JuicerNum = 0x07;
  712. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  713. Sence(GVL_MorkT.接果汁4);
  714. //Wait();
  715. break;
  716. default:
  717. JuicerNum = 0x00;
  718. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  719. Sence(GVL_MorkT.接果汁1);
  720. //Wait();
  721. break;
  722. }
  723. new WriteJuicer() { Value = JuicerNum }.Publish();
  724. morkTLebaiJC.IsHaveJuiceCup = true;
  725. }
  726. else
  727. {
  728. return;
  729. }
  730. }
  731. #endregion
  732. }
  733. /// <summary>
  734. /// 取接好果汁杯
  735. /// </summary>
  736. private void putJuice()
  737. {
  738. while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品
  739. {
  740. if (!outCupCheck)
  741. DeviceProcessLogShow("成品处有纸杯存在,请取走!!");
  742. outCupCheck = true;
  743. }
  744. outCupCheck = false;
  745. switch (JuiceCH)
  746. {
  747. case 52:
  748. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  749. Sence(GVL_MorkT.放果汁杯1);
  750. //Wait();
  751. break;
  752. case 53:
  753. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  754. Sence(GVL_MorkT.放果汁杯2);
  755. //Wait();
  756. break;
  757. case 54:
  758. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  759. Sence(GVL_MorkT.放果汁杯3);
  760. //Wait();
  761. break;
  762. case 55:
  763. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  764. Sence(GVL_MorkT.放果汁杯4);
  765. //Wait();
  766. break;
  767. default:
  768. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  769. Sence(GVL_MorkT.放果汁杯1);
  770. //Wait();
  771. break;
  772. }
  773. OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
  774. DeviceProcessLogShow($"-------------{morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).GoodName}果汁 制作完成------------");
  775. }
  776. #endregion
  777. /// <summary>
  778. /// 取杯的次数
  779. /// </summary>
  780. private int nCnt;
  781. /// <summary>
  782. /// 取杯流程
  783. /// </summary>
  784. /// <returns>0:无意义,1:取杯成功 2:取杯失败</returns>
  785. private int takeCup()
  786. {
  787. try
  788. {
  789. nCnt = 0;
  790. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  791. Sence(GVL_MorkT.机器人初始位);
  792. //Wait();
  793. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  794. Sence(GVL_MorkT.机器人安全位);
  795. //Wait();
  796. WritePLCData("", 1);
  797. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  798. Sence(GVL_MorkT.取纸杯);
  799. //Wait();
  800. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  801. Sence(GVL_MorkT.取纸杯检测);
  802. //Wait();
  803. nCnt++;
  804. Thread.Sleep(2000);
  805. while (!GetStatus<bool>("GetInput")) //读取传感器的值
  806. {
  807. if (nCnt > 3)
  808. {
  809. nCnt = 0;
  810. DeviceProcessLogShow("三次取杯失败,回原点");
  811. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  812. Sence(GVL_MorkT.机器人安全位);
  813. //Wait();
  814. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  815. Sence(GVL_MorkT.机器人初始位);
  816. //Wait();
  817. return 2;
  818. }
  819. else
  820. {
  821. nCnt++;
  822. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  823. Sence(GVL_MorkT.二次取杯);
  824. //Wait();
  825. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  826. Sence(GVL_MorkT.取纸杯检测);
  827. //Wait();
  828. }
  829. Thread.Sleep(1000);
  830. }
  831. new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
  832. Sence(GVL_MorkT.取杯位_机器人安全位);
  833. //Wait();
  834. return 1;
  835. }
  836. catch (Exception ex)
  837. {
  838. DeviceProcessLogShow(ex.ToString());
  839. }
  840. return 2;
  841. }
  842. /// <summary>
  843. /// 放杯
  844. /// </summary>
  845. /// <returns>0:无意义 1:放杯成功 2:执行失败(传感器还有信号) 3:放杯异常</returns>
  846. private int putCup()
  847. {
  848. try
  849. {
  850. if (GetStatus<bool>("GetInput2")) return 2;
  851. Sence(GVL_MorkT.JUICE_放杯);
  852. //Wait();
  853. new LebaiRobot_SetValueEvent() { RobotSetValue = 1 }.Publish();
  854. Sence(GVL_MorkT.JUICE_放杯检测);
  855. //Wait();
  856. new LebaiRobot_SetValueEvent() { RobotSetValue = 1 }.Publish();
  857. if (GetStatus<bool>("GetInput2"))
  858. {
  859. return 1;
  860. }
  861. else
  862. {
  863. return 3;
  864. }
  865. }
  866. catch (Exception ex)
  867. {
  868. DeviceProcessLogShow(ex.ToString());
  869. return 0;
  870. }
  871. }
  872. public void SimOrder<T>(T simOrder)
  873. {
  874. }
  875. #region PLC 控制函数
  876. private void WritePLCData(string address, object value)
  877. {
  878. EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
  879. }
  880. private void GetStatus(string key, Action<object> action)
  881. {
  882. if (peripheralStatus.ContainsKey(key))
  883. {
  884. if (peripheralStatus[key] != null)
  885. {
  886. action?.Invoke(peripheralStatus[key]);
  887. }
  888. }
  889. }
  890. public override void ReadData()
  891. {
  892. #region 乐白机器人状态
  893. GetStatus("RobotIsConnected", new Action<object>((o) =>
  894. {
  895. if (o is bool b)
  896. {
  897. morkTLebaiJC.RobotIsConnected = b;
  898. }
  899. }));
  900. GetStatus("RobotMode", new Action<object>((o) =>
  901. {
  902. if (o is ELebaiRModel eLebaiRModel)
  903. {
  904. morkTLebaiJC.RobotMode = eLebaiRModel;
  905. }
  906. }));
  907. GetStatus("LeibaiGetTcpInput", new Action<object>((o) =>
  908. {
  909. if (o is bool b)
  910. {
  911. morkTLebaiJC.RobotGetTcpInput = b;
  912. }
  913. }));
  914. GetStatus("LeibaiGetInput1", new Action<object>((o) =>
  915. {
  916. if (o is bool b)
  917. {
  918. morkTLebaiJC.RobotGetInput0 = b;
  919. }
  920. }));
  921. GetStatus("LeibaiGetInput2", new Action<object>((o) =>
  922. {
  923. if (o is bool b)
  924. {
  925. morkTLebaiJC.RobotGetInput1 = b;
  926. }
  927. }));
  928. GetStatus("LeibaiGetInput3", new Action<object>((o) =>
  929. {
  930. if (o is bool b)
  931. {
  932. morkTLebaiJC.RobotGetInput2 = b;
  933. }
  934. }));
  935. GetStatus("LeibaiGetInput4", new Action<object>((o) =>
  936. {
  937. if (o is bool b)
  938. {
  939. morkTLebaiJC.RobotGetInput3 = b;
  940. }
  941. }));
  942. #endregion
  943. #region 制冰机状态
  944. GetStatus("MakeIceConnected", new Action<object>((o) =>
  945. {
  946. if (o is bool bt)
  947. {
  948. morkTLebaiJC.IceMakerConnect = bt;
  949. }
  950. }));
  951. GetStatus("MakeIceDeviceStatus", new Action<object>((o) =>
  952. {
  953. if (o is byte bt)
  954. {
  955. morkTLebaiJC.IceMakerState = bt;
  956. }
  957. }));
  958. #endregion
  959. #region 咖啡机状态
  960. GetStatus("CoffeeIsConnected", new Action<object>((o) =>
  961. {
  962. if (o is bool b)
  963. {
  964. morkTLebaiJC.CoffeeIsConnected = b;
  965. }
  966. }));
  967. GetStatus("CoffeeStatus", new Action<object>((o) =>
  968. {
  969. if (o is DrCoffeeStatus coffeeStatus)
  970. {
  971. morkTLebaiJC.DrCoffeeStatus = coffeeStatus;
  972. }
  973. }));
  974. GetStatus("CoffeeAppStatus", new Action<object>((o) =>
  975. {
  976. if (o is DrCoffeeAppStatus appStatus)
  977. {
  978. morkTLebaiJC.CoffeeAppStatus = appStatus;
  979. }
  980. }));
  981. GetStatus("CoffeeWarning", new Action<object>((o) =>
  982. {
  983. if (o is DrCoffeeWarning coffeeWarning)
  984. {
  985. morkTLebaiJC.CoffeeWarning = coffeeWarning;
  986. }
  987. }));
  988. GetStatus("CoffeeFault", new Action<object>((o) =>
  989. {
  990. if (o is DrCoffeeFault coffeeFault)
  991. {
  992. morkTLebaiJC.CaffeeFault = coffeeFault;
  993. }
  994. }));
  995. #endregion
  996. #region 单片机状态
  997. EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput0" });
  998. EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput1" });
  999. EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput2" });
  1000. EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput3" });
  1001. EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput4" });
  1002. EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput5" });
  1003. EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput6" });
  1004. EventBus.EventBus.GetInstance().Publish(new ReadMcu() { DeviceId = DeviceId, ReadPar = 0, TagName = "SCChipGetInput7" });
  1005. GetStatus("SCChipIsConnect", new Action<object>((o) =>
  1006. {
  1007. if (o is bool b)
  1008. {
  1009. morkTLebaiJC.SCChipIsConnect = b;
  1010. }
  1011. }));
  1012. GetStatus("SCChipGetInput0", new Action<object>((o) =>
  1013. {
  1014. if (o is bool b)
  1015. {
  1016. morkTLebaiJC.SCChipInput0 = b;
  1017. }
  1018. }));
  1019. GetStatus("SCChipGetInput1", new Action<object>((o) =>
  1020. {
  1021. if (o is bool b)
  1022. {
  1023. morkTLebaiJC.SCChipInput1 = b;
  1024. }
  1025. }));
  1026. GetStatus("SCChipGetInput2", new Action<object>((o) =>
  1027. {
  1028. if (o is bool b)
  1029. {
  1030. morkTLebaiJC.SCChipInput2 = b;
  1031. }
  1032. }));
  1033. GetStatus("SCChipGetInput3", new Action<object>((o) =>
  1034. {
  1035. if (o is bool b)
  1036. {
  1037. morkTLebaiJC.SCChipInput3 = b;
  1038. }
  1039. }));
  1040. GetStatus("SCChipGetInput4", new Action<object>((o) =>
  1041. {
  1042. if (o is bool b)
  1043. {
  1044. morkTLebaiJC.SCChipInput4 = b;
  1045. }
  1046. }));
  1047. GetStatus("SCChipGetInput5", new Action<object>((o) =>
  1048. {
  1049. if (o is bool b)
  1050. {
  1051. morkTLebaiJC.SCChipInput5 = b;
  1052. }
  1053. }));
  1054. GetStatus("SCChipGetInput6", new Action<object>((o) =>
  1055. {
  1056. if (o is bool b)
  1057. {
  1058. morkTLebaiJC.SCChipInput6 = b;
  1059. }
  1060. }));
  1061. GetStatus("SCChipGetInput7", new Action<object>((o) =>
  1062. {
  1063. if (o is bool b)
  1064. {
  1065. morkTLebaiJC.SCChipInput7 = b;
  1066. }
  1067. }));
  1068. #endregion
  1069. #region 果汁机
  1070. GetStatus("GetJuicerConnected", new Action<object>((o) =>
  1071. {
  1072. if (o is bool b)
  1073. {
  1074. morkTLebaiJC.JuicerConnected = b;
  1075. }
  1076. }));
  1077. GetStatus("GetJuicerDeviceStatus", new Action<object>((o) =>
  1078. {
  1079. if (o is int[] b)
  1080. {
  1081. morkTLebaiJC.JuicerState = b;
  1082. }
  1083. }));
  1084. #endregion
  1085. }
  1086. #endregion
  1087. public override void Stop()
  1088. {
  1089. }
  1090. public override void ResetProgram()
  1091. {
  1092. }
  1093. public override void SimOrder()
  1094. {
  1095. EventBus.EventBus.GetInstance().Subscribe<MorkTSimOrder>(0, delegate (IEvent @event, EventCallBackHandle callBackHandle)
  1096. {
  1097. string guid = Guid.NewGuid().ToString();
  1098. if (@event != null && @event is MorkTSimOrder msm)
  1099. {
  1100. DeviceProcessLogShow("----开始模拟订单----");
  1101. if (msm.OrderNum == 1)
  1102. {
  1103. morkTLebaiJC.morkOrderPushesCoffee.Enqueue(new OrderLocInfo() { Loc =(ushort)msm.DrinkCode, SuborderId = guid, GoodName="模拟咖啡订单" });
  1104. }
  1105. else if (msm.OrderNum == 2)
  1106. {
  1107. morkTLebaiJC.morkOrderPushesJuicer.Enqueue(new OrderLocInfo() { Loc = (ushort) (msm.JuiceList + 51), makeID = msm.JuiceMakeID, SuborderId = guid, GoodName = "模拟果汁订单" });
  1108. }
  1109. else if (msm.OrderNum == 3)
  1110. {
  1111. morkTLebaiJC.morkOrderPushesTea.Enqueue(new OrderLocInfo() { SuborderId = guid, GoodName = "模拟茶水订单" });
  1112. }
  1113. else if (msm.OrderNum == 4)
  1114. {
  1115. morkTLebaiJC.morkOrderPushesWater.Enqueue(new OrderLocInfo() { SuborderId = guid, GoodName = "模拟开水订单" });
  1116. }
  1117. }
  1118. });
  1119. }
  1120. }
  1121. }