PostProcess.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. using System;
  2. using System.Collections.Generic;
  3. using Aitex.Core.Equipment.SusceptorDefine;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.Routine;
  7. using Aitex.Core.RT.SCCore;
  8. using MECF.Framework.Common.DBCore;
  9. using VirgoRT.Devices;
  10. using VirgoCommon;
  11. namespace VirgoRT.Modules.PMs
  12. {
  13. class PostProcessRoutine : PMRoutineBase
  14. {
  15. private enum PostProcessSequence
  16. {
  17. DelayForTest,
  18. RFPowerOff,
  19. StopGasFlow,
  20. CloseAllValves,
  21. ClosePumpValve,
  22. DelayWaitValve,
  23. Loop,
  24. SetLiftPin,
  25. Pump,
  26. PumpDelay,
  27. Vent,
  28. VentDelay,
  29. EndLoop,
  30. ClosePurgeValve,
  31. VentEndToPrecision,
  32. VentEndDelay,
  33. VentEndCloseVentValve,
  34. VentAndPinDown,
  35. End,
  36. };
  37. private RecipeHead head;
  38. private int _purgeCycleCount;
  39. private int _purgeVentPressure;
  40. private int _purgePumpPressure;
  41. private int _purgeVentTimeLimit;
  42. private int _purgePumpTimeLimit;
  43. private int _purgeVentStableTime;
  44. private int _purgePumpStableTime;
  45. private int _ventTime;
  46. //private int _ventTimeLimit;
  47. private readonly RfPowerRoutine _rfPowerRoutine;
  48. private readonly VentRoutine _ventRoutine;
  49. private readonly int _VentingAndPinUpTimeout = 60 * 1000;
  50. //---------------------------------Properties------------------------------------
  51. //
  52. public string RecipeName { get; private set; }
  53. public string RecipeContext { get; private set; }
  54. private bool PurgeActive
  55. {
  56. get
  57. {
  58. if (head != null)
  59. {
  60. if (!string.IsNullOrEmpty(head.PurgeActive))
  61. {
  62. return Convert.ToBoolean(head.PurgeActive);
  63. }
  64. }
  65. return true;
  66. }
  67. }
  68. //For keep vacuum after idle clean
  69. private bool NotToPurgeOrVent
  70. {
  71. get
  72. {
  73. if (head != null)
  74. {
  75. if (!string.IsNullOrEmpty(head.NotToPurgeOrVent))
  76. {
  77. return Convert.ToBoolean(head.NotToPurgeOrVent);
  78. }
  79. }
  80. return false;
  81. }
  82. }
  83. private bool LiftPinWhileVenting
  84. {
  85. get
  86. {
  87. if (head != null)
  88. {
  89. if (!string.IsNullOrEmpty(head.VentingPinState))
  90. {
  91. return head.VentingPinState == "Up" ? true : false;
  92. }
  93. }
  94. return false;
  95. }
  96. }
  97. //--------------------------------Constructor------------------------------------
  98. //
  99. public PostProcessRoutine(JetPM chamber, VentRoutine _vRoutine) : base(chamber)
  100. {
  101. Name = "PostProcess";
  102. _rfPowerRoutine = new RfPowerRoutine(_chamber, false);
  103. _ventRoutine = _vRoutine;
  104. }
  105. public void Terminate()
  106. {
  107. }
  108. public Result Start(params object[] objs)
  109. {
  110. try
  111. {
  112. Reset();
  113. //this.UpdateSCValue();
  114. RecipeName = (string)objs[0];
  115. RecipeContext = (string)objs[1];
  116. List<RecipeStep> recipeSteps;
  117. if (!Recipe.Parse(Module, RecipeContext, out head, out recipeSteps))
  118. {
  119. return Result.FAIL;
  120. }
  121. _purgeCycleCount = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeCycleCount");
  122. _purgeVentPressure = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentPressure");
  123. _purgePumpPressure = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpPressure");
  124. _purgeVentTimeLimit = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentTimeLimit");
  125. _purgePumpTimeLimit = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpTimeLimit");
  126. _purgeVentStableTime = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentStableTime");
  127. _purgePumpStableTime = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpStableTime");
  128. _ventTime = (int)SC.GetValue<double>($"{_chamber.Module}.VentTime");
  129. //_ventTimeLimit = (int)SC.GetSC<double>(SCName.System_VentTimeLimit).Value;
  130. }
  131. catch (Exception ex)
  132. {
  133. LOG.Write(ex, "Post process Start has exception");
  134. return Result.FAIL;
  135. }
  136. Notify("开始");
  137. return Result.RUN;
  138. }
  139. public Result Monitor()
  140. {
  141. try
  142. {
  143. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  144. {
  145. TimeDelay((int)PostProcessSequence.DelayForTest, 10);
  146. }
  147. ExecuteRoutine((int)PostProcessSequence.RFPowerOff, _rfPowerRoutine);
  148. CloseAllValve((int)PostProcessSequence.CloseAllValves, 1);
  149. if (!NotToPurgeOrVent) //For keep vacuum after idle clean
  150. {
  151. if (PurgeActive)
  152. {
  153. StartLoop((int)PostProcessSequence.Loop, "", _purgeCycleCount, Notify, Stop);
  154. CyclePump((int)PostProcessSequence.Pump, _purgePumpPressure, _purgePumpTimeLimit, true);
  155. TimeDelay((int)PostProcessSequence.PumpDelay, _purgePumpStableTime);
  156. CycleVent((int)PostProcessSequence.Vent, _purgeVentPressure, _purgeVentTimeLimit, true);
  157. TimeDelay((int)PostProcessSequence.VentDelay, _purgeVentStableTime);
  158. EndLoop((int)PostProcessSequence.EndLoop, Notify, Stop);
  159. }
  160. if(LiftPinWhileVenting)
  161. {
  162. ParallellyVentAndLiftPin((int)PostProcessSequence.VentAndPinDown);
  163. }
  164. else
  165. {
  166. SetLiftPinUpDown((int)PostProcessSequence.SetLiftPin, false, 5000);
  167. ExecuteRoutine((int)PostProcessSequence.VentEndToPrecision, _ventRoutine);
  168. }
  169. CloseValve((int)PostProcessSequence.VentEndCloseVentValve, valveOpenCloseTimeout);
  170. }
  171. End((int)PostProcessSequence.End);
  172. }
  173. catch (RoutineBreakException)
  174. {
  175. return Result.RUN;
  176. }
  177. catch (RoutineFaildException)
  178. {
  179. Notify("出错");
  180. return Result.FAIL;
  181. }
  182. catch (Exception ex)
  183. {
  184. Stop(ex.Message);
  185. return Result.FAIL;
  186. }
  187. Notify("结束");
  188. return Result.DONE;
  189. }
  190. public void Exit()
  191. {
  192. //ProcessDataRecorder.End(RecipeRunGuid.ToString(), SusceptorStatus.Processed.ToString(), Module);
  193. //if (DeviceModel.SignalTower != null)
  194. //{
  195. // DeviceModel.SignalTower.BuzzerBlinking(SC.GetValue<double>(SCName.System_BuzzerBlinkingTime));
  196. //}
  197. //update processing end time
  198. //Singleton<ProcessRecorder>.Instance.EndRecipeProcess(Singleton<PMEntity>.Instance.CurrentRunningJob.RecipeRunId, SusceptorStatus.Processed);
  199. }
  200. private void ParallellyVentAndLiftPin(int id)
  201. {
  202. bool Func()
  203. {
  204. Notify($"设置 lift pin {_chamber.Name} " + "升");
  205. if (!_chamber.SetLiftPin(MovementPosition.Up, out string reason))
  206. {
  207. Stop(reason);
  208. return false;
  209. }
  210. _ventRoutine.Start();
  211. return true;
  212. }
  213. bool? Check1()
  214. {
  215. bool res1 = _chamber.CheckLiftUp();
  216. var result = _ventRoutine.Monitor();
  217. return res1 && result == Result.DONE;
  218. }
  219. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, _VentingAndPinUpTimeout);
  220. if (ret.Item1)
  221. {
  222. if (ret.Item2 == Result.FAIL)
  223. {
  224. throw new RoutineFaildException();
  225. }
  226. if (ret.Item2 == Result.TIMEOUT)
  227. {
  228. Stop(_chamber.CheckLiftUp() ? $"Set Pin Up timeout in {_VentingAndPinUpTimeout / 1000} seconds" : $"Venting timeout in {_VentingAndPinUpTimeout / 1000} seconds");
  229. throw new RoutineFaildException();
  230. }
  231. throw new RoutineBreakException();
  232. }
  233. }
  234. }
  235. }