Search in sources :

Example 1 with ReferenceDescription

use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription in project milo by eclipse.

the class DataTypeDictionaryReader method browseNode.

private CompletableFuture<List<ReferenceDescription>> browseNode(BrowseDescription browseDescription) {
    RequestHeader requestHeader = stackClient.newRequestHeader(session.getAuthenticationToken(), stackClient.getConfig().getRequestTimeout());
    BrowseRequest browseRequest = new BrowseRequest(requestHeader, new ViewDescription(NodeId.NULL_VALUE, DateTime.MIN_VALUE, uint(0)), uint(0), new BrowseDescription[] { browseDescription });
    return stackClient.sendRequest(browseRequest).thenApply(BrowseResponse.class::cast).thenApply(r -> Objects.requireNonNull(r.getResults())[0]).thenCompose(result -> {
        List<ReferenceDescription> references = Collections.synchronizedList(new ArrayList<>());
        return maybeBrowseNext(result, references);
    });
}
Also used : BrowseResponse(org.eclipse.milo.opcua.stack.core.types.structured.BrowseResponse) BrowseNextRequest(org.eclipse.milo.opcua.stack.core.types.structured.BrowseNextRequest) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) LoggerFactory(org.slf4j.LoggerFactory) ReadRequest(org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest) DateTime(org.eclipse.milo.opcua.stack.core.types.builtin.DateTime) DictionaryDescription(org.eclipse.milo.opcua.binaryschema.parser.DictionaryDescription) Unpooled(io.netty.buffer.Unpooled) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) ByteArrayInputStream(java.io.ByteArrayInputStream) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) BrowseDescription(org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription) Map(java.util.Map) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) BrowseResult(org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult) ReferenceDescription(org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription) BrowseDirection(org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseDirection) BsdParser(org.eclipse.milo.opcua.binaryschema.parser.BsdParser) Collectors(java.util.stream.Collectors) JAXBException(javax.xml.bind.JAXBException) CodecDescription(org.eclipse.milo.opcua.binaryschema.parser.CodecDescription) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) Objects(java.util.Objects) CompositeByteBuf(io.netty.buffer.CompositeByteBuf) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Stream(java.util.stream.Stream) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) NodeClass(org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) FutureUtils(org.eclipse.milo.opcua.stack.core.util.FutureUtils) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) StreamUtil.opt2stream(org.eclipse.milo.opcua.sdk.core.util.StreamUtil.opt2stream) BrowseResponse(org.eclipse.milo.opcua.stack.core.types.structured.BrowseResponse) OpcUaSession(org.eclipse.milo.opcua.sdk.client.OpcUaSession) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) BrowseRequest(org.eclipse.milo.opcua.stack.core.types.structured.BrowseRequest) DataTypeDictionary(org.eclipse.milo.opcua.stack.core.types.DataTypeDictionary) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) OpcUaBinaryDataTypeDictionary(org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionary) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) RequestHeader(org.eclipse.milo.opcua.stack.core.types.structured.RequestHeader) Lists(com.google.common.collect.Lists) ByteBuf(io.netty.buffer.ByteBuf) ConversionUtil.l(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) BrowseNextResponse(org.eclipse.milo.opcua.stack.core.types.structured.BrowseNextResponse) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) UaStackClient(org.eclipse.milo.opcua.stack.client.UaStackClient) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) IOException(java.io.IOException) Ints(com.google.common.primitives.Ints) ViewDescription(org.eclipse.milo.opcua.stack.core.types.structured.ViewDescription) BrowseResultMask(org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseResultMask) FutureUtils.failedFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedFuture) Preconditions(com.google.common.base.Preconditions) Collections(java.util.Collections) InputStream(java.io.InputStream) Namespaces(org.eclipse.milo.opcua.stack.core.util.Namespaces) ViewDescription(org.eclipse.milo.opcua.stack.core.types.structured.ViewDescription) ReferenceDescription(org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription) RequestHeader(org.eclipse.milo.opcua.stack.core.types.structured.RequestHeader) BrowseRequest(org.eclipse.milo.opcua.stack.core.types.structured.BrowseRequest)

Example 2 with ReferenceDescription

use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription in project milo by eclipse.

the class AddressSpace method browseNodesAsync.

/**
 * Browse from {@code nodeId} using {@code browseOptions}.
 * <p>
 * This call completes asynchronously.
 *
 * @param nodeId        the {@link NodeId} to start the browse from.
 * @param browseOptions the {@link BrowseOptions} to use.
 * @return a CompletableFuture that completes successfully with a List of {@link UaNode}s
 * referenced by {@code node} given the currently configured {@link BrowseOptions} or completes
 * exceptionally if a service-level error occurs.
 */
public CompletableFuture<List<? extends UaNode>> browseNodesAsync(NodeId nodeId, BrowseOptions browseOptions) {
    BrowseDescription browseDescription = new BrowseDescription(nodeId, browseOptions.getBrowseDirection(), browseOptions.getReferenceTypeId(), browseOptions.isIncludeSubtypes(), browseOptions.getNodeClassMask(), uint(BrowseResultMask.All.getValue()));
    CompletableFuture<List<ReferenceDescription>> browse = BrowseHelper.browse(client, browseDescription, browseOptions.getMaxReferencesPerNode());
    return browse.thenCompose(references -> {
        List<CompletableFuture<? extends UaNode>> cfs = references.stream().map(reference -> {
            NodeClass nodeClass = reference.getNodeClass();
            ExpandedNodeId xNodeId = reference.getNodeId();
            ExpandedNodeId xTypeDefinitionId = reference.getTypeDefinition();
            switch(nodeClass) {
                case Object:
                case Variable:
                    {
                        CompletableFuture<CompletableFuture<? extends UaNode>> ff = toNodeIdAsync(xNodeId).thenCombine(toNodeIdAsync(xTypeDefinitionId), (targetNodeId, typeDefinitionId) -> {
                            if (nodeClass == NodeClass.Object) {
                                return getObjectNodeAsync(targetNodeId, typeDefinitionId);
                            } else {
                                return getVariableNodeAsync(targetNodeId, typeDefinitionId);
                            }
                        });
                        return unwrap(ff).exceptionally(ex -> {
                            logger.warn("Failed to create Node from Reference to {}", reference.getNodeId(), ex);
                            return null;
                        });
                    }
                default:
                    {
                        // TODO specialized getNode for other NodeClasses?
                        return toNodeIdAsync(xNodeId).thenCompose(this::getNodeAsync).exceptionally(ex -> {
                            logger.warn("Failed to create Node from Reference to {}", reference.getNodeId(), ex);
                            return null;
                        });
                    }
            }
        }).collect(Collectors.toList());
        return sequence(cfs);
    });
}
Also used : BuiltinReferenceType(org.eclipse.milo.opcua.stack.core.BuiltinReferenceType) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) UaDataTypeNode(org.eclipse.milo.opcua.sdk.client.nodes.UaDataTypeNode) LoggerFactory(org.slf4j.LoggerFactory) UaObjectTypeNode(org.eclipse.milo.opcua.sdk.client.nodes.UaObjectTypeNode) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) BrowseDescription(org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) UaMethodNode(org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) BrowseResult(org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult) ReferenceDescription(org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription) BrowseDirection(org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseDirection) UByte(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) Set(java.util.Set) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) Objects(java.util.Objects) UaVariableTypeNode(org.eclipse.milo.opcua.sdk.client.nodes.UaVariableTypeNode) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) NodeClass(org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass) UaNode(org.eclipse.milo.opcua.sdk.client.nodes.UaNode) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) Optional(java.util.Optional) UaVariableNode(org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) CompletableFuture(java.util.concurrent.CompletableFuture) UaObjectNode(org.eclipse.milo.opcua.sdk.client.nodes.UaObjectNode) ArrayList(java.util.ArrayList) ConversionUtil.l(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) FutureUtils.failedUaFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture) Logger(org.slf4j.Logger) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) LocalizedText(org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) BrowseResultMask(org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseResultMask) FutureUtils.failedFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedFuture) ObjectNodeConstructor(org.eclipse.milo.opcua.sdk.client.ObjectTypeManager.ObjectNodeConstructor) UaException(org.eclipse.milo.opcua.stack.core.UaException) Preconditions(com.google.common.base.Preconditions) UaReferenceTypeNode(org.eclipse.milo.opcua.sdk.client.nodes.UaReferenceTypeNode) Collections(java.util.Collections) UaViewNode(org.eclipse.milo.opcua.sdk.client.nodes.UaViewNode) NodeClass(org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) CompletableFuture(java.util.concurrent.CompletableFuture) UaNode(org.eclipse.milo.opcua.sdk.client.nodes.UaNode) List(java.util.List) ArrayList(java.util.ArrayList) BrowseDescription(org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription)

Example 3 with ReferenceDescription

use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription in project milo by eclipse.

the class DataTypeTreeBuilder method addChildren.

