Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::SensorSampler Class Referenceabstract

Virtual sensor sampler class. More...

#include <SensorSampler.h>

Inheritance diagram for Boardcore::SensorSampler:
Collaboration diagram for Boardcore::SensorSampler:

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")
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SensorSampler()

Boardcore::SensorSampler::SensorSampler ( uint8_t id,
std::chrono::nanoseconds period )
Parameters
idSampler identifier.
periodPeriod at which the sampler performs sensors update.

Definition at line 31 of file SensorSampler.cpp.

◆ ~SensorSampler()

Boardcore::SensorSampler::~SensorSampler ( )
virtual

Definition at line 36 of file SensorSampler.cpp.

Member Function Documentation

◆ addSensor()

virtual void Boardcore::SensorSampler::addSensor ( AbstractSensor * sensor,
SensorInfo sensorInfo )
pure virtual

Add a sensor to the sensors map.

Parameters
sensorThe sensor to be added.

Implemented in Boardcore::SimpleSensorSampler.

◆ compareByPeriod()

bool Boardcore::SensorSampler::compareByPeriod ( SensorSampler * left,
SensorSampler * right )
static

Definition at line 38 of file SensorSampler.cpp.

◆ disableAllSensors()

void Boardcore::SensorSampler::disableAllSensors ( )

Disable sampling for all the sensors.

Definition at line 60 of file SensorSampler.cpp.

◆ enableAllSensors()

void Boardcore::SensorSampler::enableAllSensors ( )

Enable sampling for all the sensors.

Definition at line 54 of file SensorSampler.cpp.

◆ getID()

uint8_t Boardcore::SensorSampler::getID ( )

Definition at line 81 of file SensorSampler.cpp.

◆ getNumSensors()

unsigned int Boardcore::SensorSampler::getNumSensors ( )

Definition at line 85 of file SensorSampler.cpp.

◆ getSamplingPeriod()

std::chrono::nanoseconds Boardcore::SensorSampler::getSamplingPeriod ( )

Definition at line 83 of file SensorSampler.cpp.

◆ getSensorInfo()

const SensorInfo Boardcore::SensorSampler::getSensorInfo ( AbstractSensor * sensor)

Definition at line 87 of file SensorSampler.cpp.

◆ operator==()

bool Boardcore::SensorSampler::operator== ( const SensorSampler & sampler) const
inline

Definition at line 53 of file SensorSampler.h.

◆ sampleAndCallback()

void Boardcore::SensorSampler::sampleAndCallback ( )

For each sensor, sample it and call the corresponding callback.

Definition at line 66 of file SensorSampler.cpp.

◆ toggleSensor()

void Boardcore::SensorSampler::toggleSensor ( AbstractSensor * sensor,
bool isEnabled )

Enabled or disable a sensor.

Parameters
sensorThe sensor to be toggled (enabled/disabled).
isEnabledBool 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.

Member Data Documentation

◆ logger

PrintLogger Boardcore::SensorSampler::logger = Logging::getLogger("sensorsampler")
protected

Definition at line 112 of file SensorSampler.h.

◆ sensors

std::vector<std::pair<AbstractSensor*, SensorInfo> > Boardcore::SensorSampler::sensors
protected

Definition at line 110 of file SensorSampler.h.


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