LoaderUnloadSideRoutine.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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.Utilities;
  12. using MECF.Framework.Common.CommonData.Loader;
  13. using MECF.Framework.Common.CommonData;
  14. using Aitex.Core.RT.DataCenter;
  15. namespace CyberX8_RT.Modules.Loader
  16. {
  17. public class LoaderUnloadSideRoutine : RoutineBase, IRoutine
  18. {
  19. private enum UnloadStep
  20. {
  21. RotationGoToLOADA,
  22. RotationGoToLOADAWait,
  23. SideUnload,
  24. UnloadAllWait,
  25. End
  26. }
  27. #region 常量
  28. private const string SIDE_A = "SideA";
  29. private const string SIDE_B = "SideB";
  30. private const int LOTTRACK_TIME = 1000;
  31. #endregion
  32. #region 内部变量
  33. private JetAxisBase _rotationAxis;
  34. private string _side;
  35. private LoaderUnloadRoutine _sideUnloadRoutine;
  36. private bool _isSideUnloaded = false;
  37. private bool _isSideStop = false;
  38. /// <summary>
  39. /// lotTrack time
  40. /// </summary>
  41. private DateTime _lotTackTime = DateTime.Now;
  42. /// <summary>
  43. /// Loader Common
  44. /// </summary>
  45. private LoaderCommonDevice _loaderCommon;
  46. /// <summary>
  47. /// LoaderSide
  48. /// </summary>
  49. private LoaderSideDevice _loaderSide;
  50. /// <summary>
  51. /// Loader LotTrackData
  52. /// </summary>
  53. private List<LoaderLotTrackData> _datas = new List<LoaderLotTrackData>();
  54. #endregion
  55. #region 属性
  56. /// <summary>
  57. /// UnLoad LotTrackData
  58. /// </summary>
  59. public List<LoaderLotTrackData> UnloadLotTrackDatas { get { return _datas; } }
  60. #endregion
  61. /// <summary>
  62. /// 构造函数
  63. /// </summary>
  64. /// <param name="module"></param>
  65. public LoaderUnloadSideRoutine(string module) : base(module)
  66. {
  67. }
  68. /// <summary>
  69. /// 中止
  70. /// </summary>
  71. public void Abort()
  72. {
  73. }
  74. /// <summary>
  75. /// 监控
  76. /// </summary>
  77. /// <returns></returns>
  78. public RState Monitor()
  79. {
  80. LottrackRecord();
  81. Runner.Run(UnloadStep.RotationGoToLOADA,RotationGotoLOADA,_delay_1ms)
  82. .WaitWithStopCondition(UnloadStep.RotationGoToLOADAWait,CheckRotationPositionStatus,CheckRotationPositionRunStop)
  83. .Run(UnloadStep.SideUnload, () => StartUnloadRoutine(_sideUnloadRoutine,_isSideUnloaded), _delay_1ms)
  84. .WaitWithStopCondition(UnloadStep.UnloadAllWait, CheckUnloadAllRoutineEndStatus,CheckUnloadAllRoutineStopStatus)
  85. .End(UnloadStep.End, NullFun, _delay_1ms);
  86. return Runner.Status;
  87. }
  88. /// <summary>
  89. /// Rotation Goto LOADA
  90. /// </summary>
  91. /// <returns></returns>
  92. private bool RotationGotoLOADA()
  93. {
  94. bool result = _rotationAxis.PositionStation("LOADA", false);
  95. if (!result)
  96. {
  97. NotifyError(eEvent.ERR_LOADER, "rotation start goto LOADA failed", 0);
  98. }
  99. return result;
  100. }
  101. /// <summary>
  102. /// 检验Rotation移动状态
  103. /// </summary>
  104. /// <returns></returns>
  105. private bool CheckRotationPositionStatus()
  106. {
  107. return _rotationAxis.Status == RState.End;
  108. }
  109. /// <summary>
  110. /// 检验Rotation是否还在运动
  111. /// </summary>
  112. /// <returns></returns>
  113. private bool CheckRotationPositionRunStop()
  114. {
  115. bool result = _rotationAxis.Status == RState.Failed || _rotationAxis.Status == RState.Timeout ;
  116. if (result)
  117. {
  118. NotifyError(eEvent.ERR_LOADER, "rotation goto position failed",0);
  119. }
  120. return result;
  121. }
  122. /// <summary>
  123. /// 启动Unload routine
  124. /// </summary>
  125. /// <param name="unloadRoutine"></param>
  126. /// <returns></returns>
  127. private bool StartUnloadRoutine(LoaderUnloadRoutine unloadRoutine,bool isSideUnloaded)
  128. {
  129. if (isSideUnloaded)
  130. {
  131. return true;
  132. }
  133. bool result= unloadRoutine.Start()==RState.Running;
  134. if(!result)
  135. {
  136. NotifyError(eEvent.ERR_LOADER, unloadRoutine.ErrorMsg, 0);
  137. }
  138. return result;
  139. }
  140. /// <summary>
  141. /// 检验UnloadAll完成状态
  142. /// </summary>
  143. /// <returns></returns>
  144. private bool CheckUnloadAllRoutineEndStatus()
  145. {
  146. bool sideResult = true;
  147. if (!_isSideUnloaded)
  148. {
  149. sideResult = CheckUnloadRoutineEndStatus(_sideUnloadRoutine);
  150. }
  151. return sideResult;
  152. }
  153. /// <summary>
  154. /// 检查UnloadAll停止状态
  155. /// </summary>
  156. /// <returns></returns>
  157. private bool CheckUnloadAllRoutineStopStatus()
  158. {
  159. bool sideComplete = false;
  160. if (!_isSideUnloaded&&!_isSideStop)
  161. {
  162. RState ret = _sideUnloadRoutine.Monitor();
  163. _isSideStop = ret == RState.Failed || ret == RState.Timeout;
  164. sideComplete = (ret != RState.Running);
  165. if (_isSideStop)
  166. {
  167. NotifyError(eEvent.ERR_LOADER, $"unload A failed\r\n{_sideUnloadRoutine.ErrorMsg}", 1);
  168. }
  169. }
  170. return _isSideStop;
  171. }
  172. /// <summary>
  173. /// 检验routine完成状态
  174. /// </summary>
  175. /// <param name="unloadRoutine"></param>
  176. /// <returns></returns>
  177. private bool CheckUnloadRoutineEndStatus(LoaderUnloadRoutine unloadRoutine)
  178. {
  179. return unloadRoutine.Monitor() == RState.End;
  180. }
  181. /// <summary>
  182. /// 检验Routine结束状态
  183. /// </summary>
  184. /// <param name="unloadRoutine"></param>
  185. /// <returns></returns>
  186. private bool CheckUnloadRoutineStopStatus(LoaderUnloadRoutine unloadRoutine,string side)
  187. {
  188. RState state=unloadRoutine.Monitor();
  189. if (state == RState.Failed || state == RState.Timeout)
  190. {
  191. NotifyError(eEvent.ERR_LOADER, $"{side} Unload failed", 0);
  192. return true;
  193. }
  194. return false;
  195. }
  196. /// <summary>
  197. /// 启动
  198. /// </summary>
  199. /// <param name="objs"></param>
  200. /// <returns></returns>
  201. public RState Start(params object[] objs)
  202. {
  203. _side = objs[0].ToString();
  204. InitializeParameters();
  205. _loaderCommon = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");
  206. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.{_side}");
  207. return Runner.Start(Module, "Start UnloadAll");
  208. }
  209. /// <summary>
  210. /// 初始化参数
  211. /// </summary>
  212. private void InitializeParameters()
  213. {
  214. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  215. _sideUnloadRoutine = new LoaderUnloadRoutine(ModuleName.Loader1.ToString(), _side);
  216. _isSideUnloaded = false;
  217. _isSideStop = false;
  218. }
  219. /// <summary>
  220. /// 重试
  221. /// </summary>
  222. /// <param name="step"></param>
  223. public RState Retry(int step)
  224. {
  225. InitializeParameters();
  226. List<Enum> preStepIds = new List<Enum>();
  227. return Runner.Retry(UnloadStep.RotationGoToLOADA,preStepIds,Module,"UnloadAll Retry");
  228. }
  229. /// <summary>
  230. /// 检验前面Unload完成状态
  231. /// </summary>
  232. /// <returns></returns>
  233. public bool CheckCompleteCondition(int index)
  234. {
  235. string side = _side == SIDE_A ? "A" : "B";
  236. if (!CheckSideUnloadCondition(side, index,true))
  237. {
  238. return false;
  239. }
  240. return true;
  241. }
  242. /// <summary>
  243. /// 检验Side Unload情况
  244. /// </summary>
  245. /// <param name="side"></param>
  246. /// <param name="index"></param>
  247. /// <returns></returns>
  248. private bool CheckSideUnloadCondition(string side, int index,bool showError)
  249. {
  250. JetAxisBase shuttleAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Shuttle{side}");
  251. double shuttlePosition = shuttleAxis.MotionData.MotorPosition;
  252. if (!shuttleAxis.CheckPositionInStationIgnoreWaferSize(shuttlePosition, "OUT"))
  253. {
  254. if (showError)
  255. {
  256. NotifyError(eEvent.ERR_LOADER, $"shuttle{side} {shuttlePosition} is not in Out", index);
  257. }
  258. return false;
  259. }
  260. JetAxisBase tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Tilt{side}");
  261. double tiltPosition = tiltAxis.MotionData.MotorPosition;
  262. if (!tiltAxis.CheckPositionInStationIgnoreWaferSize(tiltPosition, "HORI"))
  263. {
  264. if (showError)
  265. {
  266. NotifyError(eEvent.ERR_LOADER, $"tilt{side} {tiltPosition} is not in HORI", index);
  267. return false;
  268. }
  269. }
  270. JetAxisBase crsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LS{side}");
  271. double crsPosition = crsAxis.MotionData.MotorPosition;
  272. if (!crsAxis.CheckPositionInStationIgnoreWaferSize(crsPosition, "Unlock"))
  273. {
  274. if (showError)
  275. {
  276. NotifyError(eEvent.ERR_LOADER, $"LS{side} {crsPosition} is not in Unlock", index);
  277. }
  278. return false;
  279. }
  280. return true;
  281. }
  282. /// <summary>
  283. /// 记录Lottrack
  284. /// </summary>
  285. private void LottrackRecord()
  286. {
  287. //记录Lottrack
  288. if (DateTime.Now.Subtract(_lotTackTime).TotalMilliseconds >= LOTTRACK_TIME)
  289. {
  290. AddLotTrackData();
  291. _lotTackTime = DateTime.Now;
  292. }
  293. }
  294. /// <summary>
  295. /// 获取Lot Track数据
  296. /// </summary>
  297. /// <returns></returns>
  298. private void AddLotTrackData()
  299. {
  300. LoaderLotTrackData data = new LoaderLotTrackData();
  301. data.TimeStamp = DateTime.Now;
  302. data.LoaderABernoulliBladderEnable = _loaderSide.SideData.BernoulliBladder;
  303. data.LoaderABernoulliExtended = _loaderSide.SideData.BernoulliExtended;
  304. data.LoaderABernoulliBladderPressure = _loaderSide.SideData.BernoulliBladderPressure;
  305. data.LoaderABernoulliN2Pressure = _loaderSide.SideData.BernoulliPressure;
  306. data.LoaderACRSVacuum = _loaderSide.SideData.CRSVacuum;
  307. data.LoaderACRSVacuumAnlg = _loaderSide.SideData.CRSVacuumValue;
  308. data.LoaderAWHPressure = _loaderSide.SideData.WHBladderPressure;
  309. data.LoaderATranslatePressure = _loaderSide.SideData.TransPressure;
  310. data.LoaderWHClamped = _loaderCommon.CommonData.WaferHolderClamp;
  311. _datas.Add(data);
  312. }
  313. }
  314. }