feat(native-alarms): per-binding IsMesReportable on native alarm source bindings (ScadaBridge#59)

TemplateNativeAlarmSource.IsMesReportable + tri-state InstanceNativeAlarmSourceOverride
.IsMesReportableOverride flatten onto ResolvedNativeAlarmSource; NativeAlarmActor stamps every
mirrored condition and InstanceActor the quiet-binding placeholder, so ScriptAlarm,
Alarms.MesReportableAsync() and the #60 wire fields carry it. Additive to the 900-999 severity band.
Migration AddNativeAlarmSourceMesReportable. Management commands, CLI --mes-reportable, Central UI
(template dialog checkbox, instance override select), Transport DTOs/importer/diff and the revision
hash (true-only, so existing hashes are unchanged) carry it.

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 15:09:54 -05:00
parent 69a2017000
commit f98369a786
38 changed files with 2579 additions and 43 deletions
@@ -24,6 +24,8 @@ public class InstanceNativeAlarmSourceOverride
public string? SourceReferenceOverride { get; set; }
/// <summary>Overrides the condition filter when set; null = keep inherited.</summary>
public string? ConditionFilterOverride { get; set; }
/// <summary>Overrides the binding's <c>IsMesReportable</c> flag when set; null = keep inherited.</summary>
public bool? IsMesReportableOverride { get; set; }
/// <summary>Initializes a new override for the specified source binding.</summary>
/// <param name="sourceCanonicalName">Canonical name of the source to override.</param>
@@ -23,6 +23,13 @@ public class TemplateNativeAlarmSource
public string SourceReference { get; set; } = string.Empty;
/// <summary>Optional condition filter; null = mirror all conditions under the source.</summary>
public string? ConditionFilter { get; set; }
/// <summary>
/// When true, every condition mirrored under this binding is MES-reportable
/// (<c>AlarmStateChanged.IsMesReportable</c> / <c>ScriptAlarm.IsMesReportable</c>). Additive to the
/// 900-999 severity-band convention, which still flags a condition on its own. Default false.
/// Overridable per instance via <c>InstanceNativeAlarmSourceOverride.IsMesReportableOverride</c>.
/// </summary>
public bool IsMesReportable { get; set; }
/// <summary>When true, this binding cannot be overridden in derived templates.</summary>
public bool IsLocked { get; set; }
/// <summary>True when copied from a base template and not yet overridden on the derived template.</summary>
@@ -65,7 +65,8 @@ public record SetInstanceNativeAlarmSourceOverrideCommand(
string SourceCanonicalName,
string? ConnectionNameOverride,
string? SourceReferenceOverride,
string? ConditionFilterOverride);
string? ConditionFilterOverride,
bool? IsMesReportableOverride = null); // additive trailing optional; null = inherit the binding's flag
public record DeleteInstanceNativeAlarmSourceOverrideCommand(
int InstanceId,
@@ -83,7 +84,8 @@ public record NativeAlarmSourceOverrideEntry(
string SourceCanonicalName,
string? ConnectionNameOverride,
string? SourceReferenceOverride,
string? ConditionFilterOverride);
string? ConditionFilterOverride,
bool? IsMesReportableOverride = null);
/// <summary>
/// Bulk, all-or-nothing apply of per-instance native-alarm-source overrides — the
@@ -49,8 +49,8 @@ public record AddTemplateAlarmCommand(int TemplateId, string Name, string Trigge
public record UpdateTemplateAlarmCommand(int AlarmId, string Name, string TriggerType, int PriorityLevel, string? Description, string? TriggerConfiguration, bool IsLocked, bool IsMesReportable = false);
public record DeleteTemplateAlarmCommand(int AlarmId);
// Native alarm source bindings (read-only mirror of an OPC UA A&C / MxGateway source's alarms)
public record AddTemplateNativeAlarmSourceCommand(int TemplateId, string Name, string ConnectionName, string SourceReference, string? ConditionFilter, string? Description, bool IsLocked);
public record UpdateTemplateNativeAlarmSourceCommand(int NativeAlarmSourceId, string Name, string ConnectionName, string SourceReference, string? ConditionFilter, string? Description, bool IsLocked);
public record AddTemplateNativeAlarmSourceCommand(int TemplateId, string Name, string ConnectionName, string SourceReference, string? ConditionFilter, string? Description, bool IsLocked, bool IsMesReportable = false);
public record UpdateTemplateNativeAlarmSourceCommand(int NativeAlarmSourceId, string Name, string ConnectionName, string SourceReference, string? ConditionFilter, string? Description, bool IsLocked, bool IsMesReportable = false);
public record DeleteTemplateNativeAlarmSourceCommand(int NativeAlarmSourceId);
public record ListTemplateNativeAlarmSourcesCommand(int TemplateId);
// MinTimeBetweenRuns/ExecutionTimeoutSeconds are additive trailing optionals (default null = "unset"):
@@ -116,8 +116,10 @@ public record AlarmStateChanged(
/// <summary>
/// True when the alarm's deployed configuration flags it as MES-reportable
/// (<c>ResolvedAlarm.IsMesReportable</c>). Stamped by the Instance Actor on its alarm
/// snapshot and on every event it relays to the site stream; always false for native
/// conditions, which have no per-alarm config row. Carried to central on
/// snapshot and on every event it relays to the site stream. For a native condition it is
/// the binding-level flag (<c>ResolvedNativeAlarmSource.IsMesReportable</c>, Gitea #59), set by
/// the owning <c>NativeAlarmActor</c> — there is still no per-condition config row; the
/// 900-999 severity band remains an independent, additive signal. Carried to central on
/// <c>AlarmStateUpdate</c> field 25 and <c>DebugAlarmStateDto</c> field 20 (Gitea #60);
/// a pre-#60 site sends the proto3 default. Additive; default false.
/// </summary>
@@ -160,6 +160,11 @@ public sealed record ResolvedNativeAlarmSource
/// <summary>Gets the source of this binding: "Template", "Inherited", "Composed", or "Override".</summary>
public string Source { get; init; } = "Template";
/// <summary>
/// Gets whether every condition under this binding is MES-reportable (effective value after
/// the instance override). Additive to the 900-999 severity band.
/// </summary>
public bool IsMesReportable { get; init; }
/// <summary>
/// Gets whether this native alarm source is locked at the template level. A locked
/// source cannot be repointed by an instance override — mirrors the attribute/alarm
/// lock semantics.
@@ -57,7 +57,7 @@ namespace ZB.MOM.WW.ScadaBridge.Commons.Types.Scripts;
/// </param>
/// <param name="IsMesReportable">
/// True when the deployed configuration flags the alarm as MES-reportable (template
/// checkbox or instance override). Always false for native conditions.
/// checkbox or instance override). For native conditions it is the source binding's flag (Gitea #59).
/// </param>
public sealed record ScriptAlarm(
string Name,