Search in sources :

Example 1 with PlainProperty

use of com.prosysopc.ua.server.nodes.PlainProperty in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addMultiLanguageValueNode.

/**
 * Adds the Value Node for the MultiLanguageProperty.
 *
 * @param node The desired MultiLanguageProperty Node
 * @param arraySize The desired Array Size.
 */
private void addMultiLanguageValueNode(UaNode node, int arraySize) {
    try {
        NodeId propId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASMultiLanguagePropertyType.VALUE);
        PlainProperty<LocalizedText[]> myLTProperty = new PlainProperty<>(this, propId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASMultiLanguagePropertyType.getNamespaceUri(), AASMultiLanguagePropertyType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASMultiLanguagePropertyType.VALUE));
        myLTProperty.setDataTypeId(Identifiers.LocalizedText);
        myLTProperty.setValueRank(ValueRanks.OneDimension);
        myLTProperty.setArrayDimensions(new UnsignedInteger[] { UnsignedInteger.valueOf(arraySize) });
        node.addProperty(myLTProperty);
        myLTProperty.setDescription(new LocalizedText("", ""));
    } catch (Throwable ex) {
        logger.error("addMultiLanguageValueNode Exception", ex);
        throw ex;
    }
}
Also used : PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText)

Example 2 with PlainProperty

use of com.prosysopc.ua.server.nodes.PlainProperty in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method setRangeValueAndType.

/**
 * Adds the min and max properties to the UA range object and sets the values
 *
 * @param aasRange The AAS range object
 * @param range The corresponding UA range object
 * @param submodel The corresponding submodel
 * @param rangeRef The AAS reference to the Range
 */
