예제 #1
0
// ----------------------------------------------------------------------------------
// CSSYChannel::GetAllPropertiesL()
// ----------------------------------------------------------------------------------
//  
void CSSYChannel::GetAllPropertiesL( const TSensrvChannelId aChannelId, 
                                         RSensrvPropertyList& aChannelPropertyList )
    {
    SSY_TRACE_IN();
    SSY_TRACE( EExtended, "ORIENTATIONSSY:ChannelId %d", iChannelInfo.iChannelId );

    if ( ChannelId() != aChannelId )
        {
        SSY_TRACE( EError, "ORIENTATIONSSY:ERROR: GetAllPropertiesL wrong channelId!" );
        User::Leave( KErrArgument );
        }

    aChannelPropertyList.Reset();
    
    RSensrvPropertyList channelProperties;

    iSensorProperties->GetAllProperties( aChannelPropertyList );
    iChannelProperties->GetAllProperties( channelProperties );

    for ( TInt index = 0; index < channelProperties.Count(); index++ )
        {
        aChannelPropertyList.Append( channelProperties[index] );
        }
    
    channelProperties.Close();
    
    SSY_TRACE_OUT();
    }
void CSensorBackendSym::GetDescription()
    {
    RSensrvPropertyList list;
    TRAPD(err, iBackendData.iSensorChannel->GetAllPropertiesL(KSensrvSensorDescription, list));
    if(err == KErrNone)
        {
        QString str;
        TBuf8<KSensrvPropertyTextBufferSize> desc;
        for(int i=0; i<list.Count(); i++)
            {            
            if(list[i].GetArrayIndex() == ESensrvArrayPropertyInfo)
                {                
                continue;
                }
            list[i].GetValue(desc);
            str.append((const char*)desc.PtrZ());
            }
        setDescription(str);
        }
    }
// ----------------------------------------------------------------------------------
// CTCStateTiltListenData::HandleStateEntryL
// ----------------------------------------------------------------------------------
//
void CTCStateTiltListenData::HandleStateEntryL()
    {
    FUNC_LOG;
    if( iHzSamplingRate == 0 )
        {
        RSensrvPropertyList list = iTransactionHandler.Properties();
        for( TInt i = 0; i != list.Count(); i++ )
            {
            if( list[ i ].GetPropertyId() == KSensrvPropIdDataRate )
                {
                list[ i ].GetValue( iHzSamplingRate );
                INFO_1( "Sampling rate: %d", iHzSamplingRate );                
                }
            }
        }
    iRequestedDataCount = iTransactionHandler.DataCount();
    if( !iTimerToSend )
        {
        iTimerToSend = CTCSendEventTimer::NewL( iHzSamplingRate, *this );
        }
	iTimerToSend->Start(iHzSamplingRate);
    }
