Skyward boardcore
|
Virtual sensor sampler class. More...
#include <SensorSampler.h>
Public Member Functions | |
SensorSampler (uint8_t id, std::chrono::nanoseconds period) | |
virtual | ~SensorSampler () |
bool | operator== (const SensorSampler &sampler) const |
virtual void | addSensor (AbstractSensor *sensor, SensorInfo sensorInfo)=0 |
Add a sensor to the sensors map. | |
void | toggleSensor (AbstractSensor *sensor, bool isEnabled) |
Enabled or disable a sensor. | |
void | enableAllSensors () |
Enable sampling for all the sensors. | |
void | disableAllSensors () |
Disable sampling for all the sensors. | |
void | sampleAndCallback () |
For each sensor, sample it and call the corresponding callback. | |
uint8_t | getID () |
std::chrono::nanoseconds | getSamplingPeriod () |
unsigned int | getNumSensors () |
const SensorInfo | getSensorInfo (AbstractSensor *sensor) |
Static Public Member Functions | |
static bool | compareByPeriod (SensorSampler *left, SensorSampler *right) |
Protected Attributes | |
std::vector< std::pair< AbstractSensor *, SensorInfo > > | sensors |
PrintLogger | logger = Logging::getLogger("sensorsampler") |
Virtual sensor sampler class.
When requested, a SensorSampler samples all the enabled sensors it manages. After sampling a sensor, the SensorSampler calls the callback associated with that sensor, where these samples can be processed.
Definition at line 42 of file SensorSampler.h.
Boardcore::SensorSampler::SensorSampler | ( | uint8_t | id, |
std::chrono::nanoseconds | period ) |
id | Sampler identifier. |
period | Period at which the sampler performs sensors update. |
Definition at line 31 of file SensorSampler.cpp.
|
virtual |
Definition at line 36 of file SensorSampler.cpp.
|
pure virtual |
Add a sensor to the sensors map.
sensor | The sensor to be added. |
Implemented in Boardcore::SimpleSensorSampler.
|
static |
Definition at line 38 of file SensorSampler.cpp.
void Boardcore::SensorSampler::disableAllSensors | ( | ) |
Disable sampling for all the sensors.
Definition at line 60 of file SensorSampler.cpp.
void Boardcore::SensorSampler::enableAllSensors | ( | ) |
Enable sampling for all the sensors.
Definition at line 54 of file SensorSampler.cpp.
uint8_t Boardcore::SensorSampler::getID | ( | ) |
Definition at line 81 of file SensorSampler.cpp.
unsigned int Boardcore::SensorSampler::getNumSensors | ( | ) |
Definition at line 85 of file SensorSampler.cpp.
std::chrono::nanoseconds Boardcore::SensorSampler::getSamplingPeriod | ( | ) |
Definition at line 83 of file SensorSampler.cpp.
const SensorInfo Boardcore::SensorSampler::getSensorInfo | ( | AbstractSensor * | sensor | ) |
Definition at line 87 of file SensorSampler.cpp.
|
inline |
Definition at line 53 of file SensorSampler.h.
void Boardcore::SensorSampler::sampleAndCallback | ( | ) |
For each sensor, sample it and call the corresponding callback.
Definition at line 66 of file SensorSampler.cpp.
void Boardcore::SensorSampler::toggleSensor | ( | AbstractSensor * | sensor, |
bool | isEnabled ) |
Enabled or disable a sensor.
sensor | The sensor to be toggled (enabled/disabled). |
isEnabled | Bool value to be set in the sensor info to indicate if the sensor will be enabled or disabled. |
Definition at line 43 of file SensorSampler.cpp.
|
protected |
Definition at line 112 of file SensorSampler.h.
|
protected |
Definition at line 110 of file SensorSampler.h.