LoaderShuttleAxisInterLock.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using MECF.Framework.Common.Equipment;
  4. using CyberX8_RT.Devices.AXIS;
  5. using System;
  6. using Aitex.Core.Util;
  7. using CyberX8_RT.Modules.PUF;
  8. using CyberX8_RT.Modules.Transporter;
  9. using CyberX8_RT.Modules;
  10. namespace CyberX8_RT.Devices.Loader
  11. {
  12. public class LoaderShuttleAxisInterLock : IAxisInterLock
  13. {
  14. #region 内部变量
  15. private JetAxisBase _axis;
  16. #endregion
  17. #region 属性
  18. /// <summary>
  19. /// 模块名称
  20. /// </summary>
  21. public string Module { get { return _axis.Module ; } }
  22. /// <summary>
  23. /// 子模块名称
  24. /// </summary>
  25. public string Name { get { return _axis.Name; } }
  26. #endregion
  27. #region 内部变量
  28. private LoaderSideDevice _loaderSide = null;
  29. #endregion
  30. /// <summary>
  31. /// 构造函数
  32. /// </summary>
  33. /// <param name="Module"></param>
  34. /// <param name="name"></param>
  35. public LoaderShuttleAxisInterLock(JetAxisBase axis)
  36. {
  37. _axis = axis;
  38. }
  39. /// <summary>
  40. /// 加载LoaderSide对象
  41. /// </summary>
  42. private void GetLoaderSide()
  43. {
  44. if (_loaderSide == null)
  45. {
  46. switch (Name)
  47. {
  48. case "ShuttleA":
  49. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideA");
  50. break;
  51. default:
  52. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideB");
  53. break;
  54. }
  55. }
  56. }
  57. /// <summary>
  58. /// GotoPosition条件检验
  59. /// </summary>
  60. /// <param name="station"></param>
  61. /// <returns></returns>
  62. /// <exception cref="NotImplementedException"></exception>
  63. public bool CheckGotoPosition(string station)
  64. {
  65. //Check Home
  66. if (!CheckHomeCondition())
  67. {
  68. return false;
  69. }
  70. //Shuttle Home
  71. if (!_axis.IsHomed)
  72. {
  73. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Name} is not home, Cannot execute GotoSavedPosition");
  74. return false;
  75. }
  76. JetAxisBase rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  77. if(rotationAxis == null)
  78. {
  79. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} rotation Axis is null");
  80. return false;
  81. }
  82. if (!rotationAxis.IsSwitchOn)
  83. {
  84. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{rotationAxis.Module} is switch off");
  85. return false;
  86. }
  87. if (rotationAxis.Status == CyberX8_Core.RState.Running)
  88. {
  89. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Name} rotation status is running, Cannot execute GotoSavedPosition");
  90. return false;
  91. }
  92. GetLoaderSide();
  93. JetAxisBase tiltAxis = null;
  94. if (Name == "ShuttleA")
  95. {
  96. tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
  97. }
  98. else
  99. {
  100. tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
  101. }
  102. if (tiltAxis == null)
  103. {
  104. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tilt Axis is null");
  105. return false;
  106. }
  107. if (!tiltAxis.IsSwitchOn)
  108. {
  109. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{tiltAxis.Module} is switch off");
  110. return false;
  111. }
  112. if (tiltAxis.Status==CyberX8_Core.RState.Running)
  113. {
  114. LOG.WriteLog(eEvent.ERR_LOADER, Module, "tilt status is running,Cannot execute GotoSavedPosition");
  115. return false;
  116. }
  117. //Loader 的 TILT 轴在‘VERT’位
  118. double tiltPosition = tiltAxis.MotionData.MotorPosition;
  119. if (!tiltAxis.CheckPositionIsInStation(tiltPosition, "VERT"))
  120. {
  121. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} Tilt {tiltPosition} is not in VERT station,Cannot execute GotoSavedPosition");
  122. return false;
  123. }
  124. //PUF1 的 ROTATION 轴在‘HOME’、‘FLIP’或‘ROBOT’位
  125. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  126. {
  127. JetAxisBase puf1RotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF1}.Rotation");
  128. if (puf1RotationAxis == null)
  129. {
  130. LOG.WriteLog(eEvent.ERR_PUF, Module, "Puf1 Rotation Axis is null");
  131. return false;
  132. }
  133. double puf1RotationPosition = puf1RotationAxis.MotionData.MotorPosition;
  134. if (!puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Home")
  135. && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Flip")
  136. && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Robot"))
  137. {
  138. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"PUF1 Rotation {puf1RotationPosition} is not in Home, Flip or Robot station,Cannot execute GotoSavedPosition");
  139. return false;
  140. }
  141. }
  142. return true;
  143. }
  144. /// <summary>
  145. /// Check Home
  146. /// </summary>
  147. /// <returns></returns>
  148. private bool CheckHomeCondition()
  149. {
  150. //Efem Home
  151. if (ModuleHelper.IsInstalled(ModuleName.EFEM))
  152. {
  153. EfemEntity efemEntity = Singleton<RouteManager>.Instance.GetModule<EfemEntity>(ModuleName.EFEM.ToString());
  154. if (efemEntity == null)
  155. {
  156. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} entity is null");
  157. return false;
  158. }
  159. if (!efemEntity.IsHomed)
  160. {
  161. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} is not home, Cannot execute GotoSavedPosition");
  162. return false;
  163. }
  164. }
  165. //Transporter2 Home
  166. if (ModuleHelper.IsInstalled(ModuleName.Transporter2))
  167. {
  168. TransporterEntity loaderTransporterEntity = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(ModuleName.Transporter2.ToString());
  169. if (loaderTransporterEntity == null)
  170. {
  171. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{ModuleName.Transporter2.ToString()} entity is null");
  172. return false;
  173. }
  174. if (!loaderTransporterEntity.IsHomed)
  175. {
  176. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{ModuleName.Transporter2.ToString()} is not home, Cannot execute GotoSavedPosition");
  177. return false;
  178. }
  179. }
  180. //Puf1 Home
  181. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  182. {
  183. PUFEntity puf1Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF1.ToString());
  184. if (puf1Entity == null)
  185. {
  186. LOG.WriteLog(eEvent.ERR_PUF, Module, $"{ModuleName.PUF1.ToString()} entity is null");
  187. return false;
  188. }
  189. if (!puf1Entity.IsHomed)
  190. {
  191. LOG.WriteLog(eEvent.ERR_PUF, Module, $"{ModuleName.PUF1.ToString()} is not home, Cannot execute GotoSavedPosition");
  192. return false;
  193. }
  194. }
  195. return true;
  196. }
  197. }
  198. }