VpwPrepareRoutine.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 VpwCellDevice _vpwCellDevice;
  45. /// <summary>
  46. /// 延迟时间
  47. /// </summary>
  48. private int _putDownAfterDripClose = 2000;
  49. /// <summary>
  50. /// 等待Wafer放入时间
  51. /// </summary>
  52. private int _waitForWaferTime = 300000;
  53. /// <summary>
  54. /// Main设备
  55. /// </summary>
  56. private VpwMainDevice _mainDevice;
  57. /// <summary>
  58. /// VPW Entity
  59. /// </summary>
  60. private VpwMainEntity _vpwMainEntity;
  61. #endregion
  62. /// <summary>
  63. /// 构造函数
  64. /// </summary>
  65. /// <param name="module"></param>
  66. public VpwPrepareRoutine(string module) : base(module)
  67. {
  68. }
  69. /// <summary>
  70. /// 中止
  71. /// </summary>
  72. public void Abort()
  73. {
  74. Runner.Stop("Manual abort");
  75. }
  76. /// <summary>
  77. /// 监控
  78. /// </summary>
  79. /// <returns></returns>
  80. public RState Monitor()
  81. {
  82. Runner.Run(PrepareStep.CheckPreCondition,CheckPreCondition,_delay_1ms)
  83. .RunIf(PrepareStep.Purge,_recipe.PurgeEnable,Purge,_delay_1ms)
  84. .DelayIf(PrepareStep.PurgeDelay,_recipe.PurgeEnable, 500)
  85. .WaitWithStopConditionIf(PrepareStep.WaitPurge,_recipe.PurgeEnable,CheckPurgeStatus,CheckPurgeStopStatus)
  86. .Run(PrepareStep.RotationPositionOffset,RotationPositionOffset,_delay_1ms)
  87. .WaitWithStopCondition(PrepareStep.WaitRotation,CheckRotationStatus,CheckRotationStopStatus)
  88. .Run(PrepareStep.CloseDrip,()=>_vpwCellDevice.FlowDripOff(),_delay_1ms)
  89. .Delay(PrepareStep.Delay,_putDownAfterDripClose)
  90. .End(PrepareStep.End,NullFun,_delay_1ms);
  91. return Runner.Status;
  92. }
  93. /// <summary>
  94. /// Purge routine
  95. /// </summary>
  96. /// <returns></returns>
  97. private bool Purge()
  98. {
  99. if (_vpwMainEntity == null)
  100. {
  101. NotifyError(eEvent.ERR_VPW, "VPW Main not exist", -1);
  102. return false;
  103. }
  104. if (_vpwMainEntity.IsIdle)
  105. {
  106. return _vpwMainEntity.CheckToPostMessage<VPWMainState, VPWMainMsg>(eEvent.ERR_VPW, Module, (int)VPWMainMsg.Purge);
  107. }
  108. else if (_vpwMainEntity.State == VPWMainState.Purgeing)
  109. {
  110. return true;
  111. }
  112. else
  113. {
  114. NotifyError(eEvent.ERR_VPW, $"State {_vpwMainEntity.State} cannot purge", -1);
  115. return false;
  116. }
  117. }
  118. /// <summary>
  119. /// 检验Purge执行是否结束
  120. /// </summary>
  121. /// <returns></returns>
  122. private bool CheckPurgeStatus()
  123. {
  124. return _vpwMainEntity.IsIdle;
  125. }
  126. /// <summary>
  127. /// 检验Purger执行是否出现异常
  128. /// </summary>
  129. /// <returns></returns>
  130. private bool CheckPurgeStopStatus()
  131. {
  132. return _vpwMainEntity.IsError;
  133. }
  134. /// <summary>
  135. /// Position运行至offset
  136. /// </summary>
  137. /// <returns></returns>
  138. private bool RotationPositionOffset()
  139. {
  140. bool result = _vpwCellDevice.HomeRotation();
  141. if (!result)
  142. {
  143. NotifyError(eEvent.ERR_VPW, "rotation start home failed", -1);
  144. }
  145. return result;
  146. }
  147. /// <summary>
  148. /// 检验电机是否完成运动
  149. /// </summary>
  150. /// <returns></returns>
  151. private bool CheckRotationStatus()
  152. {
  153. return _vpwCellDevice.CheckHomeEndStatus();
  154. }
  155. /// <summary>
  156. /// 检验电机运动是否出现异常
  157. /// </summary>
  158. /// <returns></returns>
  159. private bool CheckRotationStopStatus()
  160. {
  161. bool result = _vpwCellDevice.CheckRotationStopStatus();
  162. if (result)
  163. {
  164. NotifyError(eEvent.ERR_VPW, "rotation home failed", -1);
  165. }
  166. return result;
  167. }
  168. /// <summary>
  169. /// 启动
  170. /// </summary>
  171. /// <param name="objs"></param>
  172. /// <returns></returns>
  173. public RState Start(params object[] objs)
  174. {
  175. _recipe=(VpwRecipe)objs[0];
  176. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  177. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  178. _putDownAfterDripClose = SC.GetValue<int>($"{Module}.PutDownAfterDripClose");
  179. _waitForWaferTime = SC.GetValue<int>($"{Module}.WaitForWaferTime") * 1000;
  180. _vpwMainEntity = Singleton<RouteManager>.Instance.GetModule<VpwMainEntity>(ModuleName.VPWMain1.ToString());
  181. return Runner.Start(Module, $"{Module} prepare");
  182. }
  183. /// <summary>
  184. /// 检验前置条件
  185. /// </summary>
  186. /// <returns></returns>
  187. private bool CheckPreCondition()
  188. {
  189. if (!_vpwCellDevice.CheckRotationSwitchOn())
  190. {
  191. NotifyError(eEvent.ERR_VPW,"rotaion is not switch on",-1);
  192. return false;
  193. }
  194. return true;
  195. }
  196. /// <summary>
  197. /// 重试
  198. /// </summary>
  199. /// <param name="step"></param>
  200. public RState Retry(int step)
  201. {
  202. if (_recipe == null)
  203. {
  204. NotifyError(eEvent.ERR_VPW, "recipe is null", -1);
  205. return RState.Failed;
  206. }
  207. List<Enum> preStepIds = new List<Enum>();
  208. return Runner.Retry(PrepareStep.CheckPreCondition, preStepIds, Module, "Prepare Retry");
  209. }
  210. }
  211. }