PMPrepareTransferRoutine.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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 Virgo_DCommon;
  9. using Virgo_DRT.Devices;
  10. namespace Virgo_DRT.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. public PMPrepareTransferRoutine(JetPM chamber, VentRoutine _vRoutine) : base(chamber)
  34. {
  35. Name = "PrepareTransfer";
  36. _ventRoutine = _vRoutine;
  37. }
  38. public Result Init(EnumTransferType type, float temp)
  39. {
  40. _TransferType = type;
  41. if (_TransferType == EnumTransferType.Place)
  42. {
  43. _ws = WaferManager.Instance.GetWafer(ModuleName.EfemRobot, 0).Size;
  44. Name = $"Prepare Place {_ws}";
  45. }
  46. else if (_TransferType == EnumTransferType.Pick)
  47. {
  48. _ws = WaferManager.Instance.GetWafer(_chamber.Module, 0).Size;
  49. Name = $"Prepare Pick {_ws}";
  50. }
  51. _temp = temp;
  52. return Result.DONE;
  53. }
  54. public Result Start(params object[] objs)
  55. {
  56. Reset();
  57. _timeout = SC.GetValue<int>($"{Module}.PrepareTransferTimeout");
  58. _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceToTarget");
  59. Notify($"开始, 准备 {(_TransferType == EnumTransferType.Place ? "放" : _TransferType == EnumTransferType.Pick ? "取" : "动作未知")}{_ws} 寸片, ");
  60. return Result.RUN;
  61. }
  62. public Result Monitor()
  63. {
  64. try
  65. {
  66. // vent
  67. if (!SC.GetValue<bool>("System.IsATMMode"))
  68. {
  69. ExecuteRoutine((int)RoutineStep.Vent, _ventRoutine);
  70. }
  71. if (_TransferType == EnumTransferType.Place)
  72. {
  73. if (_temp > 10)
  74. {
  75. CheckSubstrateTemp((int)RoutineStep.CheckTemp, _temp, _timeout, _tolerance);
  76. }
  77. PMPreparePlace((int)RoutineStep.PrepareTransferPlace, _TransferType == EnumTransferType.Pick, _ws, true, _timeout);
  78. }
  79. else if (_TransferType == EnumTransferType.Pick)
  80. {
  81. PMPreparePick((int)RoutineStep.PrepareTransferPick, _TransferType == EnumTransferType.Pick, true, _timeout);
  82. }
  83. End((int)RoutineStep.kEnd);
  84. }
  85. catch (RoutineBreakException)
  86. {
  87. return Result.RUN;
  88. }
  89. catch (RoutineFaildException)
  90. {
  91. Notify("出错");
  92. return Result.FAIL;
  93. }
  94. catch (Exception ex)
  95. {
  96. Stop(ex.Message);
  97. return Result.FAIL;
  98. }
  99. Notify("结束");
  100. return Result.DONE;
  101. }
  102. public override void Abort()
  103. {
  104. }
  105. public void PMPreparePlace(int id, bool isUp, WaferSize ws, bool isOpen, int timeout)
  106. {
  107. bool Func()
  108. {
  109. Notify($"设置 liftPin {(isUp ? "升" : "降")}, 设置 {ws} Pin 升, 设置 SlitDoor {(isOpen ? "开" : "关")}");
  110. if (!_chamber.SetLiftPin(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  111. {
  112. Stop(reason);
  113. return false;
  114. }
  115. if (ws == WaferSize.WS3)
  116. {
  117. _chamber.SetGuidePin3Inch(MovementPosition.Up);
  118. _chamber.SetGuidePin4Inch(MovementPosition.Down);
  119. }
  120. else if (ws == WaferSize.WS4)
  121. {
  122. _chamber.SetGuidePin4Inch(MovementPosition.Up);
  123. _chamber.SetGuidePin3Inch(MovementPosition.Down);
  124. }
  125. else if (ws == WaferSize.WS6)
  126. {
  127. _chamber.SetGuidePin3Inch(MovementPosition.Down);
  128. _chamber.SetGuidePin4Inch(MovementPosition.Down);
  129. }
  130. _chamber.SetSlitDoor(isOpen, out string reason1);
  131. return true;
  132. }
  133. bool? Check1()
  134. {
  135. bool res1 = isUp ? _chamber.CheckLiftUp() : _chamber.CheckLiftDown();
  136. bool res2 = false;
  137. switch (ws)
  138. {
  139. case WaferSize.WS3:
  140. res2 = _chamber.Inch3Position == MovementPosition.Up && _chamber.Inch4Position == MovementPosition.Down;
  141. break;
  142. case WaferSize.WS4:
  143. res2 = _chamber.Inch4Position == MovementPosition.Up && _chamber.Inch3Position == MovementPosition.Down;
  144. break;
  145. case WaferSize.WS6:
  146. res2 = _chamber.Inch3Position == MovementPosition.Down && _chamber.Inch4Position == MovementPosition.Down;
  147. break;
  148. }
  149. bool res3 = isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose();
  150. return res1 && res2 && res3;
  151. }
  152. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeout * 1000);
  153. if (ret.Item1)
  154. {
  155. if (ret.Item2 == Result.FAIL)
  156. {
  157. throw new RoutineFaildException();
  158. }
  159. if (ret.Item2 == Result.TIMEOUT)
  160. {
  161. Stop($"无法 放片准备 in {timeout} seconds");
  162. throw new RoutineFaildException();
  163. }
  164. throw new RoutineBreakException();
  165. }
  166. }
  167. public void PMPreparePick(int id, bool isUp, bool isOpen, int timeout)
  168. {
  169. bool Func()
  170. {
  171. Notify($"设置 LiftPin {(isUp ? "升" : "降")}, 设置 SlitDoor {(isOpen ? "开" : "关")}");
  172. if (!_chamber.SetLiftPin(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  173. {
  174. Stop(reason);
  175. return false;
  176. }
  177. _chamber.SetSlitDoor(isOpen, out string reason1);
  178. return true;
  179. }
  180. bool? Check1()
  181. {
  182. bool res1 = isUp ? _chamber.CheckLiftUp() : _chamber.CheckLiftDown();
  183. bool res2 = isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose();
  184. return res1 && res2;
  185. }
  186. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeout * 1000);
  187. if (ret.Item1)
  188. {
  189. if (ret.Item2 == Result.FAIL)
  190. {
  191. throw new RoutineFaildException();
  192. }
  193. if (ret.Item2 == Result.TIMEOUT)
  194. {
  195. Stop($"无法 取片准备 in {timeout} seconds");
  196. throw new RoutineFaildException();
  197. }
  198. throw new RoutineBreakException();
  199. }
  200. }
  201. public void SetLiftPinUpDown(int id, bool isUp, int timeout)
  202. {
  203. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  204. {
  205. Notify($"设置 lift pin {_chamber.Name} " + (isUp ? "升" : "降"));
  206. if (!_chamber.SetLiftPin(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  207. {
  208. Stop(reason);
  209. return false;
  210. }
  211. return true;
  212. }, () => isUp ? _chamber.CheckLiftUp() : _chamber.CheckLiftDown(), timeout * 1000);
  213. if (ret.Item1)
  214. {
  215. if (ret.Item2 == Result.FAIL)
  216. {
  217. throw new RoutineFaildException();
  218. }
  219. else if (ret.Item2 == Result.TIMEOUT) //timeout
  220. {
  221. Stop($"无法 {(isUp ? "Up" : "Down")} lift pin in {timeout} seconds");
  222. throw new RoutineFaildException();
  223. }
  224. else
  225. throw new RoutineBreakException();
  226. }
  227. }
  228. public void SetGuidePinUp(int id, WaferSize ws, int timeout)
  229. {
  230. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  231. {
  232. Notify($"set Guide pin {_chamber.Name} " + "升");
  233. if (ws == WaferSize.WS3)
  234. {
  235. _chamber.SetGuidePin3Inch(MovementPosition.Up);
  236. _chamber.SetGuidePin4Inch(MovementPosition.Down);
  237. }
  238. else if (ws == WaferSize.WS4)
  239. {
  240. _chamber.SetGuidePin4Inch(MovementPosition.Up);
  241. _chamber.SetGuidePin3Inch(MovementPosition.Down);
  242. }
  243. else if (ws == WaferSize.WS6)
  244. {
  245. _chamber.SetGuidePin3Inch(MovementPosition.Down);
  246. _chamber.SetGuidePin4Inch(MovementPosition.Down);
  247. }
  248. return true;
  249. }, () =>
  250. {
  251. bool res = false;
  252. switch (ws)
  253. {
  254. case WaferSize.WS3:
  255. res = _chamber.Inch3Position == MovementPosition.Up && _chamber.Inch4Position == MovementPosition.Down;
  256. break;
  257. case WaferSize.WS4:
  258. res = _chamber.Inch4Position == MovementPosition.Up && _chamber.Inch3Position == MovementPosition.Down;
  259. break;
  260. case WaferSize.WS6:
  261. res = _chamber.Inch3Position == MovementPosition.Down && _chamber.Inch4Position == MovementPosition.Down;
  262. break;
  263. }
  264. return res;
  265. }, timeout * 1000);
  266. if (ret.Item1)
  267. {
  268. if (ret.Item2 == Result.FAIL)
  269. {
  270. throw new RoutineFaildException();
  271. }
  272. else if (ret.Item2 == Result.TIMEOUT) //timeout
  273. {
  274. Stop($"can not complete in {timeout} seconds");
  275. throw new RoutineFaildException();
  276. }
  277. else
  278. throw new RoutineBreakException();
  279. }
  280. }
  281. }
  282. }