PufHomeAllRoutine.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using MECF.Framework.Common.Equipment;
  4. using MECF.Framework.Common.Utilities;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Devices.AXIS;
  7. using CyberX8_RT.Devices.PUF;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using CyberX8_RT.Devices.Safety;
  14. using Aitex.Core.RT.Log;
  15. namespace CyberX8_RT.Modules.PUF
  16. {
  17. public class PufHomeAllRoutine : ModuleRoutineBase, IRoutine
  18. {
  19. private enum PufHomeAllStep
  20. {
  21. CheckWafer,
  22. ChuckIn,
  23. WaitChuck,
  24. RotationHome,
  25. CheckRotationHome,
  26. RotationHomeStation,
  27. RotationHomeStationWait,
  28. FlipHome,
  29. CheckFlipHome,
  30. FlipSideA,
  31. FlipSideAWait,
  32. End
  33. }
  34. #region 内部变量
  35. private JetAxisBase _flipAxis;
  36. private JetAxisBase _rotationAxis;
  37. private PUFEntity _pufEntity;
  38. private PufChuckRoutine _chuckRoutine;
  39. #endregion
  40. public PufHomeAllRoutine(ModuleName module,PUFEntity pufEntity) : base(module)
  41. {
  42. _flipAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.Flip");
  43. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.Rotation");
  44. _chuckRoutine = new PufChuckRoutine(module.ToString());
  45. _pufEntity = pufEntity;
  46. Name = "Home";
  47. }
  48. public void Abort()
  49. {
  50. Runner.Stop("Manual Abort");
  51. }
  52. public RState Monitor()
  53. {
  54. Runner.Run(PufHomeAllStep.CheckWafer, () => { return !_pufEntity.SideAWaferPresent && !_pufEntity.SideBWaferPresent; },NullFun,100)
  55. .Run(PufHomeAllStep.ChuckIn, () => _chuckRoutine.Start(false) == RState.Running, _delay_1ms)
  56. .WaitWithStopCondition(PufHomeAllStep.WaitChuck, () => CommonFunction.CheckRoutineEndState(_chuckRoutine),
  57. CheckChuckStopStatus)
  58. .Run(PufHomeAllStep.RotationHome, RotationAxisHome, _delay_1ms)
  59. .WaitWithStopCondition(PufHomeAllStep.CheckRotationHome, CheckRotationPositionStatus, CheckRotationPositionRunStop)
  60. .Run(PufHomeAllStep.RotationHomeStation, () => { return _rotationAxis.PositionStation("Home",true); }, NullFun, 100)
  61. .WaitWithStopCondition(PufHomeAllStep.RotationHomeStationWait, CheckRotationPositionStatus, CheckRotationPositionRunStop)
  62. .Run(PufHomeAllStep.FlipHome, FlipAxisHome, _delay_1ms)
  63. .WaitWithStopCondition(PufHomeAllStep.CheckFlipHome, CheckFlipPositionStatus, CheckFlipPositionRunStop)
  64. .Run(PufHomeAllStep.FlipSideA, () => { return _flipAxis.PositionStation("SideA", true); }, NullFun, 100)
  65. .WaitWithStopCondition(PufHomeAllStep.FlipSideAWait, CheckFlipPositionStatus, CheckFlipPositionRunStop)
  66. .End(PufHomeAllStep.End,NullFun);
  67. return Runner.Status;
  68. }
  69. /// <summary>
  70. /// 检验chuck routine停止状态
  71. /// </summary>
  72. /// <returns></returns>
  73. private bool CheckChuckStopStatus()
  74. {
  75. bool result = CommonFunction.CheckRoutineStopState(_chuckRoutine);
  76. if (result)
  77. {
  78. LOG.WriteLog(eEvent.ERR_PUF,Module.ToString(), _chuckRoutine.ErrorMsg);
  79. }
  80. return result;
  81. }
  82. /// <summary>
  83. /// Flip Home
  84. /// </summary>
  85. /// <returns></returns>
  86. private bool FlipAxisHome()
  87. {
  88. return _flipAxis.Home();
  89. }
  90. /// <summary>
  91. /// 检验Flip home状态
  92. /// </summary>
  93. /// <returns></returns>
  94. private bool CheckFlipHome()
  95. {
  96. return _flipAxis.IsHomed && _flipAxis.Status == RState.End;
  97. }
  98. /// <summary>
  99. /// 检验Flip移动状态
  100. /// </summary>
  101. /// <returns></returns>
  102. private bool CheckFlipPositionStatus()
  103. {
  104. return _flipAxis.Status == RState.End;
  105. }
  106. /// <summary>
  107. /// 检验Flip是否还在运动
  108. /// </summary>
  109. /// <returns></returns>
  110. private bool CheckFlipPositionRunStop()
  111. {
  112. return _flipAxis.Status == RState.Failed;
  113. }
  114. /// <summary>
  115. /// rotation home
  116. /// </summary>
  117. /// <returns></returns>
  118. private bool RotationAxisHome()
  119. {
  120. return _rotationAxis.Home();
  121. }
  122. /// <summary>
  123. /// rotation Home状态
  124. /// </summary>
  125. /// <returns></returns>
  126. private bool CheckRotationHome()
  127. {
  128. return _rotationAxis.IsHomed&&_rotationAxis.Status==RState.End;
  129. }
  130. /// <summary>
  131. /// 检验Rotation移动状态
  132. /// </summary>
  133. /// <returns></returns>
  134. private bool CheckRotationPositionStatus()
  135. {
  136. return _rotationAxis.Status == RState.End;
  137. }
  138. /// <summary>
  139. /// 检验Rotation是否还在运动
  140. /// </summary>
  141. /// <returns></returns>
  142. private bool CheckRotationPositionRunStop()
  143. {
  144. return _rotationAxis.Status == RState.Failed;
  145. }
  146. /// <summary>
  147. /// 启动
  148. /// </summary>
  149. /// <param name="objs"></param>
  150. /// <returns></returns>
  151. public RState Start(params object[] objs)
  152. {
  153. Runner.Start(Module, Name);
  154. return RState.Running;
  155. }
  156. }
  157. }