VpwRecipeRoutine.cs 8.5 KB

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