javaextensions/sensor/src.s60/cacceleratorsensor.h
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     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 implementation
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CACCELERATORSENSOR_H
       
    20 #define CACCELERATORSENSOR_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <sensrvaccelerometersensor.h>
       
    26 #include <sensrvchannel.h>
       
    27 #include <sensrvdatalistener.h>
       
    28 
       
    29 #include "csensorbase.h"
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34  *  Cacceleratorsensor
       
    35  *
       
    36  */
       
    37 class CAcceleratorSensor : public CSensorBase, public MSensrvDataListener
       
    38 {
       
    39 public:
       
    40     // Constructors and destructor
       
    41 
       
    42     /**
       
    43      * Destructor.
       
    44      */
       
    45     ~CAcceleratorSensor();
       
    46 
       
    47     /**
       
    48      * Two-phased constructor.
       
    49      */
       
    50     static CAcceleratorSensor* NewL(const TSensrvChannelInfo& aChannelInfo);
       
    51 
       
    52     /**
       
    53      * Two-phased constructor.
       
    54      */
       
    55     static CAcceleratorSensor* NewLC(const TSensrvChannelInfo& aChannelInfo);
       
    56 
       
    57 public:    // From Sensor
       
    58     int OpenChannel(SensorListener* aListener);
       
    59 
       
    60 public:    // From CSensorBase
       
    61     virtual HBufC* CreateDescriptionLC();
       
    62     virtual CSensorBase* DuplicateL();
       
    63     virtual TReal InterpretValue(TReal aValue);
       
    64     void StartDataListeningL();
       
    65     void StartConditionListeningL();
       
    66     void CancelDataListeningL();
       
    67     void CloseChannelL();
       
    68     void StopConditionListeningL();
       
    69 
       
    70 private: // New methods
       
    71     void OpenChannelL();
       
    72 
       
    73     void DescriptorAppendChannel(TPtr* aPtr, const RSensrvPropertyList aList,
       
    74                                  TInt aItemIndex);
       
    75 protected:
       
    76     void GetProperty(const RSensrvPropertyList aList,
       
    77                      const TSensrvPropertyId aPropertyId, const TInt aItemIndex,
       
    78                      TSensrvProperty& aProperty);
       
    79 
       
    80     void GetProperty(const RSensrvPropertyList aList,
       
    81                      const TSensrvPropertyId aPropertyId,
       
    82                      const TInt aItemIndex,
       
    83                      const TInt aArrayIndex,
       
    84                      TSensrvProperty& aProperty);
       
    85 
       
    86 public:    // From MSensrvDataListener
       
    87     virtual void DataReceived(CSensrvChannel& aChannel, TInt aCount, TInt aDataLost);
       
    88     void DataError(CSensrvChannel& aChannel, TSensrvErrorSeverity aError);
       
    89     void GetDataListenerInterfaceL(TUid aInterfaceUid, TAny*& aInterface);
       
    90 
       
    91 protected:
       
    92     /**
       
    93      * Constructor for performing 1st stage construction
       
    94      */
       
    95     CAcceleratorSensor(const TSensrvChannelInfo& aChannelInfo);
       
    96 
       
    97     /**
       
    98      * EPOC default constructor for performing 2nd stage construction
       
    99      */
       
   100     void ConstructL();
       
   101 
       
   102 protected: // Methods used to differentiate between double value and raw data versions
       
   103     virtual void Model(TPtr* aPtr);
       
   104     virtual void DataType(TPtr* aPtr);
       
   105     virtual void DataUnit(const RSensrvPropertyList aList, TPtr* aPtr);
       
   106     virtual void DataRange(const RSensrvPropertyList aList,
       
   107                            TPtr* aPtr);
       
   108     virtual void CopyData(const TSensrvAccelerometerAxisData aData,
       
   109                           TInt aIndex);
       
   110     virtual TInt SensorDescriptionId();
       
   111 
       
   112 protected: // Data
       
   113 
       
   114     /**
       
   115      * Channel information
       
   116      */
       
   117     TSensrvChannelInfo iChannelInfo;
       
   118     CSensrvChannel* iChannel;
       
   119 
       
   120     // Datas per channel
       
   121     SensorData* iChannelXData;
       
   122     SensorData* iChannelYData;
       
   123     SensorData* iChannelZData;
       
   124 
       
   125     // Multplier for scaled measurement values
       
   126     TReal iScaleFactor;
       
   127 
       
   128     // Start time of datalistening
       
   129     TTime iStartTime;
       
   130 };
       
   131 
       
   132 #endif // CACCELERATORSENSOR_H
       
   133