Go to the documentation of this file.00001 import sys
00002 sys.path.insert(0, "..")
00003 import time
00004 import math
00005
00006
00007 from opcua import ua, Server
00008 from opcua.server.history_sql import HistorySQLite
00009
00010
00011 if __name__ == "__main__":
00012
00013
00014 server = Server()
00015 server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
00016
00017
00018 uri = "http://examples.freeopcua.github.io"
00019 idx = server.register_namespace(uri)
00020
00021
00022 objects = server.get_objects_node()
00023
00024
00025 myobj = objects.add_object(idx, "MyObject")
00026 myvar = myobj.add_variable(idx, "MyVariable", ua.Variant(0, ua.VariantType.Double))
00027 myvar.set_writable()
00028
00029
00030 server.iserver.history_manager.set_storage(HistorySQLite("my_datavalue_history.sql"))
00031
00032
00033 server.start()
00034
00035
00036 server.historize_node_data_change(myvar, period=None, count=100)
00037
00038 try:
00039 count = 0
00040 while True:
00041 time.sleep(1)
00042 count += 0.1
00043 myvar.set_value(math.sin(count))
00044
00045 finally:
00046
00047 server.stop()