VpwPrepareRoutine.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using Aitex.Core.Util;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.RecipeCenter;
  8. using MECF.Framework.Common.Routine;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using PunkHPX8_Core;
  11. using PunkHPX8_RT.Devices.AXIS;
  12. using PunkHPX8_RT.Devices.VpwCell;
  13. using PunkHPX8_RT.Devices.VpwMain;
  14. using PunkHPX8_RT.Modules.VpwMain;
  15. using PunkHPX8_RT.Schedulers;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Threading.Tasks;
  21. namespace PunkHPX8_RT.Modules.VpwCell
  22. {
  23. public class VpwPrepareRoutine : RoutineBase, IRoutine
  24. {
  25. private enum PrepareStep
  26. {
  27. CheckPreCondition,
  28. Purge,
  29. PurgeDelay,
  30. WaitPurge,
  31. RotationPositionOffset,
  32. WaitRotation,
  33. CloseDrip,
  34. WaitForChamberDown,
  35. ChamerDown,
  36. Delay,
  37. End
  38. }
  39. #region 内部变量
  40. /// <summary>
  41. /// recipe
  42. /// </summary>
  43. private VpwRecipe _recipe;
  44. /// <summary>
  45. /// 设备
  46. /// </summary>
  47. private VpwCellDevice _vpwCellDevice;
  48. /// <summary>
  49. /// 延迟时间
  50. /// </summary>
  51. private int _putDownAfterDripClose = 2000;
  52. /// <summary>
  53. /// 等待Wafer放入时间
  54. /// </summary>
  55. private int _waitForWaferTime = 300000;
  56. /// <summary>
  57. /// Main设备
  58. /// </summary>
  59. private VpwMainDevice _mainDevice;
  60. /// <summary>
  61. /// VPW Entity
  62. /// </summary>
  63. private VpwMainEntity _vpwMainEntity;
  64. #endregion
  65. /// <summary>
  66. /// 构造函数
  67. /// </summary>
  68. /// <param name="module"></param>
  69. public VpwPrepareRoutine(string module) : base(module)
  70. {
  71. RoutineName = "VpwPrepare";
  72. }
  73. /// <summary>
  74. /// 中止
  75. /// </summary>
  76. public void Abort()
  77. {
  78. Runner.Stop("Manual abort");
  79. }
  80. /// <summary>
  81. /// 监控
  82. /// </summary>
  83. /// <returns></returns>
  84. public RState Monitor()
  85. {
  86. Runner.Run(PrepareStep.CheckPreCondition,CheckPreCondition,_delay_1ms)
  87. .RunIf(PrepareStep.Purge,_recipe.PurgeEnable,Purge,_delay_1ms)
  88. .DelayIf(PrepareStep.PurgeDelay,_recipe.PurgeEnable, 500)
  89. .WaitWithStopConditionIf(PrepareStep.WaitPurge,_recipe.PurgeEnable,CheckPurgeStatus,CheckPurgeStopStatus)
  90. .Run(PrepareStep.RotationPositionOffset,RotationPositionOffset,_delay_1ms)
  91. .WaitWithStopCondition(PrepareStep.WaitRotation,CheckRotationStatus,CheckRotationStopStatus)
  92. .Run(PrepareStep.CloseDrip,()=>_vpwCellDevice.FlowDripOff(),_delay_1ms)
  93. .Run(PrepareStep.ChamerDown, ChamberDown, () => {
  94. return _mainDevice.CommonData.ChamberOpened && !_mainDevice.CommonData.ChamberClosed;
  95. },_delay_2s)
  96. .Delay(PrepareStep.Delay,_putDownAfterDripClose)
  97. .End(PrepareStep.End,NullFun,_delay_1ms);
  98. return Runner.Status;
  99. }
  100. /// <summary>
  101. /// Purge routine
  102. /// </summary>
  103. /// <returns></returns>
  104. private bool Purge()
  105. {
  106. if (_vpwMainEntity == null)
  107. {
  108. NotifyError(eEvent.ERR_VPW, "VPW Main not exist", -1);
  109. return false;
  110. }
  111. if (_vpwMainEntity.IsIdle)
  112. {
  113. return _vpwMainEntity.CheckToPostMessage<VPWMainState, VPWMainMsg>(eEvent.INFO_VPW, Module, (int)VPWMainMsg.Purge);
  114. }
  115. else if (_vpwMainEntity.State == VPWMainState.Purging)
  116. {
  117. return true;
  118. }
  119. else
  120. {
  121. NotifyError(eEvent.ERR_VPW, $"State {_vpwMainEntity.State} cannot purge", -1);
  122. return false;
  123. }
  124. }
  125. /// <summary>
  126. /// 检验Purge执行是否结束
  127. /// </summary>
  128. /// <returns></returns>
  129. private bool CheckPurgeStatus()
  130. {
  131. return _vpwMainEntity.IsIdle;
  132. }
  133. /// <summary>
  134. /// 检验Purger执行是否出现异常
  135. /// </summary>
  136. /// <returns></returns>
  137. private bool CheckPurgeStopStatus()
  138. {
  139. return _vpwMainEntity.IsError;
  140. }
  141. /// <summary>
  142. /// Position运行至offset
  143. /// </summary>
  144. /// <returns></returns>
  145. private bool RotationPositionOffset()
  146. {
  147. bool result = _vpwCellDevice.HomeRotation();
  148. if (!result)
  149. {
  150. NotifyError(eEvent.ERR_VPW, "rotation start home failed", -1);
  151. }
  152. return result;
  153. }
  154. /// <summary>
  155. /// 检验电机是否完成运动
  156. /// </summary>
  157. /// <returns></returns>
  158. private bool CheckRotationStatus()
  159. {
  160. return _vpwCellDevice.CheckHomeEndStatus();
  161. }
  162. /// <summary>
  163. /// 检验电机运动是否出现异常
  164. /// </summary>
  165. /// <returns></returns>
  166. private bool CheckRotationStopStatus()
  167. {
  168. bool result = _vpwCellDevice.CheckRotationStopStatus();
  169. if (result)
  170. {
  171. NotifyError(eEvent.ERR_VPW, "rotation home failed", -1);
  172. }
  173. return result;
  174. }
  175. /// <summary>
  176. /// 打开 Chamber
  177. /// </summary>
  178. /// <returns></returns>
  179. private bool ChamberDown()
  180. {
  181. return _mainDevice.ChamberDown();
  182. }
  183. /// <summary>
  184. /// 启动
  185. /// </summary>
  186. /// <param name="objs"></param>
  187. /// <returns></returns>
  188. public RState Start(params object[] objs)
  189. {
  190. _recipe=(VpwRecipe)objs[0];
  191. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  192. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  193. _putDownAfterDripClose = SC.GetValue<int>($"{Module}.PutDownAfterDripClose");
  194. _waitForWaferTime = SC.GetValue<int>($"{Module}.WaitForWaferTime") * 1000;
  195. _vpwMainEntity = Singleton<RouteManager>.Instance.GetModule<VpwMainEntity>(ModuleName.VPWMain1.ToString());
  196. return Runner.Start(Module, $"{Module} prepare");
  197. }
  198. /// <summary>
  199. /// 检验前置条件
  200. /// </summary>
  201. /// <returns></returns>
  202. private bool CheckPreCondition()
  203. {
  204. if (!_vpwCellDevice.CheckRotationSwitchOn())
  205. {
  206. NotifyError(eEvent.ERR_VPW,"rotaion is not switch on",-1);
  207. return false;
  208. }
  209. return true;
  210. }
  211. /// <summary>
  212. /// 重试
  213. /// </summary>
  214. /// <param name="step"></param>
  215. public RState Retry(int step)
  216. {
  217. if (_recipe == null)
  218. {
  219. NotifyError(eEvent.ERR_VPW, "recipe is null", -1);
  220. return RState.Failed;
  221. }
  222. List<Enum> preStepIds = new List<Enum>();
  223. return Runner.Retry(PrepareStep.CheckPreCondition, preStepIds, Module, "Prepare Retry");
  224. }
  225. }
  226. }