PreProcess.cs 11 KB

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