PMVATPerformanceRoutine.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. public enum CMPressure
  14. {
  15. CM1,
  16. CM2,
  17. }
  18. class PMVATPerformanceRoutine : PMRoutineBase, IRoutine
  19. {
  20. public StringBuilder m_sb = new StringBuilder();
  21. int gasIndex;
  22. //int GasMaxScale;
  23. public int counter;
  24. int gasTime;
  25. int gasSetPoint;
  26. ValveType[] valveTypes = new ValveType[4] { ValveType.PV11, ValveType.PV21, ValveType.PV31, ValveType.PV41 };
  27. List<int> Positions = new List<int>() {50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000};
  28. public VATPerformanceResult m_VATPerformanceResult;
  29. private CMPressure currentCMPressure = CMPressure.CM1;
  30. private enum VATPerformanceStep
  31. {
  32. kDelay_1s,
  33. kStartGas,
  34. kReadChamberPressure,
  35. kEnd,
  36. }
  37. public PMVATPerformanceRoutine(JetPMBase chamber) : base(chamber)
  38. {
  39. Name = "PMVATPerformance";
  40. }
  41. public RState Start(params object[] objs)
  42. {
  43. if (!CheckTurboPump())
  44. {
  45. return RState.Failed;
  46. }
  47. if (_chamber.GetPVPosition() == 0)
  48. {
  49. Stop("钟摆阀没有打开");
  50. return RState.Failed;
  51. }
  52. _chamber.OpenValve(ValveType.Guage, true);
  53. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  54. _chamber.OpenValve(ValveType.TurboPumpPurge, true);
  55. counter = 1;
  56. Reset();
  57. gasIndex = (int)objs[0];
  58. gasTime = (int)objs[1];
  59. gasSetPoint = (int)objs[2];
  60. m_VATPerformanceResult = new VATPerformanceResult();
  61. m_VATPerformanceResult.StartTime = DateTime.Now.ToString("yyyyMMddHHmm");
  62. m_VATPerformanceResult.FlowTime = gasTime;
  63. m_VATPerformanceResult.GasName = $"Gas{gasIndex.ToString()}";
  64. currentCMPressure = CMPressure.CM1;
  65. m_sb.Clear();
  66. return Runner.Start(Module, Name);
  67. }
  68. public RState Monitor()
  69. {
  70. Runner.Delay((int)VATPerformanceStep.kDelay_1s, 1000 * 1)
  71. .LoopStart((int)VATPerformanceStep.kStartGas, "VAT Performance Test", Positions.Count, () => SetPositionGas(), gasTime)
  72. .LoopEnd((int)VATPerformanceStep.kReadChamberPressure, ReadChamberPressure, 2000)
  73. .End((int)VATPerformanceStep.kEnd, () =>
  74. {
  75. m_VATPerformanceResult.EndTime=DateTime.Now.ToString("yyyyMMddHHmm");
  76. _chamber.CloseValves();
  77. SerializeHelper.Instance.WriteToJsonFile<VATPerformanceResult>(m_VATPerformanceResult, $"VATPerformanceResult/{m_VATPerformanceResult.GasName}/{m_VATPerformanceResult.StartTime}.json");
  78. return true;
  79. }, 500);
  80. return Runner.Status;
  81. }
  82. private bool SetPositionGas()
  83. {
  84. if (!_chamber.SetPVPostion(Positions[counter - 1]))
  85. {
  86. return false;
  87. }
  88. if (gasIndex <= 4)
  89. {
  90. _chamber.OpenValve(valveTypes[gasIndex - 1], true);
  91. }
  92. _chamber.OpenValve(ValveType.GasFinal, true);
  93. _chamber.FlowGas(gasIndex - 1, gasSetPoint);
  94. return true;
  95. }
  96. private bool ReadChamberPressure()
  97. {
  98. double pressureValue;
  99. if (currentCMPressure == CMPressure.CM1)
  100. {
  101. pressureValue = _chamber.ProcessLowPressure;
  102. if (Math.Abs(pressureValue - 100) < 3)
  103. {
  104. pressureValue = _chamber.ProcessHighPressure;
  105. currentCMPressure = CMPressure.CM2;
  106. }
  107. }
  108. else
  109. {
  110. pressureValue = _chamber.ProcessHighPressure;
  111. if (pressureValue < 100)
  112. {
  113. if (_chamber.IsGuageValveOpened == false)
  114. {
  115. _chamber.OpenValve(ValveType.Guage, true);
  116. System.Threading.Thread.Sleep(3000);
  117. }
  118. pressureValue = _chamber.ProcessLowPressure;
  119. currentCMPressure = CMPressure.CM1;
  120. }
  121. }
  122. var value =Math.Round(gasSetPoint / pressureValue,3);
  123. m_VATPerformanceResult.ValuePairs.Add(value);
  124. m_sb.Append(value.ToString());
  125. m_sb.Append(',');
  126. counter += 1;
  127. return true;
  128. }
  129. public void Abort()
  130. {
  131. _chamber.CloseValves();
  132. }
  133. }
  134. }