PreProcessRoutine.cs 16 KB

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