luna-sysmgr-common
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NYXConnectorBase Class Referenceabstract

#include <NyxSensorConnector.h>

Inheritance diagram for NYXConnectorBase:
[legend]
Collaboration diagram for NYXConnectorBase:
[legend]

Public Types

enum  Sensor {
  SensorIllegal = 0, SensorFirst, SensorAcceleration = SensorFirst, SensorOrientation,
  SensorShake, SensorALS, SensorAngularVelocity, SensorBearing,
  SensorGravity, SensorLinearAcceleration, SensorMagneticField, SensorScreenProximity,
  SensorRotation, SensorLogicalAccelerometer, SensorLogicalOrientation, SensorLogicalDeviceOrientation,
  SensorLogicalMotion, SensorLast = SensorLogicalMotion
}
 
enum  SensorReportRate {
  SensorReportRateUnknown = NYX_REPORT_RATE_UNKNOWN, SensorReportRateDefault = NYX_REPORT_RATE_DEFAULT, SensorReportRateLow = NYX_REPORT_RATE_LOW, SensorReportRateMedium = NYX_REPORT_RATE_MEDIUM,
  SensorReportRateHigh = NYX_REPORT_RATE_HIGH, SensorReportRateHighest = NYX_REPORT_RATE_HIGHEST, SensorReportRateCount = NYX_REPORT_RATE_COUNT
}
 Defines all valid poll rates for sensors. More...
 

Signals

virtual void sensorDataAvailable ()
 

Public Member Functions

virtual ~NYXConnectorBase ()
 
virtual bool on ()
 
virtual bool off ()
 
virtual bool setRate (SensorReportRate aRate)
 
virtual void setOrientationAngle (int aAngle)
 
virtual std::string toJSONString ()
 
virtual json_object * toJSONObject ()=0
 
virtual QEventgetQSensorData ()=0
 
virtual nyx_device_handle_t getHandle ()
 
Sensor type ()
 
virtual void scheduleDeletion ()
 

Static Public Member Functions

static std::vector
< NYXConnectorBase::Sensor
getSupportedSensors ()
 
static std::string getSupportedSensors (bool bJson)
 
static NYXConnectorBasegetSensor (Sensor aSensorType, NYXConnectorObserver *aObserver=0, bool bCanPostEvent=true)
 

Protected Slots

virtual void readSensorData (int aSocket)=0
 

Protected Member Functions

 NYXConnectorBase (Sensor aSensorType, nyx_device_type_t aDevType, nyx_device_id_t aDevID, NYXConnectorObserver *aObserver, bool bCanPostEvent)
 
virtual nyx_error_t openSensor ()
 
virtual void connectSensorSignalToSlot ()
 
void callObserver (bool aShouldEmit=true)
 
bool canPostEvent ()
 
virtual void postProcessSensorData ()
 

Protected Attributes

Sensor m_SensorType
 
QSocketNotifier * m_NYXSensorNotifier
 
nyx_device_handle_t m_Handle
 
nyx_device_type_t m_NYXDeviceType
 
nyx_device_id_t m_NYXDeviceId
 
NYXConnectorObserverm_Observer
 
int m_SensorFD
 
bool m_CanPostEvent
 
int m_OrientationAngle
 
bool m_Finished
 

Detailed Description

Base Class for a connector to physical Sensors/devices using NYX APIs

Member Enumeration Documentation

Enumerator
SensorIllegal 
SensorFirst 
SensorAcceleration 
SensorOrientation 
SensorShake 
SensorALS 
SensorAngularVelocity 
SensorBearing 
SensorGravity 
SensorLinearAcceleration 
SensorMagneticField 
SensorScreenProximity 
SensorRotation 
SensorLogicalAccelerometer 

A logical sensor made of 4 physical sensors (Acceleration, Orientation, Shake & Rotation)

SensorLogicalOrientation 

A logical sensor made of 2 physical sensors (Orientation, Rotation). Do not add any other physical sensor as it may slow down the whole device

SensorLogicalDeviceOrientation 

A logical sensor made of 2 physical sensors (Rotation & Bearing)

SensorLogicalMotion 

A logical sensor made of 4 physical sensors (Rotation, Bearing, Acceleration & Linear Acceleration)

SensorLast 

Device iterators should stop iterating beyond this point

Defines all valid poll rates for sensors.

Each sensor module that polls for events defines a corresponding rate (in samples per second) for each of these values.

Enumerator
SensorReportRateUnknown 

Report rate is unknown

SensorReportRateDefault 

Default reporting rate for sensor when user has not requested specific rate

SensorReportRateLow 

Slow rate of reporting sensor events

SensorReportRateMedium 

Medium rate of reporting sensor events

SensorReportRateHigh 

Fast rate of reporting sensor events

SensorReportRateHighest 

Fastest rate of reporting sensor events

SensorReportRateCount 

Must always be last

Constructor & Destructor Documentation

NYXConnectorBase::~NYXConnectorBase ( )
virtual

default destructor

NYXConnectorBase::NYXConnectorBase ( Sensor  aSensorType,
nyx_device_type_t  aDevType,
nyx_device_id_t  aDevID,
NYXConnectorObserver aObserver,
bool  bCanPostEvent 
)
protected

Parameterize constructor

Parameters
[in]aSensorType- Sensor Type
[in]aDevType- NYX device Type
[in]aDevID- NYX device ID
[in]aObserver- Observer for the NYX device
[in]bCanPostEvent- Defines whether a particular sensor can post event data or not

Member Function Documentation

void NYXConnectorBase::callObserver ( bool  aShouldEmit = true)
protected