void CSensorBackendSym::GetMeasurementrangeAndAccuracy()
    {
    /*
    In QT Mobility measurement range and accuracy are coupled together to form the output range
    where as, in Symbian accuracy and measurement range are independent properties.
    To solve the QT requirement, the mapping used is as follows
    1. If symbian provides only one accuracy, use this with all the measurement ranges
    2. If there are n accuracies and n measurement ranges, map linearly (n:n)
    3. If there are n accuracies and n+x measurement ranges, then the mapping will be 
         n:n for each n measurement ranges and accuracies
         KAccuracyInvalid : for each n+x measurement ranges
    */
    TReal accuracy = 0;
    RSensrvPropertyList accuracyList;
    TInt err;
    TRAP(err, iBackendData.iSensorChannel->GetAllPropertiesL(KSensrvPropIdChannelAccuracy, accuracyList));
    if(err == KErrNone)
        {            
        // If only one accuracy value present set value to accuracy
        if(accuracyList.Count() == 1)
            {
            if(accuracyList[0].PropertyType() == ESensrvIntProperty)
                {
                TInt intAccuracy;
                accuracyList[0].GetValue(intAccuracy);
                accuracy = intAccuracy;
                }
            else if(accuracyList[0].PropertyType() == ESensrvRealProperty)
                {
                accuracyList[0].GetValue(accuracy);
                }
            }
        // If more than one accuracy values present set accuracy to invalid
        else
            {
            accuracy = KAccuracyInvalid; 
            }
        }
       
    //Scale
    TSensrvProperty scale_prop;
    TReal scale=1;
    TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdChannelScale, KSensrvItemIndexNone, scale_prop));
    if(err == KErrNone)
        {      
        if(scale_prop.PropertyType() == ESensrvIntProperty)
            {
            TInt intScale;
            scale_prop.GetValue(intScale);
            scale = intScale;
            }
        else if(scale_prop.PropertyType() == ESensrvRealProperty)
            {
            scale_prop.GetValue(scale);
            }
            TReal scaleMultiplier;
            Math::Pow(scaleMultiplier, 10, scale);
            scale = scaleMultiplier;
        }  
       
    //measurement minimum & maximum
    TSensrvProperty measurerange_prop;    
    TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, measurerange_prop));
    if(err == KErrNone)
        {
        if(measurerange_prop.GetArrayIndex() == ESensrvSingleProperty)
        {
            TReal measureMin, measureMax, value;
            if(measurerange_prop.PropertyType() == ESensrvIntProperty)
                {
                TInt intMin, intMax;
                measurerange_prop.GetMinValue(intMin);
                measurerange_prop.GetMaxValue(intMax);
                measureMin = intMin;
                measureMax = intMax;
                }
            else if(measurerange_prop.PropertyType() == ESensrvRealProperty)
                {
                measurerange_prop.GetMinValue(measureMin);
                measurerange_prop.GetMaxValue(measureMax);
                }
            //Set output as range
            addOutputRange(measureMin*scale, measureMax*scale, accuracy);
        }
        //if list has more than one item, data rate will be having descrete values, agreed with DS team
        else if(measurerange_prop.GetArrayIndex() == ESensrvArrayPropertyInfo)                             
            {
            TReal measureMin, measureMax;
            TInt min, max, index;
            if(measurerange_prop.PropertyType() == ESensrvIntProperty)
                {
                measurerange_prop.GetMinValue(min);
                measurerange_prop.GetMaxValue(max);
                measurerange_prop.GetValue(index);
                }
            else if(measurerange_prop.PropertyType() == ESensrvRealProperty)
                {
                TReal realMin, realMax, realValue;
                measurerange_prop.GetMinValue(realMin);
                measurerange_prop.GetMaxValue(realMax);
                measurerange_prop.GetValue(realValue); 
                min = realMin;
                max = realMax;
                index = realValue;
                }
            for(int i=min; i<=max; i++)
                {  
                TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, i, measurerange_prop));
                if(err == KErrNone)
                    {
                    if(measurerange_prop.PropertyType() == ESensrvIntProperty)
                        {
                        TInt intMeasureMin, intMeasureMax;
                        measurerange_prop.GetMinValue(intMeasureMin);
                        measurerange_prop.GetMaxValue(intMeasureMax);
                        measureMin = intMeasureMin;
                        measureMax = intMeasureMax;
                        }
                    else if(measurerange_prop.PropertyType() == ESensrvRealProperty)
                        {
                        measurerange_prop.GetMinValue(measureMin);
                        measurerange_prop.GetMaxValue(measureMax);
                        }
                    // If only one accuracy value is present set same accuracy for all 
                    if(accuracy != KAccuracyInvalid)
                        {
                        addOutputRange(measureMin*scale, measureMax*scale, accuracy);
                        }
                    // If more than one accuracy values are there then map them linearly
                    else
                        {
                        if(accuracyList.Count() > (i - min))
                            {
                            accuracyList[i].GetValue(accuracy);
                            addOutputRange(measureMin*scale, measureMax*scale, accuracy);
                            }
                        else
                            {
                            // If less accuracy values are present than measurement ranges then 
                            // set invalid accuracy for rest of measument ranges
                            addOutputRange(measureMin*scale, measureMax*scale, KAccuracyInvalid);
                            }
                        }
                    }
                }
            }
        }
    }