PMGaslinePurgeRoutine.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Venus_RT.Devices;
  4. using MECF.Framework.Common.Routine;
  5. using Venus_Core;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System;
  9. namespace Venus_RT.Modules.PMs
  10. {
  11. class PMGaslinePurgeRoutine : PMRoutineBase, IRoutine
  12. {
  13. private enum GaslinePurgeStep
  14. {
  15. kPreTurnValves,
  16. kOpenPVN21_PV12_1,
  17. kFlowMFC1_2,
  18. kClosePV12_3,
  19. kOpenPV22_4,
  20. kFlowMFC2_5,
  21. kClosePV22_6,
  22. kOpenPV32_7,
  23. kFlowMFC3_8,
  24. kClosePV32_9,
  25. kOpenPV42_10,
  26. kFlowMFC4_11,
  27. kClosePV42_12,
  28. kClosePVN21_13,
  29. kOpenMFC1_14,
  30. kCloseMFC1_15,
  31. kOpenMFC2_16,
  32. kCloseMFC2_17,
  33. kOpenMFC3_18,
  34. kCloseMFC3_19,
  35. kOpenMFC4_20,
  36. kCloseMFC4_21,
  37. kEnd,
  38. }
  39. private enum NewGaslinePurgeStep
  40. {
  41. kWaitPendulumValveClose,
  42. kClosePumpingValve,
  43. kPreTurnValves,
  44. kStartPurge,
  45. kPumpGasLines,
  46. kStopPumpGasLines,
  47. kPurgeGasLines,
  48. kStopPurgeGasLines,
  49. kCloseAllValves,
  50. kPumpDown,
  51. kEnd,
  52. }
  53. public int PurgeCounter { get; private set; }
  54. private int _gasPurgeFlowTime = 5;
  55. private int _gasPurgePumpTime = 10;
  56. private int _gasPurgeCycleCount = 30;
  57. private readonly double _GasFlow = 1.0;
  58. bool Flow_MFC1() => _chamber.FlowGas(1, _GasFlow);
  59. bool Flow_MFC2() => _chamber.FlowGas(2, _GasFlow);
  60. bool Flow_MFC3() => _chamber.FlowGas(3, _GasFlow);
  61. bool Flow_MFC4() => _chamber.FlowGas(4, _GasFlow);
  62. private string[] _gasLineNums;
  63. private bool IsVenus = false;
  64. private int _currentIndex = 0;
  65. private int _gasPurgeAllCycleCount = 0;
  66. private PumpDownRoutine _pumpDownRoutine;
  67. public PMGaslinePurgeRoutine(JetPMBase chamber, PumpDownRoutine pdRoutine) : base(chamber)
  68. {
  69. Name = "GasLine Purge";
  70. _pumpDownRoutine = pdRoutine;
  71. }
  72. public RState Start(params object[] objs)
  73. {
  74. if (CheckLid() &&
  75. CheckSlitDoor() &&
  76. CheckDryPump())
  77. {
  78. _gasPurgeFlowTime = SC.GetValue<int>($"{Module}.Purge.GasPurgeFlowTime");
  79. _gasPurgePumpTime = SC.GetValue<int>($"{Module}.Purge.GasPurgePumpTime");
  80. _gasPurgeCycleCount = SC.GetValue<int>($"{Module}.Purge.GasPurgeCycleCount");
  81. Reset();
  82. PreTurnValves();
  83. _gasLineNums = objs[0].ToString().Split(',');
  84. switch (_chamber.ChamberType)
  85. {
  86. case JetChamber.VenusSE:
  87. case JetChamber.VenusDE:
  88. _gasPurgeAllCycleCount = _gasPurgeCycleCount* _gasLineNums.Count();
  89. _currentIndex = 0;
  90. IsVenus = true;
  91. break;
  92. default:
  93. IsVenus = false;
  94. break;
  95. }
  96. PurgeCounter = 0;
  97. return Runner.Start(Module, Name);
  98. }
  99. return RState.Failed;
  100. }
  101. public RState Monitor()
  102. {
  103. //Runner.Delay(GaslinePurgeStep.kPreTurnValves, _delay_1s)
  104. // .LoopStart(GaslinePurgeStep.kOpenPVN21_PV12_1, "Gas Purge Cycle", _gasPurgeCycleCount, OpenPVN21_PV12, _delay_1s)
  105. // .LoopRun(GaslinePurgeStep.kFlowMFC1_2, Flow_MFC1, _gasPurgeFlowTime * 1000)
  106. // .LoopRun(GaslinePurgeStep.kClosePV12_3, HOFs.WrapAction(_chamber.OpenValve, ValveType.PV12, false), _delay_1s)
  107. // .LoopRun(GaslinePurgeStep.kOpenPV22_4, HOFs.WrapAction(_chamber.OpenValve, ValveType.PV22, true), _delay_1s)
  108. // .LoopRun(GaslinePurgeStep.kFlowMFC2_5, Flow_MFC2, _gasPurgeFlowTime * 1000)
  109. // .LoopRun(GaslinePurgeStep.kClosePV22_6, HOFs.WrapAction(_chamber.OpenValve, ValveType.PV22, false), _delay_1s)
  110. // .LoopRun(GaslinePurgeStep.kOpenPV32_7, HOFs.WrapAction(_chamber.OpenValve, ValveType.PV32, true), _delay_1s)
  111. // .LoopRun(GaslinePurgeStep.kFlowMFC3_8, Flow_MFC3, _gasPurgeFlowTime * 1000)
  112. // .LoopRun(GaslinePurgeStep.kClosePV32_9, HOFs.WrapAction(_chamber.OpenValve, ValveType.PV32, false), _delay_1s)
  113. // .LoopRun(GaslinePurgeStep.kOpenPV42_10, HOFs.WrapAction(_chamber.OpenValve, ValveType.PV42, true), _delay_1s)
  114. // .LoopRun(GaslinePurgeStep.kFlowMFC4_11, Flow_MFC4, _gasPurgeFlowTime * 1000)
  115. // .LoopRun(GaslinePurgeStep.kClosePV42_12, HOFs.WrapAction(_chamber.OpenValve, ValveType.PV42, false), _delay_1s)
  116. // .LoopRun(GaslinePurgeStep.kClosePVN21_13, HOFs.WrapAction(_chamber.OpenValve, ValveType.PV21, false), _delay_1s)
  117. // .LoopRun(GaslinePurgeStep.kOpenMFC1_14, HOFs.WrapAction(_chamber.OpenValve, ValveType.Mfc1, true), _gasPurgePumpTime * 1000)
  118. // .LoopRun(GaslinePurgeStep.kCloseMFC1_15, HOFs.WrapAction(_chamber.OpenValve, ValveType.Mfc1, false), _delay_1s)
  119. // .LoopRun(GaslinePurgeStep.kOpenMFC2_16, HOFs.WrapAction(_chamber.OpenValve, ValveType.Mfc2, true), _gasPurgePumpTime * 1000)
  120. // .LoopRun(GaslinePurgeStep.kCloseMFC2_17, HOFs.WrapAction(_chamber.OpenValve, ValveType.Mfc2, false), _delay_1s)
  121. // .LoopRun(GaslinePurgeStep.kOpenMFC3_18, HOFs.WrapAction(_chamber.OpenValve, ValveType.Mfc3, true), _gasPurgePumpTime * 1000)
  122. // .LoopRun(GaslinePurgeStep.kCloseMFC3_19, HOFs.WrapAction(_chamber.OpenValve, ValveType.Mfc3, false), _delay_1s)
  123. // .LoopRun(GaslinePurgeStep.kOpenMFC4_20, HOFs.WrapAction(_chamber.OpenValve, ValveType.Mfc4, true), _gasPurgePumpTime * 1000)
  124. // .LoopEnd(GaslinePurgeStep.kCloseMFC4_21, StopAllGas, _delay_1s)
  125. // .End(GaslinePurgeStep.kEnd, NullFun, _delay_50ms);
  126. if (!IsVenus)
  127. {
  128. Runner.Delay(NewGaslinePurgeStep.kPreTurnValves, _delay_1s)
  129. .LoopStart(NewGaslinePurgeStep.kStartPurge, "Gas Purge Cycle", _gasPurgeCycleCount, PreparePurge, _delay_1s)
  130. .LoopRun(NewGaslinePurgeStep.kPumpGasLines, StartPump, _gasPurgePumpTime * 1000)
  131. .LoopRun(NewGaslinePurgeStep.kStopPumpGasLines, StopPump)
  132. .LoopRun(NewGaslinePurgeStep.kPurgeGasLines, StartPurge, _gasPurgeFlowTime * 1000)
  133. .LoopRun(NewGaslinePurgeStep.kStopPurgeGasLines, StopPurge)
  134. .LoopEnd(NewGaslinePurgeStep.kCloseAllValves, StopAllGas, _delay_1s)
  135. .End(GaslinePurgeStep.kEnd, NullFun, _delay_50ms);
  136. }
  137. else
  138. {
  139. Runner.Wait(NewGaslinePurgeStep.kWaitPendulumValveClose,()=>!_chamber.IsPenVOpen)
  140. .Run(NewGaslinePurgeStep.kClosePumpingValve, ClosePumping, _delay_1s)
  141. .Delay(NewGaslinePurgeStep.kPreTurnValves, _delay_1s)
  142. .LoopStart(NewGaslinePurgeStep.kStartPurge, "Gas Purge Cycle", _gasPurgeAllCycleCount, PreparePurge, _delay_1s)
  143. .LoopRun(NewGaslinePurgeStep.kPumpGasLines, StartPumpWithIndex, _gasPurgePumpTime * 1000)
  144. .LoopRun(NewGaslinePurgeStep.kStopPumpGasLines, StopPumpWithIndex)
  145. .LoopRun(NewGaslinePurgeStep.kPurgeGasLines, StartPurgeWithIndex, _gasPurgeFlowTime * 1000)
  146. .LoopRun(NewGaslinePurgeStep.kStopPurgeGasLines, StopPurgeWithIndex)
  147. .LoopEnd(NewGaslinePurgeStep.kCloseAllValves, StopAllGas, _delay_1s)
  148. .Run(NewGaslinePurgeStep.kPumpDown,StartPumpDown,PumpDownOver)
  149. .End(GaslinePurgeStep.kEnd, NullFun, _delay_50ms);
  150. }
  151. return Runner.Status;
  152. }
  153. private bool ClosePumping()
  154. {
  155. _chamber.OpenValve(ValveType.TurboPumpPumping,false);
  156. return true;
  157. }
  158. private bool StartPumpDown()
  159. {
  160. return _pumpDownRoutine.Start() == RState.Running;
  161. }
  162. private bool PumpDownOver()
  163. {
  164. return _pumpDownRoutine.Monitor() == RState.End;
  165. }
  166. private bool StopPurgeWithIndex()
  167. {
  168. int idx = Convert.ToInt32(_gasLineNums[_currentIndex / _gasPurgeCycleCount]);
  169. _chamber.OpenValve(ValveType.PVN22, false);
  170. _chamber.OpenValve(ValveType.PVN21, false);
  171. _chamber.StopGas(idx);
  172. switch (idx)
  173. {
  174. case 0:
  175. _chamber.OpenValve(ValveType.PV12, false);
  176. break;
  177. case 1:
  178. _chamber.OpenValve(ValveType.PV22, false);
  179. break;
  180. case 2:
  181. _chamber.OpenValve(ValveType.PV32, false);
  182. break;
  183. case 3:
  184. _chamber.OpenValve(ValveType.PV42, false);
  185. break;
  186. case 4:
  187. _chamber.OpenValve(ValveType.PV52, false);
  188. break;
  189. case 5:
  190. _chamber.OpenValve(ValveType.PV62, false);
  191. break;
  192. case 6:
  193. _chamber.OpenValve(ValveType.PV72, false);
  194. break;
  195. case 7:
  196. _chamber.OpenValve(ValveType.PV82, false);
  197. break;
  198. case 8:
  199. _chamber.OpenValve(ValveType.PV92, false);
  200. break;
  201. case 9:
  202. _chamber.OpenValve(ValveType.PVA2, false);
  203. break;
  204. case 10:
  205. _chamber.OpenValve(ValveType.PVB2, false);
  206. break;
  207. case 11:
  208. _chamber.OpenValve(ValveType.PVC2, false);
  209. break;
  210. }
  211. _currentIndex++;
  212. return true;
  213. }
  214. private bool StartPurgeWithIndex()
  215. {
  216. int idx = Convert.ToInt32(_gasLineNums[_currentIndex / _gasPurgeCycleCount]);
  217. _chamber.OpenValve(ValveType.PVN22, true);
  218. _chamber.OpenValve(ValveType.PVN21, true);
  219. _chamber.FullMFC(idx);
  220. switch (idx)
  221. {
  222. case 0:
  223. _chamber.OpenValve(ValveType.PV12, true);
  224. break;
  225. case 1:
  226. _chamber.OpenValve(ValveType.PV22, true);
  227. break;
  228. case 2:
  229. _chamber.OpenValve(ValveType.PV32, true);
  230. break;
  231. case 3:
  232. _chamber.OpenValve(ValveType.PV42, true);
  233. break;
  234. case 4:
  235. _chamber.OpenValve(ValveType.PV52, true);
  236. break;
  237. case 5:
  238. _chamber.OpenValve(ValveType.PV62, true);
  239. break;
  240. case 6:
  241. _chamber.OpenValve(ValveType.PV72, true);
  242. break;
  243. case 7:
  244. _chamber.OpenValve(ValveType.PV82, true);
  245. break;
  246. case 8:
  247. _chamber.OpenValve(ValveType.PV92, true);
  248. break;
  249. case 9:
  250. _chamber.OpenValve(ValveType.PVA2, true);
  251. break;
  252. case 10:
  253. _chamber.OpenValve(ValveType.PVB2, true);
  254. break;
  255. case 11:
  256. _chamber.OpenValve(ValveType.PVC2, true);
  257. break;
  258. }
  259. return true;
  260. }
  261. private bool StartPumpWithIndex()
  262. {
  263. int idx = Convert.ToInt32(_gasLineNums[_currentIndex / _gasPurgeCycleCount]);
  264. _chamber.PumpGas(idx);
  265. return true;
  266. }
  267. private bool StopPumpWithIndex()
  268. {
  269. int idx = Convert.ToInt32(_gasLineNums[_currentIndex / _gasPurgeCycleCount]);
  270. switch (idx)
  271. {
  272. case 0:
  273. _chamber.OpenValve(ValveType.PV11, false);
  274. _chamber.OpenValve(ValveType.Mfc1, false);
  275. break;
  276. case 1:
  277. _chamber.OpenValve(ValveType.PV21, false);
  278. _chamber.OpenValve(ValveType.Mfc2, false);
  279. break;
  280. case 2:
  281. _chamber.OpenValve(ValveType.PV31, false);
  282. _chamber.OpenValve(ValveType.Mfc3, false);
  283. break;
  284. case 3:
  285. _chamber.OpenValve(ValveType.PV41, false);
  286. _chamber.OpenValve(ValveType.Mfc4, false);
  287. break;
  288. case 4:
  289. _chamber.OpenValve(ValveType.PV51, false);
  290. _chamber.OpenValve(ValveType.Mfc5, false);
  291. break;
  292. case 5:
  293. _chamber.OpenValve(ValveType.PV61, false);
  294. _chamber.OpenValve(ValveType.Mfc6, false);
  295. break;
  296. case 6:
  297. _chamber.OpenValve(ValveType.PV71, false);
  298. _chamber.OpenValve(ValveType.Mfc7, false);
  299. break;
  300. case 7:
  301. _chamber.OpenValve(ValveType.PV81, false);
  302. _chamber.OpenValve(ValveType.Mfc8, false);
  303. break;
  304. case 8:
  305. _chamber.OpenValve(ValveType.PV91, false);
  306. _chamber.OpenValve(ValveType.Mfc9, false);
  307. break;
  308. case 9:
  309. _chamber.OpenValve(ValveType.PVA1, false);
  310. _chamber.OpenValve(ValveType.Mfc10, false);
  311. break;
  312. case 10:
  313. _chamber.OpenValve(ValveType.PVB1, false);
  314. _chamber.OpenValve(ValveType.Mfc11, false);
  315. break;
  316. case 11:
  317. _chamber.OpenValve(ValveType.PVC1, false);
  318. _chamber.OpenValve(ValveType.Mfc12, false);
  319. break;
  320. }
  321. _chamber.StopGas(idx);
  322. _chamber.OpenValve(ValveType.SecondPurge,false);
  323. return true;
  324. }
  325. public void Abort()
  326. {
  327. CloseAllValves();
  328. }
  329. public bool PreparePurge()
  330. {
  331. return true;
  332. }
  333. private void PreTurnValves()
  334. {
  335. _chamber.OpenValve(ValveType.Guage, false);
  336. _chamber.OpenValve(ValveType.SoftPump, false);
  337. _chamber.OpenValve(ValveType.FastPump, false);
  338. _chamber.TurnPendulumValve(false);
  339. _chamber.OpenValve(ValveType.GasFinal, false);
  340. _chamber.OpenValve(ValveType.N2, false);
  341. _chamber.OpenValve(ValveType.PVN22, false);
  342. //_chamber.OpenValve(ValveType.TurboPumpPumping, false);
  343. _chamber.OpenValve(ValveType.TurboPumpPurge, false);
  344. }
  345. private bool OpenPVN21_PV12()
  346. {
  347. _chamber.OpenValve(ValveType.PVN21, true);
  348. _chamber.OpenValve(ValveType.PV12, true);
  349. return true;
  350. }
  351. private bool StopAllGas()
  352. {
  353. _chamber.StopGas(1);
  354. _chamber.StopGas(2);
  355. _chamber.StopGas(3);
  356. _chamber.StopGas(4);
  357. PurgeCounter++;
  358. return true;
  359. }
  360. private bool StartPump()
  361. {
  362. _gasLineNums.ToList().ForEach(x =>
  363. {
  364. _chamber.PumpGas(Convert.ToInt32(x) - 1);
  365. });
  366. return true;
  367. }
  368. private bool StopPump()
  369. {
  370. _chamber.OpenValve(ValveType.N2Purge2, false);
  371. return true;
  372. }
  373. private bool StartPurge()
  374. {
  375. _gasLineNums.ToList().ForEach(x =>
  376. {
  377. _chamber.PurgeGas(Convert.ToInt32(x) - 1);
  378. });
  379. return true;
  380. }
  381. private bool StopPurge()
  382. {
  383. _chamber.OpenValve(ValveType.PVN21, false);
  384. return true;
  385. }
  386. }
  387. }