LoaderRotationAxisInterLock.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. namespace CyberX8_RT.Devices.Loader
  7. {
  8. public class LoaderRotationAxisInterLock : IAxisInterLock
  9. {
  10. #region 内部变量
  11. private JetAxisBase _axis;
  12. #endregion
  13. #region 属性
  14. /// <summary>
  15. /// 模块名称
  16. /// </summary>
  17. public string Module { get { return _axis.Module; } }
  18. /// <summary>
  19. /// 子模块名称
  20. /// </summary>
  21. public string Name { get { return _axis.Name; } }
  22. #endregion
  23. /// <summary>
  24. /// 构造函数
  25. /// </summary>
  26. /// <param name="Module"></param>
  27. /// <param name="name"></param>
  28. public LoaderRotationAxisInterLock(JetAxisBase axis)
  29. {
  30. _axis = axis;
  31. }
  32. /// <summary>
  33. /// GotoPosition条件检验
  34. /// </summary>
  35. /// <param name="station"></param>
  36. /// <returns></returns>
  37. /// <exception cref="NotImplementedException"></exception>
  38. public bool CheckGotoPosition(string station)
  39. {
  40. //Rotation is homed
  41. if (!_axis.IsHomed)
  42. {
  43. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} Rotation is not home, Cannot execute GotoSavedPosition");
  44. return false;
  45. }
  46. if (!AxisManager.Instance.CheckModuleAxisSwitchOn(Module, Name))
  47. {
  48. return false;
  49. }
  50. //Loader ShuttleA
  51. JetAxisBase shuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleA");
  52. if(shuttleAAxis == null)
  53. {
  54. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleA Axis is null");
  55. return false;
  56. }
  57. if (shuttleAAxis.IsRun)
  58. {
  59. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} shuttleA is running, Cannot execute GotoSavedPosition");
  60. return false;
  61. }
  62. //Loader ShuttleB
  63. JetAxisBase shuttleBAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleB");
  64. if (shuttleBAxis == null)
  65. {
  66. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleB Axis is null");
  67. return false;
  68. }
  69. if (shuttleBAxis.IsRun)
  70. {
  71. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} shuttleB is running, Cannot execute GotoSavedPosition");
  72. return false;
  73. }
  74. //Loader TiltA
  75. JetAxisBase tiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
  76. if (tiltAAxis == null)
  77. {
  78. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} TiltA Axis is null");
  79. return false;
  80. }
  81. if (tiltAAxis.IsRun)
  82. {
  83. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltA is running, Cannot execute GotoSavedPosition");
  84. return false;
  85. }
  86. //Loader TiltB
  87. JetAxisBase tiltBAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
  88. if(tiltBAxis == null)
  89. {
  90. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltB Axis is null");
  91. return false;
  92. }
  93. if (tiltBAxis.IsRun)
  94. {
  95. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltB is running, Cannot execute GotoSavedPosition");
  96. return false;
  97. }
  98. //PUF1 的 ROTATION 轴在‘HOME’、‘FLIP’或‘ROBOT’位
  99. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  100. {
  101. JetAxisBase puf1RotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF1}.Rotation");
  102. if(puf1RotationAxis == null)
  103. {
  104. LOG.WriteLog(eEvent.ERR_PUF, Module, "Puf1 Rotation Axis is null");
  105. return false;
  106. }
  107. double puf1RotationPosition = puf1RotationAxis.MotionData.MotorPosition;
  108. if (!puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Home")
  109. && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Flip")
  110. && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Robot"))
  111. {
  112. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"PUF1 Rotation {puf1RotationPosition} is not in Home, Flip or Robot station,Cannot execute GotoSavedPosition");
  113. return false;
  114. }
  115. }
  116. //Loader 的 SHUTTLE A 轴在‘MID’、‘LS’或‘IN’位
  117. double shuttleAPosition = shuttleAAxis.MotionData.MotorPosition;
  118. if (!shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "MID")
  119. && !shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "LS")
  120. && !shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "IN"))
  121. {
  122. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleA {shuttleAPosition} is not in MID, LS or IN station,Cannot execute GotoSavedPosition");
  123. return false;
  124. }
  125. //Loader 的 SHUTTLE B 轴在‘MID’、‘LS’或‘IN’位
  126. double shuttleBPosition = shuttleBAxis.MotionData.MotorPosition;
  127. if (!shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "MID")
  128. && !shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "LS")
  129. && !shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "IN"))
  130. {
  131. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleB {shuttleBPosition} is not in MID, LS or IN station,Cannot execute GotoSavedPosition");
  132. return false;
  133. }
  134. //Loader transporter 的 ELEVATOR 在‘UP’位。
  135. bool loaderTransporterInstalled = ModuleHelper.IsInstalled(ModuleName.Transporter2);
  136. if (loaderTransporterInstalled)
  137. {
  138. JetAxisBase loaderTransporterElevatorAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Transporter2}.Elevator");
  139. if(loaderTransporterElevatorAxis == null)
  140. {
  141. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, "Loader transporter elevator Axis is null");
  142. return false;
  143. }
  144. double loaderTransporterPosition = loaderTransporterElevatorAxis.MotionData.MotorPosition;
  145. if (!loaderTransporterElevatorAxis.CheckPositionIsInStation(loaderTransporterPosition, "Up"))
  146. {
  147. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"Loader transporter elevator is not in Up station, Cannot execute GotoSavedPosition");
  148. return false;
  149. }
  150. }
  151. return true;
  152. }
  153. }
  154. }