EFEMAlignRoutine.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. SetAlignFlatType,
  21. WaitAlignFlatTypeIdle,
  22. SetAngle,
  23. ReWaitIdle,
  24. Rotate,
  25. LastWaitIdle,
  26. VacuumOff,
  27. End
  28. }
  29. private int _moveTimeout = 20 * 1000;
  30. EfemBase _efem;
  31. private double angle = 25;
  32. private WaferSize ws = WaferSize.WS12;
  33. private int _angleOffset = 0;
  34. private int _platType = 0;
  35. public EFEMAlignRoutine(EfemBase efem) : base(ModuleName.Aligner1.ToString())
  36. {
  37. _efem = efem;
  38. }
  39. public RState Start(params object[] objs)
  40. {
  41. if (SC.ContainsItem($"EFEM.AlignerOffsetAngle"))
  42. {
  43. _angleOffset = SC.GetValue<int>($"EFEM.AlignerOffsetAngle");
  44. }
  45. if (objs.Length >= 3)
  46. {
  47. try
  48. {
  49. angle = Convert.ToDouble(objs[2]) + _angleOffset;
  50. }
  51. catch
  52. {
  53. LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, Module, $"ALIAN PARAMETER IS ILLEGAL ");
  54. }
  55. }
  56. if (objs.Length >= 4)
  57. {
  58. _platType=(int)objs[3];
  59. }
  60. if (!CheckPreCondition())
  61. {
  62. return RState.Failed;
  63. }
  64. return Runner.Start(Module,$"PreAligner Start align");
  65. }
  66. /// <summary>
  67. /// 检验前置条件
  68. /// </summary>
  69. /// <returns></returns>
  70. private bool CheckPreCondition()
  71. {
  72. if (!WaferManager.Instance.CheckHasWafer(ModuleName.Aligner1, 0))
  73. {
  74. NotifyError(eEvent.ERR_EFEM_ROBOT, $"Efem PreAligner not have wafer, cannot do the align action",0);
  75. return false;
  76. }
  77. return true;
  78. }
  79. public RState Monitor()
  80. {
  81. Runner.Wait(AlignStep.WaitIdle, WaitEFEMIdle)
  82. .Run(AlignStep.SetAlignFlatType, SetAlignerFlatType, CheckAlignDone, _delay_5s)
  83. .Wait(AlignStep.WaitAlignFlatTypeIdle, WaitEFEMIdle)
  84. .Run(AlignStep.SetAngle, SetAlignAngle, CheckAlignDone, _delay_5s)
  85. .Wait(AlignStep.ReWaitIdle, WaitEFEMIdle)
  86. .Run(AlignStep.Rotate, Align, CheckAlignDone, _moveTimeout)
  87. .Wait(AlignStep.LastWaitIdle, WaitEFEMIdle)
  88. //.Run(AlignStep.VacuumOff,VacuumOff,CheckAlignDone,_delay_5s)
  89. .End( AlignStep.End, ActionDone, 0);
  90. return Runner.Status;
  91. }
  92. private bool SetAlignerFlatType()
  93. {
  94. return _efem.SetAlignFlatType(_platType);
  95. }
  96. private bool VacuumOff()
  97. {
  98. return _efem.Vacuum(ModuleName.Aligner1, false);
  99. }
  100. private bool SetAlignAngle()
  101. {
  102. return _efem.SetAlignAngle(ModuleName.Aligner1, angle);
  103. }
  104. private bool Align()
  105. {
  106. return _efem.Align(ModuleName.Aligner1,angle,0,ws);
  107. }
  108. private bool CheckAlignDone()
  109. {
  110. if (_efem.Status == RState.End)
  111. {
  112. return true;
  113. }
  114. else if (_efem.Status == RState.Failed)
  115. {
  116. LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, Module, $"Efem PreAligner align failed: {_efem.Status}");
  117. return true;
  118. }
  119. return false;
  120. }
  121. private bool ActionDone()
  122. {
  123. return true;
  124. }
  125. private bool WaitEFEMIdle()
  126. {
  127. return Singleton<RouteManager>.Instance.EFEM.RobotStatus == RState.End;
  128. }
  129. public void Abort()
  130. {
  131. }
  132. /// <summary>
  133. /// 重试
  134. /// </summary>
  135. /// <param name="step"></param>
  136. public RState Retry(int step)
  137. {
  138. if (!CheckPreCondition())
  139. {
  140. return RState.Failed;
  141. }
  142. _efem.Reset();
  143. List<Enum> preStepIds = new List<Enum>();
  144. return Runner.Retry(AlignStep.WaitIdle, preStepIds, Module, "Align Retry");
  145. }
  146. /// <summary>
  147. /// 检验前面完成状态
  148. /// </summary>
  149. /// <returns></returns>
  150. public bool CheckCompleteCondition(int index)
  151. {
  152. return true;
  153. }
  154. }
  155. }