namespace ZB.MOM.WW.OtOpcUa.Configuration.Entities;
///
/// Per Phase 7 plan decisions #5, #13, #15 — a scripted OPC UA Part 9 alarm whose
/// condition is the predicate referenced by
/// . Materialized by Core.ScriptedAlarms as a
/// concrete AlarmConditionType subtype per .
///
///
///
/// Message tokens ({TagPath}) resolved at emission time per plan decision #13.
/// (plan decision #15) gates whether transitions
/// route through the Core.AlarmHistorian SQLite queue + Galaxy.Host to the Aveva
/// Historian alarm schema.
///
///
public sealed class ScriptedAlarm
{
public Guid ScriptedAlarmRowId { get; set; }
public long GenerationId { get; set; }
/// Stable logical id — drives AlarmConditionType.ConditionName.
public required string ScriptedAlarmId { get; set; }
/// Logical FK to — owner of this alarm.
public required string EquipmentId { get; set; }
/// Operator-facing alarm name.
public required string Name { get; set; }
/// Concrete Part 9 type — "AlarmCondition" / "LimitAlarm" / "OffNormalAlarm" / "DiscreteAlarm".
public required string AlarmType { get; set; }
/// Numeric severity 1..1000 per OPC UA Part 9 (usual bands: 1-250 Low, 251-500 Medium, 501-750 High, 751-1000 Critical).
public int Severity { get; set; } = 500;
/// Template with {TagPath} tokens resolved at emission time.
public required string MessageTemplate { get; set; }
/// Logical FK to — predicate script returning bool.
public required string PredicateScriptId { get; set; }
///
/// Plan decision #15 — when true, transitions route through the SQLite store-and-forward
/// queue to the Aveva Historian. Defaults on for scripted alarms because they are the
/// primary motivation for the historian sink; operator can disable per alarm.
///
public bool HistorizeToAveva { get; set; } = true;
///
/// OPC UA Part 9 Retain flag — whether the alarm keeps active-state between
/// sessions. Most plant alarms are retained; one-shot event-style alarms are not.
///
public bool Retain { get; set; } = true;
public bool Enabled { get; set; } = true;
public ConfigGeneration? Generation { get; set; }
}