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.
- 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
| Format | Meaning |
|---|---|
| BrowseName | ns=0 Default |
| ns:BrowseName | Specify NamespaceIndex |
| /seg1/seg2/seg3 | Multiple segments, separated by / |
Example:
| BrowsePath | Meaning |
|---|---|
| /Server | ns=0 Child node Server |
| /2:Boiler1 | ns=2 Child node Boiler1 |
| /Server/2:Boilers/2:Boiler1/2:Temperature | Multi-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 withatoiinto 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
| API | RPC Number of times | Applicable |
|---|---|---|
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 segment | Exploratory |
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。