VpwPrepareRoutine.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. PurgeDelay,
  29. WaitPurge,
  30. RotationPositionOffset,
  31. WaitRotation,
  32. CloseDrip,
  33. Delay,
  34. End
  35. }
  36. #region 内部变量
  37. /// <summary>
  38. /// recipe
  39. /// </summary>
  40. private VpwRecipe _recipe;
  41. /// <summary>
  42. /// 电机
  43. /// </summary>
  44. private JetAxisBase _rotationAxis;
  45. /// <summary>
  46. /// 设备
  47. /// </summary>
  48. private VpwCellDevice _vpwCellDevice;
  49. /// <summary>
  50. /// 延迟时间
  51. /// </summary>
  52. private int _putDownAfterDripClose = 2000;
  53. /// <summary>
  54. /// 等待Wafer放入时间
  55. /// </summary>
  56. private int _waitForWaferTime = 300000;
  57. /// <summary>
  58. /// Main设备
  59. /// </summary>
  60. private VpwMainDevice _mainDevice;
  61. /// <summary>
  62. /// VPW Entity
  63. /// </summary>
  64. private VpwMainEntity _vpwMainEntity;
  65. #endregion
  66. /// <summary>
  67. /// 构造函数
  68. /// </summary>
  69. /// <param name="module"></param>
  70. public VpwPrepareRoutine(string module) : base(module)
  71. {
  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. .Delay(PrepareStep.PurgeDelay,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. .Delay(PrepareStep.Delay,_putDownAfterDripClose)
  94. .End(PrepareStep.End,NullFun,_delay_1ms);
  95. return Runner.Status;
  96. }
  97. /// <summary>
  98. /// Purge routine
  99. /// </summary>
  100. /// <returns></returns>
  101. private bool Purge()
  102. {
  103. if (_vpwMainEntity == null)
  104. {
  105. NotifyError(eEvent.ERR_VPW, "VPW Main not exist", -1);
  106. return false;
  107. }
  108. if (_vpwMainEntity.IsIdle)
  109. {
  110. return _vpwMainEntity.CheckToPostMessage<VPWMainState, VPWMainMsg>(eEvent.ERR_VPW, Module, (int)VPWMainMsg.Purge);
  111. }
  112. else if (_vpwMainEntity.State == VPWMainState.Purgeing)
  113. {
  114. return true;
  115. }
  116. else
  117. {
  118. NotifyError(eEvent.ERR_VPW, $"State {_vpwMainEntity.State} cannot purge", -1);
  119. return false;
  120. }
  121. }
  122. /// <summary>
  123. /// 检验Purge执行是否结束
  124. /// </summary>
  125. /// <returns></returns>
  126. private bool CheckPurgeStatus()
  127. {
  128. return _vpwMainEntity.IsIdle;
  129. }
  130. /// <summary>
  131. /// 检验Purger执行是否出现异常
  132. /// </summary>
  133. /// <returns></returns>
  134. private bool CheckPurgeStopStatus()
  135. {
  136. return _vpwMainEntity.IsError;
  137. }
  138. /// <summary>
  139. /// Position运行至offset
  140. /// </summary>
  141. /// <returns></returns>
  142. private bool RotationPositionOffset()
  143. {
  144. bool result= _rotationAxis.PositionStation("ChuckPlaceOffset");
  145. if (!result)
  146. {
  147. NotifyError(eEvent.ERR_VPW, "rotation start position to ChuckPlaceOffset failed", -1);
  148. }
  149. return result;
  150. }
  151. /// <summary>
  152. /// 检验电机是否完成运动
  153. /// </summary>
  154. /// <returns></returns>
  155. private bool CheckRotationStatus()
  156. {
  157. return _rotationAxis.Status == RState.End;
  158. }
  159. /// <summary>
  160. /// 检验电机运动是否出现异常
  161. /// </summary>
  162. /// <returns></returns>
  163. private bool CheckRotationStopStatus()
  164. {
  165. bool result= _rotationAxis.Status == RState.Failed;
  166. if (result)
  167. {
  168. NotifyError(eEvent.ERR_VPW, "rotation position to ChuckPlaceOffset failed", -1);
  169. }
  170. return result;
  171. }
  172. /// <summary>
  173. /// 启动
  174. /// </summary>
  175. /// <param name="objs"></param>
  176. /// <returns></returns>
  177. public RState Start(params object[] objs)
  178. {
  179. _recipe=(VpwRecipe)objs[0];
  180. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  181. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  182. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  183. _putDownAfterDripClose = SC.GetValue<int>($"{Module}.PutDownAfterDripClose");
  184. _waitForWaferTime = SC.GetValue<int>($"{Module}.WaitForWaferTime") * 1000;
  185. _vpwMainEntity = Singleton<RouteManager>.Instance.GetModule<VpwMainEntity>(ModuleName.VPWMain1.ToString());
  186. return Runner.Start(Module, $"{Module} prepare");
  187. }
  188. /// <summary>
  189. /// 检验前置条件
  190. /// </summary>
  191. /// <returns></returns>
  192. private bool CheckPreCondition()
  193. {
  194. if (!_rotationAxis.IsSwitchOn)
  195. {
  196. NotifyError(eEvent.ERR_VPW,"rotaion is not switch on",-1);
  197. return false;
  198. }
  199. if (!_rotationAxis.IsHomed)
  200. {
  201. NotifyError(eEvent.ERR_VPW, "rotaion is not homed", -1);
  202. return false;
  203. }
  204. return false;
  205. }
  206. /// <summary>
  207. /// 重试
  208. /// </summary>
  209. /// <param name="step"></param>
  210. public RState Retry(int step)
  211. {
  212. if (_recipe == null)
  213. {
  214. NotifyError(eEvent.ERR_VPW, "recipe is null", -1);
  215. return RState.Failed;
  216. }
  217. List<Enum> preStepIds = new List<Enum>();
  218. return Runner.Retry(PrepareStep.CheckPreCondition, preStepIds, Module, "Prepare Retry");
  219. }
  220. }
  221. }