using Aitex.Core.RT.Device; using Aitex.Core.RT.SCCore; using Aitex.Sorter.Common; using athosRT.FSM; using athosRT.tool; using MECF.Framework.Common.Equipment; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.OcrReaders; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static Aitex.Core.Util.SubscriptionAttribute; namespace athosRT.Modules.EFEMs.Routine { public class AlignRoutine : ModuleRoutineBase, FSM.IRoutine { private SCConfigItem _scAlignTimeout = null; private SCConfigItem _scReaderTimeout = null; private SCConfigItem _scReadLaserNotch = null; private int _timeoutAlign = 0; private int _timeoutReadID = 0; private double _fReadLaserNotch = 0.0; private Aligner aligner; private OcrReader widreader = null; private bool flag; public double Notch { get; set; } public MoveOption Option { get; set; } public bool VerifyAny { get; set; } public bool VerifyLaserMaker { get; set; } public string LaserMaker { get; set; } public bool VerifyT7Code { get; set; } public string T7Code { get; set; } public AlignRoutine():base(ModuleName.Aligner) { Name = "Aligner"; widreader = DEVICE.GetDevice("WIDReader"); _scAlignTimeout = SC.GetConfigItem("Aligner.TimeLimitForAlignWafer"); _scReaderTimeout = SC.GetConfigItem("OcrReader.TimeLimitForWID"); _scReadLaserNotch = SC.GetConfigItem("Aligner.AlignerReadAngle"); aligner = DEVICE.GetDevice("Aligner"); flag = false; } public RState Start(params object[] objs) { Reset(); _scAlignTimeout = SC.GetConfigItem("Aligner.TimeLimitForAlignWafer"); _scReaderTimeout = SC.GetConfigItem("OcrReader.TimeLimitForWID"); _scReadLaserNotch = SC.GetConfigItem("Aligner.AlignerReadAngle"); _timeoutAlign = _scAlignTimeout.IntValue*1000; _timeoutReadID = _scReaderTimeout.IntValue * 1000; _fReadLaserNotch = _scReadLaserNotch.IntValue * 1000; return Runner.Start(ModuleName.Aligner,"aligner routine 开始"); } public enum AlignStep { AlignWafer, ReleaseAligner, AlignerMoveUp, ReadWaferID, ReadWaferID1, AlignWafer1, ReleaseAligner1, AlignerMoveUp1, } public RState Monitor() { Runner .Run(AlignStep.AlignWafer, AlignWafer, CheckAlignReady, _timeoutAlign) .Run(AlignStep.ReleaseAligner, ReleaseAlign, CheckAlignReady, _timeoutAlign) .Run(AlignStep.AlignerMoveUp, AlignerMoveUp, CheckAlignReady, _timeoutAlign) .Run(AlignStep.ReadWaferID, ReadWafer1, Check1WIDReader, _timeoutAlign) .Run(AlignStep.ReadWaferID1, ReadWafer2, Check2WIDReader, _timeoutAlign) .Run(AlignStep.AlignWafer1, AlignWafer1, CheckAlignReady1, _timeoutAlign) .Run(AlignStep.ReleaseAligner1, ReleaseAlign1, CheckAlignReady1, _timeoutAlign) .End(AlignStep.AlignerMoveUp1, AlignerMoveUp1, CheckAlignReady1, _timeoutAlign) ; return Runner.Status; } private bool ReadWafer2() { if ((Option & MoveOption.ReadID2) == MoveOption.ReadID2) { if (widreader.Read(false, out _)) { LogObject.Info(Name, "wafer id reader操作成功"); return true; } else { LogObject.Error(Name, "wafer id reader操作失败"); return false; } } return true; } private bool Check1WIDReader() { if ((Option & MoveOption.ReadID) == MoveOption.ReadID) { if (!widreader.Busy) { LogObject.Info(Name, "ID Reader 设备不再busy"); return true; } else { LogObject.Info(Name, "ID Reader 设备仍busy"); return false; } } return true; } private bool Check2WIDReader() { if ((Option & MoveOption.ReadID2) == MoveOption.ReadID2) { if (!widreader.Busy) { LogObject.Info(Name, "ID Reader 设备不再busy"); return true; } else { LogObject.Info(Name, "ID Reader 设备仍busy"); return false; } } return true; } private bool ReadWafer1() { if ((Option & MoveOption.ReadID) == MoveOption.ReadID) { if (widreader.Read(true, out _)) { LogObject.Info(Name, "wafer id reader操作成功"); return true; } else { LogObject.Error(Name, "wafer id reader操作失败"); return false; } } return true; } private bool AlignerMoveUp() { if (check1()) { if (aligner.LiftUp(out _)) { LogObject.Info(Name, "align MoveUp操作成功"); return true; } else { LogObject.Error(Name, "align MoveUp操作失败"); return false; } } return true; } private bool ReleaseAlign() { if (check1()) { if (aligner.Release(Hand.Both, out _)) { LogObject.Info(Name, "align Release操作成功"); return true; } else { LogObject.Error(Name, "align Release操作失败"); return false; } } return true; } private bool CheckAlignReady() { if (check1()) { if (!aligner.Busy) { LogObject.Info(Name, "align 设备不再busy"); return true; } else { LogObject.Info(Name, "align 设备仍busy"); return false; } } return true; } private bool AlignWafer() { if (check1()) { if (aligner.Align(Notch, out _)) { LogObject.Info(Name, "align wafer操作成功"); return true; } else { LogObject.Error(Name, "align wafer操作失败"); return false; } } return true; } private bool AlignerMoveUp1() { if (check2()) { if (aligner.LiftUp(out _)) { LogObject.Info(Name, "align1 MoveUp操作成功"); return true; } else { LogObject.Error(Name, "align1 MoveUp操作失败"); return false; } } return true; } private bool ReleaseAlign1() { if (check2()) { if (aligner.Release(Hand.Both, out _)) { LogObject.Info(Name, "align1 Release操作成功"); return true; } else { LogObject.Error(Name, "align1 Release操作失败"); return false; } } return true; } private bool CheckAlignReady1() { if (check2()) { if (!aligner.Busy) { LogObject.Info(Name, "align1 设备不再busy"); return true; } else { LogObject.Info(Name, "align1 设备仍busy"); return false; } } return true; } private bool AlignWafer1() { if (check2()) { if (aligner.Align(Notch, out _)) { LogObject.Info(Name, "align1 wafer操作成功"); return true; } else { LogObject.Error(Name, "align1 wafer操作失败"); return false; } } return true; } public void Abort() { } private bool check2() { return (!flag || Math.Abs(this.Notch - this._fReadLaserNotch) > 0.01); } private bool check1() { if ((Option & MoveOption.ReadID) == MoveOption.ReadID || (Option & MoveOption.ReadID2) == MoveOption.ReadID2) { flag = true; return true; } else { flag = false; return false; } } } }