using Aitex.Core.Common; using Aitex.Core.RT.Device; using Aitex.Core.RT.Event; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using Aitex.Sorter.Common; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Schedulers; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes; using MECF.Framework.RT.EquipmentLibrary.LogicUnits; using static JetEfemLib.Efems.EfemModule; namespace JetEfemLib.Aligners { public class FutureAligner : AlignerBase, ITransferTarget, IEfemAlignerCallback { private RorzeEfem _efem; private string _efemName; private bool _actionDone = false; private EfemType _efemType; public FutureAligner(string module, string name, string efemName):base(module, name, module, module) { base.Module = module; base.Name = name; base.Display = name; base.DeviceID = ""; _efemName = efemName; _efemType = (EfemType)SC.GetValue($"EFEM.EfemType"); //IsMapWaferByLoadPort = false; } public override bool IsBusy { get { if (_efemType != EfemType.FutureEfem3P) return _efem.CheckIsBusy(ModuleHelper.Converter(Module)) && !_actionDone; else return _efem.CheckIsBusy(ModuleName.Aligner) && !_actionDone; } } public override bool Initialize() { if (_efem == null && !string.IsNullOrEmpty(_efemName)) { _efem = DEVICE.GetDevice(_efemName); _efem.SetAlignerCallback(ModuleHelper.Converter(Module), this); } //base.Initialize(); return true; } private void _aligner_AlarmGenerated(string moduleName, EventLevel level, string message) { if (moduleName == Module) IsError = true; } public override bool Home(out string reason) { reason = string.Empty; if (!_efem.HomeWaferAligner(ModuleHelper.Converter(Module),out reason)) { OnError(); return false; } _actionDone = false; return true; } public override bool Align(double angle, out string reason) { reason = string.Empty; if (!_efem.AlignWafer(ModuleHelper.Converter(Module), angle, out reason)) { OnError(); return false; } _actionDone = false; return true; } public override bool Lift(string Position, out string reason) { reason = string.Empty; if(_efemType != EfemType.FutureEfem3P) { if (!_efem.Lift(ModuleHelper.Converter(Module), Position, out reason)) { OnError(); return false; } _actionDone = false; } else _actionDone = true; return true; } public override bool QueryWaferPresence(out string reason) { reason = string.Empty; if (!_efem.AlignerMapWaferPresence(out string slotMap, out reason)) { return false; } //bool hasWafer = slotMap.Substring(0, 1) == "1"; //if (hasWafer && // WaferManager.Instance.CheckNoWafer(Module, 0)) //{ // EV.PostInfoLog(Module, $"found map wafer, created wafer at {Module}"); // WaferManager.Instance.CreateWafer(ModuleHelper.Converter(Module), 0, WaferStatus.Normal); //} //if (!hasWafer && // WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), 0)) //{ // EV.PostInfoLog(Module, $"did not find wafer, delete wafer from {Module} "); // WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Module), 0); //} return true; } public bool PrepareTransfer(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason) { throw new System.NotImplementedException(); } public bool TransferHandoff(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason) { throw new System.NotImplementedException(); } public bool PostTransfer(ModuleName robot, Hand blade, int[] targetSlot, EnumTransferType transferType, out string reason) { throw new System.NotImplementedException(); } public bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason) { reason=string.Empty; if (transferType == EnumTransferType.Pick) { return WaferManager.Instance.CheckHasWafer(Module,targetSlot); } if (transferType == EnumTransferType.Place) { return WaferManager.Instance.CheckNoWafer(Module,targetSlot); } return false; } public bool NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason) { reason = string.Empty; return true; } public bool NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason) { reason = string.Empty; return true; } public void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType) { } public void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType) { } public void NoteComplete() { _actionDone = true; } public void NoteCancel(string error) { } } }