VpwManualRecipeRoutine.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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.Runtime.InteropServices;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. namespace PunkHPX8_RT.Modules.VpwCell
  18. {
  19. public class VpwManualRecipeRoutine : RoutineBase, IRoutine
  20. {
  21. private enum RecipeStep
  22. {
  23. Prepare,
  24. WaitPrepare,
  25. VacuumPrewet,
  26. WaitVacuumPrewet,
  27. VentPrewet,
  28. WaitVentPrewet,
  29. ExtendClean,
  30. WaitExtendClean,
  31. SpinOff,
  32. WaitSpinOff,
  33. StopRotation,
  34. WaitStop,
  35. End
  36. }
  37. #region 内部变量
  38. /// <summary>
  39. /// 手动Prepare routine
  40. /// </summary>
  41. private VpwManualPrepareRoutine _manualPrepareRoutine;
  42. /// <summary>
  43. /// Vacuum prewet routine
  44. /// </summary>
  45. private VpwVacuumPrewetRoutine _vacuumPrewetRoutine;
  46. /// <summary>
  47. /// Vent Prewet
  48. /// </summary>
  49. private VpwVentPrewetRoutine _ventPrewetRoutine;
  50. /// <summary>
  51. /// Extend clean
  52. /// </summary>
  53. private VpwExtendCleanRoutine _extendCleanRoutine;
  54. /// <summary>
  55. /// Spin Off Routine
  56. /// </summary>
  57. private VpwSpinOffRoutine _spinOffRoutine;
  58. /// <summary>
  59. /// recipe
  60. /// </summary>
  61. private VpwRecipe _recipe;
  62. /// <summary>
  63. /// Cell device
  64. /// </summary>
  65. private VpwCellDevice _vpwCellDevice;
  66. /// <summary>
  67. /// Main device
  68. /// </summary>
  69. private VpwMainDevice _mainDevice;
  70. #endregion
  71. /// <summary>
  72. /// 构造函数
  73. /// </summary>
  74. /// <param name="module"></param>
  75. public VpwManualRecipeRoutine(string module) : base(module)
  76. {
  77. _manualPrepareRoutine = new VpwManualPrepareRoutine(module);
  78. _vacuumPrewetRoutine=new VpwVacuumPrewetRoutine(module);
  79. _ventPrewetRoutine = new VpwVentPrewetRoutine(module);
  80. _extendCleanRoutine= new VpwExtendCleanRoutine(module);
  81. _spinOffRoutine=new VpwSpinOffRoutine(module);
  82. }
  83. /// <summary>
  84. /// 中止
  85. /// </summary>
  86. public void Abort()
  87. {
  88. Runner.Stop("Manual stop");
  89. _mainDevice.VPWBoostPumpTarget = VpwMain.VPWBoostPumpTarget.Pressure;
  90. }
  91. /// <summary>
  92. /// 监控
  93. /// </summary>
  94. /// <returns></returns>
  95. public RState Monitor()
  96. {
  97. Runner.Run(RecipeStep.Prepare, Prepare, _delay_1ms)
  98. .WaitWithStopCondition(RecipeStep.WaitPrepare, () => CommonFunction.CheckRoutineEndState(_manualPrepareRoutine),
  99. () => { return CheckSubRoutineError(_manualPrepareRoutine, _manualPrepareRoutine, 0); })
  100. .Run(RecipeStep.VacuumPrewet, VacuumPrewet)
  101. .WaitWithStopCondition(RecipeStep.WaitVacuumPrewet, () => CommonFunction.CheckRoutineEndState(_vacuumPrewetRoutine),
  102. () => { return CheckSubRoutineError(_vacuumPrewetRoutine, _vacuumPrewetRoutine, 1); })
  103. .Run(RecipeStep.VentPrewet, VentPrewet)
  104. .WaitWithStopCondition(RecipeStep.WaitVentPrewet, () => CommonFunction.CheckRoutineEndState(_ventPrewetRoutine),
  105. () => { return CheckSubRoutineError(_ventPrewetRoutine, _ventPrewetRoutine, 2); })
  106. .Run(RecipeStep.ExtendClean, ExtendClean)
  107. .WaitWithStopCondition(RecipeStep.WaitExtendClean, () => CommonFunction.CheckRoutineEndState(_extendCleanRoutine),
  108. () => { return CheckSubRoutineError(_extendCleanRoutine, _extendCleanRoutine, 3); })
  109. .Run(RecipeStep.SpinOff, SpinOff)
  110. .WaitWithStopCondition(RecipeStep.WaitSpinOff, () => CommonFunction.CheckRoutineEndState(_spinOffRoutine),
  111. () => { return CheckSubRoutineError(_spinOffRoutine, _spinOffRoutine, 4); })
  112. .Run(RecipeStep.StopRotation, StopRotation, _delay_1ms)
  113. .WaitWithStopCondition(RecipeStep.WaitStop, CheckStopEndStatus, CheckStopErrorStatus)
  114. .End(RecipeStep.End, End, _delay_1ms);
  115. return Runner.Status;
  116. }
  117. /// <summary>
  118. /// Prepare
  119. /// </summary>
  120. /// <returns></returns>
  121. private bool Prepare()
  122. {
  123. return _manualPrepareRoutine.Start(_recipe) == RState.Running;
  124. }
  125. /// <summary>
  126. /// Vacuum Prewet
  127. /// </summary>
  128. /// <returns></returns>
  129. private bool VacuumPrewet()
  130. {
  131. return _vacuumPrewetRoutine.Start(_recipe) == RState.Running;
  132. }
  133. /// <summary>
  134. /// Vent Prewet
  135. /// </summary>
  136. /// <returns></returns>
  137. private bool VentPrewet()
  138. {
  139. return _ventPrewetRoutine.Start(_recipe) == RState.Running;
  140. }
  141. /// <summary>
  142. /// Extend Clean
  143. /// </summary>
  144. /// <returns></returns>
  145. private bool ExtendClean()
  146. {
  147. return _extendCleanRoutine.Start(_recipe) == RState.Running;
  148. }
  149. /// <summary>
  150. /// Vacuum Prewet
  151. /// </summary>
  152. /// <returns></returns>
  153. private bool SpinOff()
  154. {
  155. return _spinOffRoutine.Start(_recipe) == RState.Running;
  156. }
  157. /// <summary>
  158. /// 检验子routine异常
  159. /// </summary>
  160. /// <param name="routine"></param>
  161. /// <param name="routineBase"></param>
  162. /// <param name="index"></param>
  163. /// <returns></returns>
  164. private bool CheckSubRoutineError(IRoutine routine,RoutineBase routineBase,int index)
  165. {
  166. bool result = CommonFunction.CheckRoutineStopState(routine);
  167. if (result)
  168. {
  169. NotifyError(eEvent.ERR_VPW, routineBase.ErrorMsg, index);
  170. }
  171. return result;
  172. }
  173. /// <summary>
  174. /// 停止rotation
  175. /// </summary>
  176. /// <returns></returns>
  177. private bool StopRotation()
  178. {
  179. bool result = _vpwCellDevice.StopProfilePosition();
  180. if (!result)
  181. {
  182. NotifyError(eEvent.ERR_VPW, "Stop rotation failed", 0);
  183. }
  184. return result;
  185. }
  186. /// <summary>
  187. /// 检验停止完成状态
  188. /// </summary>
  189. /// <returns></returns>
  190. private bool CheckStopEndStatus()
  191. {
  192. return _vpwCellDevice.CheckRotationEndStatus();
  193. }
  194. /// <summary>
  195. /// 检验停止异常
  196. /// </summary>
  197. /// <returns></returns>
  198. private bool CheckStopErrorStatus()
  199. {
  200. bool result = _vpwCellDevice.CheckRotationStopStatus();
  201. if (result)
  202. {
  203. NotifyError(eEvent.ERR_VPW, "Stop rotation failed", 0);
  204. }
  205. return result;
  206. }
  207. /// <summary>
  208. /// 结束
  209. /// </summary>
  210. /// <returns></returns>
  211. private bool End()
  212. {
  213. _mainDevice.VPWBoostPumpTarget = VpwMain.VPWBoostPumpTarget.Pressure;
  214. _mainDevice.BoosterPumpDisableOperation("", null);
  215. return true;
  216. }
  217. /// <summary>
  218. /// 启动
  219. /// </summary>
  220. /// <param name="objs"></param>
  221. /// <returns></returns>
  222. public RState Start(params object[] objs)
  223. {
  224. _recipe = objs[0] as VpwRecipe;
  225. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  226. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  227. return Runner.Start(Module, "start run manual recipe");
  228. }
  229. }
  230. }