Search in sources :

Example 76 with NodeId

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

the class AasServiceNodeManager method addAdminInformationProperties.

/**
 * Adds the AdminInformation Properties to the given node (if they don't
 * exist).
 *
 * @param adminInfNode The desired AdminInformation node
 * @param info The corresponding AAS AdministrativeInformation object
 */
private void addAdminInformationProperties(AASAdministrativeInformationType adminInfNode, AdministrativeInformation info) {
    try {
        if ((adminInfNode != null) && (info != null)) {
            if (info.getVersion() != null) {
                if (adminInfNode.getVersionNode() == null) {
                    NodeId myPropertyId = new NodeId(getNamespaceIndex(), adminInfNode.getNodeId().getValue().toString() + "." + AASAdministrativeInformationType.VERSION);
                    PlainProperty<String> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAdministrativeInformationType.VERSION).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASAdministrativeInformationType.VERSION));
                    myProperty.setDataTypeId(Identifiers.String);
                    if (VALUES_READ_ONLY) {
                        myProperty.setAccessLevel(AccessLevelType.CurrentRead);
                    }
                    myProperty.setDescription(new LocalizedText("", ""));
                    adminInfNode.addProperty(myProperty);
                }
                adminInfNode.setVersion(info.getVersion());
            }
            if (info.getRevision() != null) {
                if (adminInfNode.getRevisionNode() == null) {
                    NodeId myPropertyId = new NodeId(getNamespaceIndex(), adminInfNode.getNodeId().getValue().toString() + "." + AASAdministrativeInformationType.REVISION);
                    PlainProperty<String> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAdministrativeInformationType.REVISION).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASAdministrativeInformationType.REVISION));
                    myProperty.setDataTypeId(Identifiers.String);
                    if (VALUES_READ_ONLY) {
                        myProperty.setAccessLevel(AccessLevelType.CurrentRead);
                    }
                    myProperty.setDescription(new LocalizedText("", ""));
                    adminInfNode.addProperty(myProperty);
                }
                adminInfNode.setRevision(info.getRevision());
            }
        }
    } catch (Exception ex) {
        LOG.error("addAdminInfProperties Exception", 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 77 with NodeId

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

the class AasServiceNodeManager method addConceptDescriptions.

/**
 * Adds the given list of AAS Concept Descriptions.
 *
 * @param descriptions The desired list of AAS Concept Descriptions
 * @throws StatusException If the operation fails
 */
private void addConceptDescriptions(List<ConceptDescription> descriptions) throws StatusException {
    try {
        // create folder DictionaryEntries
        final UaNode dictionariesFolder = getServer().getNodeManagerRoot().getNodeOrExternal(Identifiers.Dictionaries);
        // Folder for my objects
        final NodeId dictionarieEntriesFolderId = new NodeId(getNamespaceIndex(), "Dictionaries.DictionaryEntries");
        FolderTypeNode dictEntriesFolder = createInstance(FolderTypeNode.class, "DictionaryEntries", dictionarieEntriesFolderId);
        this.addNodeAndReference(dictionariesFolder, dictEntriesFolder, Identifiers.Organizes);
        for (ConceptDescription c : descriptions) {
            String name = c.getIdShort();
            NodeId nid = createNodeId(dictionariesFolder, name);
            DictionaryEntryType dictNode;
            switch(c.getIdentification().getIdType()) {
                case IRDI:
                    AASIrdiConceptDescriptionType irdiNode = createInstance(AASIrdiConceptDescriptionType.class, name, nid);
                    addIdentifiable(irdiNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(irdiNode, getReference(c));
                    dictEntriesFolder.addComponent(irdiNode);
                    dictionaryMap.put(getReference(c), irdiNode);
                    dictNode = irdiNode;
                    break;
                case IRI:
                    AASIriConceptDescriptionType iriNode = createInstance(AASIriConceptDescriptionType.class, name, nid);
                    addIdentifiable(iriNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(iriNode, getReference(c));
                    dictEntriesFolder.addComponent(iriNode);
                    dictionaryMap.put(getReference(c), iriNode);
                    dictNode = iriNode;
                    break;
                default:
                    AASCustomConceptDescriptionType customNode = createInstance(AASCustomConceptDescriptionType.class, name, nid);
                    addIdentifiable(customNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(customNode, getReference(c));
                    dictEntriesFolder.addComponent(customNode);
                    dictionaryMap.put(getReference(c), customNode);
                    dictNode = customNode;
                    break;
            }
            referableMap.put(AasUtils.toReference(c), new ObjectData(c, dictNode));
        }
    } catch (Exception ex) {
        LOG.error("addConceptDescriptions Exception", ex);
        throw ex;
    }
}
Also used : AASIriConceptDescriptionType(opc.i4aas.AASIriConceptDescriptionType) DictionaryEntryType(com.prosysopc.ua.types.opcua.DictionaryEntryType) AASCustomConceptDescriptionType(opc.i4aas.AASCustomConceptDescriptionType) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) UaNode(com.prosysopc.ua.nodes.UaNode) NodeManagerUaNode(com.prosysopc.ua.server.NodeManagerUaNode) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) FolderTypeNode(com.prosysopc.ua.types.opcua.server.FolderTypeNode) 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) AASIrdiConceptDescriptionType(opc.i4aas.AASIrdiConceptDescriptionType)

Example 78 with NodeId

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

the class AasServiceNodeManager method setPropertyValueAndType.

/**
 * Adds the OPC UA property itself to the given Property object and sets the value.
 *
 * @param aasProperty The AAS property
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param prop The UA Property object
 * @param propRef The AAS reference to the property
 */
@SuppressWarnings("java:S125")
private void setPropertyValueAndType(Property aasProperty, Submodel submodel, AASPropertyType prop, Reference propRef) {
    try {
        NodeId myPropertyId = new NodeId(getNamespaceIndex(), prop.getNodeId().getValue().toString() + "." + AASPropertyType.VALUE);
        QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASPropertyType.getNamespaceUri(), AASPropertyType.VALUE).toQualifiedName(getNamespaceTable());
        LocalizedText displayName = LocalizedText.english(AASPropertyType.VALUE);
        submodelElementAasMap.put(myPropertyId, new SubmodelElementData(aasProperty, submodel, SubmodelElementData.Type.PROPERTY_VALUE, propRef));
        LOG.debug("setPropertyValueAndType: NodeId {}; Property: {}", myPropertyId, aasProperty);
        if (submodel != null) {
            submodelElementOpcUAMap.put(propRef, prop);
        }
        AASValueTypeDataType valueDataType;
        PropertyValue typedValue = PropertyValue.of(aasProperty.getValueType(), aasProperty.getValue());
        if ((typedValue != null) && (typedValue.getValue() != null)) {
            valueDataType = ValueConverter.datatypeToValueType(typedValue.getValue().getDataType());
        } else {
            valueDataType = ValueConverter.stringToValueType(aasProperty.getValueType());
        }
        prop.setValueType(valueDataType);
        switch(valueDataType) {
            // 
            case Boolean:
                PlainProperty<Boolean> myBoolProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                myBoolProperty.setDataTypeId(Identifiers.Boolean);
                if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
                    myBoolProperty.setValue(typedValue.getValue().getValue());
                }
                prop.addProperty(myBoolProperty);
                break;
            // 
            case Int32:
                PlainProperty<Integer> myIntProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                myIntProperty.setDataTypeId(Identifiers.Int32);
                if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
                    myIntProperty.setValue(typedValue.getValue().getValue());
                }
                prop.addProperty(myIntProperty);
                break;
            // 
            case Int64:
                PlainProperty<Long> myLongProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                myLongProperty.setDataTypeId(Identifiers.Int64);
                if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
                    Object obj = typedValue.getValue().getValue();
                    if (!(obj instanceof Long)) {
                        obj = Long.parseLong(obj.toString());
                    }
                    myLongProperty.setValue(obj);
                }
                prop.addProperty(myLongProperty);
                break;
            // 
            case Int16:
                PlainProperty<Short> myInt16Property = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                myInt16Property.setDataTypeId(Identifiers.Int16);
                if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
                    myInt16Property.setValue(typedValue.getValue().getValue());
                }
                prop.addProperty(myInt16Property);
                break;
            // 
            case SByte:
                PlainProperty<Byte> mySByteProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                mySByteProperty.setDataTypeId(Identifiers.SByte);
                if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
                    mySByteProperty.setValue(typedValue.getValue().getValue());
                }
                prop.addProperty(mySByteProperty);
                break;
            case Double:
                PlainProperty<Double> myDoubleProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                myDoubleProperty.setDataTypeId(Identifiers.Double);
                if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
                    myDoubleProperty.setValue(typedValue.getValue().getValue());
                }
                prop.addProperty(myDoubleProperty);
                break;
            case Float:
                PlainProperty<Float> myFloatProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                myFloatProperty.setDataTypeId(Identifiers.Float);
                if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
                    myFloatProperty.setValue(typedValue.getValue().getValue());
                }
                prop.addProperty(myFloatProperty);
                break;
            // 
            case String:
                PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                myStringProperty.setDataTypeId(Identifiers.String);
                if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
                    myStringProperty.setValue(typedValue.getValue().getValue());
                }
                prop.addProperty(myStringProperty);
                break;
            // 
            default:
                LOG.warn("setValueAndType: Property {}: Unknown type: {}; use string as default", prop.getBrowseName().getName(), aasProperty.getValueType());
                PlainProperty<String> myDefaultProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
                myDefaultProperty.setDataTypeId(Identifiers.String);
                myDefaultProperty.setValue(aasProperty.getValue());
                prop.addProperty(myDefaultProperty);
                break;
        }
        if ((prop.getValueNode() != null) && (prop.getValueNode().getDescription() == null)) {
            prop.getValueNode().setDescription(new LocalizedText("", ""));
        }
    } catch (Exception ex) {
        LOG.error("setPropertyValueAndType Exception", ex);
    }
}
Also used : ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText) AASValueTypeDataType(opc.i4aas.AASValueTypeDataType) PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) MultiLanguagePropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.MultiLanguagePropertyValue) 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) UnsignedInteger(com.prosysopc.ua.stack.builtintypes.UnsignedInteger) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) UaObject(com.prosysopc.ua.nodes.UaObject) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

Example 79 with NodeId

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

the class AASOperationTypeImplBase method operation.

@Override
public void operation() throws MethodCallStatusException, ServiceException {
    NodeId methodId = getComponentId(getQualifiedName("http://opcfoundation.org/UA/I4AAS/V3/", "Operation"));
    call(methodId);
}
Also used : NodeId(com.prosysopc.ua.stack.builtintypes.NodeId)

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