123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492 |
- using Aitex.Core.Common;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Sorter.Common;
- using EFEM.RT.Devices;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
- using System;
- namespace EFEM.RT.Routines
- {
- public class PlaceRoutine : CommonRoutine, IRoutine, IEfemPlaceRoutine
- {
- private enum Place
- {
- QueryState,
- OpenLoadLockDoor,
- CoolBufferMoveUP,
- WaitCoolBufferMoveUP,
- CheckBeforePlace,
- QueryRobotParameter,
- RobotServoOff,
- WaitRobotServoOff,
- SetWaferSizeParameter0000,
- SetWaferSizeParameter0114,
- RobotServoOn,
- WaitRobotServoOn,
- PlaceWafer,
- WaitPlace,
- CloseLoadLockDoor,
- CoolBufferMoveDown,
- WaitCoolBufferMoveDown,
- CheckAfterPlace,
- XMove,
- PostMessage,
- RobotBusytoSimifOn,
- RobotBusytoSimifOff,
- PinDown,
- CheckWaferPrecense,
- WaitCheckWaferPrecense,
- CheckWaferPrecenseAfterPlace,
- QuerySignalStatus,
- RobotBladeGrip,
- NotifyFlipperPrepare,
- NotifyFlipperOver
- }
- protected bool MultiWaferSize = DeviceDefineManager.Instance.GetValue<bool>("MultiWaferSize") ?? false;
- protected bool EnableMoveInDiffSlotsNumLP
- {
- get
- {
- if (SC.ContainsItem("System.IsEnableMoveInDiffSlotsNumLP"))
- return SC.GetValue<bool>("System.IsEnableMoveInDiffSlotsNumLP");
- return false;
- }
- }
- private SCConfigItem _scPlaceTimeout = null;
- private int _timeout = 0;
- private int _axisTimeout = 0;
- private int _axisSpeed = 0;
- private int _alignerdelay = 0;
- private int _coolingdelay = 0;
- private int delaytime = 0;
- public PlaceRoutine(string module, string name)
- {
- Module = module; Name = name;
- _alignerdelay = SC.GetValue<int>("System.AlignerPinDownDelay");
- _coolingdelay = SC.GetValue<int>("System.CoolingPinDownDelay");
- _scPlaceTimeout = SC.GetConfigItem(SorterCommon.ScPathName.Robot_TimeLimitForPlaceWafer);
- if (HaveMotionAxis)
- {
- _axisTimeout = SC.GetValue<int>("MotionAxis.MoveTimeout");
- _axisSpeed = SC.GetValue<int>("MotionAxis.AutoSpeed");
- }
- }
- public bool Initalize()
- {
- IsStopped = true;
- return true;
- }
- public ModuleName Station { get; set; }
- public int Slot { get; set; }
- public Hand Blade { get; set; }
- public LoadPort _lpDevice;
- private bool _skipWait;
- public Result Start(params object[] objs)
- {
- IsStopped = false;
- Name = "Place";
- Reset();
- _timeout = robot.RobotCommandTimeout;
- if (ModuleHelper.IsCoolingBuffer(Station))
- delaytime = _coolingdelay * 1000;
- else delaytime = _alignerdelay * 1000;
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.PuttingWaferToChamberBegins, string.Format("{0}{1:D2} by {2}", Station.ToString(), Slot + 1, Blade.ToString()));
- return Result.RUN;
- }
- public Result Monitor()
- {
- try
- {
- if (IsStopped) return Result.DONE;
- if (ModuleHelper.IsCoolingBuffer(Station) || ModuleHelper.IsAligner(Station))
- {
- var dev = GetCoolBuffer(Station);
- if (dev != null)
- {
- //QueryCoolBufferState((int)Place.QueryState, GetCoolBuffer(Station));
- CoolBufferMoveUP((int)Place.CoolBufferMoveUP, GetCoolBuffer(Station), WaferManager.Instance.GetWaferSize(ModuleName.Robot, 0), _timeout, Notify, Stop);
- WaitCoolBufferMoveUp((int)Place.WaitCoolBufferMoveUP, GetCoolBuffer(Station), "Wait CoolingBuffer Move Up...", _timeout, Notify, Stop);
- }
- }
- else if (ModuleHelper.IsFlipper(Station))
- {
- FlipperPrepare((int)Place.NotifyFlipperPrepare, GetFlipper(), "Flipper Prepare Transfer...", _timeout, Notify, Stop);
- }
- CheckBladeWaferIsExist((int)Place.CheckWaferPrecense, robot, Blade, _timeout);
- // RobotSignalStatus((int)Place.QuerySignalStatus, robot, _timeout);
- WaitRobotMotion((int)Place.WaitCheckWaferPrecense, robot, "Wait finish check wafer", _timeout, Notify, Stop);
- CheckBeforePlace((int)Place.CheckBeforePlace, "Check wafer before place", Station, Slot, Blade, Notify, Stop);
- //GripRobotBlade((int)Place.RobotBladeGrip, Blade, robot, _timeout);
- if (!ModuleHelper.IsLoadLock(Station))
- {
- PlaceWafer((int)Place.PlaceWafer, "Place wafer", Station, Slot, Blade, OffsetX, OffsetY, OffsetZ, Notify, Stop);
- this.WaitRobotMotion((int)Place.WaitPlace, robot, "Wait wafer placed", _timeout, Notify, Stop);
- }
- if (LoadLockDoorControlByStation && ModuleHelper.IsLoadLock(Station) && !Singleton<EfemEntity>.Instance.IsOnlineMode)
- {
- LoadLockCloseAtmDoor((int)Place.CloseLoadLockDoor, DEVICE.GetDevice<LoadLockDevice>(Station.ToString()), "Wait Atm Door Close", _timeout, Notify, Stop);
- }
- //为了提高上位机调度效率,机械手放片在上面就认为place指令完成。pin落下的时间和指令从上位机发送
- //为了保持兼容性,暂时判断了是否上位机控制,需要等cycle功能做好,这里都统一成外部控制lift pin
- if (!Singleton<EfemEntity>.Instance.IsOnlineMode)
- {
- if (ModuleHelper.IsCoolingBuffer(Station) || ModuleHelper.IsAligner(Station))
- {
- var dev = GetCoolBuffer(Station);
- if (dev != null)
- {
- TimeDelay((int)Place.PinDown, delaytime);
- CoolBufferMoveDown((int)Place.CoolBufferMoveDown, GetCoolBuffer(Station), WaferManager.Instance.GetWaferSize(Station, Slot), _timeout, Notify, Stop);
- WaitCoolBufferMoveDown((int)Place.WaitCoolBufferMoveDown, GetCoolBuffer(Station), "Wait CoolingBuffer Move Down...", _timeout, Notify, Stop);
- }
- }
- }
- if (ModuleHelper.IsFlipper(Station))
- {
- FlipperComplete((int)Place.NotifyFlipperOver, GetFlipper(), "Flipper Complete Transfer...", _timeout, Notify, Stop);
- }
- PostMessage((int)Place.PostMessage, string.Format("{0}{1:D2} by {2}", Station.ToString(), Slot + 1, Blade.ToString()));
- //CheckBladeWaferIsExist((int)Place.CheckWaferPrecenseAfterPlace, robot, Blade, _timeout);
- CheckAfterPlace((int)Place.CheckAfterPlace, "Check wafer information after wafer placed", Station, Slot, Blade, Notify, Stop);
- }
- catch (RoutineBreakException)
- {
- if (!IsActived(TokenId) && !_skipWait)
- {
- _skipWait = true;
- return Monitor();
- }
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- IsStopped = true;
- return Result.FAIL;
- }
- IsStopped = true;
- return Result.DONE;
- }
- protected override void Notify(string message)
- {
- EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Place sequence:{0}", message));
- }
- /// <summary>
- /// prepare process failed
- /// </summary>
- /// <param name="failReason"></param>
- /// <param name="reactor"></param>
- protected override void Stop(string failReason)
- {
- string reason = String.Empty;
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.PlaceWaferFailed, Station.ToString(), Slot + 1, Blade.ToString(), failReason);
- }
- public void PlaceWafer(int id, string name, ModuleName chamber, int slot, Hand blade, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("Place wafer to {0}", chamber.ToString()));
- string reason = string.Empty;
- return robot.Place((RobotArmEnum)(int)blade, chamber.ToString(), slot);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- public void CheckBeforePlace(int id, string name, ModuleName chamber, int slot, Hand blade, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("Check {0}{1:D2} wafer information before place wafer", chamber.ToString(), slot));
- string reason = string.Empty;
- if (!CheckRobotMotionInterlock(chamber, slot, out reason))
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.TransferPrepareFailed, String.Format("Target {0}{1:D2},{2}", chamber.ToString(), slot + 1, reason));
- return false;
- }
- if (blade == Hand.Blade1)
- {
- bool bNoWafer = WaferManager.Instance.CheckWafer(chamber, slot, WaferStatus.Empty);
- if (!bNoWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferPresentWithRecord, String.Format("Target {0}{1:D2}", chamber.ToString(), slot + 1));
- return false;
- }
- bool bHasWafer = WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)blade, WaferStatus.Normal);
- if (!bHasWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
- return false;
- }
- bHasWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)blade); //check sensor
- if (!bHasWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
- return false;
- }
- if (IsEnableIdentifyThickness)
- {
- if (ModuleHelper.IsLoadPort(chamber))
- {
- if (SC.GetStringValue($"CarrierInfo.LowerThicknessType") != SC.GetStringValue($"CarrierInfo.{chamber}ThicknessType"))
- {
- EV.PostAlarmLog(ModuleName.System.ToString(), $"The wafer thickness of the lower arm is different from {chamber}.");
- return false;
- }
- }
- }
- }
- else if (blade == Hand.Blade2)
- {
- bool bHasWafer = true;
- for (int i = 0; i < robot.Blade2Slots; i++)
- {
- bool bNoWafer = WaferManager.Instance.CheckWafer(chamber, slot + i, WaferStatus.Empty);
- if (!bNoWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferPresentWithRecord, String.Format("Target {0}{1:D2}", chamber.ToString(), slot + i + 1));
- return false;
- }
- bHasWafer &= WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)blade + i, WaferStatus.Normal);
- bool bSensorWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)blade + i); //check sensor
- if (!bSensorWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
- return false;
- }
- }
- if (!bHasWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
- return false;
- }
- if (IsEnableIdentifyThickness)
- {
- if (ModuleHelper.IsLoadPort(chamber))
- {
- if (SC.GetStringValue($"CarrierInfo.UpperThicknessType") != SC.GetStringValue($"CarrierInfo.{chamber}ThicknessType"))
- {
- EV.PostAlarmLog(ModuleName.System.ToString(), $"The wafer thickness of the lower arm is different from {chamber}.");
- return false;
- }
- }
- }
- }
- else
- {
- bool bHasWafer = true;
- for (int i = 0; i < robot.Blade2Slots + 1; i++)
- {
- bool bNoWafer = WaferManager.Instance.CheckWafer(chamber, slot + i, WaferStatus.Empty);
- if (!bNoWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferPresentWithRecord, String.Format("Target {0}{1:D2}", chamber.ToString(), slot + i + 1));
- return false;
- }
- bHasWafer &= WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)Hand.Blade1 + i, WaferStatus.Normal);
- bool bSensorWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)Hand.Blade1 + i); //check sensor
- if (!bSensorWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
- return false;
- }
- if (ModuleHelper.IsLoadPort(chamber))
- {
- string arm = i == 0 ? "Lower" : "Upper";
- if (SC.GetStringValue($"CarrierInfo.{arm}ThicknessType") != SC.GetStringValue($"CarrierInfo.{chamber}ThicknessType"))
- {
- EV.PostAlarmLog(ModuleName.System.ToString(), $"The wafer thickness of the {arm} arm is different from {chamber}.");
- return false;
- }
- }
- }
- if (!bHasWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend);
- return false;
- }
- }
- if (ModuleHelper.IsCoolingBuffer(chamber))
- {
- IoCoolingBuffer buffer = DEVICE.GetDevice<IoCoolingBuffer>(chamber.ToString());
- if (buffer == null)
- {
- EV.PostWarningLog("System", String.Format("{0} Device is Null", chamber.ToString()));
- return false;
- }
- if (!buffer.CheckPinUp())
- {
- EV.PostWarningLog(chamber.ToString(), "Can not place wafer to buffer, buffer isn't pick position.");
- return false;
- }
- }
- if (ModuleHelper.IsLoadPort(chamber))
- {
- //WaferSize size = WaferManager.Instance.GetWaferSize(ModuleName.Robot, (blade == Hand.Both) ? 0 : (int)blade);
- WaferInfo wafer = WaferManager.Instance.GetWafer(ModuleName.Robot, (blade == Hand.Both) ? 0 : (int)blade);
- LoadPortBaseDevice lp = DEVICE.GetDevice<LoadPortBaseDevice>(chamber.ToString());
- LoadPortBaseDevice lp1 = DEVICE.GetDevice<LoadPortBaseDevice>(((ModuleName)wafer.OriginStation).ToString());
- if (!EnableMoveInDiffSlotsNumLP && lp1 != null && lp1.ValidSlotsNumber != lp.ValidSlotsNumber)
- {
- EV.PostWarningLog(chamber.ToString(), "Can not place wafer to loadport, SlotsNumber is unmatch.");
- return false;
- }
- if (IsEnableMultiWaferSize)
- {
- //因为此手臂只有一个手抓
- WaferSize size = WaferManager.Instance.GetWaferSize(ModuleName.Robot, (blade == Hand.Both) ? 0 : (int)blade);
- lp = DEVICE.GetDevice<LoadPortBaseDevice>(chamber.ToString());
- if (size != lp.GetCurrentWaferSize())
- {
- EV.PostWarningLog(chamber.ToString(), "Can not place wafer to loadport, size is unmatch.");
- return false;
- }
- }
- }
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- error(String.Format("Check wafer information failed, can not place."));
- throw (new RoutineFaildException());
- }
- }
- }
- public void CheckAfterPlace(int id, string name, ModuleName chamber, int slot, Hand blade, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(name);
- //if (ModuleHelper.IsLoadLock(chamber) && Singleton<EfemEntity>.Instance.IsOnlineMode)
- //{
- // //online mode, DeleteWafer in LoadLock
- // WaferManager.Instance.DeleteWafer(chamber, slot);
- //}
- //if (ModuleHelper.IsBuffer(chamber) && Singleton<EfemEntity>.Instance.IsOnlineMode)
- //{
- // //online mode, DeleteWafer in LoadLock
- // WaferManager.Instance.DeleteWafer(chamber, slot);
- //}
- if (blade == Hand.Blade1)
- {
- bool bNoWafer = CheckSensorNoWafer(ModuleName.Robot, (int)blade);
- if (!bNoWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedAfterSend);
- return false;
- }
- }
- else if (blade == Hand.Blade2)
- {
- for (int i = 0; i < robot.Blade2Slots; i++)
- {
- bool bNoWafer = CheckSensorNoWafer(ModuleName.Robot, (int)blade + i);
- if (!bNoWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedAfterSend);
- return false;
- }
- }
- }
- else
- {
- for (int i = 0; i < robot.Blade2Slots + 1; i++)
- {
- bool bNoWafer = CheckSensorNoWafer(ModuleName.Robot, (int)Hand.Blade1 + i);
- if (!bNoWafer)
- {
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedAfterSend);
- return false;
- }
- }
- }
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- error(String.Format("Failed to check wafer information"));
- throw (new RoutineFaildException());
- }
- }
- }
- }
- }
|