Files
scadalink-design/src/ScadaLink.Commons/Messages/Streaming/AlarmStateChanged.cs
Joseph Doherty 751248feb6 feat(alarms): HiLo trigger type with per-band level, hysteresis, messages, overrides
Adds a new HiLo alarm trigger type with four configurable setpoints
(LoLo / Lo / Hi / HiHi). Each setpoint carries an optional priority,
deadband (for hysteresis), and operator message. The site runtime emits
AlarmStateChanged with an AlarmLevel field so consumers can differentiate
warning vs critical bands.

Plumbing:
  - new AlarmLevel enum + AlarmStateChanged.Level/Message init properties
  - AlarmTriggerEditor (Blazor) gets a HiLo render with severity tinting
  - AlarmTriggerConfigCodec extracted from the editor for testability
  - sitestream.proto carries level + message over gRPC
  - SemanticValidator enforces numeric attribute, setpoint ordering,
    non-negative deadband
  - on-trigger scripts get an Alarm global (Name/Level/Priority/Message)
    so notification routing can branch by severity
  - per-instance InstanceAlarmOverride entity + EF migration + flattening
    step + CLI commands; HiLo overrides merge setpoint-by-setpoint, binary
    types whole-replace
  - DebugView shows a Level badge + per-band message tooltip
  - App.razor auto-reloads on permanent Blazor circuit failure
  - docker/regen-proto.sh automates the proto regen workflow (the linux/arm64
    protoc segfault means generated files are checked in for now)
2026-05-13 03:23:32 -04:00

30 lines
1.1 KiB
C#

using ScadaLink.Commons.Types.Enums;
namespace ScadaLink.Commons.Messages.Streaming;
public record AlarmStateChanged(
string InstanceUniqueName,
string AlarmName,
AlarmState State,
int Priority,
DateTimeOffset Timestamp)
{
/// <summary>
/// Severity level when <see cref="State"/> is <see cref="AlarmState.Active"/>.
/// Always <see cref="AlarmLevel.None"/> for binary trigger types
/// (ValueMatch, RangeViolation, RateOfChange); set by the HiLo trigger
/// type to one of Low/LowLow/High/HighHigh based on the crossed setpoint.
/// Added as an init-property so existing positional constructors still
/// work — message contract evolves additively.
/// </summary>
public AlarmLevel Level { get; init; } = AlarmLevel.None;
/// <summary>
/// Optional per-band operator message (e.g., "Coolant critically low —
/// shut down"). Set by HiLo triggers when the per-setpoint message is
/// configured; otherwise empty. Notification routing and UI tooltips may
/// surface this to operators.
/// </summary>
public string Message { get; init; } = string.Empty;
}