Merge #954: AdminUI OpcUaClient form field for AlarmRefreshRequiredMinInterval (seconds, double, 0 = off)
This commit is contained in:
@@ -476,7 +476,7 @@ initialise (the AdminUI form drops them on the next save). Pinned by
|
||||
> - **RefreshRequired:** its sweeps are coalesced while one is queued **and rate-limited (#946)**: at least
|
||||
> `alarmRefreshRequiredMinInterval` (default 10 s, start to start; `00:00:00` disables) separates two sweeps on one
|
||||
> session. A request inside the window is **deferred** to the window's end, never dropped, and everything arriving
|
||||
> meanwhile coalesces into that one sweep; a new session starts a fresh window. Reconnect / re-subscribe / loss-retry
|
||||
> meanwhile coalesces into that one sweep; a new session starts a fresh window. AdminUI: "Alarm RefreshRequired min interval (s)" on the driver form (#954). Reconnect / re-subscribe / loss-retry
|
||||
> refreshes (own 3-attempt budget) are not subject to it. The alarm event item asks for a
|
||||
> queue of 10,000 (previously 1,000); the server may revise it down. Counters on `otopcua.driver.opcuaclient.events`:
|
||||
> `alarm_event_queue_overflow` and `alarm_refresh_lossy`.
|
||||
|
||||
+10
@@ -229,6 +229,12 @@
|
||||
<InputNumber DisplayName="Subscription priority (0-255)" aria-describedby="@FieldId("field-24-error")" id="@FieldId("field-24")" @bind-Value="_form.OpcUa.SubscriptionPriority" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
|
||||
<div id="@FieldId("field-24-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _form.OpcUa.SubscriptionPriority)" /> }</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="@FieldId("field-31")" class="form-label">Alarm RefreshRequired min interval (s)</label>
|
||||
<InputNumber DisplayName="Alarm RefreshRequired min interval (s)" aria-describedby="@FieldIds("field-31-error", "field-31-hint")" id="@FieldId("field-31")" @bind-Value="_form.OpcUa.AlarmRefreshRequiredMinIntervalSeconds" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
|
||||
<div id="@FieldId("field-31-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _form.OpcUa.AlarmRefreshRequiredMinIntervalSeconds)" /> }</div>
|
||||
<div id="@FieldId("field-31-hint")" class="form-text">Minimum spacing between RefreshRequired-triggered alarm ConditionRefresh sweeps. Default 10; 0 = no limit (#946).</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-check form-switch mt-4">
|
||||
<InputCheckbox aria-describedby="@FieldIds("rejectUnkRevocation-hint")" @bind-Value="_form.OpcUa.RejectUnknownRevocationStatus" @bind-Value:after="EmitAsync" class="form-check-input" id="@FieldId("rejectUnkRevocation")" />
|
||||
@@ -376,6 +382,8 @@
|
||||
public int TimeoutSeconds { get; set; } = 10;
|
||||
public int SessionTimeoutSeconds { get; set; } = 120;
|
||||
public int KeepAliveIntervalSeconds { get; set; } = 5;
|
||||
// #954: double (not int) so a hand-authored sub-second value is not truncated to 0 (= limit off) on save.
|
||||
public double AlarmRefreshRequiredMinIntervalSeconds { get; set; } = 10;
|
||||
public int MaxDiscoveredNodes { get; set; } = 10_000;
|
||||
public int MaxBrowseDepth { get; set; } = 10;
|
||||
|
||||
@@ -418,6 +426,7 @@
|
||||
TimeoutSeconds = (int)r.Timeout.TotalSeconds,
|
||||
SessionTimeoutSeconds = (int)r.SessionTimeout.TotalSeconds,
|
||||
KeepAliveIntervalSeconds = (int)r.KeepAliveInterval.TotalSeconds,
|
||||
AlarmRefreshRequiredMinIntervalSeconds = r.AlarmRefreshRequiredMinInterval.TotalSeconds,
|
||||
MaxDiscoveredNodes = r.MaxDiscoveredNodes,
|
||||
MaxBrowseDepth = r.MaxBrowseDepth,
|
||||
SecurityMode = r.SecurityMode,
|
||||
@@ -458,6 +467,7 @@
|
||||
Timeout = TimeSpan.FromSeconds(TimeoutSeconds),
|
||||
SessionTimeout = TimeSpan.FromSeconds(SessionTimeoutSeconds),
|
||||
KeepAliveInterval = TimeSpan.FromSeconds(KeepAliveIntervalSeconds),
|
||||
AlarmRefreshRequiredMinInterval = TimeSpan.FromSeconds(Math.Max(AlarmRefreshRequiredMinIntervalSeconds, 0)),
|
||||
MaxDiscoveredNodes = MaxDiscoveredNodes,
|
||||
MaxBrowseDepth = MaxBrowseDepth,
|
||||
SecurityMode = SecurityMode,
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using System.Text.Json;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
|
||||
|
||||
/// <summary>#954: the factory parses the AlarmRefreshRequiredMinInterval shape the AdminUI form writes.</summary>
|
||||
public sealed class OpcUaClientAlarmRefreshIntervalConfigTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("""{"endpointUrl":"opc.tcp://x:1","alarmRefreshRequiredMinInterval":"00:00:30"}""", 30.0)]
|
||||
[InlineData("""{"endpointUrl":"opc.tcp://x:1","alarmRefreshRequiredMinInterval":"00:00:00"}""", 0.0)]
|
||||
[InlineData("""{"endpointUrl":"opc.tcp://x:1","alarmRefreshRequiredMinInterval":"00:00:00.5000000"}""", 0.5)]
|
||||
[InlineData("""{"endpointUrl":"opc.tcp://x:1"}""", 10.0)]
|
||||
public void ParseOptions_ReadsFormShape(string json, double expectedSeconds) =>
|
||||
OpcUaClientDriverFactoryExtensions.ParseOptions("d", json).AlarmRefreshRequiredMinInterval
|
||||
.ShouldBe(TimeSpan.FromSeconds(expectedSeconds));
|
||||
|
||||
[Fact]
|
||||
public void ParseOptions_ReadsSerializedOptions()
|
||||
{
|
||||
var json = JsonSerializer.Serialize(
|
||||
new OpcUaClientDriverOptions { AlarmRefreshRequiredMinInterval = TimeSpan.FromSeconds(7) },
|
||||
new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
||||
OpcUaClientDriverFactoryExtensions.ParseOptions("d", json).AlarmRefreshRequiredMinInterval
|
||||
.ShouldBe(TimeSpan.FromSeconds(7));
|
||||
}
|
||||
}
|
||||
+30
@@ -142,6 +142,36 @@ public sealed class OpcUaClientDriverPageFormSerializationTests
|
||||
result.ProbeTimeoutSeconds.ShouldBe(25);
|
||||
}
|
||||
|
||||
/// <summary>#954: AlarmRefreshRequiredMinInterval must survive the form (default 10 s; 0 = off; sub-second kept).</summary>
|
||||
[Theory]
|
||||
[InlineData(10.0)]
|
||||
[InlineData(0.0)]
|
||||
[InlineData(45.0)]
|
||||
[InlineData(0.5)]
|
||||
public void FormModel_RoundTrip_PreservesAlarmRefreshRequiredMinInterval(double seconds)
|
||||
{
|
||||
var original = new OpcUaClientDriverOptions { AlarmRefreshRequiredMinInterval = TimeSpan.FromSeconds(seconds) };
|
||||
|
||||
var form = OpcUaClientDriverForm.OpcUaClientFormModel.FromRecord(original);
|
||||
form.AlarmRefreshRequiredMinIntervalSeconds.ShouldBe(seconds);
|
||||
var back = form.ToRecord([]);
|
||||
|
||||
back.AlarmRefreshRequiredMinInterval.ShouldBe(TimeSpan.FromSeconds(seconds));
|
||||
// Through the wire shape the form emits (camelCase options JSON, TimeSpan as "hh:mm:ss").
|
||||
var json = JsonSerializer.Serialize(back, _opts);
|
||||
JsonSerializer.Deserialize<OpcUaClientDriverOptions>(json, _opts)!
|
||||
.AlarmRefreshRequiredMinInterval.ShouldBe(TimeSpan.FromSeconds(seconds));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormModel_DefaultAlarmRefreshRequiredMinInterval_MatchesDriverDefault()
|
||||
{
|
||||
new OpcUaClientDriverForm.OpcUaClientFormModel().ToRecord([]).AlarmRefreshRequiredMinInterval
|
||||
.ShouldBe(new OpcUaClientDriverOptions().AlarmRefreshRequiredMinInterval);
|
||||
new OpcUaClientDriverForm.OpcUaClientFormModel { AlarmRefreshRequiredMinIntervalSeconds = -5 }.ToRecord([])
|
||||
.AlarmRefreshRequiredMinInterval.ShouldBe(TimeSpan.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #273/#275/#277/#278: the typed form rewrites the whole record on save, so a key it does not model
|
||||
/// is silently dropped (#576). Every new option must survive FromRecord -> ToRecord.
|
||||
|
||||
Reference in New Issue
Block a user