Function emits sensorDataAvailable() signal based on the passed argument Once the signal is emitted it calls the observer

Parameters
[in]aShouldEmit- Whether to emit signal or not. Default to true.
bool NYXConnectorBase::canPostEvent ( )
inlineprotected

Find out whether a particular sensor can post event data or not

void NYXConnectorBase::connectSensorSignalToSlot ( )
protectedvirtual

Connects the Sensor FD to a SLOT Override this method if a sensor has some other slot to register than the default one

Reimplemented in NYXLogicalSensorConnectorBase.

virtual nyx_device_handle_t NYXConnectorBase::getHandle ( )
inlinevirtual

Gets the low level NYX handle for the sensor

Returns
valid handle, NULL otherwise
NYXConnectorBase * NYXConnectorBase::getSensor ( Sensor  aSensorType,
NYXConnectorObserver aObserver = 0,
bool  bCanPostEvent = true 
)
static

Factory method which initializes(opens) the appropriate sensor and returns a valid instance.

Parameters
[in]aSensorType- Sensor Type
[in]bCanPostEvent- Control whether sensor can post event data to applications or not By default it sends sensor data.
[in]aObserver- Observer for the NYX Connectors.
Returns
appropriate Sensor instance if successful, NULL otherwise
std::vector< NYXConnectorBase::Sensor > NYXConnectorBase::getSupportedSensors ( )
static

Function returns the available sensors for the current device

Returns
list of sensors in a vector
std::string NYXConnectorBase::getSupportedSensors ( bool  bJson)
static

Function returns the available sensors for the current device

Parameters
aJson- This is a Fake argument and won't be used. This is just to re-use the method name
Returns
json Array List
bool NYXConnectorBase::off ( )
virtual

Stop the appropriate sensor

Returns
true if successful, false otherwise

Reimplemented in NYXLogicalSensorConnectorBase.

bool NYXConnectorBase::on ( )
virtual

Start the appropriate sensor

Returns
true if successful, false otherwise

Reimplemented in NYXLogicalSensorConnectorBase.

nyx_error_t NYXConnectorBase::openSensor ( )
protectedvirtual

Opens a given sensor. Override this method if a sensor doesn't wants to be opened in a default way.

Reimplemented in NYXLogicalSensorConnectorBase.

virtual void NYXConnectorBase::postProcessSensorData ( )
inlineprotectedvirtual

Implement this method, if a sensor requires post processing of the sensor data before sending it for App consumption

Reimplemented in NYXRotationSensorConnector, NYXOrientationSensorConnector, and NYXAccelerationSensorConnector.

virtual void NYXConnectorBase::readSensorData ( int  aSocket)
protectedpure virtualslot

SLOT gets called whenever there is some sensor data available to read.

Parameters
[in]aSocket- Socket identifier
void NYXConnectorBase::scheduleDeletion ( )
virtual

Function marks this object for deletion As Qt deleteLater() is not working as expected, we will add an idle runloop callback which will help us delete this object

Reimplemented in NYXLogicalSensorConnectorBase.

virtual void NYXConnectorBase::sensorDataAvailable ( )
virtualsignal

SIGNAL is emitted whenever sensor data is available to consume

virtual void NYXConnectorBase::setOrientationAngle ( int  aAngle)
inlinevirtual

Sets the Orientation angle, which will be taken into account while processing sensor data for Accelerometer, Rotation, Bearing (Compass) and Gyro

Parameters
aAngle- Angle

Reimplemented in NYXLogicalSensorConnectorBase.

bool NYXConnectorBase::setRate ( SensorReportRate  aRate)
virtual

Sets the report rate for the sensor

Parameters
[in]aRate- report rate
Returns
appropriate Sensor instance if successful, NULL otherwise

Reimplemented in NYXLogicalSensorConnectorBase.

virtual json_object* NYXConnectorBase::toJSONObject ( )
pure virtual

Gets the sensor data as a json Object

Returns
sensor data as a json object if successful, NULL otherwise
Note
The json object ownership is transferred to the caller and will be responsible for freeing it using json_object_put(<object>);

Implemented in NYXLogicalSensorConnectorBase, NYXShakeSensorConnector, NYXRotationSensorConnector, NYXScreenProximitySensorConnector, NYXOrientationSensorConnector, NYXMagneticFieldSensorConnector, NYXLinearAccelearationSensorConnector, NYXGravitySensorConnector, NYXBearingSensorConnector, NYXAngularVelocitySensorConnector, NYXAlsSensorConnector, and NYXAccelerationSensorConnector.

std::string NYXConnectorBase::toJSONString ( )
virtual

Gets the sensor data in json format

Returns
sensor data in json format if successful, "" (empty string) otherwise
Sensor NYXConnectorBase::type ( )
inline

Gets the Sensor Type

Returns
appropriate valid Sensor type, SENSOR_ILLEGAL if not initialized

Member Data Documentation

bool NYXConnectorBase::m_CanPostEvent
protected
bool NYXConnectorBase::m_Finished
protected
nyx_device_handle_t NYXConnectorBase::m_Handle
protected
nyx_device_id_t NYXConnectorBase::m_NYXDeviceId
protected
nyx_device_type_t NYXConnectorBase::m_NYXDeviceType
protected
QSocketNotifier* NYXConnectorBase::m_NYXSensorNotifier
protected
NYXConnectorObserver* NYXConnectorBase::m_Observer
protected
int NYXConnectorBase::m_OrientationAngle
protected
int NYXConnectorBase::m_SensorFD
protected
Sensor NYXConnectorBase::m_SensorType
protected

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