LoaderSwingAxisInterLock.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Log;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.Utilities;
  6. using CyberX8_RT.Devices.AXIS;
  7. using CyberX8_RT.Devices.AXIS.Yaskawa;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace CyberX8_RT.Devices.Loader
  14. {
  15. public class LoaderSwingAxisInterLock : IAxisInterLock
  16. {
  17. #region 内部变量
  18. private JetAxisBase _axis;
  19. #endregion
  20. #region 属性
  21. /// <summary>
  22. /// 模块名称
  23. /// </summary>
  24. public string Module { get { return _axis.Module ; } }
  25. /// <summary>
  26. /// 子模块名称
  27. /// </summary>
  28. public string Name { get { return _axis.Name; } }
  29. #endregion
  30. #region 内部变量
  31. private LoaderSideDevice _loaderSide = null;
  32. #endregion
  33. /// <summary>
  34. /// 构造函数
  35. /// </summary>
  36. /// <param name="Module"></param>
  37. /// <param name="name"></param>
  38. public LoaderSwingAxisInterLock(JetAxisBase axis)
  39. {
  40. _axis = axis;
  41. }
  42. /// <summary>
  43. /// 加载LoaderSide对象
  44. /// </summary>
  45. private void GetLoaderSide()
  46. {
  47. if (_loaderSide == null)
  48. {
  49. switch (Name)
  50. {
  51. case "SwingA":
  52. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideA");
  53. break;
  54. default:
  55. _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideB");
  56. break;
  57. }
  58. }
  59. }
  60. /// <summary>
  61. /// GotoPosition条件检验
  62. /// </summary>
  63. /// <param name="station"></param>
  64. /// <returns></returns>
  65. /// <exception cref="NotImplementedException"></exception>
  66. public bool CheckGotoPosition(string station)
  67. {
  68. if (!_axis.IsHomed)
  69. {
  70. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Name} is not home, Cannot execute GotoSavedPosition");
  71. return false;
  72. }
  73. GetLoaderSide();
  74. JetAxisBase tiltAxis = null;
  75. if(Name=="SwingA")
  76. {
  77. tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
  78. }
  79. else
  80. {
  81. tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
  82. }
  83. if (!tiltAxis.IsSwitchOn)
  84. {
  85. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{tiltAxis.Module} is switch off");
  86. return false;
  87. }
  88. if (tiltAxis.IsRun)
  89. {
  90. LOG.WriteLog(eEvent.ERR_LOADER, Module, "tilt is running,Cannot execute GotoSavedPosition");
  91. return false;
  92. }
  93. if (station.EndsWith("CLOSED"))
  94. {
  95. double tiltPosition = tiltAxis.MotionData.MotorPosition;
  96. if(!tiltAxis.CheckPositionIsInStation(tiltPosition, "VERT"))
  97. {
  98. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{tiltAxis.Module} {tiltPosition} is not in VERT");
  99. return false;
  100. }
  101. }
  102. //Puf vertical is park
  103. if (ModuleHelper.IsInstalled(ModuleName.PUF1))
  104. {
  105. JetAxisBase puf1VerticalAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF1}.Vertical");
  106. if (puf1VerticalAxis != null)
  107. {
  108. double puf1VertocalPosition = puf1VerticalAxis.MotionData.MotorPosition;
  109. if (!puf1VerticalAxis.CheckPositionIsInStation(puf1VertocalPosition, "Park"))
  110. {
  111. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{ModuleName.PUF1} Vertical {puf1VertocalPosition} is not in Park, Cannot execute GotoSavedPosition");
  112. return false;
  113. }
  114. }
  115. }
  116. if (ModuleHelper.IsInstalled(ModuleName.PUF2))
  117. {
  118. JetAxisBase puf2VerticalAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF2}.Vertical");
  119. if (puf2VerticalAxis != null)
  120. {
  121. double puf2VerticalPosition=puf2VerticalAxis.MotionData.MotorPosition;
  122. if (!puf2VerticalAxis.CheckPositionIsInStation(puf2VerticalPosition, "Park"))
  123. {
  124. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{ModuleName.PUF2} Vertical {puf2VerticalPosition} is not in Park, Cannot execute GotoSavedPosition");
  125. return false;
  126. }
  127. }
  128. }
  129. //Door 在Closed,无法从其他位置运动至Closed位置
  130. if (_loaderSide.SideData.DoorLowerLocked||_loaderSide.SideData.DoorUpperLocked)
  131. {
  132. if (station.EndsWith("CLOSED"))
  133. {
  134. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"door locked, {Name} cannot goto CLOSED");
  135. return false;
  136. }
  137. else
  138. {
  139. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"door locked, {Name} cannot move to other stations");
  140. return false;
  141. }
  142. }
  143. JetAxisBase rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  144. if (!rotationAxis.IsSwitchOn)
  145. {
  146. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{rotationAxis.Module} is switch off");
  147. return false;
  148. }
  149. if (rotationAxis.IsRun)
  150. {
  151. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"rotation is running,Cannot execute GotoSavedPosition");
  152. return false;
  153. }
  154. double rotationPosition = rotationAxis.MotionData.MotorPosition;
  155. if (rotationAxis.CheckPositionIsEmpty(rotationPosition))
  156. {
  157. //LOG.WriteLog(eEvent.ERR_LOADER, Module, "loader rotation axis is empty, Cannot execute GotoSavedPosition");
  158. //return false;
  159. return true;
  160. }
  161. else
  162. {
  163. if (rotationAxis.CheckPositionIsInStation(rotationPosition, "LOADA300") ||
  164. rotationAxis.CheckPositionIsInStation(rotationPosition, "LOADB300")||
  165. rotationAxis.CheckPositionIsInStation(rotationPosition, "SERVICEB"))
  166. {
  167. return true;
  168. }
  169. else if (rotationAxis.CheckPositionIsInStation(rotationPosition, "CAMERA"))
  170. {
  171. if (station.EndsWith("CAMERA"))
  172. {
  173. return true;
  174. }
  175. else
  176. {
  177. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"loader rotation axis {rotationPosition} is in Camera, {Name} only goto Camera");
  178. return false;
  179. }
  180. }
  181. else
  182. {
  183. LOG.WriteLog(eEvent.ERR_LOADER, Module, $"loader rotation axis is in {rotationAxis.CurrentStation}, can not go to position");
  184. return false;
  185. }
  186. }
  187. }
  188. }
  189. }