SEMFVentRoutine.cs 3.1 KB

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