MFPurgeRoutine.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 MFPurgeRoutine : ModuleRoutineBase, IRoutine
  10. {
  11. private enum PurgeStep
  12. {
  13. kCloseValves,
  14. kPumpToCrossing,
  15. kPumpToBase,
  16. kPurgeDelay_1,
  17. kPurgeVent,
  18. kPurgeDelay_2,
  19. kPurgePumpToCrossing,
  20. kPurgePumpToBase,
  21. kPurgePumpDelay,
  22. kPurgeEnd,
  23. kEnd,
  24. }
  25. public int PurgeCounter { get; private set; }
  26. private double _basePressure = 100;
  27. private double _CrossingPressure = 2000;
  28. private double _purgeVentPressure = 10;
  29. private int _purgeCycleCounter = 30;
  30. private int _purgePumpTime = 120;
  31. private readonly JetTM _JetTM;
  32. public MFPurgeRoutine(JetTM tm, ModuleName mod) : base(mod)
  33. {
  34. Name = $"{Module} Purge";
  35. _JetTM = tm;
  36. }
  37. public RState Start(params object[] objs)
  38. {
  39. if (_JetTM.CheckLidClosed(Module) &&
  40. _JetTM.CheckVentValveClosed(Module) &&
  41. _JetTM.CheckPurgeValveClosed(Module) &&
  42. _JetTM.CheckPumpValveClosed(Module))
  43. {
  44. Reset();
  45. _JetTM.CloseModuleAllValves(Module);
  46. _basePressure = SC.GetValue<double>($"{Module}.PumpBasePressure");
  47. _CrossingPressure = SC.GetValue<double>($"{Module}.PumpCrossingPressure");
  48. _purgeVentPressure = SC.GetValue<double>($"{Module}.PurgeVentPressure");
  49. _purgeCycleCounter = SC.GetValue<int>($"{Module}.PurgeCycleCount");
  50. _purgePumpTime = SC.GetValue<int>($"{Module}.PurgePumpTime");
  51. //_JetTM.TurnN2Valve(true);
  52. PurgeCounter = 0;
  53. return Runner.Start(Module, Name);
  54. }
  55. return RState.Failed;
  56. }
  57. public RState Monitor()
  58. {
  59. Runner.Delay(PurgeStep.kCloseValves, _delay_1s)
  60. .Run(PurgeStep.kPumpToCrossing, HOFs.WrapAction(_JetTM.TurnSoftPumpValve, Module, true), () => { return _JetTM.GetModulePressure(Module) < _CrossingPressure; })
  61. .Run(PurgeStep.kPumpToBase, SwitchFastPump, () => { return _JetTM.GetModulePressure(Module) < _basePressure; })
  62. .LoopStart(PurgeStep.kPurgeDelay_1, "Purge", _purgeCycleCounter, HOFs.WrapAction(_JetTM.TurnFastPumpValve, Module, false), _delay_1s)
  63. .LoopRun(PurgeStep.kPurgeVent, OpenPurge, () => { return _JetTM.GetModulePressure(Module) >= _purgeVentPressure; })
  64. .LoopRun(PurgeStep.kPurgeDelay_2, ClosePurge, _delay_1s)
  65. //.LoopRun(PurgeStep.kPurgePumpToCrossing, HOFs.WrapAction(_JetTM.TurnSoftPumpValve, Module, true), () => { return _JetTM.GetModulePressure(Module) < _basePressure; })
  66. .LoopRun(PurgeStep.kPurgePumpToBase, SwitchFastPump, () => { return _JetTM.GetModulePressure(Module) < _basePressure; })
  67. //.LoopRun(PurgeStep.kPurgePumpDelay, NullFun, _purgePumpTime * 1000)
  68. .LoopEnd(PurgeStep.kPurgeEnd, HOFs.WrapAction(_JetTM.CloseModuleAllValves, Module), _delay_1s)
  69. .End(PurgeStep.kEnd, NullFun, _delay_50ms);
  70. return Runner.Status;
  71. }
  72. public void Abort()
  73. {
  74. if (Module == ModuleName.LLA)
  75. {
  76. _JetTM.SetLLAFlow(0);
  77. }
  78. else if (Module == ModuleName.LLB)
  79. {
  80. _JetTM.SetLLBFlow(0);
  81. }
  82. _JetTM.CloseModuleAllValves(Module);
  83. }
  84. private bool SwitchFastPump()
  85. {
  86. _JetTM.TurnSoftPumpValve(Module, false);
  87. _JetTM.TurnFastPumpValve(Module, true);
  88. return true;
  89. }
  90. private bool OpenPurge()
  91. {
  92. _JetTM.TurnN2Valve(true);
  93. if (Module == ModuleName.TM)
  94. {
  95. _JetTM.TurnVentValve(Module, true);
  96. }
  97. else
  98. {
  99. if (Module == ModuleName.LLA)
  100. {
  101. _JetTM.SetLLAFlow(2000);
  102. }
  103. else if(Module == ModuleName.LLB)
  104. {
  105. _JetTM.SetLLBFlow(2000);
  106. }
  107. _JetTM.TurnPurgeValve(Module, true);
  108. }
  109. return true;
  110. }
  111. public bool ClosePurge()
  112. {
  113. _JetTM.TurnN2Valve(false);
  114. if (Module == ModuleName.TM)
  115. {
  116. _JetTM.TurnVentValve(Module, false);
  117. }
  118. else
  119. {
  120. if (Module == ModuleName.LLA)
  121. {
  122. _JetTM.SetLLAFlow(0);
  123. }
  124. else if (Module == ModuleName.LLB)
  125. {
  126. _JetTM.SetLLBFlow(0);
  127. }
  128. _JetTM.TurnPurgeValve(Module, false);
  129. }
  130. return true;
  131. }
  132. }
  133. }