VpwPrepareRoutine.cs 7.7 KB

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