MFPumpRoutine.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 MECF.Framework.Common.Equipment;
  6. using Venus_Core;
  7. namespace Venus_RT.Modules.TM
  8. {
  9. class MFPumpRoutine : ModuleRoutineBase, IRoutine
  10. {
  11. private enum PumpStep
  12. {
  13. kWaitPeerModule,
  14. kSoftPump,
  15. kFastPump,
  16. kClosePumpValves,
  17. }
  18. private double _pumpBasePressure;
  19. private double _pumpCrossingPressure;
  20. private int _pumpingTimeout;
  21. private readonly JetTM _JetTM;
  22. public MFPumpRoutine(JetTM jetTM, ModuleName mod) : base(mod)
  23. {
  24. _JetTM = jetTM;
  25. Name = "Pump Down";
  26. }
  27. public RState Start(params object[] objs)
  28. {
  29. if (_JetTM.CheckLidClosed(Module) &&
  30. _JetTM.CheckVentValveClosed(Module) &&
  31. _JetTM.CheckPurgeValveClosed(Module))
  32. {
  33. Reset();
  34. _pumpBasePressure = SC.GetValue<double>($"{Module}.PumpBasePressure");
  35. _pumpCrossingPressure = SC.GetValue<double>($"{Module}.PumpCrossingPressure");
  36. _pumpingTimeout = SC.GetValue<int>($"{Module}.PumpingTimeout") * 1000;
  37. return Runner.Start(Module, Name);
  38. }
  39. return RState.Failed;
  40. }
  41. public RState Monitor()
  42. {
  43. Runner.Wait((int)PumpStep.kWaitPeerModule, WaitPeerModule)
  44. .Run((int)PumpStep.kSoftPump, OpenSoftPump, () => { return _JetTM.GetModulePressure(Module) < _pumpCrossingPressure; }, _pumpingTimeout)
  45. .Run((int)PumpStep.kFastPump, SwitchFastPump, IsPressureReady, _pumpingTimeout)
  46. .End((int)PumpStep.kClosePumpValves, ClosePumpValves, _delay_50ms);
  47. return Runner.Status;
  48. }
  49. private bool WaitPeerModule()
  50. {
  51. if(!IsPressureReady())
  52. {
  53. if (Module == ModuleName.LLA)
  54. {
  55. return !_JetTM.IsLLBFastPumpOpen && !_JetTM.IsLLBSoftPumpOpen;
  56. }
  57. else if (Module == ModuleName.LLB)
  58. {
  59. return !_JetTM.IsLLAFastPumpOpen && !_JetTM.IsLLASoftPumpOpen;
  60. }
  61. }
  62. return true;
  63. }
  64. private bool IsPressureReady()
  65. {
  66. return _JetTM.GetModulePressure(Module) < _pumpBasePressure;
  67. }
  68. private bool OpenSoftPump()
  69. {
  70. if (!IsPressureReady())
  71. {
  72. _JetTM.TurnSoftPumpValve(Module, true);
  73. }
  74. return true;
  75. }
  76. private bool SwitchFastPump()
  77. {
  78. if (!IsPressureReady())
  79. {
  80. _JetTM.TurnSoftPumpValve(Module, false);
  81. _JetTM.TurnFastPumpValve(Module, true);
  82. }
  83. return true;
  84. }
  85. private bool ClosePumpValves()
  86. {
  87. _JetTM.TurnSoftPumpValve(Module, false);
  88. _JetTM.TurnFastPumpValve(Module, false);
  89. return true;
  90. }
  91. public void Abort()
  92. {
  93. ClosePumpValves();
  94. }
  95. }
  96. }