终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Control_MORKIC.cs 24 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. using BPA.Message;
  2. using BPA.Message.Enum;
  3. using BPA.Message.IOT;
  4. using BPASmartClient.Device;
  5. using BPASmartClient.DRCoffee;
  6. using BPASmartClient.EventBus;
  7. using BPASmartClient.GSIceCream;
  8. using BPASmartClient.Helper;
  9. using BPASmartClient.Lebai;
  10. using BPASmartClient.Message;
  11. using BPASmartClient.Model;
  12. using BPASmartClient.Model.冰淇淋.Enum;
  13. using BPASmartClient.Model.单片机;
  14. using BPASmartClient.Model.单片机.Enum;
  15. using BPASmartClient.Model.咖啡机.Enum;
  16. using BPASmartClient.SCChip;
  17. using Robotc;
  18. using System;
  19. using System.Collections.Concurrent;
  20. using System.Collections.Generic;
  21. using System.Linq;
  22. using System.Threading;
  23. using static BPASmartClient.EventBus.EventBus;
  24. namespace BPASmartClient.MORKIC
  25. {
  26. /*
  27. * 冰淇淋咖啡机组合套装
  28. * 物料位置:
  29. * 1:冰淇料
  30. * 2:冰淇淋杯
  31. * 5:咖啡
  32. * 6:咖啡杯
  33. */
  34. public class Control_MORKIC : BaseDevice
  35. {
  36. //咖啡机主控程序
  37. private CoffeeMachine coffeeMachine;
  38. //单片机主控程序
  39. private ICChipMachine icchipMachine;
  40. //广绅单口冰淇淋机
  41. private IceCreamMachine iceCreamMachine;
  42. //物料存放位置
  43. private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>();
  44. /// <summary>
  45. /// 获取乐百机器人的数据
  46. /// </summary>
  47. SignalResult lebai = new SignalResult();
  48. /// <summary>
  49. /// 咖啡位置是否有东西
  50. /// </summary>
  51. private bool IsCoffeeMake = false;
  52. private bool enableFunny = false;
  53. private DateTime lastRecvdOrder = DateTime.Now;
  54. private bool working = false;
  55. private bool IceIsOK = true;
  56. public void ConnectOk()
  57. {
  58. }
  59. /// <summary>
  60. /// 当前正在制作咖啡
  61. /// </summary>
  62. SimOrderData MakeCoffeeOrder = new SimOrderData();
  63. /// <summary>
  64. /// 咖啡订单队列
  65. /// </summary>
  66. ConcurrentQueue<SimOrderData> morkOrderPushesCoffee = new ConcurrentQueue<SimOrderData>();
  67. /// <summary>
  68. /// 冰淇淋订单队列
  69. /// </summary>
  70. ConcurrentQueue<SimOrderData> morkOrderPushesIceCream = new ConcurrentQueue<SimOrderData>();
  71. /// <summary>
  72. /// 等待取餐的订单,只有一个
  73. /// </summary>
  74. ConcurrentQueue<SimOrderData> WaitTakeMealOrder = new ConcurrentQueue<SimOrderData>();
  75. public void Init()
  76. {
  77. ActionManage.GetInstance.Register(new Action<object>((s) =>
  78. {
  79. if (s is DrCoffeeDrinksCode cf)
  80. {
  81. DoCoffee(new SimOrderData { Loc = ((int)cf).ToString() });
  82. }
  83. else if (s is Dictionary<string, string> ms)
  84. {
  85. if (ms.ContainsKey("Button"))
  86. {
  87. switch (ms["Button"])
  88. {
  89. case "启动示教":
  90. LebaiRobot.GetInstance.StartTeachMode();
  91. break;
  92. case "停止示教":
  93. LebaiRobot.GetInstance.EndtTeachMode();
  94. break;
  95. case "启动机器人":
  96. LebaiRobot.GetInstance.StartRobot();
  97. break;
  98. case "急停":
  99. LebaiRobot.GetInstance.EStopRobot();
  100. break;
  101. default:
  102. break;
  103. }
  104. }
  105. }
  106. }), "SimCoffee");
  107. //构建所有商品物料信息
  108. batchings = PolymerBatching.BuildAll();
  109. EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  110. {
  111. if (MakeCoffeeOrder != null)
  112. MakeCoffeeOrder.OrderStatus = 1;
  113. });
  114. System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
  115. //一系列外围基础配置
  116. var com_Coffee = config.AppSettings.Settings["COM_Coffee"].Value;
  117. var baud_Coffee = config.AppSettings.Settings["BAUD_Coffee"].Value;
  118. var com_IceCream = config.AppSettings.Settings["COM_IceCream"].Value;
  119. var baud_IceCream = config.AppSettings.Settings["BAUD_IceCream"].Value;
  120. var iceCreamCXBThreshold = int.Parse(config.AppSettings.Settings["IceCream_CXB_Threshold"].Value);
  121. var com_ICChip = config.AppSettings.Settings["COM_ICChip"].Value;
  122. var baud_ICChip = config.AppSettings.Settings["BAUD_IChip"].Value;
  123. if (iceCreamCXBThreshold > 0)
  124. {
  125. //设置冰淇淋成型比
  126. MorkIStatus.GetInstance().CXB_Threshold = (byte)iceCreamCXBThreshold;
  127. }
  128. //咖啡机创建
  129. coffeeMachine = new CoffeeMachine();
  130. //单片机机创建
  131. icchipMachine = new ICChipMachine();
  132. //冰淇淋机创建
  133. iceCreamMachine = new IceCreamMachine();
  134. Main();
  135. ReadRobotData();
  136. OrderMake();
  137. }
  138. private int NoOrderTime = 0;
  139. public override DeviceClientType DeviceType => DeviceClientType.MORKT;
  140. //订单制作
  141. public void OrderMake()
  142. {
  143. ThreadManage.GetInstance().StartLong(new Action(() =>
  144. {
  145. while (IsHealth && (morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count > 0 || IsCoffeeMake))
  146. {
  147. working = true; NoOrderTime = 0;
  148. //1.有咖啡订单 取杯去制作
  149. if (!IsCoffeeMake)//位置无杯子
  150. {
  151. if (morkOrderPushesCoffee.Count > 0 && morkOrderPushesCoffee.TryDequeue(out SimOrderData simOrder))
  152. {
  153. IsCoffeeMake = true; MakeCoffeeOrder = simOrder;
  154. MessageLog.GetInstance.Show($"开始制作 [咖啡] 订单[{simOrder.morkOrder.SortNum}]");
  155. DoCoffee(simOrder);
  156. }
  157. }
  158. if (!LebaiRobot.GetInstance.GetInput())//取餐口是否有餐饮
  159. {
  160. //取餐位的订单完成
  161. if (WaitTakeMealOrder.TryDequeue(out SimOrderData waitOrder)) OrderChange(waitOrder.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
  162. //1.制作冰淇淋
  163. if (morkOrderPushesIceCream.Count > 0 && MorkIStatus.GetInstance().CurrentMode != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
  164. if (MorkIStatus.GetInstance().CXB >= 86 && morkOrderPushesIceCream.Count > 0)//成型比大于80 我才会制作
  165. {
  166. if (LebaiRobot.GetInstance.GetInput(3))
  167. {
  168. if (IceIsOK) MessageLog.GetInstance.Show("请擦拭冰淇淋机出口");
  169. IceIsOK = false;
  170. }
  171. else if (morkOrderPushesIceCream.TryDequeue(out SimOrderData order))
  172. {
  173. IceIsOK = true;
  174. MessageLog.GetInstance.Show($"开始制作 [冰淇淋] 订单[{order.morkOrder.SortNum}]");
  175. DoIceCream(order);
  176. }
  177. }
  178. //2.取咖啡到取餐口
  179. if (IsCoffeeMake)
  180. {
  181. if (MakeCoffeeOrder != null && MakeCoffeeOrder.OrderStatus == 1)
  182. {
  183. MessageLog.GetInstance.Show($"将咖啡移动到取餐位 [咖啡] 订单[{MakeCoffeeOrder.morkOrder.SortNum}]");
  184. DoCoffeeQC(MakeCoffeeOrder);
  185. MakeCoffeeOrder = null;
  186. IsCoffeeMake = false;
  187. }
  188. }
  189. }
  190. working = false;
  191. lastRecvdOrder = DateTime.Now;
  192. }
  193. if (IsHealth == false && (morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count > 0 || IsCoffeeMake))
  194. {
  195. MessageLog.GetInstance.Show($"机器连接问题 订单,不允许制作,请检查设备连接后尝试," +
  196. $"乐白:{LebaiRobot.GetInstance.IsConnected}咖啡机:{MorkIStatus.GetInstance().CanDo}单片机:{ChipStatus.GetInstance().CanDo}");
  197. if (LebaiRobot.GetInstance.IsConnected && IsCoffeeMake && !LebaiRobot.GetInstance.GetInput())//乐白有订单
  198. {
  199. MessageLog.GetInstance.Show($"将咖啡移动到取餐位 [咖啡] 订单[{MakeCoffeeOrder.morkOrder.SortNum}]");
  200. DoCoffeeQC(MakeCoffeeOrder);
  201. MakeCoffeeOrder = null;
  202. IsCoffeeMake = false;
  203. }
  204. }
  205. if (!LebaiRobot.GetInstance.GetInput())
  206. {
  207. if (WaitTakeMealOrder.TryDequeue(out SimOrderData waitOrder)) OrderChange(waitOrder.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
  208. }
  209. Thread.Sleep(1000);
  210. }), "订单制作");
  211. }
  212. private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
  213. {
  214. EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
  215. }
  216. public void Main()
  217. {
  218. //咖啡机开启主线程
  219. coffeeMachine.Start();
  220. //单片机开启主线程
  221. icchipMachine.Start();
  222. //冰淇淋机开启主线程
  223. iceCreamMachine.Start();
  224. new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
  225. //开始心跳刷新,根据咖啡机及冰淇淋机来判断
  226. //ThreadManage.GetInstance().StartLong(new Action(() =>
  227. //{
  228. // GeneralConfig.Healthy =
  229. // LebaiRobot.GetInstance.IsConnected &&
  230. // MorkCStatus.GetInstance().CanDo &&
  231. // ChipStatus.GetInstance().CanDo;
  232. // //GeneralConfig.Healthy = true;
  233. // Thread.Sleep(100);
  234. //}), "MORK-IC心跳刷新");
  235. ThreadManage.GetInstance().Start(new Action(() =>
  236. {
  237. while (!LebaiRobot.GetInstance.IsConnected)
  238. {
  239. Thread.Sleep(10);
  240. }
  241. //LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_欢迎);
  242. }), "MORK-IC欢迎");
  243. }
  244. public void DataParse<T>(T order)
  245. {
  246. if (order is MorkOrderPush morkOrderPush)
  247. {
  248. //商品类型
  249. GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER;
  250. string loc_coffe = string.Empty;
  251. string loc_cup = string.Empty;
  252. #region 订单分类
  253. //遍历物料
  254. foreach (var item in morkOrderPush.GoodBatchings)
  255. {
  256. var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId);
  257. if (res != null)
  258. {
  259. //验证商品是咖啡还是冰淇淋
  260. if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER)
  261. {
  262. //获取当前物料所属商品类型
  263. currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc);
  264. }
  265. //获取主料和容器位置
  266. switch (batchings[res.BatchingLoc].BatchingClass)
  267. {
  268. case BATCHING_CLASS.HOLDER:
  269. loc_cup = res.BatchingLoc;
  270. break;
  271. case BATCHING_CLASS.MAIN_MATERIAL:
  272. loc_coffe = res.BatchingLoc;
  273. break;
  274. }
  275. }
  276. }
  277. //根据商品类型执行具体制作流程
  278. switch (currentGoodsType)
  279. {
  280. case GOODS_TYPE.COFFEE:
  281. morkOrderPushesCoffee.Enqueue(new SimOrderData { Loc = loc_coffe, morkOrder = morkOrderPush });
  282. break;
  283. case GOODS_TYPE.ICECREAM:
  284. morkOrderPushesIceCream.Enqueue(new SimOrderData { Loc = loc_coffe, morkOrder = morkOrderPush });
  285. break;
  286. case GOODS_TYPE.NEITHER:
  287. MessageLog.GetInstance.Show("未知的商品类型");
  288. break;
  289. }
  290. #endregion
  291. }
  292. }
  293. /// <summary>
  294. /// 验证当前是做咖啡还是做冰淇淋
  295. /// </summary>
  296. /// <param name="batchingLoc">物料位置</param>
  297. private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc)
  298. {
  299. if (batchings.ContainsKey(batchingLoc))
  300. return batchings[batchingLoc].GoodsType;
  301. return GOODS_TYPE.NEITHER;
  302. }
  303. private void Wait(int value = 101)
  304. {
  305. while (!(lebai.Ok && lebai.Value == value))
  306. {
  307. Thread.Sleep(5);
  308. }
  309. }
  310. /// <summary>
  311. /// 做咖啡-接杯子 并且 回到 安全位置
  312. /// </summary>
  313. private void DoCoffee(SimOrderData order)
  314. {
  315. #region 且时且多入场设备程序
  316. int checkeNum = 0;
  317. // are.Reset();
  318. LebaiRobot.GetInstance.SetValue(0);
  319. OrderChange(order.morkOrder.SuborderId, ORDER_STATUS.COOKING);
  320. //SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
  321. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡杯);
  322. Wait();
  323. new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制
  324. Thread.Sleep(500);
  325. MessageLog.GetInstance.Show("尝试取咖啡杯!");
  326. LebaiRobot.GetInstance.SetValue(1);
  327. int count = 2;
  328. p:
  329. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯检测);
  330. Wait();
  331. LebaiRobot.GetInstance.SetValue(1);
  332. if (!LebaiRobot.GetInstance.GetInput())
  333. {
  334. if (count >= 3)
  335. {
  336. //退出循环回到初始位置
  337. DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!");
  338. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯回原点);
  339. Wait();
  340. LebaiRobot.GetInstance.SetValue(1);
  341. return;
  342. }
  343. DeviceProcessLogShow("执行二次取咖啡杯");
  344. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取咖啡杯);
  345. Wait();
  346. new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制
  347. LebaiRobot.GetInstance.SetValue(1);
  348. count++;
  349. goto p;
  350. }
  351. DeviceProcessLogShow("咖啡杯取杯完成");
  352. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡后回原点);
  353. Wait();
  354. LebaiRobot.GetInstance.SetValue(1);
  355. //加场景 回初始位置
  356. new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(order.Loc) }.Publish(); //接咖啡控制
  357. DeviceProcessLogShow($"发送咖啡机制作{order.Loc}!");
  358. #endregion
  359. }
  360. /// <summary>
  361. /// 将咖啡杯子 取走到 取餐口
  362. /// </summary>
  363. private void DoCoffeeQC(SimOrderData order)
  364. {
  365. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡出餐);
  366. Wait();
  367. LebaiRobot.GetInstance.SetValue(1);
  368. //订单状态改变:完成
  369. OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK);
  370. //SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId,BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK);
  371. DeviceProcessLogShow($"{order.morkOrder.GoodsName}等待取餐");
  372. WaitTakeMealOrder.Enqueue(order);
  373. }
  374. /// <summary>
  375. /// 做冰淇淋
  376. /// </summary>
  377. private void DoIceCream(SimOrderData order)
  378. {
  379. //if (LebaiRobot.GetInstance.GetInput(3))
  380. //{
  381. // MessageLog.GetInstance.Show("请擦拭冰淇淋机出口");
  382. // return;
  383. //}
  384. #region 且时且多入场设备程序
  385. int checkeNum = 0;
  386. //are.Reset();
  387. LebaiRobot.GetInstance.SetValue(0);
  388. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取冰淇淋杯);
  389. Wait();
  390. new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制
  391. Thread.Sleep(500);
  392. MessageLog.GetInstance.Show("尝试取冰淇淋杯!");
  393. LebaiRobot.GetInstance.SetValue(1);
  394. int count = 2;
  395. p:
  396. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯检测);
  397. Wait();
  398. LebaiRobot.GetInstance.SetValue(1);
  399. if (!LebaiRobot.GetInstance.GetInput())
  400. {
  401. if (count >= 3)
  402. {
  403. //退出循环回到初始位置
  404. MessageLog.GetInstance.Show($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!");
  405. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯回原点);
  406. Wait();
  407. LebaiRobot.GetInstance.SetValue(1);
  408. return;
  409. }
  410. MessageLog.GetInstance.Show($"执行{count}次取冰淇淋杯!");
  411. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取冰淇淋杯);
  412. new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制
  413. Wait();
  414. LebaiRobot.GetInstance.SetValue(1);
  415. count++;
  416. goto p;
  417. }
  418. MessageLog.GetInstance.Show("冰淇淋杯检测完成");
  419. #region 通讯冰淇淋机
  420. //制冷模式
  421. new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
  422. LebaiRobot.GetInstance.SetValue(0);
  423. OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
  424. //SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
  425. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接1号冰淇淋);
  426. Wait();
  427. bool doItResult = true;
  428. //出料
  429. new GSIceCream_DischargeEvent().Publish(delegate (object[] args)
  430. {
  431. doItResult = (bool)args[0];
  432. });
  433. if (doItResult)
  434. {
  435. IceCreamCookCheck();
  436. }
  437. else
  438. {
  439. int count_1 = 0;
  440. while (MorkIStatus.GetInstance().CXB <= 86)
  441. {
  442. Thread.Sleep(5);
  443. count_1++;
  444. if (count_1 >= 2000)
  445. break;
  446. }
  447. IceCreamCookCheck();
  448. }
  449. LebaiRobot.GetInstance.SetValue(1);
  450. #endregion
  451. while (LebaiRobot.GetInstance.GetInput())
  452. {
  453. Thread.Sleep(500);
  454. }
  455. LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_放冰淇淋位置);
  456. Wait();
  457. LebaiRobot.GetInstance.SetValue(1);
  458. //订单状态改变:完成
  459. OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK);
  460. //SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK);
  461. MessageLog.GetInstance.Show($"{order.morkOrder.GoodsName}等待取餐");
  462. WaitTakeMealOrder.Enqueue(order);
  463. #endregion
  464. }
  465. /// <summary>
  466. /// 冰淇淋制作
  467. /// </summary>
  468. public void IceCreamCookCheck()
  469. {
  470. int retry = 3;
  471. DateTime beginTime = DateTime.Now;
  472. while (!LebaiRobot.GetInstance.GetInput(3))
  473. {
  474. if (retry <= 0 && DateTime.Now.Subtract(beginTime).TotalSeconds >= 10)
  475. {
  476. MessageLog.GetInstance.Show("超时未出料,重试次数用尽");
  477. break;
  478. }
  479. if (DateTime.Now.Subtract(beginTime).TotalSeconds > 5)
  480. {
  481. MessageLog.GetInstance.Show("超时未出料,重新发送打料指令");
  482. new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.打料 }.Publish();
  483. beginTime = DateTime.Now;
  484. retry--;
  485. }
  486. Thread.Sleep(10);
  487. }
  488. MessageLog.GetInstance.Show("开始等待6s");
  489. Thread.Sleep(5000);
  490. }
  491. //private void CoffeEndCookHandle(IEvent @event, EventBus.EventCallBackHandle callBack)
  492. //{
  493. // //are.Set();
  494. // if(MakeCoffeeOrder!=null)
  495. // MakeCoffeeOrder.OrderStatus = 1;
  496. //}
  497. public void ReadRobotData()
  498. {
  499. ThreadManage.GetInstance().StartLong(new Action(() =>
  500. {
  501. lebai = LebaiRobot.GetInstance.GetValueAsync();
  502. LebaiRobot.GetInstance.GetRobotModeStatus();
  503. //LebaiRobot.GetInstance.GetInput();
  504. Thread.Sleep(100);
  505. }), "乐百机器人数据读取", true);
  506. }
  507. public void SimOrder<T>(T simOrder)
  508. {
  509. }
  510. /// <summary>
  511. /// IOT 广播消息命令
  512. /// </summary>
  513. public void IotBroadcast<T>(T broadcast)
  514. {
  515. if (broadcast != null && broadcast is IOTCommandModel iOTCommand)
  516. {
  517. switch (iOTCommand.CommandName)
  518. {
  519. case 0://控制类
  520. if (iOTCommand.CommandValue != null)
  521. {
  522. if (iOTCommand.CommandValue.ContainsKey("SimOrder"))
  523. {
  524. //SimOrder(new SimOrderData { NoodleLoc = 1, BowlLoc = 10 });
  525. }
  526. }
  527. break;
  528. case 1://设置属性
  529. break;
  530. case 2://通知消息
  531. break;
  532. default:
  533. break;
  534. }
  535. }
  536. }
  537. public override void DoMain()
  538. {
  539. }
  540. public override void Stop()
  541. {
  542. }
  543. public override void ReadData()
  544. {
  545. }
  546. public override void MainTask()
  547. {
  548. }
  549. public override void ResetProgram()
  550. {
  551. }
  552. }
  553. public class SimOrderData
  554. {
  555. public string id { get; set; }
  556. public int OrderStatus { get; set; }
  557. public string Loc { get; set; }
  558. public MorkOrderPush morkOrder { get; set; }
  559. public SimOrderData()
  560. {
  561. id = Guid.NewGuid().ToString();
  562. OrderStatus = 0;
  563. }
  564. }
  565. }