Files
lmxopcua/src/Core/ZB.MOM.WW.OtOpcUa.Commons/OpcUa/AlarmConditionSnapshot.cs
T
Joseph Doherty ddc1f29e3a feat(heidenhain): Part 9 condition class from alarm class/group, ALARM: selectors in the browse picker, unclaimed alarms counted + logged (#839)
- Core: optional AlarmEventArgs.ConditionClass (AlarmConditionClass Base/Process/Maintenance/System/Safety)
  carried by NativeAlarmProjector on AlarmConditionSnapshot and written to ConditionClassId/Name by
  OtOpcUaNodeManager (kept across class-less events, carried across a #641 rebuild).
- Heidenhain: HeidenhainAlarmClasses — HEIDENHAIN DNC-interface class/group names (corroborated by the
  captured iTNC 530 record); class 5 => Safety, group 1/2 => Process, 4/5 => System, else Base.
- DiscoverAsync offers AlarmConditions/ selector leaves (IsAlarm Boolean); browse-commit seeds the alarm object.
- Alarms no selector claims: otopcua.driver.alarms.unmatched counter, /hosts diagnostics, rate-limited Warning.

Refs #839
2026-11-11 03:41:14 -05:00

70 lines
4.0 KiB
C#

using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
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="StatusCode">
/// Status code 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. It is a pure annotation — it never alters Active/Acked/Retain. Defaults to
/// <see cref="OpcUaStatus.Good"/> so scripted-alarm callers (which stay Good in v1) need not supply it.
/// Carries the full sub-code, so a comms-lost condition reports
/// <see cref="OpcUaStatus.BadNoCommunication"/> rather than a bare <see cref="OpcUaStatus.Bad"/>.
/// </param>
/// <param name="UnshelveAtUtc">
/// For <see cref="AlarmShelvingKind.Timed"/>, the UTC instant the engine expires the shelve; otherwise
/// <c>null</c>. Carried so the node's Part 9 <c>ShelvingState.UnshelveTime</c> reports the real remaining
/// time instead of the SDK's ~24.8-day ceiling. A timed snapshot without it (a caller that
/// predates the field) falls back to that ceiling — the engine still owns the expiry either way.
/// </param>
/// <param name="ConditionClass">
/// The Part 9 <c>ConditionClass</c> a native source assigned (lmxopcua#839), or <c>null</c> to leave the node's class
/// as it is (scripted alarms and every native source that does not classify). Not part of the event delta-gate: a
/// class rides along with the transition that set it.
/// </param>
public sealed record AlarmConditionSnapshot(
bool Active,
bool Acknowledged,
bool Confirmed,
bool Enabled,
AlarmShelvingKind Shelving,
ushort Severity,
string Message,
uint StatusCode = OpcUaStatus.Good,
DateTime? UnshelveAtUtc = null,
AlarmConditionClass? ConditionClass = null);
/// <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,
}