303 LOG(ESensor,EInfo,"Channel Created"); |
303 LOG(ESensor,EInfo,"Channel Created"); |
304 // Check if the sensor data is scaled and set the scale factor |
304 // Check if the sensor data is scaled and set the scale factor |
305 iScaleFactor = 1; |
305 iScaleFactor = 1; |
306 TInt format(ESensrvChannelDataFormatAbsolute); |
306 TInt format(ESensrvChannelDataFormatAbsolute); |
307 TSensrvProperty property; |
307 TSensrvProperty property; |
308 TRAPD(err1,iChannel->GetPropertyL(KSensrvPropIdChannelDataFormat, KSensrvItemIndexNone, |
308 iChannel->GetPropertyL(KSensrvPropIdChannelDataFormat, KSensrvItemIndexNone, |
309 property);); |
309 property); |
310 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() One = %d",err1); |
310 |
|
311 |
311 if (property.PropertyType() == ESensrvIntProperty) |
312 if (property.PropertyType() == ESensrvIntProperty) |
312 { |
313 { |
313 property.GetValue(format); |
314 property.GetValue(format); |
314 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetValue()::KSensrvPropIdChannelDataFormat format = %d",format); |
315 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetValue()::KSensrvPropIdChannelDataFormat format = %d",format); |
315 } |
316 } |
324 { |
325 { |
325 LOG(ESensor,EInfo," format is equal to ESensrvChannelDataFormatScaled"); |
326 LOG(ESensor,EInfo," format is equal to ESensrvChannelDataFormatScaled"); |
326 // Scaled value maximum |
327 // Scaled value maximum |
327 TSensrvProperty property_scaled; |
328 TSensrvProperty property_scaled; |
328 TInt maxScaled(0); |
329 TInt maxScaled(0); |
329 TRAPD(err2,iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, |
330 iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, |
330 property_scaled);); |
331 property_scaled); |
331 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Two = %d",err2); |
332 |
332 |
333 |
333 if (property_scaled.GetArrayIndex() == ESensrvArrayPropertyInfo) |
334 if (property_scaled.GetArrayIndex() == ESensrvArrayPropertyInfo) |
334 { |
335 { |
335 LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If"); |
336 LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If"); |
336 //for 2G Accelerometer Sensor index value is 0. |
337 //for 2G Accelerometer Sensor index value is 0. |
337 TInt rangeIndex(0); |
338 TInt rangeIndex(0); |
338 TRAPD(err3,iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, |
339 iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, |
339 rangeIndex, property_scaled);); |
340 rangeIndex, property_scaled); |
340 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Three = %d",err3); |
|
341 |
|
342 property_scaled.GetMaxValue(maxScaled); |
341 property_scaled.GetMaxValue(maxScaled); |
343 |
342 |
344 LOG1(ESensor,EInfo,"property_scaled::maxValue = %d",maxScaled); |
343 LOG1(ESensor,EInfo,"property_scaled::maxValue = %d",maxScaled); |
345 } |
344 } |
346 else |
345 else |
349 property_scaled.GetMaxValue(maxScaled); |
348 property_scaled.GetMaxValue(maxScaled); |
350 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::maxScaled = %d",maxScaled); |
349 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::maxScaled = %d",maxScaled); |
351 } |
350 } |
352 // MeasureRange can be an array property |
351 // MeasureRange can be an array property |
353 TReal maxMeasure; |
352 TReal maxMeasure; |
|
353 |
354 TSensrvProperty property_Measured; |
354 TSensrvProperty property_Measured; |
355 TRAPD(err4,iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, |
355 iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, |
356 property_Measured);); |
356 property_Measured); |
357 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Four = %d",err4); |
357 |
358 |
358 TInt arrayIndex = property_Measured.GetArrayIndex(); |
359 if (err4 == KErrNone) |
359 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::KSensrvPropIdMeasureRange::arrayIndex = %d",arrayIndex); |
360 { |
360 |
361 TInt arrayIndex = property_Measured.GetArrayIndex(); |
361 if (property_Measured.GetArrayIndex() == ESensrvArrayPropertyInfo) |
362 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::KSensrvPropIdMeasureRange::arrayIndex = %d",arrayIndex); |
362 { |
363 |
363 LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If"); |
364 if (property_Measured.GetArrayIndex() == ESensrvArrayPropertyInfo) |
364 |
365 { |
365 TInt index2g = 0; |
366 LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If"); |
366 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::Getting RangeIndex = %f",index2g); |
367 |
367 //We need to TypeCast variable rangeIndex to TInt for |
368 TInt index2g = 0; |
368 iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, |
369 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::Getting RangeIndex = %f",index2g); |
369 index2g, property_Measured); |
370 //We need to TypeCast variable rangeIndex to TInt for |
370 property_Measured.GetMaxValue(maxMeasure); |
371 TRAPD(err5,iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, |
371 } |
372 index2g, property_Measured);); |
372 else |
373 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Five = %d",err5); |
373 { |
374 property_Measured.GetMaxValue(maxMeasure); |
374 LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::else"); |
375 } |
375 property_Measured.GetMaxValue(maxMeasure); |
376 else |
376 } |
377 { |
377 |
378 LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::else"); |
378 |
379 property_Measured.GetMaxValue(maxMeasure); |
|
380 } |
|
381 |
|
382 } |
|
383 iScaleFactor = maxMeasure / maxScaled ; |
379 iScaleFactor = maxMeasure / maxScaled ; |
384 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::iScaleFactor = %f",iScaleFactor); |
380 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::iScaleFactor = %f",iScaleFactor); |
385 } |
381 } |
386 // this checking was introduced for 9.2 |
382 // this checking was introduced for 9.2 |
387 else if (format == ESensrvChannelDataFormatAbsolute) |
383 else if (format == ESensrvChannelDataFormatAbsolute) |