VpwPrepareRoutine.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. namespace PunkHPX8_RT.Modules.VpwCell
  21. {
  22. public class VpwPrepareRoutine : RoutineBase, IRoutine
  23. {
  24. private enum PrepareStep
  25. {
  26. CheckPreCondition,
  27. Purge,
  28. WaitPurge,
  29. RotationPositionOffset,
  30. WaitRotation,
  31. CloseDrip,
  32. Delay,
  33. End
  34. }
  35. #region 内部变量
  36. /// <summary>
  37. /// recipe
  38. /// </summary>
  39. private VpwRecipe _recipe;
  40. /// <summary>
  41. /// 电机
  42. /// </summary>
  43. private JetAxisBase _rotationAxis;
  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. .WaitWithStopConditionIf(PrepareStep.WaitPurge,_recipe.PurgeEnable,CheckPurgeStatus,CheckPurgeStopStatus)
  88. .Run(PrepareStep.RotationPositionOffset,RotationPositionOffset,_delay_1ms)
  89. .WaitWithStopCondition(PrepareStep.WaitRotation,CheckRotationStatus,CheckRotationStopStatus)
  90. .Run(PrepareStep.CloseDrip,()=>_vpwCellDevice.FlowDripOff(),_delay_1ms)
  91. .Delay(PrepareStep.Delay,_putDownAfterDripClose)
  92. .End(PrepareStep.End,NullFun,_delay_1ms);
  93. return Runner.Status;
  94. }
  95. /// <summary>
  96. /// Purge routine
  97. /// </summary>
  98. /// <returns></returns>
  99. private bool Purge()
  100. {
  101. if (_vpwMainEntity == null)
  102. {
  103. NotifyError(eEvent.ERR_VPW, "VPW Main not exist", -1);
  104. return false;
  105. }
  106. if (_vpwMainEntity.IsIdle)
  107. {
  108. return _vpwMainEntity.CheckToPostMessage<VPWMainState, VPWMainMsg>(eEvent.ERR_VPW, Module, (int)VPWMainMsg.Purge);
  109. }
  110. else if (_vpwMainEntity.State == VPWMainState.Purgeing)
  111. {
  112. return true;
  113. }
  114. else
  115. {
  116. NotifyError(eEvent.ERR_VPW, $"State {_vpwMainEntity.State} cannot purge", -1);
  117. return false;
  118. }
  119. }
  120. /// <summary>
  121. /// 检验Purge执行是否结束
  122. /// </summary>
  123. /// <returns></returns>
  124. private bool CheckPurgeStatus()
  125. {
  126. return _vpwMainEntity.IsIdle;
  127. }
  128. /// <summary>
  129. /// 检验Purger执行是否出现异常
  130. /// </summary>
  131. /// <returns></returns>
  132. private bool CheckPurgeStopStatus()
  133. {
  134. return _vpwMainEntity.IsError;
  135. }
  136. /// <summary>
  137. /// Position运行至offset
  138. /// </summary>
  139. /// <returns></returns>
  140. private bool RotationPositionOffset()
  141. {
  142. bool result= _rotationAxis.PositionStation("ChuckPlaceOffset");
  143. if (!result)
  144. {
  145. NotifyError(eEvent.ERR_VPW, "rotation start position to ChuckPlaceOffset failed", -1);
  146. }
  147. return result;
  148. }
  149. /// <summary>
  150. /// 检验电机是否完成运动
  151. /// </summary>
  152. /// <returns></returns>
  153. private bool CheckRotationStatus()
  154. {
  155. return _rotationAxis.Status == RState.End;
  156. }
  157. /// <summary>
  158. /// 检验电机运动是否出现异常
  159. /// </summary>
  160. /// <returns></returns>
  161. private bool CheckRotationStopStatus()
  162. {
  163. bool result= _rotationAxis.Status == RState.Failed;
  164. if (result)
  165. {
  166. NotifyError(eEvent.ERR_VPW, "rotation position to ChuckPlaceOffset failed", -1);
  167. }
  168. return result;
  169. }
  170. /// <summary>
  171. /// 启动
  172. /// </summary>
  173. /// <param name="objs"></param>
  174. /// <returns></returns>
  175. public RState Start(params object[] objs)
  176. {
  177. _recipe=(VpwRecipe)objs[0];
  178. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  179. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  180. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  181. _putDownAfterDripClose = SC.GetValue<int>($"{Module}.PutDownAfterDripClose");
  182. _waitForWaferTime = SC.GetValue<int>($"{Module}.WaitForWaferTime") * 1000;
  183. _vpwMainEntity = Singleton<RouteManager>.Instance.GetModule<VpwMainEntity>(ModuleName.VPWMain1.ToString());
  184. return Runner.Start(Module, $"{Module} prepare");
  185. }
  186. /// <summary>
  187. /// 检验前置条件
  188. /// </summary>
  189. /// <returns></returns>
  190. private bool CheckPreCondition()
  191. {
  192. if (!_rotationAxis.IsSwitchOn)
  193. {
  194. NotifyError(eEvent.ERR_VPW,"rotaion is not switch on",-1);
  195. return false;
  196. }
  197. if (!_rotationAxis.IsHomed)
  198. {
  199. NotifyError(eEvent.ERR_VPW, "rotaion is not homed", -1);
  200. return false;
  201. }
  202. return false;
  203. }
  204. /// <summary>
  205. /// 重试
  206. /// </summary>
  207. /// <param name="step"></param>
  208. public RState Retry(int step)
  209. {
  210. if (_recipe == null)
  211. {
  212. NotifyError(eEvent.ERR_RINSE, "recipe is null", -1);
  213. return RState.Failed;
  214. }
  215. List<Enum> preStepIds = new List<Enum>();
  216. return Runner.Retry(PrepareStep.CheckPreCondition, preStepIds, Module, "Prepare Retry");
  217. }
  218. }
  219. }