SchedulerEFEM.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using Aitex.Core.Common;
  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.SubstrateTrackings;
  8. using MECF.Framework.RT.ModuleLibrary.EfemModules;
  9. using MECF.Framework.RT.ModuleLibrary.SystemModules;
  10. using MECF.Framework.RT.ModuleLibrary.TMModules;
  11. namespace EfemDualSchedulerLib.Schedulers
  12. {
  13. public class SchedulerEFEM : SchedulerModule
  14. {
  15. public override bool IsAvailable
  16. {
  17. get { return _efem.IsReady && _efem.IsOnline && CheckTaskDone(); }
  18. }
  19. public override bool IsOnline
  20. {
  21. get { return _efem.IsOnline; }
  22. }
  23. public override bool IsError
  24. {
  25. get { return _efem.IsError; }
  26. }
  27. public bool Blade1Enable
  28. {
  29. get => SC.GetValueOrDefault<bool>($"Efem.EfemRobot.LowerBladeEnable");
  30. }
  31. public bool Blade2Enable
  32. {
  33. get => SC.GetValueOrDefault<bool>($"Efem.EfemRobot.UpperBladeEnable");
  34. }
  35. private EfemModuleBase _efem = null;
  36. private Hand _hand;
  37. private Hand _taskSwapPickHand;
  38. private Hand _taskSwapPlaceHand;
  39. private int _taskSwapPickSlot;
  40. private int _taskSwapPlaceSlot;
  41. public ModuleName PreviousTarget { get; set; }
  42. public SchedulerEFEM(EfemModuleBase moduleDevice) : base(ModuleName.EFEM.ToString())
  43. {
  44. _efem = moduleDevice;
  45. PreviousTarget = ModuleName.System;
  46. }
  47. public override void ResetTask()
  48. {
  49. base.ResetTask();
  50. PreviousTarget = ModuleName.System;
  51. }
  52. public override WaferInfo GetWaferInfo(int slot)
  53. {
  54. return WaferManager.Instance.GetWafer(ModuleName.EfemRobot, slot);
  55. }
  56. public override bool HasWafer(int slot)
  57. {
  58. return WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, slot);
  59. }
  60. public override bool NoWafer(int slot)
  61. {
  62. return WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, slot);
  63. }
  64. public override bool CheckWaferNextStepIsThisModule(ModuleName module, int slot)
  65. {
  66. if (!WaferManager.Instance.CheckHasWafer(module, slot))
  67. return false;
  68. WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
  69. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  70. return false;
  71. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
  72. return false;
  73. if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.EfemRobot))
  74. return false;
  75. return true;
  76. }
  77. public override bool CheckWaferNextStepIsThisModuleSlot(ModuleName module, int slot, int thisSlot)
  78. {
  79. if (!WaferManager.Instance.CheckHasWafer(module, slot))
  80. return false;
  81. WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
  82. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  83. return false;
  84. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
  85. return false;
  86. if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(ModuleName.EfemRobot))
  87. return false;
  88. if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter["SlotSelection"].ToString().Contains(thisSlot.ToString()))
  89. return false;
  90. return true;
  91. }
  92. public bool IsReadyForPick(Hand blade)
  93. {
  94. return WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)blade);
  95. }
  96. public bool IsReadyForPlace(Hand blade)
  97. {
  98. return WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)blade);
  99. }
  100. public bool Pick(ModuleName source, int slot, Hand hand)
  101. {
  102. _task = TaskType.Pick;
  103. _hand = hand;
  104. if (!_efem.Pick(source, hand, slot, out string reason))
  105. {
  106. LOG.Write(reason);
  107. }
  108. PreviousTarget = source;
  109. LogTaskStart(_task, $"{source}.{slot + 1}=>{Module}.{hand}");
  110. return true;
  111. }
  112. public bool Place(ModuleName destination, int slot, Hand hand)
  113. {
  114. _task = TaskType.Place;
  115. _hand = hand;
  116. if (!_efem.Place(destination, hand, slot, out string reason))
  117. {
  118. LOG.Write(reason);
  119. }
  120. PreviousTarget = destination;
  121. LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}");
  122. return true;
  123. }
  124. public bool Map(ModuleName destination)
  125. {
  126. _task = TaskType.Map;
  127. if (!_efem.Map(destination, out string reason))
  128. {
  129. LOG.Write(reason);
  130. }
  131. PreviousTarget = destination;
  132. LogTaskStart(_task, $"mapping {Module}");
  133. return true;
  134. }
  135. public bool PickAndPlace(ModuleName target, int pickSlot, int placeSlot, Hand pickHand, Hand placeHand)
  136. {
  137. PreviousTarget = target;
  138. _task = TaskType.PickAndPlace;
  139. _taskSwapPickHand = pickHand;
  140. _taskSwapPlaceHand = placeHand;
  141. _taskSwapPickSlot = pickSlot;
  142. _taskSwapPlaceSlot = placeSlot;
  143. LogTaskStart(_task, $" {target}.{pickSlot + 1}=>{Module}.{pickHand} && {Module}.{placeHand}=>{target}.{placeSlot + 1}");
  144. return _efem.PickAndPlace(target, pickHand, pickSlot, target, placeHand, placeSlot, out _);
  145. }
  146. public bool Goto(ModuleName target, int slot, Hand hand)
  147. {
  148. PreviousTarget = target;
  149. _task = TaskType.Goto;
  150. if (!_efem.Goto(target, hand, slot, out string reason))
  151. {
  152. LOG.Write(reason);
  153. }
  154. LogTaskStart(_task, $"robot {hand} goto {target}, slot {slot + 1}");
  155. return true;
  156. }
  157. public bool CheckTaskDone()
  158. {
  159. bool ret = false;
  160. switch (_task)
  161. {
  162. case TaskType.None:
  163. ret = true;
  164. break;
  165. case TaskType.Pick:
  166. if (_hand == Hand.Both)
  167. {
  168. ret = WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)Hand.Blade1)
  169. && WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)Hand.Blade2);
  170. }
  171. else
  172. {
  173. ret = WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)_hand);
  174. }
  175. break;
  176. case TaskType.Place:
  177. if (_hand == Hand.Both)
  178. {
  179. ret = WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)Hand.Blade1)
  180. && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)Hand.Blade2);
  181. }
  182. else
  183. {
  184. ret = WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)_hand);
  185. }
  186. break;
  187. case TaskType.Map:
  188. ret = _efem.IsReady;
  189. break;
  190. case TaskType.Goto:
  191. ret = _efem.IsReady;
  192. break;
  193. case TaskType.PickAndPlace:
  194. ret = WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)_taskSwapPickHand)
  195. && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)_taskSwapPlaceHand);
  196. break;
  197. }
  198. if (ret && _task != TaskType.None)
  199. {
  200. LogTaskDone(_task, "");
  201. _task = TaskType.None;
  202. }
  203. return ret;
  204. }
  205. }
  206. }