Search in sources :

Example 1 with AttributeId

use of org.eclipse.milo.opcua.stack.core.AttributeId 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);
        }
    });
}
Also used : UaObjectNode(org.eclipse.milo.opcua.sdk.client.nodes.UaObjectNode) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) UaException(org.eclipse.milo.opcua.stack.core.UaException) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) ArrayList(java.util.ArrayList)

Example 2 with AttributeId

use of org.eclipse.milo.opcua.stack.core.AttributeId 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);
        }
    });
}
Also used : ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) UaException(org.eclipse.milo.opcua.stack.core.UaException) ArrayList(java.util.ArrayList) UaViewNode(org.eclipse.milo.opcua.sdk.client.nodes.UaViewNode)

Example 3 with AttributeId

use of org.eclipse.milo.opcua.stack.core.AttributeId 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);
        }
    });
}
Also used : ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) UaException(org.eclipse.milo.opcua.stack.core.UaException) ArrayList(java.util.ArrayList) UaDataTypeNode(org.eclipse.milo.opcua.sdk.client.nodes.UaDataTypeNode)

Example 4 with AttributeId

use of org.eclipse.milo.opcua.stack.core.AttributeId 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);
        }
    });
}
Also used : UaMethodNode(org.eclipse.milo.opcua.sdk.client.nodes.UaMethodNode) ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) UaException(org.eclipse.milo.opcua.stack.core.UaException) ArrayList(java.util.ArrayList)

Example 5 with AttributeId

use of org.eclipse.milo.opcua.stack.core.AttributeId in project milo by eclipse.

the class AddressSpace method createVariableTypeNodeFromBaseAttributes.

private CompletableFuture<UaVariableTypeNode> createVariableTypeNodeFromBaseAttributes(NodeId nodeId, List<DataValue> baseAttributeValues) {
    Set<AttributeId> remainingAttributes = Sets.difference(AttributeId.VARIABLE_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 {
            UaVariableTypeNode node = newVariableTypeNode(nodeId, attributeValues);
            nodeCache.put(node.getNodeId(), node);
            return completedFuture(node);
        } catch (UaException e) {
            return failedFuture(e);
        }
    });
}
Also used : ReadResponse(org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) UaVariableTypeNode(org.eclipse.milo.opcua.sdk.client.nodes.UaVariableTypeNode) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) UaException(org.eclipse.milo.opcua.stack.core.UaException) ArrayList(java.util.ArrayList)

Aggregations

AttributeId (org.eclipse.milo.opcua.stack.core.AttributeId)21 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)19 ArrayList (java.util.ArrayList)14 UaException (org.eclipse.milo.opcua.stack.core.UaException)14 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)14 Identifiers (org.eclipse.milo.opcua.stack.core.Identifiers)11 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)10 ExtensionObject (org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject)10 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)10 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)9 ReadResponse (org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 UaNode (org.eclipse.milo.opcua.sdk.server.nodes.UaNode)7 UInteger (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger)7 List (java.util.List)6 NoSuchElementException (java.util.NoSuchElementException)6 Reference (org.eclipse.milo.opcua.sdk.core.Reference)6 AbstractLifecycle (org.eclipse.milo.opcua.sdk.server.AbstractLifecycle)6 Session (org.eclipse.milo.opcua.sdk.server.Session)6 Util.diagnosticValueFilter (org.eclipse.milo.opcua.sdk.server.diagnostics.variables.Util.diagnosticValueFilter)6