db751d12a5
Part 9 ConditionType.Quality was never assigned; default(StatusCode)==Good so every native + scripted condition reported Good unconditionally — a comms-lost device still showed a healthy, inactive, Good condition (a wrong-VALUE bug, distinct from the null-value #473/#475). Clients (and HMIs bucketing on IsGood) could not tell "genuinely inactive" from "lost contact". Layer 1 — make Quality a real, plumbed field: - AlarmConditionSnapshot gains OpcUaQuality Quality (default Good). - MaterialiseAlarmCondition sets it (native BadWaitingForInitialData, scripted Good). - WriteAlarmCondition projects snapshot.Quality; the delta-gate gains a Quality member so a quality-bucket change fires a Part 9 event. Layer 2 — drive native quality from driver connectivity (a comms-lost driver emits no alarm transitions, and an alarm-bearing raw tag has no value variable, so quality can't come from either existing channel): - DriverInstanceActor Tells parent ConnectivityChanged on Connected/Reconnecting. - DriverHostActor fans it to every native condition the driver owns as OpcUaPublishActor.AlarmQualityUpdate (Good on connect, Bad on disconnect). - New dedicated IOpcUaAddressSpaceSink.WriteAlarmQuality sets ONLY Quality and fires only on a bucket change — never touches Active/Acked/Retain (an active alarm that loses comms stays active). Not a full-snapshot re-projection, so it can't clobber severity/message and works for a never-fired condition. Forwarded through DeferredAddressSpaceSink (F10b trap; auto-verified by the reflection forwarding guard). Ungated by redundancy role; no /alerts row. Scripted conditions stay Good; worst-of-input quality deferred to #478 (Layer 3). Tests: node-level (materialise/project/no-clobber/unknown-node no-op), NativeAlarmProjector, DriverInstanceActor connectivity emission, DriverHostActor fan-out, OpcUaPublishActor routing, and the wire-level guard (Condition_event_Quality_tracks_source_connectivity_on_the_wire) — RED-verified against a simulated pre-fix always-Good server. Existing DriverInstanceActor parent probes ignore the new ConnectivityChanged. Docs: docs/AlarmTracking.md §"Condition source-data Quality (#477)"; design doc docs/plans/2026-07-17-alarm-condition-quality-477-design.md.
53 lines
2.9 KiB
C#
53 lines
2.9 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.Commons.OpcUa;
|
|
|
|
/// <summary>
|
|
/// Commons-level projection of an alarm's full OPC UA Part 9 condition state, carried from the
|
|
/// Runtime engine to the SDK sink. Commons cannot reference <c>Core.ScriptedAlarms</c> (its
|
|
/// domain enums live there), so this DTO is deliberately primitive: every field is a
|
|
/// <see cref="bool"/>, the Commons-local <see cref="AlarmShelvingKind"/> enum, a
|
|
/// <see cref="ushort"/> severity, or a <see cref="string"/>. The Runtime host maps its Core
|
|
/// <c>AlarmConditionState</c> + <c>AlarmSeverity</c> down to this shape; the SDK
|
|
/// <c>OtOpcUaNodeManager</c> projects it back up onto a real <c>AlarmConditionState</c> node.
|
|
/// </summary>
|
|
/// <param name="Active">Whether the alarm condition is currently active (ActiveState).</param>
|
|
/// <param name="Acknowledged">Whether the active transition has been acknowledged (AckedState).</param>
|
|
/// <param name="Confirmed">Whether the clear transition has been confirmed (ConfirmedState).</param>
|
|
/// <param name="Enabled">Whether the alarm is enabled (EnabledState); a disabled alarm reports no events.</param>
|
|
/// <param name="Shelving">The shelving mode (ShelvingState): unshelved, one-shot, or timed.</param>
|
|
/// <param name="Severity">OPC UA severity on the 1..1000 scale (the SDK <c>SetSeverity</c> input).</param>
|
|
/// <param name="Message">The human-readable condition message (LocalizedText payload).</param>
|
|
/// <param name="Quality">
|
|
/// Quality of the condition's source data (Part 9 <c>ConditionType.Quality</c>). Carried so a
|
|
/// comms-lost native source can report a non-<c>Good</c> condition instead of the accidentally-Good
|
|
/// default (issue #477). It is a pure annotation — it never alters Active/Acked/Retain. Defaults to
|
|
/// <see cref="OpcUaQuality.Good"/> so scripted-alarm callers (which stay Good in v1) need not supply it.
|
|
/// </param>
|
|
public sealed record AlarmConditionSnapshot(
|
|
bool Active,
|
|
bool Acknowledged,
|
|
bool Confirmed,
|
|
bool Enabled,
|
|
AlarmShelvingKind Shelving,
|
|
ushort Severity,
|
|
string Message,
|
|
OpcUaQuality Quality = OpcUaQuality.Good);
|
|
|
|
/// <summary>
|
|
/// Commons-local mirror of the Core <c>ShelvingKind</c> enum so this assembly carries no
|
|
/// dependency on <c>Core.ScriptedAlarms</c>. <see cref="Unshelved"/> = no suppression,
|
|
/// <see cref="OneShot"/> = suppress the next active transition, <see cref="Timed"/> = suppress
|
|
/// until a configured expiry. The Runtime host maps the Core enum onto these members; the SDK
|
|
/// sink maps them onto the Part 9 <c>SetShelvingState(shelved, oneShot, shelvingTime)</c> flags.
|
|
/// </summary>
|
|
public enum AlarmShelvingKind
|
|
{
|
|
/// <summary>No shelving — the alarm behaves normally.</summary>
|
|
Unshelved,
|
|
|
|
/// <summary>One-shot shelve — suppresses the next active transition, then expires.</summary>
|
|
OneShot,
|
|
|
|
/// <summary>Timed shelve — suppresses until a configured expiry timestamp passes.</summary>
|
|
Timed,
|
|
}
|