PufPlaceToLoaderRoutine.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.Routine;
  6. using Aitex.Core.Util;
  7. using MECF.Framework.Common.DBCore;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.Routine;
  10. using MECF.Framework.Common.SubstrateTrackings;
  11. using MECF.Framework.Common.Utilities;
  12. using MECF.Framework.Common.WaferHolder;
  13. using CyberX8_Core;
  14. using CyberX8_RT.Devices.AXIS;
  15. using CyberX8_RT.Devices.Loader;
  16. using CyberX8_RT.Devices.PUF;
  17. using CyberX8_RT.Modules.Loader;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Threading.Tasks;
  23. namespace CyberX8_RT.Modules.PUF
  24. {
  25. public class PufPlaceToLoaderRoutine : RoutineBase, IRoutine
  26. {
  27. private enum PlaceStep
  28. {
  29. CheckStatus,
  30. OnlyPlaceToLoader,
  31. OnlyPlaceToLoaderWait,
  32. SwitchWaferHolder,
  33. LastVerticalFlip,
  34. LastVerticalFlipWait,
  35. LastVerticalPark,
  36. LastVerticalParkWait,
  37. LastRotationPark,
  38. LastRotationParkWait,
  39. End
  40. }
  41. #region 常量
  42. private const string CURRENT_STATION_LIST = "CurrentStationList";
  43. private const string SIDE_A = "SideA";
  44. #endregion
  45. #region 内部变量
  46. private string _side;
  47. private LoaderEntity _loaderEntity;
  48. private JetAxisBase _flipAxis;
  49. private JetAxisBase _rotationAxis;
  50. private JetAxisBase _verticalAxis;
  51. private PufVacuum _vacuum;
  52. private LoaderSideDevice _loaderSide;
  53. private JetAxisBase _loaderCrsAxis;
  54. private JetAxisBase _gantryAxis;
  55. private PufOnlyPlaceToLoaderRoutine _onlyPlaceToLoaderRoutine;
  56. #endregion
  57. /// <summary>
  58. /// 构造函数
  59. /// </summary>
  60. /// <param name="module"></param>
  61. public PufPlaceToLoaderRoutine(string module) : base(module)
  62. {
  63. }
  64. /// <summary>
  65. /// 中止
  66. /// </summary>
  67. public void Abort()
  68. {
  69. _flipAxis.StopPositionOperation();
  70. _rotationAxis.StopPositionOperation();
  71. _verticalAxis.StopPositionOperation();
  72. Runner.Stop("Manual Abort");
  73. }
  74. /// <summary>
  75. /// 监控
  76. /// </summary>
  77. /// <returns></returns>
  78. public RState Monitor()
  79. {
  80. Runner.Run(PlaceStep.CheckStatus,CheckPreCondition,_delay_1ms)
  81. .Run(PlaceStep.OnlyPlaceToLoader,StartOnlyPlaceToLoader,_delay_1ms)
  82. .WaitWithStopCondition(PlaceStep.OnlyPlaceToLoaderWait,CheckPlaceEndStatus,CheckPlaceStopStatus)
  83. .Run(PlaceStep.SwitchWaferHolder,SwitchWaferHolderSideWafer,_delay_1ms)
  84. .Run(PlaceStep.LastVerticalFlip, () => _verticalAxis.PositionStation("Flip"), _delay_1ms)
  85. .WaitWithStopCondition(PlaceStep.LastVerticalFlipWait, CheckVerticalPositionStatus, CheckVerticalPositionRunStop)
  86. .Run(PlaceStep.LastVerticalPark, () => _verticalAxis.PositionStation("Park"), _delay_1ms)
  87. .WaitWithStopCondition(PlaceStep.LastVerticalParkWait, CheckVerticalPositionStatus, CheckVerticalPositionRunStop)
  88. .Run(PlaceStep.LastRotationPark, () => _rotationAxis.PositionStation("Park"), _delay_1ms)
  89. .WaitWithStopCondition(PlaceStep.LastRotationParkWait, CheckRotationPositionStatus, CheckRotationPositionRunStop)
  90. .End(PlaceStep.End, NullFun, _delay_1ms);
  91. return Runner.Status;
  92. }
  93. /// <summary>
  94. /// 执行放片至Loader
  95. /// </summary>
  96. /// <returns></returns>
  97. private bool StartOnlyPlaceToLoader()
  98. {
  99. return _onlyPlaceToLoaderRoutine.Start(_side) == RState.Running;
  100. }
  101. /// <summary>
  102. /// 检验放片状态
  103. /// </summary>
  104. /// <returns></returns>
  105. private bool CheckPlaceEndStatus()
  106. {
  107. return _onlyPlaceToLoaderRoutine.Monitor() ==RState.End;
  108. }
  109. /// <summary>
  110. /// 检验放片停止状态
  111. /// </summary>
  112. /// <returns></returns>
  113. private bool CheckPlaceStopStatus()
  114. {
  115. RState state = _onlyPlaceToLoaderRoutine.Monitor();
  116. if(state==RState.Failed||state==RState.Timeout)
  117. {
  118. return true;
  119. }
  120. return false;
  121. }
  122. /// <summary>
  123. /// WaferHolder交换片
  124. /// </summary>
  125. /// <returns></returns>
  126. private bool SwitchWaferHolderSideWafer()
  127. {
  128. WaferHolderInfo waferHolderInfo = _loaderEntity.WaferHolderInfo;
  129. if (waferHolderInfo != null)
  130. {
  131. if (Module == ModuleName.PUF1.ToString())
  132. {
  133. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(Module), 1, ModuleName.Loader1, 0);
  134. WaferInfo loaderWaferInfo = WaferManager.Instance.GetWafer(ModuleName.Loader1, 0);
  135. waferHolderInfo.WaferAId = loaderWaferInfo.WaferID;
  136. waferHolderInfo.WaferAType = (int)loaderWaferInfo.WaferType;
  137. WaferHolderDataRecorder.UpdateWaferHolderData(waferHolderInfo.Id, waferHolderInfo);
  138. MaterialTrackerManager.Instance.UpdateModuleMaterial(ModuleName.Loader1.ToString());
  139. }
  140. else
  141. {
  142. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(Module), 1, ModuleName.Loader1, 1);
  143. WaferInfo loaderWaferInfo = WaferManager.Instance.GetWafer(ModuleName.Loader1, 1);
  144. waferHolderInfo.WaferBId = loaderWaferInfo.WaferID;
  145. waferHolderInfo.WaferBType = (int)loaderWaferInfo.WaferType;
  146. WaferHolderDataRecorder.UpdateWaferHolderData(waferHolderInfo.Id, waferHolderInfo);
  147. MaterialTrackerManager.Instance.UpdateModuleMaterial(ModuleName.Loader1.ToString());
  148. }
  149. }
  150. return true;
  151. }
  152. /// <summary>
  153. /// 检验Rotation移动状态
  154. /// </summary>
  155. /// <returns></returns>
  156. private bool CheckRotationPositionStatus()
  157. {
  158. return _rotationAxis.Status == RState.End;
  159. }
  160. /// <summary>
  161. /// 检验Rotation是否还在运动
  162. /// </summary>
  163. /// <returns></returns>
  164. private bool CheckRotationPositionRunStop()
  165. {
  166. return _rotationAxis.Status == RState.Failed;
  167. }
  168. /// <summary>
  169. /// 检验Vertical移动状态
  170. /// </summary>
  171. /// <returns></returns>
  172. private bool CheckVerticalPositionStatus()
  173. {
  174. return _verticalAxis.Status == RState.End;
  175. }
  176. /// <summary>
  177. /// 检验Vertical是否还在运动
  178. /// </summary>
  179. /// <returns></returns>
  180. private bool CheckVerticalPositionRunStop()
  181. {
  182. return _verticalAxis.Status == RState.Failed;
  183. }
  184. /// <summary>
  185. /// 启动
  186. /// </summary>
  187. /// <param name="objs"></param>
  188. /// <returns></returns>
  189. public RState Start(params object[] objs)
  190. {
  191. _side = objs[0].ToString();
  192. _loaderEntity = Singleton<RouteManager>.Instance.GetModule<LoaderEntity>(ModuleName.Loader1.ToString());
  193. _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Flip");
  194. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  195. _verticalAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Vertical");
  196. _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
  197. _gantryAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Transporter2}.Gantry");
  198. GetLoaderSide();
  199. GetCrsAxis();
  200. _onlyPlaceToLoaderRoutine = new PufOnlyPlaceToLoaderRoutine(Module.ToString());
  201. return Runner.Start(Module, "Place To Loader");
  202. }
  203. /// <summary>
  204. /// 检验是否存在Wafer
  205. /// </summary>
  206. /// <returns></returns>
  207. private bool CheckWaferPresent()
  208. {
  209. if (_side == "SideA")
  210. {
  211. if (!_vacuum.ChuckAWaferPresent)
  212. {
  213. NotifyError(eEvent.ERR_PUF, $"{_side} has no Wafer", -1);
  214. return false;
  215. }
  216. }
  217. else
  218. {
  219. if (!_vacuum.ChuckBWaferPresent)
  220. {
  221. NotifyError(eEvent.ERR_PUF, $"{_side} has no Wafer",-1);
  222. return false;
  223. }
  224. }
  225. return true;
  226. }
  227. /// <summary>
  228. /// 检验前置条件
  229. /// </summary>
  230. /// <returns></returns>
  231. private bool CheckPreCondition()
  232. {
  233. if(!CheckWaferPresent())
  234. {
  235. return false;
  236. }
  237. bool isLoaderInstall = ModuleHelper.IsInstalled(ModuleName.Loader1);
  238. if (isLoaderInstall)
  239. {
  240. if(_loaderSide.SideData.WaferPresent)
  241. {
  242. NotifyError(eEvent.ERR_PUF, $"{_loaderSide.Module}.{_loaderSide.Name} has Wafer",-1);
  243. return false;
  244. }
  245. JetAxisBase loaderRotationaxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Rotation");
  246. if (loaderRotationaxis != null)
  247. {
  248. double loaderRotationPosition = loaderRotationaxis.MotionData.MotorPosition;
  249. if (!loaderRotationaxis.CheckPositionIsInStation(loaderRotationPosition, "LOADA"))
  250. {
  251. NotifyError(eEvent.ERR_PUF, $"Loader Rotation {loaderRotationPosition} is not in LOADA", -1);
  252. return false;
  253. }
  254. }
  255. if (Module == ModuleName.PUF1.ToString())
  256. {
  257. //Loader1.SwingA 在Open
  258. JetAxisBase loaderShuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.ShuttleA");
  259. if (loaderShuttleAAxis != null)
  260. {
  261. double loaderShuttleAPosition = loaderShuttleAAxis.MotionData.MotorPosition;
  262. if (!loaderShuttleAAxis.CheckPositionIsInStation(loaderShuttleAPosition, "OPEN"))
  263. {
  264. NotifyError(eEvent.ERR_PUF, $"Loader ShuttleA {loaderShuttleAPosition} is not in OPEN", -1);
  265. return false;
  266. }
  267. }
  268. //Loader1.TiltA 在HORI
  269. JetAxisBase loaderTiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.TiltA");
  270. if (loaderTiltAAxis != null)
  271. {
  272. double loaderTiltAPosition = loaderTiltAAxis.MotionData.MotorPosition;
  273. if (!loaderTiltAAxis.CheckPositionIsInStation(loaderTiltAPosition, "HORI"))
  274. {
  275. NotifyError(eEvent.ERR_PUF, $"Loader TiltA {loaderTiltAPosition} is not in HORI", -1);
  276. return false;
  277. }
  278. }
  279. }
  280. if (Module == ModuleName.PUF2.ToString())
  281. {
  282. //Loader1.SwingB 在Open
  283. JetAxisBase loaderShuttleBAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.ShuttleB");
  284. double loaderShuttleBPosition = loaderShuttleBAxis.MotionData.MotorPosition;
  285. if (!loaderShuttleBAxis.CheckPositionIsInStation(loaderShuttleBPosition, "OPEN"))
  286. {
  287. LOG.WriteLog(eEvent.ERR_PUF, Module, $"Loader ShuttleB {loaderShuttleBPosition} is not in OPEN");
  288. return false;
  289. }
  290. //Loader1.TiltB 在HORI
  291. JetAxisBase loaderTiltBAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.TiltB");
  292. double loaderTiltBPosition = loaderTiltBAxis.MotionData.MotorPosition;
  293. if (!loaderTiltBAxis.CheckPositionIsInStation(loaderTiltBPosition, "HORI"))
  294. {
  295. LOG.WriteLog(eEvent.ERR_PUF, Module, $"Loader TiltB {loaderTiltBPosition} is not in HORI");
  296. return false;
  297. }
  298. }
  299. //Loader Handle Wafer状态确认
  300. // Lip Seal Vacuum "ON"
  301. if (!_loaderSide.SideData.CRSVacuum)
  302. {
  303. NotifyError(eEvent.ERR_PUF, "Loader1 LS Vacuum is off", -1);
  304. return false;
  305. }
  306. //Bernoulli Bladder "ON",Retracted Green Light
  307. if (!_loaderSide.SideData.BernoulliBladder)
  308. {
  309. NotifyError(eEvent.ERR_PUF, "Loader1 Bernoulli Bladder is off",-1);
  310. return false;
  311. }
  312. if (_loaderSide.SideData.BernoulliExtended)
  313. {
  314. NotifyError(eEvent.ERR_PUF, "Loader1 Bernoulli Retracted is off", -1);
  315. return false;
  316. }
  317. //其他SideA/B均为OFF
  318. if (_loaderSide.SideData.BernoulliN2)
  319. {
  320. NotifyError(eEvent.ERR_PUF, "Loader1 Bernoulli N2 is on",-1);
  321. return false;
  322. }
  323. }
  324. //Loader Transporter在Loader右侧
  325. bool loaderTransporterInstalled = ModuleHelper.IsInstalled(ModuleName.Transporter2);
  326. if (loaderTransporterInstalled && !_gantryAxis.JudgeCompareTargetStation("Loader", "Right"))
  327. {
  328. NotifyError(eEvent.ERR_PUF, "Loader Transporter is not in Loader right position", -1);
  329. return false;
  330. }
  331. double rotationPosition = _rotationAxis.MotionData.MotorPosition;
  332. if (_rotationAxis.CheckPositionIsEmpty(rotationPosition))
  333. {
  334. LOG.WriteLog(eEvent.ERR_PUF, Module, $"rotation axis {rotationPosition} is not at Station");
  335. return false;
  336. }
  337. double flipPosition = _flipAxis.MotionData.MotorPosition;
  338. if (_flipAxis.CheckPositionIsEmpty(flipPosition))
  339. {
  340. LOG.WriteLog(eEvent.ERR_PUF, Module, $"flip axis {flipPosition} is not at Station");
  341. return false;
  342. }
  343. return true;
  344. }
  345. /// <summary>
  346. /// 获取LoaderSide
  347. /// </summary>
  348. private void GetLoaderSide()
  349. {
  350. if (Module == ModuleName.PUF1.ToString())
  351. {
  352. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{ModuleName.Loader1}.SideA");
  353. }
  354. else
  355. {
  356. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{ModuleName.Loader1}.SideB");
  357. }
  358. }
  359. /// <summary>
  360. /// 获取lipseal Axis
  361. /// </summary>
  362. private void GetCrsAxis()
  363. {
  364. if(Module==ModuleName.PUF1.ToString())
  365. {
  366. _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSA");
  367. }
  368. else
  369. {
  370. _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSB");
  371. }
  372. }
  373. }
  374. }