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
00012 server = Server()
00013 server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
00014
00015
00016 uri = "http://examples.freeopcua.github.io"
00017 idx = server.register_namespace(uri)
00018
00019
00020 objects = server.get_objects_node()
00021
00022
00023 myobj = objects.add_object(idx, "MyObject")
00024 myvar = myobj.add_variable(idx, "MyVariable", 6.7)
00025 myvar.set_writable()
00026
00027
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
00038 server.stop()