namespace ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances;
///
/// Per-instance override for a template-defined alarm. Lets a deployed
/// instance tweak setpoints, priority, or per-band messages without forking
/// the template. Locked alarms (TemplateAlarm.IsLocked) cannot be overridden
/// — LockEnforcer rejects the change at write time.
///
/// Merge semantics (applied during flattening, after template inheritance and
/// composition):
/// • with a HiLo trigger merges
/// into the inherited JSON setpoint-by-setpoint (derived keys win,
/// inherited keys survive for unset derived keys). Same logic as
/// template-to-template HiLo override, just one layer deeper.
/// • For ValueMatch / RangeViolation / RateOfChange, the override replaces
/// the whole TriggerConfiguration JSON (existing whole-replace semantics).
/// • replaces the alarm's PriorityLevel
/// when set.
///
public class InstanceAlarmOverride
{
/// Primary key.
public int Id { get; set; }
/// Foreign key to the instance this override belongs to.
public int InstanceId { get; set; }
///
/// Canonical name of the alarm being overridden — matches
/// ResolvedAlarm.CanonicalName after flattening, so composed-member
/// alarms are referenced as [CompositionInstance].[AlarmName].
///
public string AlarmCanonicalName { get; set; }
///
/// Partial JSON (for HiLo) or full JSON (for binary trigger types) to
/// override the inherited TriggerConfiguration. null means
/// "leave inherited as-is".
///
public string? TriggerConfigurationOverride { get; set; }
///
/// Replaces the alarm's PriorityLevel when set. null = keep inherited.
///
public int? PriorityLevelOverride { get; set; }
///
/// Initializes a new alarm override for the specified alarm.
///
/// Canonical name of the alarm to override.
public InstanceAlarmOverride(string alarmCanonicalName)
{
AlarmCanonicalName = alarmCanonicalName ?? throw new ArgumentNullException(nameof(alarmCanonicalName));
}
}