PMPurgeRoutine.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. namespace Venus_RT.Modules.PMs
  7. {
  8. class PMPurgeRoutine : PMRoutineBase, IRoutine
  9. {
  10. private enum PurgeStep
  11. {
  12. kStart,
  13. kCloseValvesExceptN2Purge,
  14. kPurgeVent,
  15. kStopVent,
  16. kCloseISOValve,
  17. kSoftPump,
  18. kFastPump,
  19. kCloseFastPump,
  20. kOpenISOValve,
  21. kOpenVATValve,
  22. kOpenV8N2Purge,
  23. kCloseVATValve,
  24. kEnd,
  25. }
  26. public int PurgeCounter { get; private set; }
  27. private readonly int _pumpingTargetPressure = 200;
  28. private int _purgeVentPressure = 1000;
  29. private int _roughPumpDownPressure = 75;
  30. private int _purgePumpTime = 60;
  31. private int _purgeCycleCount = 30;
  32. private JetChamber jetChamber = JetChamber.None;
  33. private bool needsoft = true;
  34. public PMPurgeRoutine(JetPMBase chamber) : base(chamber)
  35. {
  36. jetChamber = (JetChamber)SC.GetValue<int>($"{chamber.Name}.ChamberType");
  37. Name = "PM Purge";
  38. if (jetChamber == JetChamber.VenusDE)
  39. {
  40. needsoft = false;
  41. }
  42. }
  43. public RState Start(params object[] objs)
  44. {
  45. if (CheckLid() &&
  46. CheckSlitDoor() &&
  47. CheckDryPump() &&
  48. CheckTurboPump())
  49. {
  50. _purgeVentPressure = SC.GetValue<int>($"{Module}.Purge.PurgeVentPressure");
  51. _roughPumpDownPressure = SC.GetValue<int>($"{Module}.Purge.PurgePumpPressure") * 1000;
  52. _purgePumpTime = SC.GetValue<int>($"{Module}.Purge.PurgePumpTime");
  53. _purgeCycleCount = SC.GetValue<int>($"{Module}.Purge.PurgeCycleCount");
  54. Reset();
  55. //CloseValvesExceptN2Purge();
  56. PurgeCounter = 0;
  57. return Runner.Start(Module, Name);
  58. }
  59. return RState.Failed;
  60. }
  61. public RState Monitor()
  62. {
  63. Runner.Delay(PurgeStep.kStart, _delay_1s)
  64. .LoopStart(PurgeStep.kCloseValvesExceptN2Purge, "Purge Cycle", _purgeCycleCount, CloseValvesExceptN2Purge, _delay_5s)
  65. .LoopRun(PurgeStep.kPurgeVent, OpenVentValves, () => { return _chamber.ChamberPressure >= _purgeVentPressure; })
  66. .LoopRun(PurgeStep.kStopVent, CloseVentValves, _delay_2s)
  67. .LoopRun(PurgeStep.kCloseISOValve, HOFs.WrapAction(_chamber.OpenValve, ValveType.TurboPumpPumping, false), _delay_2s)
  68. .LoopRunIf(PurgeStep.kSoftPump, needsoft, HOFs.WrapAction(_chamber.OpenValve, ValveType.SoftPump, true), () => { return _chamber.ChamberPressure <= _roughPumpDownPressure; })
  69. .LoopRun(PurgeStep.kFastPump, StartFastPump, () => { return _chamber.ChamberPressure <= _pumpingTargetPressure; })
  70. .LoopRun(PurgeStep.kCloseFastPump, HOFs.WrapAction(_chamber.OpenValve, ValveType.FastPump, false), _delay_2s)
  71. .LoopRun(PurgeStep.kOpenISOValve, HOFs.WrapAction(_chamber.OpenValve, ValveType.TurboPumpPumping, true), _delay_2s)
  72. .LoopRun(PurgeStep.kOpenVATValve, HOFs.Apply(_chamber.TurnPendulumValve, true), _delay_5s)
  73. .LoopRun(PurgeStep.kOpenV8N2Purge, OpenV8N2Purge, (_purgePumpTime - 5) * 1000)
  74. .LoopEnd(PurgeStep.kCloseVATValve, CloseVATValve, _delay_1s)
  75. .End(PurgeStep.kEnd, NullFun, _delay_1s);
  76. return Runner.Status;
  77. }
  78. public void Abort()
  79. {
  80. CloseAllValves();
  81. }
  82. private bool CloseValvesExceptN2Purge()
  83. {
  84. _chamber.OpenValve(ValveType.Guage, false);
  85. _chamber.OpenValve(ValveType.SoftPump, false);
  86. _chamber.OpenValve(ValveType.FastPump, false);
  87. _chamber.TurnPendulumValve(false);
  88. _chamber.OpenValve(ValveType.GasFinal, false);
  89. _chamber.OpenValve(ValveType.N2, false);
  90. _chamber.OpenValve(ValveType.PVN22, true);
  91. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  92. _chamber.OpenValve(ValveType.TurboPumpPurge, true);
  93. return true;
  94. }
  95. private bool OpenVentValves()
  96. {
  97. _chamber.OpenValve(ValveType.GasFinal, true);
  98. _chamber.OpenValve(ValveType.N2, true);
  99. return true;
  100. }
  101. private bool CloseVentValves()
  102. {
  103. _chamber.OpenValve(ValveType.GasFinal, false);
  104. _chamber.OpenValve(ValveType.N2, false);
  105. _chamber.OpenValve(ValveType.PVN22, false);
  106. _chamber.OpenValve(ValveType.TurboPumpPurge, false);
  107. return true;
  108. }
  109. private bool StartFastPump()
  110. {
  111. _chamber.OpenValve(ValveType.SoftPump, false);
  112. _chamber.OpenValve(ValveType.FastPump, true);
  113. return true;
  114. }
  115. private bool OpenV8N2Purge()
  116. {
  117. _chamber.OpenValve(ValveType.Guage, true);
  118. _chamber.OpenValve(ValveType.TurboPumpPurge, true);
  119. return true;
  120. }
  121. private bool CloseVATValve()
  122. {
  123. _chamber.TurnPendulumValve(false);
  124. PurgeCounter++;
  125. return true;
  126. }
  127. }
  128. }