EFEMAlignRoutine.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.SubstrateTrackings;
  6. using System;
  7. using System.Collections.Generic;
  8. using CyberX8_Core;
  9. using CyberX8_RT.Devices.EFEM;
  10. using Aitex.Core.Util;
  11. using MECF.Framework.Common.Routine;
  12. using Aitex.Core.RT.SCCore;
  13. namespace CyberX8_RT.Modules.EFEM
  14. {
  15. public class EFEMAlignRoutine : RoutineBase, IRoutine
  16. {
  17. private enum AlignStep
  18. {
  19. WaitIdle,
  20. SetAngle,
  21. ReWaitIdle,
  22. Rotate,
  23. End
  24. }
  25. private int _moveTimeout = 20 * 1000;
  26. EfemBase _efem;
  27. private double angle = 25;
  28. private WaferSize ws = WaferSize.WS12;
  29. private int _angleOffset = 0;
  30. public EFEMAlignRoutine(EfemBase efem) : base(ModuleName.Aligner1.ToString())
  31. {
  32. _efem = efem;
  33. }
  34. public RState Start(params object[] objs)
  35. {
  36. if (SC.ContainsItem($"EFEM.AlignerOffsetAngle"))
  37. {
  38. _angleOffset = SC.GetValue<int>($"EFEM.AlignerOffsetAngle");
  39. }
  40. if (objs.Length >= 3)
  41. {
  42. try
  43. {
  44. angle = Convert.ToDouble(objs[2]) + _angleOffset;
  45. }
  46. catch
  47. {
  48. LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, Module, $"ALIAN PARAMETER IS ILLEGAL ");
  49. }
  50. }
  51. if (!CheckPreCondition())
  52. {
  53. return RState.Failed;
  54. }
  55. return Runner.Start(Module,$"PreAligner Start align");
  56. }
  57. /// <summary>
  58. /// 检验前置条件
  59. /// </summary>
  60. /// <returns></returns>
  61. private bool CheckPreCondition()
  62. {
  63. if (!WaferManager.Instance.CheckHasWafer(ModuleName.Aligner1, 0))
  64. {
  65. NotifyError(eEvent.ERR_EFEM_ROBOT, $"Efem PreAligner not have wafer, cannot do the align action",0);
  66. return false;
  67. }
  68. return true;
  69. }
  70. public RState Monitor()
  71. {
  72. Runner.Wait(AlignStep.WaitIdle, WaitEFEMIdle)
  73. .Run(AlignStep.SetAngle,SetAlignAngle,CheckAlignDone,_delay_5s)
  74. .Wait(AlignStep.ReWaitIdle, WaitEFEMIdle)
  75. .Run(AlignStep.Rotate, Align, CheckAlignDone, _moveTimeout)
  76. .End( AlignStep.End, ActionDone, 0);
  77. return Runner.Status;
  78. }
  79. private bool SetAlignAngle()
  80. {
  81. return _efem.SetAlignAngle(ModuleName.Aligner1, angle);
  82. }
  83. private bool Align()
  84. {
  85. return _efem.Align(ModuleName.Aligner1,angle,0,ws);
  86. }
  87. private bool CheckAlignDone()
  88. {
  89. if (_efem.Status == RState.End)
  90. {
  91. return true;
  92. }
  93. else if (_efem.Status == RState.Failed)
  94. {
  95. LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, Module, $"Efem PreAligner align failed: {_efem.Status}");
  96. return true;
  97. }
  98. return false;
  99. }
  100. private bool ActionDone()
  101. {
  102. return true;
  103. }
  104. private bool WaitEFEMIdle()
  105. {
  106. return Singleton<RouteManager>.Instance.EFEM.RobotStatus == RState.End;
  107. }
  108. public void Abort()
  109. {
  110. }
  111. /// <summary>
  112. /// 重试
  113. /// </summary>
  114. /// <param name="step"></param>
  115. public RState Retry(int step)
  116. {
  117. if (!CheckPreCondition())
  118. {
  119. return RState.Failed;
  120. }
  121. _efem.Reset();
  122. List<Enum> preStepIds = new List<Enum>();
  123. return Runner.Retry(AlignStep.WaitIdle, preStepIds, Module, "Align Retry");
  124. }
  125. /// <summary>
  126. /// 检验前面完成状态
  127. /// </summary>
  128. /// <returns></returns>
  129. public bool CheckCompleteCondition(int index)
  130. {
  131. return true;
  132. }
  133. }
  134. }