MFPMRetractRoutine.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Aitex.Sorter.Common;
  4. using Venus_RT.Devices;
  5. using MECF.Framework.Common.Routine;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.SubstrateTrackings;
  8. using Venus_Core;
  9. using Aitex.Core.RT.Log;
  10. using Aitex.Core.Util;
  11. using Venus_RT.Modules.PMs;
  12. namespace Venus_RT.Modules.TM
  13. {
  14. class MFPMRetractRoutine : ModuleRoutineBase, IRoutine
  15. {
  16. private enum RetractStep
  17. {
  18. ArmRetract,
  19. End,
  20. }
  21. private readonly JetTM _JetTM;
  22. private readonly ITransferRobot _robot;
  23. private int _extendingTimeout = 120 * 1000;
  24. private ModuleName _targetModule;
  25. private PMEntity _pmModule;
  26. int _targetSlot;
  27. Hand _hand;
  28. public MFPMRetractRoutine(JetTM tm, ITransferRobot robot) : base(ModuleName.TM)
  29. {
  30. _JetTM = tm;
  31. _robot = robot;
  32. Name = "Retract from PM";
  33. }
  34. public RState Start(params object[] objs)
  35. {
  36. if (!_robot.IsHomed)
  37. {
  38. LOG.Write(eEvent.ERR_TM, Module, $"TM Robot is not homed, please home it first");
  39. return RState.Failed;
  40. }
  41. _targetModule = (ModuleName)objs[0];
  42. _targetSlot = (int)objs[1];
  43. _hand = (Hand)objs[2];
  44. if (ModuleHelper.IsPm(_targetModule) && ModuleHelper.IsInstalled(_targetModule))
  45. {
  46. _pmModule = Singleton<RouteManager>.Instance.GetPM(_targetModule);
  47. }
  48. else
  49. {
  50. LOG.Write(eEvent.ERR_TM, Module, $"Invalid target module : {_targetModule} for retract action");
  51. return RState.Failed;
  52. }
  53. if (_pmModule.IsSlitDoorClose)
  54. {
  55. LOG.Write(eEvent.ERR_TM, Module, $"{_targetModule} slit door closed, can not retract robot arm");
  56. return RState.Failed;
  57. }
  58. Reset();
  59. _extendingTimeout = SC.GetValue<int>($"{Module}.ExtendTimeout") * 1000;
  60. return Runner.Start(Module, Name);
  61. }
  62. public RState Monitor()
  63. {
  64. Runner.Run((int)RetractStep.ArmRetract, ArmRetract, WaitRobotExtendDone)
  65. .End((int)RetractStep.End, NullFun, _delay_50ms);
  66. return Runner.Status;
  67. }
  68. private bool ArmRetract()
  69. {
  70. if (WaferManager.Instance.CheckHasWafer(_targetModule, _targetSlot))
  71. {
  72. return _robot.PickRetract(_targetModule, _targetSlot, _hand);
  73. }
  74. else
  75. {
  76. return _robot.PlaceRetract(_targetModule, _targetSlot, _hand);
  77. }
  78. }
  79. private bool WaitRobotExtendDone()
  80. {
  81. if (_robot.Status == RState.Running)
  82. {
  83. return false;
  84. }
  85. else if (_robot.Status == RState.End)
  86. {
  87. return true;
  88. }
  89. else
  90. {
  91. Runner.Stop($"TM Robot Arm Retract failed, {_robot.Status}");
  92. return true;
  93. }
  94. }
  95. public void Abort()
  96. {
  97. _robot.Halt();
  98. }
  99. }
  100. }