use of org.eclipse.milo.opcua.stack.core.types.structured.BrowsePath 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());
}
use of org.eclipse.milo.opcua.stack.core.types.structured.BrowsePath in project milo by eclipse.
the class TranslateBrowsePathExample method run.
@Override
public void run(OpcUaClient client, CompletableFuture<OpcUaClient> future) throws Exception {
// synchronous connect
client.connect().get();
TranslateBrowsePathsToNodeIdsResponse response = client.translateBrowsePaths(newArrayList(new BrowsePath(Identifiers.ObjectsFolder, new RelativePath(new RelativePathElement[] { new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(2, "HelloWorld")), new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(2, "ScalarTypes")), new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(2, "UInt64")) })))).get();
BrowsePathResult result = l(response.getResults()).get(0);
StatusCode statusCode = result.getStatusCode();
logger.info("Status={}", statusCode);
l(result.getTargets()).forEach(target -> logger.info("TargetId={}", target.getTargetId()));
future.complete(client);
}
Aggregations