123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- using System;
- 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 Aitex.Sorter.Common;
- 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.LoadPorts.TDK;
- namespace EFEM.RT.Routines.LP
- {
- internal class UnloadFoupRoutine : CommonRoutine, IRoutine
- {
- public enum UnloadFoupStep
- {
- UNLOAD,
- WaitUnload,
- UnladoLight,
- }
- public ModuleName Chamber { get; set; }
- private SCConfigItem _scLoadTimeout = null;
- private int _timeoutUnload = 0;
- LoadPortBaseDevice _device = null;
- public UnloadFoupRoutine()
- {
- Name = "Unload";
- _scLoadTimeout = SC.GetConfigItem("LoadPort.TimeLimitLoadportUnload");
- }
- public bool Initalize()
- {
- IsStopped = true;
- return true;
- }
- public Result Start(params object[] objs)
- {
- _timeoutUnload = _scLoadTimeout.IntValue;
- Reset();
- _device = DEVICE.GetDevice<LoadPortBaseDevice>(Chamber.ToString());
- EV.PostMessage(Chamber.ToString(), EventEnum.UnloadFOUPStart, Chamber.ToString());
- string reason = string.Empty;
- if (_device.DockState == FoupDockState.Undocked)
- {
- EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, string.Format("{0} is unload, can't do again", Chamber.ToString()));
- return Result.FAIL;
- }
- if (SC.GetValue<bool>("System.LPRobotActionIntervene"))
- {
- if(!CheckLoadportMotionInterlock(Chamber, out reason))
- {
- EV.PostMessage(Chamber.ToString(), EventEnum.UnloadFOUPFailed, reason);
- return Result.FAIL;
- }
- }
- if (!_device.IsEnableUnload(out reason))
- {
- EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, reason);
- return Result.FAIL;
- }
- IsStopped = false;
- return Result.RUN;
- }
- public Result Monitor()
- {
- if (IsStopped) return Result.DONE;
- try
- {
- Unload((int)UnloadFoupStep.UNLOAD, "Unload", _timeoutUnload, Notify, Stop);
- WaitLoadportMotion((int)UnloadFoupStep.WaitUnload, _device, "Wait Unload...", _timeoutUnload, Notify, Stop);
-
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- IsStopped = true;
- return Result.FAIL;
- }
- IsStopped = true;
- EV.PostMessage(Chamber.ToString(), EventEnum.UnloadFOUPEnd, Chamber.ToString());
- return Result.DONE;
- }
- public new void Abort()
- {
- }
-
- protected void Unload(int id, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- notify(String.Format("{0} Home", _device.Name));
- string reason = string.Empty;
- return _device.Unload(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());
- }
- }
- public void UnloadLight(int id, LoadPort device, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("{0} unload light", device.Name));
- string reason = string.Empty;
- return device.SetIndicator(Indicator.UNLOAD, IndicatorState.OFF, out reason);
- }, () =>
- {
- if (device.IsBusy == false)
- {
- 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("{0} timeout, than {1} seconds", name, time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected override void Notify(string message)
- {
- EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Unload :{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.UnloadFOUPFailed, failReason);
- }
- }
- }
|