PreProcessRoutine.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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 JetVirgoPM.Devices;
  9. using JetVirgoPM.PMs.Routines;
  10. using MECF.Framework.Common.Equipment;
  11. using MECF.Framework.Common.Routine;
  12. using MECF.Framework.Common.SubstrateTrackings;
  13. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
  14. using MECF.Framework.RT.ModuleLibrary.PMModules;
  15. namespace JetVirgoPM.PMs.RecipeExecutors
  16. {
  17. class PreProcessRoutine : PMRoutineBase
  18. {
  19. public enum Routine
  20. {
  21. DelayForTest,
  22. SetLiftPin,
  23. SetSlitDoor,
  24. CheckCoolant1Temp1,
  25. CheckCoolant1Temp2,
  26. CheckTemp1,
  27. CheckTemp2,
  28. CheckLETemp,
  29. CheckDryPump,
  30. PumpDown,
  31. SetRfMatchMode,
  32. SetElectrodeTemp,
  33. SetHeaterTemp,
  34. PinDownAndPump,
  35. End,
  36. }
  37. //---------------------------------Fields----------------------------------------
  38. //
  39. private readonly PumpDownRoutine _pumpRoutine;
  40. private readonly TemperatureControlRoutine _TempRoutine;
  41. private int _checkChamberTempTimeout = 60;
  42. private double _tolerance;
  43. private double _Chiller1OffsetTemp = 0.0f;
  44. private double _Chiller2OffsetTemp = 0.0f;
  45. private bool _bPinDownExecuted = false;
  46. private readonly int _PumpingAndPinDownTimeout = 60 * 1000;
  47. //---------------------------------Properties------------------------------------
  48. //
  49. public string CurrentRecipeBaseName { get; private set; }
  50. public string CurrentRecipeRunningName { get; private set; }
  51. public string CurrentRecipeContent { get; private set; }
  52. public string CurrentLotName { get; set; }
  53. public List<RecipeStep> CurrentRecipeStepList { get; set; }
  54. public RecipeHead CurrentRecipeHead { get; set; }
  55. private bool _withWafer;
  56. public bool _Chamber1Disabled;
  57. public bool _Chamber2Disabled;
  58. private bool _enableChiller1;
  59. private bool _enableChiller2;
  60. private bool _enableLE1;
  61. private bool _enableLE2;
  62. private int _pumpBasePressure;
  63. private double _pumpTimeLimit;
  64. private double BasePressure
  65. {
  66. get
  67. {
  68. if (CurrentRecipeHead != null)
  69. {
  70. if (!string.IsNullOrEmpty(CurrentRecipeHead.BasePressure))
  71. {
  72. double setpoint = Convert.ToDouble(CurrentRecipeHead.BasePressure);
  73. if (setpoint > 0 && setpoint < 750000)
  74. return setpoint;
  75. }
  76. }
  77. return _pumpBasePressure;
  78. }
  79. }
  80. private double PumpDownLimit
  81. {
  82. get
  83. {
  84. if (CurrentRecipeHead != null)
  85. {
  86. if (!string.IsNullOrEmpty(CurrentRecipeHead.PumpDownLimit))
  87. {
  88. double setpoint = Convert.ToDouble(CurrentRecipeHead.PumpDownLimit);
  89. if (setpoint > 0 && setpoint < 600)
  90. return setpoint;
  91. }
  92. }
  93. return _pumpTimeLimit;
  94. }
  95. }
  96. public bool PumpingPinIsUp
  97. {
  98. get
  99. {
  100. if (CurrentRecipeHead != null)
  101. {
  102. if (!string.IsNullOrEmpty(CurrentRecipeHead.PumpingPinState))
  103. {
  104. return CurrentRecipeHead.PumpingPinState == "Up" ? true : false;
  105. }
  106. }
  107. return false;
  108. }
  109. }
  110. public double Chamber1Temp
  111. {
  112. get
  113. {
  114. if (CurrentRecipeHead != null)
  115. {
  116. if (!string.IsNullOrEmpty(CurrentRecipeHead.Chamber1Temperature))
  117. {
  118. double setpoint = Convert.ToDouble(CurrentRecipeHead.Chamber1Temperature);
  119. if (setpoint > 0 && setpoint < 600)
  120. return setpoint;
  121. }
  122. }
  123. return 0;
  124. }
  125. }
  126. public double Chamber2Temp
  127. {
  128. get
  129. {
  130. if (CurrentRecipeHead != null)
  131. {
  132. if (!string.IsNullOrEmpty(CurrentRecipeHead.Chamber2Temperature))
  133. {
  134. double setpoint = Convert.ToDouble(CurrentRecipeHead.Chamber2Temperature);
  135. if (setpoint > 0 && setpoint < 600)
  136. return setpoint;
  137. }
  138. }
  139. return 0;
  140. }
  141. }
  142. private int PinDownPressure
  143. {
  144. get
  145. {
  146. if (CurrentRecipeHead != null)
  147. {
  148. if (!string.IsNullOrEmpty(CurrentRecipeHead.PinDownPressure))
  149. {
  150. int setpoint = Convert.ToInt32(CurrentRecipeHead.PinDownPressure);
  151. if (setpoint > 0)
  152. return setpoint;
  153. }
  154. }
  155. return 1000;
  156. }
  157. }
  158. //--------------------------------Constructor------------------------------------
  159. //
  160. public PreProcessRoutine(JetDualPM chamber, PumpDownRoutine pdr) : base(chamber)
  161. {
  162. Name = "Pre Process";
  163. _pumpRoutine = pdr;
  164. }
  165. public void Terminate()
  166. {
  167. }
  168. public RState LoadRecipe(params object[] param)
  169. {
  170. CurrentRecipeBaseName = (string)param[0];
  171. if (param.Length > 1)
  172. WaferID = (string)param[1];
  173. else
  174. WaferID = null;
  175. if (param.Length > 2)
  176. _withWafer = (bool)param[2];
  177. else
  178. _withWafer = true;
  179. if (_withWafer && WaferManager.Instance.CheckNoWafer(Module, 0) && WaferManager.Instance.CheckNoWafer(Module, 1))
  180. {
  181. EV.PostWarningLog(Module.ToString(), $"can not load recipe, no wafer at {Module}");
  182. return RState.Failed;
  183. }
  184. CurrentRecipeContent = RecipeFileManager.Instance.LoadRecipe("", CurrentRecipeBaseName, true);
  185. if (string.IsNullOrEmpty(CurrentRecipeContent))
  186. {
  187. EV.PostInfoLog(ModuleName.System.ToString(), $"error during read recipe file {CurrentRecipeBaseName}");
  188. return RState.Failed;
  189. }
  190. if (!RecipeFileManager.Instance.CheckRecipe(Module, CurrentRecipeContent, out var reasons))
  191. {
  192. EV.PostAlarmLog(Module, $"recipe file content not valid {CurrentRecipeBaseName}");
  193. string info = "";
  194. foreach (var item in reasons)
  195. info += item;
  196. EV.PostPopDialogMessage(EventLevel.Alarm, "recipe file not valid", info);
  197. }
  198. CurrentRecipeRunningName = $"{CurrentRecipeBaseName}";
  199. if (!Recipe.Parse(Module, CurrentRecipeContent, out RecipeHead recipeHead, out var recipeSteps))
  200. {
  201. return RState.Failed;
  202. }
  203. CurrentRecipeStepList = recipeSteps;
  204. CurrentRecipeHead = recipeHead;
  205. return RState.End;
  206. }
  207. public RState Start(params object[] param)
  208. {
  209. if (_withWafer && WaferManager.Instance.CheckNoWafer(Module, 0) && WaferManager.Instance.CheckNoWafer(Module, 1))
  210. {
  211. EV.PostWarningLog(Module.ToString(), $"can not run process, no wafer at {Module}");
  212. return RState.Failed;
  213. }
  214. //if (CheckSlitDoor1() != Result.RUN||CheckSlitDoor2() != Result.RUN || CheckDryPump() != Result.RUN)
  215. //{
  216. // return Result.FAIL;
  217. //}
  218. if (CheckDryPump() != RState.Running)
  219. {
  220. return RState.Failed;
  221. }
  222. _chamber.SetGenerator1CommunicationMode(1); // RS232 mode
  223. _chamber.SetGenerator2CommunicationMode(1); // RS232 mode
  224. _Chamber1Disabled = _chamber.Chamber1Disable;
  225. _Chamber2Disabled = _chamber.Chamber2Disable;
  226. _enableChiller1 = _chamber.Chiller1Enable;
  227. _enableChiller2 = _chamber.Chiller2Enable;
  228. _pumpBasePressure = SC.GetValue<int>($"{Module}.Pump.PumpBasePressure");
  229. _pumpTimeLimit = SC.GetValue<double>($"{Module}.Pump.PumpTimeLimit");
  230. _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceToTarget");
  231. _Chiller1OffsetTemp = SC.GetValue<double>($"{Module}.Chiller1.ChillerTemperatureOffset");
  232. _Chiller2OffsetTemp = SC.GetValue<double>($"{Module}.Chiller2.ChillerTemperatureOffset");
  233. try
  234. {
  235. if (BasePressure <= 0 || BasePressure >= 760000)
  236. {
  237. return RState.Failed;
  238. }
  239. if (PumpDownLimit <= 0.01 || PumpDownLimit >= 600)
  240. {
  241. return RState.Failed;
  242. }
  243. _checkChamberTempTimeout = SC.GetValue<int>($"{Module}.CheckChamberTempTimeout");
  244. Reset();
  245. //RecipeRunGuid = Guid.NewGuid();
  246. //ProcessDataRecorder.Start(RecipeRunGuid.ToString(), CurrentRecipeRunningName.Split('\\')[1], WaferID, CurrentRecipeRunningName.Split('\\')[0]);
  247. //RecipeFileManager.Instance.SaveRecipeHistory(ModuleName.System.ToString(), CurrentRecipeRunningName, CurrentRecipeContent);
  248. }
  249. catch (Exception ex)
  250. {
  251. LOG.Write(ex, "Preprocess Start has exception");
  252. throw ex;
  253. }
  254. _bPinDownExecuted = false;
  255. _enableLE1 = true;
  256. _enableLE2 = true;
  257. return Runner.Start(_chamber.Module.ToString(), Name);
  258. }
  259. public RState Monitor()
  260. {
  261. Runner.Run(Routine.SetSlitDoor, HOFs.Apply(SetSlitDoor, EnumDualPM.Both, false), HOFs.Apply(CheckSlitDoor, EnumDualPM.Both, false), 5000)
  262. .Run(Routine.PinDownAndPump, PumpStart, CheckPumpAndPinDown, _delay_60s)
  263. .Run(Routine.CheckCoolant1Temp1, SetCoolant1Temp, CheckCoolant1Temp, _checkChamberTempTimeout * 1000)
  264. .Run(Routine.CheckCoolant1Temp2, SetCoolant2Temp, CheckCoolant2Temp, _checkChamberTempTimeout * 1000)
  265. .Run(Routine.CheckLETemp, SetLETemp, CheckLETemp, _checkChamberTempTimeout * 1000)
  266. .Run(Routine.CheckTemp1, SetLETemp1, CheckLETemp1, _checkChamberTempTimeout * 1000)
  267. .Run(Routine.CheckTemp2, SetLETemp2, CheckLETemp2, _checkChamberTempTimeout * 1000)
  268. .End(Routine.End, EndFunc, _delay_50ms);
  269. return Runner.Status;
  270. }
  271. public void Exit()
  272. { }
  273. bool PumpStart()
  274. {
  275. return _pumpRoutine.Start(BasePressure) == RState.Running;
  276. }
  277. bool CheckPumpAndPinDown()
  278. {
  279. if (!_bPinDownExecuted && !PumpingPinIsUp && ((_chamber.ChamberPressure <= PinDownPressure) || (PinDownPressure <= BasePressure)))
  280. {
  281. _bPinDownExecuted = true;
  282. Notify($"设置 lift pin {_chamber.Name} " + "降" + $"抽气时降顶针:PinDownPressure{PinDownPressure.ToString()},ChamberPressurePressure{_chamber.ChamberPressurePressure.ToString()}" + $",BasePressure{BasePressure.ToString()}");
  283. if (!_Chamber1Disabled && !_chamber.SetLiftPin1(MovementPosition.Down, out string reasonPin1))
  284. {
  285. Stop(reasonPin1);
  286. return false;
  287. }
  288. if (!_Chamber2Disabled && !_chamber.SetLiftPin2(MovementPosition.Down, out string reasonPin2))
  289. {
  290. Stop(reasonPin2);
  291. return false;
  292. }
  293. }
  294. bool res1 = _Chamber1Disabled || _chamber.CheckLift1Down();
  295. bool res2 = _Chamber2Disabled || _chamber.CheckLift2Down();
  296. var result = _pumpRoutine.Monitor();
  297. if(result == RState.Failed || result == RState.Timeout)
  298. {
  299. Runner.Stop($"设置 Pump {_chamber.Name} failed " + $"抽气时降顶针:PinDownPressure{PinDownPressure.ToString()},ChamberPressurePressure{_chamber.ChamberPressurePressure.ToString()}" + $",BasePressure{BasePressure.ToString()}");
  300. return true;
  301. }
  302. return (PumpingPinIsUp || (res1 && res2)) && (result == RState.End);
  303. }
  304. bool SetCoolant1Temp()
  305. {
  306. if (!SC.IsATMMode && _enableChiller1 && !_Chamber1Disabled && Chamber1Temp > 0)
  307. {
  308. _enableLE1 = false;
  309. return SetCoolant1Temp(Chamber1Temp, _Chiller1OffsetTemp, _tolerance);
  310. }
  311. return true;
  312. }
  313. bool CheckCoolant1Temp()
  314. {
  315. if (!SC.IsATMMode && _enableChiller1 && !_Chamber1Disabled && Chamber1Temp > 0)
  316. {
  317. return CheckCoolant1Temp(Chamber1Temp, _Chiller1OffsetTemp, _tolerance);
  318. }
  319. return true;
  320. }
  321. bool SetCoolant2Temp()
  322. {
  323. if (!SC.IsATMMode && _enableChiller2 && !_Chamber2Disabled && Chamber2Temp > 0)
  324. {
  325. _enableLE2 = false;
  326. return SetCoolant2Temp(Chamber2Temp, _Chiller2OffsetTemp, _tolerance);
  327. }
  328. return true;
  329. }
  330. bool CheckCoolant2Temp()
  331. {
  332. if (!SC.IsATMMode && _enableChiller2 && !_Chamber2Disabled && Chamber2Temp > 0)
  333. {
  334. return CheckCoolant2Temp(Chamber2Temp, _Chiller2OffsetTemp, _tolerance);
  335. }
  336. return true;
  337. }
  338. bool SetLETemp()
  339. {
  340. if (!SC.IsATMMode && (_enableLE1 && !_Chamber1Disabled && Chamber1Temp > 0) && (_enableLE2 && !_Chamber2Disabled && Chamber2Temp > 0))
  341. {
  342. return SetLETemp(Chamber1Temp, Chamber2Temp, _tolerance, _enableLE1, _enableLE2);
  343. }
  344. return true;
  345. }
  346. bool CheckLETemp()
  347. {
  348. if (!SC.IsATMMode && (_enableLE1 && !_Chamber1Disabled && Chamber1Temp > 0) && (_enableLE2 && !_Chamber2Disabled && Chamber2Temp > 0))
  349. {
  350. return CheckLETemp(Chamber1Temp, Chamber2Temp, _tolerance, _enableLE1, _enableLE2);
  351. }
  352. return true;
  353. }
  354. bool SetLETemp1()
  355. {
  356. if (!SC.IsATMMode && _enableLE1 && !_Chamber1Disabled && Chamber1Temp > 0)
  357. {
  358. return SetLETemp(Chamber1Temp, 0, _tolerance, _enableLE1, false);
  359. }
  360. return true;
  361. }
  362. bool CheckLETemp1()
  363. {
  364. if (!SC.IsATMMode && _enableLE1 && !_Chamber1Disabled && Chamber1Temp > 0)
  365. {
  366. return CheckLETemp(Chamber1Temp, 0, _tolerance, _enableLE1, false);
  367. }
  368. return true;
  369. }
  370. bool SetLETemp2()
  371. {
  372. if (!SC.IsATMMode && _enableLE2 && !_Chamber2Disabled && Chamber2Temp > 0)
  373. {
  374. return SetLETemp(0, Chamber2Temp, _tolerance, false, _enableLE2);
  375. }
  376. return true;
  377. }
  378. bool CheckLETemp2()
  379. {
  380. if (!SC.IsATMMode && _enableLE2 && !_Chamber2Disabled && Chamber2Temp > 0)
  381. {
  382. return CheckLETemp(0, Chamber2Temp, _tolerance, false, _enableLE2);
  383. }
  384. return true;
  385. }
  386. }
  387. }