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