Search in sources :

Example 1 with NodeId

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

the class AasServiceNodeManager method setOperationArgument.

/**
 * Sets the arguments for the given Operation Variable.
 *
 * @param arg The UA argument
 * @param var The corresponding Operation Variable
 */
private void setOperationArgument(Argument arg, OperationVariable var) {
    try {
        if (var.getValue() instanceof Property) {
            Property prop = (Property) var.getValue();
            arg.setName(prop.getIdShort());
            arg.setValueRank(ValueRanks.Scalar);
            arg.setArrayDimensions(null);
            // Description
            addDescriptions(arg, prop.getDescriptions());
            NodeId type = ValueConverter.convertValueTypeStringToNodeId(prop.getValueType());
            if (type.isNullNodeId()) {
                logger.warn("setOperationArgument: Property " + prop.getIdShort() + ": Unknown type: " + prop.getValueType());
                // Default type is String. That's what we receive from the AAS Service
                arg.setDataType(Identifiers.String);
            } else {
                arg.setDataType(type);
            }
        } else {
            logger.warn("setOperationArgument: unknown Argument type");
        }
    } catch (Throwable ex) {
        logger.error("setOperationArgument Exception", ex);
        throw ex;
    }
}
Also used : NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) Property(io.adminshell.aas.v3.model.Property) MultiLanguageProperty(io.adminshell.aas.v3.model.MultiLanguageProperty) PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty)

Example 2 with NodeId

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

the class AasServiceNodeManager method addConceptDescriptionReference.

/**
 * Adds a reference to a ConceptDescription.
 *
 * @param node The desired UA node
 * @param ref The reference to create
 * @throws StatusException If the operation fails
 * @throws ServiceResultException Generic service exception
 */
private void addConceptDescriptionReference(UaNode node, Reference ref) throws StatusException, ServiceResultException {
    try {
        if (ref != null) {
            String name = "ConceptDescription";
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASMultiLanguagePropertyType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(node, browseName);
            AASReferenceType nodeRef = createInstance(AASReferenceTypeNode.class, nid, browseName, LocalizedText.english(name));
            setAasReferenceData(ref, nodeRef);
            node.addComponent(nodeRef);
            node.addReference(nodeRef, Identifiers.HasDictionaryEntry, false);
        }
    } catch (Throwable ex) {
        logger.error("addConceptDescriptionReference Exception", ex);
        throw ex;
    }
}
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) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString)

Example 3 with NodeId

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

the class AasServiceNodeManager method addIdentifierKeyValuePair.

/**
 * Adds an IdentifierKeyValuePair to the given Node.
 *
 * @param node The UA node in which the IdentifierKeyValuePair should be created
 * @param identifierPair The desired IdentifierKeyValuePair
 * @param name The desired name of the IdentifierKeyValuePair node
 * @param readOnly True if the value should be read-only
 * @throws StatusException If the operation fails
 */
private void addIdentifierKeyValuePair(UaNode node, IdentifierKeyValuePair identifierPair, String name, boolean readOnly) throws StatusException {
    if (node == null) {
        throw new IllegalArgumentException("node = null");
    } else if (identifierPair == null) {
        throw new IllegalArgumentException("identifierPair = null");
    }
    try {
        logger.info("addIdentifierKeyValuePair " + name + "; to Node: " + node.toString());
        QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASIdentifierKeyValuePairType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
        NodeId nid = createNodeId(node, browseName);
        AASIdentifierKeyValuePairType identifierPairNode = createInstance(AASIdentifierKeyValuePairType.class, nid, browseName, LocalizedText.english(name));
        setIdentifierKeyValuePairData(identifierPairNode, identifierPair, readOnly);
        node.addComponent(identifierPairNode);
    } catch (Throwable ex) {
        logger.error("addIdentifierKeyValuePair Exception", ex);
        throw ex;
    }
}
Also used : AASIdentifierKeyValuePairType(opc.i4aas.AASIdentifierKeyValuePairType) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId)

Example 4 with NodeId

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

the class AasServiceNodeManager method addAasBlob.

