using Aitex.Core.RT.Device; using Aitex.Core.RT.Event; using Aitex.Core.RT.SCCore; using athosRT.FSM; using athosRT.tool; using MECF.Framework.Common.Equipment; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.OcrReaders; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace athosRT.Modules.LPs { public class ReadWaferIDRoutine : ModuleRoutineBase, FSM.IRoutine { private SCConfigItem _screaderTimeout => SC.GetConfigItem("OcrReader.TimeLimitForWID"); private int _timeoutReadID = 0; private OcrReader widreader = null; public string JobName { get; set; } public ReadWaferIDRoutine(ModuleName module) : base(module) { } public string _reason = string.Empty; public RState Start(params object[] objs) { _timeoutReadID = _screaderTimeout.IntValue; widreader = DEVICE.GetDevice("WIDReader"); Reset(); //EV.PostMessage(ModuleName.Robot.ToString(), EventEnum.AlignBegins, (object)string.Format("{0:D}", (object)this.Notch)); return Runner.Start(Module, "ReadWaferID"); } public RState Monitor() { Runner. Run(ReadWaferIDStep.ReadWaferID, ReadWaferID, ReaderBusy, _timeoutReadID). Run(ReadWaferIDStep.Offline, Offline, ReaderBusy, _timeoutReadID). Run(ReadWaferIDStep.LoadJob, LoadJob, ReaderBusy, _timeoutReadID). Run(ReadWaferIDStep.Online, Online, ReaderBusy, _timeoutReadID). End(ReadWaferIDStep.ReadWaferID, ReadWaferID, ReaderBusy, _timeoutReadID) ; return Runner.Status; } public bool ReadWaferID() { if (widreader.Read(out _reason)) { return true; } else { LogObject.Error("WIDReader", $"无法执行Read reason:{_reason}"); return false; } return true; } public bool ReaderBusy() { if (widreader.Busy) { return false; } else { LogObject.Info("WIDReader", "not busy"); return true; } } public bool LoadJob(){ if (widreader.LoadJob(JobName, out _reason)) { return true; } else { LogObject.Error("WIDReader", $"无法执行LoadJob reason:{_reason}"); return false; } } public bool Offline(){ if (widreader.Online(false, out _reason)) { return true; } else { LogObject.Error("WIDReader", $"无法执行Offline reason:{_reason}"); return false; } } public bool Online(){ if (widreader.Online(true, out _reason)) { return true; } else { LogObject.Error("WIDReader", $"无法执行Online reason:{_reason}"); return false; } } public void Abort() { } public enum ReadWaferIDStep { ReadWaferID, LoadJob, Offline, Online, ReaderBusy } } }