/* ========================================================================
* 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 Opc.Ua;
using Opc.Ua.WotCon.Client;
namespace AggregationClient
{
///
/// Configures the reusable aggregation loader and reader workflow.
///
public sealed class AggregationClientOptions
{
///
/// Gets or sets the aggregation server endpoint.
///
public string AggregationEndpoint { get; set; } =
"opc.tcp://localhost:62550/AggregationServer";
///
/// Gets or sets the Source A endpoint substituted into the Pump TD.
///
public string SourceAEndpoint { get; set; } =
"opc.tcp://localhost:62551/SourceA";
///
/// Gets or sets the Source B endpoint substituted into the Pump TD.
///
public string SourceBEndpoint { get; set; } =
"opc.tcp://localhost:62552/SourceB";
///
/// Gets or sets the OPC UA application name.
///
public string ApplicationName { get; set; } = "AggregationClient";
///
/// Gets or sets the isolated PKI root.
///
public string? PkiRoot { get; set; }
///
/// Gets or sets the directory containing documents.json and its documents.
///
public string DocumentsDirectory { get; set; } =
System.IO.Path.Combine(System.AppContext.BaseDirectory, "Documents");
///
/// Gets or sets whether to run the explicit control and alarm demonstration.
///
public bool ExerciseControls { get; set; }
}
///
/// Result of loading, refreshing, browsing and reading the aggregate Pump.
///
public sealed class AggregationClientResult
{
///
/// Initializes a result.
///
public AggregationClientResult(
WotRegistryBulkLoadResult loadResult,
ArrayOf browsedNodes,
ArrayOf values)
{
LoadResult = loadResult;
BrowsedNodes = browsedNodes;
Values = values;
}
///
/// Initializes the result of loading both pumps.
///
public AggregationClientResult(
WotRegistryBulkLoadResult loadResult,
ArrayOf pumps,
ArrayOf controls = default)
{
LoadResult = loadResult;
Pumps = pumps;
Controls = controls;
if (!pumps.IsEmpty)
{
BrowsedNodes = pumps[0].BrowsedNodes;
Values = pumps[0].Values;
}
}
///
/// Gets the document load and refresh result.
///
public WotRegistryBulkLoadResult LoadResult { get; }
///
/// Gets the recursively browsed Pump nodes.
///
public ArrayOf BrowsedNodes { get; }
///
/// Gets the values read from the materialized Pump.
///
public ArrayOf Values { get; }
///
/// Gets the independently browsed and read pumps.
///
public ArrayOf Pumps { get; }
///
/// Gets completed source-owned management and alarm round trips.
///
public ArrayOf Controls { get; }
}
///
/// Identifies a completed Start, Stop, Reset, Acknowledge and Confirm demonstration.
///
public sealed class WotPumpControlResult
{
///
/// Initializes the completed control result.
///
public WotPumpControlResult(string pumpName, string sourceName)
{
PumpName = pumpName ?? throw new ArgumentNullException(nameof(pumpName));
SourceName = sourceName ?? throw new ArgumentNullException(nameof(sourceName));
}
///
/// Gets the pump whose local actions were exercised.
///
public string PumpName { get; }
///
/// Gets the independently observed upstream source.
///
public string SourceName { get; }
}
///
/// Contains the model identity, browse results, and typed readings for one pump.
///
public sealed class WotPumpResult
{
///
/// Initializes the pump result.
///
public WotPumpResult(
string name,
NodeId rootNodeId,
ArrayOf browsedNodes,
ArrayOf values)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
RootNodeId = rootNodeId;
BrowsedNodes = browsedNodes;
Values = values;
}
///
/// Gets the stable pump name.
///
public string Name { get; }
///
/// Gets the root discovered by browsing from Objects.
///
public NodeId RootNodeId { get; }
///
/// Gets the pump's objects, variables, methods, and nested properties.
///
public ArrayOf BrowsedNodes { get; }
///
/// Gets the measurements, supervision signals, and identity values.
///
public ArrayOf Values { get; }
}
///
/// Describes one node found while browsing the materialized Pump.
///
public sealed class WotPumpBrowseNode
{
///
/// Initializes a browse result.
///
public WotPumpBrowseNode(
NodeId nodeId,
QualifiedName browseName,
LocalizedText displayName,
NodeClass nodeClass)
{
NodeId = nodeId;
BrowseName = browseName;
DisplayName = displayName;
NodeClass = nodeClass;
}
///
/// Gets the node id.
///
public NodeId NodeId { get; }
///
/// Gets the browse name.
///
public QualifiedName BrowseName { get; }
///
/// Gets the display name.
///
public LocalizedText DisplayName { get; }
///
/// Gets the node class.
///
public NodeClass NodeClass { get; }
}
///
/// Contains one materialized Pump value.
///
public sealed class WotPumpValueResult
{
///
/// Initializes a value result.
///
public WotPumpValueResult(
string name,
NodeId nodeId,
StatusCode statusCode,
Variant value)
{
Name = name;
NodeId = nodeId;
StatusCode = statusCode;
Value = value;
}
///
/// Gets the stable property name.
///
public string Name { get; }
///
/// Gets the materialized node id.
///
public NodeId NodeId { get; }
///
/// Gets the read status.
///
public StatusCode StatusCode { get; }
///
/// Gets the read value.
///
public Variant Value { get; }
}
}