PMPartialPressureRoutine.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Venus_Core;
  9. using Venus_RT.Devices;
  10. using Venus_Unity;
  11. namespace Venus_RT.Modules.PMs
  12. {
  13. class PMPartialPressureRoutine : PMRoutineBase, IRoutine
  14. {
  15. int gasIndex;
  16. int GasMaxScale;
  17. public int counter;
  18. int gasTime;
  19. ValveType[] valveTypes = new ValveType[4] { ValveType.PV11, ValveType.PV21, ValveType.PV31, ValveType.PV41 };
  20. public PartialPressureResult m_PartialPressureResult=new PartialPressureResult ();
  21. public StringBuilder m_sb = new StringBuilder();
  22. private enum PartialPressureStep
  23. {
  24. kDelay_1s,
  25. kStartGas,
  26. kReadChamberPressure,
  27. kEnd,
  28. }
  29. public PMPartialPressureRoutine(JetPMBase chamber) : base(chamber)
  30. {
  31. Name = "PMPartialPressure";
  32. }
  33. public RState Start(params object[] objs)
  34. {
  35. if (!CheckTurboPump())
  36. {
  37. return RState.Failed;
  38. }
  39. if (_chamber.GetPVPosition() == 0)
  40. {
  41. Stop("钟摆阀没有打开");
  42. return RState.Failed;
  43. }
  44. _chamber.OpenValve(ValveType.Guage, true);
  45. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  46. _chamber.OpenValve(ValveType.TurboPumpPurge, true);
  47. counter = 1;
  48. Reset();
  49. gasIndex = (int)objs[0];
  50. gasTime = (int)objs[1];
  51. GasMaxScale = SC.GetValue<int>($"{Module}.MfcGas{gasIndex.ToString()}.MfcN2Scale");
  52. //_chamber.CloseValves();
  53. _chamber.SetPVPostion(1000);
  54. m_PartialPressureResult.StartTime= DateTime.Now.ToString("yyyyMMddHHmm");
  55. m_PartialPressureResult.FlowTime = gasTime;
  56. m_PartialPressureResult.GasName= $"Gas{gasIndex.ToString()}";
  57. m_PartialPressureResult.ValuePairs.Clear();
  58. m_sb.Clear();
  59. return Runner.Start(Module, Name);
  60. }
  61. public RState Monitor()
  62. {
  63. Runner.Delay(PartialPressureStep.kDelay_1s, 1000 * 1)
  64. .LoopStart(PartialPressureStep.kStartGas, "Partial Pressure Test", 10, () => SetGasPoint(), gasTime)
  65. .LoopEnd(PartialPressureStep.kReadChamberPressure, ReadChamberPressure, _delay_1s)
  66. .End(PartialPressureStep.kEnd, () =>
  67. {
  68. _chamber.CloseValves();
  69. m_PartialPressureResult.EndTime = DateTime.Now.ToString("yyyyMMddHHmm");
  70. SerializeHelper.Instance.WriteToJsonFile<PartialPressureResult>(m_PartialPressureResult, $"PartialPressureResult/{Module}/{m_PartialPressureResult.GasName}/{m_PartialPressureResult.StartTime}.json");
  71. return true;
  72. }, 500);
  73. return Runner.Status;
  74. }
  75. private bool SetGasPoint()
  76. {
  77. if (_chamber.ChamberType == JetChamber.VenusDE || _chamber.ChamberType == JetChamber.VenusSE)
  78. {
  79. valveTypes = new ValveType[12] { ValveType.PV11, ValveType.PV21, ValveType.PV31, ValveType.PV41, ValveType.PV51, ValveType.PV61, ValveType.PV71, ValveType.PV81, ValveType.PV91, ValveType.PVA1, ValveType.PVB1, ValveType.PVC1, };
  80. _chamber.OpenValve(valveTypes[gasIndex - 1], true);
  81. _chamber.OpenValve(ValveType.GasFinal, true);
  82. _chamber.FlowGas(gasIndex - 1, GasMaxScale * 0.1 * counter);
  83. return true;
  84. }
  85. else
  86. {
  87. if (gasIndex <= 4)
  88. {
  89. _chamber.OpenValve(valveTypes[gasIndex - 1], true);
  90. }
  91. _chamber.OpenValve(ValveType.GasFinal, true);
  92. _chamber.FlowGas(gasIndex - 1, GasMaxScale * 0.1 * counter);
  93. return true;
  94. }
  95. }
  96. private bool ReadChamberPressure()
  97. {
  98. var pressure = Math.Round(_chamber.ProcessPressure, 3);
  99. m_PartialPressureResult.ValuePairs.Add(new Value() { Flow = (GasMaxScale * 0.1 * counter).ToString(), Pressure = pressure });
  100. m_sb.Append(pressure.ToString());
  101. m_sb.Append(',');
  102. counter += 1;
  103. return true;
  104. }
  105. public void Abort()
  106. {
  107. _chamber.CloseValves();
  108. }
  109. }
  110. }