RfPowerRoutine.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System;
  2. using Aitex.Core.Common.DeviceData;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using VirgoCommon;
  6. using VirgoRT.Devices;
  7. namespace VirgoRT.Modules.PMs
  8. {
  9. class RfPowerRoutine : PMRoutineBase, IRoutine
  10. {
  11. private enum RoutineStep
  12. {
  13. kRFPowerOn,
  14. kRFPowerOFF,
  15. MatchOn,
  16. End,
  17. };
  18. private bool _enableBias;
  19. private readonly bool _ON;
  20. private double _rfPower;
  21. private double _rfPowerBias;
  22. private BiasRfMatchMode _matchMode;
  23. private double _matchC1;
  24. private double _matchC2;
  25. private double _rfPowerOnTime;
  26. public RfPowerRoutine(JetPM chamber, bool bON) : base(chamber)
  27. {
  28. Name = "RF Power";
  29. _ON = bON;
  30. }
  31. public Result Start(params object[] objs)
  32. {
  33. if (!_chamber.IsFastPumpOpened)
  34. {
  35. Stop("Pump 阀没有打开");
  36. return Result.FAIL;
  37. }
  38. //if (_chamber.TotalGasSetpoint <= 0)
  39. //{
  40. // Stop("No gas flowing for RF power on");
  41. // return Result.FAIL;
  42. //}
  43. Reset();
  44. _enableBias = SC.GetValue<bool>($"{_chamber.Module}.BiasRf.EnableBiasRF");
  45. if (_ON)
  46. {
  47. if (objs == null || objs.Length < 3)
  48. throw new ArgumentException("RF routine argument error");
  49. _rfPower = Convert.ToDouble(objs[0]);
  50. _rfPowerBias = Convert.ToDouble(objs[1]);
  51. _rfPowerOnTime = Convert.ToDouble(objs[2]);
  52. _matchMode = Convert.ToInt32(objs[3]) == 1 ? BiasRfMatchMode.Preset : BiasRfMatchMode.Hold;
  53. _matchC1 = Convert.ToDouble(objs[4]);
  54. _matchC2 = Convert.ToDouble(objs[5]);
  55. }
  56. else
  57. {
  58. _rfPower = 0.0;
  59. _rfPowerBias = 0.0;
  60. _matchMode = BiasRfMatchMode.Preset;
  61. _matchC1 = 0.0;
  62. _matchC2 = 0.0;
  63. _rfPowerOnTime = 0.0;
  64. }
  65. return Result.RUN;
  66. }
  67. public Result Monitor()
  68. {
  69. try
  70. {
  71. if (_ON)
  72. {
  73. RFPowerOn((int)RoutineStep.kRFPowerOn, "RF Power On");
  74. }
  75. else
  76. {
  77. RFPowerOFF((int)RoutineStep.kRFPowerOFF, "RF Power OFF");
  78. }
  79. //MatchOn((int)RoutineStep.MatchOn, "Match On");
  80. End((int)RoutineStep.End);
  81. }
  82. catch (RoutineBreakException)
  83. {
  84. return Result.RUN;
  85. }
  86. catch (RoutineFaildException)
  87. {
  88. return Result.FAIL;
  89. }
  90. catch (Exception ex)
  91. {
  92. Stop(ex.Message);
  93. return Result.FAIL;
  94. }
  95. return Result.DONE;
  96. }
  97. public void RFPowerOn(int id, string name)
  98. {
  99. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  100. {
  101. if (_enableBias)
  102. Notify($"放电开始, 源射频设定值 {_rfPower}, 偏压射频设定值 {_rfPowerBias}");
  103. else
  104. Notify($"放电开始, 源射频设定值 {_rfPower}");
  105. if (Math.Abs(_rfPower) > 0.01 && Math.Abs(_rfPowerBias) > 0.01)
  106. {
  107. _chamber.GeneratorSetpower((float)_rfPower);
  108. _chamber.GeneratorBiasSetpower((float)_rfPowerBias);
  109. if (_matchMode == BiasRfMatchMode.Preset)
  110. {
  111. _chamber.GeneratorBiasSetMatchMode(true);
  112. Notify($"Bias RF Match C1设定值 {_matchC1}, Bias RF Match C2设定值 {_matchC2}");
  113. _chamber.SetBiasMatchPosition((float)_matchC1, (float)_matchC2);
  114. }
  115. else if (_matchMode == BiasRfMatchMode.Hold)
  116. {
  117. _chamber.GeneratorBiasSetMatchMode(false);
  118. }
  119. return _chamber.GeneratorPowerOn(true) && _chamber.GeneratorBiasPowerOn(true);
  120. }
  121. else if (Math.Abs(_rfPower) < 0.01 && Math.Abs(_rfPowerBias) > 0.01)
  122. {
  123. if (_matchMode == BiasRfMatchMode.Preset)
  124. {
  125. _chamber.GeneratorBiasSetMatchMode(true);
  126. Notify($"Bias RF Match C1设定值 {_matchC1}, Bias RF Match C2设定值 {_matchC2}");
  127. _chamber.SetBiasMatchPosition((float)_matchC1, (float)_matchC2);
  128. }
  129. else if (_matchMode == BiasRfMatchMode.Hold)
  130. {
  131. _chamber.GeneratorBiasSetMatchMode(false);
  132. }
  133. _chamber.GeneratorBiasSetpower((float)_rfPowerBias);
  134. return _chamber.GeneratorBiasPowerOn(true);
  135. }
  136. else if (Math.Abs(_rfPower) > 0.01 && Math.Abs(_rfPowerBias) < 0.01)
  137. {
  138. _chamber.GeneratorSetpower((float)_rfPower);
  139. return _chamber.GeneratorPowerOn(true);
  140. }
  141. else
  142. {
  143. Notify("放电结束");
  144. return false;
  145. }
  146. }, () =>
  147. {
  148. if (Elapsed >= _rfPowerOnTime)
  149. {
  150. Notify("放电结束");
  151. _chamber.StopAllGases();
  152. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  153. _chamber.GeneratorPowerOn(false);
  154. _chamber.GeneratorBiasPowerOn(false);
  155. return true;
  156. }
  157. return false;
  158. }, _rfPowerOnTime * 1000);
  159. if (ret.Item1)
  160. {
  161. if (ret.Item2 == Result.FAIL)
  162. {
  163. _chamber.StopAllGases();
  164. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  165. _chamber.GeneratorPowerOn(false);
  166. _chamber.GeneratorBiasPowerOn(false);
  167. throw new RoutineFaildException();
  168. }
  169. throw new RoutineBreakException();
  170. }
  171. }
  172. public void RFPowerOFF(int id, string name)
  173. {
  174. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  175. {
  176. Notify("放电停止");
  177. if (!_enableBias)
  178. return _chamber.GeneratorPowerOn(false);
  179. return _chamber.GeneratorPowerOn(false) && _chamber.GeneratorBiasPowerOn(false);
  180. }, () => true, 2000);
  181. if (ret.Item1)
  182. {
  183. if (ret.Item2 == Result.FAIL)
  184. {
  185. _chamber.StopAllGases();
  186. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  187. throw new RoutineFaildException();
  188. }
  189. throw new RoutineBreakException();
  190. }
  191. }
  192. public void MatchOn(int id, string name)
  193. {
  194. bool Func()
  195. {
  196. Notify($"Match C1设定值 {_matchC1}, Match C2设定值 {_matchC2}");
  197. if (_chamber.SetMatchPosition((float)_matchC1, (float)_matchC2))
  198. {
  199. return true;
  200. }
  201. return false;
  202. }
  203. bool? Check1()
  204. {
  205. return true;
  206. }
  207. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 0);
  208. if (ret.Item1)
  209. {
  210. if (ret.Item2 == Result.FAIL)
  211. {
  212. throw new RoutineFaildException();
  213. }
  214. throw new RoutineBreakException();
  215. }
  216. }
  217. public void BiasMatchOn(int id, string name)
  218. {
  219. bool Func()
  220. {
  221. Notify($"Bias RF Match C1设定值 {_matchC1}, Bias RF Match C2设定值 {_matchC2}");
  222. if (_chamber.SetBiasMatchPosition((float)_matchC1, (float)_matchC2))
  223. {
  224. return true;
  225. }
  226. return false;
  227. }
  228. bool? Check1()
  229. {
  230. return true;
  231. }
  232. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 0);
  233. if (ret.Item1)
  234. {
  235. if (ret.Item2 == Result.FAIL)
  236. {
  237. throw new RoutineFaildException();
  238. }
  239. throw new RoutineBreakException();
  240. }
  241. }
  242. public override void Abort()
  243. {
  244. _chamber.GeneratorSetpower(0);
  245. _chamber.GeneratorBiasSetpower(0);
  246. _chamber.GeneratorPowerOn(false);
  247. _chamber.GeneratorBiasPowerOn(false);
  248. }
  249. }
  250. }