6 from IPython
import embed
11 print(
"New data change event", handle, node, val, attr)
14 print(
"Python: New event", handle, event)
17 if __name__ ==
"__main__":
19 server = opcua.Server(
True)
20 server.set_endpoint(
"opc.tcp://localhost:4841/freeopcua/server/")
21 server.set_server_name(
"FreeOpcUa Example Server")
28 uri =
"http://examples.freeopcua.github.io" 29 idx = server.register_namespace(uri)
32 objects = server.get_objects_node()
33 print(
"I got objects folder: ", objects)
36 myobject = objects.add_object(idx,
"NewObject")
37 myvar = myobject.add_variable(idx,
"MyVariable", [16, 56])
38 myprop = myobject.add_property(idx,
"myprop", 9.9)
39 myfolder = myobject.add_folder(idx,
"myfolder")
50 ev.message =
"This is event nr: " + str(counter)
51 ev.source_node = objects.get_id()
52 ev.time = datetime.datetime.now()
53 print(
"Sending event: ", ev)
54 server.trigger_event(ev)
55 myvar.set_value([counter, counter+10])
def data_change(self, handle, node, val, attr)
FMT_API void print(std::FILE *f, CStringRef format_str, ArgList args)
def event(self, handle, event)