PreProcess.cs 12 KB

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