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
00012 server = Server()
00013 server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
00014
00015
00016
00017 server.load_certificate("certificate-example.der")
00018 server.load_private_key("private-key-example.pem")
00019
00020
00021 uri = "http://examples.freeopcua.github.io"
00022 idx = server.register_namespace(uri)
00023
00024
00025 objects = server.get_objects_node()
00026
00027
00028 myobj = objects.add_object(idx, "MyObject")
00029 myvar = myobj.add_variable(idx, "MyVariable", 6.7)
00030 myvar.set_writable()
00031
00032
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
00042 server.stop()