void CAccelerometerSensorSym::start() { TSensrvProperty dataFormatProperty; TInt err; CSensorBackendSym::start(); TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdChannelDataFormat, ESensrvSingleProperty, dataFormatProperty)); if(err == KErrNone) { TSensrvProperty scaleRangeProperty; TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, scaleRangeProperty)); if(err == KErrNone) { if(scaleRangeProperty.GetArrayIndex() == ESensrvSingleProperty) { if(scaleRangeProperty.PropertyType() == ESensrvIntProperty) { scaleRangeProperty.GetMaxValue(iScaleRange); } else if(scaleRangeProperty.PropertyType() == ESensrvRealProperty) { TReal realScale; scaleRangeProperty.GetMaxValue(realScale); iScaleRange = realScale; } } else if(scaleRangeProperty.GetArrayIndex() == ESensrvArrayPropertyInfo) { TInt index; if(scaleRangeProperty.PropertyType() == ESensrvIntProperty) { scaleRangeProperty.GetValue(index); } else if(scaleRangeProperty.PropertyType() == ESensrvRealProperty) { TReal realIndex; scaleRangeProperty.GetValue(realIndex); index = realIndex; } TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, index, scaleRangeProperty)); if(err == KErrNone) { if(scaleRangeProperty.PropertyType() == ESensrvIntProperty) { scaleRangeProperty.GetMaxValue(iScaleRange); } else if(scaleRangeProperty.PropertyType() == ESensrvRealProperty) { TReal realScaleRange; scaleRangeProperty.GetMaxValue(realScaleRange); iScaleRange = realScaleRange; } } } } } }
// --------------------------------------------------------------------------- // CSsyReferenceControl::FindPropertyL // --------------------------------------------------------------------------- // void CSsyReferenceControl::FindPropertyL( const TSensrvPropertyId aPropertyId, const TInt aArrayIndex, TSensrvProperty& aProperty ) { COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindPropertyL()" ) ) ); TSensrvProperty* property = NULL; TBool propertyFound( EFalse ); // Search property for ( TInt i = 0; i < iProperties.Count() && !propertyFound; i++ ) { property = static_cast<TSensrvProperty*>( &iProperties[i] ); // Compare property IDs if ( property->GetPropertyId() == aPropertyId ) { // Correct property ID is found, now check is it array type of property. // Either array indexes must match or propertys array index has to be array info if ( ( property->GetArrayIndex() == aArrayIndex ) || ( ( property->GetArrayIndex() == ESensrvArrayPropertyInfo ) && ( ESensrvSingleProperty == aArrayIndex ) ) ) { // Correct array index found propertyFound = ETrue; } } } // Leave if not found if ( !propertyFound ) { User::Leave( KErrNotFound ); } aProperty = *property; COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindPropertyL() - return" ) ) ); }
// --------------------------------------------------------------------------- // CSsyReferencePropertyProvider::GetPropertyL // --------------------------------------------------------------------------- // void CSsyReferencePropertyProvider::GetPropertyL( const TSensrvChannelId aChannelId, TSensrvProperty& aProperty ) { COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetPropertyL()" ) ) ); if ( iChannel.ChannelId() != aChannelId && aChannelId != 0 ) { User::Leave( KErrArgument ); } else { // Search property. Leaves with KErrNotFound if property is not found aProperty = iChannel.FindPropertyL( aProperty.GetPropertyId(), aProperty.PropertyItemIndex(), aProperty.GetArrayIndex() ); } COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetPropertyL() - return" ) ) ); }
/** * start is overridden to allow retrieving initial calibration property before * and to set the required value type flags */ void CMagnetometerSensorSym::start() { if(sensor()) { // Initialize the values iReading.setX(0); iReading.setY(0); iReading.setZ(0); // Set the required type of values QVariant v = sensor()->property("returnGeoValues"); iReturnGeoValues = (v.isValid() && v.toBool()); // if the property isn't set it's false } TInt err; // get current property value for calibration and set it to reading TSensrvProperty calibration; TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropCalibrationLevel, ESensrvSingleProperty, calibration)); // If error in getting the calibration level, continue to start the sensor // as it is not a fatal error if ( err == KErrNone ) { TInt calibrationVal; calibration.GetValue(calibrationVal); iCalibrationLevel = calibrationVal * (1.0/3.0); } // Call backend start CSensorBackendSym::start(); TSensrvProperty dataFormatProperty; TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdChannelDataFormat, ESensrvSingleProperty, dataFormatProperty)); if(err == KErrNone) { TInt dataFormat; dataFormatProperty.GetValue(dataFormat); if(dataFormat == ESensrvChannelDataFormatScaled) { TSensrvProperty scaleRangeProperty; TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, scaleRangeProperty)); if(err == KErrNone) { if(scaleRangeProperty.GetArrayIndex() == ESensrvSingleProperty) { if(scaleRangeProperty.PropertyType() == ESensrvIntProperty) { scaleRangeProperty.GetMaxValue(iScaleRange); } else if(scaleRangeProperty.PropertyType() == ESensrvRealProperty) { TReal realScale; scaleRangeProperty.GetMaxValue(realScale); iScaleRange = realScale; } } else if(scaleRangeProperty.GetArrayIndex() == ESensrvArrayPropertyInfo) { TInt index; if(scaleRangeProperty.PropertyType() == ESensrvIntProperty) { scaleRangeProperty.GetValue(index); } else if(scaleRangeProperty.PropertyType() == ESensrvRealProperty) { TReal realIndex; scaleRangeProperty.GetValue(realIndex); index = realIndex; } TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, index, scaleRangeProperty)); if(err == KErrNone) { if(scaleRangeProperty.PropertyType() == ESensrvIntProperty) { scaleRangeProperty.GetMaxValue(iScaleRange); } else if(scaleRangeProperty.PropertyType() == ESensrvRealProperty) { TReal realScaleRange; scaleRangeProperty.GetMaxValue(realScaleRange); iScaleRange = realScaleRange; } } } } } } }