VpwRecipeRoutine.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.Util;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.RecipeCenter;
  7. using MECF.Framework.Common.Routine;
  8. using MECF.Framework.Common.Utilities;
  9. using PunkHPX8_Core;
  10. using PunkHPX8_RT.Devices.VpwCell;
  11. using PunkHPX8_RT.Devices.VpwMain;
  12. using PunkHPX8_RT.Modules.VpwMain;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. namespace PunkHPX8_RT.Modules.VpwCell
  19. {
  20. public class VpwRecipeRoutine : RoutineBase, IRoutine
  21. {
  22. private enum RecipeStep
  23. {
  24. ChamberUp,
  25. CloseDrain,
  26. CheckLoopDO,
  27. VacuumPrewet,
  28. WaitVacuumPrewet,
  29. VentPrewet,
  30. WaitVentPrewet,
  31. ExtendClean,
  32. WaitExtendClean,
  33. SpinOff,
  34. WaitSpinOff,
  35. End
  36. }
  37. #region 内部变量
  38. /// <summary>
  39. /// recipe
  40. /// </summary>
  41. private VpwRecipe _recipe;
  42. /// <summary>
  43. /// 设备
  44. /// </summary>
  45. private VpwCellDevice _vpwCellDevice;
  46. /// <summary>
  47. /// Main设备
  48. /// </summary>
  49. private VpwMainEntity _mainEntity;
  50. /// <summary>
  51. /// Vacuum prewet routine
  52. /// </summary>
  53. private VpwVacuumPrewetRoutine _vacuumPrewetRoutine;
  54. /// <summary>
  55. /// Vent Prewet
  56. /// </summary>
  57. private VpwVentPrewetRoutine _ventPrewetRoutine;
  58. /// <summary>
  59. /// Extend clean
  60. /// </summary>
  61. private VpwExtendCleanRoutine _extendCleanRoutine;
  62. /// <summary>
  63. /// Spin Off Routine
  64. /// </summary>
  65. private VpwSpinOffRoutine _spinOffRoutine;
  66. #endregion
  67. /// <summary>
  68. /// 构造函数
  69. /// </summary>
  70. /// <param name="module"></param>
  71. public VpwRecipeRoutine(string module) : base(module)
  72. {
  73. _vacuumPrewetRoutine = new VpwVacuumPrewetRoutine(Module);
  74. _ventPrewetRoutine = new VpwVentPrewetRoutine(module);
  75. _extendCleanRoutine = new VpwExtendCleanRoutine(module);
  76. _spinOffRoutine = new VpwSpinOffRoutine(module);
  77. }
  78. /// <summary>
  79. /// 中止
  80. /// </summary>
  81. public void Abort()
  82. {
  83. Runner.Stop("Manual stop");
  84. }
  85. /// <summary>
  86. /// 监控
  87. /// </summary>
  88. /// <returns></returns>
  89. public RState Monitor()
  90. {
  91. Runner.Run(RecipeStep.ChamberUp, ChamberUp, CheckChamberClosed)
  92. .Run(RecipeStep.CloseDrain, _vpwCellDevice.DrainValveOff, _delay_1ms)
  93. .Run(RecipeStep.CheckLoopDO, CheckLoopDO, _delay_1ms)
  94. .Run(RecipeStep.VacuumPrewet,VacuumPrewet,_delay_1ms)
  95. .WaitWithStopCondition(RecipeStep.WaitVacuumPrewet, () => CommonFunction.CheckRoutineEndState(_vacuumPrewetRoutine),
  96. () => { return CheckSubRoutineError(_vacuumPrewetRoutine, _vacuumPrewetRoutine, 1); })
  97. .Run(RecipeStep.VentPrewet, VentPrewet)
  98. .WaitWithStopCondition(RecipeStep.WaitVentPrewet, () => CommonFunction.CheckRoutineEndState(_ventPrewetRoutine),
  99. () => { return CheckSubRoutineError(_ventPrewetRoutine, _ventPrewetRoutine, 2); })
  100. .Run(RecipeStep.ExtendClean, ExtendClean)
  101. .WaitWithStopCondition(RecipeStep.WaitExtendClean, () => CommonFunction.CheckRoutineEndState(_extendCleanRoutine),
  102. () => { return CheckSubRoutineError(_extendCleanRoutine, _extendCleanRoutine, 3); })
  103. .Run(RecipeStep.SpinOff, SpinOff)
  104. .WaitWithStopCondition(RecipeStep.WaitSpinOff, () => CommonFunction.CheckRoutineEndState(_spinOffRoutine),
  105. () => { return CheckSubRoutineError(_spinOffRoutine, _spinOffRoutine, 4); })
  106. .End(RecipeStep.End, NullFun, _delay_1ms);
  107. return Runner.Status;
  108. }
  109. /// <summary>
  110. /// chamber up
  111. /// </summary>
  112. /// <returns></returns>
  113. private bool ChamberUp()
  114. {
  115. bool result = _mainEntity.CheckToPostMessage<VPWMainState,VPWMainMsg>(eEvent.INFO_VPW,Module,(int)VPWMainMsg.ChamberUp);
  116. if (!result)
  117. {
  118. NotifyError(eEvent.ERR_VPW, "chamber up failed", 0);
  119. }
  120. return result;
  121. }
  122. /// <summary>
  123. /// 检验Chamber是否关闭
  124. /// </summary>
  125. /// <returns></returns>
  126. private bool CheckChamberClosed()
  127. {
  128. bool result= _mainEntity.IsChamberClosed&&_mainEntity.IsIdle;
  129. return result;
  130. }
  131. /// <summary>
  132. /// Check LoopDO数值
  133. /// </summary>
  134. /// <returns></returns>
  135. private bool CheckLoopDO()
  136. {
  137. if(_recipe.DiwLoopDoSet == 0)
  138. {
  139. return true;
  140. }
  141. double loopDoValue = _vpwCellDevice.LoopDOValue;
  142. bool result = loopDoValue < _recipe.DiwLoopDoSet;
  143. if (!result)
  144. {
  145. NotifyError(eEvent.ERR_VPW, $"LoopDO value {loopDoValue} is less than {_recipe.DiwLoopDoSet}", 0);
  146. }
  147. return result;
  148. }
  149. /// <summary>
  150. /// Vacuum Prewet
  151. /// </summary>
  152. /// <returns></returns>
  153. private bool VacuumPrewet()
  154. {
  155. bool result = _vacuumPrewetRoutine.Start(_recipe) == RState.Running;
  156. if (!result)
  157. {
  158. NotifyError(eEvent.ERR_VPW, _vacuumPrewetRoutine.ErrorMsg, 1);
  159. }
  160. return result;
  161. }
  162. /// <summary>
  163. /// 检验Vacuum Prewet结束状态
  164. /// </summary>
  165. /// <returns></returns>
  166. private bool CheckVacuumPrewetEndStatus()
  167. {
  168. bool result = CommonFunction.CheckRoutineEndState(_vacuumPrewetRoutine);
  169. return result;
  170. }
  171. /// <summary>
  172. /// Vent Prewet
  173. /// </summary>
  174. /// <returns></returns>
  175. private bool VentPrewet()
  176. {
  177. return _ventPrewetRoutine.Start(_recipe) == RState.Running;
  178. }
  179. /// <summary>
  180. /// Extend Clean
  181. /// </summary>
  182. /// <returns></returns>
  183. private bool ExtendClean()
  184. {
  185. return _extendCleanRoutine.Start(_recipe) == RState.Running;
  186. }
  187. /// <summary>
  188. /// Vacuum Prewet
  189. /// </summary>
  190. /// <returns></returns>
  191. private bool SpinOff()
  192. {
  193. return _spinOffRoutine.Start(_recipe) == RState.Running;
  194. }
  195. /// <summary>
  196. /// 检验子routine异常
  197. /// </summary>
  198. /// <param name="routine"></param>
  199. /// <param name="routineBase"></param>
  200. /// <param name="index"></param>
  201. /// <returns></returns>
  202. private bool CheckSubRoutineError(IRoutine routine, RoutineBase routineBase, int index)
  203. {
  204. bool result = CommonFunction.CheckRoutineStopState(routine);
  205. if (result)
  206. {
  207. NotifyError(eEvent.ERR_VPW, routineBase.ErrorMsg, index);
  208. }
  209. return result;
  210. }
  211. /// <summary>
  212. /// 启动
  213. /// </summary>
  214. /// <param name="objs"></param>
  215. /// <returns></returns>
  216. public RState Start(params object[] objs)
  217. {
  218. _recipe = objs[0] as VpwRecipe;
  219. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  220. _mainEntity = Singleton<RouteManager>.Instance.GetModule<VpwMainEntity>(ModuleName.VPWMain1.ToString());
  221. return Runner.Start(Module, "start run recipe");
  222. }
  223. /// <summary>
  224. /// 重试
  225. /// </summary>
  226. /// <param name="step"></param>
  227. public RState Retry(int step)
  228. {
  229. if (_recipe == null)
  230. {
  231. NotifyError(eEvent.ERR_VPW, "recipe is null", -1);
  232. return RState.Failed;
  233. }
  234. List<Enum> preStepIds = new List<Enum>();
  235. return Runner.Retry(RecipeStep.ChamberUp, preStepIds, Module, "Run recipe Retry");
  236. }
  237. }
  238. }