VpwPrepareRoutine.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. }
  72. /// <summary>
  73. /// 中止
  74. /// </summary>
  75. public void Abort()
  76. {
  77. Runner.Stop("Manual abort");
  78. }
  79. /// <summary>
  80. /// 监控
  81. /// </summary>
  82. /// <returns></returns>
  83. public RState Monitor()
  84. {
  85. Runner.Run(PrepareStep.CheckPreCondition,CheckPreCondition,_delay_1ms)
  86. .RunIf(PrepareStep.Purge,_recipe.PurgeEnable,Purge,_delay_1ms)
  87. .DelayIf(PrepareStep.PurgeDelay,_recipe.PurgeEnable, 500)
  88. .WaitWithStopConditionIf(PrepareStep.WaitPurge,_recipe.PurgeEnable,CheckPurgeStatus,CheckPurgeStopStatus)
  89. .Run(PrepareStep.RotationPositionOffset,RotationPositionOffset,_delay_1ms)
  90. .WaitWithStopCondition(PrepareStep.WaitRotation,CheckRotationStatus,CheckRotationStopStatus)
  91. .Run(PrepareStep.CloseDrip,()=>_vpwCellDevice.FlowDripOff(),_delay_1ms)
  92. .Run(PrepareStep.ChamerDown, ChamberDown, () => {
  93. return _mainDevice.CommonData.ChamberOpened && !_mainDevice.CommonData.ChamberClosed;
  94. },_delay_2s)
  95. .Delay(PrepareStep.Delay,_putDownAfterDripClose)
  96. .End(PrepareStep.End,NullFun,_delay_1ms);
  97. return Runner.Status;
  98. }
  99. /// <summary>
  100. /// Purge routine
  101. /// </summary>
  102. /// <returns></returns>
  103. private bool Purge()
  104. {
  105. if (_vpwMainEntity == null)
  106. {
  107. NotifyError(eEvent.ERR_VPW, "VPW Main not exist", -1);
  108. return false;
  109. }
  110. if (_vpwMainEntity.IsIdle)
  111. {
  112. return _vpwMainEntity.CheckToPostMessage<VPWMainState, VPWMainMsg>(eEvent.INFO_VPW, Module, (int)VPWMainMsg.Purge);
  113. }
  114. else if (_vpwMainEntity.State == VPWMainState.Purging)
  115. {
  116. return true;
  117. }
  118. else
  119. {
  120. NotifyError(eEvent.ERR_VPW, $"State {_vpwMainEntity.State} cannot purge", -1);
  121. return false;
  122. }
  123. }
  124. /// <summary>
  125. /// 检验Purge执行是否结束
  126. /// </summary>
  127. /// <returns></returns>
  128. private bool CheckPurgeStatus()
  129. {
  130. return _vpwMainEntity.IsIdle;
  131. }
  132. /// <summary>
  133. /// 检验Purger执行是否出现异常
  134. /// </summary>
  135. /// <returns></returns>
  136. private bool CheckPurgeStopStatus()
  137. {
  138. return _vpwMainEntity.IsError;
  139. }
  140. /// <summary>
  141. /// Position运行至offset
  142. /// </summary>
  143. /// <returns></returns>
  144. private bool RotationPositionOffset()
  145. {
  146. bool result = _vpwCellDevice.HomeRotation();
  147. if (!result)
  148. {
  149. NotifyError(eEvent.ERR_VPW, "rotation start home failed", -1);
  150. }
  151. return result;
  152. }
  153. /// <summary>
  154. /// 检验电机是否完成运动
  155. /// </summary>
  156. /// <returns></returns>
  157. private bool CheckRotationStatus()
  158. {
  159. return _vpwCellDevice.CheckHomeEndStatus();
  160. }
  161. /// <summary>
  162. /// 检验电机运动是否出现异常
  163. /// </summary>
  164. /// <returns></returns>
  165. private bool CheckRotationStopStatus()
  166. {
  167. bool result = _vpwCellDevice.CheckRotationStopStatus();
  168. if (result)
  169. {
  170. NotifyError(eEvent.ERR_VPW, "rotation home failed", -1);
  171. }
  172. return result;
  173. }
  174. /// <summary>
  175. /// 打开 Chamber
  176. /// </summary>
  177. /// <returns></returns>
  178. private bool ChamberDown()
  179. {
  180. return _mainDevice.ChamberDown();
  181. }
  182. /// <summary>
  183. /// 启动
  184. /// </summary>
  185. /// <param name="objs"></param>
  186. /// <returns></returns>
  187. public RState Start(params object[] objs)
  188. {
  189. _recipe=(VpwRecipe)objs[0];
  190. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  191. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  192. _putDownAfterDripClose = SC.GetValue<int>($"{Module}.PutDownAfterDripClose");
  193. _waitForWaferTime = SC.GetValue<int>($"{Module}.WaitForWaferTime") * 1000;
  194. _vpwMainEntity = Singleton<RouteManager>.Instance.GetModule<VpwMainEntity>(ModuleName.VPWMain1.ToString());
  195. return Runner.Start(Module, $"{Module} prepare");
  196. }
  197. /// <summary>
  198. /// 检验前置条件
  199. /// </summary>
  200. /// <returns></returns>
  201. private bool CheckPreCondition()
  202. {
  203. if (!_vpwCellDevice.CheckRotationSwitchOn())
  204. {
  205. NotifyError(eEvent.ERR_VPW,"rotaion is not switch on",-1);
  206. return false;
  207. }
  208. return true;
  209. }
  210. /// <summary>
  211. /// 重试
  212. /// </summary>
  213. /// <param name="step"></param>
  214. public RState Retry(int step)
  215. {
  216. if (_recipe == null)
  217. {
  218. NotifyError(eEvent.ERR_VPW, "recipe is null", -1);
  219. return RState.Failed;
  220. }
  221. List<Enum> preStepIds = new List<Enum>();
  222. return Runner.Retry(PrepareStep.CheckPreCondition, preStepIds, Module, "Prepare Retry");
  223. }
  224. }
  225. }