using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Sorter.Common; using Venus_RT.Devices; using MECF.Framework.Common.Routine; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using Venus_Core; using Aitex.Core.RT.Log; using Aitex.Core.Util; using Venus_RT.Modules.PMs; namespace Venus_RT.Modules.TM { class MFPMRetractRoutine : ModuleRoutineBase, IRoutine { private enum RetractStep { ArmRetract, End, } private readonly JetTM _JetTM; private readonly ITransferRobot _robot; private int _extendingTimeout = 120 * 1000; private ModuleName _targetModule; private PMEntity _pmModule; int _targetSlot; Hand _hand; public MFPMRetractRoutine(JetTM tm, ITransferRobot robot) : base(ModuleName.TMRobot) { _JetTM = tm; _robot = robot; Name = "Retract from PM"; } public RState Start(params object[] objs) { if (!_robot.IsHomed) { LOG.Write(eEvent.ERR_TM, Module, $"TM Robot is not homed, please home it first"); return RState.Failed; } _targetModule = (ModuleName)objs[0]; _targetSlot = (int)objs[1]; _hand = (Hand)objs[2]; if (ModuleHelper.IsPm(_targetModule) && ModuleHelper.IsInstalled(_targetModule)) { _pmModule = Singleton.Instance.GetPM(_targetModule); } else { LOG.Write(eEvent.ERR_TM, Module, $"Invalid target module : {_targetModule} for retract action"); return RState.Failed; } if (_pmModule.IsSlitDoorClose) { LOG.Write(eEvent.ERR_TM, Module, $"{_targetModule} slit door closed, can not retract robot arm"); return RState.Failed; } Reset(); _extendingTimeout = SC.GetValue($"{Module}.ExtendTimeout") * 1000; return Runner.Start(Module, $"Retract from {_targetModule}"); } public RState Monitor() { Runner.Run(RetractStep.ArmRetract, ArmRetract, WaitRobotExtendDone) .End(RetractStep.End, NullFun, _delay_50ms); return Runner.Status; } private bool ArmRetract() { if (WaferManager.Instance.CheckHasWafer(_targetModule, _targetSlot)) { return _robot.PickRetract(_targetModule, _targetSlot, _hand); } else { return _robot.PlaceRetract(_targetModule, _targetSlot, _hand); } } private bool WaitRobotExtendDone() { if (_robot.Status == RState.Running) { return false; } else if (_robot.Status == RState.End) { return true; } else { Runner.Stop($"TM Robot Arm Retract failed, {_robot.Status}"); return true; } } public void Abort() { //_robot.Halt(); } } }