LoaderInstallCRSRoutine.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.Util;
  5. using MECF.Framework.Common.CommonData.Loader;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.Routine;
  8. using MECF.Framework.Common.Utilities;
  9. using CyberX8_Core;
  10. using CyberX8_RT.Devices.AXIS;
  11. using CyberX8_RT.Devices.AXIS.CANOpen;
  12. using CyberX8_RT.Modules.PUF;
  13. using CyberX8_RT.Modules;
  14. using System;
  15. using CyberX8_RT.Modules.Transporter;
  16. using Aitex.Core.RT.SCCore;
  17. namespace CyberX8_RT.Devices.Loader
  18. {
  19. public class LoaderInstallCRSRoutine : RoutineBase, IRoutine
  20. {
  21. private enum InstallStep
  22. {
  23. CheckPreCondition,
  24. TiltGotoVertical,
  25. TiltGotoVerticalCheck,
  26. LSGotoUnlock,
  27. LSGotoUnlockWait,
  28. ShuttleGotoIN,
  29. ShuttleGotoINWait,
  30. BernoulliBladderOn,
  31. BernoulliBladderOnCheck,
  32. BernoulliN2On,
  33. BernoulliN2OnCheck,
  34. WSBladderOn,
  35. WSBladderOnCheck,
  36. LSVacuumOn,
  37. LSVacuumOnCheck,
  38. VacuumLevelCheck,
  39. VacuumLevelCheckWait,
  40. ShuttleGotoLS,
  41. ShuttleGotoLSWait,
  42. LSGotoLock,
  43. LSGotoLockWait,
  44. BernoulliN2Off,
  45. BernoulliN2OffCheck,
  46. WSBladderOff,
  47. WSBladderOffCheck,
  48. Wait500MSForWSBladder,
  49. LSVacuumOff,
  50. LSVacuumOffCheck,
  51. Wait500MS,
  52. ShuttleGotoMID,
  53. ShuttleGotoMIDWait,
  54. HomingLSAxis,
  55. HomingLSAxisWait,
  56. End
  57. }
  58. #region 内部变量
  59. private string _side = "";
  60. private JetAxisBase _lsAxis;
  61. private LoaderSideBernoulliBladderRoutine _bernoulliBladderRoutine;
  62. private LoaderSideBernoulliN2PressureRoutine _bernoulliN2PressureRoutine;
  63. private LoaderSideVacuumRoutine _vacuumRoutine;
  64. private LoaderSideVacuumLevelCheckRoutine _vacuumLevelCheckRoutine;
  65. private LoaderSideWhBladderRoutine _whBladderRoutine;
  66. private JetAxisBase _shuttleAxis;
  67. private JetAxisBase _tiltAxis;
  68. private JetAxisBase _rotationAxis;
  69. private LoaderCommonDevice _loaderCommonDevice;
  70. private LoaderSideDevice _sideDevice;
  71. /// <summary>
  72. /// WaferSize
  73. /// </summary>
  74. private int _waferSize;
  75. #endregion
  76. /// <summary>
  77. /// 构造函数
  78. /// </summary>
  79. /// <param name="module"></param>
  80. public LoaderInstallCRSRoutine(string module,string side) : base(module)
  81. {
  82. _side = side;
  83. }
  84. /// <summary>
  85. /// 中止
  86. /// </summary>
  87. public void Abort()
  88. {
  89. Runner.Stop("Manual Abort");
  90. }
  91. /// <summary>
  92. /// 监控
  93. /// </summary>
  94. /// <returns></returns>
  95. public RState Monitor()
  96. {
  97. Runner.Run(InstallStep.CheckPreCondition, CheckPreCondition, _delay_1ms)
  98. //1. Tilt Goto Vertical
  99. .Run(InstallStep.TiltGotoVertical, () => { return _tiltAxis.PositionStation("VERT",false); }, NullFun, _delay_1ms)
  100. .WaitWithStopCondition(InstallStep.TiltGotoVerticalCheck, () => { return _tiltAxis.Status == RState.End; },
  101. () => { return _tiltAxis.Status == RState.Failed; })
  102. //2. LS Goto Unlock
  103. .Run(InstallStep.LSGotoUnlock, () => { return _lsAxis.PositionStation($"Unlock{_waferSize}", false); }, NullFun, _delay_1ms)
  104. .WaitWithStopCondition(InstallStep.LSGotoUnlockWait, () => { return _lsAxis.Status == RState.End; },
  105. () => { return _lsAxis.Status == RState.Failed; })
  106. //3. Shuttle Goto IN
  107. .Run(InstallStep.ShuttleGotoIN, () => { return _shuttleAxis.PositionStation("IN", false); }, NullFun, _delay_1ms)
  108. .WaitWithStopCondition(InstallStep.ShuttleGotoINWait, () => { return _shuttleAxis.Status == RState.End; },
  109. () => { return _shuttleAxis.Status == RState.Failed; })
  110. //4. BernoulliBladder On
  111. .Run(InstallStep.BernoulliBladderOn, () => { return _bernoulliBladderRoutine.Start(true) == RState.Running; }, _delay_1ms)
  112. .WaitWithStopCondition(InstallStep.BernoulliBladderOnCheck, () => { return CommonFunction.CheckRoutineEndState(_bernoulliBladderRoutine); },
  113. () => CheckRoutineStopStatus(_bernoulliBladderRoutine, "BernoulliBladder On failed"))
  114. //5. Bernoulli N2 On
  115. .Run(InstallStep.BernoulliN2On, () => { return _bernoulliN2PressureRoutine.Start(true) == RState.Running; }, _delay_1ms)
  116. .WaitWithStopCondition(InstallStep.BernoulliN2OnCheck, () => { return CommonFunction.CheckRoutineEndState(_bernoulliN2PressureRoutine); },
  117. () => CheckRoutineStopStatus(_bernoulliN2PressureRoutine, " BernoulliN2 On failed"))
  118. //6. WS Bladder On
  119. .Run(InstallStep.WSBladderOn, () => { return _whBladderRoutine.Start(true) == RState.Running; }, _delay_1ms)
  120. .WaitWithStopCondition(InstallStep.WSBladderOnCheck, () => { return CommonFunction.CheckRoutineEndState(_whBladderRoutine); },
  121. () => CheckRoutineStopStatus(_whBladderRoutine, "WSBladder On failed"))
  122. //7. LS Vacuum On
  123. .Run(InstallStep.LSVacuumOn, () => { return _vacuumRoutine.Start(true) == RState.Running; }, _delay_1ms)
  124. .WaitWithStopCondition(InstallStep.LSVacuumOnCheck, () => { return CommonFunction.CheckRoutineEndState(_vacuumRoutine); },
  125. () => CheckRoutineStopStatus(_vacuumRoutine, "LS Vacuum On failed"))
  126. //8. LS Vacuum Level Check
  127. .Run(InstallStep.VacuumLevelCheck, () => { return _vacuumLevelCheckRoutine.Start(true) == RState.Running; }, _delay_1ms)
  128. .WaitWithStopCondition(InstallStep.VacuumLevelCheckWait, () => { return CommonFunction.CheckRoutineEndState(_vacuumLevelCheckRoutine); },
  129. () => CheckRoutineStopStatus(_vacuumLevelCheckRoutine, "LS Vacuum Level Check failed"))
  130. //9. Shuttle Goto LS
  131. .Run(InstallStep.ShuttleGotoLS, () => { return _shuttleAxis.PositionStation("LS", false); }, NullFun, _delay_1ms)
  132. .WaitWithStopCondition(InstallStep.ShuttleGotoLSWait, () => { return _shuttleAxis.Status == RState.End; },
  133. () => { return _shuttleAxis.Status == RState.Failed; })
  134. //10. LS Goto Lock
  135. .Run(InstallStep.LSGotoLock, () => { return _lsAxis.PositionStation($"Lock{_waferSize}", false, 0, 0, 0, false); }, NullFun, _delay_1ms)
  136. .WaitWithStopCondition(InstallStep.LSGotoLockWait, () => { return _lsAxis.Status == RState.End; },
  137. () => { return _lsAxis.Status == RState.Failed; })
  138. //11. Bernoulli N2 Off
  139. .Run(InstallStep.BernoulliN2Off, () => { return _bernoulliN2PressureRoutine.Start(false) == RState.Running; }, _delay_1ms)
  140. .WaitWithStopCondition(InstallStep.BernoulliN2OffCheck, () => { return CommonFunction.CheckRoutineEndState(_bernoulliN2PressureRoutine); },
  141. () => CheckRoutineStopStatus(_bernoulliN2PressureRoutine, " BernoulliN2 Off failed"))
  142. //12. WS Bladder Off
  143. .Run(InstallStep.WSBladderOff, () => { return _whBladderRoutine.Start(false) == RState.Running; }, _delay_1ms)
  144. .WaitWithStopCondition(InstallStep.WSBladderOffCheck, () => { return CommonFunction.CheckRoutineEndState(_whBladderRoutine); },
  145. () => CheckRoutineStopStatus(_whBladderRoutine, "WSBladder Off failed"))
  146. //13. Wait 0.5s for WS Bladder
  147. .Delay(InstallStep.Wait500MSForWSBladder, 500)
  148. //14. LS Vacuum Off
  149. .Run(InstallStep.LSVacuumOff, () => { return _vacuumRoutine.Start(false) == RState.Running; }, _delay_1ms)
  150. .WaitWithStopCondition(InstallStep.LSVacuumOffCheck, () => { return CommonFunction.CheckRoutineEndState(_vacuumRoutine); },
  151. () => CheckRoutineStopStatus(_vacuumRoutine, "LS Vacuum Off failed"))
  152. //15. Wait 0.5s
  153. .Delay(InstallStep.Wait500MS, 500)
  154. //16. Shuttle Goto MID
  155. .Run(InstallStep.ShuttleGotoMID, () => { return _shuttleAxis.PositionStation("MID", false); }, NullFun, _delay_1ms)
  156. .WaitWithStopCondition(InstallStep.ShuttleGotoMIDWait, () => { return _shuttleAxis.Status == RState.End; },
  157. () => { return _shuttleAxis.Status == RState.Failed; })
  158. //17. Home LS Axis
  159. .Run(InstallStep.HomingLSAxis, () => { return _lsAxis.Home(); }, _delay_1ms)
  160. .WaitWithStopCondition(InstallStep.HomingLSAxisWait, () => { return _lsAxis.Status == RState.End; },
  161. () => { return _lsAxis.Status == RState.Failed; })
  162. .End(InstallStep.End, NullFun, 10);
  163. return Runner.Status;
  164. }
  165. /// <summary>
  166. /// 启动
  167. /// </summary>
  168. /// <param name="objs"></param>
  169. /// <returns></returns>
  170. /// <exception cref="NotImplementedException"></exception>
  171. public RState Start(params object[] objs)
  172. {
  173. if (SC.ContainsItem($"Loader1.{_side}WaferSize"))
  174. {
  175. _waferSize = SC.GetValue<int>($"Loader1.{_side}WaferSize");
  176. }
  177. _shuttleAxis = GetShuttleAxis();
  178. _lsAxis = GetLsAxis();
  179. _tiltAxis = GetTiltAxis();
  180. _loaderCommonDevice = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");
  181. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  182. _sideDevice = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.{_side}");
  183. _vacuumRoutine = new LoaderSideVacuumRoutine($"{Module}.{_side}");
  184. _vacuumLevelCheckRoutine = new LoaderSideVacuumLevelCheckRoutine($"{Module}.{_side}");
  185. _whBladderRoutine = new LoaderSideWhBladderRoutine($"{Module}.{_side}");
  186. _bernoulliBladderRoutine = new LoaderSideBernoulliBladderRoutine($"{Module}.{_side}");
  187. _bernoulliN2PressureRoutine = new LoaderSideBernoulliN2PressureRoutine($"{Module}.{_side}");
  188. Runner.Start(Module, "Install LS");
  189. return RState.Running;
  190. }
  191. /// <summary>
  192. /// 检验Routine异常状态
  193. /// </summary>
  194. /// <returns></returns>
  195. private bool CheckRoutineStopStatus(IRoutine routine, string error)
  196. {
  197. bool result = CommonFunction.CheckRoutineStopState(routine);
  198. if (result)
  199. {
  200. NotifyError(eEvent.ERR_LOADER, $"{error}", 0);
  201. }
  202. return result;
  203. }
  204. /// <summary>
  205. /// 获取Shuttle轴对象
  206. /// </summary>
  207. /// <returns></returns>
  208. private JetAxisBase GetShuttleAxis()
  209. {
  210. switch (_side)
  211. {
  212. case "SideA":
  213. return DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleA");
  214. default:
  215. return DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleB");
  216. }
  217. }
  218. /// <summary>
  219. /// 获取CRS轴对象
  220. /// </summary>
  221. /// <returns></returns>
  222. private JetAxisBase GetLsAxis()
  223. {
  224. switch (_side)
  225. {
  226. case "SideA":
  227. return DEVICE.GetDevice<JetAxisBase>($"{Module}.LSA");
  228. default:
  229. return DEVICE.GetDevice<JetAxisBase>($"{Module}.LSB");
  230. }
  231. }
  232. /// <summary>
  233. /// 获取Tilt轴对象
  234. /// </summary>
  235. /// <returns></returns>
  236. private JetAxisBase GetTiltAxis()
  237. {
  238. switch (_side)
  239. {
  240. case "SideA":
  241. return DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
  242. default:
  243. return DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
  244. }
  245. }
  246. /// <summary>
  247. /// 检验前置条件
  248. /// </summary>
  249. /// <returns></returns>
  250. private bool CheckPreCondition()
  251. {
  252. if (!CheckHomeCondition())
  253. {
  254. return false;
  255. }
  256. if (!CheckInstallCRSAxisCondition())
  257. {
  258. return false;
  259. }
  260. if (!InstallCRSStatusCheck())
  261. {
  262. return false;
  263. }
  264. return true;
  265. }
  266. /// <summary>
  267. /// 检验Home条件
  268. /// </summary>
  269. /// <returns></returns>
  270. private bool CheckHomeCondition()
  271. {
  272. //检验PUF、Loader Transporter,Robot均Homed
  273. //Efem Home
  274. if (ModuleHelper.IsInstalled(ModuleName.EFEM))
  275. {
  276. EfemEntity efemEntity = Singleton<RouteManager>.Instance.GetModule<EfemEntity>(ModuleName.EFEM.ToString());
  277. if (!efemEntity.IsHomed)
  278. {
  279. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} is not home, Cannot execute GotoSavedPosition");
  280. return false;
  281. }
  282. }
  283. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  284. {
  285. PUFEntity puf1Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF1.ToString());
  286. if (!puf1Entity.IsHomed)
  287. {
  288. NotifyError(eEvent.ERR_LOADER, "PUF1 is not homed", -1);
  289. return false;
  290. }
  291. }
  292. if (ModuleHelper.IsInstalled(ModuleName.Transporter2))
  293. {
  294. TransporterEntity loaderTransportEntity = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(ModuleName.Transporter2.ToString());
  295. if (!loaderTransportEntity.IsHomed)
  296. {
  297. NotifyError(eEvent.ERR_LOADER, "Loader Transporter is not homed", -1);
  298. return false;
  299. }
  300. }
  301. return true;
  302. }
  303. /// <summary>
  304. /// 检验Axis条件
  305. /// </summary>
  306. /// <param name="side"></param>
  307. /// <returns></returns>
  308. private bool CheckInstallCRSAxisCondition()
  309. {
  310. if (!_rotationAxis.IsHomed)
  311. {
  312. NotifyError(eEvent.ERR_LOADER, $"Rotation is not homed", -1);
  313. return false;
  314. }
  315. if (!_shuttleAxis.IsHomed)
  316. {
  317. NotifyError(eEvent.ERR_LOADER, $"{_shuttleAxis.Name} is not homed", -1);
  318. return false;
  319. }
  320. if (!_tiltAxis.IsHomed)
  321. {
  322. NotifyError(eEvent.ERR_LOADER, $"{_tiltAxis.Name} is not homed", -1);
  323. return false;
  324. }
  325. if (!_lsAxis.IsHomed)
  326. {
  327. NotifyError(eEvent.ERR_LOADER, $"{_lsAxis.Name} is not homed", -1);
  328. return false;
  329. }
  330. //LS已经运动到 Setup 位
  331. double crsPosition = _lsAxis.MotionData.MotorPosition;
  332. if (!_lsAxis.CheckPositionIsInStation(crsPosition, $"Setup{_waferSize}"))
  333. {
  334. NotifyError(eEvent.ERR_LOADER, $"LS {crsPosition} not in Setup{_waferSize}", -1);
  335. return false;
  336. }
  337. //Rotation已经运动到 loaderA 位(sideA 下片时)或 loaderB 位(sideB 下片时)
  338. double rotationPosition = _rotationAxis.MotionData.MotorPosition;
  339. if (_side == "SideA")
  340. {
  341. if (!_rotationAxis.CheckPositionIsInStation(rotationPosition, $"LOADA{_waferSize}"))
  342. {
  343. NotifyError(eEvent.ERR_LOADER, $"Rotation {rotationPosition} not in LOADA{_waferSize}", -1);
  344. return false;
  345. }
  346. }
  347. else
  348. {
  349. if (!_rotationAxis.CheckPositionIsInStation(rotationPosition, $"LOADB{_waferSize}"))
  350. {
  351. NotifyError(eEvent.ERR_LOADER, $"Rotation {rotationPosition} not in LOADB{_waferSize}", -1);
  352. return false;
  353. }
  354. }
  355. //Shuttle已经运动到除 IN 外任何位置
  356. double shuttlePosition = _shuttleAxis.MotionData.MotorPosition;
  357. if (_shuttleAxis.CheckPositionIsInStation(shuttlePosition, "IN"))
  358. {
  359. NotifyError(eEvent.ERR_LOADER, $"Shuttle {shuttlePosition} is in IN", -1);
  360. return false;
  361. }
  362. return true;
  363. }
  364. /// <summary>
  365. /// 检验Status条件
  366. /// </summary>
  367. /// <param name="side"></param>
  368. /// <returns></returns>
  369. private bool InstallCRSStatusCheck()
  370. {
  371. LoaderSideData sideData = _sideDevice.SideData;
  372. LoaderCommonData commonData = _loaderCommonDevice.CommonData;
  373. //Bernoulli Bladder(WS Bladder on)
  374. if (!sideData.BernoulliBladder)
  375. {
  376. NotifyError(eEvent.ERR_LOADER, "Bernoulli Bladder is off", -1);
  377. return false;
  378. }
  379. //Bernoulli N2(BernoulliN2 off)
  380. if (sideData.BernoulliN2)
  381. {
  382. NotifyError(eEvent.ERR_LOADER, "Bernoulli N2 is on", -1);
  383. return false;
  384. }
  385. //CRS Vacuum检验(Vacuum off)
  386. if (sideData.CRSVacuum)
  387. {
  388. LOG.WriteLog(eEvent.ERR_LOADER, Module, "LS Vacuum is on");
  389. return false;
  390. }
  391. //Wafer Shuttle Present
  392. if (!commonData.WaferHolderPresent)
  393. {
  394. LOG.WriteLog(eEvent.ERR_LOADER, Module, "Wafer Shuttle is absent");
  395. return false;
  396. }
  397. //WS Clamp On
  398. if (!commonData.WaferHolderClamp)
  399. {
  400. NotifyError(eEvent.ERR_LOADER, "Wafer Shuttle Clamp is off", -1);
  401. return false;
  402. }
  403. //WS Bladder off
  404. if (sideData.WHBladder)
  405. {
  406. LOG.WriteLog(eEvent.ERR_LOADER, Module, "WS Bladder is on");
  407. return false;
  408. }
  409. //Drip Tray Fluid(正常)
  410. if (commonData.DripTrayFluid)
  411. {
  412. LOG.WriteLog(eEvent.ERR_LOADER, Module, "Drip Tray Fluid is on");
  413. return false;
  414. }
  415. return true;
  416. }
  417. }
  418. }