Refine XML docs for historian, OPC UA, and tests
This commit is contained in:
@@ -18,6 +18,10 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.Historian
|
||||
|
||||
private readonly HistorianConfiguration _config;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a Historian reader that translates OPC UA history requests into Wonderware Historian queries.
|
||||
/// </summary>
|
||||
/// <param name="config">The Historian connection settings and command timeout used for runtime history lookups.</param>
|
||||
public HistorianDataSource(HistorianConfiguration config)
|
||||
{
|
||||
_config = config;
|
||||
@@ -26,6 +30,11 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.Historian
|
||||
/// <summary>
|
||||
/// Reads raw historical values for a tag from the Historian.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The Wonderware tag name backing the OPC UA node whose raw history is being requested.</param>
|
||||
/// <param name="startTime">The inclusive start of the client-requested history window.</param>
|
||||
/// <param name="endTime">The inclusive end of the client-requested history window.</param>
|
||||
/// <param name="maxValues">The maximum number of samples to return when the OPC UA client limits the result set.</param>
|
||||
/// <param name="ct">The cancellation token that aborts the database call when the OPC UA request is cancelled.</param>
|
||||
public async Task<List<DataValue>> ReadRawAsync(
|
||||
string tagName, DateTime startTime, DateTime endTime, int maxValues,
|
||||
CancellationToken ct = default)
|
||||
@@ -76,6 +85,12 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.Historian
|
||||
/// <summary>
|
||||
/// Reads aggregate historical values for a tag from the Historian.
|
||||
/// </summary>
|
||||
/// <param name="tagName">The Wonderware tag name backing the OPC UA node whose aggregate history is being requested.</param>
|
||||
/// <param name="startTime">The inclusive start of the aggregate history window requested by the OPC UA client.</param>
|
||||
/// <param name="endTime">The inclusive end of the aggregate history window requested by the OPC UA client.</param>
|
||||
/// <param name="intervalMs">The Wonderware summary resolution, in milliseconds, used to bucket aggregate values.</param>
|
||||
/// <param name="aggregateColumn">The Historian summary column that matches the OPC UA aggregate function being requested.</param>
|
||||
/// <param name="ct">The cancellation token that aborts the aggregate query when the client request is cancelled.</param>
|
||||
public async Task<List<DataValue>> ReadAggregateAsync(
|
||||
string tagName, DateTime startTime, DateTime endTime,
|
||||
double intervalMs, string aggregateColumn,
|
||||
@@ -119,6 +134,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.Historian
|
||||
/// <summary>
|
||||
/// Maps Wonderware Historian quality codes to OPC UA StatusCodes.
|
||||
/// </summary>
|
||||
/// <param name="quality">The raw Wonderware Historian quality byte stored with a historical sample.</param>
|
||||
public static StatusCode MapQuality(byte quality)
|
||||
{
|
||||
if (quality == 0)
|
||||
@@ -134,6 +150,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.Historian
|
||||
/// Maps an OPC UA aggregate NodeId to the corresponding Historian column name.
|
||||
/// Returns null if the aggregate is not supported.
|
||||
/// </summary>
|
||||
/// <param name="aggregateId">The OPC UA aggregate identifier requested by the history client.</param>
|
||||
public static string? MapAggregateToColumn(NodeId aggregateId)
|
||||
{
|
||||
if (aggregateId == ObjectIds.AggregateFunction_Average)
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
/// <summary>
|
||||
/// Compares old and new hierarchy+attributes and returns the set of gobject IDs that have any difference.
|
||||
/// </summary>
|
||||
/// <param name="oldHierarchy">The previously published Galaxy object hierarchy snapshot.</param>
|
||||
/// <param name="oldAttributes">The previously published Galaxy attribute snapshot keyed to the old hierarchy.</param>
|
||||
/// <param name="newHierarchy">The latest Galaxy object hierarchy snapshot pulled from the repository.</param>
|
||||
/// <param name="newAttributes">The latest Galaxy attribute snapshot that should be reflected in the OPC UA namespace.</param>
|
||||
public static HashSet<int> FindChangedGobjectIds(
|
||||
List<GalaxyObjectInfo> oldHierarchy, List<GalaxyAttributeInfo> oldAttributes,
|
||||
List<GalaxyObjectInfo> newHierarchy, List<GalaxyAttributeInfo> newAttributes)
|
||||
@@ -70,6 +74,8 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
/// <summary>
|
||||
/// Expands a set of changed gobject IDs to include all descendant gobject IDs in the hierarchy.
|
||||
/// </summary>
|
||||
/// <param name="changed">The root Galaxy objects that were detected as changed between snapshots.</param>
|
||||
/// <param name="hierarchy">The hierarchy used to include descendant objects whose OPC UA nodes must also be rebuilt.</param>
|
||||
public static HashSet<int> ExpandToSubtrees(HashSet<int> changed, List<GalaxyObjectInfo> hierarchy)
|
||||
{
|
||||
var childrenByParent = hierarchy.GroupBy(h => h.ParentGobjectId)
|
||||
|
||||
@@ -54,8 +54,19 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
|
||||
private sealed class TagMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the MXAccess data type code used to map Galaxy values into OPC UA variants.
|
||||
/// </summary>
|
||||
public int MxDataType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the source Galaxy attribute should be exposed as an array node.
|
||||
/// </summary>
|
||||
public bool IsArray { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the declared array length from Galaxy metadata when the attribute is modeled as an array.
|
||||
/// </summary>
|
||||
public int? ArrayDimension { get; set; }
|
||||
}
|
||||
|
||||
@@ -70,14 +81,49 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
|
||||
private sealed class AlarmInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the full tag reference for the process value whose alarm state is tracked.
|
||||
/// </summary>
|
||||
public string SourceTagReference { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the OPC UA node identifier for the source variable that owns the alarm condition.
|
||||
/// </summary>
|
||||
public NodeId SourceNodeId { get; set; } = NodeId.Null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the operator-facing source name used in generated alarm events.
|
||||
/// </summary>
|
||||
public string SourceName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the most recent in-alarm state so duplicate transitions are not reissued.
|
||||
/// </summary>
|
||||
public bool LastInAlarm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the retained OPC UA condition node associated with the source alarm.
|
||||
/// </summary>
|
||||
public AlarmConditionState? ConditionNode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Galaxy tag reference that supplies runtime alarm priority updates.
|
||||
/// </summary>
|
||||
public string PriorityTagReference { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Galaxy tag reference or attribute binding used to resolve the alarm message text.
|
||||
/// </summary>
|
||||
public string DescAttrNameTagReference { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cached OPC UA severity derived from the latest alarm priority value.
|
||||
/// </summary>
|
||||
public ushort CachedSeverity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cached alarm message used when emitting active and cleared events.
|
||||
/// </summary>
|
||||
public string CachedMessage { get; set; } = "";
|
||||
}
|
||||
|
||||
@@ -124,6 +170,8 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
/// <param name="namespaceUri">The namespace URI that identifies the Galaxy model to clients.</param>
|
||||
/// <param name="mxAccessClient">The runtime client used to service reads, writes, and subscriptions.</param>
|
||||
/// <param name="metrics">The metrics collector used to track node manager activity.</param>
|
||||
/// <param name="historianDataSource">The optional historian adapter used to satisfy OPC UA history read requests.</param>
|
||||
/// <param name="alarmTrackingEnabled">Enables alarm-condition state generation for Galaxy attributes modeled as alarms.</param>
|
||||
public LmxNodeManager(
|
||||
IServerInternal server,
|
||||
ApplicationConfiguration configuration,
|
||||
@@ -444,6 +492,8 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
/// <summary>
|
||||
/// Incrementally syncs the address space by detecting changed gobjects and rebuilding only those subtrees. (OPC-010)
|
||||
/// </summary>
|
||||
/// <param name="hierarchy">The latest Galaxy object hierarchy snapshot to compare against the currently published model.</param>
|
||||
/// <param name="attributes">The latest Galaxy attribute snapshot to compare against the currently published variables.</param>
|
||||
public void SyncAddressSpace(List<GalaxyObjectInfo> hierarchy, List<GalaxyAttributeInfo> attributes)
|
||||
{
|
||||
lock (Lock)
|
||||
@@ -1140,9 +1190,9 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
|
||||
#region Condition Refresh
|
||||
|
||||
/// <summary>
|
||||
/// Reports all active retained alarm conditions during a condition refresh.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
/// <param name="context">The OPC UA request context for the condition refresh operation.</param>
|
||||
/// <param name="monitoredItems">The monitored event items that should receive retained alarm conditions.</param>
|
||||
public override ServiceResult ConditionRefresh(OperationContext context, IList<IEventMonitoredItem> monitoredItems)
|
||||
{
|
||||
foreach (var kvp in _alarmInAlarmTags)
|
||||
|
||||
@@ -42,6 +42,8 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
/// <param name="galaxyName">The Galaxy name used to construct the namespace URI and product URI.</param>
|
||||
/// <param name="mxAccessClient">The runtime client used by the node manager for live data access.</param>
|
||||
/// <param name="metrics">The metrics collector shared with the node manager.</param>
|
||||
/// <param name="historianDataSource">The optional historian adapter used when clients issue OPC UA history reads.</param>
|
||||
/// <param name="alarmTrackingEnabled">Enables alarm condition tracking for alarm-capable Galaxy attributes.</param>
|
||||
public LmxOpcUaServer(string galaxyName, IMxAccessClient mxAccessClient, PerformanceMetrics metrics,
|
||||
HistorianDataSource? historianDataSource = null, bool alarmTrackingEnabled = false)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.OpcUa
|
||||
/// <param name="config">The endpoint and session settings for the OPC UA host.</param>
|
||||
/// <param name="mxAccessClient">The runtime client used by the node manager for live reads, writes, and subscriptions.</param>
|
||||
/// <param name="metrics">The metrics collector shared with the node manager and runtime bridge.</param>
|
||||
/// <param name="historianDataSource">The optional historian adapter that enables OPC UA history read support.</param>
|
||||
public OpcUaServerHost(OpcUaConfiguration config, IMxAccessClient mxAccessClient, PerformanceMetrics metrics,
|
||||
HistorianDataSource? historianDataSource = null)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Host.Status
|
||||
/// <param name="metrics">The performance metrics collector whose operation statistics should be reported.</param>
|
||||
/// <param name="galaxyStats">The Galaxy repository statistics to surface on the dashboard.</param>
|
||||
/// <param name="serverHost">The OPC UA server host whose active session count should be reported.</param>
|
||||
/// <param name="nodeManager">The node manager whose queue depth and MXAccess event throughput should be surfaced on the dashboard.</param>
|
||||
public void SetComponents(IMxAccessClient? mxAccessClient, PerformanceMetrics? metrics,
|
||||
GalaxyRepositoryStats? galaxyStats, OpcUaServerHost? serverHost,
|
||||
LmxNodeManager? nodeManager = null)
|
||||
|
||||
Reference in New Issue
Block a user