well_known_nodes
well_known_nodes Module-defined NodeId string constants for standard OPC Foundation nodes. Use them instead of writing them out manually to improve i=2258 code readability.
from darra_opcua import well_known_nodes as wkn # Module Name darra_opcua (pip package darra-opcua)
# or
from darra_opcua import wkn # Predefined aliases
- See Namespace Reverse Lookup Namespaces.
- To NodeId read the data, see read / write.
Common Root Nodes
| Constants | NodeId | Meaning |
|---|---|---|
| wkn.ROOT_FOLDER | i=84 | Address Space Root |
| wkn.OBJECTS_FOLDER | i=85 | Business Data Root |
| wkn.TYPES_FOLDER | i=86 | Type Definition Root |
| wkn.VIEWS_FOLDER | i=87 | View Root |
| wkn.SERVER | i=2253 | The Server Object Itself |
Server Status
| Constants | NodeId | Meaning |
|---|---|---|
| wkn.SERVER_SERVER_STATUS | i=2256 | Server Status Structure |
| wkn.SERVER_SERVER_STATUS_STATE | i=2259 | Status (Running / Failed / ...) |
| wkn.SERVER_SERVER_STATUS_CURRENT_TIME | i=2258 | Current server time |
| wkn.SERVER_SERVER_STATUS_START_TIME | i=2257 | Server startup time |
| wkn.SERVER_SERVER_STATUS_BUILD_INFO | i=2260 | BuildInfo (Product / Manufacturer / Version) |
| wkn.SERVER_SERVER_ARRAY | i=2254 | ServerArray Array of Strings |
| wkn.SERVER_NAMESPACE_ARRAY | i=2255 | NamespaceArray Array of Strings |
Standards ReferenceType
| Constants | NodeId |
|---|---|
| wkn.HAS_COMPONENT | i=47 |
| wkn.HAS_PROPERTY | i=46 |
| wkn.ORGANIZES | i=35 |
| wkn.HAS_TYPE_DEFINITION | i=40 |
| wkn.REFERENCES | i=31 |
| wkn.HIERARCHICAL_REFERENCES | i=33 |
Common DataType
| Constants | NodeId |
|---|---|
| wkn.BOOLEAN | i=1 |
| wkn.INT32 | i=6 |
| wkn.UINT32 | i=7 |
| wkn.INT64 | i=8 |
| wkn.FLOAT | i=10 |
| wkn.DOUBLE | i=11 |
| wkn.STRING | i=12 |
| wkn.DATE_TIME | i=13 |
| wkn.BYTE_STRING | i=15 |
WellKnownNamespaces
from darra_opcua import WellKnownNamespaces
WellKnownNamespaces.OPC_FOUNDATION # "http://opcfoundation.org/UA/"
WellKnownNamespaces.DI # "http://opcfoundation.org/UA/DI/"
Usage
from darra_opcua import wkn
# ua It is connected. OpcUaSession
# Not recommended: Hard-coding
with ua.read("i=2258") as dv:
print(dv.value)
# Recommendation: Use constants
with ua.read(wkn.SERVER_SERVER_STATUS_CURRENT_TIME) as dv:
print(dv.value)
ServerStatus Read All (Batch)
from darra_opcua import wkn
nodes = [
wkn.SERVER_SERVER_STATUS_STATE,
wkn.SERVER_SERVER_STATUS_CURRENT_TIME,
wkn.SERVER_SERVER_STATUS_START_TIME,
wkn.SERVER_NAMESPACE_ARRAY,
]
results = ua.read_many(nodes) # List[Optional[OpcUaDataValue]]
names = ["State", "CurrentTime", "StartTime", "Namespaces"]
for name, dv in zip(names, results):
if dv:
with dv:
print(f"{name:13s} = {dv.value}")
Complete List
Searching the source code — darra_opcua/well_known_nodes.py a total of 55 constants (8 Folders + 16 Servers + 12 ReferenceTypes + 19 DataTypes), all of which are nodes under the standard OPC Foundation namespace ns=0, and their type is str (NodeId string encoding).
Cross-Language Comparison
ConstantsNaming Conventions The languages are different, but the values are the same (i=NNN strings):
| Meaning | Python | C# | Java | C++ | Rust | C |
|---|---|---|---|---|---|---|
| Citation Format | wkn Module Constants | WellKnownNodes Static Class Constants | — | — | — | — |
| Address Space Root | wkn.ROOT_FOLDER | WellKnownNodes.RootFolder | — | — | — | — |
| Business Data Root | wkn.OBJECTS_FOLDER | WellKnownNodes.ObjectsFolder | — | — | — | — |
| Current server time | wkn.SERVER_SERVER_STATUS_CURRENT_TIME | WellKnownNodes.Server_ServerStatus_CurrentTime | — | — | — | — |
| Standard Namespace URI | WellKnownNamespaces.OPC_FOUNDATION | WellKnownNamespaces.OpcFoundation | — | — | — | — |
Python isModule-Level Underline and Capitalization, C# isStatic Class in PascalCase with underscores separating segments, Namespace DarraOpcUa_Client. Both columns should contain their respective real names; do not copy from the other column.
Java / C++ / Rust / C: The four columns marked "read-only, unverified" in this entry — indicate that the information has not been verified; it does not mean that it does not exist.