Search in sources :

Example 26 with StatusException

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

the class AasServiceNodeManager method createAnnotatedRelationshipElement.

/**
 * Creates an Annotated Relationship Element.
 *
 * @param aasRelElem The AAS Annotated Relationship Element
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param relElemRef The AAS reference to the AnnotatedRelationshipElement
 * @param nodeId The desired NodeId for the node to be created
 * @return The create UA Annotated Relationship Element
 * @throws StatusException If the operation fails
 */
private AASRelationshipElementType createAnnotatedRelationshipElement(AnnotatedRelationshipElement aasRelElem, Submodel submodel, Reference relElemRef, NodeId nodeId) throws StatusException {
    AASRelationshipElementType retval = null;
    try {
        AASAnnotatedRelationshipElementType relElemNode = createInstance(AASAnnotatedRelationshipElementType.class, nodeId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAnnotatedRelationshipElementType.getNamespaceUri(), aasRelElem.getIdShort()).toQualifiedName(getNamespaceTable()), LocalizedText.english(aasRelElem.getIdShort()));
        // Annotations
        for (DataElement de : aasRelElem.getAnnotations()) {
            addAasDataElement(relElemNode.getAnnotationNode(), de, submodel, relElemRef, false);
        }
        retval = relElemNode;
    } catch (Exception ex) {
        LOG.error("createAnnotatedRelationshipElement Exception", ex);
        throw ex;
    }
    return retval;
}
Also used : DataElement(io.adminshell.aas.v3.model.DataElement) AASAnnotatedRelationshipElementType(opc.i4aas.AASAnnotatedRelationshipElementType) AASRelationshipElementType(opc.i4aas.AASRelationshipElementType) 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)

Example 27 with StatusException

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

the class AasServiceNodeManager method addEmbeddedDataSpecificationsReferences.

/**
 * Adds the references to the given Embedded Data Specification references.
 *
 * @param refListNode The desired object where the DataSpecifications should be added
 * @param refList The list of the desired Data Specification references
 * @throws StatusException If the operation fails
 */
private void addEmbeddedDataSpecificationsReferences(AASReferenceList refListNode, List<Reference> refList) throws StatusException {
    try {
        if ((refListNode != null) && (!refList.isEmpty())) {
            int count = 0;
            for (Reference ref : refList) {
                count++;
                String name = AASAssetAdministrationShellType.DATA_SPECIFICATION;
                if (count > 1) {
                    name += count;
                }
                addAasReferenceAasNS(refListNode, ref, name);
            }
        }
    } catch (Exception ex) {
        LOG.error(ADD_EMBED_DS_EXC, ex);
        throw ex;
    }
}
Also used : Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) Constraint(io.adminshell.aas.v3.model.Constraint) 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)

Example 28 with StatusException

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

the class AasServiceNodeManager method addAasReferenceList.

/**
 * Creates a node with the given name and adds the given list of references.
 *
 * @param node The UA node in which the list of references should be created
 * @param list The desired list of references
 * @param name The desired name of the Node
 * @throws StatusException If the operation fails
 */
