Files
Marc Schier e8bec27d5d Complete WoT binding preservation and two-pump aggregation (#4431)
# Description

Complete WoT Binding preservation and the two-pump aggregation workflow
without implicit overlays or multi-source action fan-out.

- Add verified linked-document export and bounded partition merging.
Preserve complete source facts, reject contradictory archival content,
and retain usable readable content when a future native grammar is
unsupported.
- Wire local Methods and Condition events through the existing
injectable binding/runtime infrastructure. Keep local and upstream
identities distinct, translate namespace-bearing values, and bound
occurrence routes by source and generation.
- Wait for asynchronous event-producer readiness before completing
subscription creation, so the first alarm is not lost. Preserve
cancellation, teardown, and startup-failure reporting.
- Import runtime types in inheritance order and attach typed Method
argument Properties. Keep generated Double spelling deterministic across
supported frameworks and remove an AOT-unsafe registry validation
conversion.
- Generate both pumps and their asset/group projections. Expose fifteen
typed readings per pump, separate source-owned controls, and
acknowledge/confirm/reset workflows. Extend the demo script for managed
and NativeAOT execution, bounded failures, and exact-process cleanup.
- Synchronize current-state documentation and specification fixtures.
Compose fixture paths from platform-independent components and emit/pin
LF pump XML so byte-exact regeneration holds on Windows, Linux, and
macOS.
- Keep sample JSON readable with sorted members, two-space indentation,
and LF line endings. Normalize generated filenames to single hyphens
without changing registry resource IDs, document values, logical links,
or dependency ordering; the manifest maps resource IDs to their physical
filenames.

Most changed files are deterministic regenerations of checked-in sample
documents. The demo manifest contains 533 linked resources; the
aggregation server remains generic and has no Pump-specific compiled
model dependency.

No new alarm vocabulary, shelving/suppression/dialog/ConditionRefresh
transport mapping, Azure SDK changes, or complete Pump/OpenUSD parity is
introduced.

## Related Issues

Fixes #4430, which records the approved implementation scope, design
decisions, and acceptance criteria.

Follow-up to #4411. Specification fixtures are pinned to
[OPCF-Members/spec-drafts commit
82620d9](https://github.com/OPCF-Members/spec-drafts/commit/82620d9e313f35386dfc7477f7875cd47d2fd268),
associated with OPCF-Members/spec-drafts#35.

## Validation

- .NET 10 and .NET 8: complete affected converter/schema, WoT
Connectivity, and binding suites passed.
- .NET Framework 4.8: affected libraries, converter/generator, projected
runtime, readiness, and NodeSet-import compatibility runs passed. The
existing filesystem test exceeding the host's legacy path limit passed
through a temporary short-path alias, without changing its assertions.
- All 29 aggregation sample tests passed, including the independent
companion-model oracle.
- Managed/default-port and NativeAOT/alternate-port demo runs completed
with 533 documents, two pumps, thirty Good readings, and all four
pump/source control and alarm workflows.
- Timeout and duplicate-port failure paths were exercised; owned
processes and ports were released.
- Specification artifact/rule checks, byte-identical example mirroring,
statement-digest verification, and changed-file whitespace checks
passed.
- The [Build and Test .NET 10.0 workflow for
278b092](https://github.com/OPCFoundation/UA-.NETStandard/actions/runs/34095520510)
passed, including the previously failing Linux/macOS Types and WoT
Connectivity jobs. Portability fixes preserve the existing assertions
and add an explicit LF-output regression.
- After the readability changes in `dc61d032`, all 131 targeted
sample/projected-runtime cases passed on both .NET 10 and .NET Framework
4.8, and all 29 aggregation sample tests passed after rebuilding. All
539 JSON assets meet the formatting and filename rules; the 538 document
JSON values are unchanged, with only physical paths changing in the
manifest. Byte-exact regeneration assertions remain in place.

Local validation was scoped to affected projects rather than the entire
UA.slnx solution. Numeric coverage percentages and remaining CI gates
remain for CI; coverage thresholds were not changed. Existing unrelated
analyzer warnings were left unchanged.

## Checklist

- [ ] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [ ] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added all necessary documentation.
- [x] I have verified that my changes do not introduce (new) build or
analyzer warnings.
- [ ] I ran **all** tests locally using the **UA.slnx** solution against
at least .net **framework** and .net **10**, and all passed.
- [ ] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [x] I have addressed **all** PR feedback received.

Regression and integration tests are included and passed as described
above; the combined tests/coverage checkbox remains open because numeric
coverage was not measured locally.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6a9f41b1-72f0-4c74-bd7f-26fa531e5738
2026-09-07 12:24:14 +00:00

133 lines
5.5 KiB
C#

/* ========================================================================
* Copyright (c) 2005-2026 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System;
using System.Globalization;
using System.Threading;
using Microsoft.Extensions.Hosting;
using Opc.Ua.WotCon;
using Opc.Ua.WotCon.Client;
using AggregationClient;
try
{
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
string? timeoutText = builder.Configuration["timeoutSeconds"];
int timeoutSeconds = 480;
if (timeoutText is not null &&
(!int.TryParse(timeoutText, NumberStyles.Integer, CultureInfo.InvariantCulture, out timeoutSeconds) ||
timeoutSeconds is < 1 or > 3600))
{
throw new ArgumentException("timeoutSeconds must be an integer between 1 and 3600.");
}
string? exerciseText = builder.Configuration["exerciseControls"];
bool exerciseControls = false;
if (exerciseText is not null && !bool.TryParse(exerciseText, out exerciseControls))
{
throw new ArgumentException("exerciseControls must be true or false.");
}
var options = new AggregationClientOptions
{
AggregationEndpoint = builder.Configuration["aggregationEndpoint"] ??
"opc.tcp://localhost:62550/AggregationServer",
SourceAEndpoint = builder.Configuration["sourceAEndpoint"] ??
"opc.tcp://localhost:62551/SourceA",
SourceBEndpoint = builder.Configuration["sourceBEndpoint"] ??
"opc.tcp://localhost:62552/SourceB",
ApplicationName = builder.Configuration["applicationName"] ??
"AggregationClient",
PkiRoot = builder.Configuration["pkiRoot"],
ExerciseControls = exerciseControls,
DocumentsDirectory = builder.Configuration["documentsDirectory"] ??
System.IO.Path.Combine(AppContext.BaseDirectory, "Documents")
};
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutSeconds));
AggregationClientResult result = await AggregationClientRunner
.RunAsync(options, timeout.Token)
.ConfigureAwait(false);
foreach (WotRegistryDocumentLoadOutcome upload in result.LoadResult.Uploaded)
{
Console.WriteLine(
$"Loaded {upload.Document.Kind} {upload.Document.ResourceId} " +
$"(version {upload.VersionId}, created: {upload.Created}).");
}
WotRegistryRefreshResult refresh = result.LoadResult.Refresh ??
throw new InvalidOperationException("The registry refresh did not run.");
Console.WriteLine(
$"Refresh generation {refresh.NewGeneration}: {refresh.Summary.Outcome}, " +
$"{refresh.Summary.Succeeded}/{refresh.Summary.Total} succeeded.");
foreach (WoTResourceLoadResultDataType resource in refresh.Results)
{
Console.WriteLine(
$" {resource.ResourceId}: {resource.Phase}/{resource.Outcome} " +
$"({resource.LoadState})");
if (!string.IsNullOrWhiteSpace(resource.Message))
{
Console.WriteLine($" Message: {resource.Message}");
}
}
int totalValues = 0;
foreach (WotPumpResult pump in result.Pumps)
{
Console.WriteLine($"Materialized {pump.Name} browse:");
foreach (WotPumpBrowseNode node in pump.BrowsedNodes)
{
Console.WriteLine($" {node.NodeId}: {node.DisplayName} ({node.NodeClass})");
}
Console.WriteLine($"Materialized {pump.Name} values:");
foreach (WotPumpValueResult value in pump.Values)
{
Console.WriteLine($" {pump.Name}.{value.Name}: {value.Value} [{value.StatusCode}]");
totalValues++;
}
}
Console.WriteLine(
$"WOT_AGGREGATION_DATA_OK documents={result.LoadResult.Uploaded.Count} " +
$"pumps={result.Pumps.Count} values={totalValues}");
foreach (WotPumpControlResult control in result.Controls)
{
Console.WriteLine(
$"{control.PumpName}/{control.SourceName}: Start, Stop, Reset, Acknowledge and Confirm completed.");
}
if (result.Controls.Count == 4)
{
Console.WriteLine($"WOT_AGGREGATION_CONTROLS_OK sourcePumpPairs={result.Controls.Count}");
}
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
Console.Error.WriteLine(ex.StackTrace);
Environment.ExitCode = 1;
}