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