123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- 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<int>("EFEM.EfemRobot.PickTimeout");
- //if (ModuleHelper.IsLoadLock(_source))
- //{
- // LoadLock ll = DEVICE.GetDevice<LoadLock>(_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<PMModule>(_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;
- }
- }
- }
|