LoaderRotationAxisInterLock.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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;
  8. using CyberX8_RT.Modules.Transporter;
  9. using CyberX8_RT.Modules.PUF;
  10. namespace CyberX8_RT.Devices.Loader
  11. {
  12. public class LoaderRotationAxisInterLock : 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. /// <summary>
  28. /// 构造函数
  29. /// </summary>
  30. /// <param name="Module"></param>
  31. /// <param name="name"></param>
  32. public LoaderRotationAxisInterLock(JetAxisBase axis)
  33. {
  34. _axis = axis;
  35. }
  36. /// <summary>
  37. /// GotoPosition条件检验
  38. /// </summary>
  39. /// <param name="station"></param>
  40. /// <returns></returns>
  41. /// <exception cref="NotImplementedException"></exception>
  42. public bool CheckGotoPosition(string station)
  43. {
  44. //Check Home
  45. if (!CheckHomeCondition())
  46. {
  47. return false;
  48. }
  49. //Rotation is homed
  50. if (!_axis.IsHomed)
  51. {
  52. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} Rotation is not home, Cannot execute GotoSavedPosition");
  53. return false;
  54. }
  55. if (!AxisManager.Instance.CheckModuleAxisSwitchOn(Module, Name))
  56. {
  57. return false;
  58. }
  59. //Loader ShuttleA
  60. JetAxisBase shuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleA");
  61. if(shuttleAAxis == null)
  62. {
  63. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleA Axis is null");
  64. return false;
  65. }
  66. if (shuttleAAxis.Status==CyberX8_Core.RState.Running)
  67. {
  68. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} shuttleA status is running, Cannot execute GotoSavedPosition");
  69. return false;
  70. }
  71. //Loader ShuttleB
  72. JetAxisBase shuttleBAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleB");
  73. if (shuttleBAxis == null)
  74. {
  75. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleB Axis is null");
  76. return false;
  77. }
  78. if (shuttleBAxis.Status== CyberX8_Core.RState.Running)
  79. {
  80. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} shuttleB status is running, Cannot execute GotoSavedPosition");
  81. return false;
  82. }
  83. //Loader TiltA
  84. JetAxisBase tiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
  85. if (tiltAAxis == null)
  86. {
  87. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} TiltA Axis is null");
  88. return false;
  89. }
  90. if (tiltAAxis.Status== CyberX8_Core.RState.Running)
  91. {
  92. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltA status is running, Cannot execute GotoSavedPosition");
  93. return false;
  94. }
  95. //Loader TiltB
  96. JetAxisBase tiltBAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
  97. if(tiltBAxis == null)
  98. {
  99. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltB Axis is null");
  100. return false;
  101. }
  102. if (tiltBAxis.Status==CyberX8_Core.RState.Running)
  103. {
  104. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltB status is running, Cannot execute GotoSavedPosition");
  105. return false;
  106. }
  107. //PUF1 的 ROTATION 轴在‘HOME’、‘FLIP’或‘ROBOT’位
  108. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  109. {
  110. JetAxisBase puf1RotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF1}.Rotation");
  111. if(puf1RotationAxis == null)
  112. {
  113. LOG.WriteLog(eEvent.ERR_PUF, Module, "Puf1 Rotation Axis is null");
  114. return false;
  115. }
  116. double puf1RotationPosition = puf1RotationAxis.MotionData.MotorPosition;
  117. if (!puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Home")
  118. && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Flip")
  119. && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Robot"))
  120. {
  121. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"PUF1 Rotation {puf1RotationPosition} is not in Home, Flip or Robot station,Cannot execute GotoSavedPosition");
  122. return false;
  123. }
  124. }
  125. //Loader 的 SHUTTLE A 轴在‘MID’、‘LS’或‘IN’位
  126. double shuttleAPosition = shuttleAAxis.MotionData.MotorPosition;
  127. if (!shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "MID")
  128. && !shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "LS")
  129. && !shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "IN"))
  130. {
  131. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleA {shuttleAPosition} is not in MID, LS or IN station,Cannot execute GotoSavedPosition");
  132. return false;
  133. }
  134. //Loader 的 SHUTTLE B 轴在‘MID’、‘LS’或‘IN’位
  135. double shuttleBPosition = shuttleBAxis.MotionData.MotorPosition;
  136. if (!shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "MID")
  137. && !shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "LS")
  138. && !shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "IN"))
  139. {
  140. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleB {shuttleBPosition} is not in MID, LS or IN station,Cannot execute GotoSavedPosition");
  141. return false;
  142. }
  143. //Loader transporter 的 ELEVATOR 在‘UP’位。
  144. bool loaderTransporterInstalled = ModuleHelper.IsInstalled(ModuleName.Transporter2);
  145. if (loaderTransporterInstalled)
  146. {
  147. JetAxisBase loaderTransporterElevatorAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Transporter2}.Elevator");
  148. if(loaderTransporterElevatorAxis == null)
  149. {
  150. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, "Loader transporter elevator Axis is null");
  151. return false;
  152. }
  153. double loaderTransporterPosition = loaderTransporterElevatorAxis.MotionData.MotorPosition;
  154. if (!loaderTransporterElevatorAxis.CheckPositionIsInStation(loaderTransporterPosition, "UP"))
  155. {
  156. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"Loader transporter elevator is not in UP station, Cannot execute GotoSavedPosition");
  157. return false;
  158. }
  159. }
  160. return true;
  161. }
  162. /// <summary>
  163. /// Check Home
  164. /// </summary>
  165. /// <returns></returns>
  166. private bool CheckHomeCondition()
  167. {
  168. //Efem Home
  169. if (ModuleHelper.IsInstalled(ModuleName.EFEM))
  170. {
  171. EfemEntity efemEntity = Singleton<RouteManager>.Instance.GetModule<EfemEntity>(ModuleName.EFEM.ToString());
  172. if (efemEntity == null)
  173. {
  174. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} entity is null");
  175. return false;
  176. }
  177. if (!efemEntity.IsHomed)
  178. {
  179. LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} is not home, Cannot execute GotoSavedPosition");
  180. return false;
  181. }
  182. }
  183. //Transporter2 Home
  184. if (ModuleHelper.IsInstalled(ModuleName.Transporter2))
  185. {
  186. TransporterEntity loaderTransporterEntity = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(ModuleName.Transporter2.ToString());
  187. if (loaderTransporterEntity == null)
  188. {
  189. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{ModuleName.Transporter2.ToString()} entity is null");
  190. return false;
  191. }
  192. if (!loaderTransporterEntity.IsHomed)
  193. {
  194. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{ModuleName.Transporter2.ToString()} is not home, Cannot execute GotoSavedPosition");
  195. return false;
  196. }
  197. }
  198. //Puf1 Home
  199. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  200. {
  201. PUFEntity puf1Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF1.ToString());
  202. if (puf1Entity == null)
  203. {
  204. LOG.WriteLog(eEvent.ERR_PUF, Module, $"{ModuleName.PUF1.ToString()} entity is null");
  205. return false;
  206. }
  207. if (!puf1Entity.IsHomed)
  208. {
  209. LOG.WriteLog(eEvent.ERR_PUF, Module, $"{ModuleName.PUF1.ToString()} is not home, Cannot execute GotoSavedPosition");
  210. return false;
  211. }
  212. }
  213. return true;
  214. }
  215. }
  216. }