Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::SensorManager Class Reference

The SensorManager handles sensors initialization and sampling. More...

#include <SensorManager.h>

Public Types

using function_t = std::function<void()>
 
using SensorMap_t = std::map<AbstractSensor*, SensorInfo>
 

Public Member Functions

 SensorManager (const SensorMap_t &sensorsMap)
 
 SensorManager (const SensorMap_t &sensorsMap, TaskScheduler *scheduler)
 
 ~SensorManager ()
 Deallocates samplers (through the samplers vector).
 
bool start ()
 Starts the task scheduler.
 
void stop ()
 Starts the task scheduler.
 
void enableSensor (AbstractSensor *sensor)
 Enable sampling for the specified sensor.
 
void disableSensor (AbstractSensor *sensor)
 Disable sampling for the specified sensor.
 
void enableAllSensors ()
 
void disableAllSensors ()
 
bool areAllSensorsInitialized ()
 Checks whether all the sensors have been initialized correctly.
 
const SensorInfo getSensorInfo (AbstractSensor *sensor)
 
const vector< TaskStatsResultgetSamplersStats ()
 

Detailed Description

The SensorManager handles sensors initialization and sampling.

Sensors are grouped by sampling period in various SensorSampler objects. These samplers are then added to the scheduler ordered by sampling period. The scheduler then manages the samplers by calling their sampleAndCallback method periodically.

TODO: The SensorManager should be able to reinitialized sensors that have failed previous initializations.

Definition at line 47 of file SensorManager.h.

Member Typedef Documentation

◆ function_t

using Boardcore::SensorManager::function_t = std::function<void()>

Definition at line 50 of file SensorManager.h.

◆ SensorMap_t

Definition at line 51 of file SensorManager.h.

Constructor & Destructor Documentation

◆ SensorManager() [1/2]

Boardcore::SensorManager::SensorManager ( const SensorMap_t & sensorsMap)
explicit

Definition at line 30 of file SensorManager.cpp.

◆ SensorManager() [2/2]

Boardcore::SensorManager::SensorManager ( const SensorMap_t & sensorsMap,
TaskScheduler * scheduler )

Definition at line 37 of file SensorManager.cpp.

◆ ~SensorManager()

Boardcore::SensorManager::~SensorManager ( )

Deallocates samplers (through the samplers vector).

Definition at line 45 of file SensorManager.cpp.

Member Function Documentation

◆ areAllSensorsInitialized()

bool Boardcore::SensorManager::areAllSensorsInitialized ( )

Checks whether all the sensors have been initialized correctly.

Definition at line 100 of file SensorManager.cpp.

◆ disableAllSensors()

void Boardcore::SensorManager::disableAllSensors ( )

Definition at line 94 of file SensorManager.cpp.

◆ disableSensor()

void Boardcore::SensorManager::disableSensor ( AbstractSensor * sensor)

Disable sampling for the specified sensor.

Parameters
sensorThe sensor to be disabled.

Definition at line 75 of file SensorManager.cpp.

◆ enableAllSensors()

void Boardcore::SensorManager::enableAllSensors ( )

Definition at line 88 of file SensorManager.cpp.

◆ enableSensor()

void Boardcore::SensorManager::enableSensor ( AbstractSensor * sensor)

Enable sampling for the specified sensor.

Parameters
sensorThe sensor to be enabled.

Definition at line 62 of file SensorManager.cpp.

◆ getSamplersStats()

const vector< TaskStatsResult > Boardcore::SensorManager::getSamplersStats ( )
Returns
Vector of statistics, one for each sampler, taken from the scheduler.

Definition at line 113 of file SensorManager.cpp.

◆ getSensorInfo()

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

Definition at line 102 of file SensorManager.cpp.

◆ start()

bool Boardcore::SensorManager::start ( )

Starts the task scheduler.

Definition at line 53 of file SensorManager.cpp.

◆ stop()

void Boardcore::SensorManager::stop ( )

Starts the task scheduler.

Definition at line 60 of file SensorManager.cpp.


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