using Aitex.Core.Common; using Aitex.Core.RT.Device; using Aitex.Core.Util; using Aitex.Sorter.Common; using athosRT.Devices.EFEM.ABS; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using EV = athosRT.tool.EV; namespace athosRT.Devices.EFEM.Task { public class CheckImp { protected ErrorCheckList1 flag1 = 0; protected ErrorCheckList2 flag2 = 0; protected ErrorCheckList3 flag3 = 0; protected int LoadPortQuantity = Singleton.Instance.GetValue(nameof(LoadPortQuantity)).GetValueOrDefault(); protected int LoadLockQuantity = Singleton.Instance.GetValue(nameof(LoadLockQuantity)).GetValueOrDefault(); protected bool AlignerInstalled = Singleton.Instance.GetValue(nameof(AlignerInstalled)).GetValueOrDefault(); protected bool CoolingBufferInstalled = Singleton.Instance.GetValue(nameof(CoolingBufferInstalled)).GetValueOrDefault(); protected bool RobotIsSingleArm = Singleton.Instance.GetValue(nameof(RobotIsSingleArm)).GetValueOrDefault(); protected bool MultiWaferSize = Singleton.Instance.GetValue(nameof(MultiWaferSize)).GetValueOrDefault(); public const string PARAM_NG = "PARAM_NG"; protected int _token; public bool HasInfoMessage { get; set; } public CheckImp() => HasInfoMessage = true; public bool CheckError(string device, out string reason) { //44个policy 额滴神啊 //44个policy 只有3个包含真正的判断的check 其他都是空的 3个分别是EMSPolicy、VacPolicy、AirPolicy //剩余一些信号可能要加 所以要将IO信号、task等搞清楚 方便修改、添加条件 //if ( flag1.HasFlag(ErrorCheckList1.VAC) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.AIR) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.STALL) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.LIMIT) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.SENSOR) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.POSITION) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.EMS) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.COMM) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.COMM2) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.VACON) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.VACOFF) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.CLAMPON) && !Check(device, out reason) // || flag1.HasFlag(ErrorCheckList1.CLAMPOF) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.RRTWAF) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.CRSWAF) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.THICKWAF) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.THINWAF) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.DBLWAF) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.BAOWAF) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.COMMAND) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.PODNG) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.PODMISMATCH) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.VAC_S) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.CLAMP_S) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.SAFTY) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.LOCKNG) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.UNLOCKNG) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.L_KEY_LK) && !Check(device, out reason) // || flag2.HasFlag(ErrorCheckList2.L_KEY_UL) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.MAP_S) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.MAP_S1) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.MAP_S2) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.WAFLOST) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.ALIGNNG) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.PODNG) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.PODMISMATCH) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.VAC_S) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.CLAMP_S) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.DRIVER) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.DRPOWERDOWN) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.HARDWARE) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.INTERNAL) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.E84_TIMEOUTx) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.E84_CS_VALID) && !Check(device, out reason) // || flag3.HasFlag(ErrorCheckList3.READFAIL) && !Check(device, out reason)) if (flag1.HasFlag(ErrorCheckList1.VAC) && !Check(device, out reason) || flag1.HasFlag(ErrorCheckList1.AIR) && !Check(device, out reason) || flag1.HasFlag(ErrorCheckList1.EMS) && !Check(device, out reason) ) return false; reason = "UNDEFINITION"; return true; } public bool Check(string device, out string reason) where T : class, IPolicy, new() { reason = string.Empty; return Singleton.Instance.Check(device, out reason); } //用来判断传入的字符串 符合开头/结尾/包含中间参数的情况 protected string Args2Unit(string args) { string str = string.Empty; if (string.IsNullOrEmpty(args) || args.StartsWith("ALL") || args.StartsWith("SYSTEM")) str = "System"; else if (args.StartsWith("ROB")) str = "Robot"; else if (args.StartsWith("ALIGN")) { if (AlignerInstalled) str = "Aligner"; else if (CoolingBufferInstalled) { if (args.EndsWith("ALIGN1") || args.EndsWith("ALIGN")) str = "CoolingBuffer1"; else if (args.EndsWith("ALIGN2")) str = "CoolingBuffer2"; else if (args.EndsWith("ALIGN3")) str = "Aligner1"; else if (args.EndsWith("ALIGN4")) str = "Aligner2"; } } else if (args.Equals("P1") && LoadPortQuantity > 0) str = "LP1"; else if (args.Equals("P2") && LoadPortQuantity > 1) str = "LP2"; else if (args.Equals("P3") && LoadPortQuantity > 2) str = "LP3"; else if (args.Equals("P4") && LoadPortQuantity > 3) str = "LP4"; else if (args.Equals("P5") && LoadPortQuantity > 4) str = "LP5"; else if (args.Equals("P6") && LoadPortQuantity > 5) str = "LP6"; else if (args.Equals("P7") && LoadPortQuantity > 6) str = "LP7"; else if (args.Equals("P8") && LoadPortQuantity > 7) str = "LP8"; else if (args.Equals("P9") && LoadPortQuantity > 8) str = "LP9"; else if (args.Equals("P10") && LoadPortQuantity > 9) str = "LP10"; else if ((args.Equals("LLA") || args.StartsWith("LLLA")) && LoadLockQuantity > 0) str = "LoadlockA"; else if ((args.Equals("LLB") || args.StartsWith("LLLB")) && LoadLockQuantity > 1) str = "LoadlockB"; else if (args.Equals("LLC") && LoadLockQuantity > 2) str = "LoadlockC"; else if (args.Equals("LLD") && LoadLockQuantity > 3) str = "LoadlockD"; else if (args.Equals("STOWER")) str = "SignalTower"; return str; } //与上差不多 但会将modulename通过外部变量target传回去 protected bool ParseMoveTarget(string args, out ModuleName target, out int slot) { target = ModuleName.System; slot = 1; if (args.StartsWith("ALIGN")) { if (AlignerInstalled) { target = ModuleName.Aligner; slot = 1; } else if (CoolingBufferInstalled) { if (args.EndsWith("ALIGN1") || args.EndsWith("ALIGN")) { target = ModuleName.CoolingBuffer1; slot = 1; } else if (args.EndsWith("ALIGN2")) { target = ModuleName.CoolingBuffer2; slot = 1; } else if (args.EndsWith("ALIGN3")) { target = ModuleName.Aligner1; slot = 1; } else if (args.EndsWith("ALIGN4")) { target = ModuleName.Aligner2; slot = 1; } } return true; } if (args.StartsWith("P1") && LoadPortQuantity > 0) { target = ModuleName.LP1; if (int.TryParse(args.Replace("P1", ""), out slot)) return true; } else if (args.StartsWith("P2") && LoadPortQuantity > 1) { target = ModuleName.LP2; if (int.TryParse(args.Replace("P2", ""), out slot)) return true; } else if (args.StartsWith("P3") && LoadPortQuantity > 2) { target = ModuleName.LP3; if (int.TryParse(args.Replace("P3", ""), out slot)) return true; } else if (args.StartsWith("P4") && LoadPortQuantity > 3) { target = ModuleName.LP4; if (int.TryParse(args.Replace("P4", ""), out slot)) return true; } if (args.StartsWith("BUFFER")) { target = ModuleName.Buffer; if (int.TryParse(args.Replace("BUFFER", ""), out slot)) return true; } else if (args.StartsWith("LLLA") || args.StartsWith("LLA")) { target = ModuleName.LL1; string s = args.Replace("LLLA", "").Replace("LLA", ""); if (string.IsNullOrEmpty(s)) { slot = 1; return true; } if (int.TryParse(s, out slot)) return true; } else if (args.StartsWith("LLLB") || args.StartsWith("LLB")) { target = ModuleName.LL2; string s = args.Replace("LLLB", "").Replace("LLB", ""); if (string.IsNullOrEmpty(s)) { slot = 1; return true; } if (int.TryParse(s, out slot)) return true; } return false; } //与上是差不多 但目标是输出Robot的arm protected bool ParseMoveArm(string args, out Hand arm) { arm = Hand.Blade2; string str = args; if (!(str == "ARM1")) { if (!(str == "ARM2")) { if (!(str == "ARM3")) return false; arm = Hand.Both; } else arm = Hand.Blade1; } else arm = Hand.Blade2; return !RobotIsSingleArm || arm == 0; } protected bool CheckWaferSize(string waferSize, ModuleName target, int slot) { WaferSize result; if (!Enum.TryParse(waferSize, out result)) { EV.PostWarningLog("EFEM", waferSize + " is not a valid size type"); return false; } if (ModuleHelper.IsLoadPort(target)) { OpenStageWithWaferSizeLoadPort device = DEVICE.GetDevice(target.ToString()); if (device.CassetteState == LoadportCassetteState.Normal && device.WaferSize != result) { EV.PostWarningLog("EFEM", string.Format("{0} is not match target {1}", (object)device.WaferSize, (object)result)); return false; } } else if (Singleton.Instance.CheckHasWafer(target, slot) && Singleton.Instance.GetWaferSize(target, slot) != result) { EV.PostWarningLog("EFEM", string.Format("{0} is not match target {1}", (object)Singleton.Instance.GetWaferSize(target, slot), (object)result)); return false; } return true; } protected bool CheckIsPort(string device) => device == "LP1" || device == "LP2" || device == "LP3" || device == "LP4"; protected bool CheckIsTower(string device) => device == "SignalTower"; //获取实例化的Entity protected IServerModule GetEntity(string name) { IServerModule entity = Singleton.Instance.GetEntity(name); return entity.Name == "Aligner" && !AlignerInstalled ? null : entity; } } }