using System; using System.Linq; 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; namespace FutureEfemLib.Aligners { public class FutureBuffer : BaseDevice, IDevice, IEfemBufferCallback { private RorzeEfem _efem; private string _efemName; public FutureBuffer(string module, string name, string efemName) : base(module, name, module, module) { base.Module = module; base.Name = name; base.Display = name; base.DeviceID = ""; _efemName = efemName; //IsMapWaferByLoadPort = false; } public bool IsBusy { get { return _efem.CheckIsBusy(ModuleHelper.Converter(Module)); } } public bool Initialize() { if (_efem == null && !string.IsNullOrEmpty(_efemName)) { _efem = DEVICE.GetDevice(_efemName); _efem.SetBufferCallback(ModuleHelper.Converter(Module), this); } //base.Initialize(); 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() { } public void NoteCancel(string error) { } public virtual void NoteSlotMap(string slotMap) { slotMap = slotMap.Replace('3', '2'); slotMap = slotMap.Replace('4', 'W'); slotMap = slotMap.Replace('7', 'W'); slotMap = slotMap.Replace('8', 'W'); slotMap = slotMap.Replace('2', 'W'); var _module = ModuleHelper.Converter(Module); for (int i = 0; i < slotMap.Length; i++) { // No wafer: "0", Wafer: "1", Crossed:"2", Undefined: "?", Overlapping wafers: "W" WaferInfo wafer = null; switch (slotMap[i]) { case '0': WaferManager.Instance.DeleteWafer(_module, i); CarrierManager.Instance.UnregisterCarrierWafer(Name, i); break; case '1': if (!WaferManager.Instance.GetWafer(_module, i).IsEmpty) break; wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Normal); WaferManager.Instance.UpdateWaferSize(_module, i, GetCurrentWaferSize()); CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer); break; case '2': wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Crossed); WaferManager.Instance.UpdateWaferSize(_module, i, GetCurrentWaferSize()); CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer); //NotifyWaferError(Name, i, WaferStatus.Crossed); break; case 'W': wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Double); WaferManager.Instance.UpdateWaferSize(_module, i, GetCurrentWaferSize()); CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer); //NotifyWaferError(Name, i, WaferStatus.Double); break; case '?': wafer = WaferManager.Instance.CreateWafer(_module, i, WaferStatus.Unknown); WaferManager.Instance.UpdateWaferSize(_module, i, GetCurrentWaferSize()); CarrierManager.Instance.RegisterCarrierWafer(Name, i, wafer); //NotifyWaferError(Name, i, WaferStatus.Unknown); break; } } string waferMap = ""; foreach (var wafer in WaferManager.Instance.GetWafers(ModuleHelper.Converter(Module))) { waferMap += wafer.IsEmpty ? "0" : "1"; } if (slotMap != waferMap) { EV.PostAlarmLog("EFEM", $"Map result : {slotMap} is not match {waferMap}"); } else { EV.PostInfoLog("EFEM", $"Map result : {slotMap} is match {waferMap}"); } } private WaferSize GetCurrentWaferSize() { if (SC.GetStringValue("EFEM.EfemRobot.DefaultMapWaferSize").Trim() == "8") return WaferSize.WS8; return WaferSize.WS12; } public void Monitor() { } public void Terminate() { } public void Reset() { } } }