123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- using System;
- using System.Runtime.Remoting.Messaging;
- using Aitex.Core.Common;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using EFEM.RT.Devices.LoadPorts.JetOpenCst;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
- namespace EFEM.RT.Routines
- {
- public class WaferMappingRoutine : CommonRoutine, IRoutine
- {
- private enum Mapping
- {
- CheckLoadPortReadyMap,
- CheckRobotMapInterlock,
- CheckRobotReadyMap,
- QueryRobotParameter,
- RobotServoOff,
- WaitRobotServoOff,
- SetWaferSizeParameter0000,
- SetWaferSizeParameter0114,
- RobotServoOn,
- WaitRobotServoOn,
- MapWafer,
- WaitMapping,
- GetWaferMap,
- }
- private bool MultiWaferSize = DeviceDefineManager.Instance.GetValue<bool>("MultiWaferSize") ?? false;
- private SCConfigItem _scPickTimeout = null;
- private int _timeout = 0;
- private LoadPortBaseDevice _lp;
- public bool IsDeviceNull => _lp == null;
- public WaferMappingRoutine()
- {
- Name = "Wafer Mapping";
- _scPickTimeout = SC.GetConfigItem(SorterCommon.ScPathName.Robot_TimeLimitForPickWafer);
- }
- public bool Initalize()
- {
- return true;
- }
- public ModuleName Source { get; set; }
- private WaferSize _waferSize;
- public Result Start(params object[] objs)
- {
- Reset();
- _timeout = SC.GetValue<int>(SorterCommon.ScPathName.Robot_TimeLimitForPickWafer);
- Name = "Wafer Mapping";
- Reset();
- NeedSetParameter = true;
- string module = (string)objs[0];
- ModuleName source;
- if (string.IsNullOrEmpty(module) || !Enum.TryParse(module, out source))
- {
- LOG.Write("Start map wafer argument is not valid");
- return Result.FAIL;
- }
- Source = source;
- if (ModuleHelper.IsLoadPort(Source))
- {
- if (SC.GetValue<int>($"LoadPort.{Source}.CstType") == 0)
- {
- _lp = DEVICE.GetDevice<LoadPortBaseDevice>(Source.ToString());
- _waferSize = _lp.GetCurrentWaferSize();
- }
- else if (SC.GetValue<int>($"LoadPort.{Source}.CstType") == 1)
- {
- _lp = DEVICE.GetDevice<OpenStageJet>(Source.ToString());
- _waferSize = _lp.GetCurrentWaferSize();
- }
- else if (SC.GetValue<int>($"LoadPort.{Source}.CstType") == 2)
- {
- _lp = DEVICE.GetDevice<LoadPortBaseDevice>(Source.ToString());
- _waferSize = _lp.GetCurrentWaferSize();
- }
- }
- //if (_lp != null)
- //{
- // var _lpOpen = _lp as OpenStageWithWaferSizeLoadPort;
- // _waferSize = _lpOpen.WaferSize;
- //}
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.GeneralInfo, string.Format("Wafer Mapping {0} start.", Source.ToString()));
- return Result.RUN;
- }
- public Result Monitor()
- {
- try
- {
- if (ModuleHelper.IsLoadPort(Source))
- CheckLoadPortReady((int)Mapping.CheckLoadPortReadyMap, _lp);
- if (DeviceDefineManager.Instance.GetValue<bool>("WAFSHEnable") == false)
- {
- CheckRobotReady((int)Mapping.CheckRobotReadyMap);
- //QueryRbParameterAndCompare0114((int)Mapping.QueryRobotParameter, "Query Robot parameters", 0114, "URS", _waferSize,_timeout, Notify, Stop);
- MapWafer((int)Mapping.MapWafer);
- WaitRobotMotion((int)Mapping.WaitMapping, robot, "Wait robot motion finish", _timeout, Notify, Stop);
- GetWaferMap((int)Mapping.GetWaferMap, "Get wafer Mapping", Source, _timeout, Notify, Stop);
- }
- else
- {
- GetWaferMap((int)Mapping.GetWaferMap, _lp, _timeout);
- }
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- return Result.FAIL;
- }
- EV.PostMessage(ModuleName.System.ToString(), EventEnum.GeneralInfo, string.Format("Wafer mapping {0} end.", Source.ToString()));
- return Result.DONE;
- }
- public void CheckLoadPortReady(int id, LoadPortBaseDevice device)
- {
- Tuple<bool, Result> ret = Check(id, () =>
- {
- Notify(String.Format("{0} check enable transfer", device.Name));
- string reason = null;
- bool IsEnableMap = device.IsEnableMapWafer(out reason);
- if (!IsEnableMap)
- {
- EV.PostWarningLog(device.Name, $"{device.Name} can not maping,LP is not ready,{reason}. ");
- }
- return IsEnableMap;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop("Load Port not ready to map wafer");
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void CheckRobotReady(int id)
- {
- string reason = string.Empty;
- Tuple<bool, Result> ret = Check(id, () =>
- {
- Notify(String.Format("check robot ready map"));
- return CheckRobotMotionInterlock(out reason);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop(reason);
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected override void Notify(string message)
- {
- EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Wafer mapping:{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.DefaultWarning, string.Format("Wafer mapping {0} stopped, {1}", Source.ToString(), failReason));
- }
- public void MapWafer(int id)
- {
- string reason = string.Empty;
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- Notify(String.Format("Wafer Mapping for {0}", Source));
- return robot.WaferMapping(Source, out reason);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop(reason);
- throw (new RoutineFaildException());
- }
- }
- }
- protected void GetWaferMap(int id, LoadPortBaseDevice device, int time)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify(String.Format("Query Mapping"));
- string reason = string.Empty;
- return device.QueryWaferMap(out reason);
- }, () =>
- {
- if (!device.IsBusy)
- {
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop(String.Format("Query Mapping time out, using more than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void GetWaferMap(int id, string name, ModuleName chamber, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("Query Mapping"));
- string reason = string.Empty;
- return robot.QueryWaferMap(chamber, out reason);
- }, () =>
- {
- if (robot.RobotState == RobotStateEnum.Idle)
- {
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("Query Mapping time out, using more than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- }
- }
|