/**
 * Adds an AAS Blob to the given UA node.
 *
 * @param node The desired UA node
 * @param aasBlob The AAS blob to add
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param parentRef Tne reference to the parent object
 * @param ordered Specifies whether the blob 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 addAasBlob(UaNode node, Blob aasBlob, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    try {
        if ((node != null) && (aasBlob != null)) {
            String name = aasBlob.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASBlobType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASBlobType blobNode = createInstance(AASBlobType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(blobNode, aasBlob);
            // MimeType
            blobNode.setMimeType(aasBlob.getMimeType());
            Reference blobRef = AasUtils.toReference(parentRef, aasBlob);
            // Value
            if (aasBlob.getValue() != null) {
                if (blobNode.getValueNode() == null) {
                    addBlobValueNode(blobNode);
                }
                submodelElementAasMap.put(blobNode.getValueNode().getNodeId(), new SubmodelElementData(aasBlob, submodel, SubmodelElementData.Type.BLOB_VALUE, blobRef));
                logger.debug("addAasBlob: NodeId " + blobNode.getValueNode().getNodeId() + "; Blob: " + aasBlob);
                submodelElementOpcUAMap.put(blobRef, blobNode);
                blobNode.setValue(ByteString.valueOf(aasBlob.getValue()));
            }
            if (ordered) {
                node.addReference(blobNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(blobNode);
            }
            referableMap.put(blobRef, new ObjectData(aasBlob, blobNode, submodel));
        }
    } catch (Throwable ex) {
        logger.error("addAasBlob Exception", ex);
        throw ex;
    }
}
Also used : AASBlobType(opc.i4aas.AASBlobType) 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) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

Example 5 with NodeId

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

the class AasServiceNodeManager method addAasProperty.

/**
 * Adds an AAS property the given node.
 *
 * @param node The desired node
 * @param aasProperty The corresponding AAS property to add
 * @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 property should be added ordered
 *            (true) or unordered (false)
 */
private void addAasProperty(UaNode node, Property aasProperty, Submodel submodel, Reference parentRef, boolean ordered) {
    try {
        String name = aasProperty.getIdShort();
        QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASPropertyType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
        NodeId nid = getDefaultNodeId();
        AASPropertyType prop = createInstance(AASPropertyType.class, nid, browseName, LocalizedText.english(name));
        addSubmodelElementBaseData(prop, aasProperty);
        Reference propRef = AasUtils.toReference(parentRef, aasProperty);
        // ValueId
        Reference ref = aasProperty.getValueId();
        if (ref != null) {
            addAasReferenceAasNS(prop, ref, AASPropertyType.VALUE_ID);
        }
        // here Value and ValueType are set
        setPropertyValueAndType(aasProperty, submodel, prop, propRef);
        if (VALUES_READ_ONLY) {
            // ValueType read-only
            prop.getValueTypeNode().setAccessLevel(AccessLevelType.CurrentRead);
            // if the Submodel is null, we also make the value read-only
            if ((submodel == null) && (prop.getValueNode() != null)) {
                prop.getValueNode().setAccessLevel(AccessLevelType.CurrentRead);
            }
        }
        logger.info("addAasProperty: add Property " + nid.toString());
        if (ordered) {
            node.addReference(prop, Identifiers.HasOrderedComponent, false);
        } else {
            node.addComponent(prop);
        }
        referableMap.put(propRef, new ObjectData(aasProperty, prop, submodel));
    } catch (Throwable ex) {
        logger.error("addAasProperty Exception", 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) AASPropertyType(opc.i4aas.AASPropertyType) 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)

Aggregations

NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)79 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)59 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 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)16 ExpandedNodeId (com.prosysopc.ua.stack.builtintypes.ExpandedNodeId)15 LocalizedText (com.prosysopc.ua.stack.builtintypes.LocalizedText)12 DataValue (com.prosysopc.ua.stack.builtintypes.DataValue)10 PlainProperty (com.prosysopc.ua.server.nodes.PlainProperty)9 SubmodelElementData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)8