Commit 09eb9dc7 authored by Pete Bachant's avatar Pete Bachant Committed by oroulet

Add 'depth' parameter to read_values

parent 4c6cc262
......@@ -865,13 +865,24 @@ class Client:
node.nodeid = node.basenodeid
node.basenodeid = None
async def read_values(self, nodes):
async def read_values(self, nodes, depth=2):
"""
Read the value of multiple nodes in one ua call.
The 'depth' parameter defines how deep in the 'Value' attributes we
should extract
"""
if 0 > depth > 2:
raise ValueError("'depth' must be between 0 and 2")
nodeids = [node.nodeid for node in nodes]
results = await self.uaclient.read_attributes(nodeids, ua.AttributeIds.Value)
return [result.Value.Value for result in results]
vals = []
for r in results:
v = r
for _ in range(depth):
v = v.Value
vals.append(v)
return vals
async def write_values(self, nodes, values):
"""
......
......@@ -152,7 +152,7 @@ class _SubHandler:
def event_notification(self, event):
self.sync_handler.event_notification(event)
def status_change_notification(self, status: ua.StatusChangeNotification):
self.sync_handler.status_change_notification(status)
......@@ -253,7 +253,7 @@ class Client:
pass
@syncmethod
def read_values(self, nodes):
def read_values(self, nodes, depth=2):
pass
@syncmethod
......@@ -704,7 +704,7 @@ def new_enum( # type: ignore[empty-body]
name: Union[int, ua.QualifiedName],
values: List[str],
optional: bool = False
) -> SyncNode:
) -> SyncNode:
pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment