SchedulerSETMRobot.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. using Aitex.Core.RT.Fsm;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.SCCore;
  4. using Aitex.Core.Util;
  5. using Aitex.Sorter.Common;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.Schedulers;
  8. using MECF.Framework.Common.SubstrateTrackings;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Interop;
  15. using Venus_Core;
  16. using Venus_RT.Modules.TM.VenusEntity;
  17. using Venus_RT.Scheduler;
  18. namespace Venus_RT.Modules.Schedulers
  19. {
  20. public class SchedulerSETMRobot : SchedulerModule
  21. {
  22. class SchedulerItem
  23. {
  24. public SETMEntity.MSG MoveType { get; set; }
  25. public ModuleName target { get; set; }
  26. public Queue<MoveItem> moveList { get; set; }
  27. }
  28. public override bool IsAvailable
  29. {
  30. get { return _entity.IsIdle && (_entity.IsOnline || !Singleton<RouteManager>.Instance.IsAutoMode) && RunSchedulers(); }
  31. }
  32. public override bool IsOnline
  33. {
  34. get { return _entity.IsOnline; }
  35. }
  36. public override bool IsError
  37. {
  38. get { return _entity.IsError; }
  39. }
  40. public override bool IsIdle
  41. {
  42. get { return _entity.IsIdle; }
  43. }
  44. public RState RobotStatus
  45. {
  46. get { return _entity.RobotStatus; }
  47. }
  48. //public bool IsVCESlitDoorClosed => _entity.IsVCESlitDoorClosed(Module);
  49. private SETMEntity _entity;
  50. public int _entityTaskToken = (int)FSM_MSG.NONE;
  51. private Queue<SchedulerItem> _schedulerList = new Queue<SchedulerItem>();
  52. private SchedulerItem _currentScheduler = null;
  53. private int _singleArmOption = 0;
  54. public SchedulerSETMRobot() : base(ModuleName.TMRobot.ToString())
  55. {
  56. _entity = Singleton<RouteManager>.Instance.seTM;
  57. _singleArmOption = SC.GetValue<int>($"TM.SingleArmOption");
  58. }
  59. public bool PostMoveItems(MoveItem[] items)
  60. {
  61. foreach (var item in items)
  62. {
  63. LOG.Write(eEvent.EV_ROUTER, ModuleName.TMRobot, $"Post Moving Item: {item.SourceModule} Slot {item.SourceSlot + 1} => {item.DestinationModule} Slot {item.DestinationSlot + 1}");
  64. }
  65. //pm swap
  66. void PackPMSwapCmds(MoveItem[] swapItems)
  67. {
  68. // must swap the item order for PM swap
  69. if (!ModuleHelper.IsTMRobot(swapItems[1].SourceModule))
  70. {
  71. SchedulerItem item = new SchedulerItem();
  72. item.MoveType = SETMEntity.MSG.Pick;
  73. item.target = swapItems[1].SourceModule;
  74. item.moveList = new Queue<MoveItem>();
  75. item.moveList.Enqueue(new MoveItem(swapItems[1].SourceModule, swapItems[1].SourceSlot, ModuleName.TMRobot, 0, (Hand)0));
  76. _schedulerList.Enqueue(item);
  77. }
  78. SchedulerItem swap = new SchedulerItem();
  79. swap.MoveType = SETMEntity.MSG.PMSwap;
  80. swap.target = swapItems[0].SourceModule;
  81. swap.moveList = new Queue<MoveItem>();
  82. swap.moveList.Enqueue(new MoveItem(swapItems[0].SourceModule, swapItems[0].SourceSlot, ModuleName.TMRobot, 1, (Hand)1));
  83. swap.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, 0, swapItems[1].DestinationModule, swapItems[1].DestinationSlot, (Hand)0));
  84. _schedulerList.Enqueue(swap);
  85. if (!ModuleHelper.IsTMRobot(swapItems[0].DestinationModule))
  86. {
  87. SchedulerItem last = new SchedulerItem();
  88. last.MoveType = SETMEntity.MSG.Place;
  89. last.target = swapItems[0].DestinationModule;
  90. last.moveList = new Queue<MoveItem>();
  91. last.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, 1, swapItems[0].DestinationModule, swapItems[0].DestinationSlot, (Hand)1));
  92. _schedulerList.Enqueue(last);
  93. }
  94. }
  95. void PackSwapCmds(MoveItem[] swapItems, SETMEntity.MSG swapType, int swapIndex)
  96. {
  97. SchedulerItem swap = new SchedulerItem();
  98. swap.MoveType = swapType;
  99. swap.target = swapItems[0].DestinationModule;
  100. swap.moveList = new Queue<MoveItem>();
  101. for (int i = 0; i < swapIndex; i++)
  102. {
  103. if (!ModuleHelper.IsTMRobot(swapItems[i].SourceModule))
  104. {
  105. SchedulerItem item = new SchedulerItem();
  106. item.MoveType = !ModuleHelper.IsPm(swapItems[i].SourceModule) ? SETMEntity.MSG.Pick : SETMEntity.MSG.PMPick;
  107. item.target = swapItems[i].SourceModule;
  108. item.moveList = new Queue<MoveItem>();
  109. item.moveList.Enqueue(new MoveItem(swapItems[i].SourceModule, swapItems[i].SourceSlot, ModuleName.TMRobot, i, (Hand)i));
  110. _schedulerList.Enqueue(item);
  111. swap.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, i, swapItems[i].DestinationModule, swapItems[i].DestinationSlot, (Hand)i));
  112. }
  113. }
  114. for (int j = swapIndex; j < swapItems.Length; j++)
  115. {
  116. swap.moveList.Enqueue(new MoveItem(swapItems[j].SourceModule, swapItems[j].SourceSlot, ModuleName.TMRobot, j - swapIndex, (Hand)(j - swapIndex)));
  117. }
  118. _schedulerList.Enqueue(swap);
  119. for (int j = swapIndex; j < swapItems.Length; j++)
  120. {
  121. if (!ModuleHelper.IsTMRobot(swapItems[j].DestinationModule))
  122. {
  123. SchedulerItem item = new SchedulerItem();
  124. item.MoveType = !ModuleHelper.IsPm(swapItems[j].DestinationModule) ? SETMEntity.MSG.Place : SETMEntity.MSG.PMPlace;
  125. item.target = swapItems[j].DestinationModule;
  126. item.moveList = new Queue<MoveItem>();
  127. item.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, j - swapIndex, swapItems[j].DestinationModule, swapItems[j].DestinationSlot, (Hand)(j - swapIndex)));
  128. _schedulerList.Enqueue(item);
  129. }
  130. }
  131. }
  132. //双臂模式 检查是否双臂有wafer
  133. if (WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 0) && WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 1) && _singleArmOption == 0)
  134. {
  135. if (items.Length == 4)
  136. {
  137. //是回到vce 且下一个也是 再下两个要出来 可以做swap
  138. if (ModuleHelper.IsVCE(items[0].DestinationModule) &&
  139. items[0].DestinationModule == items[1].DestinationModule &&
  140. items[0].DestinationModule == items[2].SourceModule &&
  141. items[0].DestinationModule == items[3].SourceModule)
  142. {
  143. PackSwapCmds(items, SETMEntity.MSG.Swap, 2);
  144. }
  145. else if (items.Length == 3)
  146. {
  147. if (ModuleHelper.IsVCE(items[0].DestinationModule) &&
  148. items[0].DestinationModule == items[1].DestinationModule &&
  149. items[0].DestinationModule == items[2].SourceModule)
  150. {
  151. PackSwapCmds(items, SETMEntity.MSG.Swap, 2);
  152. }
  153. else if (ModuleHelper.IsVCE(items[0].DestinationModule) &&
  154. items[0].DestinationModule == items[1].SourceModule &&
  155. items[0].DestinationModule == items[2].SourceModule)
  156. {
  157. PackSwapCmds(items, SETMEntity.MSG.Swap, 1);
  158. }
  159. else if (ModuleHelper.IsVCE(items[0].SourceModule) &&
  160. items[0].SourceModule == items[1].SourceModule &&
  161. ModuleHelper.IsPm(items[1].DestinationModule) &&
  162. items[1].DestinationModule == items[2].SourceModule)
  163. {
  164. SchedulerItem llDoublePick = new SchedulerItem();
  165. llDoublePick.MoveType = SETMEntity.MSG.Swap;
  166. llDoublePick.target = items[0].SourceModule;
  167. llDoublePick.moveList = new Queue<MoveItem>();
  168. llDoublePick.moveList.Enqueue(new MoveItem(items[0].SourceModule, items[0].SourceSlot, ModuleName.TMRobot, 0, 0));
  169. llDoublePick.moveList.Enqueue(new MoveItem(items[1].SourceModule, items[1].SourceSlot, ModuleName.TMRobot, 1, (Hand)1));
  170. _schedulerList.Enqueue(llDoublePick);
  171. SchedulerItem pm1_place = new SchedulerItem();
  172. pm1_place.MoveType = SETMEntity.MSG.PMPlace;
  173. pm1_place.target = items[0].DestinationModule;
  174. pm1_place.moveList = new Queue<MoveItem>();
  175. pm1_place.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, 0, items[0].DestinationModule, items[0].DestinationSlot, 0));
  176. _schedulerList.Enqueue(pm1_place);
  177. SchedulerItem pm2_swap = new SchedulerItem();
  178. pm2_swap.MoveType = SETMEntity.MSG.PMSwap;
  179. pm2_swap.target = items[2].SourceModule;
  180. pm2_swap.moveList = new Queue<MoveItem>();
  181. pm2_swap.moveList.Enqueue(new MoveItem(items[2].SourceModule, items[2].SourceSlot, ModuleName.TMRobot, 0, 0));
  182. pm2_swap.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, 1, items[1].DestinationModule, items[1].DestinationSlot, (Hand)1));
  183. _schedulerList.Enqueue(pm2_swap);
  184. if (ModuleHelper.IsVCE(items[2].DestinationModule))
  185. {
  186. SchedulerItem llPlace = new SchedulerItem();
  187. llPlace.MoveType = SETMEntity.MSG.Place;
  188. llPlace.target = items[2].DestinationModule;
  189. llPlace.moveList = new Queue<MoveItem>();
  190. llPlace.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, 0, items[2].DestinationModule, items[2].DestinationSlot, 0));
  191. _schedulerList.Enqueue(llPlace);
  192. }
  193. }
  194. }
  195. }
  196. else if (items.Length == 2)
  197. {
  198. if (ModuleHelper.IsTMRobot(items[0].DestinationModule)
  199. && ModuleHelper.IsTMRobot(items[1].DestinationModule)
  200. &&ModuleHelper.IsVCE(items[0].SourceModule)
  201. &&ModuleHelper.IsVCE(items[1].SourceModule)
  202. &&WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot,0) && WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 1))
  203. {
  204. SchedulerItem llDoublePick = new SchedulerItem();
  205. llDoublePick.MoveType = SETMEntity.MSG.Swap;
  206. llDoublePick.target = items[0].SourceModule;
  207. llDoublePick.moveList = new Queue<MoveItem>();
  208. llDoublePick.moveList.Enqueue(new MoveItem(items[0].SourceModule, items[0].SourceSlot, ModuleName.TMRobot, 0, 0));
  209. llDoublePick.moveList.Enqueue(new MoveItem(items[1].SourceModule, items[1].SourceSlot, ModuleName.TMRobot, 1, (Hand)1));
  210. _schedulerList.Enqueue(llDoublePick);
  211. }
  212. else if (ModuleHelper.IsVCE(items[0].DestinationModule) &&
  213. items[0].DestinationModule == items[1].DestinationModule)
  214. {
  215. PackSwapCmds(items, SETMEntity.MSG.Swap, 2);
  216. }
  217. else if (ModuleHelper.IsVCE(items[0].SourceModule) &&
  218. items[0].SourceModule == items[1].SourceModule)
  219. {
  220. PackSwapCmds(items, SETMEntity.MSG.Swap, 0);
  221. }
  222. else if (ModuleHelper.IsPm(items[0].SourceModule) &&
  223. items[0].SourceModule == items[1].DestinationModule)
  224. {
  225. PackPMSwapCmds(items);
  226. }
  227. }
  228. }
  229. Hand freeHand = SelectFreeHand();
  230. //如果没有空的手臂 直接报错
  231. if (freeHand == Hand.None && !ModuleHelper.IsTMRobot(items[0].SourceModule))
  232. {
  233. LOG.Write(eEvent.WARN_ROUTER, ModuleName.TMRobot, "No Free Arm to transfer wafer");
  234. return false;
  235. }
  236. if (_schedulerList.Count == 0)
  237. {
  238. if (items.Length >= 2 && items[0].SourceModule == items[1].DestinationModule && ModuleHelper.IsPm(items[0].SourceModule))
  239. {
  240. SchedulerItem item = new SchedulerItem();
  241. item.MoveType = SETMEntity.MSG.PMSwap;
  242. item.target = items[0].SourceModule;
  243. item.moveList = new Queue<MoveItem>();
  244. item.moveList.Enqueue(new MoveItem(items[0].SourceModule, items[0].SourceSlot, items[1].DestinationModule, items[1].DestinationSlot, (Hand)(items[1].SourceSlot == 1 ? 0 : 1)));
  245. _schedulerList.Enqueue(item);
  246. item = new SchedulerItem();
  247. item.MoveType = SETMEntity.MSG.Place;
  248. item.target = items[0].SourceModule;
  249. item.moveList = new Queue<MoveItem>();
  250. item.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, items[1].SourceSlot, items[0].DestinationModule, items[0].DestinationSlot, (Hand)(items[1].SourceSlot == 1 ? 0 : 1)));
  251. _schedulerList.Enqueue(item);
  252. items = items.Skip(2).ToArray();
  253. }
  254. if (items.Length == 3
  255. && ModuleHelper.IsTMRobot(items[1].DestinationModule)
  256. && ModuleHelper.IsTMRobot(items[2].DestinationModule)
  257. && items[1].DestinationSlot == items[2].DestinationSlot
  258. )
  259. {
  260. items[1].DestinationSlot = 0;
  261. items[2].DestinationSlot = 1;
  262. }
  263. foreach (var moveitem in items)
  264. {
  265. //如果不是从tm上来去 就要补上tmrobot中间过程
  266. if (!ModuleHelper.IsTMRobot(moveitem.SourceModule) && !ModuleHelper.IsTMRobot(moveitem.DestinationModule))
  267. {
  268. //如何取
  269. SchedulerItem item = new SchedulerItem();
  270. item.MoveType = !ModuleHelper.IsPm(moveitem.SourceModule) ? SETMEntity.MSG.Pick : SETMEntity.MSG.PMPick;
  271. item.target = moveitem.SourceModule;
  272. item.moveList = new Queue<MoveItem>();
  273. item.moveList.Enqueue(new MoveItem(moveitem.SourceModule, moveitem.SourceSlot, ModuleName.TMRobot, (int)freeHand, freeHand));
  274. _schedulerList.Enqueue(item);
  275. //如何放
  276. item = new SchedulerItem();
  277. item.MoveType = !ModuleHelper.IsPm(moveitem.DestinationModule) ? SETMEntity.MSG.Place : SETMEntity.MSG.PMPlace;
  278. item.target = moveitem.DestinationModule;
  279. item.moveList = new Queue<MoveItem>();
  280. item.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, (int)freeHand, moveitem.DestinationModule, moveitem.DestinationSlot, freeHand));
  281. _schedulerList.Enqueue(item);
  282. }
  283. //如果是place
  284. else if (ModuleHelper.IsTMRobot(moveitem.SourceModule))
  285. {
  286. SchedulerItem item = new SchedulerItem();
  287. item.MoveType = !ModuleHelper.IsPm(moveitem.DestinationModule) ? SETMEntity.MSG.Place : SETMEntity.MSG.PMPlace;
  288. item.target = moveitem.DestinationModule;
  289. item.moveList = new Queue<MoveItem>();
  290. item.moveList.Enqueue(new MoveItem(ModuleName.TMRobot, moveitem.SourceSlot, moveitem.DestinationModule, moveitem.DestinationSlot, (Hand)moveitem.SourceSlot));
  291. _schedulerList.Enqueue(item);
  292. }
  293. //如果是pick
  294. else if (ModuleHelper.IsTMRobot(moveitem.DestinationModule))
  295. {
  296. SchedulerItem item = new SchedulerItem();
  297. item.MoveType = !ModuleHelper.IsPm(moveitem.SourceModule) ? SETMEntity.MSG.Pick : SETMEntity.MSG.PMPick;
  298. item.target = moveitem.SourceModule;
  299. item.moveList = new Queue<MoveItem>();
  300. item.moveList.Enqueue(new MoveItem(moveitem.SourceModule, moveitem.SourceSlot, ModuleName.TMRobot, moveitem.DestinationSlot, (Hand)moveitem.DestinationSlot));
  301. _schedulerList.Enqueue(item);
  302. }
  303. }
  304. }
  305. RunSchedulers();
  306. return true;
  307. }
  308. public bool SendMoveItems(MoveItem[] items)
  309. {
  310. for (int i = 1; i < items.Length; i++)
  311. {
  312. if (items[i - 1].Module != items[i].Module)
  313. {
  314. LOG.Write(eEvent.ERR_ROUTER, ModuleName.TMRobot, $"the actions for {items[i - 1].Module} and for {items[i].Module} should not put together");
  315. return false;
  316. }
  317. }
  318. void PackMoveItems(SETMEntity.MSG cmdType, MoveItem[] actions)
  319. {
  320. SchedulerItem schItem = new SchedulerItem();
  321. schItem.MoveType = cmdType;
  322. schItem.target = actions[0].DestinationModule;
  323. schItem.moveList = new Queue<MoveItem>();
  324. foreach (var ac in actions)
  325. {
  326. schItem.moveList.Enqueue(ac);
  327. }
  328. _schedulerList.Enqueue(schItem);
  329. }
  330. if (ModuleHelper.IsTMRobot(items[0].DestinationModule)) // pick
  331. {
  332. if(items.Length == 1)
  333. {
  334. PackMoveItems(ModuleHelper.IsPm(items[0].SourceModule) ? SETMEntity.MSG.PMPick : SETMEntity.MSG.Pick, items);
  335. }
  336. else
  337. {
  338. if (ModuleHelper.IsPm(items[0].SourceModule))
  339. {
  340. if(items.Length == 2 && items[0].SourceModule == items[1].DestinationModule && ModuleHelper.IsTMRobot(items[1].SourceModule))
  341. {
  342. PackMoveItems(SETMEntity.MSG.PMSwap, items);
  343. }
  344. }
  345. else if (ModuleHelper.IsLoadPort(items[0].SourceModule) && !items.ToList().Exists(mv => mv.SourceModule != items[0].SourceModule && mv.DestinationModule != items[0].SourceModule))
  346. {
  347. PackMoveItems(SETMEntity.MSG.Swap, items);
  348. }
  349. }
  350. }
  351. else if (ModuleHelper.IsTMRobot(items[0].SourceModule)) // place
  352. {
  353. if(items.Length == 1)
  354. {
  355. PackMoveItems(ModuleHelper.IsPm(items[0].DestinationModule) ? SETMEntity.MSG.PMPlace : SETMEntity.MSG.Place, items);
  356. }
  357. else if (ModuleHelper.IsLoadPort(items[0].DestinationModule) && !items.ToList().Exists(mv => mv.SourceModule != items[0].DestinationModule && mv.DestinationModule != items[0].DestinationModule))
  358. {
  359. PackMoveItems(SETMEntity.MSG.Swap, items);
  360. }
  361. }
  362. if(_schedulerList.Count == 0)
  363. {
  364. foreach (var item in items)
  365. {
  366. LOG.Write(eEvent.WARN_ROUTER, ModuleName.TMRobot, $"Wrong move action package: {item.SourceModule} Slot {item.SourceSlot + 1} => {item.DestinationModule} Slot {item.DestinationSlot + 1}");
  367. return false;
  368. }
  369. }
  370. foreach (var item in items)
  371. {
  372. LOG.Write(eEvent.EV_ROUTER, ModuleName.TMRobot, $"Post Moving Item: {item.SourceModule} Slot {item.SourceSlot + 1} => {item.DestinationModule} Slot {item.DestinationSlot + 1}");
  373. }
  374. return true;
  375. }
  376. bool RunSchedulers()
  377. {
  378. //非运行状态
  379. if (_entity.IsIdle && CheckTaskDone())
  380. {
  381. if (_schedulerList.Count == 0)
  382. return true;
  383. _currentScheduler = _schedulerList.Dequeue();
  384. Queue<MoveItem> moveItems = new Queue<MoveItem>();
  385. foreach (var item in _currentScheduler.moveList)
  386. {
  387. moveItems.Enqueue(item);
  388. LOG.Write(eEvent.INFO_TM, ModuleName.TMRobot, $"TM Moving Items: {item.SourceModule} Slot {item.SourceSlot + 1} => {item.DestinationModule} Slot {item.DestinationSlot + 1}");
  389. }
  390. if (_entity.CheckToPostMessage((int)_currentScheduler.MoveType, moveItems))
  391. {
  392. _entityTaskToken = (int)_currentScheduler.MoveType;
  393. }
  394. else
  395. _entityTaskToken = (int)FSM_MSG.NONE;
  396. }
  397. return false;
  398. }
  399. //获得没有wafer的手臂
  400. private Hand SelectFreeHand()
  401. {
  402. if (WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 0) && _singleArmOption != 2)
  403. return Hand.Blade1;
  404. if (WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 1) && _singleArmOption != 1)
  405. return Hand.Blade2;
  406. return Hand.None;
  407. }
  408. private bool CheckTaskDone()
  409. {
  410. bool ret = false;
  411. switch (_entityTaskToken)
  412. {
  413. case (int)SETMEntity.MSG.Pick:
  414. case (int)SETMEntity.MSG.PMPick:
  415. ret = WaferManager.Instance.CheckHasWafer(_currentScheduler.moveList.Peek().DestinationModule, _currentScheduler.moveList.Peek().DestinationSlot) &&
  416. WaferManager.Instance.CheckNoWafer(_currentScheduler.moveList.Peek().SourceModule, _currentScheduler.moveList.Peek().SourceSlot);
  417. break;
  418. case (int)SETMEntity.MSG.Place:
  419. case (int)SETMEntity.MSG.PMPlace:
  420. ret = WaferManager.Instance.CheckHasWafer(_currentScheduler.moveList.Peek().DestinationModule, _currentScheduler.moveList.Peek().DestinationSlot) &&
  421. WaferManager.Instance.CheckNoWafer(_currentScheduler.moveList.Peek().SourceModule, _currentScheduler.moveList.Peek().SourceSlot);
  422. break;
  423. case (int)SETMEntity.MSG.Swap:
  424. ret = WaferManager.Instance.CheckHasWafer(_currentScheduler.moveList.Peek().DestinationModule, _currentScheduler.moveList.Peek().DestinationSlot) &&
  425. WaferManager.Instance.CheckHasWafer(_currentScheduler.moveList.Last().DestinationModule, _currentScheduler.moveList.Last().DestinationSlot);
  426. break;
  427. case (int)SETMEntity.MSG.PMSwap:
  428. ret = WaferManager.Instance.CheckHasWafer(_currentScheduler.moveList.Peek().DestinationModule, _currentScheduler.moveList.Peek().DestinationSlot) &&
  429. WaferManager.Instance.CheckHasWafer(_currentScheduler.moveList.Peek().SourceModule, _currentScheduler.moveList.Peek().SourceSlot);
  430. break;
  431. case (int)SETMEntity.MSG.Align:
  432. ret = _entity.CheckAcked(_entityTaskToken) && _entity.IsIdle ;
  433. break;
  434. case (int)FSM_MSG.NONE:
  435. ret = true;
  436. break;
  437. }
  438. if (ret && _entityTaskToken != (int)FSM_MSG.NONE)
  439. {
  440. _entityTaskToken = (int)FSM_MSG.NONE;
  441. LOG.Write(eEvent.EV_ROUTER, Module, $"Scheduler, {_currentScheduler.target} Task done: {_currentScheduler.MoveType}");
  442. }
  443. return ret;
  444. }
  445. public override bool Align(float angle)
  446. {
  447. _task = TaskType.Align;
  448. if (_entity.CheckToPostMessage((int)SETMEntity.MSG.Align, angle))
  449. {
  450. _entityTaskToken = (int)SETMEntity.MSG.Align;
  451. return true;
  452. }
  453. else
  454. {
  455. _entityTaskToken = (int)FSM_MSG.NONE;
  456. return false;
  457. }
  458. }
  459. public void Abort()
  460. {
  461. _schedulerList.Clear();
  462. }
  463. public override void ResetTask()
  464. {
  465. base.ResetTask();
  466. _entityTaskToken = (int)FSM_MSG.NONE;
  467. _schedulerList.Clear();
  468. }
  469. }
  470. }