123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- using System;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Sorter.Common;
- using FutureEfemLib.LPs;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.ModuleLibrary.LPModules;
- using MECF.Framework.RT.ModuleLibrary.SystemModules;
- namespace FutureEfemLib.Efems
- {
- public class EfemMapRoutine : ModuleRoutine, IRoutine
- {
- enum RoutineStep
- {
- CheckTargetEnableMap,
- Map,
- }
- private int _mapTimeout;
- private ModuleName _target;
- private int _thicknessIndex;
- //private Hand _hand;
- //private bool _autoHand;
- private EfemModule _efemModule;
- public EfemMapRoutine(EfemModule efemModule)
- {
- Module = "EFEM";
- Name = "Map";
- _efemModule = efemModule;
- }
- public Result Start(params object[] objs)
- {
- _mapTimeout = SC.GetValue<int>("EFEM.EfemRobot.MapTimeout");
- Reset();
- _thicknessIndex = 0;
- //if (ModuleHelper.IsLoadPort(_target))
- //{
- // LoadPortModule lp = Singleton<EquipmentManager>.Instance.Modules[_target] as LoadPortModule;
- // _thicknessIndex = lp.LPDevice.GetThicknessIndex();
- //}
- Notify($"Start map {_target}");
- return Result.RUN;
- }
- public void Init(ModuleName source)
- {
- //_autoHand = true;
- _target = source;
- }
- public void Abort()
- {
- Notify($"Abort map {_target}");
- }
- public Result Monitor()
- {
- try
- {
- CheckTargetEnableMap((int)RoutineStep.CheckTargetEnableMap, _target);
- Map((int)RoutineStep.Map, _target, _thicknessIndex, _mapTimeout);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- return Result.FAIL;
- }
- Notify($"Complete map {_target}");
- return Result.DONE;
- }
- public void CheckTargetEnableMap(int id, ModuleName target)
- {
- Tuple<bool, Result> ret = Execute(id, () =>
- {
- Notify($"Check {target} enable map");
- if (!_efemModule.RobotDevice.IsReady())
- {
- Stop($"Can not map {target}, EfemRobot is not ready");
- return false;
- }
- if (!ModuleHelper.IsLoadPort(target) && !ModuleHelper.IsLoadLock(target))
- {
- Stop($"Can not map {target}, only LP or Buf supported");
- return false;
- }
- if (target == ModuleName.LLA && DEVICE.GetDevice<IoSensor>($"System.SensorBufferABigWaferProtrusion").Value)
- {
- Stop($"Can not map {target}, SensorBufferABigWaferProtrusion is on");
- return false;
- }
- if (target == ModuleName.LLB && DEVICE.GetDevice<IoSensor>($"System.SensorBufferBBigWaferProtrusion").Value)
- {
- Stop($"Can not map {target}, SensorBufferBBigWaferProtrusion is on");
- return false;
- }
- if (ModuleHelper.IsLoadPort(target))
- {
- LoadPortModuleBase lp = EquipmentManager.Modules[target] as LoadPortModuleBase;
- if (!lp.CheckReadyForMap(ModuleName.EfemRobot, Hand.Blade1, out string reason))
- {
- Stop(reason);
- return false;
- }
- }
- return true;
- });
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- }
- }
- public void Map(int id, ModuleName target, int thicknessIndex, int timeout)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- Notify($"Robot start map {target}");
- string reason;
- if (!_efemModule.RobotDevice.Map(target, thicknessIndex, out reason))
- {
- Stop(reason);
- return false;
- }
- return true;
- }, () =>
- {
- if (_efemModule.RobotDevice.IsError)
- return null;
- if (_efemModule.RobotDevice.IsIdle)
- return true;
- return false;
- }, timeout * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- 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());
- }
- }
- }
- }
|