PMPrepareTransferRoutine.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using System;
  2. using Aitex.Core.Common;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.Schedulers;
  7. using MECF.Framework.Common.SubstrateTrackings;
  8. using VirgoCommon;
  9. using VirgoRT.Devices;
  10. namespace VirgoRT.Modules.PMs
  11. {
  12. class PMPrepareTransferRoutine : PMRoutineBase, IRoutine
  13. {
  14. enum RoutineStep
  15. {
  16. LiftUpDown,
  17. Vent,
  18. VentDelay,
  19. SetGuidePin,
  20. CheckTemp,
  21. SetSlitDoor,
  22. SlitDoorDelay,
  23. PrepareTransferPlace,
  24. PrepareTransferPick,
  25. kEnd
  26. }
  27. private EnumTransferType _TransferType;
  28. private int _timeout;
  29. private readonly VentRoutine _ventRoutine;
  30. private WaferSize _ws;
  31. private float _temp;
  32. private double _tolerance;
  33. private double _OffsetTemp = 0.0f;
  34. public PMPrepareTransferRoutine(JetPM chamber, VentRoutine _vRoutine) : base(chamber)
  35. {
  36. Name = "PrepareTransfer";
  37. _ventRoutine = _vRoutine;
  38. }
  39. public Result Init(EnumTransferType type, float temp, WaferSize size)
  40. {
  41. if (type == EnumTransferType.Place)
  42. {
  43. Name = $"Prepare Place {_ws}";
  44. }
  45. else if (type == EnumTransferType.Pick)
  46. {
  47. size = WaferManager.Instance.GetWafer(_chamber.Module, 0).Size;
  48. Name = $"Prepare Pick {_ws}";
  49. }
  50. _TransferType = type;
  51. _ws = size;
  52. _temp = temp;
  53. return Result.DONE;
  54. }
  55. public Result Init(EnumTransferType type, float temp)
  56. {
  57. WaferSize ws = WaferSize.WS0;
  58. if (type == EnumTransferType.Place)
  59. {
  60. ws = WaferManager.Instance.GetWafer(ModuleName.EfemRobot, 0).Size;
  61. }
  62. else if (_TransferType == EnumTransferType.Pick)
  63. {
  64. ws = WaferManager.Instance.GetWafer(_chamber.Module, 0).Size;
  65. }
  66. return Init(type, temp, ws);
  67. }
  68. public Result Start(params object[] objs)
  69. {
  70. Reset();
  71. _timeout = SC.GetValue<int>($"{Module}.PrepareTransferTimeout");
  72. _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceToTarget");
  73. _OffsetTemp = SC.GetValue<double>($"{Module}.Chiller.ChillerTemperatureOffset");
  74. Notify($"Start, ready {(_TransferType == EnumTransferType.Place ? "place" : _TransferType == EnumTransferType.Pick ? "pick" : "unknow action")} {_ws} ");
  75. return Result.RUN;
  76. }
  77. public Result Monitor()
  78. {
  79. try
  80. {
  81. // vent
  82. if (!SC.GetValue<bool>("System.IsATMMode") && _chamber.IsSlitDoorClosed)
  83. {
  84. ExecuteRoutine((int)RoutineStep.Vent, _ventRoutine);
  85. }
  86. if (_TransferType == EnumTransferType.Place)
  87. {
  88. if (_temp > 10)
  89. {
  90. if (SC.GetValue<bool>($"{Module}.Chiller.EnableChiller"))
  91. {
  92. CheckCoolantTemp((int)RoutineStep.CheckTemp, _temp, _OffsetTemp, _timeout, _tolerance);
  93. }
  94. else
  95. {
  96. CheckSubstrateTemp((int)RoutineStep.CheckTemp, _temp, _timeout, _tolerance);
  97. }
  98. }
  99. PMPreparePlace((int)RoutineStep.PrepareTransferPlace, false, _ws, true, _timeout);
  100. }
  101. else if (_TransferType == EnumTransferType.Pick)
  102. {
  103. if (_temp > 10)
  104. {
  105. if (SC.GetValue<bool>($"{Module}.Chiller.EnableChiller"))
  106. {
  107. CheckCoolantTemp((int)RoutineStep.CheckTemp, _temp, _OffsetTemp, _timeout, _tolerance);
  108. }
  109. else
  110. {
  111. CheckSubstrateTemp((int)RoutineStep.CheckTemp, _temp, _timeout, _tolerance);
  112. }
  113. }
  114. PMPreparePick((int)RoutineStep.PrepareTransferPick, _TransferType == EnumTransferType.Pick, _ws, true, _timeout);
  115. }
  116. End((int)RoutineStep.kEnd);
  117. }
  118. catch (RoutineBreakException)
  119. {
  120. return Result.RUN;
  121. }
  122. catch (RoutineFaildException)
  123. {
  124. Notify("Error");
  125. return Result.FAIL;
  126. }
  127. catch (Exception ex)
  128. {
  129. Stop(ex.Message);
  130. return Result.FAIL;
  131. }
  132. Notify("Finish");
  133. return Result.DONE;
  134. }
  135. public override void Abort()
  136. {
  137. }
  138. public void PMPreparePlace(int id, bool isUp, WaferSize ws, bool isOpen, int timeout)
  139. {
  140. bool Func()
  141. {
  142. Notify($"Set liftPin {(isUp ? "up" : "down")}, set {ws} Pin up, set slit door {(isOpen ? "open" : "close")}");
  143. if (!_chamber.SetLiftPin(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  144. {
  145. Stop(reason);
  146. return false;
  147. }
  148. _chamber.PrepareGuidePinForPlace(ws);
  149. _chamber.SetSlitDoor(isOpen, out string reason1);
  150. return true;
  151. }
  152. bool? Check1()
  153. {
  154. bool res1 = isUp ? _chamber.CheckLiftUp() : _chamber.CheckLiftDown();
  155. bool res2 = _chamber.CheckGuidePinIsReadyForTransfer(ws);
  156. bool res3 = isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose();
  157. return res1 && res2 && res3;
  158. }
  159. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeout * 1000);
  160. if (ret.Item1)
  161. {
  162. if (ret.Item2 == Result.FAIL)
  163. {
  164. throw new RoutineFaildException();
  165. }
  166. if (ret.Item2 == Result.TIMEOUT)
  167. {
  168. Stop($"Prepare place in {timeout} seconds");
  169. throw new RoutineFaildException();
  170. }
  171. throw new RoutineBreakException();
  172. }
  173. }
  174. public void PMPreparePick(int id, bool isUp, WaferSize ws, bool isOpen, int timeout)
  175. {
  176. bool Func()
  177. {
  178. Notify($"Set lift pin {(isUp ? "up" : "down")}, set slit door {(isOpen ? "open" : "close")}");
  179. if (!_chamber.SetLiftPin(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  180. {
  181. Stop(reason);
  182. return false;
  183. }
  184. _chamber.PrepareGuidePinForPlace(ws);
  185. _chamber.SetSlitDoor(isOpen, out string reason1);
  186. return true;
  187. }
  188. bool? Check1()
  189. {
  190. bool res1 = isUp ? _chamber.CheckLiftUp() : _chamber.CheckLiftDown();
  191. bool res2 = isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose();
  192. bool res3 = _chamber.CheckGuidePinIsReadyForTransfer(ws);
  193. return res1 && res2 && res3;
  194. }
  195. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeout * 1000);
  196. if (ret.Item1)
  197. {
  198. if (ret.Item2 == Result.FAIL)
  199. {
  200. throw new RoutineFaildException();
  201. }
  202. if (ret.Item2 == Result.TIMEOUT)
  203. {
  204. Stop($"Prepare pick in {timeout} seconds");
  205. throw new RoutineFaildException();
  206. }
  207. throw new RoutineBreakException();
  208. }
  209. }
  210. public void SetGuidePinUp(int id, WaferSize ws, int timeout)
  211. {
  212. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  213. {
  214. Notify($"set Guide pin {_chamber.Name} " + "升");
  215. _chamber.PrepareGuidePinForPlace(ws);
  216. return true;
  217. }, () =>
  218. {
  219. return _chamber.CheckGuidePinIsReadyForTransfer(ws);
  220. }, timeout * 1000);
  221. if (ret.Item1)
  222. {
  223. if (ret.Item2 == Result.FAIL)
  224. {
  225. throw new RoutineFaildException();
  226. }
  227. else if (ret.Item2 == Result.TIMEOUT) //timeout
  228. {
  229. Stop($"can not complete in {timeout} seconds");
  230. throw new RoutineFaildException();
  231. }
  232. else
  233. throw new RoutineBreakException();
  234. }
  235. }
  236. }
  237. }