VentRoutine.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Venus_RT.Devices;
  4. using MECF.Framework.Common.Routine;
  5. namespace Venus_RT.Modules.PMs
  6. {
  7. class VentRoutine : PMRoutineBase, IRoutine
  8. {
  9. private enum VentStep
  10. {
  11. kClosePVValves,
  12. kOpenVentValves,
  13. kDelay_2,
  14. kCloseVentValves,
  15. }
  16. //private int _ventTime;
  17. private readonly int _defaut_timeout = 5000;
  18. private double _ventTimeDelay = 1;
  19. private int _checkATMTimeout = 90;
  20. public VentRoutine(JetPM chamber) : base(chamber)
  21. {
  22. Name = "PM Vent";
  23. }
  24. public RState Start(params object[] objs)
  25. {
  26. if (CheckLid() &&
  27. CheckSlitDoor() &&
  28. CheckCDA() &&
  29. CheckATM())
  30. {
  31. Reset();
  32. _chamber.CloseValves();
  33. _checkATMTimeout = SC.GetValue<int>($"{Module}.CheckATMTimeout");
  34. _ventTimeDelay = SC.GetValue<double>($"{Module}.OverVentTime");
  35. return Runner.Start(Module, Name);
  36. }
  37. return RState.Failed;
  38. }
  39. public RState Monitor()
  40. {
  41. Runner.Run( (int)VentStep.kClosePVValves, ClosePVValves, _delay_1s)
  42. .Run( (int)VentStep.kOpenVentValves, HOFs.Apply(TurnVentValves, true), ()=> { return _chamber.IsATM; }, _checkATMTimeout * 1000)
  43. .Delay( (int)VentStep.kDelay_2, (int)_ventTimeDelay)
  44. .End( (int)VentStep.kCloseVentValves, HOFs.Apply(TurnVentValves, false), _defaut_timeout);
  45. return Runner.Status;
  46. }
  47. private bool ClosePVValves()
  48. {
  49. return _chamber.TurnPendulumValve(false);
  50. }
  51. private bool TurnVentValves(bool bOpen)
  52. {
  53. _chamber.OpenValve(ValveType.GasFinal, bOpen);
  54. _chamber.OpenValve(ValveType.N2, bOpen);
  55. _chamber.OpenValve(ValveType.PVN22, bOpen);
  56. return true;
  57. }
  58. public void Abort()
  59. {
  60. CloseAllValves();
  61. }
  62. }
  63. }