Search in sources :

Example 1 with IntegerValue

use of de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.IntegerValue in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method setPropertyValue.

/**
 * Sets the value of a property.
 *
 * @param property The desired Property
 * @param value The new value.
 * @throws StatusException If the operation fails.
 */
private void setPropertyValue(AASPropertyType property, PropertyValue value) throws StatusException {
    if (property == null) {
        throw new IllegalArgumentException("property is null");
    } else if (value == null) {
        throw new IllegalArgumentException("value is null");
    }
    logger.debug("setPropertyValue: " + property.getBrowseName().getName() + " to " + value.getValue());
    try {
        // special treatment for some not directly supported types
        TypedValue tv = value.getValue();
        Object obj = tv.getValue();
        if ((tv instanceof DecimalValue) || (tv instanceof IntegerValue)) {
            obj = Long.parseLong(obj.toString());
        }
        property.setValue(obj);
    // switch (property.getValueType()) {
    // case ByteString:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case Boolean:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case DateTime:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case Int32:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case UInt32:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case Int64:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case UInt64:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case Int16:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case UInt16:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case Byte:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case SByte:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case Double:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case Float:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case LocalizedText:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case String:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // case UtcTime:
    // // TODO integrate Property value
    // property.setValue(value.getValue());
    // break;
    // 
    // default:
    // logger.warn("setPropertyValue: Property " + property.getBrowseName().getName() + ": Unknown type: " + property.getValueType());
    // break;
    // }
    } catch (Throwable ex) {
        logger.error("setPropertyValue Exception", ex);
        throw ex;
    }
}
Also used : DecimalValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.DecimalValue) IntegerValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.IntegerValue) UaObject(com.prosysopc.ua.nodes.UaObject) TypedValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValue)

Example 2 with IntegerValue

use of de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.IntegerValue in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method setRangeValue.

/**
 * Sets the value for the given Range.
 *
 * @param range The desired Range.
 * @param value The new value
 * @throws StatusException If the operation fails
 */
private void setRangeValue(AASRangeType range, RangeValue value) throws StatusException {
    if (range == null) {
        throw new IllegalArgumentException("range is null");
    } else if (value == null) {
        throw new IllegalArgumentException("value is null");
    }
    try {
        // special treatment for some not directly supported types
        TypedValue tvmin = value.getMin();
        Object objmin = tvmin.getValue();
        if ((tvmin instanceof DecimalValue) || (tvmin instanceof IntegerValue)) {
            objmin = Long.parseLong(objmin.toString());
        }
        TypedValue tvmax = value.getMax();
        Object objmax = tvmax.getValue();
        if ((tvmax instanceof DecimalValue) || (tvmax instanceof IntegerValue)) {
            objmax = Long.parseLong(objmax.toString());
        }
        range.setMin(objmin);
        range.setMax(objmax);
    } catch (Throwable ex) {
        logger.error("setRangeValue Exception", ex);
        throw ex;
    }
}
Also used : DecimalValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.DecimalValue) IntegerValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.IntegerValue) UaObject(com.prosysopc.ua.nodes.UaObject) TypedValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValue)

Aggregations

UaObject (com.prosysopc.ua.nodes.UaObject)2 DecimalValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.DecimalValue)2 IntegerValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.IntegerValue)2 TypedValue (de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValue)2