Search in sources :

Example 61 with QualifiedName

use of com.prosysopc.ua.stack.builtintypes.QualifiedName in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addAasSubmodelElementCollection.

/**
 * Adds a SubmodelElementCollection to the given node.
 *
 * @param node The desired UA node
 * @param aasColl The corresponding SubmodelElementCollection to add
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param parentRef The AAS reference to the parent object
 * @param ordered Specifies whether the entity should be added ordered
 *            (true) or unordered (false)
 * @throws StatusException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws AddressSpaceException If the operation fails
 * @throws ServiceResultException If the operation fails
 */
private void addAasSubmodelElementCollection(UaNode node, SubmodelElementCollection aasColl, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    try {
        if ((node != null) && (aasColl != null)) {
            String name = aasColl.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelElementCollectionType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASSubmodelElementCollectionType collNode;
            if (aasColl.getOrdered()) {
                collNode = createAasOrderedSubmodelElementCollection(name, nid);
            } else {
                collNode = createInstance(AASSubmodelElementCollectionType.class, nid, browseName, LocalizedText.english(name));
            }
            addSubmodelElementBaseData(collNode, aasColl);
            // AllowDuplicates
            if (collNode.getAllowDuplicatesNode() == null) {
                NodeId myPropertyId = new NodeId(getNamespaceIndex(), collNode.getNodeId().getValue().toString() + "." + AASSubmodelElementCollectionType.ALLOW_DUPLICATES);
                PlainProperty<Boolean> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelElementCollectionType.getNamespaceUri(), AASSubmodelElementCollectionType.ALLOW_DUPLICATES).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASSubmodelElementCollectionType.ALLOW_DUPLICATES));
                myProperty.setDataTypeId(Identifiers.Boolean);
                myProperty.setDescription(new LocalizedText("", ""));
                if (VALUES_READ_ONLY) {
                    myProperty.setAccessLevel(AccessLevelType.CurrentRead);
                }
                collNode.addProperty(myProperty);
            }
            collNode.setAllowDuplicates(aasColl.getAllowDuplicates());
            Reference collRef = AasUtils.toReference(parentRef, aasColl);
            // SubmodelElements
            addSubmodelElements(collNode, aasColl.getValues(), submodel, collRef, aasColl.getOrdered());
            if (ordered) {
                node.addReference(collNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(collNode);
            }
            referableMap.put(collRef, new ObjectData(aasColl, collNode, submodel));
        }
    } catch (Exception ex) {
        LOG.error("createAasSubmodelElementCollection Exception", ex);
        throw ex;
    }
}
Also used : PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) 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) AASSubmodelElementCollectionType(opc.i4aas.AASSubmodelElementCollectionType) 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)

Example 62 with QualifiedName

use of com.prosysopc.ua.stack.builtintypes.QualifiedName 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 63 with QualifiedName

use of com.prosysopc.ua.stack.builtintypes.QualifiedName 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 64 with QualifiedName

use of com.prosysopc.ua.stack.builtintypes.QualifiedName 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)

Example 65 with QualifiedName

use of com.prosysopc.ua.stack.builtintypes.QualifiedName in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addAasReference.

/**
 * Adds an AAS Reference to the given node with the given namespace.
 *
 * @param node The node in which the object is created
 * @param ref The desired AAS reference object to add
 * @param name The desired name
 * @param namespaceUri The desired namespace URI tu use
 * @param readOnly True if the value should be read-only
 * @return The created node
 * @throws StatusException If the operation fails
 */
private UaNode addAasReference(UaNode node, Reference ref, String name, String namespaceUri, boolean readOnly) throws StatusException {
    UaNode retval = null;
    try {
        if (ref != null) {
            QualifiedName browseName = UaQualifiedName.from(namespaceUri, name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASReferenceType nodeRef = createInstance(AASReferenceType.class, nid, browseName, LocalizedText.english(name));
            LOG.debug("addAasReference: add Node {} to Node {}", nid, node.getNodeId());
            setAasReferenceData(ref, nodeRef, readOnly);
            node.addComponent(nodeRef);
            retval = nodeRef;
        }
    } catch (Exception ex) {
        LOG.error("addAasReference Exception", ex);
        throw ex;
    }
    return retval;
}
Also used : AASReferenceType(opc.i4aas.AASReferenceType) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) UaNode(com.prosysopc.ua.nodes.UaNode) NodeManagerUaNode(com.prosysopc.ua.server.NodeManagerUaNode) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) 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

QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)74 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)60 RelativePathElement (com.prosysopc.ua.stack.core.RelativePathElement)46 ArrayList (java.util.ArrayList)46 BrowsePathResult (com.prosysopc.ua.stack.core.BrowsePathResult)45 RelativePath (com.prosysopc.ua.stack.core.RelativePath)45 BrowsePathTarget (com.prosysopc.ua.stack.core.BrowsePathTarget)40 StatusException (com.prosysopc.ua.StatusException)29 ServiceException (com.prosysopc.ua.ServiceException)28 AddressSpaceException (com.prosysopc.ua.client.AddressSpaceException)28 ServiceResultException (com.prosysopc.ua.stack.common.ServiceResultException)28 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)27 UaNodeFactoryException (com.prosysopc.ua.nodes.UaNodeFactoryException)27 MessageBusException (de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException)27 LangString (io.adminshell.aas.v3.model.LangString)27 UaClient (com.prosysopc.ua.client.UaClient)26 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)26 Test (org.junit.Test)26 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)24 Reference (io.adminshell.aas.v3.model.Reference)19