6 from IPython
import embed
11 Client to subcsription. It will receive events from server 14 opcua.SubscriptionHandler.__init__(self, *args)
15 self.
ev = MessageSecurityMode::
None 18 print(
"Python: New data change event", handle, node, val, attr)
21 print(
"Python: New event", handle, event)
25 if __name__ ==
"__main__":
27 client = opcua.Client(
False)
28 client.connect(
"opc.tcp://localhost:4841/freeopcua/server/")
33 uri =
"http://examples.freeopcua.github.io" 34 idx = client.get_namespace_index(uri)
37 statenode = client.get_node(opcua.ObjectId.Server_ServerStatus_State)
38 print(
"Server state is: ", statenode.get_value())
41 root = client.get_root_node()
42 print(
"I got root: ", root)
43 print(
"Childs are: ", root.get_children())
47 print(
"Objects is: ", client.get_objects_node())
48 objects = client.get_objects_node()
49 print(
"Children of objects are: ", objects.get_children())
52 myvar = objects.get_child([
"{}:NewObject".
format(idx),
"MyVariable"])
53 print(
"yvar is: ", myvar)
57 sub = client.create_subscription(100, sclt)
64 evhandle = sub.subscribe_events()
65 print(
"Subscribe handle is: ", evhandle)
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)
def event(self, handle, event)