Skip to main content

WellKnownNodes

WellKnownNodes This is a static class that contains predefined string NodeId constants for standard OPC Foundation nodes. Use it instead of writing the code manually to improve i=2258 code readability.

Supporting

Common Root Nodes​

ConstantsNodeIdMeaning
WellKnownNodes.RootFolderi=84Address Space Root
WellKnownNodes.ObjectsFolderi=85Business Data Root
WellKnownNodes.TypesFolderi=86Type Definition Root
WellKnownNodes.ViewsFolderi=87View Root
WellKnownNodes.Serveri=2253The Server Object Itself

Server Status​

ConstantsNodeIdMeaning
WellKnownNodes.Server_ServerStatusi=2256Server Status Structure
WellKnownNodes.Server_ServerStatus_Statei=2259Status (Running / Failed / ...)
WellKnownNodes.Server_ServerStatus_CurrentTimei=2258Current server time
WellKnownNodes.Server_ServerStatus_StartTimei=2257Server startup time
WellKnownNodes.Server_ServerStatus_BuildInfoi=2260BuildInfo (Product / Manufacturer / Version)
WellKnownNodes.Server_ServerArrayi=2254ServerArray Array of Strings
WellKnownNodes.Server_NamespaceArrayi=2255NamespaceArray Array of Strings

Standards ReferenceType​

ConstantsNodeId
WellKnownNodes.HasComponenti=47
WellKnownNodes.HasPropertyi=46
WellKnownNodes.Organizesi=35
WellKnownNodes.HasTypeDefinitioni=40
WellKnownNodes.HierarchicalReferencesi=33
WellKnownNodes.Referencesi=31

Standard Namespace URI​

The same static class group WellKnownNamespaces provides namespace constants URI:

ConstantsValue
WellKnownNamespaces.OpcFoundationhttp://opcfoundation.org/UA/
WellKnownNamespaces.DIhttp://opcfoundation.org/UA/DI/

Usage​

using DarraOpcUa_Client;

using var ua = new DarraOpcUa("opc.tcp://localhost:4840");

// Not recommended: Hard-coding
using var dv1 = ua.Read("i=2258");

// Recommendation: Use constants
using var dv2 = ua.Read(WellKnownNodes.Server_ServerStatus_CurrentTime);

ServerStatus Read in Full​

using System;
using DarraOpcUa_Client;

var items = new (string nodeId, AttributeId attr)[]
{
(WellKnownNodes.Server_ServerStatus_State, AttributeId.Value),
(WellKnownNodes.Server_ServerStatus_CurrentTime, AttributeId.Value),
(WellKnownNodes.Server_ServerStatus_StartTime, AttributeId.Value),
(WellKnownNodes.Server_NamespaceArray, AttributeId.Value),
};
var values = ua.ReadMany(items); // IReadOnlyList<DataValue>
try
{
Console.WriteLine($"State = {values[0].Value}");
Console.WriteLine($"CurrentTime = {values[1].Value.AsDateTime}");
Console.WriteLine($"StartTime = {values[2].Value.AsDateTime}");
Console.WriteLine($"Namespaces = {string.Join(",", values[3].Value.AsStringArray ?? Array.Empty<string>())}");
}
finally
{
foreach (var dv in values) dv?.Dispose();
}

Complete List​

WellKnownNodes There are 55 constants const string in total (Folder 8 / Server 16 / ReferenceType 12 / DataType 19), all of which are NodeId strings of standard ns=0 nodes. There are also ( WellKnownNamespaces 2 URI constants) in the same static class group.

Next Step​