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 EfemExtendRoutine : ModuleRoutineBase, IStepRoutine { enum RoutineStep { WaitOpenSlitValveInterlock, OpenSlitValve, CheckBeforeExtend, Extend, PrepareTransfer, End, } private ModuleName _source; private int _sourceSlot; private Hand _hand; private int _timeout; //private TMSlitValveRoutine _openSlitValveRoutine = new TMSlitValveRoutine(); private ITransferTarget _target; private EfemModule _robotModule; //private RobotPostionEnum postiontype; public EfemExtendRoutine(EfemModule robotModule) : base("Efem") { Name = "Extend"; _robotModule = robotModule; } private string _type; public void Init(ModuleName source, int sourceSlot, string blade,string type) { _source = source; _sourceSlot = sourceSlot; _hand = (Hand)Enum.Parse(typeof(Hand), blade); _type = type; // _openSlitValveRoutine.Init(source.ToString(), true); } 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 extend, {_source} not ready for transfer"); // return Result.FAIL; // } //} if (ModuleHelper.IsPm(_source)) { if (_type=="Place") { //postiontype = RobotPostionEnum.PlaceExtendUp;//_hand == Hand.Blade1 ? RobotPostionEnum.PlaceExtendDown : RobotPostionEnum.PlaceExtendUp; } else { //postiontype = RobotPostionEnum.PickExtendLow;//_hand == Hand.Blade1 ? RobotPostionEnum.PickExtendLow : RobotPostionEnum.PickExtendUp; } _target = EquipmentManager.Modules[_source] as ITransferTarget; //if (!pm.CheckReadyForTransfer(ModuleName.EfemRobot,_hand, _sourceSlot, EnumTransferType.Extend, out _)) //{ // EV.PostWarningLog(Module, $"can not extend, {_source} not ready for transfer"); // return Result.FAIL; //} } Notify($"Start, extend to {_source} slot {_sourceSlot + 1} with {_hand}"); return Runner.Start(_robotModule.Module, Name); } public void Abort() { Notify("Abort"); } public RState Monitor() { Runner.Run(RoutineStep.Extend, RobotExtend, CheckRobotExtend, _timeout * 1000) .End(RoutineStep.End, NullFun, _delay_50ms); if(Runner.Status == RState.End) Notify($"Finish, extend to {_source} slot {_sourceSlot + 1} with {_hand}"); return Runner.Status; } public bool RobotExtend() { Notify("robot execute extend command"); //string reason; //if (!_robotModule.RobotDevice.GotoRE(chamber, hand, slot,postiontype, out reason)) //{ // Stop(reason); // return false; //} return true; } bool CheckRobotExtend() { return !_robotModule.RobotDevice.IsError && _robotModule.RobotDevice.IsIdle; } } }