123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- using System;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- namespace EFEM.RT.Routines.LP
- {
- internal class LoadFoupRoutine : CommonRoutine, IRoutine
- {
- public enum LoadFoup
- {
- LOAD,
- WaitLoad,
- GetMap,
- }
- public ModuleName Chamber { get; set; }
- private SCConfigItem _scLoadTimeout = null;
- private int _timeoutLoad = 0;
- LoadPortBaseDevice _device = null;
-
- public bool IsDeviceNull => _device == null;
- public LoadFoupRoutine(string module, string name)
- {
- _scLoadTimeout = SC.GetConfigItem("LoadPort.TimeLimitLoadportLoad");
- }
- public bool Initalize()
- {
- IsStopped = true;
- return true;
- }
- public Result StartRoutine(ModuleName lp)
- {
- Chamber = lp;
- _timeoutLoad = _scLoadTimeout.IntValue;
- Reset();
- _device = DEVICE.GetDevice<LoadPortBaseDevice>(Chamber.ToString());
-
- if (_device.DockState == FoupDockState.Docked)
- {
- EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, string.Format("{0} is load already, can't do again", Chamber.ToString()));
- return Result.FAIL;
- }
-
- string reason = string.Empty;
- if (SC.GetValue<bool>("System.LPRobotActionIntervene"))
- {
- if (!CheckLoadportMotionInterlock(Chamber, out reason))
- {
- EV.PostMessage(Chamber.ToString(), EventEnum.LoadFOUPFailed, reason);
- return Result.FAIL;
- }
- }
- if (!_device.IsEnableLoad(out reason))
- {
- EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, reason);
- return Result.FAIL;
- }
- EV.PostMessage(Chamber.ToString(), EventEnum.LoadFOUPStart, Chamber.ToString());
- IsStopped = false;
- return Result.RUN;
- }
- public Result Start(params object[] objs)
- {
-
- _timeoutLoad = _scLoadTimeout.IntValue;
- Reset();
- _device = DEVICE.GetDevice<LoadPortBaseDevice>(Chamber.ToString());
- if (_device.DockState == FoupDockState.Docked)
- {
- EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, string.Format("{0} is load already, can't do again", Chamber.ToString()));
- return Result.FAIL;
- }
- EV.PostMessage(Chamber.ToString(), EventEnum.LoadFOUPStart, Chamber.ToString());
- IsStopped = false;
- return Result.RUN;
- }
- public Result Monitor()
- {
- if (IsStopped) return Result.DONE;
- try
- {
- MapLoadFoup((int)LoadFoup.LOAD, "Mapping&Load", _timeoutLoad, Notify, Stop);
- WaitLoadportMotion((int)LoadFoup.WaitLoad, _device, "Wait Load...", _timeoutLoad, Notify, Stop);
- // GetWaferMap((int)LoadFoup.GetMap, "Get Mapping", _timeoutLoad, Notify, Stop);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- IsStopped = true;
- return Result.FAIL;
- }
- IsStopped = true;
- EV.PostMessage(Chamber.ToString(), EventEnum.LoadFOUPEnd, Chamber.ToString());
- return Result.DONE;
- }
- public new void Abort()
- {
- }
-
- protected void MapLoadFoup(int id, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("{0} Load", _device.Name));
- string reason = string.Empty;
- return _device.Load(out reason);
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
-
- protected void GetWaferMap(int id, string name, int time, Action<string> notify, Action<string> error)
- {
- 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
- {
- error(String.Format("Query Mapping time out, using more than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected override void Notify(string message)
- {
- EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Load Foup:{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(Module, EventEnum.LoadFOUPFailed, failReason);
- }
- }
- }
|