Search in sources :

Example 46 with StatusException

use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addAasReferenceElement.

/**
 * Adds an AAS reference element to the given node.
 *
 * @param node The desired UA node
 * @param aasRefElem The AAS reference element to add
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param parentRef The reference to the parent object
 * @param ordered Specifies whether the reference element should be added
 *            ordered (true) or unordered (false)
 * @throws StatusException If the operation fails
 */
private void addAasReferenceElement(UaNode node, ReferenceElement aasRefElem, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
    try {
        if ((node != null) && (aasRefElem != null)) {
            String name = aasRefElem.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASReferenceElementType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASReferenceElementType refElemNode = createInstance(AASReferenceElementType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(refElemNode, aasRefElem);
            if (aasRefElem.getValue() != null) {
                setAasReferenceData(aasRefElem.getValue(), refElemNode.getValueNode(), false);
            }
            Reference refElemRef = AasUtils.toReference(parentRef, aasRefElem);
            submodelElementAasMap.put(refElemNode.getValueNode().getKeysNode().getNodeId(), new SubmodelElementData(aasRefElem, submodel, SubmodelElementData.Type.REFERENCE_ELEMENT_VALUE, refElemRef));
            submodelElementOpcUAMap.put(refElemRef, refElemNode);
            if (ordered) {
                node.addReference(refElemNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(refElemNode);
            }
            referableMap.put(refElemRef, new ObjectData(aasRefElem, refElemNode, submodel));
        }
    } catch (Exception ex) {
        LOG.error("addAasReferenceElement 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) 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) AASReferenceElementType(opc.i4aas.AASReferenceElementType) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) StatusException(com.prosysopc.ua.StatusException) MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) ServiceException(com.prosysopc.ua.ServiceException) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

Example 47 with StatusException

use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addConceptDescriptions.

/**
 * Adds the given list of AAS Concept Descriptions.
 *
 * @param descriptions The desired list of AAS Concept Descriptions
 * @throws StatusException If the operation fails
 */
private void addConceptDescriptions(List<ConceptDescription> descriptions) throws StatusException {
    try {
        // create folder DictionaryEntries
        final UaNode dictionariesFolder = getServer().getNodeManagerRoot().getNodeOrExternal(Identifiers.Dictionaries);
        // Folder for my objects
        final NodeId dictionarieEntriesFolderId = new NodeId(getNamespaceIndex(), "Dictionaries.DictionaryEntries");
        FolderTypeNode dictEntriesFolder = createInstance(FolderTypeNode.class, "DictionaryEntries", dictionarieEntriesFolderId);
        this.addNodeAndReference(dictionariesFolder, dictEntriesFolder, Identifiers.Organizes);
        for (ConceptDescription c : descriptions) {
            String name = c.getIdShort();
            NodeId nid = createNodeId(dictionariesFolder, name);
            DictionaryEntryType dictNode;
            switch(c.getIdentification().getIdType()) {
                case IRDI:
                    AASIrdiConceptDescriptionType irdiNode = createInstance(AASIrdiConceptDescriptionType.class, name, nid);
                    addIdentifiable(irdiNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(irdiNode, getReference(c));
                    dictEntriesFolder.addComponent(irdiNode);
                    dictionaryMap.put(getReference(c), irdiNode);
                    dictNode = irdiNode;
                    break;
                case IRI:
                    AASIriConceptDescriptionType iriNode = createInstance(AASIriConceptDescriptionType.class, name, nid);
                    addIdentifiable(iriNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(iriNode, getReference(c));
                    dictEntriesFolder.addComponent(iriNode);
                    dictionaryMap.put(getReference(c), iriNode);
                    dictNode = iriNode;
                    break;
                default:
                    AASCustomConceptDescriptionType customNode = createInstance(AASCustomConceptDescriptionType.class, name, nid);
                    addIdentifiable(customNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(customNode, getReference(c));
                    dictEntriesFolder.addComponent(customNode);
                    dictionaryMap.put(getReference(c), customNode);
                    dictNode = customNode;
                    break;
            }
            referableMap.put(AasUtils.toReference(c), new ObjectData(c, dictNode));
        }
    } catch (Exception ex) {
        LOG.error("addConceptDescriptions Exception", ex);
        throw ex;
    }
}
Also used : AASIriConceptDescriptionType(opc.i4aas.AASIriConceptDescriptionType) DictionaryEntryType(com.prosysopc.ua.types.opcua.DictionaryEntryType) AASCustomConceptDescriptionType(opc.i4aas.AASCustomConceptDescriptionType) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) UaNode(com.prosysopc.ua.nodes.UaNode) NodeManagerUaNode(com.prosysopc.ua.server.NodeManagerUaNode) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) FolderTypeNode(com.prosysopc.ua.types.opcua.server.FolderTypeNode) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) StatusException(com.prosysopc.ua.StatusException) MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) ServiceException(com.prosysopc.ua.ServiceException) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException) AASIrdiConceptDescriptionType(opc.i4aas.AASIrdiConceptDescriptionType)

Aggregations

StatusException (com.prosysopc.ua.StatusException)47 ServiceException (com.prosysopc.ua.ServiceException)43 AddressSpaceException (com.prosysopc.ua.client.AddressSpaceException)43 ServiceResultException (com.prosysopc.ua.stack.common.ServiceResultException)43 MessageBusException (de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException)42 UaNodeFactoryException (com.prosysopc.ua.nodes.UaNodeFactoryException)41 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)27 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)26 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)25 Reference (io.adminshell.aas.v3.model.Reference)25 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)24 LangString (io.adminshell.aas.v3.model.LangString)24 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)23 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)18 SubmodelElementData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)9 ArrayList (java.util.ArrayList)9 Constraint (io.adminshell.aas.v3.model.Constraint)8 UaNode (com.prosysopc.ua.nodes.UaNode)7 MethodManagerUaNode (com.prosysopc.ua.server.MethodManagerUaNode)7 NodeManagerUaNode (com.prosysopc.ua.server.NodeManagerUaNode)7