123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- using System;
- using System.Diagnostics;
- 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.Core.Util;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.Common.SubstrateTrackings;
- namespace VirgoRT.Modules.LPs
- {
- class LoadPortLoadRoutine : ModuleRoutine, IRoutine
- {
- enum RoutineStep
- {
- WaitEFEMReady,
- Delay,
- Load,
-
- }
- private int _timeout = 0;
- private int _wait_timeout = 20 * 60 * 1000;
- private Stopwatch _robotIdleWatch = new Stopwatch();
-
- private LoadPortModule _lpModule;
- public LoadPortLoadRoutine(LoadPortModule lpModule)
- {
- _lpModule = lpModule;
- Module = lpModule.Module;
- Name = "Load";
-
- }
-
- public Result Start(params object[] objs)
- {
- Reset();
- _timeout = SC.GetValue<int>("EFEM.LoadPort.MotionTimeout");
- if (!_lpModule.LPDevice.HasCassette )
- {
- EV.PostWarningLog(Module, $"{Module} not found carrier, can not load");
- return Result.FAIL;
- }
- Notify($"Start");
- return Result.RUN;
- }
- public Result Monitor()
- {
- try
- {
- //Wait((int)RoutineStep.WaitEFEMReady, WaitEFEMReady, _wait_timeout);
- Load((int)RoutineStep.Load, _timeout);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException )
- {
-
- return Result.FAIL;
- }
- _robotIdleWatch.Stop();
- Notify("Finished");
- return Result.DONE;
- }
- public bool IsRobotAvailable()
- {
- if(Singleton<RouteManager>.Instance.IsEfemRobotAvailable)
- {
- if(_robotIdleWatch.IsRunning)
- {
- if (_robotIdleWatch.ElapsedMilliseconds > 200)
- {
- _robotIdleWatch.Stop();
- return true;
- }
- }
- else
- {
- _robotIdleWatch.Restart();
- }
- }
- else
- {
- _robotIdleWatch.Stop();
- }
- return false;
- }
- public bool WaitEFEMReady()
- {
- if( IsRobotAvailable() &&
- WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 0) &&
- WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, 1))
- {
- return true;
- }
- else
- {
- throw (new RoutineBreakException());
- }
- }
- public void Load(int id, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Start Load {_lpModule.Name}");
- _lpModule.LPDevice.Load();
- return true;
- //return Singleton<RouteManager>.Instance.EFEM.CheckToPostMessage((int)EfemEntity.MSG.Load, Module);
- }, () =>
- {
- if (!_lpModule.LPDevice.HasCassette)
- {
- EV.PostWarningLog(Module, $"{Module} carrier has been removed, can not load");
- return true;
- }
- if (_lpModule.LPDevice.IsError)
- return null;
- if (_lpModule.LPDevice.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 Abort()
- {
-
- }
-
- }
- }
|