PostProcess.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. public MovementPosition LiftPinPosition
  84. {
  85. get
  86. {
  87. if (head != null)
  88. {
  89. if (!string.IsNullOrEmpty(head.VentingPinState))
  90. {
  91. switch (head.VentingPinState)
  92. {
  93. case "Up":
  94. return MovementPosition.Up;
  95. case "Middle":
  96. return MovementPosition.Middle;
  97. case "Down":
  98. return MovementPosition.Down;
  99. }
  100. }
  101. }
  102. return MovementPosition.Down;
  103. }
  104. }
  105. //--------------------------------Constructor------------------------------------
  106. //
  107. public PostProcessRoutine(JetPM chamber, VentRoutine _vRoutine) : base(chamber)
  108. {
  109. Name = "PostProcess";
  110. _rfPowerRoutine = new RfPowerRoutine(_chamber, false);
  111. _ventRoutine = _vRoutine;
  112. }
  113. public void Terminate()
  114. {
  115. }
  116. public Result Start(params object[] objs)
  117. {
  118. try
  119. {
  120. Reset();
  121. //this.UpdateSCValue();
  122. RecipeName = (string)objs[0];
  123. RecipeContext = (string)objs[1];
  124. List<RecipeStep> recipeSteps;
  125. if (!Recipe.Parse(Module, RecipeContext, out head, out recipeSteps))
  126. {
  127. return Result.FAIL;
  128. }
  129. _purgeCycleCount = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeCycleCount");
  130. _purgeVentPressure = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentPressure");
  131. _purgePumpPressure = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpPressure");
  132. _purgeVentTimeLimit = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentTimeLimit");
  133. _purgePumpTimeLimit = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpTimeLimit");
  134. _purgeVentStableTime = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgeVentStableTime");
  135. _purgePumpStableTime = (int)SC.GetValue<double>($"{_chamber.Module}.Purge.PurgePumpStableTime");
  136. _ventTime = (int)SC.GetValue<double>($"{_chamber.Module}.VentTime");
  137. //_ventTimeLimit = (int)SC.GetSC<double>(SCName.System_VentTimeLimit).Value;
  138. }
  139. catch (Exception ex)
  140. {
  141. LOG.Write(ex, "Post process Start has exception");
  142. return Result.FAIL;
  143. }
  144. Notify("Start");
  145. return Result.RUN;
  146. }
  147. public Result Monitor()
  148. {
  149. try
  150. {
  151. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  152. {
  153. TimeDelay((int)PostProcessSequence.DelayForTest, 10);
  154. }
  155. ExecuteRoutine((int)PostProcessSequence.RFPowerOff, _rfPowerRoutine);
  156. CloseAllValve((int)PostProcessSequence.CloseAllValves, 1);
  157. if (!NotToPurgeOrVent) //For keep vacuum after idle clean
  158. {
  159. if (PurgeActive)
  160. {
  161. StartLoop((int)PostProcessSequence.Loop, "", _purgeCycleCount, Notify, Stop);
  162. CyclePump((int)PostProcessSequence.Pump, _purgePumpPressure, _purgePumpTimeLimit, true);
  163. TimeDelay((int)PostProcessSequence.PumpDelay, _purgePumpStableTime);
  164. CycleVent((int)PostProcessSequence.Vent, _purgeVentPressure, _purgeVentTimeLimit, true);
  165. TimeDelay((int)PostProcessSequence.VentDelay, _purgeVentStableTime);
  166. EndLoop((int)PostProcessSequence.EndLoop, Notify, Stop);
  167. }
  168. ParallellyVentAndLiftPin((int)PostProcessSequence.VentAndPinDown);
  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("Error");
  180. return Result.FAIL;
  181. }
  182. catch (Exception ex)
  183. {
  184. Stop(ex.Message);
  185. return Result.FAIL;
  186. }
  187. Notify("Finish");
  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($"Set lift pin {_chamber.Name} {LiftPinPosition}");
  205. if (!_chamber.SetLiftPin(LiftPinPosition, 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.CheckLiftPinPos(LiftPinPosition);
  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.CheckLiftPinPos(LiftPinPosition) ? $"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. }