Public Types | Signals | Public Member Functions | Protected Member Functions | Properties

MeeGo::QmSensor Class Reference

Abstract base class for Sensord APIs. More...

#include <qmsensor.h>

Inheritance diagram for MeeGo::QmSensor:
Inheritance graph
[legend]

List of all members.

Public Types

enum  SessionType { SessionTypeNone, SessionTypeListen, SessionTypeControl }

Signals

void errorSignal (QString error)

Public Member Functions

virtual ~QmSensor ()
SessionType sessionType ()
bool verifySessionLevel (QmSensor::SessionType type)
bool start ()
bool stop ()
bool isRunning ()
SessionType requestSession (SessionType type=SessionTypeControl)
void closeSession ()
QString lastError () const
int interval ()
void setInterval (int value)
bool standbyOverride ()
void setStandbyOverride (bool value)

Protected Member Functions

 QmSensor (QObject *parent)
 MEEGO_DECLARE_PROTECTED (QmSensor)

Properties

QString lastError
int interval
bool standbyOverride

Detailed Description

Abstract base class for Sensord APIs.

Scope:
Internal

QmSensor provides common functions for all sensors served by sensord. To use sensors, client must initiate communication to a server by requesting a session. Then, the client can use start() and stop() to control the dataflow.

Data is provided through signals, but the previous measurement is usually accessible through accessor function and/or property. It is worth to note that measurements in server side are done when any client is requesting data from the sensor. The previous measurement will thus always match the last made measurement, regardless of current client's running state. Likewise, if no client is in running state, no measurement is done and the previous measured value may be undefined or outdated.

Sample use of sensor class ALSSensor:

 #include <qmals.h>
 QmALS* als;
 als = new QmALS();
 connect(als, SIGNAL(ALSChange(int)), this, SLOT(ALSChanged(int)));

 if (als->requestSession(QmSensor::SessionTypeListen) == QmSensor::SessionTypeNone) {
     qDebug() << "Failed to get listen session:" << als->lastError();
 }
 als->start();
 als->stop();
 delete als;

Definition at line 105 of file qmsensor.h.


Member Enumeration Documentation

Possible session types for sensor

Enumerator:
SessionTypeNone 

No open session

SessionTypeListen 

Listening session

SessionTypeControl 

Control session

Definition at line 115 of file qmsensor.h.


Constructor & Destructor Documentation

virtual MeeGo::QmSensor::~QmSensor (  )  [virtual]
MeeGo::QmSensor::QmSensor ( QObject *  parent  )  [protected]

Constructor. This class should not be instantiated.


Member Function Documentation

void MeeGo::QmSensor::closeSession (  ) 

Closes an open session by calling stop().

Deprecated:
Deprecated, use stop() instead
void MeeGo::QmSensor::errorSignal ( QString  error  )  [signal]

Emitted when an error occurs. See lastError().

Parameters:
error Human readable string describing the error
int MeeGo::QmSensor::interval (  ) 

Returns the current poll interval request made by this client.

Returns:
Current poll interval request
bool MeeGo::QmSensor::isRunning (  ) 

Returns whether the sensor is in running state.

Returns:
True for running state, false for stopped state
QString MeeGo::QmSensor::lastError (  )  const

Gets an explanatory message for previous error. The returned string always corresponds to the previous error that has occurred. Thus, it should be checked immediately after a function has returned a value indicating an error.

Returns:
QString containing human readable error description
MeeGo::QmSensor::MEEGO_DECLARE_PROTECTED ( QmSensor   )  [protected]
SessionType MeeGo::QmSensor::requestSession ( SessionType  type = SessionTypeControl  ) 

Requests a session for the sensor from sensor daemon. If the requested type of session is not granted, the function will set error and automatically fall back to attempting to gain a session of next type. Order is SessionTypeControl -> SessionTypeListen -> SessionTypeNone.

Parameters:
type The type of session to request
Returns:
Type of the session that was received. If differs from requested type, an error has been set.
SessionType MeeGo::QmSensor::sessionType (  ) 

Gets the type of current session.

Returns:
Type of current session
void MeeGo::QmSensor::setInterval ( int  value  ) 

Sets a polling interval request for sensord.

Parameters:
value Interval value to set in milliseconds
void MeeGo::QmSensor::setStandbyOverride ( bool  value  ) 

Sets a request to override sensor standby mode on screen blank event. During normal operation, screen blanking will cause all sensors to stop. Client can override this behavior by setting this property to true.

Parameters:
value Activate or deactive standby override
bool MeeGo::QmSensor::standbyOverride (  ) 

Returns the current request of this client for standby override. See setStandbyOverride for details.

Returns:
Current standby override request
bool MeeGo::QmSensor::start (  ) 

Starts the measurement process.

Returns:
True on successfull start or already running, false on error
bool MeeGo::QmSensor::stop (  ) 

Stops the measurement process.

Returns:
True on successfull stop or already stopped, false on error
bool MeeGo::QmSensor::verifySessionLevel ( QmSensor::SessionType  type  ) 

Verifies that current session is at least of level type.

Returns:
True if same or higher, false if lower

Property Documentation

int MeeGo::QmSensor::interval [read, write]

Definition at line 108 of file qmsensor.h.

QString MeeGo::QmSensor::lastError [read]

Definition at line 107 of file qmsensor.h.

bool MeeGo::QmSensor::standbyOverride [read, write]

Definition at line 109 of file qmsensor.h.


The documentation for this class was generated from the following file: