LoaderShuttleAxisInterLock.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 LoaderShuttleAxisInterLock : 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. #region 内部变量
  24. private LoaderSideDevice _loaderSide = null;
  25. #endregion
  26. /// <summary>
  27. /// 构造函数
  28. /// </summary>
  29. /// <param name="Module"></param>
  30. /// <param name="name"></param>
  31. public LoaderShuttleAxisInterLock(JetAxisBase axis)
  32. {
  33. _axis = axis;
  34. }
  35. /// <summary>
  36. /// 加载LoaderSide对象
  37. /// </summary>
  38. private void GetLoaderSide()
  39. {
  40. if (_loaderSide == null)
  41. {
  42. switch (Name)
  43. {
  44. case "ShuttleA":
  45. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideA");
  46. break;
  47. default:
  48. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideB");
  49. break;
  50. }
  51. }
  52. }
  53. /// <summary>
  54. /// GotoPosition条件检验
  55. /// </summary>
  56. /// <param name="station"></param>
  57. /// <returns></returns>
  58. /// <exception cref="NotImplementedException"></exception>
  59. public bool CheckGotoPosition(string station)
  60. {
  61. if (!_axis.IsHomed)
  62. {
  63. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Name} is not home, Cannot execute GotoSavedPosition");
  64. return false;
  65. }
  66. JetAxisBase rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  67. if(rotationAxis == null)
  68. {
  69. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} rotation Axis is null");
  70. return false;
  71. }
  72. if (!rotationAxis.IsSwitchOn)
  73. {
  74. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{rotationAxis.Module} is switch off");
  75. return false;
  76. }
  77. if (rotationAxis.IsRun)
  78. {
  79. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} rotation is running,Cannot execute GotoSavedPosition");
  80. return false;
  81. }
  82. GetLoaderSide();
  83. JetAxisBase tiltAxis = null;
  84. if (Name == "ShuttleA")
  85. {
  86. tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
  87. }
  88. else
  89. {
  90. tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
  91. }
  92. if (tiltAxis == null)
  93. {
  94. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tilt Axis is null");
  95. return false;
  96. }
  97. if (!tiltAxis.IsSwitchOn)
  98. {
  99. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{tiltAxis.Module} is switch off");
  100. return false;
  101. }
  102. if (tiltAxis.IsRun)
  103. {
  104. LOG.WriteLog(eEvent.ERR_LOADER, Module, "tilt is running,Cannot execute GotoSavedPosition");
  105. return false;
  106. }
  107. //Loader 的 TILT 轴在‘VERT’位
  108. double tiltPosition = tiltAxis.MotionData.MotorPosition;
  109. if (!tiltAxis.CheckPositionIsInStation(tiltPosition, "VERT"))
  110. {
  111. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} Tilt {tiltPosition} is not in VERT station,Cannot execute GotoSavedPosition");
  112. return false;
  113. }
  114. //PUF1 的 ROTATION 轴在‘HOME’、‘FLIP’或‘ROBOT’位
  115. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  116. {
  117. JetAxisBase puf1RotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF1}.Rotation");
  118. if (puf1RotationAxis == null)
  119. {
  120. LOG.WriteLog(eEvent.ERR_PUF, Module, "Puf1 Rotation Axis is null");
  121. return false;
  122. }
  123. double puf1RotationPosition = puf1RotationAxis.MotionData.MotorPosition;
  124. if (!puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Home")
  125. && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Flip")
  126. && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Robot"))
  127. {
  128. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"PUF1 Rotation {puf1RotationPosition} is not in Home, Flip or Robot station,Cannot execute GotoSavedPosition");
  129. return false;
  130. }
  131. }
  132. return true;
  133. }
  134. }
  135. }