6 from IPython
import embed
11 Client to subcsription. It will receive events from server 14 opcua.SubscriptionHandler.__init__(self, *args)
17 print(
"Python: New data change event", handle, node, val, attr)
20 print(
"Python: New event", handle, event)
23 if __name__ ==
"__main__":
25 client = opcua.Client(
False)
26 client.connect(
"opc.tcp://localhost:4841/freeopcua/server/")
31 uri =
"http://examples.freeopcua.github.io" 32 idx = client.get_namespace_index(uri)
35 statenode = client.get_node(opcua.ObjectId.Server_ServerStatus_State)
36 print(
"Server state is: ", statenode.get_value())
39 root = client.get_root_node()
40 print(
"I got root: ", root)
41 print(
"Childs are: ", root.get_children())
45 print(
"Objects is: ", client.get_objects_node())
46 objects = client.get_objects_node()
47 print(
"Children of objects are: ", objects.get_children())
50 myvar = objects.get_child([
"{}:NewObject".
format(idx),
"MyVariable"])
51 print(
"yvar is: ", myvar)
55 sub = client.create_subscription(100, sclt)
58 handle = sub.subscribe_data_change(myvar)
59 print(
"Subscribe handle is: ", handle)
62 evhandle = sub.subscribe_events()
63 print(
"Subscribe handle is: ", evhandle)
def event(self, handle, event)
FMT_API void print(std::FILE *f, CStringRef format_str, ArgList args)
std::string format(CStringRef format_str, ArgList args)
def data_change(self, handle, node, val, attr)