VpwManualPrepareRoutine.cs 7.9 KB

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