Search in sources :

Example 1 with AASSubmodelElementType

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

the class AasServiceNodeManager method updateSubmodelElementValue.

/**
 * Update the value of a SubmodelElement.
 *
 * @param reference The reference of the desired SubmodelElement
 * @param newValue The new value of the SubmodelElement
 * @param oldValue The old value of the SubmodelElement
 * @throws StatusException If the operation fails
 */
public void updateSubmodelElementValue(Reference reference, ElementValue newValue, ElementValue oldValue) throws StatusException {
    if (reference == null) {
        throw new IllegalArgumentException("reference is null");
    } else if (newValue == null) {
        throw new IllegalArgumentException("newValue is null");
    }
    logger.debug("updateSubmodelElementValue");
    if (submodelElementOpcUAMap.containsKey(reference)) {
        AASSubmodelElementType subElem = submodelElementOpcUAMap.get(reference);
        setSubmodelElementValue(subElem, newValue);
    } else {
        logger.warn("SubmodelElement " + reference.toString() + " not found in submodelElementOpcUAMap");
    }
}
Also used : AASSubmodelElementType(opc.i4aas.AASSubmodelElementType)

Example 2 with AASSubmodelElementType

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

the class AasServiceNodeManager method elementCreated.

/**
 * Handles an elementCreated event.
 *
 * @param element Reference to the created element.
 * @param value The element that was added.
 * @throws StatusException If the operation fails
 * @throws ServiceResultException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws AddressSpaceException If the operation fails
 */
private void elementCreated(Reference element, Referable value) throws StatusException, ServiceResultException, ServiceException, AddressSpaceException {
    if (element == null) {
        throw new IllegalArgumentException("element is null");
    } else if (value == null) {
        throw new IllegalArgumentException("value is null");
    }
    try {
        logger.debug("elementCreated called. Reference " + AasUtils.asString(element));
        // The element is the parent object where the value is added
        ObjectData parent = null;
        if (referableMap.containsKey(element)) {
            parent = referableMap.get(element);
        } else {
            logger.info("elementCreated: element not found in referableMap: " + AasUtils.asString(element));
        }
        if (value instanceof ConceptDescription) {
            addConceptDescriptions(List.of((ConceptDescription) value));
        } else if (value instanceof Asset) {
            addAsset(aasEnvironmentNode, (Asset) value);
        } else if (value instanceof Submodel) {
            addSubmodel(aasEnvironmentNode, (Submodel) value);
        } else if (value instanceof AssetAdministrationShell) {
            addAssetAdministrationShell((AssetAdministrationShell) value);
        } else if (parent != null) {
            if (value instanceof EmbeddedDataSpecification) {
                if (parent.getNode() instanceof AASAssetAdministrationShellType) {
                    addEmbeddedDataSpecifications((AASAssetAdministrationShellType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASSubmodelType) {
                    addEmbeddedDataSpecifications((AASSubmodelType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    addEmbeddedDataSpecifications((AASSubmodelElementType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASAssetType) {
                    addEmbeddedDataSpecifications((AASAssetType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else {
                    logger.warn("elementCreated: EmbeddedDataSpecification parent class not found");
                }
            } else if (value instanceof Constraint) {
                if (parent.getNode() instanceof AASSubmodelType) {
                    addQualifiers(((AASSubmodelType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    addQualifiers(((AASSubmodelElementType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
                } else {
                    logger.warn("elementCreated: Constraint parent class not found");
                }
            } else if (value instanceof SubmodelElement) {
                if (parent.getNode() instanceof AASSubmodelType) {
                    logger.info("elementCreated: call addSubmodelElements");
                    addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), (Submodel) parent.getReferable(), element);
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    logger.info("elementCreated: call addSubmodelElements");
                    addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), parent.getSubmodel(), element);
                } else {
                    logger.warn("elementCreated: SubmodelElement parent class not found: " + parent.getNode().getNodeId().toString() + "; " + parent.getNode());
                }
            }
        } else {
            logger.warn("elementCreated: element not found: " + AasUtils.asString(element));
        }
    } catch (Throwable ex) {
        logger.error("elementCreated Exception", ex);
        throw ex;
    }
}
Also used : Submodel(io.adminshell.aas.v3.model.Submodel) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) AASAssetType(opc.i4aas.AASAssetType) Constraint(io.adminshell.aas.v3.model.Constraint) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) AASSubmodelType(opc.i4aas.AASSubmodelType) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) Asset(io.adminshell.aas.v3.model.Asset) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription)

Example 3 with AASSubmodelElementType

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

the class AasServiceNodeManager method doRemoveFromMaps.

/**
 * Removes the given SubmodelElement from the maps.
 *
 * @param parent The reference to the parent element.
 * @param de The desired SubmodelElement
 */
private void doRemoveFromMaps(Reference parent, SubmodelElement de) {
    try {
        Reference ref = AasUtils.toReference(parent, de);
        ObjectData element = null;
        if (referableMap.containsKey(ref)) {
            element = referableMap.get(ref);
            if (element.getNode() instanceof AASSubmodelElementType) {
                doRemoveFromMaps((AASSubmodelElementType) element.getNode(), ref, de);
            }
            // remove element from the map
            referableMap.remove(ref);
        } else {
            logger.info("doRemoveFromMaps: element not found in referableMap: " + AasUtils.asString(ref));
        }
    } catch (Throwable ex) {
        logger.error("doRemoveFromMaps Exception", ex);
        throw ex;
    }
}
Also used : Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)

Example 4 with AASSubmodelElementType

use of opc.i4aas.AASSubmodelElementType 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

AASSubmodelElementType (opc.i4aas.AASSubmodelElementType)4 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)2 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)2 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 Asset (io.adminshell.aas.v3.model.Asset)1 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)1 ConceptDescription (io.adminshell.aas.v3.model.ConceptDescription)1 Constraint (io.adminshell.aas.v3.model.Constraint)1 EmbeddedDataSpecification (io.adminshell.aas.v3.model.EmbeddedDataSpecification)1 LangString (io.adminshell.aas.v3.model.LangString)1 Reference (io.adminshell.aas.v3.model.Reference)1 Submodel (io.adminshell.aas.v3.model.Submodel)1