PufPlaceToLoaderRoutine.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. LastRotationHomeStation,
  34. LastRotationHomeStationWait,
  35. End
  36. }
  37. #region 常量
  38. private const string CURRENT_STATION_LIST = "CurrentStationList";
  39. private const string SIDE_A = "SideA";
  40. #endregion
  41. #region 内部变量
  42. private string _side;
  43. private LoaderEntity _loaderEntity;
  44. private JetAxisBase _flipAxis;
  45. private JetAxisBase _rotationAxis;
  46. private PufVacuum _vacuum;
  47. private LoaderSideDevice _loaderSide;
  48. private JetAxisBase _loaderCrsAxis;
  49. private JetAxisBase _gantryAxis;
  50. private PufOnlyPlaceToLoaderRoutine _onlyPlaceToLoaderRoutine;
  51. #endregion
  52. /// <summary>
  53. /// 构造函数
  54. /// </summary>
  55. /// <param name="module"></param>
  56. public PufPlaceToLoaderRoutine(string module) : base(module)
  57. {
  58. }
  59. /// <summary>
  60. /// 中止
  61. /// </summary>
  62. public void Abort()
  63. {
  64. _flipAxis.StopPositionOperation();
  65. _rotationAxis.StopPositionOperation();
  66. Runner.Stop("Manual Abort");
  67. }
  68. /// <summary>
  69. /// 监控
  70. /// </summary>
  71. /// <returns></returns>
  72. public RState Monitor()
  73. {
  74. Runner.Run(PlaceStep.CheckStatus,CheckPreCondition,_delay_1ms)
  75. .Run(PlaceStep.OnlyPlaceToLoader,StartOnlyPlaceToLoader,_delay_1ms)
  76. .WaitWithStopCondition(PlaceStep.OnlyPlaceToLoaderWait,CheckPlaceEndStatus,CheckPlaceStopStatus)
  77. .Run(PlaceStep.SwitchWaferHolder,SwitchWaferHolderSideWafer,_delay_1ms)
  78. .Run(PlaceStep.LastRotationHomeStation, () => _rotationAxis.PositionStation("Home"), _delay_1ms)
  79. .WaitWithStopCondition(PlaceStep.LastRotationHomeStationWait, CheckRotationPositionStatus, CheckRotationPositionRunStop)
  80. .End(PlaceStep.End, NullFun, _delay_1ms);
  81. return Runner.Status;
  82. }
  83. /// <summary>
  84. /// 执行放片至Loader
  85. /// </summary>
  86. /// <returns></returns>
  87. private bool StartOnlyPlaceToLoader()
  88. {
  89. return _onlyPlaceToLoaderRoutine.Start(_side) == RState.Running;
  90. }
  91. /// <summary>
  92. /// 检验放片状态
  93. /// </summary>
  94. /// <returns></returns>
  95. private bool CheckPlaceEndStatus()
  96. {
  97. return _onlyPlaceToLoaderRoutine.Monitor() ==RState.End;
  98. }
  99. /// <summary>
  100. /// 检验放片停止状态
  101. /// </summary>
  102. /// <returns></returns>
  103. private bool CheckPlaceStopStatus()
  104. {
  105. RState state = _onlyPlaceToLoaderRoutine.Monitor();
  106. if(state==RState.Failed||state==RState.Timeout)
  107. {
  108. return true;
  109. }
  110. return false;
  111. }
  112. /// <summary>
  113. /// WaferHolder交换片
  114. /// </summary>
  115. /// <returns></returns>
  116. private bool SwitchWaferHolderSideWafer()
  117. {
  118. WaferHolderInfo waferHolderInfo = _loaderEntity.WaferHolderInfo;
  119. if (waferHolderInfo != null)
  120. {
  121. if (_side==SIDE_A)
  122. {
  123. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(Module), 1, ModuleName.Loader1, 0);
  124. WaferInfo loaderWaferInfo = WaferManager.Instance.GetWafer(ModuleName.Loader1, 0);
  125. waferHolderInfo.WaferAId = loaderWaferInfo.WaferID;
  126. waferHolderInfo.WaferAType = (int)loaderWaferInfo.WaferType;
  127. WaferHolderDataRecorder.UpdateWaferHolderData(waferHolderInfo.Id, waferHolderInfo);
  128. MaterialTrackerManager.Instance.UpdateModuleMaterial(ModuleName.Loader1.ToString());
  129. }
  130. else
  131. {
  132. WaferManager.Instance.WaferMoved(ModuleHelper.Converter(Module), 1, ModuleName.Loader1, 1);
  133. WaferInfo loaderWaferInfo = WaferManager.Instance.GetWafer(ModuleName.Loader1, 1);
  134. waferHolderInfo.WaferBId = loaderWaferInfo.WaferID;
  135. waferHolderInfo.WaferBType = (int)loaderWaferInfo.WaferType;
  136. WaferHolderDataRecorder.UpdateWaferHolderData(waferHolderInfo.Id, waferHolderInfo);
  137. MaterialTrackerManager.Instance.UpdateModuleMaterial(ModuleName.Loader1.ToString());
  138. }
  139. }
  140. return true;
  141. }
  142. /// <summary>
  143. /// 检验Rotation移动状态
  144. /// </summary>
  145. /// <returns></returns>
  146. private bool CheckRotationPositionStatus()
  147. {
  148. return _rotationAxis.Status == RState.End;
  149. }
  150. /// <summary>
  151. /// 检验Rotation是否还在运动
  152. /// </summary>
  153. /// <returns></returns>
  154. private bool CheckRotationPositionRunStop()
  155. {
  156. return _rotationAxis.Status == RState.Failed;
  157. }
  158. /// <summary>
  159. /// 启动
  160. /// </summary>
  161. /// <param name="objs"></param>
  162. /// <returns></returns>
  163. public RState Start(params object[] objs)
  164. {
  165. _side = objs[0].ToString();
  166. _loaderEntity = Singleton<RouteManager>.Instance.GetModule<LoaderEntity>(ModuleName.Loader1.ToString());
  167. _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Flip");
  168. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  169. _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
  170. _gantryAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Transporter2}.Gantry");
  171. GetLoaderSide();
  172. GetCrsAxis();
  173. _onlyPlaceToLoaderRoutine = new PufOnlyPlaceToLoaderRoutine(Module.ToString());
  174. return Runner.Start(Module, "Place To Loader");
  175. }
  176. /// <summary>
  177. /// 检验是否存在Wafer
  178. /// </summary>
  179. /// <returns></returns>
  180. private bool CheckWaferPresent()
  181. {
  182. if (_side == "SideA")
  183. {
  184. if (!_vacuum.ChuckAWaferPresent)
  185. {
  186. NotifyError(eEvent.ERR_PUF, $"{_side} has no Wafer", -1);
  187. return false;
  188. }
  189. }
  190. else
  191. {
  192. if (!_vacuum.ChuckBWaferPresent)
  193. {
  194. NotifyError(eEvent.ERR_PUF, $"{_side} has no Wafer",-1);
  195. return false;
  196. }
  197. }
  198. return true;
  199. }
  200. /// <summary>
  201. /// 检验前置条件
  202. /// </summary>
  203. /// <returns></returns>
  204. private bool CheckPreCondition()
  205. {
  206. if(!CheckWaferPresent())
  207. {
  208. return false;
  209. }
  210. bool isLoaderInstall = ModuleHelper.IsInstalled(ModuleName.Loader1);
  211. if (isLoaderInstall)
  212. {
  213. if(_loaderSide.SideData.WaferPresent)
  214. {
  215. NotifyError(eEvent.ERR_PUF, $"{_loaderSide.Module}.{_loaderSide.Name} wafer present sensor is true",-1);
  216. return false;
  217. }
  218. JetAxisBase loaderRotationaxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Rotation");
  219. if (loaderRotationaxis != null)
  220. {
  221. double loaderRotationPosition = loaderRotationaxis.MotionData.MotorPosition;
  222. if (!loaderRotationaxis.CheckPositionIsInStation(loaderRotationPosition, "LOADA"))
  223. {
  224. NotifyError(eEvent.ERR_PUF, $"Loader Rotation {loaderRotationPosition} is not in LOADA", -1);
  225. return false;
  226. }
  227. }
  228. string side = _side == SIDE_A ? "A" : "B";
  229. //Loader1.SwingA 在Open
  230. JetAxisBase loaderShuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Shuttle{side}");
  231. if (loaderShuttleAAxis != null)
  232. {
  233. double loaderShuttleAPosition = loaderShuttleAAxis.MotionData.MotorPosition;
  234. if (!loaderShuttleAAxis.CheckPositionInStationIgnoreWaferSize(loaderShuttleAPosition, "OUT"))
  235. {
  236. NotifyError(eEvent.ERR_PUF, $"Loader Shuttle{side} {loaderShuttleAPosition} is not in OUT", -1);
  237. return false;
  238. }
  239. }
  240. //Loader1.TiltA 在HORI
  241. JetAxisBase loaderTiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Tilt{side}");
  242. if (loaderTiltAAxis != null)
  243. {
  244. double loaderTiltAPosition = loaderTiltAAxis.MotionData.MotorPosition;
  245. if (!loaderTiltAAxis.CheckPositionIsInStation(loaderTiltAPosition, "HORI"))
  246. {
  247. NotifyError(eEvent.ERR_PUF, $"Loader Tilt{side} {loaderTiltAPosition} is not in HORI", -1);
  248. return false;
  249. }
  250. }
  251. //Loader Handle Wafer状态确认
  252. // Lip Seal Vacuum "ON"
  253. if (!_loaderSide.SideData.CRSVacuum)
  254. {
  255. NotifyError(eEvent.ERR_PUF, "Loader1 LS Vacuum is off", -1);
  256. return false;
  257. }
  258. //Bernoulli Bladder "ON",Retracted Green Light
  259. if (!_loaderSide.SideData.BernoulliBladder)
  260. {
  261. NotifyError(eEvent.ERR_PUF, "Loader1 Bernoulli Bladder is off",-1);
  262. return false;
  263. }
  264. //其他SideA/B均为OFF
  265. if (_loaderSide.SideData.BernoulliN2)
  266. {
  267. NotifyError(eEvent.ERR_PUF, "Loader1 Bernoulli N2 is on",-1);
  268. return false;
  269. }
  270. }
  271. double rotationPosition = _rotationAxis.MotionData.MotorPosition;
  272. if (_rotationAxis.CheckPositionIsEmpty(rotationPosition))
  273. {
  274. LOG.WriteLog(eEvent.ERR_PUF, Module, $"rotation axis {rotationPosition} is not at Station");
  275. return false;
  276. }
  277. double flipPosition = _flipAxis.MotionData.MotorPosition;
  278. if (_flipAxis.CheckPositionIsEmpty(flipPosition))
  279. {
  280. LOG.WriteLog(eEvent.ERR_PUF, Module, $"flip axis {flipPosition} is not at Station");
  281. return false;
  282. }
  283. return true;
  284. }
  285. /// <summary>
  286. /// 获取LoaderSide
  287. /// </summary>
  288. private void GetLoaderSide()
  289. {
  290. if (_side==SIDE_A)
  291. {
  292. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{ModuleName.Loader1}.SideA");
  293. }
  294. else
  295. {
  296. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{ModuleName.Loader1}.SideB");
  297. }
  298. }
  299. /// <summary>
  300. /// 获取lipseal Axis
  301. /// </summary>
  302. private void GetCrsAxis()
  303. {
  304. if(_side==SIDE_A)
  305. {
  306. _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSA");
  307. }
  308. else
  309. {
  310. _loaderCrsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LSB");
  311. }
  312. }
  313. }
  314. }