javaextensions/sensor/src.s60/cacceleratorsensorrawdata.cpp
branchRCL_3
changeset 19 04becd199f91
child 56 abc41079b313
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Accelerometer sensor raw data implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INTERNAL INCLUDES
       
    20 #include "cacceleratorsensorrawdata.h"
       
    21 #include "csensorproperties.h"
       
    22 #include "logger.h"
       
    23 
       
    24 #include <sensrvgeneralproperties.h>
       
    25 #include <sensrvtypes.h>
       
    26 
       
    27 _LIT(KSeparator, "#");
       
    28 _LIT(KModel, "#model=Nokia2#");
       
    29 _LIT(KDataTypeInt, "2#");
       
    30 _LIT(KDataUnitRaw, "raw");
       
    31 _LIT(KMeasureRangeCount, "1#");
       
    32 
       
    33 CAcceleratorSensorRawData* CAcceleratorSensorRawData::NewLC(const TSensrvChannelInfo& aChannelInfo)
       
    34 {
       
    35     JELOG2(ESensor);
       
    36     CAcceleratorSensorRawData* self = new(ELeave) CAcceleratorSensorRawData(aChannelInfo);
       
    37     CleanupStack::PushL(self);
       
    38     self->ConstructL();
       
    39     return self;
       
    40 }
       
    41 
       
    42 CAcceleratorSensorRawData* CAcceleratorSensorRawData::NewL(const TSensrvChannelInfo& aChannelInfo)
       
    43 {
       
    44     JELOG2(ESensor);
       
    45     CAcceleratorSensorRawData* self = CAcceleratorSensorRawData::NewLC(aChannelInfo);
       
    46     CleanupStack::Pop(); // self;
       
    47     return self;
       
    48 }
       
    49 
       
    50 void CAcceleratorSensorRawData::ConstructL()
       
    51 {
       
    52     JELOG2(ESensor);
       
    53     CAcceleratorSensor::ConstructL();
       
    54 }
       
    55 
       
    56 CSensorBase* CAcceleratorSensorRawData::DuplicateL()
       
    57 {
       
    58     JELOG2(ESensor);
       
    59     return NewL(iChannelInfo);
       
    60 }
       
    61 
       
    62 CAcceleratorSensorRawData::CAcceleratorSensorRawData(const TSensrvChannelInfo& aChannelInfo):
       
    63         CAcceleratorSensor(aChannelInfo)
       
    64 {
       
    65     JELOG2(ESensor);
       
    66     // No implementation needed
       
    67 }
       
    68 
       
    69 CAcceleratorSensorRawData::~CAcceleratorSensorRawData()
       
    70 {
       
    71     JELOG2(ESensor);
       
    72     // No implementation needed
       
    73 }
       
    74 
       
    75 void CAcceleratorSensorRawData::Model(TPtr* aPtr)
       
    76 {
       
    77     JELOG2(ESensor);
       
    78     aPtr->Append(KModel);
       
    79 }
       
    80 
       
    81 void CAcceleratorSensorRawData::DataType(TPtr* aPtr)
       
    82 {
       
    83     JELOG2(ESensor);
       
    84     aPtr->Append(KDataTypeInt);
       
    85 }
       
    86 
       
    87 void CAcceleratorSensorRawData::DataUnit(const RSensrvPropertyList /*aList*/, TPtr* aPtr)
       
    88 {
       
    89     JELOG2(ESensor);
       
    90     aPtr->Append(KDataUnitRaw);
       
    91 }
       
    92 
       
    93 void CAcceleratorSensorRawData::DataRange(const RSensrvPropertyList aList,
       
    94         TPtr* aPtr)
       
    95 {
       
    96     JELOG2(ESensor);
       
    97     TSensrvProperty property;
       
    98     TInt intValue(0);
       
    99     GetProperty(aList, KSensrvPropIdScaledRange,KSensrvItemIndexNone, property);
       
   100     if (property.PropertyType() == ESensrvIntProperty)
       
   101     {
       
   102         aPtr->Append(KMeasureRangeCount);
       
   103         property.GetMinValue(intValue);   // min
       
   104         aPtr->AppendNum(intValue);
       
   105         aPtr->Append(KSeparator);
       
   106         property.GetMaxValue(intValue);   // max
       
   107         aPtr->AppendNum(intValue);
       
   108         aPtr->Append(KSeparator);
       
   109         aPtr->AppendNum(1);
       
   110     }
       
   111     else
       
   112     {
       
   113         aPtr->AppendNum(0);
       
   114     }
       
   115 }
       
   116 void CAcceleratorSensorRawData::CopyData(const TSensrvAccelerometerAxisData aData, TInt aIndex)
       
   117 {
       
   118     JELOG2(ESensor);
       
   119     iChannelXData->iIntValues[ aIndex ] = aData.iAxisX;
       
   120     iChannelYData->iIntValues[ aIndex ] = aData.iAxisY;
       
   121     iChannelZData->iIntValues[ aIndex ] = aData.iAxisZ;
       
   122 }
       
   123 
       
   124 TInt CAcceleratorSensorRawData::SensorDescriptionId()
       
   125 {
       
   126     JELOG2(ESensor);
       
   127     return EAccelerometerSensorRawData;
       
   128 }
       
   129 
       
   130 TReal CAcceleratorSensorRawData::InterpretValue(TReal aValue)
       
   131 {
       
   132     JELOG2(ESensor);
       
   133     return aValue;
       
   134 }
       
   135 
       
   136 void CAcceleratorSensorRawData::DataReceived(CSensrvChannel& aChannel, TInt aCount, TInt aDataLost)
       
   137 {
       
   138     JELOG2(ESensor);
       
   139     CAcceleratorSensor::DataReceived(aChannel, aCount, aDataLost);
       
   140 }