diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-31 18:20:42 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-06-01 13:32:13 +0100 |
commit | c1e9b5f8a2d287865db3a4d5d056ecf736e05b24 (patch) | |
tree | b76929fcd3df118aafb006b529e4a46093a48323 /daemon/sensorPlugins | |
parent | 7a8565498f9894a6d8fbb8cd4462048a4c603418 (diff) |
Add a check for whether the daemon is starting the first time this boot
Diffstat (limited to 'daemon/sensorPlugins')
-rw-r--r-- | daemon/sensorPlugins/stepCounter.cpp | 5 | ||||
-rw-r--r-- | daemon/sensorPlugins/stepCounter.h | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/daemon/sensorPlugins/stepCounter.cpp b/daemon/sensorPlugins/stepCounter.cpp index 7dd8627..f502083 100644 --- a/daemon/sensorPlugins/stepCounter.cpp +++ b/daemon/sensorPlugins/stepCounter.cpp @@ -21,7 +21,7 @@ #include "stepCounter.h" -StepCounterPlugin::StepCounterPlugin(QObject *parent, int initInterval) : +StepCounterPlugin::StepCounterPlugin(QObject *parent, int initInterval, bool daemonFresh) : QObject(parent){ interval = initInterval; @@ -33,13 +33,12 @@ StepCounterPlugin::StepCounterPlugin(QObject *parent, int initInterval) : connect(recordIntervalTimer,SIGNAL(timeout()),this,SLOT(triggerRecording())); recordIntervalTimer->setSingleShot(true); recordIntervalTimer->start(interval); - QDateTime currDateTime = QDateTime::currentDateTime(); setupFilePath(sensorPathPrefix); while (!stepcounterSensor->isActive()) {} - if (dayFileExists(sensorPathPrefix)) { + if (dayFileExists(sensorPathPrefix) && daemonFresh) { QStringList lastLineData = fileGetPrevRecord(sensorPathPrefix); lastRecordTime = QDateTime::currentDateTime(); stepcounterSensor->reading()->setSteps(lastLineData[1].toInt() + stepcounterSensor->reading()->steps()); // we add the last recorded value from today to the current value. This 'recovers' the steps from between reboots. I'm not sure how this will work on catfish or medaka. diff --git a/daemon/sensorPlugins/stepCounter.h b/daemon/sensorPlugins/stepCounter.h index 27dc01e..a6475f5 100644 --- a/daemon/sensorPlugins/stepCounter.h +++ b/daemon/sensorPlugins/stepCounter.h @@ -22,7 +22,7 @@ class StepCounterPlugin : public QObject { Q_OBJECT public: - explicit StepCounterPlugin(QObject *parent = 0, int initInterval = 600000); + explicit StepCounterPlugin(QObject *parent = 0, int initInterval = 600000, bool daemonFresh = false); virtual ~StepCounterPlugin() {}; void timeUpdate(); |