def get_child(self, path): """ get a child specified by its path from this node. A path might be: * a string representing a qualified name. * a qualified name * a list of string * a list of qualified names """ if type(path) not in (list, tuple): path = [path] rpath = ua.RelativePath() for item in path: el = ua.RelativePathElement() el.ReferenceTypeId = ua.TwoByteNodeId( ua.ObjectIds.HierarchicalReferences) el.IsInverse = False el.IncludeSubtypes = True if isinstance(item, ua.QualifiedName): el.TargetName = item else: el.TargetName = ua.QualifiedName.from_string(item) rpath.Elements.append(el) bpath = ua.BrowsePath() bpath.StartingNode = self.nodeid bpath.RelativePath = rpath result = self.server.translate_browsepaths_to_nodeids([bpath]) result = result[0] result.StatusCode.check() # FIXME: seems this method may return several nodes return Node(self.server, result.Targets[0].TargetId)
def get_children_descriptions(self, refs=ua.ObjectIds.HierarchicalReferences, nodeclassmask=ua.NodeClass.Unspecified, includesubtypes=True): desc = ua.BrowseDescription() desc.BrowseDirection = ua.BrowseDirection.Forward desc.ReferenceTypeId = ua.TwoByteNodeId(refs) desc.IncludeSubtypes = includesubtypes desc.NodeClassMask = nodeclassmask desc.ResultMask = ua.BrowseResultMask.All desc.NodeId = self.nodeid params = ua.BrowseParameters() params.NodesToBrowse.append(desc) results = self.server.browse(params) return results[0].References
def get_objects_node(self): return self.get_node(ua.TwoByteNodeId(ua.ObjectIds.ObjectsFolder))
def get_server_node(self): return self.get_node(ua.TwoByteNodeId(ua.ObjectIds.Server))
def get_root_node(self): return self.get_node(ua.TwoByteNodeId(ua.ObjectIds.RootFolder))