using ZB.MOM.WW.OtOpcUa.Core.Abstractions; namespace ZB.MOM.WW.OtOpcUa.Driver.AbLegacy; /// /// MicroLogix 1100/1400 function-file sub-element catalogue: the driver-surface type of /// RTC:0.HR, HSC:0.ACC, ... Covers the commonly-addressed members per file — not exhaustive /// (Rockwell defines 30+ on RTC alone). Not readable today: the layouts are transcribed from the /// MicroLogix instruction-set reference; the native transport has no encoding for these files and libplctag /// cannot parse their names, so both refuse them before the wire (BadNotSupported, #592). /// public static class AbLegacyFunctionFile { /// /// Driver-surface type for .; an unrecognised /// sub-element falls back to so the driver never refuses a member the /// catalogue happens to omit. /// /// The function-file letter (RTC, HSC, ...). /// The sub-element mnemonic, or null. /// The mapped driver data type. public static DriverDataType SubElementType(string fileLetter, string? subElement) { if (subElement is null) return DriverDataType.Int32; return (fileLetter.ToUpperInvariant(), subElement.ToUpperInvariant()) switch { // Real-time clock: time fields are 16-bit words; DS (disabled) / BL (battery low) are flags. ("RTC", "DS") or ("RTC", "BL") or ("RTC", "EN") => DriverDataType.Boolean, // High-speed counter: accumulator/preset/overflow/underflow are numeric, the rest status bits. ("HSC", "EN") or ("HSC", "UF") or ("HSC", "IF") or ("HSC", "IN") or ("HSC", "IH") or ("HSC", "IL") or ("HSC", "DN") or ("HSC", "CD") or ("HSC", "CU") => DriverDataType.Boolean, // Daylight saving + memory-module info. ("DLS", "EN") => DriverDataType.Boolean, ("MMI", "MP") or ("MMI", "MCP") => DriverDataType.Boolean, // Pulse-train / PWM outputs. ("PTO", "EN") or ("PTO", "DN") or ("PTO", "EH") or ("PTO", "ED") or ("PTO", "RP") or ("PTO", "OUT") => DriverDataType.Boolean, ("PWM", "EN") or ("PWM", "DN") or ("PWM", "EH") or ("PWM", "ED") or ("PWM", "RP") or ("PWM", "OUT") => DriverDataType.Boolean, // Selectable timed interrupt + event input interrupt. ("STI", "EN") or ("STI", "TIE") or ("STI", "DN") or ("STI", "PS") or ("STI", "ED") => DriverDataType.Boolean, ("EII", "EN") or ("EII", "TIE") or ("EII", "PE") or ("EII", "ES") or ("EII", "ED") => DriverDataType.Boolean, // Everything else (HR/MIN/SEC/MON/DAY/YR/DOW, ACC/PRE/OVF/UNF, STR/STD, FT/LBN, OF/IDA/ODA/PE/PD, // SPM/ER/PFN, ID/TYP, OS/FRN/BSN/CC, ...) is a numeric word. _ => DriverDataType.Int32, }; } }