fix(client): processed history reads ask for the server's aggregate defaults
Found by the H3 live gate (H02): Client.Shared sent the SDK's default AggregateConfiguration (all false / 0), which the server refuses as a non-default configuration (BadAggregateConfigurationRejected, #677) on local and projected nodes alike, so CLI/UI --aggregate reads never worked against it. Set UseServerCapabilitiesDefaults = true. OI regression test (red without the fix) also covers HistoryReadPageAsync.
This commit is contained in:
@@ -285,7 +285,10 @@ internal sealed class DefaultSessionAdapter : ISessionAdapter
|
||||
StartTime = startTime,
|
||||
EndTime = endTime,
|
||||
ProcessingInterval = intervalMs,
|
||||
AggregateType = [aggregateId]
|
||||
AggregateType = [aggregateId],
|
||||
// The SDK's default AggregateConfiguration is all-false/0 — a NON-default configuration, which this server
|
||||
// refuses BadAggregateConfigurationRejected (#677). Ask for the server's own defaults, as Part 13 intends.
|
||||
AggregateConfiguration = new AggregateConfiguration { UseServerCapabilitiesDefaults = true },
|
||||
};
|
||||
|
||||
ArrayOf<HistoryReadValueId> nodesToRead = [new HistoryReadValueId { NodeId = nodeId }];
|
||||
|
||||
+37
-1
@@ -113,6 +113,41 @@ public sealed class GrpcDataProjectedHistoryWireTests
|
||||
bridge.Calls.ShouldBe(0);
|
||||
}
|
||||
|
||||
[Fact(Timeout = 90000)]
|
||||
public async Task The_shared_client_aggregate_read_asks_for_server_defaults_and_is_served()
|
||||
{
|
||||
// Found by the H3 live gate (H02): Client.Shared sent the SDK's default AggregateConfiguration (all false / 0), a
|
||||
// NON-default configuration this server refuses BadAggregateConfigurationRejected (#677) — on local and projected
|
||||
// nodes alike, so the CLI's --aggregate never worked against it.
|
||||
var ct = Deadline();
|
||||
await using var rig = await StartModeAsync("H3ClientAggregate", "None", ct);
|
||||
rig.Nm.HistorianDataSource = new Series(3, offset: 0);
|
||||
rig.Nm.EnsureVariable("Plant/Speed", null, "Speed", "Int32", false, AddressSpaceRealm.Raw, historianTagname: "speed");
|
||||
rig.Enforce(false, [Key()]);
|
||||
using var client = new ZB.MOM.WW.OtOpcUa.Client.Shared.OpcUaClientService();
|
||||
await client.ConnectAsync(new ZB.MOM.WW.OtOpcUa.Client.Shared.Models.ConnectionSettings
|
||||
{
|
||||
EndpointUrl = rig.EndpointUrl,
|
||||
CertificateStorePath = Path.Combine(Path.GetTempPath(), $"otopcua-clientpki-{Guid.NewGuid():N}"),
|
||||
}, ct);
|
||||
var node = rig.Nm.TryGetVariable("Plant/Speed", AddressSpaceRealm.Raw)!.NodeId;
|
||||
var values = await client.HistoryReadAggregateAsync(node, T0, T0.AddMinutes(1),
|
||||
ZB.MOM.WW.OtOpcUa.Client.Shared.Models.AggregateType.Average, 60_000, ct);
|
||||
values.Count.ShouldBe(1);
|
||||
// The hand-paging API returns the server's page verbatim (status, values, continuation).
|
||||
var page = await client.HistoryReadPageAsync(new ReadRawModifiedDetails
|
||||
{
|
||||
StartTime = T0.AddSeconds(-1), EndTime = T0.AddHours(1), NumValuesPerNode = 2, IsReadModified = false, ReturnBounds = false,
|
||||
}, node, null, false, ct);
|
||||
StatusCode.IsGood(page.Status).ShouldBeTrue();
|
||||
page.Values.Count.ShouldBe(2);
|
||||
page.ContinuationPoint.ShouldNotBeNull();
|
||||
var released = await client.HistoryReadPageAsync(new ReadRawModifiedDetails { IsReadModified = false, ReturnBounds = false },
|
||||
node, page.ContinuationPoint, true, ct);
|
||||
StatusCode.IsGood(released.Status).ShouldBeTrue();
|
||||
await client.DisconnectAsync(ct);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
private static (NodeId Node, string Identifier) Setup(ServerEventRig consumer, bool aclEnabled, NodePermissions permissions)
|
||||
@@ -209,7 +244,8 @@ public sealed class GrpcDataProjectedHistoryWireTests
|
||||
}
|
||||
|
||||
public Task<HistorianRead> ReadProcessedAsync(string fullReference, DateTime startUtc, DateTime endUtc, TimeSpan interval,
|
||||
HistoryAggregateType aggregate, CancellationToken ct) => Task.FromResult(new HistorianRead([], null));
|
||||
HistoryAggregateType aggregate, CancellationToken ct) =>
|
||||
Task.FromResult(new HistorianRead([new DataValueSnapshot(42.0, 0, startUtc, startUtc)], null));
|
||||
|
||||
public Task<HistorianRead> ReadAtTimeAsync(string fullReference, IReadOnlyList<DateTime> timestampsUtc, CancellationToken ct) =>
|
||||
Task.FromResult(new HistorianRead([], null));
|
||||
|
||||
Reference in New Issue
Block a user