MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / __init__

Method __init__

examples/server-ua-python-mirror.py:42–59  ·  view source on GitHub ↗
(self, opcua_server, ua_node)

Source from the content-addressed store, hash-verified

40 Python can write to children via write method, which will trigger an update for UA clients
41 """
42 def __init__(self, opcua_server, ua_node):
43 self.opcua_server = opcua_server
44 self.nodes = {}
45 self.b_name = ua_node.get_browse_name().Name
46
47 # keep track of the children of this object (in case python needs to write, or get more info from UA server)
48 for _child in ua_node.get_children():
49 _child_name = _child.get_browse_name()
50 self.nodes[_child_name.Name] = _child
51
52 # find all children which can be subscribed to (python object is kept up to date via subscription)
53 sub_children = ua_node.get_properties()
54 sub_children.extend(ua_node.get_variables())
55
56 # subscribe to properties/variables
57 handler = SubHandler(self)
58 sub = opcua_server.create_subscription(500, handler)
59 handle = sub.subscribe_data_change(sub_children)
60
61 def write(self, attr=None):
62 # if a specific attr isn't passed to write, write all OPC UA children

Callers

nothing calls this directly

Calls 7

get_browse_nameMethod · 0.80
get_childrenMethod · 0.80
get_propertiesMethod · 0.80
get_variablesMethod · 0.80
subscribe_data_changeMethod · 0.80
SubHandlerClass · 0.70
create_subscriptionMethod · 0.45

Tested by

no test coverage detected