Skip to main content

WellKnownNodes (C)

The C SDK uses the UA_WELL_* macros from opcua_node_id.h (NodeId string literals whose value is ns=0) to improve readability by replacing hand-written strings. For other standard nodes that the SDK does not override, just write the literal directly.

Supporting

SDK Available UA_WELL_* macros​

/* opcua_node_id.h — Standard OPC UA Node (ns=0) */

/* Root */
#define UA_WELL_ROOT_FOLDER "i=84"
#define UA_WELL_OBJECTS_FOLDER "i=85"
#define UA_WELL_TYPES_FOLDER "i=86"
#define UA_WELL_VIEWS_FOLDER "i=87"

/* The server itself */
#define UA_WELL_SERVER "i=2253"
#define UA_WELL_SERVER_STATUS "i=2256"

/* ServerStatus Structure */
#define UA_WELL_CURRENT_TIME "i=2258"
#define UA_WELL_SERVER_STATE "i=2259"

/* Standards ReferenceType */
#define UA_WELL_REFERENCES "i=31"
#define UA_WELL_HIERARCHICAL_REFERENCES "i=33"
#define UA_WELL_ORGANIZES "i=35"
#define UA_WELL_HAS_TYPE_DEFINITION "i=40"
#define UA_WELL_HAS_PROPERTY "i=46"
#define UA_WELL_HAS_COMPONENT "i=47"

Comparison of Usage​

/* Not recommended: Hard-coding */
DarraUa_DataValue* dv = DarraUa_Session_ReadNode(
h, "i=2258", UA_ATTR_VALUE, &st);

/* Recommended: Use macros */
#include <opcua_node_id.h>
DarraUa_DataValue* dv = DarraUa_Session_ReadNode(
h, UA_WELL_CURRENT_TIME, UA_ATTR_VALUE, &st);

ServerStatus Complete Read Example​

const char* nodes[] = {
UA_WELL_SERVER_STATE,
UA_WELL_CURRENT_TIME,
UA_WELL_SERVER_STATUS,
UA_WELL_SERVER,
};
DarraUa_DataValue* dvs[4] = { NULL };
DarraUa_Session_ReadNodes(h, nodes, NULL, 4, dvs);

for (int i = 0; i < 4; ++i) {
if (!dvs[i]) continue;
const DarraUa_Variant* v = DarraUa_DataValue_GetValue(dvs[i]);
printf("%-30s -> ", nodes[i]);
/* Format by Type (omitted; see the section Variant for details) */
DarraUa_DataValue_Delete(dvs[i]);
}

Complete List​

Lines preceded UA_WELL_* by are macros provided SDK by; the rest are standard OPC UA NodeId, where no SDK macros are provided, so string literals are written directly.

NodeNodeIdMeaning
Rooti=84UA_WELL_ROOT_FOLDER · Address Space Root
Objectsi=85UA_WELL_OBJECTS_FOLDER · Business Data Root
Typesi=86UA_WELL_TYPES_FOLDER · Type Definition Root
Viewsi=87UA_WELL_VIEWS_FOLDER · View Root
Serveri=2253UA_WELL_SERVER · The Server object itself
ServerStatusi=2256UA_WELL_SERVER_STATUS · Server Status Structure
ServerStatus.Statei=2259UA_WELL_SERVER_STATE · Status (Running / Failed / ...)
ServerStatus.CurrentTimei=2258UA_WELL_CURRENT_TIME · Current server time
Referencesi=31UA_WELL_REFERENCES · ReferenceType Root
HierarchicalReferencesi=33UA_WELL_HIERARCHICAL_REFERENCES · Root of hierarchical references
Organizesi=35UA_WELL_ORGANIZES · ReferenceType
HasTypeDefinitioni=40UA_WELL_HAS_TYPE_DEFINITION · ReferenceType
HasPropertyi=46UA_WELL_HAS_PROPERTY · ReferenceType
HasComponenti=47UA_WELL_HAS_COMPONENT · ReferenceType
ServerStatus.StartTimei=2257SDK No Macros · Server Startup Time
ServerStatus.BuildInfoi=2260SDK No Macro · Manufacturer / Product / Version
ServerArrayi=2254SDK No Macros · Server-Side Arrays
NamespaceArrayi=2255SDK No Macros · Namespace Arrays
HasSubtypei=45SDK Unlisted constants · ReferenceType (handwritten "i=45")

For the complete OPC UA standard NodeIds, see the OPC UA Part 6 appendix and the Opc.Ua.NodeIds.csv table provided by the OPC Foundation (applicable across languages).

Next Step​