namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Wire; /// /// PMC address-letter → FOCAS ADR_* numeric code. Values are the FOCAS/2 wire /// constants passed as the area argument on pmc_rdpmcrng /// (G=0, F=1, Y=2, X=3, A=4, R=5, T=6, K=7, C=8, D=9, E=10). /// public enum FocasPmcArea : short { G = 0, F = 1, Y = 2, X = 3, A = 4, R = 5, T = 6, K = 7, C = 8, D = 9, E = 10, } /// /// PMC data-type numeric codes per FOCAS/2: Byte=0, Word=1, Long=2, /// Real=4, Double=5. Passed as the data_type argument on /// pmc_rdpmcrng. /// public enum FocasPmcDataType : short { Byte = 0, Word = 1, Long = 2, Real = 4, Double = 5, } /// /// CNC operation mode as reported by cnc_rdopmode. Values are the FOCAS-defined /// mode codes; see for the canonical /// operator-facing labels. /// public enum FocasOperationMode : short { Mdi = 0, Auto = 1, TJog = 2, Edit = 3, Handle = 4, Jog = 5, TeachInHandle = 6, Reference = 7, Remote = 8, Test = 9, } /// Extension helpers over . public static class FocasOperationModeExtensions { /// /// Canonical operator-facing label for an operation mode (e.g. "AUTO", /// "EDIT"). Delegates to so the wire layer /// and the fixed-tree projection render identical labels — historically these two /// surfaces diverged ("TJOG" vs "T-JOG", "TEACH_IN_HANDLE" vs "TEACH-IN-HANDLE", /// and different unknown-code fallbacks). Resolved by Driver.FOCAS-010. /// public static string ToText(this FocasOperationMode mode) => FocasOpMode.ToText((short)mode); } /// /// Letter → lookup. Used by to /// translate a parsed into the wire code expected by /// pmc_rdpmcrng. /// internal static class FocasPmcAreaLookup { public static FocasPmcArea? FromLetter(string letter) => letter.ToUpperInvariant() switch { "G" => FocasPmcArea.G, "F" => FocasPmcArea.F, "Y" => FocasPmcArea.Y, "X" => FocasPmcArea.X, "A" => FocasPmcArea.A, "R" => FocasPmcArea.R, "T" => FocasPmcArea.T, "K" => FocasPmcArea.K, "C" => FocasPmcArea.C, "D" => FocasPmcArea.D, "E" => FocasPmcArea.E, _ => null, }; } /// /// mapping for wire PMC /// reads. Bit reads collapse to byte — the caller extracts the bit from the returned /// value. /// internal static class FocasPmcDataTypeLookup { public static FocasPmcDataType FromFocasDataType(FocasDataType t) => t switch { FocasDataType.Bit or FocasDataType.Byte => FocasPmcDataType.Byte, FocasDataType.Int16 => FocasPmcDataType.Word, FocasDataType.Int32 => FocasPmcDataType.Long, FocasDataType.Float32 => FocasPmcDataType.Real, FocasDataType.Float64 => FocasPmcDataType.Double, _ => FocasPmcDataType.Byte, }; }