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
{
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 alarm state to the OPC UA address space.
/// The alarm node identifier.
/// Whether the alarm is active.
/// Whether the alarm is acknowledged.
/// The source timestamp in UTC.
public void WriteAlarmState(string alarmNodeId, bool active, bool acknowledged, DateTime sourceTimestampUtc)
=> _nodeManager.WriteAlarmState(alarmNodeId, active, acknowledged, sourceTimestampUtc);
/// 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.
public void EnsureVariable(string variableNodeId, string? parentFolderNodeId, string displayName, string dataType)
=> _nodeManager.EnsureVariable(variableNodeId, parentFolderNodeId, displayName, dataType);
/// Rebuilds the entire OPC UA address space.
public void RebuildAddressSpace() => _nodeManager.RebuildAddressSpace();
}