123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400 |
- 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<bool>("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<int>("MotionAxis.MoveTimeout");
- _axisSpeed = SC.GetValue<int>("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));
- }
- /// <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 PlaceReady(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.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<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.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<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.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<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;
- }
- }
- 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<IoCoolingBuffer>(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<OpenStageWithWaferSizeLoadPort>(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<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 (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());
- }
- }
- }
- }
- }
|