opcua-asyncio
opcua-asyncio copied to clipboard
get_path created BrowsePath finds not match via tranlate_browsepaths
This is a BUG REPORT for issues in the existing code.
Describe the bug
I'm using the get_path(as_string=True) function from the node class.
The function chooses a 'wrong' path so that the translate_browsepaths() function generates the status code "BadNoMatch"
The Prosys Browser can also export a browse path (right click on node) which does find a match via the translate_browsepaths() function.
The node 'exists' in both paths but only the path from prosys works.
To Reproduce
Steps to reproduce the behavior incl code:
import asyncio
from asyncua import Client, ua
from asyncua.ua.status_codes import get_name_and_doc
async def main():
url = "opc.tcp://uademo.prosysopc.com:53530/OPCUA/SimulationServer/"
async with Client(url=url) as client:
# The node these paths should lead to:
# ns=4;s=1001/0:Direction
# Working path: /Objects/3:Simulation/3:Counter/2:Signal/4:Direction
results: ua.BrowsePathResult = await client.translate_browsepaths(
starting_node=client.nodes.root.nodeid,
relative_paths=[
"/Objects/3:Simulation/3:Counter/2:Signal/4:Direction",
"/0:Objects/0:Server/2:ValueSimulations/2:Signal/4:Direction",
],
)
for x in results:
print(get_name_and_doc(x.StatusCode.value), x)
# Output
# ('Good', 'The operation succeeded.') BrowsePathResult(StatusCode_=StatusCode(value=0), Targets= [BrowsePathTarget(TargetId=ExpandedNodeId(Identifier='1001/0:Direction', NamespaceIndex=4, NodeIdType= <NodeIdType.String: 3>, NamespaceUri=None, ServerIndex=0), RemainingPathIndex=4294967295)])
# ('BadNoMatch', 'The requested operation has no match to return.') BrowsePathResult(StatusCode_=StatusCode(value=2154758144), Targets=[])
if __name__ == "__main__":
asyncio.run(main())
The browse path that was exported from Prosys works: /Objects/3:Simulation/3:Counter/2:Signal/4:Direction
Expected behavior
The function get_path(as_string=True) should generate a path that works with the translate_browsepaths() function.
Screenshots
Version
Python-Version:3.11.5
opcua-asyncio Version (e.g. master branch, 0.9):