PMPrepareTransferRoutine.cs 8.8 KB

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