063fb21815
The bulk SetInstanceNativeAlarmSourceOverridesCommand handler always wrote the entry's IsMesReportableOverride, so a CLI import of a legacy 4-column CSV (no MesReportable column) reset every imported source's MES override to inherit. The Central UI avoided it only by looking up the stored flag client-side. NativeAlarmSourceOverrideEntry gains an additive trailing KeepStoredMesReportable flag: when set, the server leaves an existing row's MES override untouched (a new row inherits) and ignores IsMesReportableOverride; unset keeps the old meaning (null = clear to inherit), so older senders are unaffected. The CLI and the Central UI now build their entries through one rule (ToOverrideEntry on each row type): no MesReportable column => KeepStoredMesReportable. CLI README and Component-CentralUI updated. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
119 lines
6.3 KiB
C#
119 lines
6.3 KiB
C#
namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
|
|
|
|
// Skip/Take are additive offset paging (arch-review P2), applied AFTER in-memory
|
|
// site-scope filtering. Take = null preserves the historical unpaged behaviour.
|
|
public record ListInstancesCommand(int? SiteId = null, int? TemplateId = null, string? SearchTerm = null, int Skip = 0, int? Take = null);
|
|
public record GetInstanceCommand(int InstanceId);
|
|
public record CreateInstanceCommand(string UniqueName, int TemplateId, int SiteId, int? AreaId = null);
|
|
public record MgmtDeployInstanceCommand(int InstanceId);
|
|
public record MgmtEnableInstanceCommand(int InstanceId);
|
|
public record MgmtDisableInstanceCommand(int InstanceId);
|
|
public record MgmtDeleteInstanceCommand(int InstanceId);
|
|
/// <summary>
|
|
/// A single attribute-to-data-connection binding carried by
|
|
/// <see cref="SetConnectionBindingsCommand"/>. This is a named record (not a
|
|
/// <c>ValueTuple</c>) so it serializes with stable, named JSON properties and can
|
|
/// evolve additively per REQ-COM-5a.
|
|
/// <para>
|
|
/// <c>DataSourceReferenceOverride</c> is an optional per-instance override of
|
|
/// the OPC UA node id (or other protocol address) for the bound attribute.
|
|
/// When non-null it replaces the template's <c>DataSourceReference</c> at
|
|
/// flattening time; when null the template default is used.
|
|
/// </para>
|
|
/// </summary>
|
|
public record ConnectionBinding(
|
|
string AttributeName,
|
|
int DataConnectionId,
|
|
string? DataSourceReferenceOverride = null);
|
|
|
|
public record SetConnectionBindingsCommand(int InstanceId, IReadOnlyList<ConnectionBinding> Bindings);
|
|
public record SetInstanceOverridesCommand(int InstanceId, IReadOnlyDictionary<string, string?> Overrides);
|
|
public record SetInstanceAreaCommand(int InstanceId, int? AreaId);
|
|
|
|
/// <summary>
|
|
/// Sets (or upserts) a per-instance alarm override. For HiLo trigger types the
|
|
/// <c>TriggerConfigurationOverride</c> JSON is merged setpoint-by-setpoint with
|
|
/// the inherited config; for binary trigger types it replaces the whole config.
|
|
/// Each override field is optional — null means the instance inherits the template value
|
|
/// for that field (the row is replaced whole on every call, not merged).
|
|
/// </summary>
|
|
/// <param name="InstanceId">ID of the instance the override applies to.</param>
|
|
/// <param name="AlarmCanonicalName">Canonical (path-qualified for composed members) alarm name.</param>
|
|
/// <param name="TriggerConfigurationOverride">Trigger configuration JSON override, or null.</param>
|
|
/// <param name="PriorityLevelOverride">Priority level override, or null.</param>
|
|
/// <param name="IsMesReportableOverride">
|
|
/// Per-instance override of the template alarm's MES-reportable flag. Additive trailing
|
|
/// optional; null (the default) inherits the template value, true/false forces it.
|
|
/// </param>
|
|
public record SetInstanceAlarmOverrideCommand(
|
|
int InstanceId,
|
|
string AlarmCanonicalName,
|
|
string? TriggerConfigurationOverride,
|
|
int? PriorityLevelOverride,
|
|
bool? IsMesReportableOverride = null);
|
|
|
|
public record DeleteInstanceAlarmOverrideCommand(
|
|
int InstanceId,
|
|
string AlarmCanonicalName);
|
|
|
|
public record ListInstanceAlarmOverridesCommand(int InstanceId);
|
|
|
|
// Native alarm source overrides (per-instance retarget of an inherited source binding;
|
|
// null fields keep the inherited value).
|
|
public record SetInstanceNativeAlarmSourceOverrideCommand(
|
|
int InstanceId,
|
|
string SourceCanonicalName,
|
|
string? ConnectionNameOverride,
|
|
string? SourceReferenceOverride,
|
|
string? ConditionFilterOverride,
|
|
bool? IsMesReportableOverride = null); // additive trailing optional; null = inherit the binding's flag
|
|
|
|
public record DeleteInstanceNativeAlarmSourceOverrideCommand(
|
|
int InstanceId,
|
|
string SourceCanonicalName);
|
|
|
|
public record ListInstanceNativeAlarmSourceOverridesCommand(int InstanceId);
|
|
|
|
/// <summary>
|
|
/// One entry in a bulk native-alarm-source-override apply: the source binding's
|
|
/// canonical name plus the three optional retarget fields (null keeps the inherited
|
|
/// value). Mirrors <see cref="SetInstanceNativeAlarmSourceOverrideCommand"/>'s fields
|
|
/// for a single source.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <see cref="IsMesReportableOverride"/> is written as given — <c>null</c> means "inherit the
|
|
/// binding's flag" and clears a stored override — unless <see cref="KeepStoredMesReportable"/>
|
|
/// is set (ScadaBridge#104). Then the entry does not specify the MES flag at all: the server
|
|
/// keeps the instance's stored <c>IsMesReportableOverride</c> (inherit for a new override row)
|
|
/// and ignores <see cref="IsMesReportableOverride"/>. The CLI and Central UI CSV imports set it
|
|
/// for a legacy 4-column file that has no <c>MesReportable</c> column, so importing such a file
|
|
/// never resets MES overrides. Additive trailing optional: older senders keep the old meaning.
|
|
/// </remarks>
|
|
/// <param name="SourceCanonicalName">The native alarm source's canonical name.</param>
|
|
/// <param name="ConnectionNameOverride">Connection retarget, or null to inherit.</param>
|
|
/// <param name="SourceReferenceOverride">Source-reference retarget, or null to inherit.</param>
|
|
/// <param name="ConditionFilterOverride">Condition-filter retarget, or null to inherit.</param>
|
|
/// <param name="IsMesReportableOverride">MES-reportable override, or null to inherit.</param>
|
|
/// <param name="KeepStoredMesReportable">True when the entry leaves the MES flag unspecified.</param>
|
|
public record NativeAlarmSourceOverrideEntry(
|
|
string SourceCanonicalName,
|
|
string? ConnectionNameOverride,
|
|
string? SourceReferenceOverride,
|
|
string? ConditionFilterOverride,
|
|
bool? IsMesReportableOverride = null,
|
|
bool KeepStoredMesReportable = false);
|
|
|
|
/// <summary>
|
|
/// Bulk, all-or-nothing apply of per-instance native-alarm-source overrides — the
|
|
/// native-source parity analogue of <see cref="SetInstanceOverridesCommand"/>. Backs
|
|
/// the CLI <c>instance native-alarm-source import --file</c> CSV path. Every entry's
|
|
/// source must resolve for the instance and be unlocked; if any entry is invalid the
|
|
/// whole batch is rejected before any write.
|
|
/// </summary>
|
|
public record SetInstanceNativeAlarmSourceOverridesCommand(
|
|
int InstanceId,
|
|
IReadOnlyList<NativeAlarmSourceOverrideEntry> Overrides);
|
|
|
|
/// <summary>Removes an attribute override so the inherited value is used again.</summary>
|
|
public record DeleteInstanceAttributeOverrideCommand(int InstanceId, string AttributeName);
|