Search code examples
python-3.xopc-ua

read multiple values from OPC UA with opcua-asyncio


I'm looking for a way to read the values from multiple nodes at once instead of using a loop.

I created a list with the node objects from a CSV file.

for index, row in force_list.iterrows():
            tag = client.get_node(row['Address'])
            forces.append(tag)

This list I use in a loop to retrieve the values together with the timestamp and the node name.

 for i in self.forces:
       self.force_values.append((ts, str(i).split(".", 3)[-1], await i.read_value()))

This works but is slow because of the multiple requests to the server. Is there a way to read multiple values with one request with opcua-asyncio in python?


Solution

  • You can use read_values from client to read all values in one network request.

    Example:

    vals = await client.read_values(self.forces)