MFVentRoutine.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Venus_RT.Devices;
  4. using MECF.Framework.Common.Equipment;
  5. using Venus_Core;
  6. namespace Venus_RT.Modules.TM
  7. {
  8. class MFVentRoutine : ModuleRoutineBase, IRoutine
  9. {
  10. private enum VentStep
  11. {
  12. Venting,
  13. OpenSoftVent,
  14. SwitchFastVent,
  15. CloseVentValves,
  16. Delay,
  17. CloseExhaustValve,
  18. PrepareCooling,
  19. StartCooling,
  20. Cooling,
  21. End,
  22. }
  23. private int _ventingTimeout;
  24. private int _SoftVentEndPressure;
  25. private readonly JetTM _JetTM;
  26. private int _ventTimeDelay = 1;
  27. private bool _needCooling = false;
  28. private double _coolingMFCFlow = 0;
  29. public MFVentRoutine(JetTM jetTM, ModuleName mod) : base(mod)
  30. {
  31. _JetTM = jetTM;
  32. Name = "Vent ";
  33. }
  34. public RState Start(params object[] objs)
  35. {
  36. if(objs.Length > 0)
  37. {
  38. _needCooling = (bool)objs[0];
  39. _coolingMFCFlow = SC.GetValue<double>($"{Module}.Cooling.MFCFlow");
  40. }
  41. _JetTM.TurnSoftPumpValve(Module, false);
  42. _JetTM.TurnFastPumpValve(Module, false);
  43. _JetTM.TurnPurgeValve(Module, false);
  44. if (_JetTM.CheckLidClosed(Module) &&
  45. _JetTM.CheckPumpValveClosed(Module) &&
  46. _JetTM.CheckPurgeValveClosed(Module))
  47. {
  48. Reset();
  49. _ventingTimeout = SC.GetValue<int>($"{Module}.VentingTimeout") * 1000;
  50. _SoftVentEndPressure = SC.GetValue<int>($"{Module}.SoftVentEndPressure");
  51. _ventTimeDelay = SC.GetValue<int>($"{Module}.OverVentTime");
  52. return Runner.Start(Module, Name);
  53. }
  54. return RState.Failed;
  55. }
  56. public RState Monitor()
  57. {
  58. Runner.Run(VentStep.OpenSoftVent, OpenSoftVentValve, IsSoftVentEnd)
  59. .Run(VentStep.SwitchFastVent, SwitchFastVentValve, IsPressureReady, _ventingTimeout)
  60. .Delay(VentStep.Delay, _ventTimeDelay)
  61. .Run(VentStep.CloseVentValves, CloseVentValve, _delay_1s)
  62. .RunIf(VentStep.PrepareCooling, _needCooling, StopVent)
  63. .RunIf(VentStep.StartCooling, _needCooling, StartCooling, 3600000)
  64. .End(VentStep.CloseExhaustValve, CloseExhaustValve);
  65. return Runner.Status;
  66. }
  67. private bool OpenSoftVentValve()
  68. {
  69. _JetTM.TurnN2Valve(true);
  70. _JetTM.TurnPurgeValve(Module, true);
  71. switch (Module)
  72. {
  73. case ModuleName.LLA:
  74. _JetTM.SetLLAFlow(2000);
  75. break;
  76. case ModuleName.LLB:
  77. _JetTM.SetLLBFlow(2000);
  78. break;
  79. case ModuleName.TM:
  80. _JetTM.SetTMFlow(100);
  81. break;
  82. }
  83. return true;
  84. }
  85. private bool CloseExhaustValve()
  86. {
  87. _JetTM.TurnExhaustValve(Module, false);
  88. return true;
  89. }
  90. private bool IsSoftVentEnd()
  91. {
  92. return _JetTM.GetModulePressure(Module) > _SoftVentEndPressure;
  93. }
  94. private bool SwitchFastVentValve()
  95. {
  96. switch (Module)
  97. {
  98. case ModuleName.LLA:
  99. _JetTM.SetLLAFlow(0);
  100. break;
  101. case ModuleName.LLB:
  102. _JetTM.SetLLBFlow(0);
  103. break;
  104. case ModuleName.TM:
  105. _JetTM.SetTMFlow(0);
  106. break;
  107. }
  108. _JetTM.TurnPurgeValve(Module, false);
  109. _JetTM.TurnExhaustValve(Module, true);
  110. _JetTM.TurnVentValve(Module, true);
  111. return true;
  112. }
  113. private bool CloseVentValve()
  114. {
  115. _JetTM.TurnPurgeValve(Module, false);
  116. _JetTM.TurnVentValve(Module, false);
  117. return true;
  118. }
  119. private bool StopVent()
  120. {
  121. _JetTM.TurnVentValve(Module, false);
  122. _JetTM.TurnExhaustValve(Module, false);
  123. return true;
  124. }
  125. private bool StartCooling()
  126. {
  127. _JetTM.TurnPurgeValve(Module, true);
  128. _JetTM.TurnExhaustValve(Module, true);
  129. if (Module == ModuleName.LLA)
  130. {
  131. _JetTM.SetLLAFlow(_coolingMFCFlow);
  132. }
  133. else if (Module == ModuleName.LLB)
  134. {
  135. _JetTM.SetLLBFlow(_coolingMFCFlow);
  136. }
  137. return true;
  138. }
  139. private bool IsPressureReady()
  140. {
  141. return _JetTM.IsModuleATM(Module);
  142. }
  143. public void Abort()
  144. {
  145. CloseVentValve();
  146. if (_needCooling)
  147. {
  148. if (Module == ModuleName.LLA)
  149. {
  150. _JetTM.SetLLAFlow(0);
  151. }
  152. else if (Module == ModuleName.LLB)
  153. {
  154. _JetTM.SetLLBFlow(0);
  155. }
  156. _JetTM.TurnPurgeValve(Module, false);
  157. _JetTM.TurnExhaustValve(Module, false);
  158. }
  159. }
  160. }
  161. }