Search in sources :

Example 61 with NodeId

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

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

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

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

the class AasServiceNodeManager method addQualifierValueNode.

/**
 * Adds a Value Property to the given Qualifier Node.
 *
 * @param node The desired Blob Node
 */
private void addQualifierValueNode(UaNode node) {
    try {
        NodeId myPropertyId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASQualifierType.VALUE);
        PlainProperty<ByteString> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASQualifierType.getNamespaceUri(), AASQualifierType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASQualifierType.VALUE));
        myProperty.setDataTypeId(Identifiers.String);
        if (VALUES_READ_ONLY) {
            myProperty.setAccessLevel(AccessLevelType.CurrentRead);
        }
        myProperty.setDescription(new LocalizedText("", ""));
        node.addProperty(myProperty);
    } catch (Exception ex) {
        LOG.error("addQualifierValueNode Exception", ex);
        throw ex;
    }
}
Also used : PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) 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 65 with NodeId

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

NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)79 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)59 StatusException (com.prosysopc.ua.StatusException)37 ServiceException (com.prosysopc.ua.ServiceException)35 AddressSpaceException (com.prosysopc.ua.client.AddressSpaceException)35 UaNodeFactoryException (com.prosysopc.ua.nodes.UaNodeFactoryException)35 ServiceResultException (com.prosysopc.ua.stack.common.ServiceResultException)35 MessageBusException (de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException)35 ArrayList (java.util.ArrayList)33 BrowsePathTarget (com.prosysopc.ua.stack.core.BrowsePathTarget)32 RelativePathElement (com.prosysopc.ua.stack.core.RelativePathElement)32 BrowsePathResult (com.prosysopc.ua.stack.core.BrowsePathResult)31 RelativePath (com.prosysopc.ua.stack.core.RelativePath)31 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)29 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)27 LangString (io.adminshell.aas.v3.model.LangString)27 UaClient (com.prosysopc.ua.client.UaClient)19 Test (org.junit.Test)19 Reference (io.adminshell.aas.v3.model.Reference)17 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)17