VentRoutine.cs 2.2 KB

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