Search in sources :

Example 1 with ModelingKind

use of io.adminshell.aas.v3.model.ModelingKind in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addSubmodel.

/**
 * Adds a submodel to a given Node
 *
 * @param node The desired Node where the submodel should be added
 * @param submodel The desired AAS submodel
 */
private void addSubmodel(UaNode node, Submodel submodel) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    if (submodel == null) {
        throw new IllegalArgumentException("submodel is null");
    }
    try {
        String shortId = submodel.getIdShort();
        if (!shortId.isEmpty()) {
            String displayName = "Submodel:" + shortId;
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelType.getNamespaceUri(), shortId).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(node, browseName);
            if (findNode(nid) != null) {
                // The NodeId already exists
                nid = getDefaultNodeId();
            }
            logger.trace("addSubmodel: create Submodel " + submodel.getIdShort() + "; NodeId: " + nid.toString());
            AASSubmodelType smNode = createInstance(AASSubmodelType.class, nid, browseName, LocalizedText.english(displayName));
            // ModelingKind
            smNode.setModelingKind(ValueConverter.convertModelingKind(submodel.getKind()));
            addIdentifiable(smNode, submodel.getIdentification(), submodel.getAdministration(), submodel.getCategory());
            // DataSpecifications
            addEmbeddedDataSpecifications(smNode, submodel.getEmbeddedDataSpecifications());
            // Qualifiers
            List<Constraint> qualifiers = submodel.getQualifiers();
            if ((qualifiers != null) && (!qualifiers.isEmpty())) {
                if (smNode.getQualifierNode() == null) {
                    addQualifierNode(smNode);
                }
                addQualifiers(smNode.getQualifierNode(), qualifiers);
            }
            // SemanticId
            if (submodel.getSemanticId() != null) {
                addSemanticId(smNode, submodel.getSemanticId());
            }
            // Description
            addDescriptions(smNode, submodel.getDescriptions());
            Reference refSubmodel = AasUtils.toReference(submodel);
            // SubmodelElements
            addSubmodelElements(smNode, submodel.getSubmodelElements(), submodel, refSubmodel);
            if (VALUES_READ_ONLY) {
                smNode.getModelingKindNode().setAccessLevel(AccessLevelType.CurrentRead);
            }
            submodelOpcUAMap.put(AasUtils.toReference(submodel), smNode);
            node.addComponent(smNode);
            referableMap.put(AasUtils.toReference(submodel), new ObjectData(submodel, smNode));
        } else {
            logger.warn("addSubmodel: IdShort is empty!");
        }
    } catch (Throwable ex) {
        logger.error("addSubmodel Exception", ex);
        throw ex;
    }
}
Also used : AASSubmodelType(opc.i4aas.AASSubmodelType) Constraint(io.adminshell.aas.v3.model.Constraint) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString)

Aggregations

UaQualifiedName (com.prosysopc.ua.UaQualifiedName)1 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)1 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)1 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)1 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)1 Constraint (io.adminshell.aas.v3.model.Constraint)1 LangString (io.adminshell.aas.v3.model.LangString)1 Reference (io.adminshell.aas.v3.model.Reference)1 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)1 AASSubmodelType (opc.i4aas.AASSubmodelType)1