VpwManualRecipeRoutine.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. StopRotation();
  90. _vpwCellDevice.FlowLargeOff();
  91. _vpwCellDevice.FlowSmallOff();
  92. _mainDevice.VPWBoostPumpTarget = VpwMain.VPWBoostPumpTarget.Pressure;
  93. }
  94. /// <summary>
  95. /// 监控
  96. /// </summary>
  97. /// <returns></returns>
  98. public RState Monitor()
  99. {
  100. Runner.Run(RecipeStep.Prepare, Prepare, _delay_1ms)
  101. .WaitWithStopCondition(RecipeStep.WaitPrepare, () => CommonFunction.CheckRoutineEndState(_manualPrepareRoutine),
  102. () => { return CheckSubRoutineError(_manualPrepareRoutine, _manualPrepareRoutine, 0); })
  103. .Run(RecipeStep.VacuumPrewet, VacuumPrewet)
  104. .WaitWithStopCondition(RecipeStep.WaitVacuumPrewet, () => CommonFunction.CheckRoutineEndState(_vacuumPrewetRoutine),
  105. () => { return CheckSubRoutineError(_vacuumPrewetRoutine, _vacuumPrewetRoutine, 1); })
  106. .Run(RecipeStep.VentPrewet, VentPrewet)
  107. .WaitWithStopCondition(RecipeStep.WaitVentPrewet, () => CommonFunction.CheckRoutineEndState(_ventPrewetRoutine),
  108. () => { return CheckSubRoutineError(_ventPrewetRoutine, _ventPrewetRoutine, 2); })
  109. .Run(RecipeStep.ExtendClean, ExtendClean)
  110. .WaitWithStopCondition(RecipeStep.WaitExtendClean, () => CommonFunction.CheckRoutineEndState(_extendCleanRoutine),
  111. () => { return CheckSubRoutineError(_extendCleanRoutine, _extendCleanRoutine, 3); })
  112. .Run(RecipeStep.SpinOff, SpinOff)
  113. .WaitWithStopCondition(RecipeStep.WaitSpinOff, () => CommonFunction.CheckRoutineEndState(_spinOffRoutine),
  114. () => { return CheckSubRoutineError(_spinOffRoutine, _spinOffRoutine, 4); })
  115. .Run(RecipeStep.StopRotation, StopRotation, _delay_1ms)
  116. .WaitWithStopCondition(RecipeStep.WaitStop, CheckStopEndStatus, CheckStopErrorStatus)
  117. .End(RecipeStep.End, End, _delay_1ms);
  118. return Runner.Status;
  119. }
  120. /// <summary>
  121. /// Prepare
  122. /// </summary>
  123. /// <returns></returns>
  124. private bool Prepare()
  125. {
  126. return _manualPrepareRoutine.Start(_recipe) == RState.Running;
  127. }
  128. /// <summary>
  129. /// Vacuum Prewet
  130. /// </summary>
  131. /// <returns></returns>
  132. private bool VacuumPrewet()
  133. {
  134. return _vacuumPrewetRoutine.Start(_recipe) == RState.Running;
  135. }
  136. /// <summary>
  137. /// Vent Prewet
  138. /// </summary>
  139. /// <returns></returns>
  140. private bool VentPrewet()
  141. {
  142. return _ventPrewetRoutine.Start(_recipe) == RState.Running;
  143. }
  144. /// <summary>
  145. /// Extend Clean
  146. /// </summary>
  147. /// <returns></returns>
  148. private bool ExtendClean()
  149. {
  150. return _extendCleanRoutine.Start(_recipe) == RState.Running;
  151. }
  152. /// <summary>
  153. /// Vacuum Prewet
  154. /// </summary>
  155. /// <returns></returns>
  156. private bool SpinOff()
  157. {
  158. return _spinOffRoutine.Start(_recipe) == RState.Running;
  159. }
  160. /// <summary>
  161. /// 检验子routine异常
  162. /// </summary>
  163. /// <param name="routine"></param>
  164. /// <param name="routineBase"></param>
  165. /// <param name="index"></param>
  166. /// <returns></returns>
  167. private bool CheckSubRoutineError(IRoutine routine,RoutineBase routineBase,int index)
  168. {
  169. bool result = CommonFunction.CheckRoutineStopState(routine);
  170. if (result)
  171. {
  172. NotifyError(eEvent.ERR_VPW, routineBase.ErrorMsg, index);
  173. }
  174. return result;
  175. }
  176. /// <summary>
  177. /// 停止rotation
  178. /// </summary>
  179. /// <returns></returns>
  180. private bool StopRotation()
  181. {
  182. bool result = _vpwCellDevice.StopProfilePosition();
  183. if (!result)
  184. {
  185. NotifyError(eEvent.ERR_VPW, "Stop rotation failed", 0);
  186. }
  187. return result;
  188. }
  189. /// <summary>
  190. /// 检验停止完成状态
  191. /// </summary>
  192. /// <returns></returns>
  193. private bool CheckStopEndStatus()
  194. {
  195. return _vpwCellDevice.CheckRotationEndStatus();
  196. }
  197. /// <summary>
  198. /// 检验停止异常
  199. /// </summary>
  200. /// <returns></returns>
  201. private bool CheckStopErrorStatus()
  202. {
  203. bool result = _vpwCellDevice.CheckRotationStopStatus();
  204. if (result)
  205. {
  206. NotifyError(eEvent.ERR_VPW, "Stop rotation failed", 0);
  207. }
  208. return result;
  209. }
  210. /// <summary>
  211. /// 结束
  212. /// </summary>
  213. /// <returns></returns>
  214. private bool End()
  215. {
  216. _mainDevice.VPWBoostPumpTarget = VpwMain.VPWBoostPumpTarget.Pressure;
  217. _mainDevice.CommonData.BoosterPumpSpeedAuto = false;
  218. return true;
  219. }
  220. /// <summary>
  221. /// 启动
  222. /// </summary>
  223. /// <param name="objs"></param>
  224. /// <returns></returns>
  225. public RState Start(params object[] objs)
  226. {
  227. _recipe = objs[0] as VpwRecipe;
  228. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  229. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  230. return Runner.Start(Module, "start run manual recipe");
  231. }
  232. }
  233. }