using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms;
///
/// Operator-authored scripted-alarm configuration. Phase 7 Stream E (config DB schema)
/// materializes these from the ScriptedAlarm + Script tables on publish.
///
///
/// Stable identity for the alarm — used as the OPC UA ConditionId + the key in the
/// state store. Should be globally unique within the cluster; convention is
/// {EquipmentPath}::{AlarmName}.
///
///
/// UNS path of the Equipment node the alarm hangs under. Alarm browse lives here;
/// ACL binding inherits this equipment's scope per Phase 6.2.
///
/// Human-readable alarm name — used in the browse tree + Admin UI.
/// Concrete OPC UA Part 9 subtype the alarm materializes as.
/// Static severity per Phase 7 plan decision #13; not currently computed by the predicate.
///
/// Message text with {TagPath} tokens resolved at event-emission time per
/// Phase 7 plan decision #13. Unresolvable tokens emit {?} + a structured
/// error so operators can spot stale references.
///
///
/// Roslyn C# script returning bool. true = alarm condition currently holds (active);
/// false = condition has cleared. Same sandbox rules as virtual tags per Phase 7 decision #6.
///
///
/// When true, every transition emission of this alarm flows to the Historian alarm
/// sink (Stream D). Defaults to true — plant alarm history is usually the
/// operator's primary diagnostic. Galaxy-native alarms default false since Galaxy
/// historises them directly.
///
///
/// Part 9 retain flag — when true, the condition node remains visible after the
/// predicate clears as long as it has un-acknowledged or un-confirmed transitions.
/// Default true.
///
public sealed record ScriptedAlarmDefinition(
string AlarmId,
string EquipmentPath,
string AlarmName,
AlarmKind Kind,
AlarmSeverity Severity,
string MessageTemplate,
string PredicateScriptSource,
bool HistorizeToAveva = true,
bool Retain = true);