Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
776c55e3
Commit
776c55e3
authored
Aug 23, 2023
by
Yuta Okamoto
Committed by
oroulet
Aug 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add translate_browsepaths() to Client
parent
8ce692c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
asyncua/client/client.py
asyncua/client/client.py
+14
-0
asyncua/sync.py
asyncua/sync.py
+4
-0
tests/test_client.py
tests/test_client.py
+24
-0
No files found.
asyncua/client/client.py
View file @
776c55e3
...
...
@@ -911,3 +911,17 @@ class Client:
parameters
.
NodesToBrowse
=
nodestobrowse
results
=
await
self
.
uaclient
.
browse
(
parameters
)
return
list
(
zip
(
nodes
,
results
))
async
def
translate_browsepaths
(
self
,
starting_node
:
ua
.
NodeId
,
relative_paths
:
List
[
Union
[
ua
.
RelativePath
,
str
]])
->
List
[
ua
.
BrowsePathResult
]:
bpaths
=
[]
for
p
in
relative_paths
:
try
:
rpath
=
ua
.
RelativePath
.
from_string
(
p
)
if
isinstance
(
p
,
str
)
else
p
except
ValueError
as
e
:
raise
ua
.
UaStringParsingError
(
f"Failed to parse one of RelativePath:
{
p
}
"
)
from
e
bpath
=
ua
.
BrowsePath
()
bpath
.
StartingNode
=
starting_node
bpath
.
RelativePath
=
rpath
bpaths
.
append
(
bpath
)
return
await
self
.
uaclient
.
translate_browsepaths_to_nodeids
(
bpaths
)
asyncua/sync.py
View file @
776c55e3
...
...
@@ -315,6 +315,10 @@ class Client:
def
write_values
(
self
,
nodes
,
values
,
raise_on_partial_error
=
True
):
pass
@
syncmethod
def
translate_browsepaths
(
self
,
starting_node
:
ua
.
NodeId
,
relative_paths
:
List
[
Union
[
ua
.
RelativePath
,
str
]])
->
List
[
ua
.
BrowsePathResult
]:
pass
def
__enter__
(
self
):
try
:
self
.
connect
()
...
...
tests/test_client.py
View file @
776c55e3
...
...
@@ -158,3 +158,27 @@ async def test_browse_nodes(server, client):
assert
isinstance
(
results
[
1
][
0
],
Node
)
assert
isinstance
(
results
[
0
][
1
],
ua
.
BrowseResult
)
assert
isinstance
(
results
[
1
][
1
],
ua
.
BrowseResult
)
async
def
test_translate_browsepaths
(
server
,
client
:
Client
):
server_node
=
await
client
.
nodes
.
objects
.
get_child
(
"Server"
)
relative_paths
=
[
"/0:ServiceLevel"
,
"/0:ServerStatus/0:State"
]
results
=
await
client
.
translate_browsepaths
(
server_node
.
nodeid
,
relative_paths
)
assert
len
(
results
)
==
2
assert
isinstance
(
results
,
list
)
assert
results
[
0
].
StatusCode
.
value
==
ua
.
StatusCodes
.
Good
assert
results
[
0
].
Targets
[
0
].
TargetId
==
ua
.
NodeId
.
from_string
(
"ns=0;i=2267"
)
assert
results
[
1
].
StatusCode
.
value
==
ua
.
StatusCodes
.
Good
assert
results
[
1
].
Targets
[
0
].
TargetId
==
ua
.
NodeId
.
from_string
(
"ns=0;i=2259"
)
for
result
in
results
:
assert
isinstance
(
result
,
ua
.
BrowsePathResult
)
results2
=
await
client
.
translate_browsepaths
(
server_node
.
nodeid
,
[
"/0:UnknownPath"
])
assert
len
(
results2
)
==
1
assert
isinstance
(
results2
,
list
)
assert
results2
[
0
].
StatusCode
.
value
==
ua
.
StatusCodes
.
BadNoMatch
assert
len
(
results2
[
0
].
Targets
)
==
0
with
pytest
.
raises
(
ua
.
UaStringParsingError
):
await
client
.
translate_browsepaths
(
server_node
.
nodeid
,
[
"/1:<Boiler"
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment