(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.txtExplain:
TARGET_INCLUDE_DIRECTORIES()announces.PUBLICto anyone who needs that nodevoid DataLogger::startLogging(uint16_t count = 0);, with0having 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
SinkMockusable for that purposetests/sink-suite.cppuse
SinkMockinstead ofSinkFile(like above)don’t use
SensorConfigto create aSensorValuesobject - create it directly, inside the test (we’re not testingSensorConfig, only the sink)Best to create
tests/sensor-values-suite.cppto define the behavior ofSensorValues
tests/sensor-config-suite.cppAdding 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.LoggerBasicTestsensor_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.cppfor iteration.
SensorValues. Much like theSensorConfig, but with live values instead of sensors.AcquisitionLoop.(Constructor). Parameters
interval,n_iterations?void doit();Nothing more.
A
Sinkhierarchy, starting at the interfaceSink. (See theSensorhierarchy 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 theSensorValuesthat it receives in astd::vectorthat 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