NodeCollection — s.Nodes()
darra::opcua::NodeCollection This is the entry point for accessing Session nodes, returned via the indexer. Node Items to be packaged, Not triggered immediately RPC (Lazy Load).
Prerequisite Reading
- Single node API Please see Node.
- For standard node constants, see WellKnownNodes.
Indexer
| Index | Return | Note |
|---|---|---|
| Nodes()[std::string const& node_id] | Node | String NodeId Access |
Predefined Entry Methods
For your convenience, here are some commonly used shortcuts:
| Category | Property | Type | Access | Description |
|---|---|---|---|---|
| Standard Entry | Root() | Node | R | Address Space Root (i=84) |
Objects() | Node | R | Business Data Root (i=85) | |
Types() | Node | R | Root of type definitions (i=86) | |
Views() | Node | R | View root (i=87) | |
Server() | Node | R | Server object (i=2253) |
// These two lines are equivalent.
auto t1 = s.Nodes().Server()["ServerStatus"]["CurrentTime"].Value();
auto t2 = s.Nodes()["i=2253"]["ServerStatus"]["CurrentTime"].Value();
Lazy Load Mechanism
auto node = s.Nodes()["ns=2;s=Temperature"]; // ← Do not trigger RPC
auto dv = node.Value(); // ← The first call to .Value() triggers a Read
On the second access, it will still .Value() re-read (without caching) because the variable value can change at any time. I want to cache the variable myself.
Child Node BrowseName Index
auto sub = node["ChildName"]; // Browse BrowseName child nodes
The process of selecting nodes:
- Use
Browse(currentNodeId)to get the list of child nodes immediately (1 time Browse RPC) - Find the child that
BrowseNameis orDisplayName"ChildName"equal to, and return the wrapperNode - Cannot find a return value that is null NodeId Node; a exception will
.Value()be thrown later.Exception
Each operator[] is a Browse; there is no cache: a["b"]["c"]["d"] is 3 Browses, not 1. The deeper the chain, the more RPCs; to save RPCs, switch to TranslateBrowsePaths or get the NodeId directly.
When to Use an Indexer, When to Use a String
| Scenario | Recommendations |
|---|---|
| Known with precision NodeId | String (s.Read("ns=2;s=...")) |
| Standard Nodes (Server Status, etc.) | Nodes().Server()[...] |
| Browse Tree / Write a One-Time Script | Indexer (Nodes()["..."]["..."]) |
| Batch (100+ nodes) | ReadMany / BrowseMany, Do not loop |