using Aitex.Core.RT.Device; using Aitex.Core.RT.Routine; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.HwAligner; using System; namespace Mainframe.Aligners { public class AlignerBaseRoutine : ModuleRoutine, IRoutine { private HwAlignerGuide _alignerDevice = null; protected AlignerBaseRoutine() : base(ModuleName.Aligner.ToString()) { _alignerDevice = DEVICE.GetDevice($"Aligner.HiWinAligner"); } public override void Abort() { } //清除Aligner报警 protected void AlignerERS(int id,int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"Aligner ERS"); _alignerDevice.Set("ERS", "ERS"); return true; }, () => { return !_alignerDevice.IsBusy; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) { Stop($"Aligner ERS Timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } //初始化变量 protected void ResetVar(int id) { Tuple ret = Execute(id, () => { Notify($"Aligner Reset Variate "); _alignerDevice.Reset(); return true; }); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { Stop($"Sensor[DI-32] check no tray"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } //电机回原点 protected void Home(int id, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"Aligner Home Msg"); _alignerDevice.Set("HOM", "HOM"); return true; }, () => { return !_alignerDevice.IsBusy; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) //timeout { Stop($"Aligner home Timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } //移动到测量中心 protected void AlignerMoveToMeasure(int id, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"Move to Measure position"); _alignerDevice.Set("MTM","MTM"); return true; }, () => { return !_alignerDevice.IsBusy; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) { Stop($"Aligner Move to Measure position Timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } //检查是否有Wafer protected void CheckHaveWafer(int id, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"check wafer exist or not"); _alignerDevice.Set("DOC", "DOC"); return true; }, () => { if (!_alignerDevice.IsBusy) { if (_alignerDevice.HaveWafer) { if (WaferManager.Instance.CheckNoWafer(Module, 0)) { WaferManager.Instance.CreateWafer(ModuleHelper.Converter(Module), 0,Aitex.Core.Common.WaferStatus.Normal); } return true; } else { if (WaferManager.Instance.CheckHasWafer(Module, 0)) { WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Module), 0); } return true; } } return false; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) { Stop($"Aligner Check Wafer Timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } //寻边 protected void DoAliger(int id, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"Alinger"); _alignerDevice.Set("BAL", "BAL"); return true; }, () => { return !_alignerDevice.IsBusy; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) { Stop($"Aligner Alinger Timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } //打开真空 protected void OpenVacuum(int id, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"Open Vacuum"); _alignerDevice.Set("CVN", "CVN"); return true; }, () => { return !_alignerDevice.IsBusy; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) { Stop($"Aligner Open Vacuum Timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } //关闭真空 protected void CloseVacuum(int id, int timeout) { Tuple ret = ExecuteAndWait(id, () => { Notify($"Close Vacuum"); _alignerDevice.Set("CVF", "CVF"); return true; }, () => { return !_alignerDevice.IsBusy; }, timeout * 1000); if (ret.Item1) { if (ret.Item2 == Result.FAIL) { throw (new RoutineFaildException()); } else if (ret.Item2 == Result.TIMEOUT) { Stop($"Aligner Close Vacuum Timeout, over {timeout} seconds"); throw (new RoutineFaildException()); } else throw (new RoutineBreakException()); } } } }