RfPowerRoutine.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. using System;
  2. using Aitex.Core.Common.DeviceData;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using Aitex.Core.Util;
  6. using JetVirgoPM.Devices;
  7. namespace JetVirgoPM.PMs.Routines
  8. {
  9. class RfPowerRoutine : PMRoutineBase, IStepRoutine
  10. {
  11. private enum RoutineStep
  12. {
  13. kRFPowerOn,
  14. kRFPowerOFF,
  15. MatchOn,
  16. End,
  17. };
  18. private readonly bool _ON;
  19. private R_TRIG _rf1TimeoutTrig = new R_TRIG();
  20. private R_TRIG _rf2TimeoutTrig = new R_TRIG();
  21. public bool EnableRF1 => Math.Abs(_rf1PowerOnTime) > 0.01;
  22. public bool EnableRF2 => Math.Abs(_rf2PowerOnTime) > 0.01;
  23. private bool _enableBias1;
  24. private double _rf1Power;
  25. private double _rf1PowerBias;
  26. private BiasRfMatchMode _match1Mode;
  27. private double _match1C1;
  28. private double _match1C2;
  29. private double _rf1PowerOnTime;
  30. private bool _enableBias2;
  31. private double _rf2Power;
  32. private double _rf2PowerBias;
  33. private BiasRfMatchMode _match2Mode;
  34. private double _match2C1;
  35. private double _match2C2;
  36. private double _rf2PowerOnTime;
  37. public RfPowerRoutine(JetDualPM chamber, bool bON) : base(chamber)
  38. {
  39. Name = "RF Power";
  40. _ON = bON;
  41. }
  42. public RState Start(params object[] objs)
  43. {
  44. if (!_chamber.IsFastPumpOpened)
  45. {
  46. Stop("Pump 阀没有打开");
  47. return RState.Failed;
  48. }
  49. if (_ON && _chamber.TotalGasSetpoint <= 0)
  50. {
  51. Stop("No gas flowing for RF power on");
  52. return RState.Failed;
  53. }
  54. Reset();
  55. _enableBias1 = SC.GetValue<bool>($"{_chamber.Module}.BiasRf1.EnableBiasRF");
  56. _enableBias2 = SC.GetValue<bool>($"{_chamber.Module}.BiasRf2.EnableBiasRF");
  57. if (_ON)
  58. {
  59. if (objs == null || objs.Length < 12)
  60. throw new ArgumentException("RF routine argument error");
  61. _rf1Power = Convert.ToDouble(objs[0]);
  62. _rf1PowerBias = Convert.ToDouble(objs[1]);
  63. _rf1PowerOnTime = Convert.ToDouble(objs[2]);
  64. _match1Mode = objs[3].ToString() == "Preset" ? BiasRfMatchMode.Preset : BiasRfMatchMode.Hold;
  65. _match1C1 = Convert.ToDouble(objs[4]);
  66. _match1C2 = Convert.ToDouble(objs[5]);
  67. _rf2Power = Convert.ToDouble(objs[6]);
  68. _rf2PowerBias = Convert.ToDouble(objs[7]);
  69. _rf2PowerOnTime = Convert.ToDouble(objs[8]);
  70. _match2Mode = objs[9].ToString() == "Preset" ? BiasRfMatchMode.Preset : BiasRfMatchMode.Hold;
  71. _match2C1 = Convert.ToDouble(objs[10]);
  72. _match2C2 = Convert.ToDouble(objs[11]);
  73. }
  74. else
  75. {
  76. _rf1Power = 0.0;
  77. _rf1PowerBias = 0.0;
  78. _match1Mode = BiasRfMatchMode.Preset;
  79. _match1C1 = 0.0;
  80. _match1C2 = 0.0;
  81. _rf1PowerOnTime = 0.0;
  82. _rf2Power = 0.0;
  83. _rf2PowerBias = 0.0;
  84. _match2Mode = BiasRfMatchMode.Preset;
  85. _match2C1 = 0.0;
  86. _match2C2 = 0.0;
  87. _rf2PowerOnTime = 0.0;
  88. }
  89. return Runner.Start(_chamber.Module.ToString(), Name);
  90. }
  91. public RState Monitor()
  92. {
  93. if (_ON)
  94. {
  95. Runner.Run(RoutineStep.kRFPowerOn, RFPowerOn, CheckRFPowerOn, Math.Max((int)_rf1PowerOnTime, (int)_rf2PowerOnTime) * 1000)
  96. .End(RoutineStep.End, EndFunc, _delay_0s);
  97. }
  98. else
  99. {
  100. Runner.Run(RoutineStep.kRFPowerOFF, RFPowerOFF, CheckRFPowerOff, 2000)
  101. .End(RoutineStep.End, EndFunc, _delay_0s);
  102. }
  103. return Runner.Status;
  104. }
  105. bool RFPowerOn()
  106. {
  107. if (!EnableRF1 && !EnableRF2)
  108. {
  109. Notify($"放电结束");
  110. return false;
  111. }
  112. if (EnableRF1)
  113. {
  114. if (_enableBias1)
  115. Notify($"放电开始, 源射频1设定值 {_rf1Power}, 偏压射频1设定值 {_rf1PowerBias}");
  116. else
  117. Notify($"放电开始, 源射频1设定值 {_rf1Power}");
  118. if (Math.Abs(_rf1Power) > 0.01 && Math.Abs(_rf1PowerBias) > 0.01)
  119. {
  120. _chamber.Generator1Setpower((float)_rf1Power);
  121. _chamber.GeneratorBias1Setpower((float)_rf1PowerBias);
  122. if (_match1Mode == BiasRfMatchMode.Preset)
  123. {
  124. _chamber.GeneratorBias1SetMatchMode(true);
  125. Notify($"Bias RF 1 Match C1设定值 {_match1C1}, Bias RF 1 Match C2设定值 {_match1C2}");
  126. _chamber.SetBias1MatchPosition((float)_match1C1, (float)_match1C2);
  127. }
  128. else if (_match1Mode == BiasRfMatchMode.Hold)
  129. {
  130. _chamber.GeneratorBias1SetMatchMode(false);
  131. }
  132. _chamber.Generator1PowerOn(true);
  133. _chamber.GeneratorBias1PowerOn(true);
  134. }
  135. else if (Math.Abs(_rf1Power) < 0.01 && Math.Abs(_rf1PowerBias) > 0.01)
  136. {
  137. if (_match1Mode == BiasRfMatchMode.Preset)
  138. {
  139. _chamber.GeneratorBias1SetMatchMode(true);
  140. Notify($"Bias RF 1 Match C1设定值 {_match1C1}, Bias RF 1 Match C2设定值 {_match1C2}");
  141. _chamber.SetBias1MatchPosition((float)_match1C1, (float)_match1C2);
  142. }
  143. else if (_match1Mode == BiasRfMatchMode.Hold)
  144. {
  145. _chamber.GeneratorBias1SetMatchMode(false);
  146. }
  147. _chamber.GeneratorBias1Setpower((float)_rf1PowerBias);
  148. _chamber.GeneratorBias1PowerOn(true);
  149. }
  150. else if (Math.Abs(_rf1Power) > 0.01 && Math.Abs(_rf1PowerBias) < 0.01)
  151. {
  152. _chamber.Generator1Setpower((float)_rf1Power);
  153. _chamber.Generator1PowerOn(true);
  154. }
  155. }
  156. if (EnableRF2)
  157. {
  158. if (_enableBias2)
  159. Notify($"放电开始, 源射频2设定值 {_rf2Power}, 偏压射频2设定值 {_rf2PowerBias}");
  160. else
  161. Notify($"放电开始, 源射频2设定值 {_rf2Power}");
  162. if (Math.Abs(_rf2Power) > 0.01 && Math.Abs(_rf2PowerBias) > 0.01)
  163. {
  164. _chamber.Generator2Setpower((float)_rf2Power);
  165. _chamber.GeneratorBias2Setpower((float)_rf2PowerBias);
  166. if (_match2Mode == BiasRfMatchMode.Preset)
  167. {
  168. _chamber.GeneratorBias2SetMatchMode(true);
  169. Notify($"Bias RF 2 Match C1设定值 {_match2C1}, Bias RF 2 Match C2设定值 {_match2C2}");
  170. _chamber.SetBias2MatchPosition((float)_match2C1, (float)_match2C2);
  171. }
  172. else if (_match2Mode == BiasRfMatchMode.Hold)
  173. {
  174. _chamber.GeneratorBias2SetMatchMode(false);
  175. }
  176. _chamber.Generator2PowerOn(true);
  177. _chamber.GeneratorBias2PowerOn(true);
  178. }
  179. else if (Math.Abs(_rf2Power) < 0.01 && Math.Abs(_rf2PowerBias) > 0.01)
  180. {
  181. if (_match2Mode == BiasRfMatchMode.Preset)
  182. {
  183. _chamber.GeneratorBias2SetMatchMode(true);
  184. Notify($"Bias RF 2 Match C1设定值 {_match2C1}, Bias RF 2 Match C2设定值 {_match2C2}");
  185. _chamber.SetBias2MatchPosition((float)_match2C1, (float)_match2C2);
  186. }
  187. else if (_match2Mode == BiasRfMatchMode.Hold)
  188. {
  189. _chamber.GeneratorBias2SetMatchMode(false);
  190. }
  191. _chamber.GeneratorBias2Setpower((float)_rf2PowerBias);
  192. _chamber.GeneratorBias2PowerOn(true);
  193. }
  194. else if (Math.Abs(_rf2Power) > 0.01 && Math.Abs(_rf2PowerBias) < 0.01)
  195. {
  196. _chamber.Generator2Setpower((float)_rf2Power);
  197. _chamber.Generator2PowerOn(true);
  198. }
  199. }
  200. return true;
  201. }
  202. bool CheckRFPowerOn()
  203. {
  204. _rf1TimeoutTrig.CLK = Elapsed >= _rf1PowerOnTime;
  205. if (_rf1TimeoutTrig.Q)
  206. {
  207. Notify("RF1放电结束");
  208. _chamber.Generator1PowerOn(false);
  209. _chamber.GeneratorBias1PowerOn(false);
  210. }
  211. _rf2TimeoutTrig.CLK = Elapsed >= _rf2PowerOnTime;
  212. if (_rf2TimeoutTrig.Q)
  213. {
  214. Notify("RF2放电结束");
  215. _chamber.Generator2PowerOn(false);
  216. _chamber.GeneratorBias2PowerOn(false);
  217. }
  218. if (Elapsed >= _rf1PowerOnTime && Elapsed >= _rf2PowerOnTime)
  219. {
  220. Notify("结束");
  221. _chamber.StopAllGases();
  222. _chamber.OpenValve(ValveType.PROCESS, false);
  223. _chamber.OpenValve(ValveType.PURGE, false);
  224. _chamber.Generator1PowerOn(false);
  225. _chamber.GeneratorBias1PowerOn(false);
  226. _chamber.Generator2PowerOn(false);
  227. _chamber.GeneratorBias2PowerOn(false);
  228. return true;
  229. }
  230. return false;
  231. }
  232. bool RFPowerOFF()
  233. {
  234. Notify("放电停止");
  235. _chamber.Generator1PowerOn(false);
  236. _chamber.Generator2PowerOn(false);
  237. if (_enableBias1)
  238. _chamber.GeneratorBias1PowerOn(false);
  239. if (_enableBias2)
  240. _chamber.GeneratorBias2PowerOn(false);
  241. return true;
  242. }
  243. bool CheckRFPowerOff()
  244. {
  245. return true;
  246. }
  247. public override void Abort()
  248. {
  249. _chamber.Generator1Setpower(0);
  250. _chamber.GeneratorBias1Setpower(0);
  251. _chamber.Generator1PowerOn(false);
  252. _chamber.GeneratorBias1PowerOn(false);
  253. _chamber.Generator2Setpower(0);
  254. _chamber.GeneratorBias2Setpower(0);
  255. _chamber.Generator2PowerOn(false);
  256. _chamber.GeneratorBias2PowerOn(false);
  257. }
  258. }
  259. }