private static CompletableFuture<Unit> addChildren(Tree<DataTypeTree.DataType> tree, UaStackClient client, OpcUaSession session, NamespaceTable namespaceTable) {
    CompletableFuture<List<ReferenceDescription>> subtypes = browseSafe(client, session, new BrowseDescription(tree.getValue().getNodeId(), BrowseDirection.Forward, Identifiers.HasSubtype, false, uint(NodeClass.DataType.getValue()), uint(BrowseResultMask.All.getValue())));
    CompletableFuture<List<DataTypeTree.DataType>> dataTypesFuture = subtypes.thenCompose(references -> {
        Stream<CompletableFuture<DataTypeTree.DataType>> dataTypeFutures = references.stream().map(dataTypeReference -> {
            NodeId dataTypeId = dataTypeReference.getNodeId().toNodeId(namespaceTable).orElse(NodeId.NULL_VALUE);
            CompletableFuture<List<ReferenceDescription>> encodings = browseSafe(client, session, new BrowseDescription(dataTypeId, BrowseDirection.Forward, Identifiers.HasEncoding, false, uint(NodeClass.Object.getValue()), uint(BrowseResultMask.All.getValue())));
            return encodings.thenApply(encodingReferences -> {
                NodeId binaryEncodingId = null;
                NodeId xmlEncodingId = null;
                for (ReferenceDescription r : encodingReferences) {
                    if (r.getBrowseName().equals(OpcUaDefaultBinaryEncoding.ENCODING_NAME)) {
                        binaryEncodingId = r.getNodeId().toNodeId(namespaceTable).orElse(null);
                    } else if (r.getBrowseName().equals(OpcUaDefaultXmlEncoding.ENCODING_NAME)) {
                        xmlEncodingId = r.getNodeId().toNodeId(namespaceTable).orElse(null);
                    }
                }
                return new DataTypeTree.DataType(dataTypeReference.getBrowseName(), dataTypeId, binaryEncodingId, xmlEncodingId);
            });
        });
        return FutureUtils.sequence(dataTypeFutures);
    });
    return dataTypesFuture.thenCompose(dataTypes -> {
        Stream<CompletableFuture<Unit>> futures = dataTypes.stream().map(tree::addChild).map(childNode -> addChildren(childNode, client, session, namespaceTable));
        return FutureUtils.sequence(futures);
    }).thenApply(v -> Unit.VALUE);
}
Also used : OpcUaDefaultBinaryEncoding(org.eclipse.milo.opcua.stack.core.types.OpcUaDefaultBinaryEncoding) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) CompletableFuture(java.util.concurrent.CompletableFuture) ReadRequest(org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest) RequestHeader(org.eclipse.milo.opcua.stack.core.types.structured.RequestHeader) Tree(org.eclipse.milo.opcua.stack.core.util.Tree) NamespaceTable(org.eclipse.milo.opcua.stack.core.NamespaceTable) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) BrowseDescription(org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) OpcUaDefaultXmlEncoding(org.eclipse.milo.opcua.stack.core.types.OpcUaDefaultXmlEncoding) DataTypeTree(org.eclipse.milo.opcua.sdk.core.DataTypeTree) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ReferenceDescription(org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription) BrowseDirection(org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseDirection) UaStackClient(org.eclipse.milo.opcua.stack.client.UaStackClient) UaResponseMessage(org.eclipse.milo.opcua.stack.core.serialization.UaResponseMessage) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) BrowseResultMask(org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseResultMask) Stream(java.util.stream.Stream) NodeClass(org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass) FutureUtils(org.eclipse.milo.opcua.stack.core.util.FutureUtils) UaException(org.eclipse.milo.opcua.stack.core.UaException) Collections(java.util.Collections) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) CompletableFuture(java.util.concurrent.CompletableFuture) DataTypeTree(org.eclipse.milo.opcua.sdk.core.DataTypeTree) ReferenceDescription(org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) List(java.util.List) Stream(java.util.stream.Stream) BrowseDescription(org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription)

Example 4 with ReferenceDescription

use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription in project milo by eclipse.

the class UaNode method getComponentAsync.

