prosysclient.py
Go to the documentation of this file.
1 
2 import sys
3 import time
4 sys.path.append(".")
5 
6 from IPython import embed
7 import opcua
8 
9 class SubHandler(opcua.SubscriptionHandler):
10  def __init__(self, *args):
11  opcua.SubscriptionHandler.__init__(self, *args)
12  self.val = MessageSecurityMode::None
13 
14  def data_change(self, handle, node, val, attr):
15  print("Python: New data change event", handle, node, val, attr)
16  self.val = val
17 
18  def event(self, handle, event):
19  print("Python: New event", handle, event)
20  self.ev = event
21 
22 
23 if __name__ == "__main__":
24  client = opcua.Client(False)
25  client.connect("opc.tcp://localhost:53530/OPCUA/SimulationServer/")
26  try:
27  root = client.get_root_node()
28  print("I got root: ", root)
29  print("Childs are: ", root.get_children())
30  print("Objects is: ", client.get_objects_node())
31  o = client.get_objects_node()
32  print("Children of objects are: ", o.get_children())
33 
34  myvar = root.get_child(["0:Objects", "5:Simulation", "5:Random1"])
35  print("yvar is: ", myvar)
36  myfloat = client.get_node("ns=4;s=Float")
37  mydouble = client.get_node("ns=4;s=Double")
38  myint64 = client.get_node("ns=4;s=Int64")
39  myuint64 = client.get_node("ns=4;s=UInt64")
40  myint32 = client.get_node("ns=4;s=Int32")
41  myuint32 = client.get_node("ns=4;s=UInt32")
42 
43  sclt = SubHandler()
44  sub = client.create_subscription(100, sclt)
45  handle = sub.subscribe_data_change(myvar)
46  print("Subscribe handle is: ", handle)
47 
48 
49  embed()
50  finally:
51  client.disconnect()
FMT_API void print(std::FILE *f, CStringRef format_str, ArgList args)
Definition: format.cc:873
def event(self, handle, event)
Definition: prosysclient.py:18
def __init__(self, args)
Definition: prosysclient.py:10
def data_change(self, handle, node, val, attr)
Definition: prosysclient.py:14


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:07