Skip to main content

TranslateBrowsePaths

TranslateBrowsePathsToNodeIds Service Hub (Start NodeId, Relative Path) Batch parse into NodeId, all pathsPer instance RPC Send them all at once. This results in far Resolve fewer network round trips than sending them one by one.

Prerequisite Reading
  • For chained exploration, we recommend using Node Indexer.
  • When there are many paths API, use this method for batch parsing—it can reduce N round trips to just 1.

Signature​

TranslateBrowsePaths Session It is a member method.

namespace darra::opcua {

class Session {
public:
std::vector<TranslateResult> TranslateBrowsePaths(
std::vector<std::pair<std::string, std::string>> const& paths);
};

}

Each item (starting_node_id, browse_path).

TranslateResult Structure​

struct TranslateResult {
std::string node_id; // Empty when parsing fails
Status status = Status::Bad;
};

Usage​

#include <darra/opcua/client.hpp>
#include <iostream>

using namespace darra::opcua;

Session s("opc.tcp://localhost:4840");
s.Connect();

std::vector<std::pair<std::string, std::string>> paths = {
{ "i=85" /* Objects */, "/Server/ServerStatus/CurrentTime" },
{ "i=85", "/Server/ServerStatus/State" },
{ "ns=2;s=Boiler1", "/Temperature" },
{ "ns=2;s=Boiler1", "/Pressure" },
};

auto results = s.TranslateBrowsePaths(paths);
for (auto const& r : results) {
if (r.status == Status::Good) {
std::cout << "OK: " << r.node_id << "\n";
} else {
std::cout << "Fail: 0x" << std::hex << static_cast<uint32_t>(r.status) << "\n";
}
}

BrowsePath Segment Format​

FormatMeaning
BrowseNamens=0 Default
ns:BrowseNameSpecify NamespaceIndex
/seg1/seg2/seg3Multiple segments, separated by /

Example:

BrowsePathMeaning
/Serverns=0 Child node Server
/2:Boiler1ns=2 Child node Boiler1
/Server/2:Boilers/2:Boiler1/2:TemperatureMulti-layer Combination
  • The leading part is optional /; the continuous part / will be skipped; an empty segment does not count as a segment.
  • The ns: part is parsed with atoi into NamespaceIndex; non-numeric values are treated as ns=0.
  • The fixed citation requirements for each section are as follows: HierarchicalReferences (i=33) + IsInverse=false + IncludeSubtypes=true — Follow the reference chain downward only; the reference type SDK cannot be specified by the caller.

Comparison with Resolve​

APIRPC Number of timesApplicable
s.Resolve(path)1 Browse per segment (3 segments = 3 round trips)Occasional use, single path
s.TranslateBrowsePaths(paths[])1 time (N paths are distributed simultaneously)Batch Processing of Multiple Paths
Chain Indexer node["a"]["b"]["c"]1 Browse per segmentExploratory
Resolve: Not going TranslateBrowsePaths

s.Resolve / Node::Resolve isClimb Browse along the path, section by section (A BrowseRequest is sent once per segment to find matching BrowseName child nodes), and the service TranslateBrowsePathsToNodeIds is not called. Therefore, the number of round trips is proportional to the number of path segments, not "1 time. RPC" For batch initialization, please use directly TranslateBrowsePaths.

When parsing multiple paths simultaneously, TranslateBrowsePaths reduce the number of round trips from "number of segments × number of paths" to 1。

Next Step​