123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- using System;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners;
- using MECF.Framework.RT.ModuleLibrary.AlignerModules;
- namespace FutureEfemLib.Aligners
- {
- class AlignerHomeRoutine : ModuleRoutine, IRoutine
- {
- enum RoutineStep
- {
- ClearError,
- Home,
- QueryStatus,
- }
- private int _timeout = 0;
- AlignerBase _aligner = null;
- public AlignerHomeRoutine(AlignerModuleBase module)
- {
- Module = module.Module;
- Name = "Home";
- }
- public bool Initalize()
- {
- return true;
- }
- public Result Start(params object[] objs)
- {
- Reset();
- _timeout = SC.GetValue<int>("EFEM.Aligner.HomeTimeout");
- _aligner = DEVICE.GetDevice<AlignerBase>($"{ModuleName.Aligner}.{ModuleName.Aligner}");
- Notify($"Start");
- return Result.RUN;
- }
- public Result Monitor()
- {
- try
- {
- //ClearError((int)RoutineStep.ClearError, _aligner, _timeout);
- Home((int)RoutineStep.Home, _aligner, _timeout);
- QueryStatus((int)RoutineStep.QueryStatus, _aligner, _timeout);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- return Result.FAIL;
- }
- Notify("Finished");
- return Result.DONE;
- }
- public void ClearError(int id, AlignerBase aligner, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Clear error {aligner.Name}");
- //string reason;
- //if (!aligner.ClearError(out reason))
- //{
- // Stop(reason);
- // return false;
- //}
- return true;
- }, () =>
- {
- if (aligner.IsError)
- return null;
- if (aligner.IsBusy)
- return false;
- return true;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop(string.Format("failed."));
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop(string.Format("timeout, can not complete in {0} seconds", timeout));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void Home(int id, AlignerBase aligner, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Start home {aligner.Name}");
- string reason;
- if (!aligner.Home(out reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }, () =>
- {
- if (aligner.IsError)
- return null;
- if (aligner.IsBusy)
- return false;
- return true;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop(string.Format("Home failed."));
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop(string.Format("Home timeout, can not complete in {0} seconds", timeout));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void QueryStatus(int id, AlignerBase aligner, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Start query status {aligner.Name}");
- string reason;
- if (!aligner.QueryWaferPresence(out reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }, () =>
- {
- if (aligner.IsError)
- return null;
- if (aligner.IsBusy)
- return false;
- return true;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop(string.Format("Query status failed."));
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- Stop(string.Format("Query status timeout, can not complete in {0} seconds", timeout));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void Abort()
- {
- }
- }
- }
|