Go to the documentation of this file.00001 import sys
00002 sys.path.insert(0, "..")
00003 import time
00004 from collections import OrderedDict
00005
00006 from opcua import ua, Server, instantiate
00007 from opcua.common.xmlexporter import XmlExporter
00008
00009
00010 if __name__ == "__main__":
00011
00012
00013 server = Server()
00014 server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
00015
00016
00017 uri = "http://examples.freeopcua.github.io"
00018 idx = server.register_namespace(uri)
00019
00020
00021 objects = server.get_objects_node()
00022
00023
00024 myobj = objects.add_object(idx, "MyObject")
00025 myvar = myobj.add_variable(idx, "MyVariable", 6.7)
00026 myvar.set_writable()
00027
00028 dev = server.nodes.base_object_type.add_object_type(0, "MyDevice")
00029 dev.add_variable(0, "sensor1", 1.0)
00030
00031 mydevice = instantiate(server.nodes.objects, dev, bname="2:Device0001")
00032
00033 node_list = [dev, mydevice, myobj, myvar]
00034
00035
00036 server.start()
00037
00038 exporter = XmlExporter(server)
00039 exporter.build_etree(node_list, ['http://myua.org/test/'])
00040 exporter.write_xml('ua-export.xml')
00041
00042 server.stop()