private void addAasReferenceList(UaNode node, List<Reference> list, String name) throws StatusException {
    if (node == null) {
        throw new IllegalArgumentException(NODE_NULL);
    } else if (list == null) {
        throw new IllegalArgumentException("list = null");
    }
    try {
        LOG.info("addAasReferenceList {}; to Node: {}", name, node);
        QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASReferenceList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
        NodeId nid = getDefaultNodeId();
        AASReferenceList referenceListNode = createInstance(AASReferenceList.class, nid, browseName, LocalizedText.english(name));
        int counter = 1;
        for (Reference ref : list) {
            addAasReferenceAasNS(referenceListNode, ref, name + counter++);
        }
        node.addComponent(referenceListNode);
    } catch (Exception ex) {
        LOG.error("addAasReferenceList 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) Constraint(io.adminshell.aas.v3.model.Constraint) 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)

Example 29 with StatusException

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

the class AasServiceNodeManager method addAasFile.

/**
 * Adds an AAS file to the given node.
 *
 * @param node The desired UA node
 * @param aasFile The AAS file object
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param parentRef The AAS reference to the parent node
 * @param ordered Specifies whether the file should be added ordered (true) or unordered (false)
 * @param nodeName The desired Name of the node. If this value is not set,
 *            the IdShort of the file is used.
 * @throws StatusException If the operation fails
 */
private void addAasFile(UaNode node, File aasFile, Submodel submodel, Reference parentRef, boolean ordered, String nodeName) throws StatusException {
    try {
        if ((node != null) && (aasFile != null)) {
            String name = aasFile.getIdShort();
            if ((nodeName != null) && (!nodeName.isEmpty())) {
                name = nodeName;
            }
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASFileType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASFileType fileNode = createInstance(AASFileType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(fileNode, aasFile);
            // MimeType
            if (!aasFile.getMimeType().isEmpty()) {
                fileNode.setMimeType(aasFile.getMimeType());
            }
            // Value
            if (aasFile.getValue() != null) {
                if (fileNode.getValueNode() == null) {
                    addFileValueNode(fileNode);
                }
                fileNode.setValue(aasFile.getValue());
                if (!aasFile.getValue().isEmpty()) {
                    java.io.File f = new java.io.File(aasFile.getValue());
                    if (!f.exists()) {
                        LOG.warn("addAasFile: File '{}' does not exist!", f.getAbsolutePath());
                    } else {
                        // File Object: include only when the file exists
                        QualifiedName fileBrowseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASFileType.getNamespaceUri(), AASFileType.FILE).toQualifiedName(getNamespaceTable());
                        NodeId fileId = new NodeId(getNamespaceIndex(), fileNode.getNodeId().getValue().toString() + "." + AASFileType.FILE);
                        FileTypeNode fileType = createInstance(FileTypeNode.class, fileId, fileBrowseName, LocalizedText.english(AASFileType.FILE));
                        fileType.setFile(new java.io.File(aasFile.getValue()));
                        fileType.setWritable(false);
                        fileType.setUserWritable(false);
                        if (fileType.getNodeVersion() != null) {
                            fileType.getNodeVersion().setDescription(new LocalizedText("", ""));
                        }
                        fileNode.addReference(fileType, Identifiers.HasAddIn, false);
                    }
                }
            }
            if (ordered) {
                node.addReference(fileNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(fileNode);
            }
            if (parentRef != null) {
                Reference fileRef = AasUtils.toReference(parentRef, aasFile);
                referableMap.put(fileRef, new ObjectData(aasFile, fileNode, submodel));
            }
        }
    } catch (Exception ex) {
        LOG.error("addAasFile Exception", ex);
        throw ex;
    }
}
Also used : AASFileType(opc.i4aas.AASFileType) 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) 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) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText) 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) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) FileTypeNode(com.prosysopc.ua.types.opcua.server.FileTypeNode) File(io.adminshell.aas.v3.model.File)

Example 30 with StatusException

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

the class AasServiceNodeManager method addSpecificAssetIds.

/**
 * Adds a list of IdentifierKeyValuePairs to the given Node.
 *
 * @param assetInfoNode The AssetInformation node in which the
 *            IdentifierKeyValuePairs should be created or added
 * @param list The desired list of IdentifierKeyValuePairs
 * @param name The desired name of the Node
 * @throws StatusException If the operation fails
 */
private void addSpecificAssetIds(AASAssetInformationType assetInfoNode, List<IdentifierKeyValuePair> list, String name) throws StatusException {
    if (assetInfoNode == null) {
        throw new IllegalArgumentException("assetInfoNode = null");
    } else if (list == null) {
        throw new IllegalArgumentException("list = null");
    }
    try {
        LOG.info("addSpecificAssetIds {}; to Node: {}", name, assetInfoNode);
        AASIdentifierKeyValuePairList listNode = assetInfoNode.getSpecificAssetIdNode();
        boolean created = false;
        if (listNode == null) {
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASIdentifierKeyValuePairList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(assetInfoNode, browseName);
            listNode = createInstance(AASIdentifierKeyValuePairList.class, nid, browseName, LocalizedText.english(name));
            created = true;
        }
        for (IdentifierKeyValuePair ikv : list) {
            if (ikv != null) {
                addIdentifierKeyValuePair(listNode, ikv, ikv.getKey());
            }
        }
        if (created) {
            assetInfoNode.addComponent(listNode);
        }
    } catch (Exception ex) {
        LOG.error("addSpecificAssetIds Exception", ex);
        throw ex;
    }
}
Also used : IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) AASIdentifierKeyValuePairList(opc.i4aas.AASIdentifierKeyValuePairList) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) 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)

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