use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription in project milo by eclipse.
the class DataTypeDictionaryReader method readDataTypeDictionaries.
public CompletableFuture<List<DataTypeDictionary<?>>> readDataTypeDictionaries() {
CompletableFuture<List<ReferenceDescription>> browseFuture = browseNode(new BrowseDescription(Identifiers.OPCBinarySchema_TypeSystem, BrowseDirection.Forward, Identifiers.HasComponent, false, uint(NodeClass.Variable.getValue()), uint(BrowseResultMask.All.getValue())));
CompletableFuture<Stream<NodeId>> dictionaryNodeIds = browseFuture.thenApply(references -> references.stream().filter(r -> r.getTypeDefinition().equalTo(Identifiers.DataTypeDictionaryType)).flatMap(r -> opt2stream(r.getNodeId().toNodeId(stackClient.getNamespaceTable()))));
return dictionaryNodeIds.thenApply(nodeIds -> nodeIds.map(this::readDataTypeDictionary).collect(Collectors.toList())).thenCompose(FutureUtils::sequence).thenApply(list -> list.stream().filter(Objects::nonNull).collect(Collectors.toList()));
}
use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription in project milo by eclipse.
the class UaNodeTest method browse.
@Test
public void browse() throws UaException {
AddressSpace addressSpace = client.getAddressSpace();
UaNode serverNode = addressSpace.getNode(Identifiers.Server);
BrowseOptions browseOptions = BrowseOptions.builder().setReferenceType(Identifiers.HasProperty).build();
List<ReferenceDescription> references = serverNode.browse(browseOptions);
assertEquals(5, references.size());
assertTrue(references.stream().anyMatch(n -> n.getNodeId().equalTo(Identifiers.Server_ServerArray)));
assertTrue(references.stream().anyMatch(n -> n.getNodeId().equalTo(Identifiers.Server_NamespaceArray)));
assertTrue(references.stream().anyMatch(n -> n.getNodeId().equalTo(Identifiers.Server_ServiceLevel)));
assertTrue(references.stream().anyMatch(n -> n.getNodeId().equalTo(Identifiers.Server_Auditing)));
assertTrue(references.stream().anyMatch(n -> n.getNodeId().equalTo(Identifiers.Server_EstimatedReturnTime)));
}
use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription 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.ReferenceDescription 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));
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.ReferenceDescription in project milo by eclipse.
the class UaObjectNode method getTypeDefinitionAsync.
public CompletableFuture<? extends UaObjectTypeNode> getTypeDefinitionAsync() {
UInteger nodeClassMask = uint(NodeClass.ObjectType.getValue());
UInteger resultMask = uint(BrowseResultMask.All.getValue());
CompletableFuture<BrowseResult> future = client.browse(new BrowseDescription(getNodeId(), BrowseDirection.Forward, Identifiers.HasTypeDefinition, false, nodeClassMask, resultMask));
return future.thenCompose(result -> {
List<ReferenceDescription> references = l(result.getReferences());
Optional<CompletableFuture<UaObjectTypeNode>> node = references.stream().flatMap(r -> {
Optional<CompletableFuture<UaObjectTypeNode>> opt = r.getNodeId().toNodeId(client.getNamespaceTable()).map(id -> client.getAddressSpace().getNodeAsync(id).thenApply(n -> (UaObjectTypeNode) n));
return opt2stream(opt);
}).findFirst();
return node.orElse(FutureUtils.failedUaFuture(StatusCodes.Bad_NotFound));
});
}
Aggregations