From ec42177b24b47ba68b3ae49634c942c76a9f92d4 Mon Sep 17 00:00:00 2001 From: Arseniy-Movshev Date: Sun, 19 Mar 2023 11:14:04 +0000 Subject: Restructure to split to daemon and qml accessor - add separate subdirs for daemon and qml - add some generic qml boilerplate - add a really lazy 'last value' loader implementation - license the project as gplv3 (add copyright notices and license text) --- logger.cpp | 94 -------------------------------------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 logger.cpp (limited to 'logger.cpp') diff --git a/logger.cpp b/logger.cpp deleted file mode 100644 index 8fd5953..0000000 --- a/logger.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "logger.h" - -#include "sensorPlugins/stepCounter.h" -#include "sensorPlugins/heartrateSensor.h" - -Logger::Logger(QObject *parent) : - QObject(parent){ - m_iface = new QDBusInterface("com.nokia.mce","/com/nokia/mce/signal", "com.nokia.mce.signal", QDBusConnection::systemBus()); - QSettings settings; - -//intialise HRM - if (heartrateSensorEnabled) { //add check for HRM - m_heartrateSensor = new HeartrateSensorPlugin(this,settings.value("stepsInterval",600000).toInt()); - } - -//initialise step counter - if (stepCounterEnabled) { //add check for step sensor - m_stepCounter = new StepCounterPlugin(this,settings.value("stepsInterval",600000).toInt()); - } - - if(!m_iface->isValid()) { - qDebug() << "interface is not valid"; - qDebug() << m_iface->lastError(); - } - if(connect(m_iface, SIGNAL(display_status_ind(QString)), this, SLOT(displayOn(QString)))) { //this fires when the display turns on - qDebug() << "healthd connected display_status signal to slot"; - } - qDebug() << "healthd sensors logger initialised"; -} - -void Logger::displayOn(QString displayState) { - if (displayState == "off") - return; - qDebug() << "display on detected"; - uint currTime = QDateTime::currentMSecsSinceEpoch(); - - if (heartrateSensorEnabled) { - m_heartrateSensor->timeUpdate(); - } - - if (stepCounterEnabled) { - m_stepCounter->timeUpdate(); - } -} - -void fileAddRecord(QString sensorPrefix, QString logdata, QDateTime recordTime) { //adds a record to today's log file for the given sensor - qDebug() << fileNameForDate(recordTime.date(), sensorPrefix); - QFile file(fileNameForDate(recordTime.date(), sensorPrefix)); - if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { - qDebug() << "failed to open file"; - return; - } - file.seek(file.size()); - QTextStream out(&file); - out << QString::number(recordTime.currentSecsSinceEpoch()) + ":" + logdata + "\n"; - file.close(); -} -bool dayFileExists(QString sensorPrefix, QDateTime dateTime) { - return QFile::exists(fileNameForDate(dateTime.date(), sensorPrefix)); -} - -QStringList fileGetPrevRecord(QString sensorPrefix, QDateTime recordTime) { - qDebug() << fileNameForDate(recordTime.date(), sensorPrefix); - QFile file(fileNameForDate(recordTime.date(), sensorPrefix)); - if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { - qDebug() << "failed to open file"; - return {0,0}; - } - QTextStream inStream(&file); - QString line; - int i; - while(!inStream.atEnd()) - { - line = inStream.readLine(); - qDebug() << line; - i++; - } - file.close(); - return line.split(":"); -} - -QString fileNameForDate(QDate date, QString prefix) { - return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/asteroid-healthloggerd/" + prefix + "/" + date.toString("yyyy-MM-dd.log"); -} -- cgit v1.2.3-70-g09d2