private void setRangeValueAndType(Range aasRange, AASRangeType range, Submodel submodel, Reference rangeRef) {
    try {
        String minValue = aasRange.getMin();
        String maxValue = aasRange.getMax();
        NodeId myPropertyIdMin = new NodeId(getNamespaceIndex(), range.getNodeId().getValue().toString() + "." + AASRangeType.MIN);
        NodeId myPropertyIdMax = new NodeId(getNamespaceIndex(), range.getNodeId().getValue().toString() + "." + AASRangeType.MAX);
        String valueType = aasRange.getValueType();
        QualifiedName browseNameMin = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASRangeType.getNamespaceUri(), AASRangeType.MIN).toQualifiedName(getNamespaceTable());
        LocalizedText displayNameMin = LocalizedText.english(AASRangeType.MIN);
        QualifiedName browseNameMax = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASRangeType.getNamespaceUri(), AASRangeType.MAX).toQualifiedName(getNamespaceTable());
        LocalizedText displayNameMax = LocalizedText.english(AASRangeType.MAX);
        submodelElementAasMap.put(myPropertyIdMin, new SubmodelElementData(aasRange, submodel, SubmodelElementData.Type.RANGE_MIN, rangeRef));
        submodelElementAasMap.put(myPropertyIdMax, new SubmodelElementData(aasRange, submodel, SubmodelElementData.Type.RANGE_MAX, rangeRef));
        submodelElementOpcUAMap.put(rangeRef, range);
        TypedValue minTypedValue = TypedValueFactory.create(valueType, minValue);
        TypedValue maxTypedValue = TypedValueFactory.create(valueType, maxValue);
        AASValueTypeDataType valueDataType;
        if (minTypedValue != null) {
            valueDataType = ValueConverter.datatypeToValueType(minTypedValue.getDataType());
        } else {
            valueDataType = ValueConverter.stringToValueType(valueType);
        }
        range.setValueType(valueDataType);
        switch(valueDataType) {
            // 
            case Boolean:
                if (minValue != null) {
                    PlainProperty<Boolean> myBoolProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    myBoolProperty.setDataTypeId(Identifiers.Boolean);
                    if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
                        myBoolProperty.setValue(minTypedValue.getValue());
                    }
                    myBoolProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myBoolProperty);
                }
                if (maxValue != null) {
                    PlainProperty<Boolean> myBoolProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    myBoolProperty.setDataTypeId(Identifiers.Boolean);
                    if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
                        myBoolProperty.setValue(maxTypedValue.getValue());
                    }
                    myBoolProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myBoolProperty);
                }
                break;
            // break;
            case Int32:
                if (minValue != null) {
                    PlainProperty<Integer> myIntProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    myIntProperty.setDataTypeId(Identifiers.Int32);
                    if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
                        myIntProperty.setValue(minTypedValue.getValue());
                    }
                    myIntProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myIntProperty);
                }
                if (maxValue != null) {
                    PlainProperty<Integer> myIntProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    myIntProperty.setDataTypeId(Identifiers.Int32);
                    if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
                        myIntProperty.setValue(maxTypedValue.getValue());
                    }
                    myIntProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myIntProperty);
                }
                break;
            case Int64:
                if (minValue != null) {
                    PlainProperty<Long> myLongProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    myLongProperty.setDataTypeId(Identifiers.Int64);
                    if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
                        Object obj = minTypedValue.getValue();
                        if (!(obj instanceof Long)) {
                            obj = Long.parseLong(obj.toString());
                        }
                        myLongProperty.setValue(obj);
                    }
                    myLongProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myLongProperty);
                }
                if (maxValue != null) {
                    PlainProperty<Long> myLongProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    myLongProperty.setDataTypeId(Identifiers.Int64);
                    if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
                        Object obj = maxTypedValue.getValue();
                        if (!(obj instanceof Long)) {
                            obj = Long.parseLong(obj.toString());
                        }
                        myLongProperty.setValue(obj);
                    }
                    myLongProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myLongProperty);
                }
                break;
            case Int16:
                if (minValue != null) {
                    PlainProperty<Short> myInt16Property = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    myInt16Property.setDataTypeId(Identifiers.Int16);
                    if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
                        myInt16Property.setValue(minTypedValue.getValue());
                    }
                    myInt16Property.setDescription(new LocalizedText("", ""));
                    range.addProperty(myInt16Property);
                }
                if (maxValue != null) {
                    PlainProperty<Short> myInt16Property = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    myInt16Property.setDataTypeId(Identifiers.Int16);
                    if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
                        myInt16Property.setValue(maxTypedValue.getValue());
                    }
                    myInt16Property.setDescription(new LocalizedText("", ""));
                    range.addProperty(myInt16Property);
                }
                break;
            case SByte:
                if (minValue != null) {
                    PlainProperty<Byte> mySByteProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    mySByteProperty.setDataTypeId(Identifiers.SByte);
                    if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
                        mySByteProperty.setValue(minTypedValue.getValue());
                    }
                    mySByteProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(mySByteProperty);
                }
                if (maxValue != null) {
                    PlainProperty<Byte> mySByteProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    mySByteProperty.setDataTypeId(Identifiers.SByte);
                    if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
                        mySByteProperty.setValue(maxTypedValue.getValue());
                    }
                    mySByteProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(mySByteProperty);
                }
                break;
            // 
            case Double:
                if (minValue != null) {
                    PlainProperty<Double> myDoubleProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    myDoubleProperty.setDataTypeId(Identifiers.Double);
                    if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
                        myDoubleProperty.setValue(minTypedValue.getValue());
                    }
                    myDoubleProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myDoubleProperty);
                }
                if (maxValue != null) {
                    PlainProperty<Double> myDoubleProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    myDoubleProperty.setDataTypeId(Identifiers.Double);
                    if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
                        myDoubleProperty.setValue(maxTypedValue.getValue());
                    }
                    myDoubleProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myDoubleProperty);
                }
                break;
            case Float:
                if (minValue != null) {
                    PlainProperty<Float> myFloatProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    myFloatProperty.setDataTypeId(Identifiers.Float);
                    if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
                        myFloatProperty.setValue(minTypedValue.getValue());
                    }
                    myFloatProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myFloatProperty);
                }
                if (maxValue != null) {
                    PlainProperty<Float> myFloatProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    myFloatProperty.setDataTypeId(Identifiers.Float);
                    if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
                        myFloatProperty.setValue(maxTypedValue.getValue());
                    }
                    myFloatProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myFloatProperty);
                }
                break;
            // 
            case String:
                if (minValue != null) {
                    PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    myStringProperty.setDataTypeId(Identifiers.String);
                    if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
                        myStringProperty.setValue(minTypedValue.getValue());
                    }
                    myStringProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myStringProperty);
                }
                if (maxValue != null) {
                    PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    myStringProperty.setDataTypeId(Identifiers.String);
                    if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
                        myStringProperty.setValue(maxTypedValue.getValue());
                    }
                    myStringProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myStringProperty);
                }
                break;
            // break;
            default:
                logger.warn("setRangeValueAndType: Range " + range.getBrowseName().getName() + ": Unknown type: " + valueType + "; use string as default");
                if (minValue != null) {
                    PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
                    myStringProperty.setDataTypeId(Identifiers.String);
                    myStringProperty.setValue(minValue);
                    myStringProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myStringProperty);
                }
                if (maxValue != null) {
                    PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
                    myStringProperty.setDataTypeId(Identifiers.String);
                    myStringProperty.setValue(maxValue);
                    myStringProperty.setDescription(new LocalizedText("", ""));
                    range.addProperty(myStringProperty);
                }
                break;
        }
    } catch (Throwable ex) {
        logger.error("setRangeValueAndType 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) TypedValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValue) AASValueTypeDataType(opc.i4aas.AASValueTypeDataType) PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) 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 3 with PlainProperty

use of com.prosysopc.ua.server.nodes.PlainProperty in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addAasSubmodelElementCollection.

/**
 * Adds a SubmodelElementCollection to the given node.
 *
 * @param node The desired UA node
 * @param aasColl The corresponding SubmodelElementCollection to add
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param parentRef The AAS reference to the parent object
 * @param ordered Specifies whether the entity 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 addAasSubmodelElementCollection(UaNode node, SubmodelElementCollection aasColl, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    try {
        if ((node != null) && (aasColl != null)) {
            String name = aasColl.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelElementCollectionType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASSubmodelElementCollectionType collNode;
            if (aasColl.getOrdered()) {
                collNode = createAasOrderedSubmodelElementCollection(name, nid);
            } else {
                collNode = createInstance(AASSubmodelElementCollectionType.class, nid, browseName, LocalizedText.english(name));
            }
            addSubmodelElementBaseData(collNode, aasColl);
            // AllowDuplicates
            if (collNode.getAllowDuplicatesNode() == null) {
                NodeId myPropertyId = new NodeId(getNamespaceIndex(), collNode.getNodeId().getValue().toString() + "." + AASSubmodelElementCollectionType.ALLOW_DUPLICATES);
                PlainProperty<Boolean> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelElementCollectionType.getNamespaceUri(), AASSubmodelElementCollectionType.ALLOW_DUPLICATES).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASSubmodelElementCollectionType.ALLOW_DUPLICATES));
                myProperty.setDataTypeId(Identifiers.Boolean);
                myProperty.setDescription(new LocalizedText("", ""));
                if (VALUES_READ_ONLY) {
                    myProperty.setAccessLevel(AccessLevelType.CurrentRead);
                }
                collNode.addProperty(myProperty);
            }
            collNode.setAllowDuplicates(aasColl.getAllowDuplicates());
            Reference collRef = AasUtils.toReference(parentRef, aasColl);
            // SubmodelElements
            addSubmodelElements(collNode, aasColl.getValues(), submodel, collRef, aasColl.getOrdered());
            if (ordered) {
                node.addReference(collNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(collNode);
            }
            referableMap.put(collRef, new ObjectData(aasColl, collNode, submodel));
        }
    } catch (Throwable ex) {
        logger.error("createAasSubmodelElementCollection Exception", ex);
        throw ex;
    }
}
Also used : PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) 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) AASSubmodelElementCollectionType(opc.i4aas.AASSubmodelElementCollectionType) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText)

Example 4 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 (Throwable ex) {
        logger.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)

Example 5 with PlainProperty

use of com.prosysopc.ua.server.nodes.PlainProperty in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addQualifierValueNode.

/**
 * Adds a Value Property to the given Qualifier Node.
 *
 * @param node The desired Blob Node
 */
private void addQualifierValueNode(UaNode node) {
    try {
        NodeId myPropertyId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASQualifierType.VALUE);
        PlainProperty<ByteString> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASQualifierType.getNamespaceUri(), AASQualifierType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASQualifierType.VALUE));
        myProperty.setDataTypeId(Identifiers.String);
        if (VALUES_READ_ONLY) {
            myProperty.setAccessLevel(AccessLevelType.CurrentRead);
        }
        myProperty.setDescription(new LocalizedText("", ""));
        node.addProperty(myProperty);
    } catch (Throwable ex) {
        logger.error("addQualifierValueNode 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)

Aggregations

PlainProperty (com.prosysopc.ua.server.nodes.PlainProperty)8 LocalizedText (com.prosysopc.ua.stack.builtintypes.LocalizedText)8 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)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 TypedValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValue)1 Reference (io.adminshell.aas.v3.model.Reference)1 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)1 AASSubmodelElementCollectionType (opc.i4aas.AASSubmodelElementCollectionType)1