using ZB.MOM.WW.ScadaBridge.Commons.Types.Alarms; using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums; namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Streaming; public record AlarmStateChanged( string InstanceUniqueName, string AlarmName, AlarmState State, int Priority, DateTimeOffset Timestamp) : ISiteStreamEvent { /// /// Severity level when is . /// Always 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. /// public AlarmLevel Level { get; init; } = AlarmLevel.None; /// /// 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. /// public string Message { get; init; } = string.Empty; /// /// Whether this alarm is computed at the site or mirrored from a native /// source. Defaults to . /// public AlarmKind Kind { get; init; } = AlarmKind.Computed; private AlarmConditionState? _condition; /// /// Unified A&C-style condition (active/acked/shelved/suppressed + severity). /// When not explicitly set, defaults to a computed mapping of /// + so existing callers and /// computed alarms carry a correct condition without extra work. /// public AlarmConditionState Condition { get => _condition ?? AlarmConditionStateFactory.ForComputed(State, Priority); init => _condition = value; } /// Native per-condition key (e.g. "Tank01.Level.HiHi"); empty for computed alarms. public string SourceReference { get; init; } = string.Empty; /// Native alarm type name (e.g. "AnalogLimitAlarm.HiHi"); empty for computed alarms. public string AlarmTypeName { get; init; } = string.Empty; /// Native alarm category/taxonomy; empty for computed alarms. public string Category { get; init; } = string.Empty; /// Operator who acknowledged at the source (display-only); empty otherwise. public string OperatorUser { get; init; } = string.Empty; /// Operator comment captured at the source (display-only); empty otherwise. public string OperatorComment { get; init; } = string.Empty; /// When the native condition originally became active, if known. public DateTimeOffset? OriginalRaiseTime { get; init; } /// Current source value (display-only); empty for computed alarms. public string CurrentValue { get; init; } = string.Empty; /// Limit/threshold value for native limit alarms (display-only); empty otherwise. public string LimitValue { get; init; } = string.Empty; }