Search in sources :

Example 71 with NodeId

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

the class AasServiceNodeManager method addQualifier.

/**
 * Creates and adds a Qualifier to the given Node.
 *
 * @param node The UA node in which the Qualifier should be created
 * @param qualifier The desired Qualifier
 * @param name The name of the qualifier
 */
private void addQualifier(UaNode node, Qualifier qualifier, String name) throws StatusException {
    if (node == null) {
        throw new IllegalArgumentException(NODE_NULL);
    } else if (qualifier == null) {
        throw new IllegalArgumentException("qualifier = null");
    }
    try {
        LOG.info("addQualifier {}; to Node: {}", name, node);
        QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASQualifierType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
        NodeId nid = createNodeId(node, browseName);
        AASQualifierType qualifierNode = createInstance(AASQualifierType.class, nid, browseName, LocalizedText.english(name));
        // Type
        qualifierNode.setType(qualifier.getType());
        // ValueType
        qualifierNode.setValueType(ValueConverter.stringToValueType(qualifier.getValueType()));
        // Value
        if (qualifier.getValue() != null) {
            if (qualifierNode.getValueNode() == null) {
                addQualifierValueNode(qualifierNode);
            }
            qualifierNode.setValue(qualifier.getValue());
        }
        // ValueId
        if (qualifier.getValueId() != null) {
            addAasReferenceAasNS(qualifierNode, qualifier.getValueId(), AASQualifierType.VALUE_ID);
        }
        if (VALUES_READ_ONLY) {
            if (qualifierNode.getValueNode() != null) {
                qualifierNode.getValueNode().setAccessLevel(AccessLevelType.CurrentRead);
            }
            if (qualifierNode.getValueTypeNode() != null) {
                qualifierNode.getValueTypeNode().setAccessLevel(AccessLevelType.CurrentRead);
            }
            if (qualifierNode.getTypeNode() != null) {
                qualifierNode.getTypeNode().setAccessLevel(AccessLevelType.CurrentRead);
            }
        }
        node.addComponent(qualifierNode);
    } catch (Exception ex) {
        LOG.error("addQualifier Exception", ex);
        throw ex;
    }
}
Also used : AASQualifierType(opc.i4aas.AASQualifierType) 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 72 with NodeId

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

the class AasServiceNodeManager method addAssetAdministrationShell.

/**
 * Adds the given AssetAdministrationShell.
 *
 * @throws StatusException If the operation fails
 */
private void addAssetAdministrationShell(AssetAdministrationShell aas) throws StatusException {
    try {
        TypeDefinitionBasedNodeBuilderConfiguration.Builder conf = TypeDefinitionBasedNodeBuilderConfiguration.builder();
        Reference derivedFrom = aas.getDerivedFrom();
        if (derivedFrom != null) {
            UaBrowsePath bp = UaBrowsePath.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAssetAdministrationShellType.DERIVED_FROM));
            conf.addOptional(bp);
        }
        this.setNodeBuilderConfiguration(conf.build());
        QualifiedName browseName = UaQualifiedName.from(NAMESPACE_URI, aas.getIdShort()).toQualifiedName(getNamespaceTable());
        String displayName = "AAS:" + aas.getIdShort();
        NodeId nid = new NodeId(getNamespaceIndex(), aas.getIdShort());
        if (findNode(nid) != null) {
            // The NodeId already exists
            nid = getDefaultNodeId();
        }
        AASAssetAdministrationShellType aasShell = createInstance(AASAssetAdministrationShellTypeNode.class, nid, browseName, LocalizedText.english(displayName));
        addIdentifiable(aasShell, aas.getIdentification(), aas.getAdministration(), aas.getCategory());
        // DataSpecifications
        addEmbeddedDataSpecifications(aasShell, aas.getEmbeddedDataSpecifications());
        // AssetInformation
        AssetInformation assetInformation = aas.getAssetInformation();
        if (assetInformation != null) {
            addAssetInformation(aasShell, assetInformation);
        }
        // submodel references
        List<Reference> submodelRefs = aas.getSubmodels();
        if ((submodelRefs != null) && (!submodelRefs.isEmpty())) {
            addSubmodelReferences(aasShell, submodelRefs);
        }
        // add AAS to Environment
        addNodeAndReference(aasEnvironmentNode, aasShell, Identifiers.Organizes);
        referableMap.put(AasUtils.toReference(aas), new ObjectData(aas, aasShell));
    } catch (Exception ex) {
        LOG.error("addAssetAdministrationShell Exception", ex);
        throw ex;
    }
}
Also used : AssetInformation(io.adminshell.aas.v3.model.AssetInformation) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) 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) TypeDefinitionBasedNodeBuilderConfiguration(com.prosysopc.ua.server.instantiation.TypeDefinitionBasedNodeBuilderConfiguration) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) UaBrowsePath(com.prosysopc.ua.UaBrowsePath) 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 73 with NodeId

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

the class AasServiceNodeManager method addFileValueNode.

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

Example 74 with NodeId

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

the class AasServiceNodeManager method addBlobValueNode.

/**
 * Adds a Value Property to the given Blob Node.
 *
 * @param node The desired Blob Node
 */
private void addBlobValueNode(UaNode node) {
    try {
        NodeId myPropertyId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASBlobType.VALUE);
        PlainProperty<ByteString> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASBlobType.getNamespaceUri(), AASBlobType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASBlobType.VALUE));
        myProperty.setDataTypeId(Identifiers.ByteString);
        myProperty.setDescription(new LocalizedText("", ""));
        node.addProperty(myProperty);
    } catch (Exception ex) {
        LOG.error("addBlobValueNode 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 75 with NodeId

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

the class AasServiceNodeManager method addAasReferenceElement.

/**
 * Adds an AAS reference element to the given node.
 *
 * @param node The desired UA node
 * @param aasRefElem The AAS reference element 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 reference element should be added
 *            ordered (true) or unordered (false)
 * @throws StatusException If the operation fails
 */
private void addAasReferenceElement(UaNode node, ReferenceElement aasRefElem, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
    try {
        if ((node != null) && (aasRefElem != null)) {
            String name = aasRefElem.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASReferenceElementType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASReferenceElementType refElemNode = createInstance(AASReferenceElementType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(refElemNode, aasRefElem);
            if (aasRefElem.getValue() != null) {
                setAasReferenceData(aasRefElem.getValue(), refElemNode.getValueNode(), false);
            }
            Reference refElemRef = AasUtils.toReference(parentRef, aasRefElem);
            submodelElementAasMap.put(refElemNode.getValueNode().getKeysNode().getNodeId(), new SubmodelElementData(aasRefElem, submodel, SubmodelElementData.Type.REFERENCE_ELEMENT_VALUE, refElemRef));
            submodelElementOpcUAMap.put(refElemRef, refElemNode);
            if (ordered) {
                node.addReference(refElemNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(refElemNode);
            }
            referableMap.put(refElemRef, new ObjectData(aasRefElem, refElemNode, submodel));
        }
    } catch (Exception ex) {
        LOG.error("addAasReferenceElement 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) 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) AASReferenceElementType(opc.i4aas.AASReferenceElementType) 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) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

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