LoaderInstallCRSRoutine.cs 21 KB

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