123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- using System;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- namespace EFEM.RT.Routines.LP
- {
- internal class ReadWaferIDRoutine : CommonRoutine, IRoutine
- {
- enum Step
- {
- ReaderWaferID,
- Offline,
- LoadJob,
- Online,
- TryRead,
- }
- public string JobName { get; set; }
- private SCConfigItem _scReaderTimeout = null;
- //private int _timeoutAlign = 0;
- private int _timeoutReadID = 0;
- public ReadWaferIDRoutine(string module, string name)
- {
- }
- public bool Initalize()
- {
- _scReaderTimeout = SC.GetConfigItem("OcrReader.TimeLimitForWID");
- return true;
- }
- public int Notch { get; set; }
- public MoveOption Option { get; set; }
- public Result Start(params object[] objs)
- {
- _timeoutReadID = _scReaderTimeout.IntValue;
- Reset();
- EV.PostMessage(ModuleName.Robot.ToString(), EventEnum.AlignBegins, string.Format("{0:D}",Notch));
- return Result.RUN;
- }
-
- public Result Monitor()
- {
- try
- {
- ReadWaferID((int)Step.ReaderWaferID, "Read wafer ID", _timeoutReadID, Notify, Stop);
- Offline((int)Step.Offline, "WIDReader Offline", _timeoutReadID, Notify, Stop);
- LoadJob((int)Step.LoadJob, "WIDReader Load option job", JobName, _timeoutReadID, Notify, Stop);
- Online((int)Step.Offline, "WIDReader Online", _timeoutReadID, Notify, Stop);
- ReadWaferID((int)Step.ReaderWaferID, "Read wafer ID", _timeoutReadID, Notify, Stop);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- return Result.FAIL;
- }
- if ((Option & MoveOption.ReadID) == MoveOption.ReadID)
- {
- // if (widreader.ReadOK)
- // WaferManager.Instance.UpdateWafer(UnitName.Aligner, 0, widreader.LaserMaker);
- }
- EV.PostMessage(ModuleName.Robot.ToString(), EventEnum.AlignEnds);
-
- return Result.DONE;
- }
- public new void Abort()
- {
- }
-
- protected void ReadWaferID(int id, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- string reason = string.Empty;
- widreader.Read(out reason);
- return true;
- }, () =>
- {
- if (!widreader.Busy)
- {
- 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("read wafer id timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void LoadJob(int id, string name, string jobName, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("Load Job"));
- string reason = string.Empty;
- widreader.LoadJob(jobName, out reason);
- return true;
- }, () =>
- {
- if (!widreader.Busy)
- {
- 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("Load Job timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void Online(int id, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("Online"));
- string reason = string.Empty;
- widreader.Online(true, out reason);
- return true;
- }, () =>
- {
- if (!widreader.Busy)
- {
- 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("Online timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected void Offline(int id, string name, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(String.Format("Offline"));
- string reason = string.Empty;
- widreader.Online(false, out reason);
- return true;
- }, () =>
- {
- if (!widreader.Busy)
- {
- 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("Offline timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected override void Notify(string message)
- {
- EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Read wafer ID:{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.AlignFailed, failReason);
- }
- }
- }
|