LoaderInstallCRSRoutine.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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. Wait500MS,
  49. LSVacuumOff,
  50. LSVacuumOffCheck,
  51. ReWait500MS,
  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; }, () => { return _tiltAxis.Status == RState.Failed; })
  101. //2. LS Goto Unlock
  102. .Run(InstallStep.LSGotoUnlock, () => { return _lsAxis.PositionStation($"Unlock{_waferSize}", false); }, NullFun, _delay_1ms)
  103. .WaitWithStopCondition(InstallStep.LSGotoUnlockWait, () => { return _lsAxis.Status == RState.End; }, () => { return _lsAxis.Status == RState.Failed; })
  104. //3. Shuttle Goto IN
  105. .Run(InstallStep.ShuttleGotoIN, () => { return _shuttleAxis.PositionStation("IN", false); }, NullFun, _delay_1ms)
  106. .WaitWithStopCondition(InstallStep.ShuttleGotoINWait, () => { return _shuttleAxis.Status == RState.End; }, () => { return _shuttleAxis.Status == RState.Failed; })
  107. //4. BernoulliBladder On
  108. .Run(InstallStep.BernoulliBladderOn, () => { return _bernoulliBladderRoutine.Start(true) == RState.Running; }, _delay_1ms)
  109. .WaitWithStopCondition(InstallStep.BernoulliBladderOnCheck, () => { return CommonFunction.CheckRoutineEndState(_bernoulliBladderRoutine); }, () => { return CommonFunction.CheckRoutineStopState(_bernoulliBladderRoutine); })
  110. //5. Bernoulli N2 On
  111. .Run(InstallStep.BernoulliN2On, () => { return _bernoulliN2PressureRoutine.Start(true) == RState.Running; }, _delay_1ms)
  112. .WaitWithStopCondition(InstallStep.BernoulliN2OnCheck, () => { return CommonFunction.CheckRoutineEndState(_bernoulliN2PressureRoutine); }, () => { return CommonFunction.CheckRoutineStopState(_bernoulliN2PressureRoutine); })
  113. //6. WS Bladder On
  114. .Run(InstallStep.WSBladderOn, () => { return _whBladderRoutine.Start(true) == RState.Running; }, _delay_1ms)
  115. .WaitWithStopCondition(InstallStep.WSBladderOnCheck, () => { return CommonFunction.CheckRoutineEndState(_whBladderRoutine); }, () => { return CommonFunction.CheckRoutineStopState(_whBladderRoutine); })
  116. //7. LS Vacuum On
  117. .Run(InstallStep.LSVacuumOn, () => { return _vacuumRoutine.Start(true) == RState.Running; }, _delay_1ms)
  118. .WaitWithStopCondition(InstallStep.LSVacuumOnCheck, () => { return CommonFunction.CheckRoutineEndState(_vacuumRoutine); }, () => { return CommonFunction.CheckRoutineStopState(_vacuumRoutine); })
  119. //8. LS Vacuum Level Check
  120. .Run(InstallStep.VacuumLevelCheck, () => { return _vacuumLevelCheckRoutine.Start(true) == RState.Running; }, _delay_1ms)
  121. .WaitWithStopCondition(InstallStep.VacuumLevelCheckWait, () => { return CommonFunction.CheckRoutineEndState(_vacuumLevelCheckRoutine); }, () => { return CommonFunction.CheckRoutineStopState(_vacuumLevelCheckRoutine); })
  122. //9. Shutle Goto LS
  123. .Run(InstallStep.ShuttleGotoLS, () => { return _shuttleAxis.PositionStation("LS", false); }, NullFun, _delay_1ms)
  124. .WaitWithStopCondition(InstallStep.ShuttleGotoLSWait, () => { return _shuttleAxis.Status == RState.End; }, () => { return _shuttleAxis.Status == RState.Failed; })
  125. //10. LS Goto Lock
  126. .Run(InstallStep.LSGotoLock, () => { return _lsAxis.PositionStation($"Lock{_waferSize}", false, 0, 0, 0, false); }, NullFun, _delay_1ms)
  127. .WaitWithStopCondition(InstallStep.LSGotoLockWait, () => { return _lsAxis.Status == RState.End; }, () => { return _lsAxis.Status == RState.Failed; })
  128. //11. Bernoulli N2 Off
  129. .Run(InstallStep.BernoulliN2Off, () => { return _bernoulliN2PressureRoutine.Start(false) == RState.Running; }, _delay_1ms)
  130. .WaitWithStopCondition(InstallStep.BernoulliN2OffCheck, () => { return CommonFunction.CheckRoutineEndState(_bernoulliN2PressureRoutine); }, () => { return CommonFunction.CheckRoutineStopState(_bernoulliN2PressureRoutine); })
  131. //12. WS Bladder Off
  132. .Run(InstallStep.WSBladderOff, () => { return _whBladderRoutine.Start(false) == RState.Running; }, _delay_1ms)
  133. .WaitWithStopCondition(InstallStep.WSBladderOffCheck, () => { return CommonFunction.CheckRoutineEndState(_whBladderRoutine); }, () => { return CommonFunction.CheckRoutineStopState(_whBladderRoutine); })
  134. //13. Wait 0.5s for WS Bladder
  135. .Delay(InstallStep.Wait500MS, 500)
  136. //14. LS Vacuum Off
  137. .Run(InstallStep.LSVacuumOff, () => { return _vacuumRoutine.Start(false) == RState.Running; }, _delay_1ms)
  138. .WaitWithStopCondition(InstallStep.LSVacuumOffCheck, () => { return CommonFunction.CheckRoutineEndState(_vacuumRoutine); }, () => { return CommonFunction.CheckRoutineStopState(_vacuumRoutine); })
  139. //15. Wait 0.5s
  140. .Delay(InstallStep.ReWait500MS, 500)
  141. //16. Shuttle Goto MID
  142. .Run(InstallStep.ShuttleGotoMID, () => { return _shuttleAxis.PositionStation("MID", false); }, NullFun, _delay_1ms)
  143. .WaitWithStopCondition(InstallStep.ShuttleGotoMIDWait, () => { return _shuttleAxis.Status == RState.End; }, () => { return _shuttleAxis.Status == RState.Failed; })
  144. //17. Home LS Axis
  145. .Run(InstallStep.HomingLSAxis, () => { return _lsAxis.Home(); }, _delay_1ms)
  146. .WaitWithStopCondition(InstallStep.HomingLSAxisWait, () => { return _lsAxis.Status == RState.End; }, () => { return _lsAxis.Status == RState.Failed; })
  147. .End(InstallStep.End, NullFun, 10);
  148. return Runner.Status;
  149. }
  150. /// <summary>
  151. /// 启动
  152. /// </summary>
  153. /// <param name="objs"></param>
  154. /// <returns></returns>
  155. /// <exception cref="NotImplementedException"></exception>
  156. public RState Start(params object[] objs)
  157. {
  158. if (SC.ContainsItem($"Loader1.{_side}WaferSize"))
  159. {
  160. _waferSize = SC.GetValue<int>($"Loader1.{_side}WaferSize");
  161. }
  162. _shuttleAxis = GetShuttleAxis();
  163. _lsAxis = GetCrsAxis();
  164. _tiltAxis = GetTiltAxis();
  165. _loaderCommonDevice = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");
  166. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  167. _sideDevice = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.{_side}");
  168. _vacuumRoutine = new LoaderSideVacuumRoutine($"{Module}.{_side}");
  169. _vacuumLevelCheckRoutine = new LoaderSideVacuumLevelCheckRoutine($"{Module}.{_side}");
  170. _whBladderRoutine = new LoaderSideWhBladderRoutine($"{Module}.{_side}");
  171. _bernoulliBladderRoutine = new LoaderSideBernoulliBladderRoutine($"{Module}.{_side}");
  172. _bernoulliN2PressureRoutine = new LoaderSideBernoulliN2PressureRoutine($"{Module}.{_side}");
  173. if(!CheckPreCondition())
  174. {
  175. return RState.Failed;
  176. }
  177. Runner.Start(Module, "InstallCRS");
  178. return RState.Running;
  179. }
  180. /// <summary>
  181. /// 获取Shuttle轴对象
  182. /// </summary>
  183. /// <returns></returns>
  184. private JetAxisBase GetShuttleAxis()
  185. {
  186. switch (_side)
  187. {
  188. case "SideA":
  189. return DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleA");
  190. default:
  191. return DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleB");
  192. }
  193. }
  194. /// <summary>
  195. /// 获取CRS轴对象
  196. /// </summary>
  197. /// <returns></returns>
  198. private JetAxisBase GetCrsAxis()
  199. {
  200. switch (_side)
  201. {
  202. case "SideA":
  203. return DEVICE.GetDevice<JetAxisBase>($"{Module}.LSA");
  204. default:
  205. return DEVICE.GetDevice<JetAxisBase>($"{Module}.LSB");
  206. }
  207. }
  208. /// <summary>
  209. /// 获取Tilt轴对象
  210. /// </summary>
  211. /// <returns></returns>
  212. private JetAxisBase GetTiltAxis()
  213. {
  214. switch (_side)
  215. {
  216. case "SideA":
  217. return DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
  218. default:
  219. return DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
  220. }
  221. }
  222. /// <summary>
  223. /// 检验前置条件
  224. /// </summary>
  225. /// <returns></returns>
  226. private bool CheckPreCondition()
  227. {
  228. if (!CheckHomeCondition())
  229. {
  230. return false;
  231. }
  232. if (!CheckInstallCRSAxisCondition())
  233. {
  234. return false;
  235. }
  236. if (!InstallCRSStatusCheck())
  237. {
  238. return false;
  239. }
  240. return true;
  241. }
  242. /// <summary>
  243. /// 检验Home条件
  244. /// </summary>
  245. /// <returns></returns>
  246. private bool CheckHomeCondition()
  247. {
  248. //检验PUF、Loader Transporter,Robot均Homed
  249. //Efem Home
  250. if (ModuleHelper.IsInstalled(ModuleName.EFEM))
  251. {
  252. EfemEntity efemEntity = Singleton<RouteManager>.Instance.GetModule<EfemEntity>(ModuleName.EFEM.ToString());
  253. if (!efemEntity.IsHomed)
  254. {
  255. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} is not home, Cannot execute GotoSavedPosition");
  256. return false;
  257. }
  258. }
  259. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  260. {
  261. PUFEntity puf1Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF1.ToString());
  262. if (!puf1Entity.IsHomed)
  263. {
  264. NotifyError(eEvent.ERR_LOADER, "PUF1 is not homed", -1);
  265. return false;
  266. }
  267. }
  268. if (ModuleHelper.IsInstalled(ModuleName.Transporter2))
  269. {
  270. TransporterEntity loaderTransportEntity = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(ModuleName.Transporter2.ToString());
  271. if (!loaderTransportEntity.IsHomed)
  272. {
  273. NotifyError(eEvent.ERR_LOADER, "Loader Transporter is not homed", -1);
  274. return false;
  275. }
  276. }
  277. return true;
  278. }
  279. /// <summary>
  280. /// 检验Axis条件
  281. /// </summary>
  282. /// <param name="side"></param>
  283. /// <returns></returns>
  284. private bool CheckInstallCRSAxisCondition()
  285. {
  286. if (!_rotationAxis.IsHomed)
  287. {
  288. NotifyError(eEvent.ERR_LOADER, $"Rotation is not homed", -1);
  289. return false;
  290. }
  291. if (!_shuttleAxis.IsHomed)
  292. {
  293. NotifyError(eEvent.ERR_LOADER, $"{_shuttleAxis.Name} is not homed", -1);
  294. return false;
  295. }
  296. if (!_tiltAxis.IsHomed)
  297. {
  298. NotifyError(eEvent.ERR_LOADER, $"{_tiltAxis.Name} is not homed", -1);
  299. return false;
  300. }
  301. if (!_lsAxis.IsHomed)
  302. {
  303. NotifyError(eEvent.ERR_LOADER, $"{_lsAxis.Name} is not homed", -1);
  304. return false;
  305. }
  306. //LS已经运动到 Setup 位
  307. double crsPosition = _lsAxis.MotionData.MotorPosition;
  308. if (!_lsAxis.CheckPositionIsInStation(crsPosition, $"Setup{_waferSize}"))
  309. {
  310. NotifyError(eEvent.ERR_LOADER, $"LS {crsPosition} not in Setup{_waferSize}", -1);
  311. return false;
  312. }
  313. //Rotation已经运动到 loaderA 位(sideA 下片时)或 loaderB 位(sideB 下片时)
  314. double rotationPosition = _rotationAxis.MotionData.MotorPosition;
  315. if (_side == "SideA")
  316. {
  317. if (!_rotationAxis.CheckPositionIsInStation(rotationPosition, $"LOADA{_waferSize}"))
  318. {
  319. NotifyError(eEvent.ERR_LOADER, $"Rotation {rotationPosition} not in LOADA{_waferSize}", -1);
  320. return false;
  321. }
  322. }
  323. else
  324. {
  325. if (!_rotationAxis.CheckPositionIsInStation(rotationPosition, $"LOADB{_waferSize}"))
  326. {
  327. NotifyError(eEvent.ERR_LOADER, $"Rotation {rotationPosition} not in LOADB{_waferSize}", -1);
  328. return false;
  329. }
  330. }
  331. //Shuttle已经运动到除 IN 外任何位置
  332. double shuttlePosition = _shuttleAxis.MotionData.MotorPosition;
  333. if (_shuttleAxis.CheckPositionIsInStation(shuttlePosition, "IN"))
  334. {
  335. NotifyError(eEvent.ERR_LOADER, $"Shuttle {shuttlePosition} not in IN", -1);
  336. return false;
  337. }
  338. return true;
  339. }
  340. /// <summary>
  341. /// 检验Status条件
  342. /// </summary>
  343. /// <param name="side"></param>
  344. /// <returns></returns>
  345. private bool InstallCRSStatusCheck()
  346. {
  347. LoaderSideData sideData = _sideDevice.SideData;
  348. LoaderCommonData commonData = _loaderCommonDevice.CommonData;
  349. //Bernoulli Bladder(WS Bladder on)
  350. if (!sideData.BernoulliBladder)
  351. {
  352. NotifyError(eEvent.ERR_LOADER, "Bernoulli Bladder is off", -1);
  353. return false;
  354. }
  355. //Bernoulli N2(BernoulliN2 off)
  356. if (sideData.BernoulliN2)
  357. {
  358. NotifyError(eEvent.ERR_LOADER, "Bernoulli N2 is on", -1);
  359. return false;
  360. }
  361. //CRS Vacuum检验(Vacuum off)
  362. if (sideData.CRSVacuum)
  363. {
  364. LOG.WriteLog(eEvent.ERR_LOADER, Module, "LS Vacuum is on");
  365. return false;
  366. }
  367. //Wafer Shuttle Present
  368. if (!commonData.WaferHolderPresent)
  369. {
  370. LOG.WriteLog(eEvent.ERR_LOADER, Module, "Wafer Shuttle is absent");
  371. return false;
  372. }
  373. //WS Clamp On
  374. if (!commonData.WaferHolderClamp)
  375. {
  376. NotifyError(eEvent.ERR_LOADER, "Wafer Shuttle Clamp is off", -1);
  377. return false;
  378. }
  379. //WS Bladder off
  380. if (sideData.WHBladder)
  381. {
  382. LOG.WriteLog(eEvent.ERR_LOADER, Module, "WS Bladder is on");
  383. return false;
  384. }
  385. //Drip Tray Fluid(正常)
  386. if (commonData.DripTrayFluid)
  387. {
  388. LOG.WriteLog(eEvent.ERR_LOADER, Module, "Drip Tray Fluid is on");
  389. return false;
  390. }
  391. return true;
  392. }
  393. }
  394. }