TransporterParkRoutine.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using MECF.Framework.Common.Routine;
  5. using MECF.Framework.Common.WaferHolder;
  6. using CyberX8_Core;
  7. using CyberX8_RT.Devices.AXIS;
  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.Modules.Transporter
  14. {
  15. public class TransporterParkRoutine : RoutineBase, IRoutine
  16. {
  17. private enum ParkStep
  18. {
  19. CheckStatus,
  20. ElevatorPark,
  21. ElevatorParkWait,
  22. GantryPark,
  23. GantryParkWait,
  24. End
  25. }
  26. #region 内部变量
  27. private JetAxisBase _gantryAxis;
  28. private JetAxisBase _elevatorAxis;
  29. private bool _hasWaferHolder = false;
  30. #endregion
  31. /// <summary>
  32. /// 构造函数
  33. /// </summary>
  34. /// <param name="module"></param>
  35. public TransporterParkRoutine(string module) : base(module)
  36. {
  37. }
  38. /// <summary>
  39. /// 中止
  40. /// </summary>
  41. public void Abort()
  42. {
  43. Runner.Stop("Manual Abort");
  44. }
  45. /// <summary>
  46. /// 监控
  47. /// </summary>
  48. /// <returns></returns>
  49. public RState Monitor()
  50. {
  51. Runner.Run(ParkStep.CheckStatus, CheckPreCondition, NullFun,_delay_1ms)
  52. //1.1 Elevator
  53. .Run(ParkStep.ElevatorPark, ElevatorPosition, _delay_1ms)
  54. .WaitWithStopCondition(ParkStep.ElevatorParkWait, CheckVerticalPositionStatus, CheckVerticalPositionRunStop)
  55. //1.2 Gantry 移动
  56. .Run(ParkStep.GantryPark, () => { return _gantryAxis.PositionStation("Park"); }, NullFun, _delay_1ms)
  57. .WaitWithStopCondition(ParkStep.GantryParkWait, CheckGantryPositionStatus, CheckGantryPositionRunStop)
  58. .End(ParkStep.End,NullFun,100);
  59. return Runner.Status;
  60. }
  61. /// <summary>
  62. /// 检验前置条件
  63. /// </summary>
  64. /// <returns></returns>
  65. private bool CheckPreCondition()
  66. {
  67. if(!_gantryAxis.IsSwitchOn)
  68. {
  69. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{Module} gantry axis is not switch on ");
  70. return false;
  71. }
  72. if (!_gantryAxis.IsHomed)
  73. {
  74. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{Module} gantry axis is not homed ");
  75. return false;
  76. }
  77. if (!_elevatorAxis.IsSwitchOn)
  78. {
  79. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{Module} elevator axis is not switch on ");
  80. return false;
  81. }
  82. if (!_elevatorAxis.IsHomed)
  83. {
  84. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{Module} elevator axis is not homed ");
  85. return false;
  86. }
  87. return true;
  88. }
  89. /// <summary>
  90. /// Elevator Position
  91. /// </summary>
  92. /// <returns></returns>
  93. private bool ElevatorPosition()
  94. {
  95. return _elevatorAxis.PositionStation("Up");
  96. }
  97. /// <summary>
  98. /// 检验Vertical移动状态
  99. /// </summary>
  100. /// <returns></returns>
  101. private bool CheckVerticalPositionStatus()
  102. {
  103. return _elevatorAxis.Status == RState.End;
  104. }
  105. /// <summary>
  106. /// 检验Vertical是否还在运动
  107. /// </summary>
  108. /// <returns></returns>
  109. private bool CheckVerticalPositionRunStop()
  110. {
  111. return _elevatorAxis.Status == RState.Failed;
  112. }
  113. /// <summary>
  114. /// 检验Gantry移动状态
  115. /// </summary>
  116. /// <returns></returns>
  117. private bool CheckGantryPositionStatus()
  118. {
  119. return _gantryAxis.Status == RState.End;
  120. }
  121. /// <summary>
  122. /// 检验Gantry是否还在运动
  123. /// </summary>
  124. /// <returns></returns>
  125. private bool CheckGantryPositionRunStop()
  126. {
  127. return _gantryAxis.Status == RState.Failed;
  128. }
  129. /// <summary>
  130. /// 启动
  131. /// </summary>
  132. /// <param name="objs"></param>
  133. /// <returns></returns>
  134. public RState Start(params object[] objs)
  135. {
  136. _elevatorAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Elevator");
  137. _gantryAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Gantry");
  138. _hasWaferHolder = WaferHolderManager.Instance.HasWaferHolder(Module);
  139. return Runner.Start(Module, "Park");
  140. }
  141. }
  142. }