EduArt Sensor Ring Library 3.0.0
Loading...
Searching...
No Matches
eduart::manager::MeasurementManager Class Reference

Meta class that handles the timing, triggering and processing of sensor measurements. Internally it runs a looping state machine. More...

#include <MeasurementManager.hpp>

Public Member Functions

 MeasurementManager (ManagerParams params, std::unique_ptr< ring::SensorRing > sensor_ring)
 Construct the manager with parameters and owned SensorRing.
 ~MeasurementManager () noexcept
 Destructor.
bool measureSome () noexcept
 Run one processing cycle of the state machine worker.
bool startMeasuring () noexcept
 Start the state machine worker loop in a dedicated thread.
bool stopMeasuring () noexcept
 Stop the state machine worker loop and join the thread.
bool isMeasuring () noexcept
 Report whether the measurement worker thread is running.
subscription::Subscription subscribeToStateChanges (std::function< void(const ManagerState state)> callback)
 Subscribe to state changes; callback is invoked when the state changes.
subscription::Subscription subscribeToDeviceGroup (device::DeviceType key, std::function< void(const device::DeviceGroup &)> callback)
 Subscribe to device group updates; callback is invoked when the group is updated.
void unsubscribe (subscription::SubscriberToken token)
 Cancel a subscription.
ManagerState getManagerState () const noexcept
 Return the current health state of the state machine worker.
ManagerParams getParams () const noexcept
 Return the parameters used to initialize the manager.
ring::SensorRinggetSensorRing () const noexcept
 Return the SensorRing managed by this manager.
void enqueueExtraAction (std::function< void()> action)
 Queue a callable to run once in the next extra-actions slot of the state machine.

Detailed Description

Meta class that handles the timing, triggering and processing of sensor measurements. Internally it runs a looping state machine.

Constructor & Destructor Documentation

◆ MeasurementManager()

eduart::manager::MeasurementManager::MeasurementManager ( ManagerParams params,
std::unique_ptr< ring::SensorRing > sensor_ring )

Construct the manager with parameters and owned SensorRing.

Parameters
[in]paramsManager configuration.
[in]sensor_ringSensorRing instance to manage (ownership transferred).

Member Function Documentation

◆ enqueueExtraAction()

void eduart::manager::MeasurementManager::enqueueExtraAction ( std::function< void()> action)

Queue a callable to run once in the next extra-actions slot of the state machine.

Parameters
[in]actionCallable executed once from the measurement thread; should be non-blocking and exception-safe.

◆ getManagerState()

ManagerState eduart::manager::MeasurementManager::getManagerState ( ) const
noexcept

Return the current health state of the state machine worker.

Returns
Current manager state.

◆ getParams()

ManagerParams eduart::manager::MeasurementManager::getParams ( ) const
noexcept

Return the parameters used to initialize the manager.

Returns
Initial parameter struct.

◆ getSensorRing()

ring::SensorRing * eduart::manager::MeasurementManager::getSensorRing ( ) const
noexcept

Return the SensorRing managed by this manager.

Returns
Pointer to the managed SensorRing (never null while manager is alive).

◆ isMeasuring()

bool eduart::manager::MeasurementManager::isMeasuring ( )
noexcept

Report whether the measurement worker thread is running.

Returns
true if the measurement thread is running.

◆ measureSome()

bool eduart::manager::MeasurementManager::measureSome ( )
noexcept

Run one processing cycle of the state machine worker.

Returns
true on success.

◆ startMeasuring()

bool eduart::manager::MeasurementManager::startMeasuring ( )
noexcept

Start the state machine worker loop in a dedicated thread.

Returns
true on success.

◆ stopMeasuring()

bool eduart::manager::MeasurementManager::stopMeasuring ( )
noexcept

Stop the state machine worker loop and join the thread.

Returns
true on success.

◆ subscribeToDeviceGroup()

subscription::Subscription eduart::manager::MeasurementManager::subscribeToDeviceGroup ( device::DeviceType key,
std::function< void(const device::DeviceGroup &)> callback )

Subscribe to device group updates; callback is invoked when the group is updated.

Parameters
[in]keyDevice group to subscribe to.
[in]callbackInvoked with the updated DeviceGroup.
Returns
RAII Subscription that auto-cancels on destruction.

◆ subscribeToStateChanges()

subscription::Subscription eduart::manager::MeasurementManager::subscribeToStateChanges ( std::function< void(const ManagerState state)> callback)

Subscribe to state changes; callback is invoked when the state changes.

Parameters
[in]callbackInvoked with the updated ManagerState.
Returns
RAII Subscription that auto-cancels on destruction.

◆ unsubscribe()

void eduart::manager::MeasurementManager::unsubscribe ( subscription::SubscriberToken token)

Cancel a subscription.

Parameters
[in]tokenToken returned by subscribeToDeviceGroup or subscribeToStateChanges.

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