using System; using Aitex.Core.RT.Device; using Aitex.Core.RT.Log; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts; namespace JetEfemLib.LPs { class LoadPortReadCarrierIdRoutine : ModuleRoutineBase, IStepRoutine { enum RoutineStep { ReadCarrierId, QueryStatus, End, } private int _timeout = 0; LoadPort _lp = null; private LoadPortModule _lpModule; public LoadPortReadCarrierIdRoutine(LoadPortModule lpModule) : base(lpModule.Module) { _lpModule = lpModule; Name = "ReadCarrierId"; } public bool Initalize() { return true; } public RState Start(params object[] objs) { Reset(); _timeout = SC.GetValue("EFEM.LoadPort.MotionTimeout"); return Runner.Start(_lpModule.Module, Name); } public RState Monitor() { Runner.Run(RoutineStep.ReadCarrierId, ReadCarrierId, CheckDevice, _timeout * 1000) .End(RoutineStep.QueryStatus, QueryStatus, CheckDevice, _timeout * 1000); return Runner.Status; } bool ReadCarrierId() { Notify($"Start read carrier id {_lpModule.LPDevice.Name}"); if (!_lpModule.LPDevice.ReadRfId(out string reason)) { Stop(reason); return false; } return true; } bool CheckDevice() { return !(_lpModule.LPDevice.Error || _lpModule.LPDevice.IsBusy); } bool QueryStatus() { Notify($"Start query status {_lpModule.LPDevice.Name}"); string reason; if (!_lpModule.LPDevice.QueryState(out reason)) { Stop(reason); return false; } return true; } public void Abort() { } } }