123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- using System;
- using Aitex.Core.Common;
- using Aitex.Core.RT.Event;
- 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.Routine;
- using MECF.Framework.Common.Schedulers;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
- using MECF.Framework.RT.EquipmentLibrary.LogicUnits;
- using MECF.Framework.RT.ModuleLibrary.AlignerModules;
- using MECF.Framework.RT.ModuleLibrary.PMModules;
- using MECF.Framework.RT.ModuleLibrary.SystemModules;
- namespace JetEfemLib.Efems
- {
- public class EfemPlaceRoutine : ModuleRoutineBase, IStepRoutine
- {
- enum RoutineStep
- {
- QuerySourceState,
- CheckBeforePlace,
- PlaceWafer,
- CheckBeforePlace2,
- PlaceWafer2,
- PlaceDelay,
- PostTransfer,
- PrepareTransfer,
- PlaceRetract,
- PlaceExtend,
- LiftUp,
- DelayBeforeLiftDown,
- LiftDown,
- DelayAfterLiftDown,
- End,
- }
- private int _delayTimeBeforeAlignerLiftDown;
- private int _delayTimeBeforeCoolingLiftDown;
- private int _timeout;
- private ModuleName _source;
- private int _sourceSlot;
- private Hand _hand;
- private bool _autoHand;
- private EfemModule _robotModule;
- private ITransferTarget _target;
- private int _postTransferTimeout;
- private WaferSize _waferSize = WaferSize.WS0;
- public EfemPlaceRoutine(EfemModule robotModule) : base(ModuleName.EFEM.ToString())
- {
- Name = "Place";
- _robotModule = robotModule;
- }
- public RState Start(params object[] objs)
- {
- if (!_robotModule.EfemDevice.IsInitialized)
- {
- EV.PostAlarmLog(Module, $"EFEM robot is not homed, please home it first");
- return RState.Failed;
- }
- _timeout = SC.GetValue<int>("EFEM.EfemRobot.PlaceTimeout");
- _delayTimeBeforeAlignerLiftDown= SC.GetValue<int>("EFEM.DelayTimeBeforeAlignerLiftDown");
- _delayTimeBeforeCoolingLiftDown= SC.GetValue<int>("EFEM.DelayTimeBeforeCoolingLiftDown");
- Reset();
- if (_autoHand)
- {
- if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
- {
- _hand = Hand.Blade1;
- }
- else if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1))
- {
- _hand = Hand.Blade2;
- }
- else
- {
- EV.PostWarningLog(Module, $"Can not place, Robot both arm no wafer");
- return RState.Failed;
- }
- }
- if (_hand == Hand.Both)
- {
- if (!SC.GetValueOrDefault<bool>("EFEM.EfemRobot.LowerBladeEnable"))
- {
- EV.PostAlarmLog(Module, $"Can not pick, Lower Blade is Disabled");
- return RState.Failed;
- }
- if (!SC.GetValueOrDefault<bool>("EFEM.EfemRobot.UpperBladeEnable"))
- {
- EV.PostAlarmLog(Module, $"Can not pick, Upper Blade is Disabled");
- return RState.Failed;
- }
- if (WaferManager.Instance.GetWafers(_source).Length < 2)
- {
- EV.PostWarningLog(Module, $"Can not place use both arm, Only one slot at {_source}");
- return RState.Failed;
- }
- if (!WaferManager.Instance.CheckNoWafer(_source, _sourceSlot))
- {
- EV.PostWarningLog(Module, $"Can not place, should no wafer at {_source}, {_sourceSlot + 1}");
- return RState.Failed;
- }
- if (!WaferManager.Instance.CheckNoWafer(_source, _sourceSlot + 1))
- {
- EV.PostWarningLog(Module, $"Can not place, should no wafer at {_source}, {_sourceSlot + 1 + 1}");
- return RState.Failed;
- }
- if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)Hand.Blade1))
- {
- EV.PostWarningLog(Module, $"Can not place, Robot arm 1 no wafer");
- return RState.Failed;
- }
- if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)Hand.Blade2))
- {
- EV.PostWarningLog(Module, $"Can not place, Robot arm 2 no wafer");
- return RState.Failed;
- }
- }
- else
- {
- if (_hand == Hand.Blade1 && !SC.GetValueOrDefault<bool>("EFEM.EfemRobot.LowerBladeEnable"))
- {
- EV.PostAlarmLog(Module, $"Can not pick, Lower Blade is Disabled");
- return RState.Failed;
- }
- if (_hand == Hand.Blade2 && !SC.GetValueOrDefault<bool>("EFEM.EfemRobot.UpperBladeEnable"))
- {
- EV.PostAlarmLog(Module, $"Can not pick, Upper Blade is Disabled");
- return RState.Failed;
- }
- if (!WaferManager.Instance.CheckNoWafer(_source, _sourceSlot))
- {
- EV.PostWarningLog(Module, $"Can not place, should no wafer at {_source}, {_sourceSlot + 1}");
- return RState.Failed;
- }
- if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)_hand))
- {
- EV.PostWarningLog(Module, $"Can not place, Robot arm {(int)_hand + 1} no wafer");
- return RState.Failed;
- }
- }
- if (ModuleHelper.IsLoadPort(_source))
- {
- if (WaferManager.Instance.GetWafer(ModuleName.EfemRobot, (int)_hand).Size != CarrierManager.Instance.GetCarrier(_source).CarrierWaferSize)
- {
- EV.PostWarningLog(Module, $"Can not place, Carrier Size and Wafer Size not matched");
- return RState.Failed;
- }
- }
- _waferSize = WaferManager.Instance.GetWafer(_source, _sourceSlot).Size;
- Notify($"Start, Place to {_source} slot {_sourceSlot + 1}, by {_hand}");
- return Runner.Start(ModuleName.EFEM.ToString(), Name);
- }
- //public Result Start(params object[] objs)
- //{
- // return Start((ModuleName)objs[0], (int)objs[1], (Hand)objs[2]);
- //}
- public void Init(ModuleName source, int slot, Hand hand)
- {
- _autoHand = false;
- _source = source;
- _sourceSlot = slot;
- _hand = hand;
- _target = EquipmentManager.Modules[source] as ITransferTarget;
- if (ModuleHelper.IsPm(source))
- _postTransferTimeout = SC.GetValue<int>($"PM.PostTransferTimeout");
- }
- public void Init(ModuleName source, int slot)
- {
- _autoHand = true;
- _source = source;
- _sourceSlot = slot;
- _target = EquipmentManager.Modules[source] as ITransferTarget;
- if (ModuleHelper.IsPm(source))
- _postTransferTimeout = SC.GetValue<int>($"PM.PostTransferTimeout");
- }
- public void Abort()
- {
- if (_target != null)
- {
- _target.NoteTransferStop(ModuleName.EfemRobot, Hand.Blade1, 0, EnumTransferType.Place);
- }
- _target = null;
- Notify("Abort");
- }
- public RState Monitor()
- {
- var delayBeforeLiftDownTime = ModuleHelper.IsAligner(_source) ? _delayTimeBeforeAlignerLiftDown : ModuleHelper.IsCooling(_source) ? _delayTimeBeforeCoolingLiftDown : 0;
- var delayAfterLiftDownTime = (ModuleHelper.IsCooling(_source) || ModuleHelper.IsAligner(_source)) ? _delay_1s : 0;
- if (_hand == Hand.Both)
- {
- Runner.Run(RoutineStep.PrepareTransfer, PrepareTransfer, CheckPrepareTransfer, _postTransferTimeout * 1000)
- .Wait(RoutineStep.CheckBeforePlace, HOFs.Apply(CheckBeforePlace, _source, _sourceSlot, Hand.Blade1))
- .Run(RoutineStep.PlaceWafer, HOFs.Apply(PlaceWafer, _source, _sourceSlot, Hand.Blade1), CheckPlaceWafer, _timeout * 1000)
- .Wait(RoutineStep.CheckBeforePlace2, HOFs.Apply(CheckBeforePlace, _source, _sourceSlot + 1, Hand.Blade2))
- .Run(RoutineStep.PlaceWafer2, HOFs.Apply(PlaceWafer, _source, _sourceSlot + 1, Hand.Blade2), CheckPlaceWafer, _timeout * 1000)
- .Run(RoutineStep.PostTransfer, PostTransfer, CheckPostTransfer, _postTransferTimeout * 1000)
- .Run(RoutineStep.DelayBeforeLiftDown, NullFun, delayBeforeLiftDownTime * 1000)
- .Run(RoutineStep.LiftDown, MovePinDown, CheckMovePinDown, _timeout * 1000)
- .Run(RoutineStep.DelayAfterLiftDown, NullFun, delayAfterLiftDownTime)
- .End(RoutineStep.End, NullFun, _delay_0s);
- }
- else
- {
- Runner.Run(RoutineStep.PrepareTransfer, PrepareTransfer, CheckPrepareTransfer, _postTransferTimeout * 1000)
- .Wait(RoutineStep.CheckBeforePlace, HOFs.Apply(CheckBeforePlace, _source, _sourceSlot, _hand))
- .Run(RoutineStep.PlaceWafer, HOFs.Apply(PlaceWafer, _source, _sourceSlot, _hand), CheckPlaceWafer, _timeout * 1000)
- .Run(RoutineStep.PostTransfer, PostTransfer, CheckPostTransfer, _postTransferTimeout * 1000)
- .Run(RoutineStep.DelayBeforeLiftDown, NullFun, delayBeforeLiftDownTime * 1000)
- .Run(RoutineStep.LiftDown, MovePinDown, CheckMovePinDown, _timeout * 1000)
- .Run(RoutineStep.DelayAfterLiftDown, NullFun, delayAfterLiftDownTime)
- .End(RoutineStep.End, NullFun, _delay_0s);
- }
- if (Runner.Status == RState.End)
- {
- _target.NoteTransferStop(ModuleName.EfemRobot, Hand.Blade1, 0, EnumTransferType.Place);
- Notify($"Finish, Place to {_source} slot {_sourceSlot + 1}, by {_hand}");
- }
- return Runner.Status;
- }
- bool PrepareTransfer()
- {
- if(ModuleHelper.IsPm(_source) && !_target.CheckReadyForTransfer(ModuleName.EfemRobot, _hand, _sourceSlot, EnumTransferType.Place, out _))
- {
- var pm = _target as PMModuleBase;
- var type = EnumTransferType.Place;
- Notify($"{pm.Name} Prepare transfer ");
- if (!pm.PrepareTransfer(ModuleName.EfemRobot, _hand, new int[] { _sourceSlot }, type, 0, 0, false, out string reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }
- return true;
- }
- bool CheckPrepareTransfer()
- {
- if (ModuleHelper.IsPm(_source) && !_target.CheckReadyForTransfer(ModuleName.EfemRobot, _hand, _sourceSlot, EnumTransferType.Place, out _))
- {
- var pm = _target as PMModuleBase;
- return !pm.IsError && pm.IsReady && pm.IsPrepareTransferReady(EnumTransferType.Place, (EnumDualPM)(_sourceSlot + 1), _waferSize);
- }
- return true;
- }
- bool CheckBeforePlace(ModuleName source, int slot, Hand blade)
- {
- Notify("Check place condition");
- string reason = string.Empty;
- if (!_target.CheckReadyForTransfer(ModuleName.EfemRobot, _hand, _sourceSlot, EnumTransferType.Place, out reason))
- {
- Stop(reason);
- return false;
- }
- if (blade == Hand.Blade1)
- {
- if (!WaferManager.Instance.CheckNoWafer(source, slot))
- {
- Stop("Source has wafer");
- return false;
- }
- if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0))
- {
- Stop("Blade 1 no wafer");
- return false;
- }
- }
- else if (blade == Hand.Blade2)
- {
- if (!WaferManager.Instance.CheckNoWafer(source, slot))
- {
- Stop("Source has wafer");
- return false;
- }
- if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1))
- {
- Stop("Blade no wafer");
- return false;
- }
- }
- else
- {
- for (int i = 0; i < 2; i++)
- {
- if (!WaferManager.Instance.CheckNoWafer(source, slot + i))
- {
- Stop("Source has wafer");
- return false;
- }
- if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, i))
- {
- Stop("Blade no wafer");
- return false;
- }
- }
- }
- return true;
- }
- bool PlaceWafer(ModuleName chamber, int slot, Hand hand)
- {
- Notify("robot start execute place command");
- string reason;
- _target.NoteTransferStart(ModuleName.EfemRobot, Hand.Blade1, 0, EnumTransferType.Place);
- if (!_robotModule.RobotDevice.Place(chamber, hand, slot, out reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }
- bool CheckPlaceWafer()
- {
- return !_robotModule.RobotDevice.IsError && _robotModule.RobotDevice.IsIdle;
- }
- bool PostTransfer()
- {
- if(ModuleHelper.IsPm(_source))
- {
- var pm = _target as PMModuleBase;
- var type = EnumTransferType.Place;
- Notify($"{pm.Name} post transfer ");
- if (!pm.PostTransfer(ModuleName.EfemRobot, Hand.Blade1, new int[] { 0 }, 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;
- }
- bool MovePinDown()
- {
- if(ModuleHelper.IsCooling(_source) || ModuleHelper.IsAligner(_source))
- {
- AlignerModuleBase aligner = _target as AlignerModuleBase;
- Notify($"{aligner.Name} lift pin down");
- return aligner.Lift(false);
- }
- return true;
- }
- bool CheckMovePinDown()
- {
- if (ModuleHelper.IsCooling(_source) || ModuleHelper.IsAligner(_source))
- {
- var aligner = _target as AlignerModuleBase;
- return aligner.IsReady;
- }
- return true;
- }
- }
- }
|