use of org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse in project milo by eclipse.
the class AddressSpace method createObjectNodeFromBaseAttributes.
private CompletableFuture<UaObjectNode> createObjectNodeFromBaseAttributes(NodeId nodeId, List<DataValue> baseAttributeValues) {
Set<AttributeId> remainingAttributes = Sets.difference(AttributeId.OBJECT_ATTRIBUTES, AttributeId.BASE_ATTRIBUTES);
CompletableFuture<ReadResponse> attributesFuture = readAttributes(nodeId, remainingAttributes);
CompletableFuture<NodeId> typeDefinitionFuture = readTypeDefinition(nodeId);
return CompletableFuture.allOf(attributesFuture, typeDefinitionFuture).thenCompose(ignored -> {
ReadResponse response = attributesFuture.join();
NodeId typeDefinitionId = typeDefinitionFuture.join();
List<DataValue> attributeValues = new ArrayList<>(baseAttributeValues);
Collections.addAll(attributeValues, response.getResults());
try {
UaObjectNode node = newObjectNode(nodeId, typeDefinitionId, attributeValues);
nodeCache.put(node.getNodeId(), node);
return completedFuture(node);
} catch (UaException e) {
return failedFuture(e);
}
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse in project milo by eclipse.
the class AddressSpace method createViewNodeFromBaseAttributes.
private CompletableFuture<UaViewNode> createViewNodeFromBaseAttributes(NodeId nodeId, List<DataValue> baseAttributeValues) {
Set<AttributeId> remainingAttributes = Sets.difference(AttributeId.VIEW_ATTRIBUTES, AttributeId.BASE_ATTRIBUTES);
CompletableFuture<ReadResponse> attributesFuture = readAttributes(nodeId, remainingAttributes);
return attributesFuture.thenCompose(response -> {
List<DataValue> attributeValues = new ArrayList<>(baseAttributeValues);
Collections.addAll(attributeValues, response.getResults());
try {
UaViewNode node = newViewNode(nodeId, attributeValues);
nodeCache.put(node.getNodeId(), node);
return completedFuture(node);
} catch (UaException e) {
return failedFuture(e);
}
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse in project milo by eclipse.
the class AddressSpace method getVariableNodeAsync.
/**
* Get a {@link UaVariableNode} instance for the VariableNode identified by {@code nodeId},
* assuming the type definition identified by {@code typeDefinitionId}.
* <p>
* If this type definition is registered with the {@link VariableTypeManager} a
* {@link UaVariableNode} of the appropriate subclass will be returned.
* <p>
* This call completes asynchronously.
*
* @param nodeId the {@link NodeId} identifying the VariableNode to get.
* @param typeDefinitionId the {@link NodeId} identifying the type definition.
* @return a CompletableFuture that completes successfully with a {@link UaVariableNode}
* instance for the VariableNode identified by {@code nodeId} or completes exceptionally if an
* error occurs while creating the VariableNode.
*/
public CompletableFuture<UaVariableNode> getVariableNodeAsync(NodeId nodeId, NodeId typeDefinitionId) {
UaNode cachedNode = nodeCache.getIfPresent(nodeId);
if (cachedNode instanceof UaVariableNode) {
return completedFuture((UaVariableNode) cachedNode);
} else {
CompletableFuture<ReadResponse> future = readAttributes(nodeId, AttributeId.VARIABLE_ATTRIBUTES);
return future.thenCompose(response -> {
List<DataValue> attributeValues = l(response.getResults());
try {
UaVariableNode node = newVariableNode(nodeId, typeDefinitionId, attributeValues);
nodeCache.put(node.getNodeId(), node);
return completedFuture(node);
} catch (UaException e) {
return failedFuture(e);
}
});
}
}
use of org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse in project milo by eclipse.
the class AddressSpace method createDataTypeNodeFromBaseAttributes.
private CompletableFuture<UaDataTypeNode> createDataTypeNodeFromBaseAttributes(NodeId nodeId, List<DataValue> baseAttributeValues) {
Set<AttributeId> remainingAttributes = Sets.difference(AttributeId.DATA_TYPE_ATTRIBUTES, AttributeId.BASE_ATTRIBUTES);
CompletableFuture<ReadResponse> attributesFuture = readAttributes(nodeId, remainingAttributes);
return attributesFuture.thenCompose(response -> {
List<DataValue> attributeValues = new ArrayList<>(baseAttributeValues);
Collections.addAll(attributeValues, response.getResults());
try {
UaDataTypeNode node = newDataTypeNode(nodeId, attributeValues);
nodeCache.put(node.getNodeId(), node);
return completedFuture(node);
} catch (UaException e) {
return failedFuture(e);
}
});
}
use of org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse in project milo by eclipse.
the class AddressSpace method createMethodNodeFromBaseAttributes.
private CompletableFuture<UaMethodNode> createMethodNodeFromBaseAttributes(NodeId nodeId, List<DataValue> baseAttributeValues) {
Set<AttributeId> remainingAttributes = Sets.difference(AttributeId.METHOD_ATTRIBUTES, AttributeId.BASE_ATTRIBUTES);
CompletableFuture<ReadResponse> attributesFuture = readAttributes(nodeId, remainingAttributes);
return attributesFuture.thenCompose(response -> {
List<DataValue> attributeValues = new ArrayList<>(baseAttributeValues);
Collections.addAll(attributeValues, response.getResults());
try {
UaMethodNode node = newMethodNode(nodeId, attributeValues);
nodeCache.put(node.getNodeId(), node);
return completedFuture(node);
} catch (UaException e) {
return failedFuture(e);
}
});
}
Aggregations