VenusVentRoutine.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Venus_Core;
  9. using Venus_RT.Devices;
  10. namespace Venus_RT.Modules.PMs
  11. {
  12. class VenusVentRoutine : PMRoutineBase, IRoutine
  13. {
  14. private enum VentStep
  15. {
  16. vISODelay,
  17. vClosePendulumValve,
  18. vCloseTurboPurge,
  19. vCloseTurboPumping,
  20. vClosePVValves,
  21. vDelayForPendulumValve,
  22. vOpenVentValves,
  23. vDelay_2,
  24. vCloseVentValves,
  25. }
  26. //private int _ventTime;
  27. private double _ventTimeDelay = 1;
  28. private int _checkATMTimeout = 90;
  29. public bool VentingFlag => _ventingflag;
  30. private bool _ventingflag = false;
  31. public VenusVentRoutine(JetPMBase chamber) : base(chamber)
  32. {
  33. Name = "PM Vent";
  34. }
  35. public RState Start(params object[] objs)
  36. {
  37. if (CheckLid() &&
  38. CheckSlitDoor() &&
  39. CheckCDA() &&
  40. CheckATM())
  41. {
  42. Reset();
  43. _checkATMTimeout = SC.GetValue<int>($"{Module}.CheckATMTimeout");
  44. _ventTimeDelay = SC.GetValue<double>($"{Module}.OverVentTime");
  45. if (Runner.Start(Module, Name) == RState.Running)
  46. {
  47. _ventingflag = true;
  48. return RState.Running;
  49. }
  50. else
  51. {
  52. _ventingflag = false;
  53. return RState.Failed;
  54. }
  55. }
  56. return RState.Failed;
  57. }
  58. public RState Monitor()
  59. {
  60. Runner.Delay(VentStep.vISODelay, _delay_2s)
  61. .Run(VentStep.vClosePendulumValve, PendulumValveClose, () => { return !_chamber.PendulumValveIsOpen(); })
  62. .Delay(VentStep.vDelayForPendulumValve, 500)
  63. .Run(VentStep.vCloseTurboPurge, CloseTurboPurge, _delay_3s)
  64. .Run(VentStep.vCloseTurboPumping, CloseTurboPumping, _delay_3s)
  65. .Run(VentStep.vClosePVValves, ClosePVValves, _delay_3s)
  66. .Run(VentStep.vOpenVentValves, OpenValve, () => { return _chamber.IsATM; }, _checkATMTimeout * 1000)
  67. .Delay(VentStep.vDelay_2, (int)_ventTimeDelay)
  68. .End(VentStep.vCloseVentValves, CloseVentGasFinalValves, _delay_2s);
  69. _ventingflag = Runner.Status == RState.Running;
  70. return Runner.Status;
  71. }
  72. private bool CloseTurboPumping()
  73. {
  74. _chamber.OpenValve(ValveType.TurboPumpPumping, false);
  75. return true;
  76. }
  77. private bool CloseTurboPurge()
  78. {
  79. _chamber.OpenValve(ValveType.TurboPumpPurge, false);
  80. return true;
  81. }
  82. private bool PendulumValveClose()
  83. {
  84. _chamber.TurnPendulumValve(false);
  85. return true;
  86. }
  87. private bool ClosePVValves()
  88. {
  89. _chamber.OpenValve(ValveType.Guage, false);
  90. if (_chamber.PendulumValveIsOpen())
  91. {
  92. return _chamber.TurnPendulumValve(false);
  93. }
  94. _chamber.OpenValve(ValveType.TurboPumpPumping, false);
  95. _chamber.OpenValve(ValveType.TurboPumpPurge, false);
  96. _chamber.OpenValve(ValveType.FastPump, false);
  97. _chamber.OpenValve(ValveType.SoftPump, false);
  98. return true;
  99. }
  100. private bool OpenValve()
  101. {
  102. _chamber.OpenValve(ValveType.PVN22, true);
  103. _chamber.OpenValve(ValveType.N2, true);
  104. _chamber.OpenValve(ValveType.GasFinal, true);
  105. return true;
  106. }
  107. private bool CloseVentGasFinalValves()
  108. {
  109. if (_chamber.ChamberType == JetChamber.VenusSE || _chamber.ChamberType == JetChamber.VenusDE)
  110. {
  111. _chamber.OpenValve(ValveType.PVN22, false);
  112. }
  113. _chamber.OpenValve(ValveType.GasFinal, false);
  114. _chamber.OpenValve(ValveType.N2, false);
  115. return true;
  116. }
  117. public void Abort()
  118. {
  119. CloseAllValves();
  120. }
  121. }
  122. }