96 lines
6.8 KiB
C#
96 lines
6.8 KiB
C#
using ZB.MOM.WW.OtOpcUa.Commons.OpcUa;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.OpcUaServer;
|
|
|
|
/// <summary>
|
|
/// Production <see cref="IOpcUaAddressSpaceSink"/> binding for v2 — bridges
|
|
/// OpcUaPublishActor's writes to the SDK address space owned by
|
|
/// <see cref="OtOpcUaNodeManager"/>. The host wires this in once the StandardServer has
|
|
/// been started (so the node manager exists).
|
|
/// </summary>
|
|
public sealed class SdkAddressSpaceSink : IOpcUaAddressSpaceSink, ISurgicalAddressSpaceSink
|
|
{
|
|
private readonly OtOpcUaNodeManager _nodeManager;
|
|
|
|
/// <summary>Initializes a new instance of the SdkAddressSpaceSink class.</summary>
|
|
/// <param name="nodeManager">The OPC UA node manager.</param>
|
|
public SdkAddressSpaceSink(OtOpcUaNodeManager nodeManager)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(nodeManager);
|
|
_nodeManager = nodeManager;
|
|
}
|
|
|
|
/// <summary>Writes a value to the OPC UA address space.</summary>
|
|
/// <param name="nodeId">The OPC UA node identifier.</param>
|
|
/// <param name="value">The value being written.</param>
|
|
/// <param name="quality">The OPC UA quality status.</param>
|
|
/// <param name="sourceTimestampUtc">The source timestamp in UTC.</param>
|
|
public void WriteValue(string nodeId, object? value, OpcUaQuality quality, DateTime sourceTimestampUtc)
|
|
=> _nodeManager.WriteValue(nodeId, value, quality, sourceTimestampUtc);
|
|
|
|
/// <summary>Writes the full Part 9 alarm-condition state to the OPC UA address space.</summary>
|
|
/// <param name="alarmNodeId">The alarm node identifier.</param>
|
|
/// <param name="state">The full condition state to project onto the node.</param>
|
|
/// <param name="sourceTimestampUtc">The source timestamp in UTC.</param>
|
|
public void WriteAlarmCondition(string alarmNodeId, AlarmConditionSnapshot state, DateTime sourceTimestampUtc)
|
|
=> _nodeManager.WriteAlarmCondition(alarmNodeId, state, sourceTimestampUtc);
|
|
|
|
/// <summary>Materialises a real Part 9 alarm-condition node in the address space.</summary>
|
|
/// <param name="alarmNodeId">The alarm node identifier (== ScriptedAlarmId).</param>
|
|
/// <param name="equipmentNodeId">The equipment folder node identifier the condition parents under.</param>
|
|
/// <param name="displayName">The human-readable condition name.</param>
|
|
/// <param name="alarmType">The domain alarm type.</param>
|
|
/// <param name="severity">The domain severity.</param>
|
|
/// <param name="isNative">True for a driver-fed (native) equipment-tag alarm; false (default) for a scripted alarm.</param>
|
|
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false)
|
|
=> _nodeManager.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity, isNative);
|
|
|
|
/// <summary>Ensures a folder node exists in the address space.</summary>
|
|
/// <param name="folderNodeId">The folder node identifier.</param>
|
|
/// <param name="parentNodeId">The parent folder node identifier.</param>
|
|
/// <param name="displayName">The display name for the folder.</param>
|
|
public void EnsureFolder(string folderNodeId, string? parentNodeId, string displayName)
|
|
=> _nodeManager.EnsureFolder(folderNodeId, parentNodeId, displayName);
|
|
|
|
/// <summary>Ensures a variable node exists in the address space.</summary>
|
|
/// <param name="variableNodeId">The variable node identifier.</param>
|
|
/// <param name="parentFolderNodeId">The parent folder node identifier.</param>
|
|
/// <param name="displayName">The display name for the variable.</param>
|
|
/// <param name="dataType">The OPC UA data type.</param>
|
|
/// <param name="writable">When true the node is created read/write; otherwise read-only.</param>
|
|
/// <param name="historianTagname">null ⇒ not historized; non-null ⇒ create Historizing with the
|
|
/// HistoryRead access bit and register the historian tagname.</param>
|
|
/// <param name="isArray">When true the node is created as a 1-D array; when false (default) scalar.</param>
|
|
/// <param name="arrayLength">The declared length of the 1-D array when <paramref name="isArray"/> is true.</param>
|
|
public void EnsureVariable(string variableNodeId, string? parentFolderNodeId, string displayName, string dataType, bool writable, string? historianTagname = null, bool isArray = false, uint? arrayLength = null)
|
|
=> _nodeManager.EnsureVariable(variableNodeId, parentFolderNodeId, displayName, dataType, writable, historianTagname, isArray, arrayLength);
|
|
|
|
/// <summary>F10b: surgically update an existing variable node's Writable + Historizing + presentation
|
|
/// shape (DataType / array-ness) in place (no rebuild). Returns false when the node does not exist
|
|
/// (caller falls back to a full rebuild).</summary>
|
|
/// <param name="variableNodeId">The variable node identifier.</param>
|
|
/// <param name="writable">When true the node becomes read/write with the inbound-write handler; otherwise read-only.</param>
|
|
/// <param name="historianTagname">null ⇒ not historized; non-null ⇒ Historizing with the HistoryRead bit and tagname binding.</param>
|
|
/// <param name="dataType">The OPC UA built-in data type name to apply in place.</param>
|
|
/// <param name="isArray">When true the node becomes a 1-D array; when false scalar.</param>
|
|
/// <param name="arrayLength">The declared length of the 1-D array when <paramref name="isArray"/> is true.</param>
|
|
public bool UpdateTagAttributes(string variableNodeId, bool writable, string? historianTagname, string dataType, bool isArray, uint? arrayLength)
|
|
=> _nodeManager.UpdateTagAttributes(variableNodeId, writable, historianTagname, dataType, isArray, arrayLength);
|
|
|
|
/// <summary>OpcUaServer-001: surgically update an existing folder node's display name in place (no
|
|
/// rebuild) for a UNS Area / Line rename. Returns false when the folder does not exist (caller falls
|
|
/// back to a full rebuild).</summary>
|
|
/// <param name="folderNodeId">The folder node identifier whose display name to update in place.</param>
|
|
/// <param name="displayName">The new display name to apply.</param>
|
|
/// <returns>True when the in-place update was applied; false when the folder is missing.</returns>
|
|
public bool UpdateFolderDisplayName(string folderNodeId, string displayName)
|
|
=> _nodeManager.UpdateFolderDisplayName(folderNodeId, displayName);
|
|
|
|
/// <summary>Rebuilds the entire OPC UA address space.</summary>
|
|
public void RebuildAddressSpace() => _nodeManager.RebuildAddressSpace();
|
|
|
|
/// <summary>Announces a runtime NodeAdded model-change (discovered-node injection) to subscribed clients.</summary>
|
|
/// <param name="affectedNodeId">The node under which discovered nodes were added.</param>
|
|
public void RaiseNodesAddedModelChange(string affectedNodeId) => _nodeManager.RaiseNodesAddedModelChange(affectedNodeId);
|
|
}
|