client_minimal.py
Go to the documentation of this file.
1 from opcua import Client, ua
2 from opcua.ua import ua_binary as uabin
3 from opcua.common.methods import call_method
4 
5 
6 class HelloClient:
7  def __init__(self, endpoint):
8  self.client = Client(endpoint)
9 
10  def __enter__(self):
11  self.client.connect()
12  return self.client
13 
14  def __exit__(self, exc_type, exc_val, exc_tb):
15  self.client.disconnect()
16 
17 
18 if __name__ == '__main__':
19  with HelloClient("opc.tcp://localhost:40840/freeopcua/server/") as client:
20  root = client.get_root_node()
21  print("Root node is: ", root)
22  objects = client.get_objects_node()
23  print("Objects node is: ", objects)
24 
25  hellower = objects.get_child("0:Hellower")
26  print("Hellower is: ", hellower)
27 
28  resulting_text = hellower.call_method("0:SayHello", False)
29  print(resulting_text)
30 
31  resulting_text = hellower.call_method("1:SayHello2", True)
32  print(resulting_text)
33 
34  resulting_array = hellower.call_method("1:SayHelloArray", False)
35  print(resulting_array)
def __exit__(self, exc_type, exc_val, exc_tb)
def __init__(self, endpoint)


ros_opcua_impl_python_opcua
Author(s): Denis Štogl , Daniel Draper
autogenerated on Tue Jan 19 2021 03:12:43