LoaderHomeAllRoutine.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.Routine;
  6. using MECF.Framework.Common.Utilities;
  7. using CyberX8_Core;
  8. using CyberX8_RT.Devices.AXIS;
  9. using CyberX8_RT.Devices.Loader;
  10. using CyberX8_RT.Devices.PUF;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using CyberX8_RT.Devices.Safety;
  17. using Aitex.Core.Util;
  18. using CyberX8_RT.Modules.PUF;
  19. using CyberX8_RT.Modules.Transporter;
  20. using Aitex.Core.Common;
  21. using static Mono.Security.X509.X520;
  22. using Aitex.Core.RT.SCCore;
  23. namespace CyberX8_RT.Modules.Loader
  24. {
  25. public class LoaderHomeAllRoutine : RoutineBase, IRoutine
  26. {
  27. private enum HomeAllStep
  28. {
  29. CheckPreCondition,
  30. ShuttleAHome,
  31. WaitShuttleAHome,
  32. TiltAHome,
  33. WaitTiltAHome,
  34. TiltAGotoVERT,
  35. TiltAGotoVERTCheck,
  36. ShuttleAGotoMID,
  37. ShuttleAGotoMIDCheck,
  38. ShuttleBHome,
  39. WaitShuttleBHome,
  40. TiltBHome,
  41. WaitTiltBHome,
  42. TiltBGotoVERT,
  43. TiltBGotoVERTCheck,
  44. ShuttleBGotoMID,
  45. ShuttleBGotoMIDCheck,
  46. LSAHome,
  47. WaitLSAHome,
  48. LSAGotoSetup,
  49. LSAGotoSetupCheck,
  50. LSBHome,
  51. WaitLSBHome,
  52. LSBGotoSetup,
  53. LSBGotoSetupCheck,
  54. RotationHome,
  55. WaitRotationHome,
  56. RotationGotoTrnpa,
  57. RotationGotoTrnpaCheck,
  58. End
  59. }
  60. #region 内部变量
  61. private JetAxisBase _shuttleAAxis;
  62. private JetAxisBase _shuttleBAxis;
  63. private JetAxisBase _tiltAAxis;
  64. private JetAxisBase _tiltBAxis;
  65. private JetAxisBase _rotationAxis;
  66. private JetAxisBase _lsAAxis;
  67. private JetAxisBase _lsBAxis;
  68. private LoaderSideDevice _sideADevice;
  69. private LoaderSideDevice _sideBDevice;
  70. private int _sideAWaferSize;
  71. private int _sideBWaferSize;
  72. #endregion
  73. public LoaderHomeAllRoutine(string module) : base(module)
  74. {
  75. _shuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.ShuttleA");
  76. _shuttleBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.ShuttleB");
  77. _tiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.TiltA");
  78. _tiltBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.TiltB");
  79. _lsAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.LSA");
  80. _lsBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.LSB");
  81. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.Rotation");
  82. }
  83. public void Abort()
  84. {
  85. Runner.Stop("Manual Abort");
  86. }
  87. public RState Monitor()
  88. {
  89. Runner.Run(HomeAllStep.CheckPreCondition, CheckPreCondition, _delay_1ms)
  90. //Home Shuttle Goto MID
  91. .Run(HomeAllStep.ShuttleAHome, () => { return _shuttleAAxis.Home(); }, _delay_1ms)
  92. .WaitWithStopCondition(HomeAllStep.WaitShuttleAHome, () => { return _shuttleAAxis.Status == RState.End; }, () => { return _shuttleAAxis.Status == RState.Failed; })
  93. //Home Tilt Goto VERT
  94. .Run(HomeAllStep.TiltAHome, () => { return _tiltAAxis.Home(); },_delay_1ms)
  95. .WaitWithStopCondition(HomeAllStep.WaitTiltAHome, () => { return _tiltAAxis.Status == RState.End; }, () => {return _tiltAAxis.Status == RState.Failed; })
  96. .Run(HomeAllStep.TiltAGotoVERT, () => { return _tiltAAxis.PositionStation("VERT",true); },100)
  97. .WaitWithStopCondition(HomeAllStep.TiltAGotoVERTCheck, () => { return _tiltAAxis.Status == RState.End; }, () => { return _tiltAAxis.Status == RState.Failed; })
  98. .Run(HomeAllStep.ShuttleBHome, () => { return _shuttleBAxis.Home(); }, _delay_1ms)
  99. .WaitWithStopCondition(HomeAllStep.WaitShuttleBHome, () => { return _shuttleBAxis.Status == RState.End; }, () => { return _shuttleBAxis.Status == RState.Failed; })
  100. .Run(HomeAllStep.TiltBHome, () => { return _tiltBAxis.Home(); }, _delay_1ms)
  101. .WaitWithStopCondition(HomeAllStep.WaitTiltBHome, () => { return _tiltBAxis.Status == RState.End; }, () => { return _tiltBAxis.Status == RState.Failed; })
  102. .Run(HomeAllStep.TiltBGotoVERT, () => { return _tiltBAxis.PositionStation("VERT",true); }, 100)
  103. .WaitWithStopCondition(HomeAllStep.TiltBGotoVERTCheck, () => { return _tiltBAxis.Status == RState.End; }, () => { return _tiltBAxis.Status == RState.Failed; })
  104. .Run(HomeAllStep.ShuttleAGotoMID, () => { return _shuttleAAxis.PositionStation("MID",true); }, 100)
  105. .WaitWithStopCondition(HomeAllStep.ShuttleAGotoMIDCheck, () => { return _shuttleAAxis.Status == RState.End; }, () => { return _shuttleAAxis.Status == RState.Failed; })
  106. .Run(HomeAllStep.ShuttleBGotoMID, () => { return _shuttleBAxis.PositionStation("MID", true); }, 100)
  107. .WaitWithStopCondition(HomeAllStep.ShuttleBGotoMIDCheck, () => { return _shuttleBAxis.Status == RState.End; }, () => { return _shuttleBAxis.Status == RState.Failed; })
  108. //Home LS Goto Setup
  109. .Run(HomeAllStep.LSAHome, () => { return _lsAAxis.Home(); }, _delay_1ms)
  110. .WaitWithStopCondition(HomeAllStep.WaitLSAHome, () => { return _lsAAxis.Status == RState.End; }, () => { return _lsAAxis.Status == RState.Failed; })
  111. .Run(HomeAllStep.LSAGotoSetup, () => { return _lsAAxis.PositionStation($"Setup{_sideAWaferSize}", true); }, _delay_1ms)
  112. .WaitWithStopCondition(HomeAllStep.LSAGotoSetupCheck, () => { return _lsAAxis.Status == RState.End; }, () => { return _lsAAxis.Status == RState.Failed; })
  113. .Run(HomeAllStep.LSBHome, () => { return _lsBAxis.Home(); }, _delay_1ms)
  114. .WaitWithStopCondition(HomeAllStep.WaitLSBHome, () => { return _lsBAxis.Status == RState.End; }, () => { return _lsBAxis.Status == RState.Failed; })
  115. .Run(HomeAllStep.LSBGotoSetup, () => { return _lsBAxis.PositionStation($"Setup{_sideBWaferSize}",true); }, 100)
  116. .WaitWithStopCondition(HomeAllStep.LSBGotoSetupCheck, () => { return _lsBAxis.Status == RState.End; }, () => { return _lsBAxis.Status == RState.Failed; })
  117. //Home Rotation Goto TRNPA
  118. .Run(HomeAllStep.RotationHome, () => { return _rotationAxis.Home(); }, _delay_1ms)
  119. .WaitWithStopCondition(HomeAllStep.WaitRotationHome, () => { return _rotationAxis.Status == RState.End; }, () => { return _rotationAxis.Status == RState.Failed; })
  120. .Run(HomeAllStep.RotationGotoTrnpa, () => { return _rotationAxis.PositionStation("TRNPA", true); }, 100)
  121. .WaitWithStopCondition(HomeAllStep.RotationGotoTrnpaCheck, () => { return _rotationAxis.Status == RState.End; }, () => { return _rotationAxis.Status == RState.Failed; })
  122. .End(HomeAllStep.End,NullFun);
  123. return Runner.Status;
  124. }
  125. public RState Start(params object[] objs)
  126. {
  127. _sideADevice = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideA");
  128. _sideBDevice = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideB");
  129. if (SC.ContainsItem($"Loader1.SideAWaferSize"))
  130. {
  131. _sideAWaferSize = SC.GetValue<int>($"Loader1.SideAWaferSize");
  132. }
  133. if (SC.ContainsItem($"Loader1.SideBWaferSize"))
  134. {
  135. _sideBWaferSize = SC.GetValue<int>($"Loader1.SideBWaferSize");
  136. }
  137. Runner.Start(Module, "Home All");
  138. return RState.Running;
  139. }
  140. /// <summary>
  141. /// 检验前置条件
  142. /// </summary>
  143. /// <returns></returns>
  144. private bool CheckPreCondition()
  145. {
  146. if (!CheckHomeCondition())
  147. {
  148. return false;
  149. }
  150. if (!CheckAxisCondition())
  151. {
  152. return false;
  153. }
  154. return true;
  155. }
  156. /// <summary>
  157. /// 检验Home条件
  158. /// </summary>
  159. /// <returns></returns>
  160. private bool CheckHomeCondition()
  161. {
  162. //检验PUF、Loader Transporter,Robot均Homed
  163. //Efem Home
  164. if (ModuleHelper.IsInstalled(ModuleName.EFEM))
  165. {
  166. EfemEntity efemEntity = Singleton<RouteManager>.Instance.GetModule<EfemEntity>(ModuleName.EFEM.ToString());
  167. if (!efemEntity.IsHomed)
  168. {
  169. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} is not home, Cannot execute GotoSavedPosition");
  170. return false;
  171. }
  172. }
  173. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  174. {
  175. PUFEntity puf1Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF1.ToString());
  176. if (!puf1Entity.IsHomed)
  177. {
  178. NotifyError(eEvent.ERR_LOADER, "PUF1 is not homed", -1);
  179. return false;
  180. }
  181. }
  182. if (ModuleHelper.IsInstalled(ModuleName.Transporter2))
  183. {
  184. TransporterEntity loaderTransportEntity = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(ModuleName.Transporter2.ToString());
  185. if (!loaderTransportEntity.IsHomed)
  186. {
  187. NotifyError(eEvent.ERR_LOADER, "Loader Transporter is not homed", -1);
  188. return false;
  189. }
  190. }
  191. return true;
  192. }
  193. /// <summary>
  194. /// 检验Axis条件
  195. /// </summary>
  196. /// <param name="side"></param>
  197. /// <returns></returns>
  198. private bool CheckAxisCondition()
  199. {
  200. //Check all motor switch on
  201. if (!AxisManager.Instance.CheckModuleAxisSwitchOn(Module, ""))
  202. {
  203. return false;
  204. }
  205. return true;
  206. }
  207. }
  208. }