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 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.
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity)
=> _nodeManager.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity);
/// 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();
}