PufOnlyPlaceToLoaderRoutine.cs 11 KB

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