using System; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using Aitex.Sorter.Common; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Schedulers; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots; using MECF.Framework.RT.EquipmentLibrary.LogicUnits; using MECF.Framework.RT.ModuleLibrary.PMModules; using MECF.Framework.RT.ModuleLibrary.SystemModules; namespace JetEfemLib.Efems { class EfemRetractRoutine : ModuleRoutineBase, IStepRoutine { enum RoutineStep { CheckBeforeRetract, Retract, WaitCloseSlitValveInterlock, CloseSlitValve, PostTransfer, End, } private ModuleName _source; private int _sourceSlot; private Hand _blade; private int _timeout; // private TMSlitValveRoutine _closeSlitValveRoutine = new TMSlitValveRoutine(); private EfemModule _robotModule; //private RobotPostionEnum postiontype; private ITransferTarget _target; public EfemRetractRoutine(EfemModule robotModule) : base(ModuleName.EfemRobot.ToString()) { Name = "Retract"; _robotModule = robotModule; } private string _type; public void Init(ModuleName source, int sourceSlot, string blade,string type) { _source = source; _sourceSlot = sourceSlot; _blade = (Hand)Enum.Parse(typeof(Hand), blade); _type = type; //_closeSlitValveRoutine.Init(source.ToString(), false); } public void Init(ModuleName source, int sourceSlot, int blade) { Init(source, sourceSlot, blade); } public RState Start(params object[] objs) { Reset(); _timeout = SC.GetValue("EFEM.EfemRobot.PickTimeout"); //if (ModuleHelper.IsLoadLock(_source)) //{ // LoadLock ll = DEVICE.GetDevice(_source.ToString()); // if (!ll.CheckEnableTransfer(EnumTransferType.Extend)) // { // EV.PostWarningLog(Module, $"can not retract, {_source} not ready for transfer"); // return Result.FAIL; // } //} if (ModuleHelper.IsPm(_source)) { if (_type=="Pick") { //postiontype = RobotPostionEnum.PickRetracted;// _blade == Hand.Blade1 ?RobotPostionEnum.PickRetractLow: RobotPostionEnum.PickRetractUp; } else { //postiontype = RobotPostionEnum.PlaceRetract;//_blade == Hand.Blade1 ? RobotPostionEnum.PlaceRetractLow : RobotPostionEnum.PlaceRetractUp; } // PMModuleBase pm = DEVICE.GetDevice(_source.ToString()+"."+ _source.ToString()); _target = EquipmentManager.Modules[_source] as ITransferTarget; //if (!pm.CheckReadyForTransfer(ModuleName.EfemRobot, _blade, _sourceSlot, EnumTransferType.Retract, out _)) //{ // EV.PostWarningLog(Module, $"can not retract, {_source} not ready for transfer"); // return Result.FAIL; //} } Notify($"Start, retract from {_source} slot {_sourceSlot + 1} with {_blade}"); return Runner.Start(ModuleName.EfemRobot.ToString(), Name); } public void Abort() { Notify("Abort"); } public RState Monitor() { Runner.Run(RoutineStep.Retract, RobotRetract, CheckRobotRetract, _timeout * 1000) .Run(RoutineStep.PostTransfer, PostTransfer, CheckPostTransfer, _timeout * 1000) .End(RoutineStep.End, NullFun, _delay_50ms); if (Runner.Status == RState.End) Notify($"Finish, retract from {_source} slot {_sourceSlot + 1} with {_blade}"); return Runner.Status; } bool RobotRetract() { Notify("robot execute goto command"); //string reason; //if (!_robotModule.RobotDevice.GotoRE(chamber, hand, slot, postiontype, out reason)) //{ // Stop(reason); // return false; //} return true; } bool CheckRobotRetract() { return !_robotModule.RobotDevice.IsError && _robotModule.RobotDevice.IsIdle; } bool PostTransfer() { if (ModuleHelper.IsPm(_source)) { var pm = _target as PMModuleBase; var type = EnumTransferType.Retract; Notify($"{pm.Name} post transfer "); if (!pm.PostTransfer(ModuleName.EfemRobot, _blade, new int[] { _sourceSlot }, type, out string reason)) { Stop(reason); return false; } return true; } return true; } bool CheckPostTransfer() { if (ModuleHelper.IsPm(_source)) { var pm = _target as PMModuleBase; return !pm.IsError && pm.IsReady; } return true; } } }