2 sys.path.insert(0,
"..")
4 from IPython
import embed
7 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 dev = server.nodes.base_object_type.add_object_type(0,
"MyDevice")
22 dev.add_variable(0,
"sensor1", 1.0)
23 dev.add_property(0,
"device_id",
"0340")
24 ctrl = dev.add_object(0,
"controller")
25 ctrl.add_property(0,
"state",
"Idle")
28 mydevice =
instantiate(server.nodes.objects, dev, bname=
"2:Device0001")
30 mydevice_var = mydevice.get_child([
"0:controller",
"0:state"])
36 mydevice_var.set_value(
"Running")
def instantiate(parent, node_type, nodeid=None, bname=None, idx=0)