Search in sources :

Example 66 with QualifiedName

use of com.prosysopc.ua.stack.builtintypes.QualifiedName 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();
        LOG.info("addSubmodelReferences: add {} Submodels to Node: {}", submodelRefs.size(), node);
        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));
            LOG.info("addSubmodelReferences: add Node {} to Node {}", referenceListNode.getNodeId(), 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 {
                    LOG.warn("addSubmodelReferences: Submodel {} not found in submodelRefMap", ref);
                }
            }
        }
        if (added) {
            node.addComponent(referenceListNode);
        }
    } catch (Exception ex) {
        LOG.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) 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 67 with QualifiedName

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

the class AasServiceNodeManager method addAasRange.

/**
 * Adds an AAS range object to the given node.
 *
 * @param node The desired UA node
 * @param aasRange The corresponding AAS range object 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 range should be added ordered (true)
 *            or unordered (false)
 * @throws StatusException If the operation fails
 */
private void addAasRange(UaNode node, Range aasRange, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
    try {
        if ((node != null) && (aasRange != null)) {
            String name = aasRange.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASRangeType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASRangeType rangeNode = createInstance(AASRangeType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(rangeNode, aasRange);
            Reference rangeRef = AasUtils.toReference(parentRef, aasRange);
            setRangeValueAndType(aasRange, rangeNode, submodel, rangeRef);
            if (ordered) {
                node.addReference(rangeNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(rangeNode);
            }
            referableMap.put(rangeRef, new ObjectData(aasRange, rangeNode, submodel));
        }
    } catch (Exception ex) {
        LOG.error("addAasRange Exception", ex);
        throw ex;
    }
}
Also used : AASRangeType(opc.i4aas.AASRangeType) 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) 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 68 with QualifiedName

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

the class AasServiceNodeManager method addAssetInformation.

/**
 * Adds an AssetInformation object to the given Node.
 *
 * @param aasNode The AAS node where the AssetInformation should be added
 * @param assetInformation The desired AssetInformation object
 * @throws StatusException If the operation fails
 */
private void addAssetInformation(AASAssetAdministrationShellType aasNode, AssetInformation assetInformation) throws StatusException {
    if (aasNode == null) {
        throw new IllegalArgumentException("aasNode = null");
    } else if (assetInformation == null) {
        throw new IllegalArgumentException("assetInformation = null");
    }
    try {
        boolean created = false;
        AASAssetInformationType assetInfoNode;
        assetInfoNode = aasNode.getAssetInformationNode();
        if (assetInfoNode == null) {
            String displayName = "AssetInformation";
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelType.getNamespaceUri(), displayName).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(aasNode, browseName);
            assetInfoNode = createInstance(AASAssetInformationType.class, nid, browseName, LocalizedText.english(displayName));
            created = true;
        }
        if (assetInfoNode != null) {
            // AssetKind
            AssetKind assetKind = assetInformation.getAssetKind();
            assetInfoNode.setAssetKind(ValueConverter.convertAssetKind(assetKind));
            // BillOfMaterials
            List<Reference> assetBills = assetInformation.getBillOfMaterials();
            if ((assetBills != null) && (!assetBills.isEmpty())) {
                AASReferenceList assetBillsNode = assetInfoNode.getBillOfMaterialNode();
                addBillOfMaterials(assetBillsNode, assetBills);
            }
            // DefaultThumbnail
            File thumbnail = assetInformation.getDefaultThumbnail();
            if (thumbnail != null) {
                addAasFile(assetInfoNode, thumbnail, null, null, false, AASAssetInformationType.DEFAULT_THUMBNAIL);
            }
            // GlobalAssetId
            Reference globalAssetId = assetInformation.getGlobalAssetId();
            if (globalAssetId != null) {
                addAasReferenceAasNS(assetInfoNode, globalAssetId, AASAssetInformationType.GLOBAL_ASSET_ID);
            }
            // SpecificAssetIds
            List<IdentifierKeyValuePair> specificAssetIds = assetInformation.getSpecificAssetIds();
            if ((specificAssetIds != null) && (!specificAssetIds.isEmpty())) {
                addSpecificAssetIds(assetInfoNode, specificAssetIds, "SpecificAssetIds");
            }
            if (created) {
                aasNode.addComponent(assetInfoNode);
            }
        }
    } catch (Exception ex) {
        LOG.error("addAssetInformation Exception", ex);
        throw ex;
    }
}
Also used : IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) 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) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) AASAssetInformationType(opc.i4aas.AASAssetInformationType) 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) AssetKind(io.adminshell.aas.v3.model.AssetKind) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) AASReferenceList(opc.i4aas.AASReferenceList) File(io.adminshell.aas.v3.model.File)

Example 69 with QualifiedName

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

the class AasServiceNodeManager method addQualifierNode.

/**
 * Adds a QualifierNode to the given Node.
 *
 * @param node The desired base node
 */
private void addQualifierNode(UaNode node) {
    try {
        String name = AASSubmodelElementType.QUALIFIER;
        LOG.info("addQualifierNode {}; to Node: {}", name, node);
        QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASQualifierList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
        NodeId nid = createNodeId(node, browseName);
        AASQualifierList listNode = createInstance(AASQualifierList.class, nid, browseName, LocalizedText.english(name));
        node.addComponent(listNode);
    } catch (Exception ex) {
        LOG.error("addQualifierNode Exception", ex);
    }
}
Also used : UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) AASQualifierList(opc.i4aas.AASQualifierList) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) 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 70 with QualifiedName

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

the class AasServiceNodeManager method addAasEnvironmentNode.

/**
 * Adds the AASEnvironment Node.
 */
private void addAasEnvironmentNode() {
    try {
        final UaObject objectsFolder = getServer().getNodeManagerRoot().getObjectsFolder();
        if (aasEnvironment != null) {
            String name = "AASEnvironment";
            LOG.info("addAasEnvironmentNode {}; to ObjectsFolder", name);
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASEnvironmentType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(objectsFolder, browseName);
            FolderType ft = createInstance(AASEnvironmentType.class, nid, browseName, LocalizedText.english(name));
            LOG.info("addAasEnvironmentNode: Created class: {}", ft.getClass().getName());
            aasEnvironmentNode = (AASEnvironmentType) ft;
            objectsFolder.addComponent(aasEnvironmentNode);
        }
    } catch (Exception ex) {
        LOG.error("addAasEnvironmentNode Exception", ex);
        throw ex;
    }
}
Also used : UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) UaObject(com.prosysopc.ua.nodes.UaObject) 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) FolderType(com.prosysopc.ua.types.opcua.FolderType)

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