use of org.eclipse.milo.opcua.stack.core.types.structured.BrowseRequest 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);
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.BrowseRequest 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.BrowseRequest 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);
});
}
Aggregations