SEMFVentRoutine.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using MECF.Framework.Common.Equipment;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Venus_Core;
  10. using Venus_RT.Devices;
  11. namespace Venus_RT.Modules.TM.VenusEntity
  12. {
  13. public class SEMFVentRoutine : ModuleRoutineBase, IRoutine
  14. {
  15. private enum SEVentStep
  16. {
  17. seOpenSoftVent,
  18. seSwitchFastVent,
  19. seDelayForClose,
  20. seCloseVentValves,
  21. }
  22. private int _venttimeout;
  23. private int _ventcrosspressure;
  24. private readonly HongHuTM _tm;
  25. public SEMFVentRoutine(HongHuTM tm, ModuleName module) : base(module)
  26. {
  27. _tm = tm;
  28. Name = "Vent";
  29. }
  30. public RState Start(params object[] objs)
  31. {
  32. if (_tm.CheckPumpValveClosed(Module))
  33. {
  34. Reset();
  35. _venttimeout = SC.GetValue<int>($"{Module}.VentingTimeout") * 1000;
  36. _ventcrosspressure = SC.GetValue<int>($"{Module}.SoftVentEndPressure");
  37. return Runner.Start(Module, Name);
  38. }
  39. return Runner.Status;
  40. }
  41. public RState Monitor()
  42. {
  43. Runner.Run(SEVentStep.seOpenSoftVent, OpenSoftVentValve, IsSoftVentEnd)
  44. .Run(SEVentStep.seSwitchFastVent, SwitchFastVentValve, IsPressureReady, _venttimeout)
  45. .Delay(SEVentStep.seDelayForClose, _delay_1s)
  46. .End(SEVentStep.seCloseVentValves, CloseVentValve, _delay_50ms);
  47. return Runner.Status;
  48. }
  49. private bool OpenSoftVentValve()
  50. {
  51. _tm.TurnSoftVentValve(Module, true);
  52. return true;
  53. }
  54. private bool IsSoftVentEnd() => _tm.GetModulePressure(Module) > _ventcrosspressure;
  55. private bool SwitchFastVentValve()
  56. {
  57. if (Module == ModuleName.SETM)
  58. _tm.SetTMFlow(100);
  59. _tm.TurnSoftVentValve(Module, false);
  60. _tm.TurnFastVentValve(Module, true);
  61. return true;
  62. }
  63. private bool IsPressureReady()
  64. {
  65. switch (Module)
  66. {
  67. case ModuleName.SETM:
  68. return _tm.IsTMATM;
  69. case ModuleName.VCE1:
  70. return _tm.IsVCEATM;
  71. }
  72. return false;
  73. }
  74. private bool CloseVentValve()
  75. {
  76. _tm.TurnSoftVentValve(Module,false);
  77. _tm.TurnFastVentValve(Module,false);
  78. if (Module == ModuleName.SETM)
  79. _tm.SetTMFlow(0);
  80. return true;
  81. }
  82. public void Abort()
  83. {
  84. _tm.TurnFastVentValve(Module,false);
  85. _tm.TurnSoftVentValve(Module, false);
  86. }
  87. }
  88. }