Skip to main content

Node — darra::opcua::Node

Node Yes NodeCollection The wrapper object returned by the indexer represents a remote node. Lazy Load — Only access methods trigger RPC.

Prerequisite Reading

Public Methods (Accessors)​

CategoryPropertyTypeAccessDescription
Tags (None RPC)NodeId()std::string const&RNode ID string
Data (Trigger RPC)Value()DataValueRCurrent value — triggers Read(Value)
DisplayName()std::stringRDisplay name — triggers Read(DisplayName)
BrowseName()std::stringRView name — triggers Read(BrowseName)
Description()std::stringRDescription — Triggers Read(Description)
GetNodeClass()NodeClassRNode class — triggers Read(NodeClass)
IsReadable()boolRAccessLevel bit 0 — triggers Read(AccessLevel)
IsWritable()boolRAccessLevel bit 1 — triggers Read(AccessLevel)
OwnerOwner()Session&RReference to the associated Session

Indexer​

IndexReturnNote
node[std::string const& browse_name]NodeChild Nodes (Browse BrowseName by)

Public Methods​

MethodsNote
ReadAttribute(attr)Reads the specified attribute and returns DataValue
Write(variant)Write the Value property
WriteAttribute(attr, variant)Write a Specified Attribute
Children(filter = Unspecified)Iterate through child nodes; return std::vector<Reference>
Resolve(path)Click for an in-depth BrowsePath analysis
Call(parent_obj_id, inputs)Call this node as a method (this node must be of type Method)

Examples​

// 1. Get Node (None RPC)
auto temp = s.Nodes()["ns=2;s=Temperature"];

// 2. Read the basic information (1 RPC each)
std::cout << "NodeId = " << temp.NodeId() << "\n";
std::cout << "DisplayName = " << temp.DisplayName() << "\n";
std::cout << "NodeClass = " << static_cast<int>(temp.GetNodeClass()) << "\n";

// 3. Read the value
auto dv = temp.Value();
double t = 0; dv.Value().TryGetDouble(t);
std::cout << "Value = " << t << " degC ft=" << dv.SourceTimestamp() << "\n";

// 4. Write
Variant v; v.SetDouble(25.5);
temp.Write(v);

// 5. Browse Subnodes
for (auto const& child : temp.Children()) {
std::cout << " " << child.browse_name << " -> " << child.node_id << "\n";
}

// 6. Chained Access (Server.ServerStatus.CurrentTime)
auto time = s.Nodes().Server()["ServerStatus"]["CurrentTime"].Value();
std::cout << "Server time ft=" << time.Value().AsFileTime() << "\n";

Important Notes​

  • All methods RPC that are triggered follow a "read-once, return-once" pattern, Do not cache. I want to cache a variable I've stored myself
  • Chain-based access: One access a["b"]["c"] per segment Browse RPC, for a total of N accesses
  • DataValue It is a stack object; when it goes out of scope, it is automatically destroyed and the memory is released.
  • Node It only holds a string NodeId and a pointer Session, but every method must go through the Session to reach the C layer, SDK None Do not make any thread-safety guarantees—if the same resource is shared across threads Session, you Node must lock it yourself.

Comparison with Resolve​

Resolve Corresponds to Side C DarraUa_Session_ResolveBrowsePath — Send once for each path Browse, rather than RPC solving the entire path in a single pass (by Browse traversing the path continuously, without using the service TranslateBrowsePaths ).

// Method A: Linked Indexer - 3 operations RPC (2 operations Browse + 1 read)
auto time = s.Nodes().Server()["ServerStatus"]["CurrentTime"].Value();
// Browse #1 Browse #2 Read #3

// Method B: Path Resolution—5 times RPC (4 path segments = 4 times Browse, plus 1 Read)
auto node = s.Resolve("/Objects/Server/ServerStatus/CurrentTime"); // 4 times Browse
auto time = node.Value(); // 1 view

// Method C: Directly NodeId - 1 time RPC
auto time = s.Read("i=2258");

To RPC solve multiple paths at once, use TranslateBrowsePaths (Batch, Single RPC). Known path → Method C; Exploratory development → Method A.

Next Step​