javaextensions/sensor/src/sensor.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14: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:  Interface for Sensor
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef SENSOR_H
       
    19 #define SENSOR_H
       
    20 
       
    21 
       
    22 // FORWARD DECLARATIONS
       
    23 class SensorListener;
       
    24 
       
    25 /**
       
    26  * SensorData struct for storing data arrays
       
    27  */
       
    28 struct SensorData
       
    29 {
       
    30     SensorData():
       
    31             iIntValues(0),
       
    32             iDoubleValues(0),
       
    33             iValidities(0),
       
    34             iTimeStamps(0),
       
    35             iNumOfValues(0)
       
    36     { }
       
    37     ~SensorData()
       
    38     {
       
    39         delete iIntValues;
       
    40         delete iDoubleValues;
       
    41         delete iValidities;
       
    42         delete iTimeStamps;
       
    43     }
       
    44     // Array of int values (could be null, if not supported by sensor)
       
    45     int* iIntValues;
       
    46     // Array of double values (could be null, if not supported by sensor)
       
    47     double* iDoubleValues;
       
    48     // Array of validities (could be null if not asked by user)
       
    49     bool* iValidities;
       
    50     // Array of time stamps (could be null if not asked by user)
       
    51     long long* iTimeStamps;
       
    52     // Number of data values
       
    53     long iNumOfValues;
       
    54     // Wanted buffer size
       
    55     int iBufferSize;
       
    56     // Time stamps included
       
    57     bool iTimeStampsIncluded;
       
    58     // Validities included
       
    59     bool iValiditiesIncluded;
       
    60 };
       
    61 
       
    62 // CLASS DESCRIPTION
       
    63 /**
       
    64  * Interface for Sensor
       
    65  * Used for controlling sensors
       
    66  *
       
    67  * @lib N/A
       
    68  * @since S60 3.2
       
    69  */
       
    70 class Sensor
       
    71 {
       
    72 public: // New methods
       
    73     /**
       
    74      * Starts the server for listening the events, does nothing if not
       
    75      * needed
       
    76      */
       
    77     virtual void StartServer() = 0;
       
    78 
       
    79     /**
       
    80      * Stops server
       
    81      */
       
    82     virtual void StopServer() = 0;
       
    83 
       
    84     /**
       
    85      * Opens channel to sensor, must be called before
       
    86      * starting listening, sets listener
       
    87      * @param Listener
       
    88      * @return possible error codes, 0 for no error
       
    89      */
       
    90     virtual int OpenChannel(SensorListener* aListener) = 0;
       
    91 
       
    92     /**
       
    93      * Starts listening the data
       
    94      * @param aData, array of sensor datas to be filled
       
    95      * @param aBufferSize number of data values listened
       
    96      * @param aBufferingPeriod, the time to buffer values -
       
    97      *                             given in milliseconds,
       
    98      *                             bufferingPeriod < 1 means the
       
    99      *                             period is left undefined
       
   100      * @param aTimestampsIncluded if true timestamps should
       
   101      *                               be included in returned Data objects
       
   102      * @param aValiditiesIncluded if true validities should be included
       
   103      *                               in returned Data objects
       
   104      * @param aIsOneShot, true if only one data is needed, (getData)
       
   105      *                       false if continuos data retrieval (data listening)
       
   106      * @return possible error codes, 0 for no error
       
   107      */
       
   108     virtual int StartDataListening(SensorData** aData,
       
   109                                    int aBufferSize,
       
   110                                    long aBufferingPeriod,
       
   111                                    bool aTimestampsIncluded,
       
   112                                    bool aValiditiesIncluded,
       
   113                                    bool aIsOneShot) = 0;
       
   114 
       
   115     /**
       
   116      * Cancel listening to data
       
   117      */
       
   118     virtual int CancelDataListening() = 0;
       
   119 
       
   120     /**
       
   121      * Closes channel to sensor
       
   122      */
       
   123     virtual void CloseChannel() = 0;
       
   124 
       
   125 
       
   126     /**
       
   127      * Adds condition and starts condition listening
       
   128      *
       
   129      * @param aHandle pointer to created condition object
       
   130      * @param aChannelId channel index
       
   131      * @param aLowerLimit limit or lower limit of range
       
   132      * @param aUpperLimit upper limit or discarded in case of LimitCondition
       
   133      * @param aLowerOp operator type for limit or lower limit in range
       
   134      * @param aUpperOp upper limit operator or discarded in case of LimitCondition
       
   135      * @return int error code. ERROR_NONE if no error.
       
   136      */
       
   137     virtual int AddCondition(
       
   138         void** aHandle,
       
   139         int aChannelId,
       
   140         double aLowerLimit,
       
   141         double aUpperLimit,
       
   142         int aLowerOp,
       
   143         int aUpperOp) = 0;
       
   144 
       
   145     /**
       
   146      * Removes condition from native side
       
   147      * @param aHandle pointer to condition object to remove
       
   148      */
       
   149     virtual int RemoveCondition(
       
   150         void* aHandle) = 0;
       
   151 
       
   152     /**
       
   153      * Starts condition listening
       
   154      * @param aListeningType, 0 means normal condition listening
       
   155      *                           1 means that condition listening is done in java side
       
   156      *                             and all values are passed (native conditions ignored)
       
   157      *
       
   158      */
       
   159     virtual int StartConditionListening(int aListeningType) = 0;
       
   160 
       
   161     /**
       
   162      * Starts condition listening
       
   163      */
       
   164     virtual int StopConditionListening() = 0;
       
   165 
       
   166     /**
       
   167      * Destructor, to allow deletion through this interface
       
   168      */
       
   169     virtual ~Sensor() {};
       
   170 };
       
   171 #endif // SENSOR_H
       
   172 
       
   173 // End of file