use of org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult in project milo by eclipse.
the class DataTypeDictionaryReader method browseNextAsync.
private CompletableFuture<List<ReferenceDescription>> browseNextAsync(ByteString continuationPoint, List<ReferenceDescription> references) {
RequestHeader requestHeader = stackClient.newRequestHeader(session.getAuthenticationToken(), stackClient.getConfig().getRequestTimeout());
BrowseNextRequest request = new BrowseNextRequest(requestHeader, false, new ByteString[] { continuationPoint });
return stackClient.sendRequest(request).thenApply(BrowseNextResponse.class::cast).thenCompose(response -> {
BrowseResult result = l(response.getResults()).get(0);
return maybeBrowseNext(result, references);
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult 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));
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult in project milo by eclipse.
the class BrowseHelper method browse.
public static CompletableFuture<List<ReferenceDescription>> browse(UaStackClient client, OpcUaSession session, BrowseDescription browseDescription, UInteger maxReferencesPerNode) {
BrowseRequest browseRequest = new BrowseRequest(client.newRequestHeader(session.getAuthenticationToken(), client.getConfig().getRequestTimeout()), new ViewDescription(NodeId.NULL_VALUE, DateTime.MIN_VALUE, uint(0)), maxReferencesPerNode, new BrowseDescription[] { browseDescription });
return client.sendRequest(browseRequest).thenApply(BrowseResponse.class::cast).thenCompose(response -> {
BrowseResult result = response.getResults()[0];
List<ReferenceDescription> references = Collections.synchronizedList(new ArrayList<>());
return maybeBrowseNext(client, session, references, result);
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult in project milo by eclipse.
the class DefaultViewServiceSet method onBrowse.
@Override
public void onBrowse(ServiceRequest service) {
browseCounter.record(service);
BrowseRequest request = (BrowseRequest) service.getRequest();
DiagnosticsContext<BrowseDescription> diagnosticsContext = new DiagnosticsContext<>();
OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
List<BrowseDescription> nodesToBrowse = l(request.getNodesToBrowse());
if (nodesToBrowse.isEmpty()) {
service.setServiceFault(StatusCodes.Bad_NothingToDo);
return;
}
if (nodesToBrowse.size() > server.getConfig().getLimits().getMaxNodesPerBrowse().intValue()) {
service.setServiceFault(StatusCodes.Bad_TooManyOperations);
return;
}
Stream<CompletableFuture<BrowseResult>> futures = nodesToBrowse.stream().map(browseDescription -> browseHelper.browse(() -> Optional.of(session), server, request.getView(), request.getRequestedMaxReferencesPerNode(), browseDescription));
FutureUtils.sequence(futures).thenAccept(results -> {
ResponseHeader header = service.createResponseHeader();
DiagnosticInfo[] diagnosticInfos = diagnosticsContext.getDiagnosticInfos(nodesToBrowse);
BrowseResponse response = new BrowseResponse(header, a(results, BrowseResult.class), diagnosticInfos);
service.setResponse(response);
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.BrowseResult in project milo by eclipse.
the class UaNode method getPropertyNodeAsync.
protected CompletableFuture<PropertyTypeNode> getPropertyNodeAsync(QualifiedName browseName) {
UInteger nodeClassMask = uint(NodeClass.Variable.getValue());
UInteger resultMask = uint(BrowseResultMask.BrowseName.getValue());
CompletableFuture<BrowseResult> future = client.browse(new BrowseDescription(getNodeId(), BrowseDirection.Forward, Identifiers.HasProperty, false, nodeClassMask, resultMask));
return future.thenCompose(result -> {
List<ReferenceDescription> references = l(result.getReferences());
Optional<CompletableFuture<PropertyTypeNode>> node = references.stream().filter(r -> browseName.equals(r.getBrowseName())).flatMap(r -> {
Optional<CompletableFuture<PropertyTypeNode>> opt = r.getNodeId().toNodeId(client.getNamespaceTable()).map(id -> client.getAddressSpace().getNodeAsync(id).thenApply(n -> (PropertyTypeNode) n));
return opt2stream(opt);
}).findFirst();
return node.orElse(failedUaFuture(StatusCodes.Bad_NotFound));
});
}
Aggregations