Esempio n. 1
0
 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)
Esempio n. 2
0
 def _make_relative_path(self, 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)
     return rpath