fix(dcl): key OPC UA alarms on ConditionId (#147)

OtOpcUa now exposes conditions imported over gRPC data connections in the
namespace https://zb.com/otopcua/mapped/conditions. Their ConditionId is
an opaque c1. NodeId stable for the life of the connection, but their
SourceName (<anchor>/<placement path>) moves when the primary placement
mapping changes. ScadaBridge keyed every condition on
SourceName.ConditionName, so a mapping change read as one alarm clearing
and a new one raising.

- Event filter selects ConditionId (select clause 19: ConditionType,
  empty browse path, AttributeId = NodeId).
- When the ConditionId (or SourceNode, which OtOpcUa sets to it) is in the
  mapped/conditions namespace, the per-condition key is its durable
  nsu=... string (index-proof across an OtOpcUa pair / upgrade). Every
  other OPC UA condition keeps the SourceName.ConditionName key, so no
  existing persisted row, MES script or operator view is re-keyed.
- The old SourceName.ConditionName text becomes an additive, display-only
  DisplayName: NativeAlarmTransition -> AlarmStateChanged ->
  AlarmStateUpdate.display_name (26) / DebugAlarmStateDto.display_name
  (22) -> ScriptAlarm.DisplayName. Persisted in native_alarm_state
  metadata_json (no column, no CDC trigger change); updates in place on
  every transition under the fixed key. Protos regenerated.
- Alarm Summary and Debug View show DisplayName (key as tooltip) and
  filter on it; site event log writes "label [key]".
- Upgrade: a pre-#147 row for an imported condition is retired by the
  first completed refresh snapshot (one return-to-normal + drop), then the
  condition continues under its ConditionId.

Tests: RealOpcUaImportedConditionKeyTests, OpcUaAlarmMapperTests,
NativeAlarmActorTests (DisplayName, rehydration, legacy-row retirement),
StreamRelayActorTests, SiteCommand golden sample, AlarmsAccessorTests,
DebugTreeBuilderTests; filter select-clause count 19 -> 20.
Docs: Component-DataConnectionLayer/Commons/Communication/SiteRuntime.
This commit is contained in:
Joseph Doherty
2026-11-28 09:14:49 -05:00
parent a117f79ad1
commit d3067ca036
29 changed files with 992 additions and 310 deletions
@@ -293,7 +293,8 @@ internal static class SiteCommandSamples
/// <summary>
/// A mirrored native alarm: every native enrichment field populated, <c>Condition</c> explicit.
/// Carries an ack time so the golden pins <c>DebugAlarmStateDto</c> field 21 (Gitea #84); the
/// computed sample leaves it null, pinning the absent-means-null decode.
/// computed sample leaves it null, pinning the absent-means-null decode. Carries a
/// DisplayName so the golden pins field 22 (Gitea #147); the computed sample leaves it empty.
/// </summary>
private static AlarmStateChanged NativeAlarm() =>
new("Site1.Pump1", "Tank01.Level.HiHi", AlarmState.Active, 850, T2)
@@ -312,7 +313,8 @@ internal static class SiteCommandSamples
CurrentValue = "91.2",
LimitValue = "90.0",
NativeSourceCanonicalName = "Tank01.TankAlarms",
IsConfiguredPlaceholder = true
IsConfiguredPlaceholder = true,
DisplayName = "Plant/remote-a/Tank01/Level.HiHi"
};
/// <summary>