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)
This commit is contained in:
19
src/ScadaLink.Commons/Types/Enums/AlarmLevel.cs
Normal file
19
src/ScadaLink.Commons/Types/Enums/AlarmLevel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace ScadaLink.Commons.Types.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Severity level for an active alarm. Binary alarm types (ValueMatch,
|
||||
/// RangeViolation, RateOfChange) always emit <see cref="None"/>. The HiLo
|
||||
/// trigger type emits one of the directional levels based on which setpoint
|
||||
/// the monitored attribute has crossed.
|
||||
///
|
||||
/// Conventional ordering (lowest setpoint to highest):
|
||||
/// LowLow < Low < normal-band < High < HighHigh
|
||||
/// </summary>
|
||||
public enum AlarmLevel
|
||||
{
|
||||
None,
|
||||
Low,
|
||||
LowLow,
|
||||
High,
|
||||
HighHigh
|
||||
}
|
||||
@@ -4,5 +4,12 @@ public enum AlarmTriggerType
|
||||
{
|
||||
ValueMatch,
|
||||
RangeViolation,
|
||||
RateOfChange
|
||||
RateOfChange,
|
||||
/// <summary>
|
||||
/// Multi-setpoint level alarm: monitors a single numeric attribute against
|
||||
/// up to four configurable setpoints (LoLo, Lo, Hi, HiHi). Each setpoint
|
||||
/// may carry its own priority; transitions between levels emit a fresh
|
||||
/// AlarmStateChanged with the corresponding <see cref="AlarmLevel"/>.
|
||||
/// </summary>
|
||||
HiLo
|
||||
}
|
||||
|
||||
23
src/ScadaLink.Commons/Types/Scripts/AlarmContext.cs
Normal file
23
src/ScadaLink.Commons/Types/Scripts/AlarmContext.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using ScadaLink.Commons.Types.Enums;
|
||||
|
||||
namespace ScadaLink.Commons.Types.Scripts;
|
||||
|
||||
/// <summary>
|
||||
/// Alarm context exposed to on-trigger scripts via <c>Alarm</c>. Lets scripts
|
||||
/// branch on the firing severity — e.g., page on-call for HiHi/LoLo but only
|
||||
/// email the day shift for Hi/Lo. Always present when an on-trigger script
|
||||
/// runs; <see cref="Level"/> is <see cref="AlarmLevel.None"/> for binary
|
||||
/// trigger types.
|
||||
/// </summary>
|
||||
public sealed class AlarmContext
|
||||
{
|
||||
public string Name { get; init; } = string.Empty;
|
||||
public AlarmLevel Level { get; init; } = AlarmLevel.None;
|
||||
public int Priority { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Per-band operator message configured on the HiLo alarm, or empty for
|
||||
/// binary trigger types and bands without a message.
|
||||
/// </summary>
|
||||
public string Message { get; init; } = string.Empty;
|
||||
}
|
||||
Reference in New Issue
Block a user