fix(deploy): wire native-alarm-source capability validation into flattening pipeline (#22)

FlatteningPipeline loaded data connections but never passed the alarm-capable
connection set to SemanticValidator, so the native-alarm-source capability check
(built but inert) never ran — a source bound to a non-alarm-capable connection
deployed silently. Compute the capable set (IAlarmSubscribableConnection: OPC UA
+ MxGateway) and thread it through ValidationService to SemanticValidator.
This commit is contained in:
Joseph Doherty
2026-06-15 13:20:20 -04:00
parent 2fb608f1b5
commit d6909207a8
4 changed files with 151 additions and 3 deletions
@@ -0,0 +1,31 @@
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 the DCL <c>DataConnectionFactory</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; <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);
}