SEMFVentRoutine.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. namespace Venus_RT.Modules.TM.VenusEntity
  13. {
  14. public class SEMFVentRoutine : ModuleRoutineBase, IRoutine
  15. {
  16. private enum SEVentStep
  17. {
  18. seOpenSoftVent,
  19. seSwitchFastVent,
  20. seDelayForClose,
  21. seCloseVentValves,
  22. }
  23. private int _venttimeout;
  24. private int _ventcrosspressure;
  25. private readonly HongHuTM _tm;
  26. public SEMFVentRoutine(HongHuTM tm, ModuleName module) : base(module)
  27. {
  28. _tm = tm;
  29. Name = "Vent";
  30. }
  31. public RState Start(params object[] objs)
  32. {
  33. if (_tm.CheckPumpValveClosed(Module))
  34. {
  35. Reset();
  36. _venttimeout = SC.GetValue<int>($"{Module}.VentingTimeout") * 1000;
  37. _ventcrosspressure = SC.GetValue<int>($"{Module}.SoftVentEndPressure");
  38. return Runner.Start(Module, Name);
  39. }
  40. else
  41. {
  42. LOG.Write(eEvent.ERR_DEVICE_INFO,Module, "Pump Valve not all Close! Cannot Vent!");
  43. return RState.Failed;
  44. }
  45. }
  46. public RState Monitor()
  47. {
  48. Runner.Run(SEVentStep.seOpenSoftVent, OpenSoftVentValve, IsSoftVentEnd)
  49. .Run(SEVentStep.seSwitchFastVent, SwitchFastVentValve, IsPressureReady, _venttimeout)
  50. .Delay(SEVentStep.seDelayForClose, _delay_1s)
  51. .End(SEVentStep.seCloseVentValves, CloseVentValve, _delay_50ms);
  52. return Runner.Status;
  53. }
  54. private bool OpenSoftVentValve()
  55. {
  56. _tm.TurnSoftVentValve(Module, true);
  57. return true;
  58. }
  59. private bool IsSoftVentEnd() => _tm.GetModulePressure(Module) > _ventcrosspressure;
  60. private bool SwitchFastVentValve()
  61. {
  62. if (Module == ModuleName.SETM)
  63. _tm.SetTMFlow(100);
  64. _tm.TurnSoftVentValve(Module, false);
  65. _tm.TurnFastVentValve(Module, true);
  66. return true;
  67. }
  68. private bool IsPressureReady()
  69. {
  70. switch (Module)
  71. {
  72. case ModuleName.SETM:
  73. return _tm.IsTMATM;
  74. case ModuleName.VCE1:
  75. return _tm.IsVCEATM;
  76. }
  77. return false;
  78. }
  79. private bool CloseVentValve()
  80. {
  81. _tm.TurnSoftVentValve(Module,false);
  82. _tm.TurnFastVentValve(Module,false);
  83. if (Module == ModuleName.SETM)
  84. _tm.SetTMFlow(0);
  85. return true;
  86. }
  87. public void Abort()
  88. {
  89. _tm.TurnFastVentValve(Module,false);
  90. _tm.TurnSoftVentValve(Module, false);
  91. }
  92. }
  93. }