123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- using System;
- 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.Schedulers;
- using MECF.Framework.Common.SubstrateTrackings;
- 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
- {
- public class EfemPickAndPlaceRoutine : ModuleRoutineBase, IStepRoutine
- {
- enum RoutineStep
- {
- CheckBeforePick,
- PickWafer,
- CheckBeforePlace,
- PlaceWafer,
- PostTransfer,
- PickExtend,
- PickRetract,
- PlaceExtend,
- PlaceRetract,
- PickLiftUp,
- PickLiftDown,
- PlaceLiftUp,
- PlaceLiftDown,
- End,
- }
- private EfemModule _robotModule;
- private ITransferTarget _target;
- private Hand _pickBlade;
- private Hand _placeBlade;
- private ModuleName _targetModule;
- private int _pickSlot;
- private int _placeSlot;
- private int _pickTimeout;
- private int _placeTimeout;
- private int _postTransferTimeout;
- public EfemPickAndPlaceRoutine(EfemModule robotModule) : base(ModuleName.EfemRobot.ToString())
- {
- Name = "Pick";
- _robotModule = robotModule;
- }
- public RState Start(params object[] objs)
- {
- _pickTimeout = SC.GetValue<int>("EFEM.EfemRobot.PickTimeout") * 1000;
- _placeTimeout = SC.GetValue<int>("EFEM.EfemRobot.PlaceTimeout");
- if (ModuleHelper.IsPm(_targetModule))
- {
- _postTransferTimeout = SC.GetValue<int>($"PM.PostTransferTimeout");
- }
- Reset();
- if (!WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)_pickBlade))
- {
- EV.PostWarningLog(Module, $"Can not pick by {_pickBlade}, found wafer on");
- return RState.Failed;
- }
- if (!WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)_placeBlade))
- {
- EV.PostWarningLog(Module, $"Can not place by {_placeBlade}, no wafer on");
- return RState.Failed;
- }
- if (_pickSlot != _placeSlot)
- {
- if (!WaferManager.Instance.CheckHasWafer(_targetModule, _pickSlot))
- {
- EV.PostWarningLog(Module, $"Can not pick from {_targetModule} slot {_pickSlot + 1}, no wafer on");
- return RState.Failed;
- }
- if (!WaferManager.Instance.CheckNoWafer(_targetModule, _placeSlot))
- {
- EV.PostWarningLog(Module, $"Can not place to {_targetModule} slot {_placeSlot + 1}, found wafer on");
- return RState.Failed;
- }
- }
- else
- {
- if (!WaferManager.Instance.CheckHasWafer(_targetModule, _placeSlot))
- {
- {
- EV.PostWarningLog(Module, $"Can not pick&place from {_targetModule} slot {_placeSlot + 1}, no wafer on");
- return RState.Failed;
- }
- }
- }
- Notify($"Start, swap wafer,pick: {_pickBlade} slot {_pickSlot + 1}, place: {_placeBlade} slot {_placeSlot+1}");
- return Runner.Start(ModuleName.EfemRobot.ToString(), Name);
- }
- public void Init(ModuleName targetModule, Hand pickBlade, int pickSlot, Hand placeBlade, int placeSlot)
- {
- _pickBlade = pickBlade;
- _placeBlade = placeBlade;
- _targetModule = targetModule;
- _pickSlot = pickSlot;
- _placeSlot = placeSlot;
- //_target = Singleton<EquipmentManager>.Instance.Modules[targetModule] as ITransferTarget;
- }
- public void Abort()
- {
- if (_target != null)
- {
- _target.NoteTransferStop(ModuleName.EfemRobot, Hand.Blade1, 0, EnumTransferType.Pick);
- }
- _target = null;
- Notify("Abort");
- }
- public RState Monitor()
- {
- if (ModuleHelper.IsPm(_targetModule))
- {
- Runner.Wait(RoutineStep.CheckBeforePick, CheckBeforePick)
- .Run(RoutineStep.PickExtend, RobotExtendForPick, CheckRobotExtend, _pickTimeout)
- .Run(RoutineStep.PickLiftDown, MovePinDown, CheckMovePinDown, _pickTimeout)
- .Run(RoutineStep.PickRetract, RobotRetractForPick, CheckRobotRetract, _pickTimeout)
- .Run(RoutineStep.PlaceExtend, RobotExtendForPlace, CheckRobotExtend, _pickTimeout)
- .Run(RoutineStep.PlaceLiftUp, MovePinUp, CheckMovePinUp, _pickTimeout)
- .Run(RoutineStep.PlaceRetract, RobotRetractForPlace, CheckRobotRetract, _pickTimeout)
- .Run(RoutineStep.PostTransfer, PostTransfer, CheckPostTransfer, _postTransferTimeout)
- .End(RoutineStep.End, NullFun, _delay_50ms);
- }
- else
- {
- Runner.Wait(RoutineStep.CheckBeforePick, CheckBeforePick)
- .Run(RoutineStep.PickWafer, PickWafer, CheckPickWafer, _pickTimeout)
- .Wait(RoutineStep.CheckBeforePlace, CheckBeforePlace)
- .Run(RoutineStep.PlaceWafer, PlaceWafer, CheckPlaceWafer, _pickTimeout)
- .End(RoutineStep.End, NullFun, _delay_50ms);
- }
- if (Runner.Status == RState.End)
- {
- _target.NoteTransferStop(ModuleName.EfemRobot, Hand.Blade1, 0, EnumTransferType.Pick);
- Notify($"complete, swap wafer,pick: {_pickBlade} slot {_pickSlot + 1}, place: {_placeBlade} slot {_placeSlot + 1}");
- }
- return Runner.Status;
- }
- bool CheckBeforePick()
- {
- var blade = _pickBlade;
- var slot = _pickSlot;
- var source = _targetModule;
- Notify("Check pick is enabled");
- string reason = string.Empty;
- if (!_target.CheckReadyForTransfer(ModuleName.EfemRobot, blade, slot, EnumTransferType.Pick, out reason))
- {
- Stop(reason);
- return false;
- }
- if (blade == Hand.Blade1)
- {
- if (!WaferManager.Instance.CheckHasWafer(source, slot))
- {
- Stop("Source no wafer");
- return false;
- }
- if (!WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0))
- {
- Stop("Blade has wafer");
- return false;
- }
- }
- else if (blade == Hand.Blade2)
- {
- if (!WaferManager.Instance.CheckHasWafer(source, slot))
- {
- Stop("Source no wafer");
- return false;
- }
- if (!WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 1))
- {
- Stop("Blade has wafer");
- return false;
- }
- }
- else
- {
- for (int i = 0; i < 2; i++)
- {
- if (!WaferManager.Instance.CheckHasWafer(source, slot + i))
- {
- Stop("Source no wafer");
- return false;
- }
- if (!WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, i))
- {
- Stop("Blade has wafer");
- return false;
- }
- }
- }
- return true;
- }
- bool RobotExtendForPick()
- {
- Notify("robot execute goto command");
- var chamber = _targetModule;
- var slot = _pickSlot;
- var hand = _pickBlade;
- var robotPostion = RobotPostionEnum.PickExtendLow;
- //string reason;
- //if (!_robotModule.RobotDevice.GotoRE(chamber, hand, slot, robotPostion, out reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }
- bool CheckRobotExtend()
- {
- return !_robotModule.RobotDevice.IsError && _robotModule.RobotDevice.IsIdle;
- }
- bool MovePinDown()
- {
- var pm = _target as PMModuleBase;
- Notify($"{pm.Name} lift pin down");
- //if (!pm.ChamberLiftPin.MoveDown(out string reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }
- bool CheckMovePinDown()
- {
- var pm = _target as PMModuleBase;
- //if (pm.ChamberLiftPin.IsDown)
- // return true;
- return false;
- }
- bool RobotRetractForPick()
- {
- Notify("robot execute goto command");
- var chamber = _targetModule;
- var slot = _pickSlot;
- var hand = _pickBlade;
- var robotPostion = RobotPostionEnum.PickRetracted;
- //string reason;
- //if (!_robotModule.RobotDevice.GotoRE(chamber, hand, slot, robotPostion, out reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }
- bool CheckRobotRetract()
- {
- return !_robotModule.RobotDevice.IsError && _robotModule.RobotDevice.IsIdle;
- }
- public bool RobotExtendForPlace()
- {
- Notify("robot execute goto command");
- var chamber = _targetModule;
- var slot = _placeSlot;
- var hand = _placeBlade;
- var robotPostion = RobotPostionEnum.PlaceExtendUp;
- //string reason;
- //if (!_robotModule.RobotDevice.GotoRE(chamber, hand, slot, robotPostion, out reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }
- bool MovePinUp()
- {
- var pm = _target as PMModuleBase;
- Notify($"{pm.Name} lift pin up ");
- //if (!pm.ChamberLiftPin.MoveUp(out string reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }
- bool CheckMovePinUp()
- {
- //if (pm.ChamberLiftPin.IsUp)
- // return true;
- return false;
- }
- bool RobotRetractForPlace()
- {
- Notify("robot execute goto command");
- var chamber = _targetModule;
- var slot = _placeSlot;
- var hand = _placeBlade;
- var robotPostion = RobotPostionEnum.PlaceRetract;
- //string reason;
- //if (!_robotModule.RobotDevice.GotoRE(chamber, hand, slot, robotPostion, out reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }
- bool PostTransfer()
- {
- var pm = _target as PMModuleBase;
- var type = EnumTransferType.Place;
- Notify($"{pm.Name} post transfer ");
- if (!pm.PostTransfer(ModuleName.EfemRobot, _placeBlade, new int[] { _placeSlot }, type, out string reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }
- bool CheckPostTransfer()
- {
- var pm = _target as PMModuleBase;
- return !pm.IsError && pm.IsReady;
- }
- bool PickWafer()
- {
- Notify("robot execute pick command");
- var chamber = _targetModule;
- var slot = _pickSlot;
- var hand = _pickBlade;
- _target.NoteTransferStart(ModuleName.EfemRobot, hand, slot, EnumTransferType.Pick);
- string reason;
- if (!_robotModule.RobotDevice.Pick(chamber, hand, slot, out reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }
- bool CheckPickWafer()
- {
- return !_robotModule.RobotDevice.IsError && _robotModule.RobotDevice.IsIdle;
- }
- bool CheckBeforePlace()
- {
- var source = _targetModule;
- var slot = _placeSlot;
- var blade = _placeBlade;
- Notify("Check place condition");
- string reason = string.Empty;
- if (!_target.CheckReadyForTransfer(ModuleName.EfemRobot, blade, slot, 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()
- {
- Notify("robot start execute place command");
- string reason;
- var chamber = _targetModule;
- var slot = _placeSlot;
- var hand = _placeBlade;
- _target.NoteTransferStart(ModuleName.EfemRobot, hand, slot, 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;
- }
- }
- }
|