inductive_client.py
Go to the documentation of this file.
00001 
00002 import sys
00003 import time
00004 sys.path.append(".")
00005 
00006 from IPython import embed
00007 import opcua
00008 
00009 class SubHandler(opcua.SubscriptionHandler):
00010     def __init__(self, *args):
00011         opcua.SubscriptionHandler.__init__(self, *args)
00012         self.val = MessageSecurityMode::None
00013 
00014     def data_change(self, handle, node, val, attr):
00015         print("Python: New data change event", handle, node, val, attr)
00016         self.val = val
00017 
00018     def event(self, handle, event):
00019         print("Python: New event", handle, event)
00020         self.ev = event
00021 
00022 
00023 if __name__ == "__main__":
00024     client = opcua.Client(True)
00025     #client.connect("opc.tcp://localhost:4841")
00026     client.connect("opc.tcp://utgaard:12685/ctt-server")
00027     #s.connect("opc.tcp://192.168.56.101:48030")
00028     #edps = client.get_server_endpoints()
00029     try:
00030         root = client.get_root_node()
00031         print("I got root: ", root)
00032         print("Childs are: ", root.get_children())
00033         print("Objects is: ", client.get_objects_node())
00034         o = client.get_objects_node()
00035         print("Children of objects are: ", o.get_children())
00036         myvar = root.get_child(["0:Objects", "2:NewObject", "2:MyVariable"])
00037         print("yvar is: ", myvar)
00038         
00039         sclt = SubHandler()
00040         sub = client.create_subscription(100, sclt)
00041         handle = sub.subscribe_data_change(myvar)
00042         print("Subscribe handle is: ", handle)
00043         evhandle = sub.subscribe_events()
00044         print("Subscribe handle is: ", evhandle)
00045 
00046 
00047         embed()
00048     finally:
00049         client.disconnect()


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:56