python-opcua icon indicating copy to clipboard operation
python-opcua copied to clipboard

Read group or multiple variables

Open h1n0t0r1 opened this issue 5 years ago • 3 comments

How to read group of variables or multiple variables at once ? In OPC DA we have groups.

h1n0t0r1 avatar Mar 19 '20 17:03 h1n0t0r1

Every OPC UA Variable can be an array! Its the most efficient way to read large amounts of data. you could combine custom data types with arrays.

AndreasHeine avatar Apr 21 '20 11:04 AndreasHeine

from opcua import ua, uamethod, Server

server = Server() server.set_endpoint("opc.tcp://127.0.0.1:4840") server.set_server_name("test") address_space = server.register_namespace("asdf") server.set_application_uri("urn:test")

root_node = server.get_root_node() object_node = server.get_objects_node() server_node = server.get_server_node()

parameter_obj = object_node.add_object(address_space, "Parameter")

array = [0,0,0,0]

test_node = parameter_obj.add_variable(address_space, "test", ua.Variant(array, ua.VariantType.UInt64))

server.start()

AndreasHeine avatar Apr 21 '20 11:04 AndreasHeine

you can use client.get_values([node1,node2,...]) and this will return a list of values

Brandon-lz avatar Mar 28 '23 03:03 Brandon-lz