Search in sources :

Example 6 with PlainProperty

use of com.prosysopc.ua.server.nodes.PlainProperty 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 7 with PlainProperty

use of com.prosysopc.ua.server.nodes.PlainProperty 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 8 with PlainProperty

use of com.prosysopc.ua.server.nodes.PlainProperty 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)

Aggregations

ServiceException (com.prosysopc.ua.ServiceException)8 StatusException (com.prosysopc.ua.StatusException)8 AddressSpaceException (com.prosysopc.ua.client.AddressSpaceException)8 UaNodeFactoryException (com.prosysopc.ua.nodes.UaNodeFactoryException)8 PlainProperty (com.prosysopc.ua.server.nodes.PlainProperty)8 LocalizedText (com.prosysopc.ua.stack.builtintypes.LocalizedText)8 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)8 ServiceResultException (com.prosysopc.ua.stack.common.ServiceResultException)8 MessageBusException (de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException)8 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)7 LangString (io.adminshell.aas.v3.model.LangString)5 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)3 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)3 UaObject (com.prosysopc.ua.nodes.UaObject)2 UnsignedInteger (com.prosysopc.ua.stack.builtintypes.UnsignedInteger)2 SubmodelElementData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)2 AASValueTypeDataType (opc.i4aas.AASValueTypeDataType)2 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)1 MultiLanguagePropertyValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.MultiLanguagePropertyValue)1 PropertyValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue)1