Skip to main content

translate_browse_paths

translate_browse_paths The service parses the "BrowsePath string" in batches NodeIdin a single pass RPC; a loop, on resolve the other hand, processes each tag one at a time RPC.

Prerequisite Reading
  • For chained exploration, we recommend using OpcUaNode Indexer.
  • This is a must-have for batch initializing 100+ paths API.

Signature​

def translate_browse_paths(
self,
paths: List[Tuple[str, str]]) -> List[TranslateResult]: ...

Each input parameter is a (starting_node_id, browse_path) tuple.

TranslateResult field​

@dataclass
class TranslateResult:
node_id: Optional[str] = None # None when parsing fails
status: StatusCode = StatusCode.Bad

Usage​

from darra_opcua import StatusCode

paths = [
("i=85", "/Server/ServerStatus/CurrentTime"),
("i=85", "/Server/ServerStatus/State"),
("ns=2;s=Boiler1", "/Temperature"),
("ns=2;s=Boiler1", "/Pressure"),
]

results = ua.translate_browse_paths(paths)
for r in results:
if r.status == StatusCode.Good:
print(f"OK: {r.node_id}")
else:
print(f"Fail: {r.status.name}")

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

Line-by-Line Analysis: resolve​

def resolve(self, path: str, start_node_id: Optional[str] = None) -> Optional[OpcUaNode]: ...
node = ua.resolve("/Objects/Server/ServerStatus/CurrentTime")
if node is None:
print("not found")

resolve The route isSingle item ResolveBrowsePath: Performs low-level segment-by-segment browse parsing; it processes each segment of the path individually Browse RPC, and returns an error if any segment cannot be found None. For large numbers of paths, please use the batch option directly ( translate_browse_paths which parses the entire RPC path in one go).

Comparison with "resolve"​

APIRPC Number of timesApplicable
resolve(path)Number of path segments (once per segment Browse)Occasional use, single path
translate_browse_paths(paths)1Batch Processing of Multiple Paths
Chain Indexer node["a"]["b"]["c"]N (once per segment browse)Exploratory

100 paths (3 segments each) using translate_browse_paths is 1 time RPC, Loop resolve To 300 times Browse RPC — It saves on the number of round trips, not a fixed number indicating "how many times faster" it is.

Next Step​