using Opc.Ua; using Serilog; namespace ZB.MOM.WW.OtOpcUa.Host.OpcUa { /// /// Maps a configured redundancy mode string to the OPC UA enum. /// public static class RedundancyModeResolver { private static readonly ILogger Log = Serilog.Log.ForContext(typeof(RedundancyModeResolver)); /// /// Resolves the configured mode string to a value. /// Returns when redundancy is disabled or the mode is unrecognized. /// /// The mode string from configuration (e.g., "Warm", "Hot"). /// Whether redundancy is enabled. /// The resolved redundancy support mode. public static RedundancySupport Resolve(string mode, bool enabled) { if (!enabled) return RedundancySupport.None; var resolved = (mode ?? "").Trim().ToLowerInvariant() switch { "warm" => RedundancySupport.Warm, "hot" => RedundancySupport.Hot, _ => RedundancySupport.None }; if (resolved == RedundancySupport.None) Log.Warning("Unknown redundancy mode '{Mode}' — falling back to None. Supported modes: Warm, Hot", mode); return resolved; } } }