(DONE) Data Logger¶
Acquisition loop, left (sensors), right (a CSV file?
Terminal/std::cout
?). Sketch that in spaghetti style
⟶ reusable components!
Sensor config (by name). Vector of pairs
(name: string, Sensor*)
internally, but with a dedicated class around it to constrain the interface to what’s needed.Acquisition loop class. Interval, left (sensor config), right (CSV/Terminal?).
Problem: decoupling ⟶ interface (eg.
Sink
)
Standup Records¶
2023-11-20¶
Structure:
datalogger/CMakeLists.txt
Explain:
TARGET_INCLUDE_DIRECTORIES()
announces.
PUBLIC
to anyone who needs that nodevoid DataLogger::startLogging(uint16_t count = 0);
, with0
having the special meaning infinity ⟶ unification into one single methodRemove leftover
DataLogger::getTime()
. Defer implementation until we need timestampstests/logger-suite.cpp
: don’t useSinkFile
- test in terms ofSinkMock
⟶ make
SinkMock
usable for that purposetests/sink-suite.cpp
use
SinkMock
instead ofSinkFile
(like above)don’t use
SensorConfig
to create aSensorValues
object - create it directly, inside the test (we’re not testingSensorConfig
, only the sink)Best to create
tests/sensor-values-suite.cpp
to define the behavior ofSensorValues
tests/sensor-config-suite.cpp
Adding the same name three times should be an error (lets use
throw runtime_error("...message here...")
as an error handling replacement)Three sensors should lead to a measurement size (.size()) of 3
…
2023-12-14¶
Look over new tests
logger_suite.LoggerBasicTest
sensor_values_suite.*
sensor_config_suite.basic
SensorConfig
: check duplicatessensor_config_suite.duplicate_sensor
Outlook
Requirements¶
Modify the program bin/data-logger.cpp
to compose itself out of
prebuilt components.
Sensor config (by name).
Acquisition loop class. Interval, left (sensor config), right (CSV/Terminal?).
Problem: decoupling ⟶ interface (eg.
Sink
)
Implementation¶
Look like a number of classes is in order …
SensorConfig
. Holds the sensors, together with their names.void add(const std::string& name, Sensor*);
Iteration over
(name,sensor)
pairs. Maybe a methodconst std::map<std::string, Sensor*> all();
that gives easy access to that iteration? See the current state ofbin/data-logger.cpp
for iteration.
SensorValues
. Much like theSensorConfig
, but with live values instead of sensors.AcquisitionLoop
.(Constructor). Parameters
interval
,n_iterations
?void doit();
Nothing more.
A
Sink
hierarchy, starting at the interfaceSink
. (See theSensor
hierarchy for how interfaces are made.)The interface will have to have something like
void write_measurements(const SensorValues&);
The first implementation could be for testing only -
MockingSink
. That class simply stores theSensorValues
that it receives in astd::vector
that is used by the tests.
Testing¶
Try hard to test all aspects
Write tests before you start to program
Future (Not Part Of This Development Cycle)¶
Configuration files format(s). JSON? XML? YAML?
.ini
?CSV sink
MQTT sink