namespace ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Protocol;

/// <summary>
/// Single source of truth for which data-connection protocol strings produce an
/// adapter that implements <see cref="IAlarmSubscribableConnection"/> (i.e. can
/// mirror native alarms).
///
/// The set MUST stay in sync with the protocols registered against an
/// alarm-subscribable adapter in
/// <c>DataConnectionLayer/DataConnectionFactory.cs</c>: today the "OpcUa" adapter
/// (<c>OpcUaDataConnection</c>) and the "MxGateway" adapter
/// (<c>MxGatewayDataConnection</c>) both implement
/// <see cref="IAlarmSubscribableConnection"/>. The runtime decision is made in
/// <c>DataConnectionActor</c> via <c>_adapter is IAlarmSubscribableConnection</c>;
/// this central-side helper lets the deploy pipeline and Central UI gate
/// native-alarm-source bindings against the same notion without instantiating an
/// adapter. Adding a new alarm-capable protocol = register the adapter in the
/// factory AND add its protocol string here.
/// </summary>
public static class AlarmCapableProtocols
{
    /// <summary>
    /// Determines whether a data connection's protocol string resolves to an
    /// alarm-capable adapter (one implementing <see cref="IAlarmSubscribableConnection"/>).
    /// Case-insensitive to match <c>DataConnectionFactory</c>'s own
    /// <c>OrdinalIgnoreCase</c> protocol-key lookup; <c>null</c>/blank is not
    /// alarm-capable.
    /// </summary>
    /// <param name="protocol">The data connection protocol string (e.g. "OpcUa").</param>
    /// <returns><c>true</c> when the protocol's adapter can subscribe native alarms; otherwise <c>false</c>.</returns>
    public static bool IsAlarmCapable(string? protocol) =>
        string.Equals(protocol, "OpcUa", StringComparison.OrdinalIgnoreCase)
        || string.Equals(protocol, "MxGateway", StringComparison.OrdinalIgnoreCase);
}
