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.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 PickExtendRoutine : CommonRoutine, IRoutine, IEfemPickRoutine { private enum PickEx { CheckBeforePick, GotoReadyPosition, WaitReadyPosition, PickExWafer, WaitExPick, PickReWafer, WaitRePick, CheckAfterPick, RobotBladeGrip, CheckWaferPrecenseBeforePick, CheckWaferPrecenseAfterPick, QuerySignalStatusBeforePick, QuerySignalStatusAfterPick, CheckTriggerSignalOn, } protected bool MultiWaferSize = DeviceDefineManager.Instance.GetValue("MultiWaferSize") ?? false; private SCConfigItem _scPickTimeout = null; private int _timeout = 0; private int _axisTimeout = 0; private int _axisSpeed = 0; public double WaitForPickTime = 0.00; public PickExtendRoutine(string module, string name) { Module = module; name = "Pick"; } public bool Initalize() { _scPickTimeout = SC.GetConfigItem(SorterCommon.ScPathName.Robot_TimeLimitForPickWafer); if (HaveMotionAxis) { _axisTimeout = SC.GetValue("MotionAxis.MoveTimeout"); _axisSpeed = SC.GetValue("MotionAxis.AutoSpeed"); } return true; } public ModuleName Source { get; set; } public int Slot { get; set; } public Hand Blade { get; set; } public MpntTaskEnum TaskEnum { get; set; } private LoadPort _lpDevice; public Result Start(params object[] objs) { Reset(); _timeout = _scPickTimeout.IntValue; Name = "Pick"; Reset(); EV.PostMessage(ModuleName.System.ToString(), EventEnum.PickingWaferFromChamberBegins, string.Format("{0}{1:D2} by {2}", Source.ToString(), Slot + 1, Blade.ToString())); if (!ModuleHelper.IsLoadLock(Source) || TaskEnum == MpntTaskEnum.ParamNg) return Result.FAIL; return Result.RUN; } public Result Monitor() { try { switch (TaskEnum) { case MpntTaskEnum.G1: CheckBeforePick((int)PickEx.CheckBeforePick, "Check wafer information", Source, Slot, Blade, Notify, Stop); RobotGoto((int)PickEx.PickExWafer, "Extend to LoadingPosition", Source, Slot, Blade, RobotPostionEnum.PickExtend, Notify, Stop); this.WaitRobotMotion((int)PickEx.WaitReadyPosition, robot, "Wait picked", _timeout, Notify, Stop); break; case MpntTaskEnum.GB: //RobotSignalStatus((int)Pick.QuerySignalStatusBeforePick, robot, _timeout); CheckBladeWaferIsExist((int)PickEx.CheckWaferPrecenseBeforePick, robot, Blade, _timeout); //CheckTriggerSignalOn((int)PickEx.CheckTriggerSignalOn, "Check Trigger Signal On", Source, _timeout); CheckBeforePick((int)PickEx.CheckBeforePick, "Check wafer information", Source, Slot, Blade, Notify, Stop); RobotGoto((int)PickEx.PickExWafer, "Extend to LoadingPosition", Source, Slot, Blade, RobotPostionEnum.PickExtend, Notify, Stop); this.WaitRobotMotion((int)PickEx.WaitReadyPosition, robot, "Wait picked", _timeout, Notify, Stop); break; case MpntTaskEnum.G4: if (NeedRobotGripAndUngrip) GripRobotBlade((int)PickEx.RobotBladeGrip, Blade, robot, _timeout); RobotGoto((int)PickEx.PickReWafer, "Retract from LoadingPosition", Source, Slot, Blade, RobotPostionEnum.PickRetracted, Notify, Stop); this.WaitRobotMotion((int)PickEx.WaitRePick, robot, "Wait picked", _timeout, Notify, Stop); CheckBladeWaferIsExist((int)PickEx.CheckWaferPrecenseAfterPick, robot, Blade, _timeout); //RobotSignalStatus((int)Pick.QuerySignalStatusAfterPick, robot, _timeout); CheckAfterPick((int)PickEx.CheckAfterPick, "Check wafer information", Source, Slot, Blade, Notify, Stop); break; default: throw new RoutineFaildException(); } } catch (RoutineBreakException) { return Result.RUN; } catch (RoutineFaildException) { return Result.FAIL; } EV.PostMessage(ModuleName.System.ToString(), EventEnum.PickingWaferFromChamberEnds, string.Format("{0}{1:D2} by {2}.", Source.ToString(), Slot + 1, Blade.ToString())); return Result.DONE; } public void CheckBeforePick(int id, string name, ModuleName chamber, int slot, Hand blade, Action notify, Action error) { Tuple ret = Execute(id, () => { notify(name); 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; } notify(String.Format("Check {0}{1:D2} wafer information", chamber.ToString(), slot)); if (blade == Hand.Blade1) { if (ModuleHelper.IsLoadLock(chamber) && Singleton.Instance.IsOnlineMode) { //online mode, CreateWafer in LoadLock //WaferManager.Instance.CreateWafer(chamber, slot, WaferStatus.Normal); } else { bool bHasWafer = WaferManager.Instance.CheckWafer(chamber, slot, WaferStatus.Normal); if (!bHasWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferAbsentWithoutRecord, String.Format("target {0}{1:D2}", chamber.ToString(), slot + 1)); return false; } } bool bNoWafer = WaferManager.Instance.CheckWafer(ModuleName.Robot, 0, WaferStatus.Empty); if (!bNoWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedBeforePick); return false; } bNoWafer = CheckSensorNoWafer(ModuleName.Robot, 0); //check sensor if (!bNoWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedBeforePick); return false; } if (ModuleHelper.IsBuffer(chamber)) { bool bHasWafer = CheckSeneorHasWafer(chamber, slot); //check sensor if (!bHasWafer) { EV.PostWarningLog(chamber.ToString(), "Can not pick wafer from buffer, Buffer slot has no wafer."); return false; } } } else if (blade == Hand.Blade2) { bool bHasWafer = true; for (int i = 0; i < robot.Blade2Slots; i++) { if (ModuleHelper.IsLoadLock(chamber) && Singleton.Instance.IsOnlineMode) { //online mode, CreateWafer in LoadLock //WaferManager.Instance.CreateWafer(chamber, slot, WaferStatus.Normal); } else bHasWafer = WaferManager.Instance.CheckWafer(chamber, slot + i, WaferStatus.Normal); bool bNoWafer = WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)blade + i, WaferStatus.Empty); if (!bNoWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedBeforePick); return false; } bNoWafer = CheckSensorNoWafer(ModuleName.Robot, (int)blade + i); //check sensor if (!bNoWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedBeforePick); return false; } if (ModuleHelper.IsBuffer(chamber)) { bHasWafer = CheckSeneorHasWafer(chamber, slot + i); //check sensor if (!bHasWafer) { EV.PostWarningLog(chamber.ToString(), "Can not pick wafer from buffer, Buffer slot has no wafer."); return false; } } } if (!bHasWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferAbsentWithoutRecord, String.Format("target {0}{1:D2}", chamber.ToString(), slot + 1)); return false; } } else { bool bHasWafer = true; for (int i = 0; i < robot.Blade2Slots + 1; i++) { if (ModuleHelper.IsLoadLock(chamber) && Singleton.Instance.IsOnlineMode) { //online mode, CreateWafer in LoadLock //WaferManager.Instance.CreateWafer(chamber, slot, WaferStatus.Normal); } else bHasWafer = WaferManager.Instance.CheckWafer(chamber, slot, WaferStatus.Normal); bool bNoWafer = WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)Hand.Blade1 + i, WaferStatus.Empty); if (!bNoWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedBeforePick); return false; } bNoWafer = CheckSensorNoWafer(ModuleName.Robot, (int)Hand.Blade1 + i); //check sensor if (!bNoWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDetectedBeforePick); return false; } if (ModuleHelper.IsBuffer(chamber) && blade == Hand.Both) { bHasWafer &= CheckSeneorHasWafer(chamber, slot + i); //check sensor if (!bHasWafer) { EV.PostWarningLog(chamber.ToString(), "Can not pick wafer from buffer, Buffer slot has no wafer."); return false; } } } if (!bHasWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferAbsentWithoutRecord, String.Format("target {0}{1:D2}", chamber.ToString(), slot)); return false; } } if (ModuleHelper.IsCoolingBuffer(chamber)) { IoCoolingBuffer buffer = DEVICE.GetDevice(chamber.ToString()); if (!buffer.CheckPinUp()) { EV.PostWarningLog(chamber.ToString(), "Can not pick wafer from buffer, buffer isn't pick position."); return false; } } return true; }); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { error(String.Format("Failed to check wafer information.")); throw (new RoutineFaildException()); } } } protected void PickReadyPosition(int id, string name, ModuleName chamber, int slot, Hand blade, Action notify, Action error) { var reason = string.Empty; var ret = Execute(id, () => { notify($"Robot go to {chamber.ToString()} ready position"); return robot.GoTo((RobotArmEnum)(int)blade, chamber.ToString(), slot, RobotPostionEnum.PickReady); }); if (ret.Item1) if (ret.Item2 == Result.FAIL) { error(reason); throw new RoutineFaildException(); } } protected void PickExWafer(int id, string name, ModuleName chamber, int slot, Hand blade, Action notify, Action error) { var reason = string.Empty; var ret = Execute(id, () => { notify(string.Format("pick extend to {0}", chamber.ToString())); return true;//robot.PickExtend(chamber, slot, blade, out reason); }); if (ret.Item1) if (ret.Item2 == Result.FAIL) { error(reason); throw new RoutineFaildException(); } } protected void PickReWafer(int id, string name, ModuleName chamber, int slot, Hand blade, Action notify, Action error) { var reason = string.Empty; var ret = Execute(id, () => { notify(string.Format("pick retract from {0}", chamber.ToString())); return true;//robot.PickRetract(chamber, slot, blade, out reason); }); if (ret.Item1) if (ret.Item2 == Result.FAIL) { error(reason); throw new RoutineFaildException(); } } public void CheckAfterPick(int id, string name, ModuleName chamber, int slot, Hand blade, Action notify, Action error) { Tuple ret = Execute(id, () => { notify(name); if (blade == Hand.Blade1) { bool bHasWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)blade); if (!bHasWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedAfterPick); return false; } } else if (blade == Hand.Blade2) { for (int i = 0; i < robot.Blade2Slots; i++) { bool bHasWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)Hand.Blade2 + i); if (!bHasWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedAfterPick); return false; } } } else { for (int i = 0; i < robot.Blade2Slots + 1; i++) { bool bHasWafer = CheckSeneorHasWafer(ModuleName.Robot, (int)Hand.Blade1 + i); if (!bHasWafer) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferNotDetectedAfterPick); return false; } } } return true; }); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { error(String.Format("Failed to check wafer information.")); throw (new RoutineFaildException()); } } } } }