LoaderLoadSideRoutine.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using MECF.Framework.Common.Equipment;
  4. using MECF.Framework.Common.Routine;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Devices.AXIS;
  7. using CyberX8_RT.Devices.Loader;
  8. using System;
  9. using System.Collections.Generic;
  10. using Aitex.Core.RT.Log;
  11. using MECF.Framework.Common.CommonData.Loader;
  12. using MECF.Framework.Common.WaferHolder;
  13. using Aitex.Core.RT.SCCore;
  14. using Aitex.Core.Util;
  15. namespace CyberX8_RT.Modules.Loader
  16. {
  17. public class LoaderLoadSideRoutine : RoutineBase, IRoutine
  18. {
  19. private enum LoadStep
  20. {
  21. SideLoad,
  22. SideAllLoadWait,
  23. LeakTest,
  24. LeakTestWait,
  25. RotationGoToTRNPA,
  26. RotationGoToTRNPAWait,
  27. UnclampWaferHolder,
  28. End
  29. }
  30. #region 常量
  31. private const string SIDE_A = "SideA";
  32. private const string SIDE_B = "SideB";
  33. private const int LOTTRACK_TIME = 1000;
  34. #endregion
  35. #region 内部变量
  36. private JetAxisBase _rotationAxis;
  37. private LoaderLoadRoutine _sideLoadRoutine;
  38. private LoaderCommonDevice _loaderCommonDevice;
  39. private bool _isSideLoaded = false;
  40. private bool _isSideStop = false;
  41. /// <summary>
  42. /// lotTrack time
  43. /// </summary>
  44. private DateTime _lotTackTime = DateTime.Now;
  45. /// <summary>
  46. /// Loader Common
  47. /// </summary>
  48. private LoaderCommonDevice _loaderCommon;
  49. /// <summary>
  50. /// LoaderSide
  51. /// </summary>
  52. private LoaderSideDevice _loaderSide;
  53. /// <summary>
  54. /// Loader LotTrackData
  55. /// </summary>
  56. private List<LoaderLotTrackData> _datas = new List<LoaderLotTrackData>();
  57. /// <summary>
  58. /// Flow LotTrackData
  59. /// </summary>
  60. private List<LoaderFlowLotTrackData> _flowDatas = new List<LoaderFlowLotTrackData>();
  61. /// <summary>
  62. /// Loader Start and Finish Time
  63. /// </summary>
  64. private List<DateTime> _loadTimeList = new List<DateTime>();
  65. /// <summary>
  66. ///
  67. /// </summary>
  68. private string _side = "";
  69. /// <summary>
  70. /// WaferSize
  71. /// </summary>
  72. private int _waferSize;
  73. /// <summary>
  74. /// load是否完成
  75. /// </summary>
  76. private bool _loadComplete = false;
  77. /// <summary>
  78. /// 完成后运行
  79. /// </summary>
  80. private string _completeSide = "TRNPA";
  81. /// <summary>
  82. /// Wafer组
  83. /// </summary>
  84. private string _waferGroup = "";
  85. #endregion
  86. #region 属性
  87. /// <summary>
  88. /// UnLoad LotTrackData
  89. /// </summary>
  90. public List<LoaderLotTrackData> LoadLotTrackDatas { get { return _datas; } }
  91. /// <summary>
  92. /// Flow LotTrackData
  93. /// </summary>
  94. public List<LoaderFlowLotTrackData> FlowLotTrackDatas { get { return _flowDatas; } }
  95. /// <summary>
  96. /// LoadTimeList
  97. /// </summary>
  98. public List<DateTime> LoadTimeList { get { return _loadTimeList; } }
  99. /// <summary>
  100. /// Wafer组
  101. /// </summary>
  102. public string WaferGroup { get { return _waferGroup; } }
  103. /// <summary>
  104. /// is SideA
  105. /// </summary>
  106. public bool IsSideA { get { return _side == SIDE_A ? true : false; } }
  107. #endregion
  108. /// <summary>
  109. /// 构造函数
  110. /// </summary>
  111. /// <param name="module"></param>
  112. public LoaderLoadSideRoutine(string module) : base(module)
  113. {
  114. }
  115. /// <summary>
  116. /// 中止
  117. /// </summary>
  118. public void Abort()
  119. {
  120. }
  121. /// <summary>
  122. /// 监控
  123. /// </summary>
  124. /// <returns></returns>
  125. public RState Monitor()
  126. {
  127. //记录Lot track
  128. LottrackRecord();
  129. Runner.Run(LoadStep.SideLoad, () => StartLoadRoutine(_sideLoadRoutine,_isSideLoaded), _delay_1ms)
  130. .WaitWithStopCondition(LoadStep.SideAllLoadWait, CheckLoadAllRoutineEndStatus,CheckLoadAllRoutineStopStatus)
  131. .Run(LoadStep.LeakTest, StartFlowTest, _delay_1ms)
  132. .WaitWithStopCondition(LoadStep.LeakTestWait, CheckFlowTestEndStatus, CheckFlowTestStopStatus)
  133. .RunIf(LoadStep.RotationGoToTRNPA,_loadComplete,RotationGotoTransporterA,_delay_1s)
  134. .WaitWithStopConditionIf(LoadStep.RotationGoToTRNPAWait,_loadComplete, CheckRotationPositionStatus,CheckRotationPositionRunStop)
  135. .RunIf(LoadStep.UnclampWaferHolder,_loadComplete, WaferHolderClampOffAction,_delay_1ms)
  136. .End(LoadStep.End, NullFun, _delay_1ms);
  137. return Runner.Status;
  138. }
  139. /// <summary>
  140. /// 检验Rotation移动状态
  141. /// </summary>
  142. /// <returns></returns>
  143. private bool CheckRotationPositionStatus()
  144. {
  145. return _rotationAxis.Status == RState.End;
  146. }
  147. /// <summary>
  148. /// 检验Rotation是否还在运动
  149. /// </summary>
  150. /// <returns></returns>
  151. private bool CheckRotationPositionRunStop()
  152. {
  153. bool result= _rotationAxis.Status == RState.Failed||_rotationAxis.Status==RState.Timeout;
  154. if (result)
  155. {
  156. NotifyError(eEvent.ERR_LOADER, "rotation goto position failed", 2);
  157. }
  158. return result;
  159. }
  160. /// <summary>
  161. /// 启动load routine
  162. /// </summary>
  163. /// <param name="loadRoutine"></param>
  164. /// <returns></returns>
  165. private bool StartLoadRoutine(LoaderLoadRoutine loadRoutine,bool isSideLoaded)
  166. {
  167. if (isSideLoaded)
  168. {
  169. return true;
  170. }
  171. bool result= loadRoutine.Start()==RState.Running;
  172. if (!result)
  173. {
  174. NotifyError(eEvent.ERR_LOADER, loadRoutine.ErrorMsg, 0);
  175. }
  176. return result;
  177. }
  178. /// <summary>
  179. /// 检验LoadAll完成状态
  180. /// </summary>
  181. /// <returns></returns>
  182. private bool CheckLoadAllRoutineEndStatus()
  183. {
  184. bool sideResult = true;
  185. if (!_isSideLoaded)
  186. {
  187. sideResult = CheckLoadRoutineEndStatus(_sideLoadRoutine);
  188. }
  189. if (sideResult)
  190. {
  191. _loadTimeList.Add(DateTime.Now);
  192. }
  193. return sideResult;
  194. }
  195. /// <summary>
  196. /// 检验LoadAll停止状态
  197. /// </summary>
  198. /// <returns></returns>
  199. private bool CheckLoadAllRoutineStopStatus()
  200. {
  201. bool sideComplete = false;
  202. if(!_isSideLoaded&&!_isSideStop)
  203. {
  204. RState ret = _sideLoadRoutine.Monitor();
  205. _isSideStop = ret == RState.Failed || ret == RState.Timeout;
  206. sideComplete = (ret != RState.Running);
  207. if (_isSideStop)
  208. {
  209. NotifyError(eEvent.ERR_LOADER, $"load failed\r\n{_sideLoadRoutine.ErrorMsg}", 0);
  210. }
  211. }
  212. return _isSideStop;
  213. }
  214. /// <summary>
  215. /// 检验routine完成状态
  216. /// </summary>
  217. /// <param name="loadRoutine"></param>
  218. /// <returns></returns>
  219. private bool CheckLoadRoutineEndStatus(LoaderLoadRoutine loadRoutine)
  220. {
  221. return loadRoutine.Monitor() == RState.End;
  222. }
  223. /// <summary>
  224. /// 启动Flowtest
  225. /// </summary>
  226. /// <returns></returns>
  227. private bool StartFlowTest()
  228. {
  229. bool result= _loaderCommonDevice.StartFlowTestAction();
  230. if (!result)
  231. {
  232. NotifyError(eEvent.ERR_LOADER, "Start Flow Test failed", 1);
  233. }
  234. return result;
  235. }
  236. /// <summary>
  237. /// 检验FlowTest停止状态
  238. /// </summary>
  239. /// <returns></returns>
  240. private bool CheckFlowTestStopStatus()
  241. {
  242. if (_loaderCommonDevice.Status == RState.Failed || _loaderCommonDevice.Status == RState.Timeout)
  243. {
  244. NotifyError(eEvent.ERR_LOADER, "Flow Test failed",1);
  245. return true;
  246. }
  247. return false;
  248. }
  249. /// <summary>
  250. /// 检验FlowTest完成状态
  251. /// </summary>
  252. /// <returns></returns>
  253. private bool CheckFlowTestEndStatus()
  254. {
  255. bool result = _loaderCommonDevice.Status == RState.End;
  256. if (result)
  257. {
  258. _flowDatas = _loaderCommonDevice.FlowLotTrackDatas;
  259. }
  260. return result;
  261. }
  262. /// <summary>
  263. /// Rotation 运动至TRNPA
  264. /// </summary>
  265. /// <returns></returns>
  266. private bool RotationGotoTransporterA()
  267. {
  268. bool result = _rotationAxis.PositionStation(_completeSide, false);
  269. if (!result)
  270. {
  271. NotifyError(eEvent.ERR_LOADER, $"rotation start goto {_completeSide} failed", 2);
  272. }
  273. return result;
  274. }
  275. /// <summary>
  276. /// Wafer Holder Clamp Off
  277. /// </summary>
  278. /// <returns></returns>
  279. public bool WaferHolderClampOffAction()
  280. {
  281. bool result = _loaderCommonDevice.WaferHolderClampOffAction();
  282. if (!result)
  283. {
  284. NotifyError(eEvent.ERR_LOADER, "Wafer Shuttle Clamp Off failed", 2);
  285. }
  286. return result;
  287. }
  288. /// <summary>
  289. /// 启动
  290. /// </summary>
  291. /// <param name="objs"></param>
  292. /// <returns></returns>
  293. public RState Start(params object[] objs)
  294. {
  295. _side = objs[0].ToString();
  296. _loadComplete=(bool)objs[1];
  297. if (objs.Length > 2)
  298. {
  299. _completeSide= objs[2].ToString();
  300. }
  301. if (objs.Length > 3)
  302. {
  303. _waferGroup= objs[3].ToString();
  304. }
  305. LoaderEntity loaderEntity = Singleton<RouteManager>.Instance.GetModule<LoaderEntity>(ModuleName.Loader1.ToString());
  306. if (_side == SIDE_A)
  307. {
  308. _waferSize = loaderEntity.SideAWaferSize;
  309. }
  310. else
  311. {
  312. _waferSize = loaderEntity.SideBWaferSize;
  313. }
  314. InitializeParameters();
  315. _loaderCommon = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");
  316. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.{_side}");
  317. //清除lotTrack数据
  318. _datas.Clear();
  319. _flowDatas.Clear();
  320. _loadTimeList.Clear();
  321. _loadTimeList.Add(DateTime.Now);
  322. return Runner.Start(Module, "Start LoadAll");
  323. }
  324. /// <summary>
  325. /// 初始化参数
  326. /// </summary>
  327. private void InitializeParameters()
  328. {
  329. _isSideLoaded = false;
  330. _isSideStop = false;
  331. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  332. _sideLoadRoutine = new LoaderLoadRoutine(ModuleName.Loader1.ToString(), _side);
  333. _loaderCommonDevice = DEVICE.GetDevice<LoaderCommonDevice>($"{ModuleName.Loader1}.Common");
  334. }
  335. /// <summary>
  336. /// 重试
  337. /// </summary>
  338. /// <param name="step"></param>
  339. public RState Retry(int step)
  340. {
  341. InitializeParameters();
  342. List<Enum> preStepIds = new List<Enum>();
  343. _datas.Clear();
  344. if (step == 0 || step == -1)
  345. {
  346. string side = _side == SIDE_A ? "A" : "B";
  347. _isSideLoaded = CheckSideLoadCondition(side, step,false);
  348. return Runner.Retry(LoadStep.SideLoad, preStepIds, Module, "LoadAll Retry");
  349. }
  350. else if (step == 1)
  351. {
  352. AddPreSteps(LoadStep.LeakTest, preStepIds);
  353. return Runner.Retry(LoadStep.LeakTest, preStepIds, Module, $"LoadAll step {LoadStep.LeakTest} start Retry");
  354. }
  355. else
  356. {
  357. AddPreSteps(LoadStep.RotationGoToTRNPA, preStepIds);
  358. return Runner.Retry(LoadStep.RotationGoToTRNPA, preStepIds, Module, $"LoadAll step {LoadStep.RotationGoToTRNPA} start Retry");
  359. }
  360. }
  361. /// <summary>
  362. /// 忽略前
  363. /// </summary>
  364. /// <param name="step"></param>
  365. /// <param name="preStepIds"></param>
  366. private void AddPreSteps(LoadStep step, List<Enum> preStepIds)
  367. {
  368. for (int i = 0; i < (int)step; i++)
  369. {
  370. preStepIds.Add((LoadStep)i);
  371. }
  372. }
  373. /// <summary>
  374. /// 检验前面Unload完成状态
  375. /// </summary>
  376. /// <returns></returns>
  377. public bool CheckCompleteCondition(int index)
  378. {
  379. string side = _side == SIDE_A ? "A" : "B";
  380. if (!CheckSideLoadCondition(side, index,true))
  381. {
  382. return false;
  383. }
  384. JetAxisBase loaderRotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Rotation");
  385. double loaderRotationPosition = loaderRotationAxis.MotionData.MotorPosition;
  386. if (!loaderRotationAxis.CheckPositionIsInStation(loaderRotationPosition, "TRNPA"))
  387. {
  388. NotifyError(eEvent.ERR_LOADER, $"loader rotation {loaderRotationPosition} not in TRNPA", index);
  389. }
  390. return true;
  391. }
  392. /// <summary>
  393. /// 检验Side Unload情况
  394. /// </summary>
  395. /// <param name="side"></param>
  396. /// <param name="index"></param>
  397. /// <returns></returns>
  398. private bool CheckSideLoadCondition(string side, int index,bool showError)
  399. {
  400. JetAxisBase shuttleAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Shuttle{side}");
  401. double shuttlePosition = shuttleAxis.MotionData.MotorPosition;
  402. if (!shuttleAxis.CheckPositionInStationIgnoreWaferSize(shuttlePosition, "MID"))
  403. {
  404. if (showError)
  405. {
  406. NotifyError(eEvent.ERR_LOADER, $"shuttle{side} {shuttlePosition} is not in mid", index);
  407. }
  408. return false;
  409. }
  410. JetAxisBase tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Tilt{side}");
  411. double tiltPosition = tiltAxis.MotionData.MotorPosition;
  412. if (!tiltAxis.CheckPositionIsInStation(tiltPosition, "VERT"))
  413. {
  414. if (showError)
  415. {
  416. NotifyError(eEvent.ERR_LOADER, $"tilt{side} {tiltPosition} is not in VERT", index);
  417. }
  418. return false;
  419. }
  420. JetAxisBase crsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LS{side}");
  421. double crsPosition = crsAxis.MotionData.MotorPosition;
  422. if (!crsAxis.CheckPositionIsInStation(crsPosition, "Setup"))
  423. {
  424. if (showError)
  425. {
  426. NotifyError(eEvent.ERR_LOADER, $"LS{side} {crsPosition} is not in Setup", index);
  427. }
  428. return false;
  429. }
  430. return true;
  431. }
  432. /// <summary>
  433. /// 记录Lottrack
  434. /// </summary>
  435. private void LottrackRecord()
  436. {
  437. //记录Lottrack
  438. if (DateTime.Now.Subtract(_lotTackTime).TotalMilliseconds >= LOTTRACK_TIME)
  439. {
  440. AddLotTrackData();
  441. _lotTackTime = DateTime.Now;
  442. }
  443. }
  444. /// <summary>
  445. /// 获取Lot Track数据
  446. /// </summary>
  447. /// <returns></returns>
  448. private void AddLotTrackData()
  449. {
  450. LoadStep step = (LoadStep)Runner.CurrentStep;
  451. if (step <= LoadStep.SideAllLoadWait)
  452. {
  453. LoaderLotTrackData data = new LoaderLotTrackData();
  454. data.TimeStamp = DateTime.Now;
  455. if (_side == SIDE_A)
  456. {
  457. data.LoaderABernoulliBladderEnable = _loaderSide.SideData.BernoulliBladder;
  458. data.LoaderABernoulliBladderPressure = _loaderSide.SideData.BernoulliBladderPressure;
  459. data.LoaderABernoulliN2Pressure = _loaderSide.SideData.BernoulliPressure;
  460. data.LoaderACRSVacuum = _loaderSide.SideData.CRSVacuum;
  461. data.LoaderACRSVacuumAnlg = _loaderSide.SideData.CRSVacuumValue;
  462. data.LoaderAWHPressure = _loaderSide.SideData.WHBladderPressure;
  463. }
  464. else
  465. {
  466. data.LoaderBBernoulliBladderEnable = _loaderSide.SideData.BernoulliBladder;
  467. data.LoaderBBernoulliBladderPressure = _loaderSide.SideData.BernoulliBladderPressure;
  468. data.LoaderBBernoulliN2Pressure = _loaderSide.SideData.BernoulliPressure;
  469. data.LoaderBCRSVacuum = _loaderSide.SideData.CRSVacuum;
  470. data.LoaderBCRSVacuumAnlg = _loaderSide.SideData.CRSVacuumValue;
  471. data.LoaderBWHPressure = _loaderSide.SideData.WHBladderPressure;
  472. }
  473. data.LoaderWHClamped = _loaderCommon.CommonData.WaferHolderClamp;
  474. _datas.Add(data);
  475. }
  476. }
  477. }
  478. }