SEMFVentRoutine.cs 3.4 KB

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