feat(grpc-data): A2a AdminUI AlarmSubscribe checkbox, condition limit fields, capacity warning
Connection/export/mapping editors offer AlarmSubscribe (DataOperationAuthoring; method bits stay unauthorable until A2b); export MaxConditions and mapping MaxConditions / ConditionStale / ConditionMethod / ConditionSnapshot timeouts with the validator's min/max; the X0 banner already shows for any post-v1 bit. The Mappings panel lists the validator's non-blocking ConditionCapacityWarnings for this cluster's consumer nodes. AllowGalaxyServiceAck is not in the UI (A2b).
This commit is contained in:
+6
@@ -77,6 +77,7 @@ else
|
||||
</section>
|
||||
<section class="panel mt-3"><h2 class="panel-head">Mappings</h2><div class="p-3">
|
||||
@if (!Mappings.Any()) { <p class="text-muted">No remote branches have been mapped.</p> }
|
||||
@foreach (var w in DataOperationAuthoring.ConditionCapacityWarnings(_snapshot!, ClusterId)) { <div class="notice mb-2" role="note">@w</div> }
|
||||
@foreach (var m in Mappings) { <div class="d-flex flex-wrap gap-2 align-items-center mb-2"><strong>@m.RemoteNamespaceMappingId</strong><span>@m.Realm · @m.BranchName via @m.DataConnectionId</span><span class="chip chip-idle">Draft: @(m.Enabled ? "enabled" : "disabled")</span><AuthorizeView Policy="@AdminUiPolicies.ConfigEditor"><button class="btn btn-sm btn-outline-primary" @onclick="() => Edit(m)">Edit</button></AuthorizeView></div> }
|
||||
<AuthorizeView Policy="@AdminUiPolicies.ConfigEditor"><button class="btn btn-sm btn-primary" @onclick="NewMapping">New mapping</button></AuthorizeView></div>
|
||||
</section>
|
||||
@@ -116,6 +117,7 @@ else
|
||||
<label class="form-label" for="export-history-reads">Concurrent history reads per peer</label><input id="export-history-reads" type="number" min="1" max="@DataConnectionValidator.MaxConcurrentHistoryReadsLimit" class="form-control mb-2" @bind="e.MaxConcurrentHistoryReads" />
|
||||
<label class="form-label" for="export-history-page">History values per page</label><input id="export-history-page" type="number" min="1" max="@DataConnectionValidator.MaxHistoryValuesPerPageLimit" class="form-control mb-2" @bind="e.MaxHistoryValuesPerPage" />
|
||||
<label class="form-label" for="export-history-bytes">History response bytes</label><input id="export-history-bytes" type="number" min="@DataConnectionValidator.MinHistoryResponseBytesLimit" max="@DataConnectionValidator.MaxHistoryResponseBytesLimit" class="form-control mb-2" @bind="e.MaxHistoryResponseBytes" /><div class="form-text">Larger answers are sent in bounded chunks.</div>
|
||||
<label class="form-label" for="export-max-conditions">Conditions per alarm subscription</label><input id="export-max-conditions" type="number" min="1" max="@DataConnectionValidator.MaxConditionsLimit" class="form-control mb-2" @bind="e.MaxConditions" /><div class="form-text">A remote AlarmSubscribe scope with more conditions than this is refused (ConditionCapacity) before anything is imported.</div>
|
||||
<label><input type="checkbox" @bind="e.Enabled" /> Enabled in next deployment</label>@Actions(e, e.DataExportRowId != Guid.Empty)
|
||||
</div></section>
|
||||
}
|
||||
@@ -134,6 +136,10 @@ else
|
||||
<fieldset><legend class="fs-6">Consumer nodes</legend>@foreach (var n in Nodes) { <label class="me-3"><input type="checkbox" checked="@m.ConsumerNodeIds.Contains(n.NodeId)" @onchange="e => Toggle(m.ConsumerNodeIds, n.NodeId, (bool)e.Value!)" /> @n.NodeId</label> }</fieldset>
|
||||
@Operations(m.AllowedOperations, v => m.AllowedOperations = v)
|
||||
<label class="form-label" for="mapping-history-bytes">History assembly bytes per request</label><input id="mapping-history-bytes" type="number" min="1" max="@DataConnectionValidator.MaxHistoryAssemblyBytesLimit" class="form-control mb-2" @bind="m.MaxHistoryAssemblyBytesPerRequest" />
|
||||
<label class="form-label" for="mapping-max-conditions">Maximum imported conditions</label><input id="mapping-max-conditions" type="number" min="1" max="@DataConnectionValidator.MaxConditionsLimit" class="form-control mb-2" @bind="m.MaxConditions" /><div class="form-text">A remote alarm scope larger than this makes the mapping's alarms Unavailable (ConditionCapacity); each imported condition materialises up to @DataConnectionValidator.NodesPerImportedCondition nodes.</div>
|
||||
<label class="form-label" for="mapping-condition-stale">Condition stale timeout (ms)</label><input id="mapping-condition-stale" type="number" min="1" max="@DataConnectionValidator.MaxConditionTimeoutMilliseconds" class="form-control mb-2" @bind="m.ConditionStaleTimeoutMilliseconds" />
|
||||
<label class="form-label" for="mapping-condition-method">Condition method timeout (ms)</label><input id="mapping-condition-method" type="number" min="1" max="@DataConnectionValidator.MaxConditionTimeoutMilliseconds" class="form-control mb-2" @bind="m.ConditionMethodTimeoutMilliseconds" />
|
||||
<label class="form-label" for="mapping-condition-snapshot">Condition snapshot timeout (ms)</label><input id="mapping-condition-snapshot" type="number" min="1" max="@DataConnectionValidator.MaxConditionTimeoutMilliseconds" class="form-control mb-2" @bind="m.ConditionSnapshotTimeoutMilliseconds" />
|
||||
<div><label><input type="checkbox" @bind="m.WriteThrough" /> Allow write-through</label></div><label><input type="checkbox" @bind="m.Enabled" /> Enabled in next deployment</label>@Actions(m, m.RemoteNamespaceMappingRowId != Guid.Empty)
|
||||
</div></section>
|
||||
}
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Validation;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
|
||||
|
||||
/// <summary>
|
||||
/// The operation checkboxes the data-connection editors offer, and the mixed-version banner (plan §4.3). The set
|
||||
/// grows with the authoring validator, never ahead of it: H2 adds <see cref="DataOperations.HistoryRead"/>.
|
||||
/// grows with the authoring validator, never ahead of it: H2 adds <see cref="DataOperations.HistoryRead"/>, A2a
|
||||
/// <see cref="DataOperations.AlarmSubscribe"/> (A2b the method bits).
|
||||
/// </summary>
|
||||
public static class DataOperationAuthoring
|
||||
{
|
||||
/// <summary>The operation bits an operator can tick, in display order.</summary>
|
||||
public static IReadOnlyList<DataOperations> AuthorableOperations { get; } =
|
||||
[DataOperations.Browse, DataOperations.Metadata, DataOperations.Read, DataOperations.Subscribe, DataOperations.Write, DataOperations.HistoryRead];
|
||||
[DataOperations.Browse, DataOperations.Metadata, DataOperations.Read, DataOperations.Subscribe, DataOperations.Write, DataOperations.HistoryRead,
|
||||
DataOperations.AlarmSubscribe];
|
||||
|
||||
/// <summary>The checkbox label of a bit.</summary>
|
||||
public static string Label(DataOperations operation) => operation == DataOperations.HistoryRead ? "HistoryRead" : operation.ToString();
|
||||
public static string Label(DataOperations operation) => operation.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// The informational banner shown while a post-v1 feature bit is ticked: ConfigDb records no node build, so the
|
||||
@@ -22,4 +25,18 @@ public static class DataOperationAuthoring
|
||||
public static string? FeatureBitBanner(DataOperations operations) => (operations & ~DataOperationSets.V1) == 0 ? null
|
||||
: "Every node of both clusters must run X0+ before authoring this: a pre-X0 node rejects the whole data-connection "
|
||||
+ "snapshot when a row carries an operation bit it does not know. Nothing checks this automatically.";
|
||||
|
||||
/// <summary>
|
||||
/// The validator's non-blocking condition-capacity warnings (plan §5.5/§6) for this cluster's consumer nodes, computed on
|
||||
/// the saved drafts with the host default <c>DataConnections:MaxImportedConditionNodes</c>.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<string> ConditionCapacityWarnings(DraftSnapshot snapshot, string clusterId)
|
||||
{
|
||||
var nodes = snapshot.ClusterNodes.Where(n => string.Equals(n.ClusterId, clusterId, StringComparison.OrdinalIgnoreCase))
|
||||
.Select(n => n.NodeId).ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
return DataConnectionValidator.ConditionCapacityWarnings(snapshot)
|
||||
.Where(w => w.Context is not null && nodes.Contains(w.Context))
|
||||
.Select(w => w.Message + " The cap is the host's setting; this check assumes its default.")
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Entities;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Validation;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.DataConnections;
|
||||
|
||||
/// <summary>A2 editor models: the AlarmSubscribe checkbox, the condition limits' defaults, the X0 banner and the capacity warning.</summary>
|
||||
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "A2")]
|
||||
public sealed class GrpcDataConditionEditorTests
|
||||
{
|
||||
[Fact]
|
||||
public void AlarmSubscribe_is_authorable_and_the_method_bits_are_not()
|
||||
{
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldContain(DataOperations.AlarmSubscribe);
|
||||
foreach (var bit in new[] { DataOperations.AlarmAcknowledge, DataOperations.AlarmConfirm, DataOperations.AlarmShelve })
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldNotContain(bit, "A2b");
|
||||
// Every authorable bit is one the validator accepts and the node understands.
|
||||
var all = DataOperationAuthoring.AuthorableOperations.Aggregate(DataOperations.None, (a, b) => a | b);
|
||||
(all & ~DataOperationSets.Understood).ShouldBe(DataOperations.None);
|
||||
// (Write is left out only because a Write mapping also needs write-through, which the minimal draft does not set.)
|
||||
DataConnectionValidator.Validate(GrpcDataEditorValidationTestsAccess.ValidSnapshot(all & ~DataOperations.Write))
|
||||
.ShouldNotContain(x => x.Code.EndsWith("OperationsInvalid", StringComparison.Ordinal));
|
||||
DataOperationAuthoring.Label(DataOperations.AlarmSubscribe).ShouldBe("AlarmSubscribe");
|
||||
new DataConnectionEditorModel().Value.AllowedOperations.HasFlag(DataOperations.AlarmSubscribe).ShouldBeFalse();
|
||||
new RemoteMappingEditorModel().Value.AllowedOperations.HasFlag(DataOperations.AlarmSubscribe).ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void New_drafts_carry_the_plans_condition_limits_and_no_Galaxy_ack()
|
||||
{
|
||||
var mapping = new RemoteMappingEditorModel().Value;
|
||||
(mapping.MaxConditions, mapping.ConditionStaleTimeoutMilliseconds, mapping.ConditionMethodTimeoutMilliseconds,
|
||||
mapping.ConditionSnapshotTimeoutMilliseconds).ShouldBe((1000, 30000, 5000, 30000));
|
||||
var export = new DataExport();
|
||||
export.MaxConditions.ShouldBe(1000);
|
||||
export.AllowGalaxyServiceAck.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_X0_banner_shows_while_AlarmSubscribe_is_ticked()
|
||||
{
|
||||
var banner = DataOperationAuthoring.FeatureBitBanner(DataOperations.Read | DataOperations.AlarmSubscribe).ShouldNotBeNull();
|
||||
banner.ShouldContain("every node of both clusters must run X0+ before authoring this", Case.Insensitive);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_AlarmSubscribe_draft_validates_and_an_out_of_range_condition_limit_does_not()
|
||||
{
|
||||
var draft = GrpcDataEditorValidationTestsAccess.ValidSnapshot(DataOperations.Read | DataOperations.AlarmSubscribe);
|
||||
DataConnectionValidator.Validate(draft).ShouldNotContain(x => x.Code.EndsWith("LimitInvalid", StringComparison.Ordinal));
|
||||
draft.RemoteNamespaceMappings[0].MaxConditions = DataConnectionValidator.MaxConditionsLimit + 1;
|
||||
DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataMappingLimitInvalid");
|
||||
draft.RemoteNamespaceMappings[0].MaxConditions = 1000;
|
||||
draft.DataExports[0].MaxConditions = 0;
|
||||
DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataExportLimitInvalid");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_capacity_warning_lists_only_this_clusters_over_cap_consumer_nodes()
|
||||
{
|
||||
RemoteNamespaceMapping Mapping(string id, string cluster, string node) => new()
|
||||
{
|
||||
RemoteNamespaceMappingId = id, ClusterId = cluster, Enabled = true, ConsumerNodeIds = [node], MaxConditions = 5000,
|
||||
AllowedOperations = DataOperations.Read | DataOperations.AlarmSubscribe,
|
||||
};
|
||||
var snapshot = new DraftSnapshot
|
||||
{
|
||||
GenerationId = 1, ClusterId = "MAIN",
|
||||
ClusterNodes = [new() { NodeId = "main-1", ClusterId = "MAIN", Host = "h", ApplicationUri = "urn:a", CreatedBy = "t" }, new() { NodeId = "other-1", ClusterId = "OTHER", Host = "h", ApplicationUri = "urn:b", CreatedBy = "t" }],
|
||||
// 5000 × 49 = 245,000 > 122,500 for each node.
|
||||
RemoteNamespaceMappings = [Mapping("m", "MAIN", "main-1"), Mapping("o", "OTHER", "other-1")],
|
||||
};
|
||||
var warning = DataOperationAuthoring.ConditionCapacityWarnings(snapshot, "main").ShouldHaveSingleItem();
|
||||
warning.ShouldContain("main-1");
|
||||
warning.ShouldContain("MaxImportedConditionNodes");
|
||||
DataOperationAuthoring.ConditionCapacityWarnings(snapshot, "none").ShouldBeEmpty();
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -14,7 +14,8 @@ public sealed class GrpcDataHistoryEditorTests
|
||||
public void HistoryRead_is_authorable_and_new_drafts_do_not_grant_it()
|
||||
{
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldContain(DataOperations.HistoryRead);
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldNotContain(DataOperations.AlarmSubscribe, "A2 bits stay unauthorable");
|
||||
// A2a made AlarmSubscribe authorable (GrpcDataConditionEditorTests); the method bits stay unauthorable until A2b.
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldNotContain(DataOperations.AlarmAcknowledge, "A2b bits stay unauthorable");
|
||||
// Every authorable bit is one the validator accepts — the editor never gets ahead of authoring.
|
||||
var all = DataOperationAuthoring.AuthorableOperations.Aggregate(DataOperations.None, (a, b) => a | b);
|
||||
(all & ~DataOperationSets.Understood).ShouldBe(DataOperations.None);
|
||||
|
||||
Reference in New Issue
Block a user