Search in sources :

Example 6 with AASReferenceList

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

the class AasServiceNodeManager method addEmbeddedDataSpecifications.

/**
 * Adds the references to the given Embedded Data Specifications.
 *
 * @param submodelElementNode The desired object where the
 *            DataSpecifications should be added
 * @param list The list of the desired Data Specifications
 * @throws StatusException If the operation fails
 */
private void addEmbeddedDataSpecifications(AASSubmodelElementType submodelElementNode, List<EmbeddedDataSpecification> list) throws StatusException {
    try {
        if ((list != null) && (!list.isEmpty())) {
            List<Reference> refList = new ArrayList<>();
            for (EmbeddedDataSpecification eds : list) {
                refList.add(eds.getDataSpecification());
            }
            AASReferenceList listNode = submodelElementNode.getDataSpecificationNode();
            if (listNode == null) {
                addAasReferenceList(submodelElementNode, refList, AASSubmodelElementType.DATA_SPECIFICATION);
            } else {
                addEmbeddedDataSpecificationsReferences(listNode, refList);
            }
        }
    } catch (Throwable ex) {
        logger.error("addEmbeddedDataSpecifications Exception", ex);
        throw ex;
    }
}
Also used : EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ArrayList(java.util.ArrayList) AASReferenceList(opc.i4aas.AASReferenceList)

Example 7 with AASReferenceList

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

the class AasServiceNodeManager method addSubmodelReferences.

/**
 * Adds the given submodel references to the given node.
 *
 * @param node The desired UA node in which the objects should be created
 * @param submodelRefs The desired submodel references
 * @throws StatusException If the operation fails
 */
private void addSubmodelReferences(AASAssetAdministrationShellType node, List<Reference> submodelRefs) throws StatusException {
    if (node == null) {
        throw new IllegalArgumentException("node = null");
    } else if (submodelRefs == null) {
        throw new IllegalArgumentException("sumodelRefs = null");
    }
    try {
        String name = "Submodel";
        AASReferenceList referenceListNode = node.getSubmodelNode();
        logger.info("addSubmodelReferences: add " + submodelRefs.size() + " Submodels to Node: " + node.toString());
        boolean added = false;
        if (referenceListNode == null) {
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASReferenceList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(node, browseName);
            referenceListNode = createInstance(AASReferenceList.class, nid, browseName, LocalizedText.english(name));
            logger.info("addSubmodelReferences: add Node " + referenceListNode.getNodeId() + "to Node" + node.getNodeId());
            added = true;
        }
        int counter = 1;
        for (Reference ref : submodelRefs) {
            UaNode submodelNode = null;
            String submodelName = getSubmodelName(ref);
            if (submodelName.isEmpty()) {
                submodelName = name + counter++;
            }
            if (submodelOpcUAMap.containsKey(ref)) {
                submodelNode = submodelOpcUAMap.get(ref);
            }
            UaNode refNode = addAasReferenceAasNS(referenceListNode, ref, submodelName);
            if (refNode != null) {
                // add hasAddIn reference to the submodel
                if (submodelNode != null) {
                    refNode.addReference(submodelNode, Identifiers.HasAddIn, false);
                } else {
                    logger.warn("addSubmodelReferences: Submodel " + ref + " not found in submodelRefMap");
                }
            }
        }
        if (added) {
            node.addComponent(referenceListNode);
        }
    } catch (Throwable ex) {
        logger.error("addSubmodelReferences Exception", ex);
        throw ex;
    }
}
Also used : 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) AASReferenceList(opc.i4aas.AASReferenceList) 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) Constraint(io.adminshell.aas.v3.model.Constraint)

Aggregations

Reference (io.adminshell.aas.v3.model.Reference)7 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)7 AASReferenceList (opc.i4aas.AASReferenceList)7 EmbeddedDataSpecification (io.adminshell.aas.v3.model.EmbeddedDataSpecification)4 ArrayList (java.util.ArrayList)4 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)3 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)3 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)3 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)2 Constraint (io.adminshell.aas.v3.model.Constraint)2 LangString (io.adminshell.aas.v3.model.LangString)2 UaNode (com.prosysopc.ua.nodes.UaNode)1 MethodManagerUaNode (com.prosysopc.ua.server.MethodManagerUaNode)1 NodeManagerUaNode (com.prosysopc.ua.server.NodeManagerUaNode)1 AssetKind (io.adminshell.aas.v3.model.AssetKind)1 File (io.adminshell.aas.v3.model.File)1 IdentifierKeyValuePair (io.adminshell.aas.v3.model.IdentifierKeyValuePair)1 AASAssetInformationType (opc.i4aas.AASAssetInformationType)1