inductive_client.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(True)
25  #client.connect("opc.tcp://localhost:4841")
26  client.connect("opc.tcp://utgaard:12685/ctt-server")
27  #s.connect("opc.tcp://192.168.56.101:48030")
28  #edps = client.get_server_endpoints()
29  try:
30  root = client.get_root_node()
31  print("I got root: ", root)
32  print("Childs are: ", root.get_children())
33  print("Objects is: ", client.get_objects_node())
34  o = client.get_objects_node()
35  print("Children of objects are: ", o.get_children())
36  myvar = root.get_child(["0:Objects", "2:NewObject", "2:MyVariable"])
37  print("yvar is: ", myvar)
38 
39  sclt = SubHandler()
40  sub = client.create_subscription(100, sclt)
41  handle = sub.subscribe_data_change(myvar)
42  print("Subscribe handle is: ", handle)
43  evhandle = sub.subscribe_events()
44  print("Subscribe handle is: ", evhandle)
45 
46 
47  embed()
48  finally:
49  client.disconnect()
FMT_API void print(std::FILE *f, CStringRef format_str, ArgList args)
Definition: format.cc:873
def data_change(self, handle, node, val, attr)
def event(self, handle, event)


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