PreProcess.cs 11 KB

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