MFVentRoutine.cs 5.9 KB

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