(self, opcua_server, ua_node)
| 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 |
nothing calls this directly
no test coverage detected