PufOnlyPlaceToLoaderRoutine.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.Routine;
  6. using MECF.Framework.Common.Utilities;
  7. using CyberX8_Core;
  8. using CyberX8_RT.Devices.AXIS;
  9. using CyberX8_RT.Devices.Loader;
  10. using CyberX8_RT.Devices.PUF;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. namespace CyberX8_RT.Modules.PUF
  17. {
  18. public class PufOnlyPlaceToLoaderRoutine : RoutineBase, IRoutine
  19. {
  20. private enum PlaceStep
  21. {
  22. LipSealGotoUnlock,
  23. LipSealGotoUnlockWait,
  24. VacuumLevelCheck,
  25. SideConditionRoutine,
  26. SideConditionRoutineWait,
  27. RotationGotoLoaderPlaceDown,
  28. RotationGotoLoaderPlaceDownWait,
  29. FirstPlaceVacuumCheck,
  30. FirstPlaceVacuumCheckWait,
  31. SecondPlaceVacuumCheck,
  32. SecondPlaceVacuumCheckWait,
  33. VacuumOff,
  34. End
  35. }
  36. #region 常量
  37. private const string SideA = "SideA";
  38. private const string SideB = "SideB";
  39. private const string WAFER_ABSENT = "WaferAbsent";
  40. #endregion
  41. #region 内部变量
  42. private bool _isSecondPlaceVacuumCheck = false;
  43. private string _side;
  44. private JetAxisBase _flipAxis;
  45. private JetAxisBase _rotationAxis;
  46. private PufVacuum _vacuum;
  47. private JetAxisBase _loaderCrsAxis;
  48. private PufWaferPickSubRoutine _pufWaferPickSubRoutine;
  49. private PufPlaceVacuumCheckRoutine _pufPlaceVacuumCheckRoutine;
  50. #endregion
  51. /// <summary>
  52. /// 构造函数
  53. /// </summary>
  54. /// <param name="module"></param>
  55. public PufOnlyPlaceToLoaderRoutine(string module) : base(module)
  56. {
  57. _pufWaferPickSubRoutine = new PufWaferPickSubRoutine(module);
  58. }
  59. /// <summary>
  60. /// 中止
  61. /// </summary>
  62. public void Abort()
  63. {
  64. if (_pufWaferPickSubRoutine != null)
  65. {
  66. _pufWaferPickSubRoutine.Abort();
  67. }
  68. _flipAxis.StopPositionOperation();
  69. _rotationAxis.StopPositionOperation();
  70. Runner.Stop("Manual Abort");
  71. }
  72. /// <summary>
  73. /// 监控
  74. /// </summary>
  75. /// <returns></returns>
  76. public RState Monitor()
  77. {
  78. Runner.Run(PlaceStep.LipSealGotoUnlock, LipSealGotoUnlock, _delay_1ms)
  79. .WaitWithStopCondition(PlaceStep.LipSealGotoUnlockWait, CheckLipSealEndStatus, CheckLipSealStopStatus)
  80. .Run(PlaceStep.VacuumLevelCheck, CheckWaferPresent, _delay_1ms)
  81. .RunConditionSubRoutine(PlaceStep.SideConditionRoutine, SideConditionIndex, new IRoutine[] { _pufWaferPickSubRoutine }, new object[] { _side })
  82. .WaitConditionSubRoutine(PlaceStep.SideConditionRoutineWait)
  83. .Run(PlaceStep.RotationGotoLoaderPlaceDown, () => _rotationAxis.PositionStation("LoaderPutDown"), _delay_1ms)
  84. .WaitWithStopCondition(PlaceStep.RotationGotoLoaderPlaceDownWait, CheckRotationPositionStatus, CheckRotationPositionRunStop)
  85. .Run(PlaceStep.FirstPlaceVacuumCheck, () => StartPlaceVacuumCheckRoutine(false, 1), _delay_1ms)
  86. .WaitWithStopCondition(PlaceStep.FirstPlaceVacuumCheckWait, CheckFirstPlaceVacuumCheckRoutineStatus, () => { return false; })
  87. .Run(PlaceStep.SecondPlaceVacuumCheck, StartSecondPlaceVacuumCheckRoutine, _delay_1ms)
  88. .WaitWithStopCondition(PlaceStep.SecondPlaceVacuumCheckWait, CheckPlaceVacuumCheckRoutineEndStatus, CheckSecondPlaceVacuumCheckRoutineStopStatus)
  89. .Run(PlaceStep.VacuumOff, VacuumOff, _delay_1ms)
  90. .End(PlaceStep.End, NullFun, _delay_1ms);
  91. return Runner.Status;
  92. }
  93. /// <summary>
  94. /// LipSeal Goto Unlock
  95. /// </summary>
  96. /// <returns></returns>
  97. private bool LipSealGotoUnlock()
  98. {
  99. if (ModuleHelper.IsInstalled(ModuleName.Loader1))
  100. {
  101. return _loaderCrsAxis.PositionStation("Unlock");
  102. }
  103. else
  104. {
  105. return true;
  106. }
  107. }
  108. /// <summary>
  109. /// 检验Lip Seal完成状态
  110. /// </summary>
  111. /// <returns></returns>
  112. private bool CheckLipSealEndStatus()
  113. {
  114. if (ModuleHelper.IsInstalled(ModuleName.Loader1))
  115. {
  116. return _loaderCrsAxis.Status == RState.End;
  117. }
  118. else
  119. {
  120. return true;
  121. }
  122. }
  123. /// <summary>
  124. /// 检验Lip Seal完成状态
  125. /// </summary>
  126. /// <returns></returns>
  127. private bool CheckLipSealStopStatus()
  128. {
  129. if (ModuleHelper.IsInstalled(ModuleName.Loader1))
  130. {
  131. return _loaderCrsAxis.Status == RState.Failed;
  132. }
  133. else
  134. {
  135. return true;
  136. }
  137. }
  138. /// <summary>
  139. /// 检验是否存在Wafer
  140. /// </summary>
  141. /// <returns></returns>
  142. private bool CheckWaferPresent()
  143. {
  144. if (_side == SideA)
  145. {
  146. if (!_vacuum.ChuckAWaferPresent)
  147. {
  148. LOG.WriteLog(eEvent.ERR_PUF, Module, $"{_side} has no Wafer");
  149. return false;
  150. }
  151. }
  152. else
  153. {
  154. if (!_vacuum.ChuckBWaferPresent)
  155. {
  156. LOG.WriteLog(eEvent.ERR_PUF, Module, $"{_side} has no Wafer");
  157. return false;
  158. }
  159. }
  160. return true;
  161. }
  162. /// <summary>
  163. /// Side条件获取SubRoutine索引
  164. /// </summary>
  165. /// <returns></returns>
  166. private int SideConditionIndex()
  167. {
  168. if (_flipAxis.CheckPositionIsInStation(_flipAxis.MotionData.MotorPosition, _side))
  169. {
  170. return 1;
  171. }
  172. else
  173. {
  174. return 0;
  175. }
  176. }
  177. /// <summary>
  178. /// 检验Rotation移动状态
  179. /// </summary>
  180. /// <returns></returns>
  181. private bool CheckRotationPositionStatus()
  182. {
  183. return _rotationAxis.Status == RState.End;
  184. }
  185. /// <summary>
  186. /// 检验Rotation是否还在运动
  187. /// </summary>
  188. /// <returns></returns>
  189. private bool CheckRotationPositionRunStop()
  190. {
  191. return _rotationAxis.Status == RState.Failed;
  192. }
  193. /// <summary>
  194. /// 启动Place Vacuum Check routine
  195. /// </summary>
  196. /// <returns></returns>
  197. private bool StartPlaceVacuumCheckRoutine(bool showError, int times)
  198. {
  199. return _pufPlaceVacuumCheckRoutine.Start(_side, showError, times) == RState.Running;
  200. }
  201. /// <summary>
  202. /// 检验第一次Place Vacuum Check routine运行情况
  203. /// </summary>
  204. /// <returns></returns>
  205. private bool CheckFirstPlaceVacuumCheckRoutineStatus()
  206. {
  207. RState rsState = _pufPlaceVacuumCheckRoutine.Monitor();
  208. if (rsState == RState.End)
  209. {
  210. return true;
  211. }
  212. if (rsState == RState.Failed || rsState == RState.Timeout)
  213. {
  214. _isSecondPlaceVacuumCheck = true;
  215. return true;
  216. }
  217. return false;
  218. }
  219. /// <summary>
  220. /// 启动Place Vacuum Check routine完成状态
  221. /// </summary>
  222. /// <returns></returns>
  223. private bool CheckPlaceVacuumCheckRoutineEndStatus()
  224. {
  225. RState rsState = _pufPlaceVacuumCheckRoutine.Monitor();
  226. return rsState == RState.End;
  227. }
  228. /// <summary>
  229. /// 启动第二次Place Vacuum Check routine
  230. /// </summary>
  231. /// <returns></returns>
  232. private bool StartSecondPlaceVacuumCheckRoutine()
  233. {
  234. if (_isSecondPlaceVacuumCheck)
  235. {
  236. return StartPlaceVacuumCheckRoutine(true, 2);
  237. }
  238. else
  239. {
  240. return true;
  241. }
  242. }
  243. /// <summary>
  244. /// 检验第二次Place Vacuum Check routine错误状态
  245. /// </summary>
  246. /// <returns></returns>
  247. private bool CheckSecondPlaceVacuumCheckRoutineStopStatus()
  248. {
  249. RState rState = _pufPlaceVacuumCheckRoutine.Monitor();
  250. if (rState == RState.Failed || rState == RState.Timeout)
  251. {
  252. return true;
  253. }
  254. return false;
  255. }
  256. /// <summary>
  257. /// 关闭Vacuum
  258. /// </summary>
  259. /// <returns></returns>
  260. private bool VacuumOff()
  261. {
  262. if (_side == "SideA")
  263. {
  264. return _vacuum.VacuumAOff();
  265. }
  266. else if (_side == "SideB")
  267. {
  268. return _vacuum.VacuumBOff();
  269. }
  270. return false;
  271. }
  272. /// <summary>
  273. /// 检验存在Wafer
  274. /// </summary>
  275. /// <returns></returns>
  276. private bool CheckWaferAbsent()
  277. {
  278. if (_side == SideA)
  279. {
  280. return _vacuum.ChuckAVacuumStatus == WAFER_ABSENT;
  281. }
  282. else if (_side == SideB)
  283. {
  284. return _vacuum.ChuckBVacuumStatus == WAFER_ABSENT;
  285. }
  286. else
  287. {
  288. return false;
  289. }
  290. }
  291. /// <summary>
  292. /// 启动
  293. /// </summary>
  294. /// <param name="objs"></param>
  295. /// <returns></returns>
  296. public RState Start(params object[] objs)
  297. {
  298. _side = objs[0].ToString();
  299. _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Flip");
  300. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  301. _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
  302. GetCrsAxis();
  303. _isSecondPlaceVacuumCheck = false;
  304. _pufPlaceVacuumCheckRoutine = new PufPlaceVacuumCheckRoutine(Module);
  305. return Runner.Start(Module, "Start Place To Loader");
  306. }
  307. /// <summary>
  308. /// 获取lipseal Axis
  309. /// </summary>
  310. private void GetCrsAxis()
  311. {
  312. if (_side==SideA)
  313. {
  314. _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSA");
  315. }
  316. else
  317. {
  318. _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSB");
  319. }
  320. }
  321. }
  322. }