终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

Control_MorkT_Container.cs 47 KiB

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