PreProcess.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.RecipeCenter;
  6. using Aitex.Core.RT.Routine;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.Util;
  9. using MECF.Framework.Common.DBCore;
  10. using MECF.Framework.Common.Equipment;
  11. using Virgo_DCommon;
  12. using Virgo_DRT.Devices;
  13. namespace Virgo_DRT.Modules.PMs
  14. {
  15. class PreProcessRoutine : PMRoutineBase
  16. {
  17. public enum Routine
  18. {
  19. SetSlitDoor,
  20. PinDownAndPump,
  21. DelayForTest,
  22. CheckDoor,
  23. CheckDryPump,
  24. PumpDown,
  25. SetRfMatchMode,
  26. SetElectrodeTemp,
  27. SetHeaterTemp,
  28. SetLiftPin,
  29. End,
  30. }
  31. //---------------------------------Fields----------------------------------------
  32. //
  33. private readonly PumpDownRoutine _pumpRoutine;
  34. private readonly TemperatureControlRoutine _TempRoutine;
  35. private int _checkSubstrateTempTimeout = 60;
  36. private double _tolerance;
  37. //---------------------------------Properties------------------------------------
  38. //
  39. public string CurrentRecipeBaseName { get; private set; }
  40. public string CurrentRecipeRunningName { get; private set; }
  41. public string CurrentRecipeContent { get; private set; }
  42. public string CurrentLotName { get; set; }
  43. public List<RecipeStep> CurrentRecipeStepList { get; set; }
  44. public RecipeHead CurrentRecipeHead { get; set; }
  45. private bool _bPinDownExecuted = false;
  46. private readonly int _PumpingAndPinDownTimeout = 60 * 1000;
  47. private int _timeout;
  48. private double BasePressure
  49. {
  50. get
  51. {
  52. if (CurrentRecipeHead != null)
  53. {
  54. if (!string.IsNullOrEmpty(CurrentRecipeHead.BasePressure))
  55. {
  56. double setpoint = Convert.ToDouble(CurrentRecipeHead.BasePressure);
  57. if (setpoint > 0 && setpoint < 750000)
  58. return setpoint;
  59. }
  60. }
  61. return SC.GetValue<int>($"{Module}.Pump.PumpBasePressure");
  62. }
  63. }
  64. private double PumpDownLimit
  65. {
  66. get
  67. {
  68. if (CurrentRecipeHead != null)
  69. {
  70. if (!string.IsNullOrEmpty(CurrentRecipeHead.PumpDownLimit))
  71. {
  72. double setpoint = Convert.ToDouble(CurrentRecipeHead.PumpDownLimit);
  73. if (setpoint > 0 && setpoint < 600)
  74. return setpoint;
  75. }
  76. }
  77. return SC.GetValue<double>($"{Module}.Pump.PumpTimeLimit");
  78. }
  79. }
  80. public double SubstrateTemp
  81. {
  82. get
  83. {
  84. if (CurrentRecipeHead != null)
  85. {
  86. if (!string.IsNullOrEmpty(CurrentRecipeHead.SubstrateTemp))
  87. {
  88. double setpoint = Convert.ToDouble(CurrentRecipeHead.SubstrateTemp);
  89. if (setpoint > 0 && setpoint < 600)
  90. return setpoint;
  91. }
  92. }
  93. return 0;
  94. }
  95. }
  96. private int PinDownPressure
  97. {
  98. get
  99. {
  100. if (CurrentRecipeHead != null)
  101. {
  102. if (!string.IsNullOrEmpty(CurrentRecipeHead.PinDownPressure))
  103. {
  104. int setpoint = Convert.ToInt32(CurrentRecipeHead.PinDownPressure);
  105. if (setpoint > 0)
  106. return setpoint;
  107. }
  108. }
  109. return 1000;
  110. }
  111. }
  112. public bool PumpingPinIsUp
  113. {
  114. get
  115. {
  116. if (CurrentRecipeHead != null)
  117. {
  118. if (!string.IsNullOrEmpty(CurrentRecipeHead.PumpingPinState))
  119. {
  120. return CurrentRecipeHead.PumpingPinState == "Up" ? true : false;
  121. }
  122. }
  123. return false;
  124. }
  125. }
  126. //--------------------------------Constructor------------------------------------
  127. //
  128. public PreProcessRoutine(JetPM chamber, PumpDownRoutine pdr) : base(chamber)
  129. {
  130. Name = "Pre Process";
  131. _pumpRoutine = pdr;
  132. }
  133. public void Terminate()
  134. {
  135. }
  136. public Result LoadRecipe(params object[] param)
  137. {
  138. CurrentRecipeBaseName = (string)param[0];
  139. CurrentRecipeContent = RecipeFileManager.Instance.LoadRecipe("", CurrentRecipeBaseName, true);
  140. if (string.IsNullOrEmpty(CurrentRecipeContent))
  141. {
  142. EV.PostInfoLog(ModuleName.System.ToString(), $"error during read recipe file {CurrentRecipeBaseName}");
  143. return Result.FAIL;
  144. }
  145. if (!RecipeFileManager.Instance.CheckRecipe(ModuleName.System.ToString(), CurrentRecipeContent, out var reasons))
  146. {
  147. EV.PostAlarmLog(Module, $"recipe file content not valid {CurrentRecipeBaseName}");
  148. string info = "";
  149. foreach (var item in reasons)
  150. info += item;
  151. EV.PostPopDialogMessage(EventLevel.Alarm, "recipe file not valid", info);
  152. }
  153. CurrentRecipeRunningName = $"{CurrentRecipeBaseName}";
  154. if (!Recipe.Parse(CurrentRecipeContent, out RecipeHead recipeHead, out var recipeSteps))
  155. {
  156. return Result.FAIL;
  157. }
  158. CurrentRecipeStepList = recipeSteps;
  159. CurrentRecipeHead = recipeHead;
  160. return Result.DONE;
  161. }
  162. public Result Start(params object[] param)
  163. {
  164. if (CheckSlitDoor() != Result.RUN || CheckDryPump() != Result.RUN)
  165. {
  166. return Result.FAIL;
  167. }
  168. _chamber.SetGeneratorCommunicationMode(1); // RS232 mode
  169. _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceToTarget");
  170. try
  171. {
  172. _timeout = SC.GetValue<int>($"{Module}.PrepareTransferTimeout");
  173. if (BasePressure <= 0 || BasePressure >= 760000)
  174. {
  175. return Result.FAIL;
  176. }
  177. if (PumpDownLimit <= 0.01 || PumpDownLimit >= 600)
  178. {
  179. return Result.FAIL;
  180. }
  181. _checkSubstrateTempTimeout = SC.GetValue<int>($"{Module}.CheckSubstrateTempTimeout");
  182. Reset();
  183. RecipeRunGuid = Guid.NewGuid();
  184. ProcessDataRecorder.Start(RecipeRunGuid.ToString(), CurrentRecipeRunningName.Split('\\')[1], null, CurrentRecipeRunningName.Split('\\')[0]);
  185. //RecipeFileManager.Instance.SaveRecipeHistory(ModuleName.System.ToString(), CurrentRecipeRunningName, CurrentRecipeContent);
  186. }
  187. catch (Exception ex)
  188. {
  189. LOG.Write(ex, "Preprocess Start has exception");
  190. throw ex;
  191. }
  192. Notify("开始");
  193. _bPinDownExecuted = false;
  194. return Result.RUN;
  195. }
  196. public Result Monitor()
  197. {
  198. try
  199. {
  200. CloseSlitDoor((int)Routine.SetSlitDoor, _timeout);
  201. CheckSubstrateTemp((int)Routine.CheckDoor, SubstrateTemp, _checkSubstrateTempTimeout, _tolerance);
  202. ParallellyPumpAndPinDown((int)Routine.PinDownAndPump);
  203. // pump down
  204. //ExecuteRoutine((int)Routine.PumpDown, _pumpRoutine);
  205. //设置RF Match Mode
  206. //SetRfMatchMode((int)Routine.SetRfMatchMode, string.Format(Resources.PreProcess_Monitor_SetRFMatchMode, _rfMatchModeDuringProcess==(int)Virgo_DRfMatchMode.Manual ? "Manual" : "Auto"), _rfMatchModeDuringProcess);
  207. //SetLiftPinUpDown((int)Routine.SetLiftPin, PumpingPinIsUp, 5000);
  208. End((int)Routine.End);
  209. }
  210. catch (RoutineBreakException)
  211. {
  212. return Result.RUN;
  213. }
  214. catch (RoutineFaildException)
  215. {
  216. return Result.FAIL;
  217. }
  218. catch (Exception ex)
  219. {
  220. Stop(ex.Message);
  221. return Result.FAIL;
  222. }
  223. Notify("结束");
  224. return Result.DONE;
  225. }
  226. public void Exit()
  227. { }
  228. protected void CloseSlitDoor(int id, int timeout)
  229. {
  230. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  231. {
  232. Notify($"设置传送门 {_chamber.Name} " + (false ? "开" : "关"));
  233. if (!_chamber.CheckSlitDoorClose())
  234. {
  235. _chamber.SetSlitDoor(false, out _);
  236. }
  237. return true;
  238. }, () => _chamber.CheckSlitDoorClose(), timeout * 1000);
  239. if (ret.Item1)
  240. {
  241. if (ret.Item2 == Result.FAIL)
  242. {
  243. throw new RoutineFaildException();
  244. }
  245. else if (ret.Item2 == Result.TIMEOUT) //timeout
  246. {
  247. Stop($"无法关传送门 in {timeout} seconds");
  248. throw new RoutineFaildException();
  249. }
  250. else
  251. throw new RoutineBreakException();
  252. }
  253. }
  254. private void ParallellyPumpAndPinDown(int id)
  255. {
  256. bool Func()
  257. {
  258. _pumpRoutine.Start(BasePressure);
  259. return true;
  260. }
  261. bool? Check1()
  262. {
  263. if (!_bPinDownExecuted)
  264. {
  265. if ((PumpingPinIsUp == false) && ((_chamber.ChamberPressure <= PinDownPressure) || (PinDownPressure <= BasePressure)))
  266. {
  267. _bPinDownExecuted = true;
  268. Notify($"设置 lift pin {_chamber.Name} " + "降");
  269. if (!_chamber.SetLiftPin(MovementPosition.Down, out string reason))
  270. {
  271. Stop(reason);
  272. return false;
  273. }
  274. }
  275. }
  276. bool res1 = _chamber.CheckLiftDown();
  277. var result = _pumpRoutine.Monitor();
  278. return (res1 || PumpingPinIsUp) && (result == Result.DONE);
  279. }
  280. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, _PumpingAndPinDownTimeout);
  281. if (ret.Item1)
  282. {
  283. if (ret.Item2 == Result.FAIL)
  284. {
  285. throw new RoutineFaildException();
  286. }
  287. if (ret.Item2 == Result.TIMEOUT)
  288. {
  289. Stop(!_chamber.CheckLiftDown() ? $"Set Pin Down timeout in {_PumpingAndPinDownTimeout / 1000} seconds" : $"Pumping timeout in {_PumpingAndPinDownTimeout / 1000} seconds");
  290. throw new RoutineFaildException();
  291. }
  292. throw new RoutineBreakException();
  293. }
  294. }
  295. }
  296. }