123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- 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.Efems;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes;
- namespace FutureEfemLib.Efems
- {
- class EfemHomeRoutine : ModuleRoutine, IRoutine
- {
- enum RoutineStep
- {
- InitEfem,
- ClearEfemError,
- InitRobot,
- HomeRobot,
- CheckRobotWafer,
- ResetSignalTowerData,
- }
- private int _timeout = 0;
- private bool _needInitEfem;
- private IEfemController _efem = null;
- private EfemModule _efemModule;
- public EfemHomeRoutine(EfemModule module)
- {
- Module = ModuleName.EfemRobot.ToString();
- Name = "Home";
- _efem = module.EfemDevice;
- _efemModule = module;
- }
- public Result Start(params object[] objs)
- {
- Reset();
- _timeout = SC.GetValue<int>("EFEM.EfemRobot.HomeTimeout");
- _needInitEfem = !_efem.IsInitialized;
- Notify($"Start");
- return Result.RUN;
- }
- public Result Monitor()
- {
- try
- {
- if (_needInitEfem)
- {
- InitEfem((int)RoutineStep.InitEfem, _timeout);
- }
- ClearEfemError((int)RoutineStep.ClearEfemError, _timeout);
- InitRobot((int)RoutineStep.InitRobot, _timeout);
- HomeRobot((int)RoutineStep.HomeRobot, _timeout);
- CheckRobotWafer((int)RoutineStep.CheckRobotWafer, _timeout);
- ResetSignalTowerData((int)RoutineStep.ResetSignalTowerData);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- return Result.FAIL;
- }
- Notify("Finished");
- return Result.DONE;
- }
- public void InitEfem(int id, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Start initialize EFEM status");
- string reason;
- if (!_efem.Home(out reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }, () =>
- {
- if (!_efem.IsInitialized)
- return false;
- if (_efem.CheckIsBusy(ModuleName.System))
- 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 ClearEfemError(int id, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Start clear EFEM error");
- //string reason;
- (_efem as RorzeEfem).ClearError();
- return true;
- }, () =>
- {
- if (_efem.CheckIsBusy(ModuleName.System))
- return false;
- //if ((_efem as StripEfem).HasAlarm)
- // 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 clear error in {0} seconds", timeout));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void InitRobot(int id, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Start initialize robot status");
- _efemModule.RobotDevice.Abort();
- if (!_efemModule.RobotDevice.Home(out string reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }, () =>
- {
- if (!_efemModule.RobotDevice.IsIdle)
- 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 HomeRobot(int id, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Start home robot");
- if (!_efemModule.RobotDevice.HomeAllAxes(out string reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }, () =>
- {
- if (_efemModule.RobotDevice.IsError)
- {
- return null;
- }
- if (!_efemModule.RobotDevice.IsIdle)
- 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 ResetSignalTowerData(int id )
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- Notify($"reset signal tower");
- //_efemModule.SignalTowerDevice.ResetData();
- return true;
- } );
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- Stop(string.Format("Home failed."));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- public void CheckRobotWafer(int id, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Start check robot wafer present");
- string reason;
- if (!_efem.QueryRobotWaferPresence(out _, out reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }, () =>
- {
- if (_efem.CheckIsBusy(ModuleName.System))
- 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 Abort()
- {
- }
- }
- }
|