PufReadyForSwapRoutine.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using MECF.Framework.Common.Routine;
  4. using CyberX8_Core;
  5. using CyberX8_RT.Devices.AXIS;
  6. using CyberX8_RT.Devices.PUF;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using Aitex.Core.RT.Log;
  13. using MECF.Framework.Common.Utilities;
  14. namespace CyberX8_RT.Modules.PUF
  15. {
  16. public class PufReadyForSwapRoutine : RoutineBase, IRoutine
  17. {
  18. private enum ReadyForSwapStep
  19. {
  20. VacuumOn,
  21. RotationPark,
  22. RotationParkWait,
  23. VerticalPark,
  24. VerticalParkWait,
  25. End
  26. }
  27. #region 常量
  28. private const string WAFER_PRESENT = "WaferPresent";
  29. #endregion
  30. #region 内部变量
  31. private JetAxisBase _rotationAxis;
  32. private JetAxisBase _verticalAxis;
  33. private PufVacuum _vacuum;
  34. #endregion
  35. /// <summary>
  36. /// 构造函数
  37. /// </summary>
  38. /// <param name="module"></param>
  39. public PufReadyForSwapRoutine(string module) : base(module)
  40. {
  41. }
  42. /// <summary>
  43. /// 中止
  44. /// </summary>
  45. public void Abort()
  46. {
  47. Runner.Stop("Manual Abort");
  48. }
  49. /// <summary>
  50. /// 监控
  51. /// </summary>
  52. /// <returns></returns>
  53. public RState Monitor()
  54. {
  55. Runner.Run(ReadyForSwapStep.VacuumOn, VacuumBOn, CheckWaferPresence, _delay_5s)
  56. .Run(ReadyForSwapStep.RotationPark, RotationGotoPark, _delay_1ms)
  57. .WaitWithStopCondition(ReadyForSwapStep.RotationParkWait, () => _rotationAxis.Status == RState.End, CheckRotationStopStatus)
  58. .Run(ReadyForSwapStep.VerticalPark, VerticalGotoPark, _delay_1ms)
  59. .WaitWithStopCondition(ReadyForSwapStep.VerticalParkWait, () => _verticalAxis.Status == RState.End, CheckVerticalStopStatus)
  60. .End(ReadyForSwapStep.End, NullFun, _delay_1ms);
  61. return Runner.Status;
  62. }
  63. /// <summary>
  64. /// Vacuum B On
  65. /// </summary>
  66. /// <returns></returns>
  67. private bool VacuumBOn()
  68. {
  69. bool result = _vacuum.VacuumBOn();
  70. if(!result)
  71. {
  72. NotifyError(eEvent.ERR_PUF, "side B Vacuum on failed", 0);
  73. }
  74. return result;
  75. }
  76. /// <summary>
  77. /// 检验是否存在Wafer
  78. /// </summary>
  79. /// <returns></returns>
  80. private bool CheckWaferPresence()
  81. {
  82. return _vacuum.ChuckBVacuumStatus == WAFER_PRESENT;
  83. }
  84. /// <summary>
  85. /// Rotation Goto Park
  86. /// </summary>
  87. /// <returns></returns>
  88. private bool RotationGotoPark()
  89. {
  90. bool result = _rotationAxis.PositionStation("Park");
  91. if (!result)
  92. {
  93. NotifyError(eEvent.ERR_PUF, "rotation goto park failed", 0);
  94. }
  95. return result;
  96. }
  97. /// <summary>
  98. /// 检验Rotation异常状态
  99. /// </summary>
  100. /// <returns></returns>
  101. private bool CheckRotationStopStatus()
  102. {
  103. bool result = _rotationAxis.Status == RState.Failed || _rotationAxis.Status == RState.Timeout;
  104. if (result)
  105. {
  106. NotifyError(eEvent.ERR_PUF, "rotaion motion failed", 0);
  107. }
  108. return result;
  109. }
  110. /// <summary>
  111. /// Vertical Goto Park
  112. /// </summary>
  113. /// <returns></returns>
  114. private bool VerticalGotoPark()
  115. {
  116. bool result = _verticalAxis.PositionStation("Park");
  117. if (!result)
  118. {
  119. NotifyError(eEvent.ERR_PUF, "vertical goto park failed", 0);
  120. }
  121. return result;
  122. }
  123. /// <summary>
  124. /// 检验Vertical异常状态
  125. /// </summary>
  126. /// <returns></returns>
  127. private bool CheckVerticalStopStatus()
  128. {
  129. bool result = _verticalAxis.Status == RState.Failed || _verticalAxis.Status == RState.Timeout;
  130. if (result)
  131. {
  132. NotifyError(eEvent.ERR_PUF, "vertical motion failed", 0);
  133. }
  134. return result;
  135. }
  136. /// <summary>
  137. /// 启动
  138. /// </summary>
  139. /// <param name="objs"></param>
  140. /// <returns></returns>
  141. public RState Start(params object[] objs)
  142. {
  143. InitializeParameters();
  144. return Runner.Start(Module, "Start Go to Park For Swap");
  145. }
  146. /// <summary>
  147. /// 初始化参数
  148. /// </summary>
  149. private void InitializeParameters()
  150. {
  151. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  152. _verticalAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Vertical");
  153. _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
  154. }
  155. /// <summary>
  156. /// 重试
  157. /// </summary>
  158. /// <param name="step"></param>
  159. public RState Retry(int step)
  160. {
  161. InitializeParameters();
  162. List<Enum> preStepIds = new List<Enum>();
  163. return Runner.Retry(ReadyForSwapStep.VacuumOn, preStepIds, Module, "ReadyForSwap Retry");
  164. }
  165. /// <summary>
  166. /// 检验完成情况
  167. /// </summary>
  168. /// <returns></returns>
  169. public bool CheckCompleteCondition()
  170. {
  171. double rotationPosition = _rotationAxis.MotionData.MotorPosition;
  172. if (!_rotationAxis.CheckPositionIsInStation(rotationPosition, "Park"))
  173. {
  174. NotifyError(eEvent.ERR_PUF, $"rotation {rotationPosition} not in Park", 0);
  175. return false;
  176. }
  177. double verticalPosition = _verticalAxis.MotionData.MotorPosition;
  178. if (!_verticalAxis.CheckPositionIsInStation(verticalPosition, "Park"))
  179. {
  180. NotifyError(eEvent.ERR_PUF, $"vertical {verticalPosition} not in Park", 0);
  181. return false;
  182. }
  183. return true;
  184. }
  185. }
  186. }