PufPickFromLoaderRoutine.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.Routine;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.Routine;
  8. using MECF.Framework.Common.Utilities;
  9. using CyberX8_Core;
  10. using CyberX8_RT.Devices.AXIS;
  11. using CyberX8_RT.Devices.Loader;
  12. using CyberX8_RT.Devices.PUF;
  13. using CyberX8_RT.Devices.TransPorter;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Threading.Tasks;
  19. using Aitex.Core.RT.SCCore;
  20. namespace CyberX8_RT.Modules.PUF
  21. {
  22. public class PufPickFromLoaderRoutine : RoutineBase,IRoutine
  23. {
  24. #region 常量
  25. private const string SideA = "SideA";
  26. private const string SideB = "SideB";
  27. private const string CURRENT_STATION_LIST = "CurrentStationList";
  28. private const string WAFER_PRESENT = "WaferPresent";
  29. #endregion
  30. private enum PufPickStep
  31. {
  32. SideConditionRoutine,
  33. SideConditionRoutineWait,
  34. RotationLoaderPickup,
  35. RotationLoaderPickupWait,
  36. ChuckOut,
  37. CheckChuckOut,
  38. VacuumOn,
  39. ChuckIn,
  40. CheckChuckIn,
  41. StickDistanceCheck,
  42. RotationHomeStation,
  43. RotationHomeStationWait,
  44. End
  45. }
  46. #region 内部变量
  47. private string _loaderSide;
  48. private string _pufSide;
  49. private JetAxisBase _flipAxis;
  50. private JetAxisBase _rotationAxis;
  51. private JetAxisBase _gantryAxis;
  52. private LoaderSideDevice _loaderSideDevice;
  53. private PufVacuum _vacuum;
  54. private PufWaferPickSubRoutine _pufWaferPickSubRoutine;
  55. private PufChuckRoutine _chuckRoutine;
  56. private PufDistanceSensor _distanceSensor;
  57. private bool _enableCheckStickDistanceStatus = false;
  58. #endregion
  59. /// <summary>
  60. /// 构造函数
  61. /// </summary>
  62. /// <param name="module"></param>
  63. /// <param name="pufEntity"></param>
  64. public PufPickFromLoaderRoutine(string module) : base(module)
  65. {
  66. }
  67. /// <summary>
  68. /// 中止
  69. /// </summary>
  70. public void Abort()
  71. {
  72. Runner.Stop("Manual Abort");
  73. }
  74. public RState Monitor()
  75. {
  76. Runner.RunConditionSubRoutine(PufPickStep.SideConditionRoutine, SideConditionIndex, new IRoutine[] { _pufWaferPickSubRoutine }, new object[] { _pufSide })
  77. .WaitConditionSubRoutine(PufPickStep.SideConditionRoutineWait)
  78. .Run(PufPickStep.RotationLoaderPickup, () => { return _rotationAxis.PositionStation("LoaderPickup"); }, NullFun, 100)
  79. .WaitWithStopCondition(PufPickStep.RotationLoaderPickupWait, () => { return _rotationAxis.Status == RState.End; }, () => { return _rotationAxis.Status == RState.Failed; })
  80. .Run(PufPickStep.ChuckOut, () => { return _chuckRoutine.Start(true) == RState.Running; }, NullFun, 100)
  81. .WaitWithStopCondition(PufPickStep.CheckChuckOut, () => CommonFunction.CheckRoutineEndState(_chuckRoutine), () => CommonFunction.CheckRoutineStopState(_chuckRoutine))
  82. .Run(PufPickStep.VacuumOn, VacuumOn, CheckWaferPresent, 5000)
  83. .Run(PufPickStep.ChuckIn, () => { return _chuckRoutine.Start(false) == RState.Running; }, NullFun, 100)
  84. .WaitWithStopCondition(PufPickStep.CheckChuckIn, () => CommonFunction.CheckRoutineEndState(_chuckRoutine), () => CommonFunction.CheckRoutineStopState(_chuckRoutine))
  85. .Wait(PufPickStep.StickDistanceCheck, CheckStickDistanceStatus, 1000)
  86. .Run(PufPickStep.RotationHomeStation, () => { return _rotationAxis.PositionStation("Home"); }, NullFun, 100)
  87. .WaitWithStopCondition(PufPickStep.RotationHomeStationWait, () => { return _rotationAxis.Status == RState.End; }, () => { return _rotationAxis.Status == RState.Failed; })
  88. .End(PufPickStep.End, NullFun);
  89. return Runner.Status;
  90. }
  91. /// <summary>
  92. /// Side条件获取SubRoutine索引
  93. /// </summary>
  94. /// <returns></returns>
  95. private int SideConditionIndex()
  96. {
  97. if (_flipAxis.CheckPositionIsInStation(_flipAxis.MotionData.MotorPosition, _pufSide))
  98. {
  99. return 1;
  100. }
  101. else
  102. {
  103. return 0;
  104. }
  105. }
  106. /// <summary>
  107. /// 检验VacuumLevel
  108. /// </summary>
  109. /// <returns></returns>
  110. private bool CheckVacuumLevel()
  111. {
  112. if (_pufSide == SideA)
  113. {
  114. return _vacuum.ChuckBVacuumStatus == WAFER_PRESENT;
  115. }
  116. else if (_pufSide == SideB)
  117. {
  118. return _vacuum.ChuckAVacuumStatus == WAFER_PRESENT;
  119. }
  120. else
  121. {
  122. return false;
  123. }
  124. }
  125. /// <summary>
  126. /// 检验存在Wafer
  127. /// </summary>
  128. /// <returns></returns>
  129. private bool CheckWaferPresent()
  130. {
  131. if (_pufSide == SideA)
  132. {
  133. return _vacuum.ChuckAVacuumStatus == WAFER_PRESENT;
  134. }
  135. else if (_pufSide == SideB)
  136. {
  137. return _vacuum.ChuckBVacuumStatus == WAFER_PRESENT;
  138. }
  139. else
  140. {
  141. return false;
  142. }
  143. }
  144. /// <summary>
  145. /// 打开Vacuum
  146. /// </summary>
  147. /// <returns></returns>
  148. private bool VacuumOn()
  149. {
  150. if (_pufSide == SideA)
  151. {
  152. _vacuum.VacuumAOn();
  153. return true;
  154. }
  155. else if (_pufSide == SideB)
  156. {
  157. _vacuum.VacuumBOn();
  158. return true;
  159. }
  160. return false;
  161. }
  162. /// <summary>
  163. /// Stick Distance检验结果
  164. /// </summary>
  165. /// <returns></returns>
  166. private bool CheckStickDistanceStatus()
  167. {
  168. if (_enableCheckStickDistanceStatus)
  169. {
  170. return _distanceSensor.CheckStickDistanceStatus();
  171. }
  172. else
  173. {
  174. return true;
  175. }
  176. }
  177. /// <summary>
  178. /// 启动
  179. /// </summary>
  180. /// <param name="objs"></param>
  181. /// <returns></returns>
  182. public RState Start(params object[] objs)
  183. {
  184. _pufSide = objs[0].ToString();
  185. _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Flip");
  186. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  187. _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
  188. _gantryAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Transporter2}.Gantry");
  189. _distanceSensor = DEVICE.GetDevice<PufDistanceSensor>($"{Module}.DistanceSensor");
  190. _pufWaferPickSubRoutine = new PufWaferPickSubRoutine(Module);
  191. _enableCheckStickDistanceStatus = SC.GetValue<bool>($"{Module}.EnableCheckStickDistanceStatus");
  192. _chuckRoutine = new PufChuckRoutine(Module);
  193. if (CheckCondition())
  194. {
  195. return Runner.Start(Module, "PickFrom Loader");
  196. }
  197. else
  198. {
  199. return RState.Failed;
  200. }
  201. }
  202. /// <summary>
  203. /// 检验条件
  204. /// </summary>
  205. /// <returns></returns>
  206. private bool CheckCondition()
  207. {
  208. //Loader1.Rotation 在LOADA
  209. bool isLoaderInstall = ModuleHelper.IsInstalled(ModuleName.Loader1);
  210. if (isLoaderInstall)
  211. {
  212. JetAxisBase loaderRotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Rotation");
  213. double loaderRotationPosition = loaderRotationAxis.MotionData.MotorPosition;
  214. if (!loaderRotationAxis.CheckPositionInStationIgnoreWaferSize(loaderRotationPosition, "LOAD"))
  215. {
  216. LOG.WriteLog(eEvent.ERR_PUF, Module, $"Loader Rotation {loaderRotationPosition} is not in LOAD");
  217. return false;
  218. }
  219. bool isLoadA = loaderRotationAxis.CheckPositionInStationIgnoreWaferSize(loaderRotationPosition, "LOADA");
  220. bool isLoadB = loaderRotationAxis.CheckPositionInStationIgnoreWaferSize(loaderRotationPosition, "LOADB");
  221. string side = isLoadA ? "A" : "B";
  222. _loaderSide = isLoadA ? SideA : SideB;
  223. _loaderSideDevice = DEVICE.GetDevice<LoaderSideDevice>($"{ModuleName.Loader1}.{_loaderSide}");
  224. //Loader1.SwingA 在Open
  225. JetAxisBase loaderShuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Shuttle{side}");
  226. double loaderShuttleAPosition = loaderShuttleAAxis.MotionData.MotorPosition;
  227. if (!loaderShuttleAAxis.CheckPositionInStationIgnoreWaferSize(loaderShuttleAPosition, "OUT"))
  228. {
  229. LOG.WriteLog(eEvent.ERR_PUF, Module, $"Loader ShuttleA {loaderShuttleAPosition} is not in OUT");
  230. return false;
  231. }
  232. //Loader1.TiltA 在HORI
  233. JetAxisBase loaderTiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Tilt{side}");
  234. double loaderTiltAPosition = loaderTiltAAxis.MotionData.MotorPosition;
  235. if (!loaderTiltAAxis.CheckPositionIsInStation(loaderTiltAPosition, "HORI"))
  236. {
  237. LOG.WriteLog(eEvent.ERR_PUF, Module, $"Loader Tilt{side} {loaderTiltAPosition} is not in HORI");
  238. return false;
  239. }
  240. //Loader Handle Wafer状态确认
  241. // Lip Seal Vacuum "ON"
  242. if (!_loaderSideDevice.SideData.CRSVacuum)
  243. {
  244. LOG.WriteLog(eEvent.ERR_PUF, Module, "Loader1 LS Vacuum is off");
  245. return false;
  246. }
  247. //Bernoulli Bladder "ON",Retracted Green Light
  248. if (!_loaderSideDevice.SideData.BernoulliBladder)
  249. {
  250. LOG.WriteLog(eEvent.ERR_PUF, Module, "Loader1 Bernoulli Bladder is off");
  251. return false;
  252. }
  253. //其他SideA/B均为OFF
  254. if (_loaderSideDevice.SideData.BernoulliN2)
  255. {
  256. LOG.WriteLog(eEvent.ERR_PUF, Module, "Loader1 Bernoulli N2 is on");
  257. return false;
  258. }
  259. if (_loaderSideDevice.SideData.WHBladder)
  260. {
  261. LOG.WriteLog(eEvent.ERR_PUF, Module, "Loader1 WS Bladder is on");
  262. return false;
  263. }
  264. }
  265. double rotationPosition = _rotationAxis.MotionData.MotorPosition;
  266. if(_rotationAxis.CheckPositionIsEmpty(rotationPosition))
  267. {
  268. LOG.WriteLog(eEvent.ERR_PUF,Module, $"rotation axis {rotationPosition} is not at Station");
  269. return false;
  270. }
  271. double flipPosition = _flipAxis.MotionData.MotorPosition;
  272. if(_flipAxis.CheckPositionIsEmpty(flipPosition))
  273. {
  274. LOG.WriteLog( eEvent.ERR_PUF,Module, $"flip axis {flipPosition} is not at Station");
  275. return false;
  276. }
  277. return true;
  278. }
  279. }
  280. }