protected CompletableFuture<? extends UaNode> getComponentAsync(QualifiedName browseName, NodeClass nodeClass) {
    UInteger nodeClassMask = uint(nodeClass.getValue());
    UInteger resultMask = uint(BrowseResultMask.All.getValue());
    CompletableFuture<BrowseResult> future = client.browse(new BrowseDescription(getNodeId(), BrowseDirection.Forward, Identifiers.HasComponent, false, nodeClassMask, resultMask));
    return future.thenCompose(result -> {
        List<ReferenceDescription> references = l(result.getReferences());
        Optional<CompletableFuture<? extends UaNode>> node = references.stream().filter(r -> browseName.equals(r.getBrowseName())).flatMap(r -> {
            Optional<CompletableFuture<? extends UaNode>> opt = r.getNodeId().toNodeId(client.getNamespaceTable()).map(id -> client.getAddressSpace().getNodeAsync(id));
            return opt2stream(opt);
        }).findFirst();
        return node.orElse(failedUaFuture(StatusCodes.Bad_NotFound));
    });
}
Also used : QualifiedProperty(org.eclipse.milo.opcua.sdk.core.QualifiedProperty) Arrays(java.util.Arrays) Array(java.lang.reflect.Array) WriteValue(org.eclipse.milo.opcua.stack.core.types.structured.WriteValue) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) AddressSpace(org.eclipse.milo.opcua.sdk.client.AddressSpace) WriteResponse(org.eclipse.milo.opcua.stack.core.types.structured.WriteResponse) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) BrowseDescription(org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) TimestampsToReturn(org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) BrowseResult(org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult) ReferenceDescription(org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription) BrowseDirection(org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseDirection) BrowsePath(org.eclipse.milo.opcua.stack.core.types.structured.BrowsePath) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) Set(java.util.Set) UaEnumeration(org.eclipse.milo.opcua.stack.core.serialization.UaEnumeration) Collectors(java.util.stream.Collectors) ReadValueId(org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId) InvocationTargetException(java.lang.reflect.InvocationTargetException) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) NodeClass(org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) Optional(java.util.Optional) Node(org.eclipse.milo.opcua.sdk.core.nodes.Node) StreamUtil.opt2stream(org.eclipse.milo.opcua.sdk.core.util.StreamUtil.opt2stream) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) BrowseOptions(org.eclipse.milo.opcua.sdk.client.AddressSpace.BrowseOptions) UaStructure(org.eclipse.milo.opcua.stack.core.serialization.UaStructure) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) OpcUaClient(org.eclipse.milo.opcua.sdk.client.OpcUaClient) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) ConversionUtil.l(org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l) UShort(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) FutureUtils.failedUaFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture) Iterator(java.util.Iterator) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) LocalizedText(org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText) RelativePathElement(org.eclipse.milo.opcua.stack.core.types.structured.RelativePathElement) PropertyTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) BrowsePathResult(org.eclipse.milo.opcua.stack.core.types.structured.BrowsePathResult) RelativePath(org.eclipse.milo.opcua.stack.core.types.structured.RelativePath) BrowseResultMask(org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseResultMask) FutureUtils.failedFuture(org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedFuture) UaException(org.eclipse.milo.opcua.stack.core.UaException) CompletableFuture(java.util.concurrent.CompletableFuture) Optional(java.util.Optional) ReferenceDescription(org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) BrowseResult(org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult) BrowseDescription(org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription)

Example 5 with ReferenceDescription

use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription in project milo by eclipse.

the class DataTypeDictionaryReader method maybeBrowseNext.

private CompletionStage<List<ReferenceDescription>> maybeBrowseNext(BrowseResult result, List<ReferenceDescription> references) {
    if (result.getStatusCode().isGood()) {
        ReferenceDescription[] rds = result.getReferences();
        if (rds != null)
            Collections.addAll(references, rds);
        ByteString continuationPoint = result.getContinuationPoint();
        if (continuationPoint.isNotNull()) {
            logger.debug("Continuation point was non-null; calling BrowseNext");
            return browseNextAsync(continuationPoint, references);
        } else {
            logger.debug("Browse finished with {} references", references.size());
            return completedFuture(references);
        }
    } else {
        return completedFuture(references);
    }
}
Also used : ReferenceDescription(org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString)

Aggregations

ReferenceDescription (org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription)14 List (java.util.List)10 AttributeId (org.eclipse.milo.opcua.stack.core.AttributeId)10 Identifiers (org.eclipse.milo.opcua.stack.core.Identifiers)10 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)10 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)10 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)10 BrowseDescription (org.eclipse.milo.opcua.stack.core.types.structured.BrowseDescription)10 BrowseResult (org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult)10 CompletableFuture (java.util.concurrent.CompletableFuture)9 ExecutionException (java.util.concurrent.ExecutionException)9 StatusCodes (org.eclipse.milo.opcua.stack.core.StatusCodes)9 UaException (org.eclipse.milo.opcua.stack.core.UaException)9 StatusCode (org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode)9 Unsigned.uint (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint)9 BrowseDirection (org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseDirection)9 BrowseResultMask (org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseResultMask)9 NodeClass (org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass)9 Optional (java.util.Optional)8 UInteger (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger)8