MFVentRoutine.cs 6.0 KB

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