SchedulerEfemRobot.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Aitex.Core.RT.Fsm;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.Util;
  9. using Aitex.Sorter.Common;
  10. using Venus_RT.Modules;
  11. using MECF.Framework.Common.Equipment;
  12. using MECF.Framework.Common.SubstrateTrackings;
  13. namespace Venus_RT.Scheduler
  14. {
  15. public class SchedulerEfemRobot : SchedulerModule
  16. {
  17. public override bool IsAvailable
  18. {
  19. get { return _entity.IsIdle && /*_entity.IsOnline && */CheckTaskDone(); }
  20. }
  21. public override bool IsOnline
  22. {
  23. get { return _entity.IsOnline; }
  24. }
  25. public override bool IsError
  26. {
  27. get { return _entity.IsError; }
  28. }
  29. private EfemEntity _entity = null;
  30. private Hand _hand;
  31. private int _entityTaskToken = (int)FSM_MSG.NONE;
  32. private Hand _taskSwapPickHand;
  33. private Hand _taskSwapPlaceHand;
  34. private int _taskSwapPickSlot;
  35. private int _taskSwapPlaceSlot;
  36. public ModuleName PreviousTarget { get; set; }
  37. public SchedulerEfemRobot() : base(ModuleName.EfemRobot.ToString())
  38. {
  39. _entity = Singleton<RouteManager>.Instance.EFEM;
  40. PreviousTarget = ModuleName.System;
  41. }
  42. public bool IsReadyForPick(Hand blade)
  43. {
  44. return WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)blade);
  45. }
  46. public bool IsReadyForPlace(Hand blade)
  47. {
  48. return WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)blade);
  49. }
  50. public bool Pick(ModuleName source, int slot, Hand hand)
  51. {
  52. _task = TaskType.Pick;
  53. _hand = hand;
  54. _entityTaskToken = _entity.InvokePick(source, slot, hand, WaferManager.Instance.GetWafer(source, slot).Size);
  55. PreviousTarget = source;
  56. LogTaskStart(_task, $"{source}.{slot + 1}=>{Module}.{hand}");
  57. return true;
  58. }
  59. public bool Place(ModuleName destination, int slot, Hand hand)
  60. {
  61. _task = TaskType.Place;
  62. _hand = hand;
  63. _entityTaskToken = _entity.InvokePlace(destination, slot, hand,
  64. WaferManager.Instance.GetWafer(ModuleName.EfemRobot, hand==Hand.Blade1 ? 0:1).Size);
  65. PreviousTarget = destination;
  66. LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}");
  67. return true;
  68. }
  69. public bool PickAndPlace(ModuleName target, int pickSlot, int placeSlot, Hand pickHand, Hand placeHand)
  70. {
  71. PreviousTarget = target;
  72. _task = TaskType.PickAndPlace;
  73. _taskSwapPickHand = pickHand;
  74. _taskSwapPlaceHand = placeHand;
  75. _taskSwapPickSlot = pickSlot;
  76. _taskSwapPlaceSlot = placeSlot;
  77. _entityTaskToken = _entity.InvokePickAndPlace(target, pickHand, pickSlot, placeHand, placeSlot, WaferManager.Instance.GetWafer(target, pickSlot).Size);
  78. LogTaskStart(_task, $" {target}.{pickSlot + 1}=>{Module}.{pickHand} && {Module}.{placeHand}=>{target}.{placeSlot + 1}");
  79. return true;
  80. }
  81. public bool Goto(ModuleName target, int slot )
  82. {
  83. _task = TaskType.Goto;
  84. _entityTaskToken = _entity.InvokeGoto(target, slot );
  85. PreviousTarget = target;
  86. LogTaskStart(_task, $"Robot goto {target}.{slot + 1}");
  87. return true;
  88. }
  89. public bool Map(ModuleName destination )
  90. {
  91. _task = TaskType.Map;
  92. _entityTaskToken = _entity.InvokeMap(destination.ToString());
  93. LogTaskStart(_task, $"{Module} mapping");
  94. PreviousTarget = destination;
  95. return true;
  96. }
  97. public bool Monitor()
  98. {
  99. return true;
  100. }
  101. public bool CheckTaskDone()
  102. {
  103. bool ret = false;
  104. switch (_task)
  105. {
  106. case TaskType.None:
  107. ret = true;
  108. break;
  109. case TaskType.Pick:
  110. ret = WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)_hand);
  111. if (ret)
  112. {
  113. WaferArriveTicks[(int) _hand] = DateTime.Now.Ticks;
  114. }
  115. break;
  116. case TaskType.Place:
  117. ret = WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)_hand);
  118. break;
  119. case TaskType.Map:
  120. ret = _entity.CheckAcked(_entityTaskToken) && _entity.IsIdle;
  121. break;
  122. case TaskType.Goto:
  123. ret = _entity.CheckAcked(_entityTaskToken) && _entity.IsIdle;
  124. break;
  125. case TaskType.PickAndPlace:
  126. ret = WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)_taskSwapPickHand)
  127. && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)_taskSwapPlaceHand);
  128. if (ret)
  129. {
  130. WaferArriveTicks[(int)_taskSwapPickHand] = DateTime.Now.Ticks;
  131. }
  132. break;
  133. }
  134. if (ret && _task != TaskType.None)
  135. {
  136. LogTaskDone(_task, "");
  137. _task = TaskType.None;
  138. }
  139. return ret;
  140. }
  141. }
  142. }