5 #ifndef HERALD_SENSOR_ARRAY_H
6 #define HERALD_SENSOR_ARRAY_H
8 #include "data/sensor_logger.h"
9 #include "sensor_delegate.h"
12 #include "payload/payload_data_supplier.h"
13 #include "datatype/payload_timestamp.h"
14 #include "datatype/data.h"
15 #include "datatype/target_identifier.h"
16 #include "datatype/payload_data.h"
17 #include "ble/ble_concrete.h"
18 #include "engine/coordinator.h"
30 using namespace datatype;
31 using namespace payload;
32 using namespace engine;
44 template <
typename ContextT,
typename PayloadDataSupplierT,
typename... SensorTs>
47 static constexpr std::size_t Size =
sizeof...(SensorTs);
50 SensorArray(ContextT& ctx, PayloadDataSupplierT& payloadDataSupplier, SensorTs&... sensors)
52 mPayloadDataSupplier(payloadDataSupplier),
55 std::variant<
std::reference_wrapper<SensorTs>...>
57 >({std::variant<std::reference_wrapper<SensorTs>...>(sensors)...})
66 ~SensorArray() =
default;
78 PayloadData payloadData() {
79 return mPayloadDataSupplier.payload(PayloadTimestamp());
90 for (
auto& sensor: mSensorArray) {
91 std::visit([](
auto&& arg) {
92 ((decltype(arg))arg).get().start();
100 for (
auto& sensor: mSensorArray) {
101 std::visit([](
auto&& arg) {
102 ((decltype(arg))arg).get().stop();
107 std::optional<std::reference_wrapper<CoordinationProvider>> coordinationProvider() {
120 PayloadDataSupplierT& mPayloadDataSupplier;
121 std::array<std::variant<std::reference_wrapper<SensorTs>...>,Size> mSensorArray;
126 std::string deviceDescription;
130 template <
typename LastT>
131 constexpr
void addSensors(
int nextPos,LastT& last) {
132 mSensorArray[nextPos] = std::reference_wrapper<LastT>(last);
135 template <
typename FirstT,
typename SecondT,
typename... RestT>
136 constexpr
void addSensors(
int nextPos,FirstT& first, SecondT& second, RestT&... rest) {
137 mSensorArray[nextPos] = std::reference_wrapper<FirstT>(first);
139 addSensors(nextPos,second,rest...);
Manages all Sensors and sensor delegates for Herald.
Definition: sensor_array.h:45
void start()
Adds a new sensor to the array, and add its coordination provider to the engine.
Definition: sensor_array.h:89
void iteration(const TimeInterval sinceLastCompleted)
Scheduling activities from external OS thread wakes - Since v1.2-beta3.
Definition: sensor_array.h:112
SensorArray(ContextT &ctx, PayloadDataSupplierT &payloadDataSupplier, SensorTs &... sensors)
Takes ownership of payloadDataSupplier (std::move)
Definition: sensor_array.h:50
Definition: time_interval.h:19
Coordinates all connection and activities used across all sensors within Herald.
Definition: coordinator.h:39
Acts as a non-global memory arena for arbitrary classes.
Definition: aggregates.h:15