javaextensions/sensor/src.s60/cacceleratorsensor.cpp
branchRCL_3
changeset 60 6c158198356e
parent 25 9ac0a0a7da70
child 83 26b2b12093af
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
   295     return err==KErrNotFound? KErrNone : err;
   295     return err==KErrNotFound? KErrNone : err;
   296 }
   296 }
   297 
   297 
   298 void CAcceleratorSensor::OpenChannelL()
   298 void CAcceleratorSensor::OpenChannelL()
   299 {
   299 {
   300     TInt err;
       
   301     JELOG2(ESensor);
   300     JELOG2(ESensor);
   302     LOG(ESensor,EInfo,"Creating Open Channel");
   301     LOG(ESensor,EInfo,"Creating Open Channel");
   303     iChannel->OpenChannelL();
   302     iChannel->OpenChannelL();
   304     LOG(ESensor,EInfo,"Channel Created");
   303     LOG(ESensor,EInfo,"Channel Created");
   305     // 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
   306     iScaleFactor = 1;
   305     iScaleFactor = 1;
   307     TInt format(ESensrvChannelDataFormatAbsolute);
   306     TInt format(ESensrvChannelDataFormatAbsolute);
   308     TSensrvProperty property;
   307     TSensrvProperty property;
   309     TRAP(err,iChannel->GetPropertyL(KSensrvPropIdChannelDataFormat, KSensrvItemIndexNone,
   308     iChannel->GetPropertyL(KSensrvPropIdChannelDataFormat, KSensrvItemIndexNone,
   310                                       property););
   309                                       property);
   311     LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() One = %d",err);
   310     
   312 
   311 
   313     if (property.PropertyType() == ESensrvIntProperty)
   312     if (property.PropertyType() == ESensrvIntProperty)
   314     {
   313     {
   315         property.GetValue(format);
   314         property.GetValue(format);
   316         LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetValue()::KSensrvPropIdChannelDataFormat format = %d",format);
   315         LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetValue()::KSensrvPropIdChannelDataFormat format = %d",format);
   326     {
   325     {
   327         LOG(ESensor,EInfo," format is equal to ESensrvChannelDataFormatScaled");
   326         LOG(ESensor,EInfo," format is equal to ESensrvChannelDataFormatScaled");
   328         // Scaled value maximum
   327         // Scaled value maximum
   329         TSensrvProperty property_scaled;
   328         TSensrvProperty property_scaled;
   330         TInt maxScaled(0);
   329         TInt maxScaled(0);
   331         TRAP(err,iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone,
   330        iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone,
   332                                           property_scaled););
   331                                           property_scaled);
   333         LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Two = %d",err);
   332         
   334 
   333 
   335         if (property_scaled.GetArrayIndex() == ESensrvArrayPropertyInfo)
   334         if (property_scaled.GetArrayIndex() == ESensrvArrayPropertyInfo)
   336         {
   335         {
   337             LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If");
   336             LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If");
   338             //for 2G Accelerometer Sensor index value is 0.
   337             //for 2G Accelerometer Sensor index value is 0.
   339             TInt rangeIndex(0);
   338             TInt rangeIndex(0);
   340             TRAP(err,iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone,
   339             iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone,
   341                                               rangeIndex, property_scaled););
   340                                               rangeIndex, property_scaled);
   342             LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Three = %d",err);
       
   343 
       
   344             property_scaled.GetMaxValue(maxScaled);
   341             property_scaled.GetMaxValue(maxScaled);
   345 
   342 
   346             LOG1(ESensor,EInfo,"property_scaled::maxValue = %d",maxScaled);
   343             LOG1(ESensor,EInfo,"property_scaled::maxValue = %d",maxScaled);
   347         }
   344         }
   348         else
   345         else
   351             property_scaled.GetMaxValue(maxScaled);
   348             property_scaled.GetMaxValue(maxScaled);
   352             LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::maxScaled = %d",maxScaled);
   349             LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::maxScaled = %d",maxScaled);
   353         }
   350         }
   354         // MeasureRange can be an array property
   351         // MeasureRange can be an array property
   355         TReal maxMeasure;
   352         TReal maxMeasure;
   356         TInt err1;
   353         
   357         TSensrvProperty property_Measured;
   354         TSensrvProperty property_Measured;
   358         TRAP(err1,iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone,
   355         iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone,
   359                                           property_Measured););
   356                                           property_Measured);
   360         LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Four = %d",err1);
   357              
   361 
   358         TInt arrayIndex = property_Measured.GetArrayIndex();
   362         if (err1 == KErrNone)
   359         LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::KSensrvPropIdMeasureRange::arrayIndex = %d",arrayIndex);
   363         {
   360 
   364             TInt arrayIndex = property_Measured.GetArrayIndex();
   361         if (property_Measured.GetArrayIndex() == ESensrvArrayPropertyInfo)
   365             LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::KSensrvPropIdMeasureRange::arrayIndex = %d",arrayIndex);
   362         {
   366 
   363             LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If");
   367             if (property_Measured.GetArrayIndex() == ESensrvArrayPropertyInfo)
   364 
   368             {
   365             TInt index2g = 0;
   369                 LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If");
   366             LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::Getting RangeIndex = %f",index2g);
   370 
   367             //We need to TypeCast variable rangeIndex to TInt for
   371                 TInt index2g = 0;
   368             iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone,
   372                 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::Getting RangeIndex = %f",index2g);
   369                                               index2g, property_Measured);
   373                 //We need to TypeCast variable rangeIndex to TInt for
   370             property_Measured.GetMaxValue(maxMeasure);
   374                 TRAP(err,iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone,
   371         }
   375                                                   index2g, property_Measured););
   372         else
   376                 LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Five = %d",err);
   373         {
   377                 property_Measured.GetMaxValue(maxMeasure);
   374             LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::else");
   378             }
   375             property_Measured.GetMaxValue(maxMeasure);
   379             else
   376         }
   380             {
   377 
   381                 LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::else");
   378         
   382                 property_Measured.GetMaxValue(maxMeasure);
       
   383             }
       
   384 
       
   385         }
       
   386         iScaleFactor = maxMeasure / maxScaled ;
   379         iScaleFactor = maxMeasure / maxScaled ;
   387         LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::iScaleFactor = %f",iScaleFactor);
   380         LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::iScaleFactor = %f",iScaleFactor);
   388     }
   381     }
   389     // this checking was introduced for 9.2
   382     // this checking was introduced for 9.2
   390     else if (format == ESensrvChannelDataFormatAbsolute)
   383     else if (format == ESensrvChannelDataFormatAbsolute)