SchedulerModule.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.Common;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.Util;
  6. using Aitex.Sorter.Common;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.Common.Schedulers;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. namespace EfemDualSchedulerLib.Schedulers
  11. {
  12. public class SchedulerModule
  13. {
  14. public enum TaskType
  15. {
  16. None,
  17. PrepareTransfer,
  18. Pick,
  19. Place,
  20. Goto,
  21. PickAndPlace,
  22. PlaceAndPick,
  23. Preprocess,
  24. Process,
  25. PostProcess,
  26. IdlePurgeProcess,
  27. IdleCleanProcess,
  28. PreJobProcess,
  29. CompleteJobProcess,
  30. OpenCover,
  31. CloseCover,
  32. Load,
  33. Unload,
  34. Align,
  35. TransferTarget,
  36. PreCooling,
  37. Cooling,
  38. Heating,
  39. Map,
  40. }
  41. public ModuleName Module
  42. {
  43. get { return ModuleHelper.Converter(_module); }
  44. }
  45. public virtual bool IsAvailable { get; }
  46. public virtual bool IsOnline { get; }
  47. public virtual bool IsError { get; }
  48. private R_TRIG[] firstDetectWaferArriveTrigs = new R_TRIG[25];
  49. private R_TRIG[] firstDetectWaferLeaveTrigs = new R_TRIG[25];
  50. protected string _module;
  51. protected TaskType _task = TaskType.None;
  52. public TaskType Task => _task;
  53. public TaskType GetTaskType() { return _task; }
  54. protected ModuleName _inProcessRobot;
  55. public ModuleName InProcessRobot => _inProcessRobot;
  56. public SchedulerModule(string module)
  57. {
  58. _module = module;
  59. for (int i = 0; i < firstDetectWaferArriveTrigs.Length; i++)
  60. {
  61. firstDetectWaferArriveTrigs[i] = new R_TRIG();
  62. }
  63. for (int i = 0; i < firstDetectWaferLeaveTrigs.Length; i++)
  64. {
  65. firstDetectWaferLeaveTrigs[i] = new R_TRIG();
  66. }
  67. }
  68. protected void LogTaskStart(TaskType cmd, string message)
  69. {
  70. EV.PostInfoLog("Scheduler", $"TaskStart:{_module},{cmd},{message}");
  71. }
  72. protected void LogTaskDone(TaskType cmd, string message)
  73. {
  74. EV.PostInfoLog("Scheduler", $"TaskDone:{_module},{cmd},{message}");
  75. }
  76. public virtual void ResetTask()
  77. {
  78. _task = TaskType.None;
  79. }
  80. public bool WaitTransfer(ModuleName robot)
  81. {
  82. _task = TaskType.TransferTarget;
  83. _inProcessRobot = robot;
  84. LogTaskStart(_task, $"Note {robot} in transfer");
  85. return true;
  86. }
  87. public bool IsWaitTransfer(ModuleName robot)
  88. {
  89. return _task == TaskType.TransferTarget && _inProcessRobot == robot;
  90. }
  91. public bool StopWaitTransfer(ModuleName robot)
  92. {
  93. LogTaskDone(_task, $"Note {robot} transfer complete");
  94. _inProcessRobot = ModuleName.System;
  95. _task = TaskType.None;
  96. return true;
  97. }
  98. public WaferInfo GetWaferInfo(int slot)
  99. {
  100. return WaferManager.Instance.GetWafer(ModuleHelper.Converter(_module), slot);
  101. }
  102. public virtual bool HasWafer(int slot)
  103. {
  104. return WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(_module), slot);
  105. }
  106. public virtual bool NoWafer(int slot)
  107. {
  108. return WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(_module), slot);
  109. }
  110. public bool FirstDetectWaferArrive(int slot)
  111. {
  112. firstDetectWaferArriveTrigs[slot].CLK = HasWafer(slot);
  113. return firstDetectWaferArriveTrigs[slot].Q;
  114. }
  115. public bool FirstDetectWaferLeave(int slot)
  116. {
  117. firstDetectWaferLeaveTrigs[slot].CLK = NoWafer(slot);
  118. return firstDetectWaferLeaveTrigs[slot].Q;
  119. }
  120. /// <summary>
  121. /// 检查参数代表的wafer下一站是否是本模块
  122. /// </summary>
  123. /// <param name="module"> 已有wafer的Module</param>
  124. /// <param name="slot"> 已有wafer的Slot</param>
  125. /// <returns></returns>
  126. public virtual bool CheckWaferNextStepIsThisModule(ModuleName module, int slot)
  127. {
  128. if (!WaferManager.Instance.CheckHasWafer(module, slot))
  129. return false;
  130. WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
  131. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  132. return false;
  133. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
  134. return false;
  135. if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(Module))
  136. return false;
  137. return true;
  138. }
  139. /// <summary>
  140. /// 检查参数代表的wafer下一站是否是本模块thisSlot
  141. /// </summary>
  142. /// <param name="module"> 已有wafer的Module</param>
  143. /// <param name="slot"> 已有wafer的Slot</param>
  144. /// <param name="thisSlot"> 本模块slot位置</param>
  145. /// <returns></returns>
  146. public virtual bool CheckWaferNextStepIsThisModuleSlot(ModuleName module, int slot, int thisSlot)
  147. {
  148. if (!WaferManager.Instance.CheckHasWafer(module, slot))
  149. return false;
  150. WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
  151. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  152. return false;
  153. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
  154. return false;
  155. if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(Module))
  156. return false;
  157. if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter["SlotSelection"].ToString().Contains(thisSlot.ToString()))
  158. return false;
  159. return true;
  160. }
  161. /// <summary>
  162. /// 判断下一步的模块是否有Wafer
  163. /// </summary>
  164. /// <param name="slot"></param>
  165. /// <returns></returns>
  166. public virtual bool CheckWaferNextStepModuleNoWafer(int slot)
  167. {
  168. if (!WaferManager.Instance.CheckHasWafer(Module, slot))
  169. return false;
  170. WaferInfo wafer = WaferManager.Instance.GetWafer(Module, slot);
  171. if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
  172. return false;
  173. if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
  174. return false;
  175. List<ModuleName> lstModuleName = wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules;
  176. if (lstModuleName.Count > 0)
  177. {
  178. for (int i = 0; i < lstModuleName.Count; i++)
  179. {
  180. if (WaferManager.Instance.CheckNoWafer(lstModuleName[i], 0))
  181. {
  182. return true;
  183. }
  184. }
  185. }
  186. return false;
  187. }
  188. public virtual bool IsReadyForPick(ModuleName robot, Hand blade, int slot)
  189. {
  190. return true;
  191. }
  192. public virtual bool IsReadyForPlace(ModuleName robot, Hand blade, int slot)
  193. {
  194. return true;
  195. }
  196. public virtual bool PrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
  197. {
  198. return true;
  199. }
  200. public virtual bool PostTransfer(ModuleName robot, EnumTransferType type, int slot)
  201. {
  202. return true;
  203. }
  204. public virtual bool Process(string recipeName, bool isCleanRecipe, bool withDummyWafer)
  205. {
  206. return true;
  207. }
  208. public virtual bool Cooling(int coolingTime)
  209. {
  210. return true;
  211. }
  212. }
  213. }