using ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.PlcFamilies; namespace ZB.MOM.WW.OtOpcUa.Driver.AbLegacy; /// /// The ONE place an AbLegacy driver's effective transport is decided from its configured /// . The driver constructor, the Test Connect probe and the /// CLI (through the driver) all resolve through here. /// An absent key means = for EVERY /// family (final review I3): on a wire the native PCCC path is proven only for N-file reads and writes /// and one F8 read, so Native stays opt-in. An explicit value always wins (an operator choice). An /// explicit Native on a PLC-5 / LogixPccc device is allowed but logs a once-per-instance Warning /// (). /// public static class AbLegacyTransportResolver { /// Returns true for a family whose native transport support is limited. /// The PLC family. /// True for PLC-5 and LogixPccc. public static bool IsNativeLimited(AbLegacyPlcFamily family) => family is AbLegacyPlcFamily.Plc5 or AbLegacyPlcFamily.LogixPccc; /// Returns the distinct native-limited families among . /// The configured devices. /// The limited families present, in declaration order. public static IReadOnlyList NativeLimitedFamilies(IEnumerable devices) { ArgumentNullException.ThrowIfNull(devices); return [.. devices.Select(d => d.PlcFamily).Where(IsNativeLimited).Distinct()]; } /// The transport an absent / null transport key selects (all families). public const AbLegacyTransport Default = AbLegacyTransport.Libplctag; /// Returns the effective transport: an explicit value always wins; null means . /// The configured transport, or null for "use the default". /// The transport the driver runs on. public static AbLegacyTransport Resolve(AbLegacyTransport? configured) => configured ?? Default; /// Returns the effective transport for . /// The driver options. /// The transport the driver runs on. public static AbLegacyTransport Resolve(AbLegacyDriverOptions options) { ArgumentNullException.ThrowIfNull(options); return Resolve(options.Transport); } /// /// Operator-facing description of the configured-vs-effective transport for the init log line: /// Libplctag (default) when the key was absent, Native (configured) when explicit. /// /// The configured transport, or null. /// A short description. public static string Describe(AbLegacyTransport? configured) => configured is null ? $"{Resolve(configured)} (default)" : $"{configured} (configured)"; }