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.Core.Applications; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes; using MECF.Framework.RT.ModuleLibrary.AlignerModules; using MECF.Framework.RT.ModuleLibrary.LPModules; using MECF.Framework.RT.ModuleLibrary.SystemModules; namespace FutureEfemLib.Efems { class EfemHomeAllRoutine : ModuleRoutine, IRoutine { enum RoutineStep { HomeRobot, HomeOtherModules, } private IRoutine _homeRobotRoutine; private AlignerModuleBase _aligner; private LoadPortModuleBase _lp1; private LoadPortModuleBase _lp2; private LoadPortModuleBase _lp3; public EfemHomeAllRoutine(EfemModule module) { Module = ModuleName.EfemRobot.ToString(); Name = "Home All"; _homeRobotRoutine = new EfemHomeRoutine(module); _aligner = EquipmentManager.Modules[ModuleName.Aligner] as AlignerModuleBase; _lp1 = EquipmentManager.Modules[ModuleName.LP1] as LoadPortModuleBase; _lp2 = EquipmentManager.Modules[ModuleName.LP2] as LoadPortModuleBase; _lp3 = EquipmentManager.Modules[ModuleName.LP3] as LoadPortModuleBase; System.Diagnostics.Debug.Assert(_aligner!=null); System.Diagnostics.Debug.Assert(_lp1 != null); System.Diagnostics.Debug.Assert(_lp2 != null); System.Diagnostics.Debug.Assert(_lp3 != null); } public Result Start(params object[] objs) { Reset(); Notify($"Start"); return Result.RUN; } public Result Monitor() { try { ExecuteRoutine((int)RoutineStep.HomeRobot, _homeRobotRoutine); HomeOtherModules((int)RoutineStep.HomeOtherModules ); } catch (RoutineBreakException) { return Result.RUN; } catch (RoutineFaildException) { return Result.FAIL; } Notify("Finished"); return Result.DONE; } public void HomeOtherModules(int id ) { Tuple ret = ExecuteAndWait(id, () => { Notify($"Start Home all EFEM modules"); string reason; if (!_aligner.Home(out reason)) { Stop(reason); return false; } if (!_lp1.Home(out reason)) { Stop(reason); return false; } if (!_lp2.Home(out reason)) { Stop(reason); return false; } if (!_lp3.Home(out reason)) { Stop(reason); return false; } return true; }, () => { if (_aligner.IsError || _lp1.IsError || _lp2.IsError || _lp3.IsError) { return null; } if (!_aligner.IsReady || !_lp1.IsReady || !_lp2.IsReady || !_lp3.IsReady) return false; return true; } ); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { Stop(string.Format("Home failed.")); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } public void Abort() { } } }