TemperatureControlRoutine.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using JetVirgoPM.Devices;
  5. namespace JetVirgoPM.PMs.Routines
  6. {
  7. class TemperatureControlRoutine : PMRoutineBase, IStepRoutine
  8. {
  9. private enum TCSequence
  10. {
  11. CheckCoolantTemp1,
  12. CheckCoolantTemp2,
  13. kCheckTemperature1,
  14. kCheckTemperature2,
  15. kCheckLETemperature,
  16. kEnd
  17. }
  18. private int _checkChamberTempTimeout = 60;
  19. private double _TargetTemp = 0.0f;
  20. private double _TargetTemp1 = 0.0f;
  21. private double _TargetTemp2 = 0.0f;
  22. private double _Chiller1OffsetTemp = 0.0f;
  23. private double _Chiller2OffsetTemp = 0.0f;
  24. private double _tolerance;
  25. private bool _enableChiller1;
  26. private bool _enableChiller2;
  27. private bool _enableLE1;
  28. private bool _enableLE2;
  29. public bool _Chamber1Disabled;
  30. public bool _Chamber2Disabled;
  31. public TemperatureControlRoutine(JetDualPM chamber) : base(chamber)
  32. {
  33. Name = "PreHeat";
  34. bUINotify = true;
  35. }
  36. public void Terminate()
  37. {
  38. }
  39. public RState Start(params object[] objs)
  40. {
  41. try
  42. {
  43. Reset();
  44. _Chamber1Disabled = SC.GetValue<bool>($"System.SetUp.{Module}Chamber1Disabled.IsInstalled");
  45. _Chamber2Disabled = SC.GetValue<bool>($"System.SetUp.{Module}Chamber2Disabled.IsInstalled");
  46. _enableChiller1 = SC.GetValue<bool>($"{Module}.Chiller1.EnableChiller");
  47. _enableChiller2 = SC.GetValue<bool>($"{Module}.Chiller2.EnableChiller");
  48. _TargetTemp1 =Convert.ToDouble(objs[0]);
  49. _TargetTemp2 = Convert.ToDouble(objs[1]);
  50. _checkChamberTempTimeout = SC.GetValue<int>($"{Module}.CheckChamberTempTimeout");
  51. _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceToTarget");
  52. _Chiller1OffsetTemp = SC.GetValue<double>($"{Module}.Chiller1.ChillerTemperatureOffset");
  53. _Chiller2OffsetTemp = SC.GetValue<double>($"{Module}.Chiller2.ChillerTemperatureOffset");
  54. Notify($"开始,TemperatureControl 1 目标 {_TargetTemp1} ℃, 偏移值 { _Chiller1OffsetTemp} ℃");
  55. Notify($"开始,TemperatureControl 2 目标 {_TargetTemp2} ℃, 偏移值 { _Chiller2OffsetTemp} ℃");
  56. _enableLE1 = true;
  57. _enableLE2 = true;
  58. return Runner.Start(_chamber.Module.ToString(), Name);
  59. }
  60. catch
  61. {
  62. return RState.Failed;
  63. }
  64. }
  65. public RState Monitor()
  66. {
  67. Runner.Run(TCSequence.CheckCoolantTemp1, SetCoolant1Temp, CheckCoolant1Temp, _checkChamberTempTimeout * 1000)
  68. .Run(TCSequence.CheckCoolantTemp2, SetCoolant2Temp, CheckCoolant2Temp, _checkChamberTempTimeout * 1000)
  69. .Run(TCSequence.kCheckLETemperature, SetLETemp, CheckLETemp, _checkChamberTempTimeout * 1000)
  70. .Run(TCSequence.kCheckTemperature1, SetLETemp1, CheckLETemp1, _checkChamberTempTimeout * 1000)
  71. .Run(TCSequence.kCheckTemperature2, SetLETemp2, CheckLETemp2, _checkChamberTempTimeout * 1000)
  72. .End(TCSequence.kEnd, EndFunc, _delay_0s);
  73. return Runner.Status;
  74. }
  75. bool SetCoolant1Temp()
  76. {
  77. if (_enableChiller1 && !_Chamber1Disabled && _TargetTemp1 > 0 )
  78. {
  79. _enableLE1 = false;
  80. return SetCoolant1Temp(_TargetTemp1, _Chiller1OffsetTemp, _tolerance);
  81. }
  82. return true;
  83. }
  84. bool CheckCoolant1Temp()
  85. {
  86. if (_enableChiller1 && !_Chamber1Disabled && _TargetTemp1 > 0 )
  87. {
  88. return CheckCoolant1Temp(_TargetTemp1, _Chiller1OffsetTemp, _tolerance);
  89. }
  90. return true;
  91. }
  92. bool SetCoolant2Temp()
  93. {
  94. if (_enableChiller2 && !_Chamber2Disabled && _TargetTemp2 > 0 )
  95. {
  96. _enableLE2 = false;
  97. return SetCoolant2Temp(_TargetTemp2, _Chiller2OffsetTemp, _tolerance);
  98. }
  99. return true;
  100. }
  101. bool CheckCoolant2Temp()
  102. {
  103. if (_enableChiller2 && !_Chamber2Disabled && _TargetTemp2 > 0)
  104. {
  105. return CheckCoolant2Temp(_TargetTemp2, _Chiller2OffsetTemp, _tolerance);
  106. }
  107. return true;
  108. }
  109. bool SetLETemp()
  110. {
  111. if ((_enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0) && (_enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0))
  112. {
  113. return SetLETemp(_TargetTemp1, _TargetTemp2, _tolerance, _enableLE1, _enableLE2);
  114. }
  115. return true;
  116. }
  117. bool CheckLETemp()
  118. {
  119. if ((_enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0) && (_enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0))
  120. {
  121. return CheckLETemp(_TargetTemp1, _TargetTemp2, _tolerance, _enableLE1, _enableLE2);
  122. }
  123. return true;
  124. }
  125. bool SetLETemp1()
  126. {
  127. if (_enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0)
  128. {
  129. return SetLETemp(_TargetTemp1, 0, _tolerance, _enableLE1, false);
  130. }
  131. return true;
  132. }
  133. bool CheckLETemp1()
  134. {
  135. if (_enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0)
  136. {
  137. return CheckLETemp(_TargetTemp1, 0, _tolerance, _enableLE1, false);
  138. }
  139. return true;
  140. }
  141. bool SetLETemp2()
  142. {
  143. if (_enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0)
  144. {
  145. return SetLETemp(0, _TargetTemp2, _tolerance, false, _enableLE2);
  146. }
  147. return true;
  148. }
  149. bool CheckLETemp2()
  150. {
  151. if (_enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0)
  152. {
  153. return CheckLETemp(0, _TargetTemp2, _tolerance, false, _enableLE2);
  154. }
  155. return true;
  156. }
  157. public override void Abort() { }
  158. }
  159. }