RFPowerSwitchRoutine.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Venus_RT.Devices;
  4. using MECF.Framework.Common.Routine;
  5. using Venus_Core;
  6. using Aitex.Core.Common.DeviceData;
  7. using System;
  8. namespace Venus_RT.Modules.PMs
  9. {
  10. class RFPowerSwitchRoutine : PMRoutineBase, IRoutine
  11. {
  12. enum RFPowerStep
  13. {
  14. kSetPower,
  15. kEnd,
  16. }
  17. private bool _bOn = true;
  18. private bool _enableBias;
  19. private double _rfPower;
  20. private double _rfPowerBias;
  21. private BiasRfMatchMode _matchMode;
  22. private double _matchC1;
  23. private double _matchC2;
  24. private int _rfPowerOnTime;
  25. public RFPowerSwitchRoutine(JetPMBase chamber, bool bOn) : base(chamber)
  26. {
  27. Name = "RF Power Switch";
  28. _bOn = bOn;
  29. }
  30. public RState Start(params object[] objs)
  31. {
  32. if (!_chamber.IsFastPumpOpened)
  33. {
  34. Stop("Pump 阀没有打开");
  35. return RState.Failed;
  36. }
  37. _enableBias = SC.GetValue<bool>($"{_chamber.Module}.BiasRf.EnableBiasRF");
  38. if (_bOn)
  39. {
  40. if (objs == null || objs.Length < 3)
  41. {
  42. Stop("RF routine argument error");
  43. return RState.Failed;
  44. }
  45. _rfPower = Convert.ToDouble(objs[0]);
  46. _rfPowerBias = Convert.ToDouble(objs[1]);
  47. _rfPowerOnTime = (int)Convert.ToDouble(objs[2]) * 1000;
  48. _matchMode = Convert.ToInt32(objs[3]) == 1 ? BiasRfMatchMode.Preset : BiasRfMatchMode.Hold;
  49. _matchC1 = Convert.ToDouble(objs[4]);
  50. _matchC2 = Convert.ToDouble(objs[5]);
  51. }
  52. else
  53. {
  54. _rfPower = 0.0;
  55. _rfPowerBias = 0.0;
  56. _matchMode = BiasRfMatchMode.Preset;
  57. _matchC1 = 0.0;
  58. _matchC2 = 0.0;
  59. _rfPowerOnTime = 2000;
  60. }
  61. Reset();
  62. return Runner.Start(Module, Name);
  63. }
  64. public RState Monitor()
  65. {
  66. Runner.Run(RFPowerStep.kSetPower, SetRFPower, _rfPowerOnTime)
  67. .End(RFPowerStep.kEnd, RFPowerFinished, _delay_1s);
  68. return Runner.Status;
  69. }
  70. private bool SetRFPower()
  71. {
  72. if(_bOn)
  73. {
  74. if (_enableBias)
  75. Notify($"放电开始, 源射频设定值 {_rfPower}, 偏压射频设定值 {_rfPowerBias}");
  76. else
  77. Notify($"放电开始, 源射频设定值 {_rfPower}");
  78. if (Math.Abs(_rfPower) > 0.01 && Math.Abs(_rfPowerBias) > 0.01)
  79. {
  80. _chamber.GeneratorSetpower((float)_rfPower);
  81. _chamber.GeneratorBiasSetpower((float)_rfPowerBias);
  82. if (_matchMode == BiasRfMatchMode.Preset)
  83. {
  84. _chamber.GeneratorBiasSetMatchMode(true);
  85. Notify($"Bias RF Match C1设定值 {_matchC1}, Bias RF Match C2设定值 {_matchC2}");
  86. _chamber.SetBiasMatchPosition((float)_matchC1, (float)_matchC2);
  87. }
  88. else if (_matchMode == BiasRfMatchMode.Hold)
  89. {
  90. _chamber.GeneratorBiasSetMatchMode(false);
  91. }
  92. return _chamber.GeneratorPowerOn(true) && _chamber.GeneratorBiasPowerOn(true);
  93. }
  94. else if (Math.Abs(_rfPower) < 0.01 && Math.Abs(_rfPowerBias) > 0.01)
  95. {
  96. if (_matchMode == BiasRfMatchMode.Preset)
  97. {
  98. _chamber.GeneratorBiasSetMatchMode(true);
  99. Notify($"Bias RF Match C1设定值 {_matchC1}, Bias RF Match C2设定值 {_matchC2}");
  100. _chamber.SetBiasMatchPosition((float)_matchC1, (float)_matchC2);
  101. }
  102. else if (_matchMode == BiasRfMatchMode.Hold)
  103. {
  104. _chamber.GeneratorBiasSetMatchMode(false);
  105. }
  106. _chamber.GeneratorBiasSetpower((float)_rfPowerBias);
  107. return _chamber.GeneratorBiasPowerOn(true);
  108. }
  109. else if (Math.Abs(_rfPower) > 0.01 && Math.Abs(_rfPowerBias) < 0.01)
  110. {
  111. _chamber.GeneratorSetpower((float)_rfPower);
  112. return _chamber.GeneratorPowerOn(true);
  113. }
  114. else
  115. {
  116. Notify("放电结束");
  117. return false;
  118. }
  119. }
  120. else
  121. {
  122. Notify("放电停止");
  123. if (!_enableBias)
  124. return _chamber.GeneratorPowerOn(false);
  125. return _chamber.GeneratorPowerOn(false) && _chamber.GeneratorBiasPowerOn(false);
  126. }
  127. }
  128. private bool RFPowerFinished()
  129. {
  130. if(_bOn)
  131. {
  132. Notify("放电结束");
  133. _chamber.StopAllGases();
  134. _chamber.OpenValve(ValveType.GasFinal, false);
  135. _chamber.GeneratorPowerOn(false);
  136. _chamber.GeneratorBiasPowerOn(false);
  137. }
  138. return true;
  139. }
  140. public void Abort()
  141. {
  142. _chamber.GeneratorSetpower(0);
  143. _chamber.GeneratorBiasSetpower(0);
  144. _chamber.GeneratorPowerOn(false);
  145. _chamber.GeneratorBiasPowerOn(false);
  146. }
  147. }
  148. }