Search in sources :

Example 1 with AASSubmodelElementList

use of opc.i4aas.AASSubmodelElementList in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method setEntityValue.

/**
 * Sets the values for the given Entity.
 *
 * @param entity The desired Entity.
 * @param value The new value.
 * @throws StatusException If the operation fails
 */
private void setEntityValue(AASEntityType entity, EntityValue value) throws StatusException {
    if (entity == null) {
        throw new IllegalArgumentException("entity is null");
    } else if (value == null) {
        throw new IllegalArgumentException("value is null");
    }
    try {
        // EntityType
        entity.setEntityType(ValueConverter.getAasEntityType(value.getEntityType()));
        // GlobalAssetId
        if ((value.getGlobalAssetId() != null) && (value.getGlobalAssetId().size() > 0)) {
            DefaultReference ref = new DefaultReference.Builder().keys(value.getGlobalAssetId()).build();
            setAasReferenceData(ref, entity.getGlobalAssetIdNode());
        }
        // Statements
        Map<String, ElementValue> valueMap = value.getStatements();
        AASSubmodelElementList statementNode = entity.getStatementNode();
        if (statementNode != null) {
            UaNode[] statementNodes = statementNode.getComponents();
            if (statementNodes.length != valueMap.size()) {
                logger.warn("Size of Value (" + valueMap.size() + ") doesn't match the number of StatementNodes (" + statementNodes.length + ")");
                throw new IllegalArgumentException("Size of Value doesn't match the number of StatementNodes");
            }
            for (UaNode statementNode1 : statementNodes) {
                if (statementNode1 instanceof AASSubmodelElementType) {
                    if (value.getStatements().containsKey(statementNode1.getBrowseName().getName())) {
                        setSubmodelElementValue((AASSubmodelElementType) statementNode1, value.getStatements().get(statementNode1.getBrowseName().getName()));
                    }
                }
            }
        }
    } catch (Throwable ex) {
        logger.error("setEntityValue Exception", ex);
        throw ex;
    }
}
Also used : AASSubmodelElementList(opc.i4aas.AASSubmodelElementList) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) UaNode(com.prosysopc.ua.nodes.UaNode) NodeManagerUaNode(com.prosysopc.ua.server.NodeManagerUaNode) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) RelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue) ReferenceElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue) AnnotatedRelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue) DataElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue) ElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference)

Aggregations

UaNode (com.prosysopc.ua.nodes.UaNode)1 MethodManagerUaNode (com.prosysopc.ua.server.MethodManagerUaNode)1 NodeManagerUaNode (com.prosysopc.ua.server.NodeManagerUaNode)1 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)1 AnnotatedRelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue)1 DataElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue)1 ElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue)1 ReferenceElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue)1 RelationshipElementValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue)1 LangString (io.adminshell.aas.v3.model.LangString)1 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)1 AASSubmodelElementList (opc.i4aas.AASSubmodelElementList)1 AASSubmodelElementType (opc.i4aas.AASSubmodelElementType)1