PMVATPerformanceRoutine.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 };//ValveType.PV11, ValveType.PV21, ValveType.PV31, ValveType.PV41,ValveType.PV51,ValveType.PV61,ValveType.PV71,ValveType.PV81, ValveType.PV91, ValveType.PVA1, ValveType.PVB1, ValveType.PVC1,
  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(VATPerformanceStep.kDelay_1s, 1000 * 1)
  71. .LoopStart(VATPerformanceStep.kStartGas, "VAT Performance Test", Positions.Count, () => SetPositionGas(), gasTime)
  72. .LoopEnd(VATPerformanceStep.kReadChamberPressure, ReadChamberPressure, 2000)
  73. .End(VATPerformanceStep.kEnd, () =>
  74. {
  75. m_VATPerformanceResult.EndTime=DateTime.Now.ToString("yyyyMMddHHmm");
  76. _chamber.CloseValves();
  77. SerializeHelper.Instance.WriteToJsonFile<VATPerformanceResult>(m_VATPerformanceResult, $"VATPerformanceResult/{_chamber.Module}/{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 (_chamber.ChamberType==JetChamber.VenusDE|| _chamber.ChamberType == JetChamber.VenusSE)
  89. {
  90. 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, };
  91. _chamber.OpenValve(valveTypes[gasIndex - 1], true);
  92. _chamber.OpenValve(ValveType.GasFinal, true);
  93. _chamber.FlowGas(gasIndex - 1, gasSetPoint);
  94. }
  95. else
  96. {
  97. if (gasIndex <= 4)
  98. {
  99. _chamber.OpenValve(valveTypes[gasIndex - 1], true);
  100. }
  101. _chamber.OpenValve(ValveType.GasFinal, true);
  102. _chamber.FlowGas(gasIndex - 1, gasSetPoint);
  103. }
  104. return true;
  105. }
  106. private bool ReadChamberPressure()
  107. {
  108. double criticalValue = 0;
  109. if (_chamber.ChamberType == JetChamber.Kepler2200A || _chamber.ChamberType == JetChamber.Kepler2200B)
  110. {
  111. criticalValue = 2000;
  112. }
  113. else
  114. {
  115. criticalValue = 100;
  116. }
  117. double pressureValue;
  118. if (currentCMPressure == CMPressure.CM1)
  119. {
  120. pressureValue = _chamber.ProcessPressure;
  121. if (Math.Abs(pressureValue - criticalValue) < 3)
  122. {
  123. pressureValue = _chamber.ChamberPressure;
  124. currentCMPressure = CMPressure.CM2;
  125. }
  126. }
  127. else
  128. {
  129. pressureValue = _chamber.ChamberPressure;
  130. if (pressureValue < criticalValue)
  131. {
  132. if (_chamber.IsGuageValveOpened == false)
  133. {
  134. _chamber.OpenValve(ValveType.Guage, true);
  135. System.Threading.Thread.Sleep(3000);
  136. }
  137. pressureValue = _chamber.ProcessPressure;
  138. currentCMPressure = CMPressure.CM1;
  139. }
  140. }
  141. var value =Math.Round(gasSetPoint / pressureValue,3);
  142. m_VATPerformanceResult.ValuePairs.Add(value);
  143. m_sb.Append(value.ToString());
  144. m_sb.Append(',');
  145. counter += 1;
  146. return true;
  147. }
  148. public void Abort()
  149. {
  150. _chamber.CloseValves();
  151. }
  152. }
  153. }