-2

In the plc database i have a database named "status" which has a variable named "Temperature". Since I know the names, I access the value of this variable like this:

from opcua import Client
client = Client("url")
client.connect()
temperature = client.get_node("ns=3;s=\"status\".\"Temperature\"").get_value()

Now how can I get this information without knowledge of database or variable name? I want a general code that takes everything from a given PLC url.

Qendrim Krasniqi
  • 162
  • 1
  • 10
  • This doesn't make sense. Do you want to read the data registers? – roganjosh Sep 03 '18 at 13:09
  • In the plc database i have a database named "status" which has a variable named "Temperature". Since I know the names, I access the value of this variable like this: temperature= client.get_node("ns=3;s=\"Temperature\"").get_value() Now how can I get this information without knowledge of database or variable name? – Qendrim Krasniqi Sep 03 '18 at 13:11
  • I think you're better updating your original question with that as an edit. I only know how to read registers for PLCs, not a database. – roganjosh Sep 03 '18 at 13:13
  • I very well may be wrong with the edit I just did. Please revert it if I tagged wrongly, and it's on my head, not the OP's – roganjosh Sep 03 '18 at 13:18

2 Answers2

0

You're looking for the Browse service.

Check the documentation or examples for whichever toolkit you're using.

Kevin Herron
  • 6,500
  • 3
  • 26
  • 35
0

Found the answer:

from opcua import Client
client = Client("url")
client.connect()
node = client.get_objects_node()
def walk(node):
    a = node.get_children()
    for child in a:
        if child.get_children():
            walk(child)
        else:
            try:
                print(type(child.get_browse_name()), child.get_value())
            except:
                pass
Qendrim Krasniqi
  • 162
  • 1
  • 10