PMPrepareTransferRoutine.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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($"开始, 准备 {(_TransferType == EnumTransferType.Place ? "放" : _TransferType == EnumTransferType.Pick ? "取" : "动作未知")}{_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. PMPreparePick((int)RoutineStep.PrepareTransferPick, _TransferType == EnumTransferType.Pick, _ws, true, _timeout);
  104. }
  105. End((int)RoutineStep.kEnd);
  106. }
  107. catch (RoutineBreakException)
  108. {
  109. return Result.RUN;
  110. }
  111. catch (RoutineFaildException)
  112. {
  113. Notify("出错");
  114. return Result.FAIL;
  115. }
  116. catch (Exception ex)
  117. {
  118. Stop(ex.Message);
  119. return Result.FAIL;
  120. }
  121. Notify("结束");
  122. return Result.DONE;
  123. }
  124. public override void Abort()
  125. {
  126. }
  127. public void PMPreparePlace(int id, bool isUp, WaferSize ws, bool isOpen, int timeout)
  128. {
  129. bool Func()
  130. {
  131. Notify($"设置 liftPin {(isUp ? "升" : "降")}, 设置 {ws} Pin 升, 设置 SlitDoor {(isOpen ? "开" : "关")}");
  132. if (!_chamber.SetLiftPin(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  133. {
  134. Stop(reason);
  135. return false;
  136. }
  137. _chamber.PrepareGuidePinForPlace(ws);
  138. //_chamber.SetSlitDoor(isOpen, out string reason1);
  139. return true;
  140. }
  141. bool? Check1()
  142. {
  143. bool res1 = isUp ? _chamber.CheckLiftUp() : _chamber.CheckLiftDown();
  144. bool res2 = _chamber.CheckGuidePinIsReadyForTransfer(ws);
  145. //bool res3 = isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose();
  146. return res1 && res2 /*&& res3*/;
  147. }
  148. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeout * 1000);
  149. if (ret.Item1)
  150. {
  151. if (ret.Item2 == Result.FAIL)
  152. {
  153. throw new RoutineFaildException();
  154. }
  155. if (ret.Item2 == Result.TIMEOUT)
  156. {
  157. Stop($"无法 放片准备 in {timeout} seconds");
  158. throw new RoutineFaildException();
  159. }
  160. throw new RoutineBreakException();
  161. }
  162. }
  163. public void PMPreparePick(int id, bool isUp, WaferSize ws, bool isOpen, int timeout)
  164. {
  165. bool Func()
  166. {
  167. Notify($"设置 LiftPin {(isUp ? "升" : "降")}, 设置 SlitDoor {(isOpen ? "开" : "关")}");
  168. if (!_chamber.SetLiftPin(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  169. {
  170. Stop(reason);
  171. return false;
  172. }
  173. _chamber.PrepareGuidePinForPlace(ws);
  174. //_chamber.SetSlitDoor(isOpen, out string reason1);
  175. return true;
  176. }
  177. bool? Check1()
  178. {
  179. bool res1 = isUp ? _chamber.CheckLiftUp() : _chamber.CheckLiftDown();
  180. //bool res2 = isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose();
  181. bool res3 = _chamber.CheckGuidePinIsReadyForTransfer(ws);
  182. return res1 /*&& res2*/ && res3;
  183. }
  184. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeout * 1000);
  185. if (ret.Item1)
  186. {
  187. if (ret.Item2 == Result.FAIL)
  188. {
  189. throw new RoutineFaildException();
  190. }
  191. if (ret.Item2 == Result.TIMEOUT)
  192. {
  193. Stop($"无法 取片准备 in {timeout} seconds");
  194. throw new RoutineFaildException();
  195. }
  196. throw new RoutineBreakException();
  197. }
  198. }
  199. public void SetGuidePinUp(int id, WaferSize ws, int timeout)
  200. {
  201. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  202. {
  203. Notify($"set Guide pin {_chamber.Name} " + "升");
  204. _chamber.PrepareGuidePinForPlace(ws);
  205. return true;
  206. }, () =>
  207. {
  208. return _chamber.CheckGuidePinIsReadyForTransfer(ws);
  209. }, timeout * 1000);
  210. if (ret.Item1)
  211. {
  212. if (ret.Item2 == Result.FAIL)
  213. {
  214. throw new RoutineFaildException();
  215. }
  216. else if (ret.Item2 == Result.TIMEOUT) //timeout
  217. {
  218. Stop($"can not complete in {timeout} seconds");
  219. throw new RoutineFaildException();
  220. }
  221. else
  222. throw new RoutineBreakException();
  223. }
  224. }
  225. }
  226. }