2 sys.path.insert(0,
"..")
4 from collections
import OrderedDict
6 from opcua
import ua, Server, instantiate
10 if __name__ ==
"__main__":
14 server.set_endpoint(
"opc.tcp://0.0.0.0:4840/freeopcua/server/")
17 uri =
"http://examples.freeopcua.github.io" 18 idx = server.register_namespace(uri)
21 objects = server.get_objects_node()
24 myobj = objects.add_object(idx,
"MyObject")
25 myvar = myobj.add_variable(idx,
"MyVariable", 6.7)
28 dev = server.nodes.base_object_type.add_object_type(0,
"MyDevice")
29 dev.add_variable(0,
"sensor1", 1.0)
31 mydevice =
instantiate(server.nodes.objects, dev, bname=
"2:Device0001")
33 node_list = [dev, mydevice, myobj, myvar]
39 exporter.build_etree(node_list, [
'http://myua.org/test/'])
40 exporter.write_xml(
'ua-export.xml')
def instantiate(parent, node_type, nodeid=None, bname=None, idx=0)