Search in sources :

Example 66 with NodeId

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

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

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

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

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

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