using System; using Aitex.Core.RT.Device; using Aitex.Core.RT.Event; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using EFEM.RT.Devices; using MECF.Framework.Common.Equipment; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase; namespace EFEM.RT.Routines.LP { internal class HomeRoutine : CommonRoutine, IRoutine { enum Home { Reset, Home, Wait, } private SCConfigItem _scHomeTimeout = null; private int _timeoutHome = 0; public ModuleName Chamber { get; set; } LoadPortBaseDevice _device = null; public HomeRoutine(string module, string name) { Module = module; Name = name; } public bool Initalize() { _scHomeTimeout = SC.GetConfigItem("LoadPort.TimeLimitLoadportLoad"); return true; } public Result Start(params object[] objs) { _timeoutHome = _scHomeTimeout.IntValue; Reset(); _device = DEVICE.GetDevice(Chamber.ToString()); EV.PostMessage(Chamber.ToString(), EventEnum.HomeBegins, Chamber.ToString()); string reason = string.Empty; if (SC.GetValue("System.LPRobotActionIntervene")) { if(!CheckLoadportMotionInterlock(Chamber, out reason)) { EV.PostMessage(Chamber.ToString(), EventEnum.HomeFailed, reason); return Result.FAIL; } } if (Chamber == ModuleName.LP1) { if (DeviceModel.SensorRBNotExtendSIMF1 != null && DeviceModel.SensorRBNotExtendSIMF1.Value) { EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, "robot Extend to LP1."); } } else { if (DeviceModel.SensorRBNotExtendSIMF2 != null && DeviceModel.SensorRBNotExtendSIMF2.Value) { EV.PostMessage(Chamber.ToString(), EventEnum.DefaultWarning, "robot Extend to LP2."); } } return Result.RUN; } public Result Monitor() { try { LoadportReset((int)Home.Reset, _device, "reset", _timeoutHome, Notify, Stop); LoadportInit((int)Home.Home, _device, "home", Notify, Stop); WaitLoadportMotion((int)Home.Wait, _device, "homing...", _timeoutHome, Notify, Stop); } catch (RoutineBreakException) { return Result.RUN; } catch (RoutineFaildException) { return Result.FAIL; } EV.PostMessage(ModuleName.System.ToString(), EventEnum.HomeEnds, ModuleName.System.ToString()); return Result.DONE; } protected override void Notify(string message) { EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Home sequence :{0}", message)); } /// /// prepare process failed /// /// /// protected override void Stop(string failReason) { string reason = String.Empty; EV.PostMessage(Module, EventEnum.HomeFailed, failReason); } } }