Go to the documentation of this file.00001 import sys
00002 sys.path.insert(0, "..")
00003 import time
00004 from IPython import embed
00005
00006
00007 from opcua import ua, Server, instantiate
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 dev = server.nodes.base_object_type.add_object_type(0, "MyDevice")
00022 dev.add_variable(0, "sensor1", 1.0)
00023 dev.add_property(0, "device_id", "0340")
00024 ctrl = dev.add_object(0, "controller")
00025 ctrl.add_property(0, "state", "Idle")
00026
00027
00028 mydevice = instantiate(server.nodes.objects, dev, bname="2:Device0001")
00029
00030 mydevice_var = mydevice.get_child(["0:controller", "0:state"])
00031
00032
00033 server.start()
00034
00035 try:
00036 mydevice_var.set_value("Running")
00037 embed()
00038 finally:
00039
00040 server.stop()