SRDLoaderRoutine.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using CyberX8_Core;
  5. using CyberX8_RT.Devices.AXIS;
  6. using CyberX8_RT.Devices.Facilities;
  7. using CyberX8_RT.Devices.SRD;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.Routine;
  10. using MECF.Framework.Common.SubstrateTrackings;
  11. using Aitex.Core.Common;
  12. namespace CyberX8_RT.Modules.SRD
  13. {
  14. public class SRDLoaderRoutine : RoutineBase, IRoutine
  15. {
  16. private enum SRDLoaderStep
  17. {
  18. Loader_LiftUpOff,
  19. Loader_FlippersIn,
  20. Loader_N2On,
  21. Loader_Delay,
  22. Loader_N2Off,
  23. Loader_ChuckVacuumOn,
  24. Loader_FlippersOut,
  25. End
  26. }
  27. #region 常量
  28. #endregion
  29. #region 内部变量
  30. /// <summary>
  31. /// Rotation Axis
  32. /// </summary>
  33. private JetAxisBase _rotationAxis;
  34. /// <summary>
  35. /// SRD Common
  36. /// </summary>
  37. private SrdCommonDevice _srdCommon;
  38. /// <summary>
  39. /// Total SRD
  40. /// </summary>
  41. private TotalSRDDevice _totalSRDDevice;
  42. /// <summary>
  43. /// System Facility
  44. /// </summary>
  45. private SystemFacilities _systemFacilities;
  46. /// <summary>
  47. /// 当前WaferSize
  48. /// </summary>
  49. private int _waferSize = 200;
  50. #endregion
  51. #region 属性
  52. #endregion
  53. /// <summary>
  54. /// 构造函数
  55. /// </summary>
  56. /// <param name="module"></param>
  57. public SRDLoaderRoutine(string module) : base(module)
  58. {
  59. }
  60. /// <summary>
  61. /// 中止
  62. /// </summary>
  63. public void Abort()
  64. {
  65. Runner.Stop("SRD Loader Abort");
  66. }
  67. /// <summary>
  68. /// 监控
  69. /// </summary>
  70. /// <returns></returns>
  71. public RState Monitor()
  72. {
  73. Runner.Run(SRDLoaderStep.Loader_LiftUpOff, LiftUpOff, CheckLiftUpOffEndStatus, CheckLiftUpOffStopStatus)
  74. .Run(SRDLoaderStep.Loader_FlippersIn, FlippersIn, CheckFlippersInEndStatus, CheckFlippersInStopStatus)
  75. .Run(SRDLoaderStep.Loader_N2On, N2On, _delay_1ms)
  76. .Delay(SRDLoaderStep.Loader_Delay, 500)
  77. .Run(SRDLoaderStep.Loader_N2Off, N2Off, _delay_1ms)
  78. .Run(SRDLoaderStep.Loader_ChuckVacuumOn, ChuckVacuumOn, CheckChuckVacuumOnEndStatus, CheckChuckVacuumOnStopStatus)
  79. .Run(SRDLoaderStep.Loader_FlippersOut, FlippersOut, CheckFlippersOutEndStatus, CheckFlippersOutStopStatus)
  80. .End(SRDLoaderStep.End, NullFun, _delay_1ms);
  81. return Runner.Status;
  82. }
  83. /// <summary>
  84. /// 启动
  85. /// </summary>
  86. /// <param name="objs"></param>
  87. /// <returns></returns>
  88. public RState Start(params object[] objs)
  89. {
  90. _srdCommon = DEVICE.GetDevice<SrdCommonDevice>($"{Module}.Common");
  91. _totalSRDDevice = DEVICE.GetDevice<TotalSRDDevice>("SRD");
  92. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  93. _systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  94. if (!GetWaferSize())
  95. {
  96. NotifyError(eEvent.ERR_SRD, "Wafer Size is invalid", 0);
  97. return RState.Failed;
  98. }
  99. if (!CheckPreCondition())
  100. {
  101. return RState.Failed;
  102. }
  103. return Runner.Start(Module, "SRD Loader Start");
  104. }
  105. /// <summary>
  106. /// Check Pre Condition
  107. /// </summary>
  108. /// <returns></returns>
  109. private bool CheckPreCondition()
  110. {
  111. //Check Rotation Home
  112. if (!_rotationAxis.IsHomed)
  113. {
  114. NotifyError(eEvent.ERR_SRD, "Rotation is not homed", 0);
  115. return false;
  116. }
  117. //Check Vacuum off
  118. if (!_srdCommon.CommonData.ChuckVacuum)
  119. {
  120. NotifyError(eEvent.ERR_SRD, "Chuck Vacuum is on", 0);
  121. return false;
  122. }
  123. //Check LiftUp
  124. if (!_srdCommon.CommonData.LiftUp)
  125. {
  126. NotifyError(eEvent.ERR_SRD, "LiftUp is off", 0);
  127. return false;
  128. }
  129. //Check LiftUp Status
  130. if (!_srdCommon.CommonData.LiftUpStatus)
  131. {
  132. NotifyError(eEvent.ERR_SRD, "LiftUp sensor is off", 0);
  133. return false;
  134. }
  135. //Check Wafer Present
  136. if (!_srdCommon.CommonData.WaferPresent)
  137. {
  138. NotifyError(eEvent.ERR_SRD, "WaferPresent sensor is off", 0);
  139. return false;
  140. }
  141. //Check LoaderDI
  142. if (!_systemFacilities.LoaderDiEnable)
  143. {
  144. NotifyError(eEvent.ERR_SRD, "Load DI Is Disable", 0);
  145. return false;
  146. }
  147. //Check Flippers
  148. if (_srdCommon.CommonData.FlippersIn150 || _srdCommon.CommonData.FlippersIn200)
  149. {
  150. NotifyError(eEvent.ERR_SRD, "FlippersIn is on", 0);
  151. return false;
  152. }
  153. if (!_srdCommon.CommonData.Flipper1Out150Status || !_srdCommon.CommonData.Flipper2Out150Status || !_srdCommon.CommonData.Flipper3Out150Status
  154. || !_srdCommon.CommonData.Flipper1Out200Status || !_srdCommon.CommonData.Flipper2Out200Status || !_srdCommon.CommonData.Flipper3Out200Status)
  155. {
  156. NotifyError(eEvent.ERR_SRD, "Flippers are at In position", 0);
  157. return false;
  158. }
  159. return true;
  160. }
  161. /// <summary>
  162. /// Get current WaferSize
  163. /// </summary>
  164. /// <returns></returns>
  165. private bool GetWaferSize()
  166. {
  167. WaferInfo waferInfo = WaferManager.Instance.GetWafer(ModuleNameString.ToEnum(Module), 0);
  168. if (waferInfo == null)
  169. {
  170. return false;
  171. }
  172. switch (waferInfo.Size)
  173. {
  174. case WaferSize.WS4:
  175. _waferSize = 100;
  176. break;
  177. case WaferSize.WS6:
  178. case WaferSize.WS150:
  179. case WaferSize.WS159:
  180. _waferSize = 150;
  181. break;
  182. case WaferSize.WS0:
  183. case WaferSize.WS8:
  184. _waferSize = 200;
  185. break;
  186. default:
  187. return false;
  188. }
  189. return true;
  190. }
  191. /// <summary>
  192. /// LiftUpOff
  193. /// </summary>
  194. /// <param name="param"></param>
  195. /// <returns></returns>
  196. private bool LiftUpOff()
  197. {
  198. bool result = _srdCommon.LiftUpOffAction("", null);
  199. if (!result)
  200. {
  201. NotifyError(eEvent.ERR_SRD, "Lift Up Off Action is failed", 0);
  202. return result;
  203. }
  204. return true;
  205. }
  206. /// <summary>
  207. /// 检验LiftUpOff结束状态
  208. /// </summary>
  209. /// <param name="param"></param>
  210. /// <returns></returns>
  211. private bool CheckLiftUpOffEndStatus()
  212. {
  213. return _srdCommon.Status == RState.End && !_srdCommon.CommonData.LiftUpStatus;
  214. }
  215. /// <summary>
  216. /// 检验LiftUpOff结束状态
  217. /// </summary>
  218. /// <param name="param"></param>
  219. /// <returns></returns>
  220. private bool CheckLiftUpOffStopStatus()
  221. {
  222. if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
  223. {
  224. NotifyError(eEvent.ERR_SRD, "Check LiftUpOff is failed", 0);
  225. return true;
  226. }
  227. return false;
  228. }
  229. /// <summary>
  230. /// Flippers In
  231. /// </summary>
  232. /// <param name="param"></param>
  233. /// <returns></returns>
  234. private bool FlippersIn()
  235. {
  236. bool result = false;
  237. object[] objects = new object[1];
  238. objects[0] = _waferSize;
  239. result = _srdCommon.FlipperInAction("", objects);
  240. if (!result)
  241. {
  242. NotifyError(eEvent.ERR_SRD, $"FlipperIn{_waferSize} Action is failed", 0);
  243. return result;
  244. }
  245. return true;
  246. }
  247. /// <summary>
  248. /// 检验FlippersIn结束状态
  249. /// </summary>
  250. /// <param name="param"></param>
  251. /// <returns></returns>
  252. private bool CheckFlippersInEndStatus()
  253. {
  254. return _srdCommon.Status == RState.End;
  255. }
  256. /// <summary>
  257. /// 检验FlippersIn结束状态
  258. /// </summary>
  259. /// <param name="param"></param>
  260. /// <returns></returns>
  261. private bool CheckFlippersInStopStatus()
  262. {
  263. if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
  264. {
  265. NotifyError(eEvent.ERR_SRD, $"Check FlipperIn{_waferSize} Action is failed", 0);
  266. return true;
  267. }
  268. return false;
  269. }
  270. /// <summary>
  271. /// 打开 Wafer N2
  272. /// </summary>
  273. /// <returns></returns>
  274. private bool N2On()
  275. {
  276. bool result = _srdCommon.N2OnAction("", null);
  277. if (!result)
  278. {
  279. NotifyError(eEvent.ERR_SRD, $"N2 On Action is failed", 0);
  280. }
  281. return result;
  282. }
  283. /// <summary>
  284. /// 关闭 Wafer N2
  285. /// </summary>
  286. /// <returns></returns>
  287. private bool N2Off()
  288. {
  289. bool result = _srdCommon.N2OffAction("", null);
  290. if (!result)
  291. {
  292. NotifyError(eEvent.ERR_SRD, $"N2 Off Action is failed", 0);
  293. }
  294. return result;
  295. }
  296. /// <summary>
  297. /// ChuckVacuumOn
  298. /// </summary>
  299. /// <param name="param"></param>
  300. /// <returns></returns>
  301. private bool ChuckVacuumOn()
  302. {
  303. bool result = _srdCommon.ChuckVacuumOnAction("", null);
  304. if (!result)
  305. {
  306. NotifyError(eEvent.ERR_SRD, "ChuckVacuumOn Action is failed", 0);
  307. return result;
  308. }
  309. return true;
  310. }
  311. /// <summary>
  312. /// 检验ChuckVacuumOn结束状态
  313. /// </summary>
  314. /// <param name="param"></param>
  315. /// <returns></returns>
  316. private bool CheckChuckVacuumOnEndStatus()
  317. {
  318. return _srdCommon.Status == RState.End && !_srdCommon.CommonData.ChuckVacuum;
  319. }
  320. /// <summary>
  321. /// 检验ChuckVacuumOn结束状态
  322. /// </summary>
  323. /// <param name="param"></param>
  324. /// <returns></returns>
  325. private bool CheckChuckVacuumOnStopStatus()
  326. {
  327. if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
  328. {
  329. NotifyError(eEvent.ERR_SRD, "Check ChuckVacuumOn is failed", 0);
  330. return true;
  331. }
  332. return false;
  333. }
  334. /// <summary>
  335. /// Flippers Out
  336. /// </summary>
  337. /// <param name="param"></param>
  338. /// <returns></returns>
  339. private bool FlippersOut()
  340. {
  341. bool result = false;
  342. object[] objects = new object[1];
  343. objects[0] = _waferSize;
  344. result = _srdCommon.FlipperOutAction("", objects);
  345. if (!result)
  346. {
  347. NotifyError(eEvent.ERR_SRD, $"FlipperOut{_waferSize} Action is failed", 0);
  348. return result;
  349. }
  350. return true;
  351. }
  352. /// <summary>
  353. /// 检验FlippersOut结束状态
  354. /// </summary>
  355. /// <param name="param"></param>
  356. /// <returns></returns>
  357. private bool CheckFlippersOutEndStatus()
  358. {
  359. return _srdCommon.Status == RState.End;
  360. }
  361. /// <summary>
  362. /// 检验FlippersOut结束状态
  363. /// </summary>
  364. /// <param name="param"></param>
  365. /// <returns></returns>
  366. private bool CheckFlippersOutStopStatus()
  367. {
  368. if (_srdCommon.Status == RState.Failed || _srdCommon.Status == RState.Timeout)
  369. {
  370. NotifyError(eEvent.ERR_SRD, $"Check FlipperOut{_waferSize} Action is failed", 0);
  371. return true;
  372. }
  373. return false;
  374. }
  375. }
  376. }