Abstract base class for Sensord APIs. More...
#include <qmsensor.h>
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 |
Abstract base class for Sensord APIs.
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.
Possible session types for sensor
SessionTypeNone |
No open session |
SessionTypeListen |
Listening session |
SessionTypeControl |
Control session |
Definition at line 115 of file qmsensor.h.
virtual MeeGo::QmSensor::~QmSensor | ( | ) | [virtual] |
MeeGo::QmSensor::QmSensor | ( | QObject * | parent | ) | [protected] |
Constructor. This class should not be instantiated.
void MeeGo::QmSensor::closeSession | ( | ) |
Closes an open session by calling stop().
void MeeGo::QmSensor::errorSignal | ( | QString | error | ) | [signal] |
Emitted when an error occurs. See lastError().
error | Human readable string describing the error |
int MeeGo::QmSensor::interval | ( | ) |
Returns the current poll interval request made by this client.
bool MeeGo::QmSensor::isRunning | ( | ) |
Returns whether the sensor is in running state.
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.
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
.
type | The type of session to request |
SessionType MeeGo::QmSensor::sessionType | ( | ) |
Gets the type of current session.
void MeeGo::QmSensor::setInterval | ( | int | value | ) |
Sets a polling interval request for sensord.
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.
value | Activate or deactive standby override |
bool MeeGo::QmSensor::standbyOverride | ( | ) |
Returns the current request of this client for standby override. See setStandbyOverride for details.
bool MeeGo::QmSensor::start | ( | ) |
Starts the measurement process.
True
on successfull start or already running, false
on error bool MeeGo::QmSensor::stop | ( | ) |
Stops the measurement process.
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
.
True
if same or higher, false
if lower 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.