| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 | 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.TM)        {            _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<RouteManager>.Instance.GetPM(_targetModule);            }            else            {                LOG.Write(eEvent.ERR_TM, Module, $"Invalid target module : {_targetModule} for picking action");                return RState.Failed;            }            if (_pmModule.IsSlitDoorClose)            {                LOG.Write(eEvent.ERR_TM, Module, $"{_targetModule} slit door closed, can not extend robot arm");                return RState.Failed;            }            Reset();            _extendingTimeout = SC.GetValue<int>($"{Module}.ExtendTimeout") * 1000;            return Runner.Start(Module, Name);        }        public RState Monitor()        {            Runner.Run((int)RetractStep.ArmRetract, ArmRetract, WaitRobotExtendDone)                .End((int)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();        }    }}
 |