server-minimal.py
Go to the documentation of this file.
00001 import sys
00002 sys.path.insert(0, "..")
00003 import time
00004 
00005 
00006 from opcua import ua, Server
00007 
00008 
00009 if __name__ == "__main__":
00010 
00011     # setup our server
00012     server = Server()
00013     server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
00014 
00015     # setup our own namespace, not really necessary but should as spec
00016     uri = "http://examples.freeopcua.github.io"
00017     idx = server.register_namespace(uri)
00018 
00019     # get Objects node, this is where we should put our nodes
00020     objects = server.get_objects_node()
00021 
00022     # populating our address space
00023     myobj = objects.add_object(idx, "MyObject")
00024     myvar = myobj.add_variable(idx, "MyVariable", 6.7)
00025     myvar.set_writable()    # Set MyVariable to be writable by clients
00026 
00027     # starting!
00028     server.start()
00029     
00030     try:
00031         count = 0
00032         while True:
00033             time.sleep(1)
00034             count += 0.1
00035             myvar.set_value(count)
00036     finally:
00037         #close connection, remove subcsriptions, etc
00038         server.stop()


ros_opcua_impl_python_opcua
Author(s): Denis Štogl , Daniel Draper
autogenerated on Sat Jun 8 2019 18:26:23