RfPowerRoutine.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using System;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using VirgoCommon;
  5. using VirgoRT.Devices;
  6. namespace VirgoRT.Modules.PMs
  7. {
  8. class RfPowerRoutine : PMRoutineBase, IRoutine
  9. {
  10. private enum RoutineStep
  11. {
  12. kRFPowerOn,
  13. kRFPowerOFF,
  14. MatchOn,
  15. End,
  16. };
  17. private readonly bool _ON;
  18. private double _rfPower;
  19. private double _matchC1;
  20. private double _matchC2;
  21. private double _rfPowerOnTime;
  22. public RfPowerRoutine(JetPM chamber, bool bON) : base(chamber)
  23. {
  24. Name = "RF Power";
  25. _ON = bON;
  26. }
  27. public Result Start(params object[] objs)
  28. {
  29. if (!_chamber.IsFastPumpOpened)
  30. {
  31. Stop("Pump 阀没有打开");
  32. return Result.FAIL;
  33. }
  34. //if (_chamber.TotalGasSetpoint <= 0)
  35. //{
  36. // Stop("No gas flowing for RF power on");
  37. // return Result.FAIL;
  38. //}
  39. Reset();
  40. if (_ON)
  41. {
  42. if (objs == null || objs.Length < 3)
  43. throw new ArgumentException("RF routine argument error");
  44. _rfPower = Convert.ToDouble(objs[0]);
  45. _rfPowerOnTime = Convert.ToDouble(objs[1]);
  46. _matchC1 = Convert.ToDouble(objs[2]);
  47. _matchC2 = Convert.ToDouble(objs[3]);
  48. }
  49. else
  50. {
  51. _rfPower = 0.0;
  52. _matchC1 = 0.0;
  53. _matchC2 = 0.0;
  54. _rfPowerOnTime = 0.0;
  55. }
  56. return Result.RUN;
  57. }
  58. public Result Monitor()
  59. {
  60. try
  61. {
  62. if (_ON)
  63. {
  64. RFPowerOn((int)RoutineStep.kRFPowerOn, "RF Power On");
  65. }
  66. else
  67. {
  68. RFPowerOFF((int)RoutineStep.kRFPowerOFF, "RF Power OFF");
  69. }
  70. //MatchOn((int)RoutineStep.MatchOn, "Match On");
  71. End((int)RoutineStep.End);
  72. }
  73. catch (RoutineBreakException)
  74. {
  75. return Result.RUN;
  76. }
  77. catch (RoutineFaildException)
  78. {
  79. return Result.FAIL;
  80. }
  81. catch (Exception ex)
  82. {
  83. Stop(ex.Message);
  84. return Result.FAIL;
  85. }
  86. return Result.DONE;
  87. }
  88. public void RFPowerOn(int id, string name)
  89. {
  90. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  91. {
  92. Notify($"放电开始, 设定值 {_rfPower}");
  93. _chamber.GeneratorSetpower((float)_rfPower);
  94. return _chamber.GeneratorPowerOn(true);
  95. }, () =>
  96. {
  97. if (Elapsed >= _rfPowerOnTime)
  98. {
  99. Notify("放电结束");
  100. _chamber.StopAllGases();
  101. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  102. _chamber.GeneratorPowerOn(false);
  103. return true;
  104. }
  105. return false;
  106. }, _rfPowerOnTime * 1000);
  107. if (ret.Item1)
  108. {
  109. if (ret.Item2 == Result.FAIL)
  110. {
  111. _chamber.StopAllGases();
  112. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  113. _chamber.GeneratorPowerOn(false);
  114. throw new RoutineFaildException();
  115. }
  116. throw new RoutineBreakException();
  117. }
  118. }
  119. public void RFPowerOFF(int id, string name)
  120. {
  121. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  122. {
  123. Notify("放电停止");
  124. return _chamber.GeneratorPowerOn(false);
  125. }, () => true, 2000);
  126. if (ret.Item1)
  127. {
  128. if (ret.Item2 == Result.FAIL)
  129. {
  130. _chamber.StopAllGases();
  131. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  132. throw new RoutineFaildException();
  133. }
  134. throw new RoutineBreakException();
  135. }
  136. }
  137. public void MatchOn(int id, string name)
  138. {
  139. bool Func()
  140. {
  141. Notify($"Match C1设定值 {_matchC1}, Match C2设定值 {_matchC2}");
  142. if (_chamber.SetMatchPosition((float)_matchC1, (float)_matchC2))
  143. {
  144. return true;
  145. }
  146. return false;
  147. }
  148. bool? Check1()
  149. {
  150. return true;
  151. }
  152. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 0);
  153. if (ret.Item1)
  154. {
  155. if (ret.Item2 == Result.FAIL)
  156. {
  157. throw new RoutineFaildException();
  158. }
  159. throw new RoutineBreakException();
  160. }
  161. }
  162. public override void Abort()
  163. {
  164. _chamber.GeneratorSetpower(0);
  165. _chamber.GeneratorPowerOn(false);
  166. }
  167. }
  168. }