Search in sources :

Example 1 with TranslateBrowsePathsToNodeIdsRequest

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

the class BrowsePathsHelper method onTranslateBrowsePaths.

public void onTranslateBrowsePaths(ServiceRequest service) {
    TranslateBrowsePathsToNodeIdsRequest request = (TranslateBrowsePathsToNodeIdsRequest) service.getRequest();
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
    List<BrowsePath> browsePaths = l(request.getBrowsePaths());
    if (browsePaths.isEmpty()) {
        service.setServiceFault(StatusCodes.Bad_NothingToDo);
        return;
    }
    if (browsePaths.size() > server.getConfig().getLimits().getMaxNodesPerTranslateBrowsePathsToNodeIds().intValue()) {
        service.setServiceFault(StatusCodes.Bad_TooManyOperations);
        return;
    }
    List<CompletableFuture<BrowsePathResult>> futures = newArrayListWithCapacity(browsePaths.size());
    for (BrowsePath browsePath : browsePaths) {
        futures.add(translate(browsePath));
    }
    sequence(futures).thenAcceptAsync(results -> {
        ResponseHeader header = service.createResponseHeader();
        TranslateBrowsePathsToNodeIdsResponse response = new TranslateBrowsePathsToNodeIdsResponse(header, a(results, BrowsePathResult.class), new DiagnosticInfo[0]);
        service.setResponse(response);
    }, server.getExecutorService());
}
Also used : OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) CompletableFuture(java.util.concurrent.CompletableFuture) ResponseHeader(org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader) BrowsePathResult(org.eclipse.milo.opcua.stack.core.types.structured.BrowsePathResult) TranslateBrowsePathsToNodeIdsRequest(org.eclipse.milo.opcua.stack.core.types.structured.TranslateBrowsePathsToNodeIdsRequest) TranslateBrowsePathsToNodeIdsResponse(org.eclipse.milo.opcua.stack.core.types.structured.TranslateBrowsePathsToNodeIdsResponse) BrowsePath(org.eclipse.milo.opcua.stack.core.types.structured.BrowsePath)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)1 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)1 BrowsePath (org.eclipse.milo.opcua.stack.core.types.structured.BrowsePath)1 BrowsePathResult (org.eclipse.milo.opcua.stack.core.types.structured.BrowsePathResult)1 ResponseHeader (org.eclipse.milo.opcua.stack.core.types.structured.ResponseHeader)1 TranslateBrowsePathsToNodeIdsRequest (org.eclipse.milo.opcua.stack.core.types.structured.TranslateBrowsePathsToNodeIdsRequest)1 TranslateBrowsePathsToNodeIdsResponse (org.eclipse.milo.opcua.stack.core.types.structured.TranslateBrowsePathsToNodeIdsResponse)1