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.Sorter.Common; using EFEM.RT.Tasks; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots; using System; namespace EFEM.RT.Routines { public class PlaceExtendRoutine : CommonRoutine, IRoutine, IEfemPlaceRoutine { private enum PlaceEx { CheckBeforePlace, PlaceReady, WaitPlaceReady, PlaceWafer, WaitPlace, PlaceRetract, WaitPlaceRetract, CheckAfterPlace, RobotBladeUnGrip, CheckWaferPrecenseBeforePlace, CheckWaferPrecenseAfterPlace, QuerySignalStatusBeforePlace, QuerySignalStatusAfterPlace, CheckTriggerSignalOn, } protected bool MultiWaferSize = DeviceDefineManager.Instance.GetValue("MultiWaferSize") ?? false; private SCConfigItem _scPlaceTimeout = null; private int _timeout = 0; private int _axisTimeout = 0; private int _axisSpeed = 0; public PlaceExtendRoutine(string module, string name) { } public bool Initalize() { _scPlaceTimeout = SC.GetConfigItem(SorterCommon.ScPathName.Robot_TimeLimitForPlaceWafer); if (HaveMotionAxis) { _axisTimeout = SC.GetValue("MotionAxis.MoveTimeout"); _axisSpeed = SC.GetValue("MotionAxis.AutoSpeed"); } return true; } public ModuleName Station { get; set; } public int Slot { get; set; } public Hand Blade { get; set; } public MpntTaskEnum TaskEnum { get; set; } public LoadPort _lpDevice; public Result Start(params object[] objs) { Name = "Place"; Reset(); _timeout = _scPlaceTimeout.IntValue; EV.PostMessage(ModuleName.System.ToString(), EventEnum.PuttingWaferToChamberBegins, string.Format("{0}{1:D2} by {2}", Station.ToString(), Slot + 1, Blade.ToString())); if (!ModuleHelper.IsLoadLock(Station) || TaskEnum == MpntTaskEnum.ParamNg) return Result.FAIL; return Result.RUN; } public Result Monitor() { try { switch (TaskEnum) { case MpntTaskEnum.P1: CheckBeforePlace((int)PlaceEx.CheckBeforePlace, "Check wafer before place", Station, Slot, Blade, Notify, Stop); RobotGoto((int)PlaceEx.PlaceWafer, "Extend to unLoadingPosition", Station, Slot, Blade, RobotPostionEnum.PlaceExtend, Notify, Stop); //PlaceReady((int)PlaceEx.PlaceReady, "Place wafer", Station, Slot, Blade, Notify, Stop); this.WaitRobotMotion((int)PlaceEx.WaitPlaceReady, robot, "Wait wafer placed", _timeout, Notify, Stop); break; case MpntTaskEnum.PB: //RobotSignalStatus((int)Pick.QuerySignalStatusBeforePlace, robot, _timeout); CheckBladeWaferIsExist((int)PlaceEx.CheckWaferPrecenseBeforePlace, robot, Blade, _timeout); //CheckTriggerSignalOn((int)PlaceEx.CheckTriggerSignalOn, "Check Trigger Signal On", Station, _timeout); CheckBeforePlace((int)PlaceEx.CheckBeforePlace, "Check wafer before place", Station, Slot, Blade, Notify, Stop); RobotGoto((int)PlaceEx.PlaceWafer, "Extend to unLoadingPosition", Station, Slot, Blade, RobotPostionEnum.PlaceExtend, Notify, Stop); this.WaitRobotMotion((int)PlaceEx.WaitPlaceReady, robot, "Wait wafer placed", _timeout, Notify, Stop); if (IsVacuumMode && NeedRobotGripAndUngrip) UnGripRobotBlade((int)PlaceEx.RobotBladeUnGrip, Blade, robot, _timeout); break; case MpntTaskEnum.P4: if (!IsVacuumMode && NeedRobotGripAndUngrip) UnGripRobotBlade((int)PlaceEx.RobotBladeUnGrip, Blade, robot, _timeout); RobotGoto((int)PlaceEx.PlaceRetract, "Retract from unLoadingPosition", Station, Slot, Blade, RobotPostionEnum.PlaceRetract, Notify, Stop); this.WaitRobotMotion((int)PlaceEx.WaitPlaceRetract, robot, "Wait wafer placed", _timeout, Notify, Stop); CheckBladeWaferIsExist((int)PlaceEx.CheckWaferPrecenseAfterPlace, robot, Blade, _timeout); //RobotSignalStatus((int)Pick.QuerySignalStatusAfterPlace, robot, _timeout); CheckAfterPlace((int)PlaceEx.CheckAfterPlace, "Check wafer information after wafer placed", Station, Slot, Blade, Notify, Stop); break; case MpntTaskEnum.ParamNg: break; } } catch (RoutineBreakException) { return Result.RUN; } catch (RoutineFaildException) { return Result.FAIL; } EV.PostMessage(ModuleName.System.ToString(), EventEnum.PuttingWaferToChamberEnds, string.Format("{0}{1:D2} by {2}", Station.ToString(), Slot + 1, Blade.ToString())); return Result.DONE; } protected override void Notify(string message) { EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Place sequence:{0}", message)); } /// /// prepare process failed /// /// /// 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 PlaceReady(int id, string name, ModuleName chamber, int slot, Hand blade, Action notify, Action error) { Tuple ret = Execute(id, () => { notify(String.Format("Place wafer to {0}", chamber.ToString())); string reason = string.Empty; return robot.GoTo((RobotArmEnum)blade, chamber.ToString(), slot, RobotPostionEnum.PlaceReady); }); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } } } public void PlaceExtend(int id, string name, ModuleName chamber, int slot, Hand blade, Action notify, Action error) { Tuple ret = Execute(id, () => { notify(String.Format("Place wafer to {0}", chamber.ToString())); string reason = string.Empty; return robot.GoTo((RobotArmEnum)blade, chamber.ToString(), slot, RobotPostionEnum.PlaceExtendAtWafer); }); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } } } public void PlaceRetract(int id, string name, ModuleName chamber, int slot, Hand blade, Action notify, Action error) { Tuple ret = Execute(id, () => { notify(String.Format("Place wafer to {0}", chamber.ToString())); string reason = string.Empty; return robot.GoTo((RobotArmEnum)blade, chamber.ToString(), slot, RobotPostionEnum.PlaceRetract); }); 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 notify, Action error) { Tuple 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; } } 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; } } 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 (!bHasWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedBeforeSend); return false; } } if (ModuleHelper.IsCoolingBuffer(chamber)) { IoCoolingBuffer buffer = DEVICE.GetDevice(chamber.ToString()); if (!buffer.CheckPinUp()) { EV.PostWarningLog(chamber.ToString(), "Can not place wafer to buffer, buffer isn't pick position."); return false; } } else if (ModuleHelper.IsLoadPort(chamber) && MultiWaferSize) { //因为此手臂只有一个手抓 WaferSize size = WaferManager.Instance.GetWaferSize(ModuleName.Robot, 0); OpenStageWithWaferSizeLoadPort lp = DEVICE.GetDevice(chamber.ToString()); if (size != lp.Size) { 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 notify, Action error) { Tuple ret = Execute(id, () => { notify(name); //if (ModuleHelper.IsLoadLock(chamber) && Singleton.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()); } } } } }