Scaling Channel Data Values

The value of a channel data item can represent the actual or relative value of the measured quantity. The relative value is a scaled value that lies within the maximum and minimum values of the measured quantity.

The KSensrvPropIdChannelDataFormat property defines if channel data items are in a scaled format. For scaled data items, the KSensrvPropIdScaledRange property defines range of the data item value and the KSensrvPropIdMeasureRange property defines range of the measured quantity.


The following example explains how the sensor data can be scaled by reading the maximum value of measure range for data items (KSensrvPropIdScaledRange) and the maximum value of the measured quantity (KSensrvPropIdMeasureRange). The example considers that the KSensrvPropIdMeasureRange property is defined as an array property.

TSensrvProperty property;
    TInt  channelDataFormat( ESensrvFormatAbsolute );
    TInt  channelDataScaledRange( 1 );
    TReal channelDataMeasureRangeMaxValue( 1 );

    //Read channel data format
    iSensorChannel->GetPropertyL( KSensrvPropIdChannelDataFormat, KSensrvItemIndexNone, property );
    property.GetValue( channelDataFormat );

    if( ESensrvFormatScaled == channelDataFormat )
        //Read data item scaled range
        iSensorChannel->GetPropertyL( KSensrvPropIdScaledRange, KSensrvItemIndexNone, property );
        property.GetMaxValue( channelDataScaledRange );

        //Read data item measure range
        iSensorChannel->GetPropertyL( KSensrvPropIdMeasureRange, KSensrvItemIndexNone, property );

        if( ESensrvArrayPropertyInfo == property.GetArrayIndex() )
            TInt arrayIndex( 0 );
            property.GetValue( arrayIndex );//Value points to array index currently in use
            iSensorChannel->GetPropertyL( KSensrvPropIdMeasureRange,
                                          property );
            //Single property
        property.GetMaxValue( channelDataMeasureRangeMaxValue );
        //No scaling needed.
        //Value of the data item represents actual value of the measured quantity.

You can convert the scaled channel data item value to the absolute value by dividing the channel data item value with the maximum value of scaled range of the channel and multiplying it with the maximum value of the measured quantity.

For example, if the accelerometer channel provides the following properties:

  • KSensrvPropIdChannelDataFormat with value ESensrvFormatScaled

  • KSensrvPropIdScaledRange with maximum value of 127

  • KSensrvPropIdMeasureRange with maximum value of 2 g

  • KSensrvPropIdChannelUnit with value ESensrvUnitGravityConstant

then the accelerometer channel data item value of 64 is equal to an absolute value of 1.01g (that is, 64 / 127 * 2g = 1.01g).