server-with-encryption.py
Go to the documentation of this file.
00001 import sys
00002 import time
00003 
00004 sys.path.insert(0, "..")
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     # load server certificate and private key. This enables endpoints
00016     # with signing and encryption.
00017     server.load_certificate("certificate-example.der")
00018     server.load_private_key("private-key-example.pem")
00019 
00020     # setup our own namespace, not really necessary but should as spec
00021     uri = "http://examples.freeopcua.github.io"
00022     idx = server.register_namespace(uri)
00023 
00024     # get Objects node, this is where we should put our custom stuff
00025     objects = server.get_objects_node()
00026 
00027     # populating our address space
00028     myobj = objects.add_object(idx, "MyObject")
00029     myvar = myobj.add_variable(idx, "MyVariable", 6.7)
00030     myvar.set_writable()    # Set MyVariable to be writable by clients
00031 
00032     # starting!
00033     server.start()
00034     try:
00035         count = 0
00036         while True:
00037             time.sleep(1)
00038             count += 0.1
00039             myvar.set_value(count)
00040     finally:
00041         #close connection, remove subcsriptions, etc
00042         server.stop()


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