def _translate_browsepath_to_nodeid( self, path: ua.BrowsePath) -> ua.BrowsePathResult: # self.logger.debug("looking at path: %s", path) res = ua.BrowsePathResult() if not path.RelativePath.Elements[-1].TargetName: # OPC UA Part 4: Services, 5.8.4 TranslateBrowsePathsToNodeIds # it's unclear if this the check should also handle empty strings res.StatusCode = ua.StatusCode(ua.StatusCodes.BadBrowseNameInvalid) return res if path.StartingNode not in self._aspace: res.StatusCode = ua.StatusCode(ua.StatusCodes.BadNodeIdInvalid) return res target_nodeids = self._navigate(path.StartingNode, path.RelativePath.Elements) if not target_nodeids: res.StatusCode = ua.StatusCode(ua.StatusCodes.BadNoMatch) return res for nodeid in target_nodeids: target = ua.BrowsePathTarget() target.TargetId = nodeid # FIXME <<<< Type conflict target.RemainingPathIndex = ua.Index( 4294967295) # FIXME: magic number, why not Index.MAX? res.Targets.append(target) # FIXME: might need to order these one way or another return res
def _translate_browsepath_to_nodeid(self, path): #self.logger.debug("looking at path: %s", path) res = ua.BrowsePathResult() if path.StartingNode not in self._aspace: res.StatusCode = ua.StatusCode(ua.StatusCodes.BadNodeIdInvalid) return res current = path.StartingNode for el in path.RelativePath.Elements: nodeid = self._find_element_in_node(el, current) if not nodeid: res.StatusCode = ua.StatusCode(ua.StatusCodes.BadNoMatch) return res current = nodeid target = ua.BrowsePathTarget() target.TargetId = current target.RemainingPathIndex = 4294967295 res.Targets = [target] return res
def _translate_browsepath_to_nodeid(self, path): #self.logger.debug("looking at path: %s", path) res = ua.BrowsePathResult() if not path.RelativePath.Elements[-1].TargetName: # OPC UA Part 4: Services, 5.8.4 TranslateBrowsePathsToNodeIds # it's unclear if this the check should also handle empty strings res.StatusCode = ua.StatusCode(ua.StatusCodes.BadBrowseNameInvalid) return res if path.StartingNode not in self._aspace: res.StatusCode = ua.StatusCode(ua.StatusCodes.BadNodeIdInvalid) return res current = path.StartingNode for el in path.RelativePath.Elements: nodeid = self._find_element_in_node(el, current) if not nodeid: res.StatusCode = ua.StatusCode(ua.StatusCodes.BadNoMatch) return res current = nodeid target = ua.BrowsePathTarget() target.TargetId = current target.RemainingPathIndex = 4294967295 res.Targets = [target] return res