semf
semf::app::Sensor< T_CONVERTED > Class Template Referenceabstract

Application class for a sensor system. More...

#include <sensor.h>

Inheritance diagram for semf::app::Sensor< T_CONVERTED >:
Inheritance graph
Collaboration diagram for semf::app::Sensor< T_CONVERTED >:
Collaboration graph

Public Member Functions

virtual ~Sensor ()=default
 
virtual T_CONVERTED currentValue () const =0
 Returns the last measured converted value. More...
 
virtual T_CONVERTED averageValue () const =0
 Returns the converted value of the average measured raw values. More...
 
virtual void update ()=0
 Triggers the sensor hardware to start a measurement cycle. More...
 

Public Attributes

Signal dataAvailable
 

Detailed Description

template<typename T_CONVERTED>
class semf::app::Sensor< T_CONVERTED >

Application class for a sensor system.

In Sensor a measurement cycle can be triggered by calling update(). After completion dataAvailable gets emitted and the function currentValue() and averageValue() can be used to acquire the measured values. Multiple Sensor objects can be connected to one HardwareSensor. For having a simple conversion function, SimpleSensorConverter can be an simple option.

For building a sensor system, you need:

  1. Object from a class inheriting from HardwareSensor like AnalogSensor or AnalogDmaSensor.
  2. Data buffer.
  3. Object from a class inheriting from Sensor base class and overwriting the convert() function.
Template Parameters
T_CONVERTEDType of an application/usable sensor value which has an unit, e.g. float for temperature [°C].
See also
SensorConverter
SimpleSensorConverter
HardwareSensor

Definition at line 40 of file sensor.h.

Constructor & Destructor Documentation

◆ ~Sensor()

template<typename T_CONVERTED >
virtual semf::app::Sensor< T_CONVERTED >::~Sensor ( )
virtualdefault

Member Function Documentation

◆ averageValue()

template<typename T_CONVERTED >
virtual T_CONVERTED semf::app::Sensor< T_CONVERTED >::averageValue ( ) const
pure virtual

Returns the converted value of the average measured raw values.

Returns
Converted value based on an average of raw measurements.

◆ currentValue()

template<typename T_CONVERTED >
virtual T_CONVERTED semf::app::Sensor< T_CONVERTED >::currentValue ( ) const
pure virtual

Returns the last measured converted value.

Returns
Converted value based on a single raw measurement.

◆ update()

template<typename T_CONVERTED >
virtual void semf::app::Sensor< T_CONVERTED >::update ( )
pure virtual

Triggers the sensor hardware to start a measurement cycle.

Note
dataAvailable signal is emitted for new sensor data is available.

Member Data Documentation

◆ dataAvailable

template<typename T_CONVERTED >
Signal semf::app::Sensor< T_CONVERTED >::dataAvailable

Gets emitted when new sensor data is available.

Definition at line 62 of file sensor.h.