PufOnlyPlaceToLoaderRoutine.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. bool result= _loaderCrsAxis.Status == RState.Failed;
  132. if (result)
  133. {
  134. NotifyError(eEvent.ERR_PUF, $"lipsel axis goto unlock failed", 0);
  135. }
  136. return result;
  137. }
  138. else
  139. {
  140. return true;
  141. }
  142. }
  143. /// <summary>
  144. /// 检验是否存在Wafer
  145. /// </summary>
  146. /// <returns></returns>
  147. private bool CheckWaferPresent()
  148. {
  149. if (_side == SideA)
  150. {
  151. if (!_vacuum.ChuckAWaferPresent)
  152. {
  153. LOG.WriteLog(eEvent.ERR_PUF, Module, $"{_side} has no Wafer");
  154. return false;
  155. }
  156. }
  157. else
  158. {
  159. if (!_vacuum.ChuckBWaferPresent)
  160. {
  161. LOG.WriteLog(eEvent.ERR_PUF, Module, $"{_side} has no Wafer");
  162. return false;
  163. }
  164. }
  165. return true;
  166. }
  167. /// <summary>
  168. /// Side条件获取SubRoutine索引
  169. /// </summary>
  170. /// <returns></returns>
  171. private int SideConditionIndex()
  172. {
  173. if (_flipAxis.CheckPositionIsInStation(_flipAxis.MotionData.MotorPosition, _side))
  174. {
  175. return 1;
  176. }
  177. else
  178. {
  179. return 0;
  180. }
  181. }
  182. /// <summary>
  183. /// 检验Rotation移动状态
  184. /// </summary>
  185. /// <returns></returns>
  186. private bool CheckRotationPositionStatus()
  187. {
  188. return _rotationAxis.Status == RState.End;
  189. }
  190. /// <summary>
  191. /// 检验Rotation是否还在运动
  192. /// </summary>
  193. /// <returns></returns>
  194. private bool CheckRotationPositionRunStop()
  195. {
  196. return _rotationAxis.Status == RState.Failed;
  197. }
  198. /// <summary>
  199. /// 启动Place Vacuum Check routine
  200. /// </summary>
  201. /// <returns></returns>
  202. private bool StartPlaceVacuumCheckRoutine(bool showError, int times)
  203. {
  204. return _pufPlaceVacuumCheckRoutine.Start(_side, showError, times) == RState.Running;
  205. }
  206. /// <summary>
  207. /// 检验第一次Place Vacuum Check routine运行情况
  208. /// </summary>
  209. /// <returns></returns>
  210. private bool CheckFirstPlaceVacuumCheckRoutineStatus()
  211. {
  212. RState rsState = _pufPlaceVacuumCheckRoutine.Monitor();
  213. if (rsState == RState.End)
  214. {
  215. return true;
  216. }
  217. if (rsState == RState.Failed || rsState == RState.Timeout)
  218. {
  219. _isSecondPlaceVacuumCheck = true;
  220. return true;
  221. }
  222. return false;
  223. }
  224. /// <summary>
  225. /// 启动Place Vacuum Check routine完成状态
  226. /// </summary>
  227. /// <returns></returns>
  228. private bool CheckPlaceVacuumCheckRoutineEndStatus()
  229. {
  230. RState rsState = _pufPlaceVacuumCheckRoutine.Monitor();
  231. return rsState == RState.End;
  232. }
  233. /// <summary>
  234. /// 启动第二次Place Vacuum Check routine
  235. /// </summary>
  236. /// <returns></returns>
  237. private bool StartSecondPlaceVacuumCheckRoutine()
  238. {
  239. if (_isSecondPlaceVacuumCheck)
  240. {
  241. return StartPlaceVacuumCheckRoutine(true, 2);
  242. }
  243. else
  244. {
  245. return true;
  246. }
  247. }
  248. /// <summary>
  249. /// 检验第二次Place Vacuum Check routine错误状态
  250. /// </summary>
  251. /// <returns></returns>
  252. private bool CheckSecondPlaceVacuumCheckRoutineStopStatus()
  253. {
  254. RState rState = _pufPlaceVacuumCheckRoutine.Monitor();
  255. if (rState == RState.Failed || rState == RState.Timeout)
  256. {
  257. return true;
  258. }
  259. return false;
  260. }
  261. /// <summary>
  262. /// 关闭Vacuum
  263. /// </summary>
  264. /// <returns></returns>
  265. private bool VacuumOff()
  266. {
  267. if (_side == "SideA")
  268. {
  269. return _vacuum.VacuumAOff();
  270. }
  271. else if (_side == "SideB")
  272. {
  273. return _vacuum.VacuumBOff();
  274. }
  275. return false;
  276. }
  277. /// <summary>
  278. /// 启动
  279. /// </summary>
  280. /// <param name="objs"></param>
  281. /// <returns></returns>
  282. public RState Start(params object[] objs)
  283. {
  284. _side = objs[0].ToString();
  285. _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Flip");
  286. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  287. _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
  288. GetCrsAxis();
  289. _isSecondPlaceVacuumCheck = false;
  290. _pufPlaceVacuumCheckRoutine = new PufPlaceVacuumCheckRoutine(Module);
  291. return Runner.Start(Module, "Start Place To Loader");
  292. }
  293. /// <summary>
  294. /// 获取lipseal Axis
  295. /// </summary>
  296. private void GetCrsAxis()
  297. {
  298. if (_side==SideA)
  299. {
  300. _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSA");
  301. }
  302. else
  303. {
  304. _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSB");
  305. }
  306. }
  307. }
  308. }