From 55339aacf03642657e1f9c7d087f9b9fd319de4a Mon Sep 17 00:00:00 2001 From: Arseniy-Movshev Date: Sun, 12 Mar 2023 00:33:58 +0000 Subject: Change to having one record file per day and rewrite file access infrastructure to serve this. I believe this is a useful improvement. The main two advantages are that a) it is very cheap to check whether a record exists for a given day - just check for file presence and b) there is a reasonable limit to the size of these files (never more than a few hundred records per day) which means that they can just be loaded into ram for processing without any complex splitting operations Currently, the necessary `~/asteroid-healthloggerd/stepCounter` and `...loggerd/heartrateMonitor` directories are not automatically created and the code just vomits errors into log if it can't write to them. --- logger.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'logger.h') diff --git a/logger.h b/logger.h index 53d797e..e56a51a 100644 --- a/logger.h +++ b/logger.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -16,6 +17,7 @@ class Logger : public QObject public: explicit Logger(QObject *parent = 0); virtual ~Logger() {}; + private slots: void displayOn(QString displayState); @@ -25,8 +27,11 @@ private: HeartrateSensorPlugin *m_heartrateSensor; bool stepCounterEnabled = true; StepCounterPlugin *m_stepCounter; + }; -void writeReadingToFile(QString data, QString filename); -QString getLineFromFile(int lineNumber, QString filename); + void fileAddRecord(QString sensorPrefix, QString logdata, QDateTime recordTime = QDateTime::currentDateTime()); //adds a record to today's log file for the given sensor + bool dayFileExists(QString sensorPrefix, QDateTime date = QDateTime::currentDateTime()); //check if today has a log file for the given sensor + QStringList fileGetPrevRecord(QString sensorPrefix, QDateTime recordTime = QDateTime::currentDateTime()); //works backwards to find the last record in today's file before the given time - returns nothing if no file is found. + QString fileNameForDate(QDate date, QString prefix); #endif // LOGGER_H -- cgit v1.2.3-54-g00ecf