From f7cc492fd676496fa6ac377ad378f7fa74129e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 8 Apr 2024 08:50:13 +0200 Subject: [PATCH] Add Qt6 support --- config.pri | 13 ++- libnymea-energy/energylogs.cpp | 2 +- libnymea-energy/energylogs.h | 2 +- libnymea-energy/energymanager.cpp | 2 +- libnymea-energy/energymanager.h | 4 +- libnymea-energy/energyplugin.cpp | 2 +- libnymea-energy/energyplugin.h | 8 +- libnymea-energy/libnymea-energy.pro | 2 - plugin/energyjsonhandler.cpp | 2 +- plugin/energyjsonhandler.h | 14 +-- plugin/energylogger.cpp | 144 ++++++++++++++++------------ plugin/energylogger.h | 2 +- plugin/energymanagerimpl.cpp | 10 +- plugin/energymanagerimpl.h | 16 ++-- plugin/experiencepluginenergy.cpp | 4 +- plugin/experiencepluginenergy.h | 4 +- plugin/plugin.pro | 6 +- 17 files changed, 134 insertions(+), 103 deletions(-) diff --git a/config.pri b/config.pri index faa15ab..36dacdb 100644 --- a/config.pri +++ b/config.pri @@ -7,4 +7,15 @@ gcc { top_srcdir = $$PWD top_builddir = $$shadowed($$PWD) -CONFIG += c++11 +greaterThan(QT_MAJOR_VERSION, 5) { + message("Building using Qt6 support") + CONFIG *= c++17 + QMAKE_LFLAGS *= -std=c++17 + QMAKE_CXXFLAGS *= -std=c++17 +} else { + message("Building using Qt5 support") + CONFIG *= c++11 + QMAKE_LFLAGS *= -std=c++11 + QMAKE_CXXFLAGS *= -std=c++11 + DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x050F00 +} diff --git a/libnymea-energy/energylogs.cpp b/libnymea-energy/energylogs.cpp index a2df794..2412395 100644 --- a/libnymea-energy/energylogs.cpp +++ b/libnymea-energy/energylogs.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. diff --git a/libnymea-energy/energylogs.h b/libnymea-energy/energylogs.h index 34331a2..eb7d5f1 100644 --- a/libnymea-energy/energylogs.h +++ b/libnymea-energy/energylogs.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. diff --git a/libnymea-energy/energymanager.cpp b/libnymea-energy/energymanager.cpp index da7f833..cdc131f 100644 --- a/libnymea-energy/energymanager.cpp +++ b/libnymea-energy/energymanager.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. diff --git a/libnymea-energy/energymanager.h b/libnymea-energy/energymanager.h index d7b955a..edeef1e 100644 --- a/libnymea-energy/energymanager.h +++ b/libnymea-energy/energymanager.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -64,7 +64,7 @@ public: virtual double totalAcquisition() const = 0; virtual double totalReturn() const = 0; - virtual EnergyLogs* logs() const = 0; + virtual EnergyLogs *logs() const = 0; signals: void rootMeterChanged(); diff --git a/libnymea-energy/energyplugin.cpp b/libnymea-energy/energyplugin.cpp index 5e51b56..0ba0685 100644 --- a/libnymea-energy/energyplugin.cpp +++ b/libnymea-energy/energyplugin.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. diff --git a/libnymea-energy/energyplugin.h b/libnymea-energy/energyplugin.h index bee1470..be58fca 100644 --- a/libnymea-energy/energyplugin.h +++ b/libnymea-energy/energyplugin.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -48,9 +48,9 @@ public: virtual void init() = 0; protected: - EnergyManager* energyManager() const; - ThingManager* thingManager() const; - JsonRPCServer* jsonRpcServer() const; + EnergyManager *energyManager() const; + ThingManager *thingManager() const; + JsonRPCServer *jsonRpcServer() const; private: friend class ExperiencePluginEnergy; diff --git a/libnymea-energy/libnymea-energy.pro b/libnymea-energy/libnymea-energy.pro index 91e8370..a781bec 100644 --- a/libnymea-energy/libnymea-energy.pro +++ b/libnymea-energy/libnymea-energy.pro @@ -7,7 +7,6 @@ NYMEA_ENERGY_VERSION_STRING = "0.0.1" CONFIG += link_pkgconfig PKGCONFIG += nymea - HEADERS += \ energylogs.h \ energymanager.h \ @@ -37,4 +36,3 @@ QMAKE_PKGCONFIG_LIBDIR = $$target.path QMAKE_PKGCONFIG_VERSION = $$NYMEA_ENERGY_VERSION_STRING QMAKE_PKGCONFIG_FILE = nymea-energy QMAKE_PKGCONFIG_DESTDIR = pkgconfig - diff --git a/plugin/energyjsonhandler.cpp b/plugin/energyjsonhandler.cpp index 678bb16..4a70285 100644 --- a/plugin/energyjsonhandler.cpp +++ b/plugin/energyjsonhandler.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. diff --git a/plugin/energyjsonhandler.h b/plugin/energyjsonhandler.h index 1aeb5dd..8e8c2b1 100644 --- a/plugin/energyjsonhandler.h +++ b/plugin/energyjsonhandler.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -32,7 +32,7 @@ #define ENERGYJSONHANDLER_H #include -#include "jsonrpc/jsonhandler.h" +#include class EnergyManager; @@ -44,11 +44,11 @@ public: QString name() const override; - Q_INVOKABLE JsonReply* GetRootMeter(const QVariantMap ¶ms); - Q_INVOKABLE JsonReply* SetRootMeter(const QVariantMap ¶ms); - Q_INVOKABLE JsonReply* GetPowerBalance(const QVariantMap ¶ms); - Q_INVOKABLE JsonReply* GetPowerBalanceLogs(const QVariantMap ¶ms); - Q_INVOKABLE JsonReply* GetThingPowerLogs(const QVariantMap ¶ms); + Q_INVOKABLE JsonReply *GetRootMeter(const QVariantMap ¶ms); + Q_INVOKABLE JsonReply *SetRootMeter(const QVariantMap ¶ms); + Q_INVOKABLE JsonReply *GetPowerBalance(const QVariantMap ¶ms); + Q_INVOKABLE JsonReply *GetPowerBalanceLogs(const QVariantMap ¶ms); + Q_INVOKABLE JsonReply *GetThingPowerLogs(const QVariantMap ¶ms); signals: void RootMeterChanged(const QVariantMap ¶ms); diff --git a/plugin/energylogger.cpp b/plugin/energylogger.cpp index 24ed906..2e6a814 100644 --- a/plugin/energylogger.cpp +++ b/plugin/energylogger.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -43,7 +43,8 @@ #include Q_DECLARE_LOGGING_CATEGORY(dcEnergyExperience) -EnergyLogger::EnergyLogger(QObject *parent) : EnergyLogs(parent) +EnergyLogger::EnergyLogger(QObject *parent) + : EnergyLogs(parent) { if (!initDB()) { qCCritical(dcEnergyExperience()) << "Unable to open energy log. Energy logs will not be available."; @@ -152,7 +153,7 @@ PowerBalanceLogEntries EnergyLogger::powerBalanceLogs(SampleRate sampleRate, con } while (query.next()) { -// qCDebug(dcEnergyExperience()) << "Adding result"; + // qCDebug(dcEnergyExperience()) << "Adding result"; result.append(queryResultToBalanceLogEntry(query.record())); } return result; @@ -198,11 +199,11 @@ ThingPowerLogEntries EnergyLogger::thingPowerLogs(SampleRate sampleRate, const Q while (query.next()) { result.append(ThingPowerLogEntry( - QDateTime::fromMSecsSinceEpoch(query.value("timestamp").toLongLong()), - query.value("thingId").toUuid(), - query.value("currentPower").toDouble(), - query.value("totalConsumption").toDouble(), - query.value("totalProduction").toDouble())); + QDateTime::fromMSecsSinceEpoch(query.value("timestamp").toLongLong()), + query.value("thingId").toUuid(), + query.value("currentPower").toDouble(), + query.value("totalConsumption").toDouble(), + query.value("totalProduction").toDouble())); } return result; @@ -489,89 +490,110 @@ bool EnergyLogger::initDB() { m_db.close(); - m_db = QSqlDatabase::addDatabase("QSQLITE", "energylogs"); + m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), "energylogs"); QDir path = QDir(NymeaSettings::storagePath()); - if (!path.exists()) { + if (!path.exists()) path.mkpath(path.path()); - } + m_db.setDatabaseName(path.filePath("energylogs.sqlite")); - bool opened = m_db.open(); - if (!opened) { + if (!m_db.isValid()) { + qCWarning(dcEnergyExperience()) << "The energy database is not valid" << m_db.databaseName(); + return false; + } + + qCDebug(dcEnergyExperience()) << "Opening energy database" << m_db.databaseName(); + if (!m_db.open()) { qCWarning(dcEnergyExperience()) << "Cannot open energy log DB at" << m_db.databaseName() << m_db.lastError(); return false; } if (!m_db.tables().contains("metadata")) { qCDebug(dcEnergyExperience()) << "No \"metadata\" table in database. Creating it."; - m_db.exec("CREATE TABLE metadata (version INT);"); - m_db.exec("INSERT INTO metadata (version) VALUES (1);"); - if (m_db.lastError().isValid()) { - qCWarning(dcEnergyExperience()) << "Error creating metadata table in energy log database. Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); + QString queryString = "CREATE TABLE IF NOT EXISTS metadata (version INT);"; + QSqlQuery createTableMetadataVersionQuery(queryString, m_db); + + if (!createTableMetadataVersionQuery.exec()) { + qCWarning(dcEnergyExperience()) << "Error creating metadata table in energy log database. Query:" << queryString << createTableMetadataVersionQuery.lastError().text() << "Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); + return false; + } + + queryString = "INSERT INTO metadata (version) VALUES (1);"; + QSqlQuery writeVersionQuery(queryString, m_db); + if (!writeVersionQuery.exec()) { + qCWarning(dcEnergyExperience()) << "Error writing metadata table in energy log database. Query:" << queryString << writeVersionQuery.lastError().text() << "Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); return false; } } if (!m_db.tables().contains("powerBalance")) { qCDebug(dcEnergyExperience()) << "No \"powerBalance\" table in database. Creating it."; - m_db.exec("CREATE TABLE powerBalance " - "(" - "timestamp BIGINT," - "sampleRate INT," - "consumption FLOAT," - "production FLOAT," - "acquisition FLOAT," - "storage FLOAT," - "totalConsumption FLOAT," - "totalProduction FLOAT," - "totalAcquisition FLOAT," - "totalReturn FLOAT" - ");"); + QString query("CREATE TABLE IF NOT EXISTS powerBalance " + "(" + "timestamp BIGINT," + "sampleRate INT," + "consumption FLOAT," + "production FLOAT," + "acquisition FLOAT," + "storage FLOAT," + "totalConsumption FLOAT," + "totalProduction FLOAT," + "totalAcquisition FLOAT," + "totalReturn FLOAT" + ");"); - if (m_db.lastError().isValid()) { - qCWarning(dcEnergyExperience()) << "Error creating powerBalance table in energy log database. Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); + QSqlQuery createTableQuery(query, m_db); + if (!createTableQuery.exec()) { + qCWarning(dcEnergyExperience()) << "Error creating powerBalance table in energy log database." << query << createTableQuery.lastError().text() << "Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); return false; } + } - m_db.exec("CREATE INDEX IF NOT EXISTS idx_powerBalance ON powerBalance(sampleRate, timestamp);"); - if (m_db.lastError().isValid()) { - qCWarning(dcEnergyExperience()) << "Error creating powerBalance table index in energy log database. Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); + + QSqlQuery createPowerBalanceIndexQuery("CREATE INDEX IF NOT EXISTS idx_powerBalance ON powerBalance(sampleRate, timestamp);", m_db); + if (!createPowerBalanceIndexQuery.exec()) { + qCWarning(dcEnergyExperience()) << "Error creating powerBalance table index in energy log database. Query:" << createPowerBalanceIndexQuery.lastQuery() << createPowerBalanceIndexQuery.lastError().text() << "Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); return false; } if (!m_db.tables().contains("thingPower")) { qCDebug(dcEnergyExperience()) << "No \"thingPower\" table in database. Creating it."; - m_db.exec("CREATE TABLE thingPower " - "(" - "timestamp BIGINT," - "sampleRate INT," - "thingId VARCHAR(38)," - "currentPower FLOAT," - "totalConsumption FLOAT," - "totalProduction FLOAT" - ");"); - if (m_db.lastError().isValid()) { - qCWarning(dcEnergyExperience()) << "Error creating thingPower table in energy log database. Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); + QString query("CREATE TABLE IF NOT EXISTS thingPower " + "(" + "timestamp BIGINT," + "sampleRate INT," + "thingId VARCHAR(38)," + "currentPower FLOAT," + "totalConsumption FLOAT," + "totalProduction FLOAT" + ");"); + + QSqlQuery createThingPowerTableQuery(query, m_db); + if (!createThingPowerTableQuery.exec()) { + qCWarning(dcEnergyExperience()) << "Error creating thingPower table in energy log database. Query:" << query << createThingPowerTableQuery.lastError().text() << "Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); return false; } } - m_db.exec("CREATE INDEX IF NOT EXISTS idx_thingPower ON thingPower(thingId, sampleRate, timestamp);"); - if (m_db.lastError().isValid()) { - qCWarning(dcEnergyExperience()) << "Error creating thingPower table index in energy log database. Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); + + QSqlQuery createThingPowerIndexQuery("CREATE INDEX IF NOT EXISTS idx_thingPower ON thingPower(thingId, sampleRate, timestamp);", m_db); + if (!createThingPowerIndexQuery.exec()) { + qCWarning(dcEnergyExperience()) << "Error creating thingPower table index in energy log database. Query:" << createThingPowerIndexQuery.lastQuery() << createThingPowerIndexQuery.lastError().text() << "Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); return false; } if (!m_db.tables().contains("thingCache")) { qCDebug(dcEnergyExperience()) << "No \"thingCache\" table in database. Creating it."; - m_db.exec("CREATE TABLE thingCache " - "(" - "thingId VARCHAR(38) PRIMARY KEY," - "totalEnergyConsumed FLOAT," - "totalEnergyProduced FLOAT" - ");"); - if (m_db.lastError().isValid()) { - qCWarning(dcEnergyExperience()) << "Error creating thingCache table in energy log database. Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); + QString query("CREATE TABLE IF NOT EXISTS thingCache " + "(" + "thingId VARCHAR(38) PRIMARY KEY," + "totalEnergyConsumed FLOAT," + "totalEnergyProduced FLOAT" + ");"); + + QSqlQuery createThingCacheTableQuery(query, m_db); + if (!createThingCacheTableQuery.exec()) { + qCWarning(dcEnergyExperience()) << "Error creating thingCache table in energy log database. Query:" << query << createThingCacheTableQuery.lastError().text() << "Driver error:" << m_db.lastError().driverText() << "Database error:" << m_db.lastError().databaseText(); return false; } } @@ -672,8 +694,8 @@ void EnergyLogger::rectifySamples(SampleRate sampleRate, SampleRate baseSampleRa newestSample = oldestBaseSample; } -// qCDebug(dcEnergyExperience()) << "next sample after last in series:" << nextSampleTimestamp(sampleRate, newestSample).toString(); -// qCDebug(dcEnergyExperience()) << "next scheduled sample:" << m_nextSamples.value(sampleRate).toString(); + // qCDebug(dcEnergyExperience()) << "next sample after last in series:" << nextSampleTimestamp(sampleRate, newestSample).toString(); + // qCDebug(dcEnergyExperience()) << "next scheduled sample:" << m_nextSamples.value(sampleRate).toString(); if (!newestSample.isNull() && nextSampleTimestamp(sampleRate, newestSample) < m_nextSamples[sampleRate]) { // regularly sample one sample as there may be some valid samples in the base series QDateTime nextSample = nextSampleTimestamp(sampleRate, newestSample.addMSecs(1000)); @@ -713,8 +735,8 @@ void EnergyLogger::rectifySamples(SampleRate sampleRate, SampleRate baseSampleRa } newestSample = oldestBaseSample; } -// qCDebug(dcEnergyExperience()) << "T next sample after last in series:" << nextSampleTimestamp(sampleRate, newestSample).toString(); -// qCDebug(dcEnergyExperience()) << "T next scheduled sample:" << m_nextSamples.value(sampleRate).toString(); + // qCDebug(dcEnergyExperience()) << "T next sample after last in series:" << nextSampleTimestamp(sampleRate, newestSample).toString(); + // qCDebug(dcEnergyExperience()) << "T next scheduled sample:" << m_nextSamples.value(sampleRate).toString(); if (!newestSample.isNull() && nextSampleTimestamp(sampleRate, newestSample) < m_nextSamples[sampleRate]) { QDateTime nextSample = nextSampleTimestamp(sampleRate, newestSample.addMSecs(1000)); sampleThingPower(thingId, sampleRate, baseSampleRate, nextSample); diff --git a/plugin/energylogger.h b/plugin/energylogger.h index 1cb5d8c..40e50ad 100644 --- a/plugin/energylogger.h +++ b/plugin/energylogger.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. diff --git a/plugin/energymanagerimpl.cpp b/plugin/energymanagerimpl.cpp index 70398b0..a08dcbe 100644 --- a/plugin/energymanagerimpl.cpp +++ b/plugin/energymanagerimpl.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -180,8 +180,8 @@ void EnergyManagerImpl::watchThing(Thing *thing) m_powerBalanceTotalEnergyConsumedCache[thing] = stateEntry.totalConsumption(); m_powerBalanceTotalEnergyProducedCache[thing] = stateEntry.totalProduction(); - m_thingsTotalEnergyConsumedCache[thing] = qMakePair(stateEntry.totalConsumption(), entry.totalConsumption()); - m_thingsTotalEnergyProducedCache[thing] = qMakePair(stateEntry.totalProduction(), entry.totalProduction()); + m_thingsTotalEnergyConsumedCache[thing] = QPair(stateEntry.totalConsumption(), entry.totalConsumption()); + m_thingsTotalEnergyProducedCache[thing] = QPair(stateEntry.totalProduction(), entry.totalProduction()); qCDebug(dcEnergyExperience()) << "Loaded thing power totals for" << thing->name() << "Consumption:" << entry.totalConsumption() << "Production:" << entry.totalProduction() << "Last thing state consumption:" << stateEntry.totalConsumption() << "production:" << stateEntry.totalProduction(); updateThingPower(thing); @@ -315,7 +315,7 @@ void EnergyManagerImpl::updateThingPower(Thing *thing) } double consumptionDiff = newThingConsumptionState - oldThingConsumptionState; double newThingConsumptionInternal = oldThingConsumptionInternal + consumptionDiff; - m_thingsTotalEnergyConsumedCache[thing] = qMakePair(newThingConsumptionState, newThingConsumptionInternal); + m_thingsTotalEnergyConsumedCache[thing] = QPair(newThingConsumptionState, newThingConsumptionInternal); // Production @@ -334,7 +334,7 @@ void EnergyManagerImpl::updateThingPower(Thing *thing) } double productionDiff = newThingProductionState - oldThingProductionState; double newThingProductionInternal = oldThingProductionInternal + productionDiff; - m_thingsTotalEnergyProducedCache[thing] = qMakePair(newThingProductionState, newThingProductionInternal); + m_thingsTotalEnergyProducedCache[thing] = QPair(newThingProductionState, newThingProductionInternal); // Write to log diff --git a/plugin/energymanagerimpl.h b/plugin/energymanagerimpl.h index 832e5fe..27d19da 100644 --- a/plugin/energymanagerimpl.h +++ b/plugin/energymanagerimpl.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -35,7 +35,7 @@ #include #include -#include "integrations/thingmanager.h" +#include #include "energymanager.h" @@ -59,7 +59,7 @@ public: double totalAcquisition() const override; double totalReturn() const override; - EnergyLogs* logs() const override; + EnergyLogs *logs() const override; private: void watchThing(Thing *thing); @@ -94,14 +94,14 @@ private: // For things totals we need to cache 2 values: // The last thing state values we've processed - QHash m_powerBalanceTotalEnergyConsumedCache; - QHash m_powerBalanceTotalEnergyProducedCache; + QHash m_powerBalanceTotalEnergyConsumedCache; + QHash m_powerBalanceTotalEnergyProducedCache; // - The last thing state value we've read and processed // - The last entry in our internal counters we've processed and logged - // QHash> - QHash> m_thingsTotalEnergyConsumedCache; - QHash> m_thingsTotalEnergyProducedCache; + // QHash> + QHash> m_thingsTotalEnergyConsumedCache; + QHash> m_thingsTotalEnergyProducedCache; }; #endif // ENERGYMANAGERIMPL_H diff --git a/plugin/experiencepluginenergy.cpp b/plugin/experiencepluginenergy.cpp index 4159e34..5a7a33a 100644 --- a/plugin/experiencepluginenergy.cpp +++ b/plugin/experiencepluginenergy.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -117,7 +117,7 @@ void ExperiencePluginEnergy::loadEnergyPlugin(const QString &file) qCWarning(dcExperiences()) << loader.errorString(); return; } - EnergyPlugin *plugin = qobject_cast(loader.instance()); + EnergyPlugin *plugin = qobject_cast(loader.instance()); if (!plugin) { qCWarning(dcEnergyExperience()) << "Could not get plugin instance of" << loader.fileName(); loader.unload(); diff --git a/plugin/experiencepluginenergy.h b/plugin/experiencepluginenergy.h index d1d4d63..1f374e9 100644 --- a/plugin/experiencepluginenergy.h +++ b/plugin/experiencepluginenergy.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2024, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -56,7 +56,7 @@ private: void loadPlugins(); void loadEnergyPlugin(const QString &file); - QList m_plugins; + QList m_plugins; EnergyManagerImpl *m_energyManager = nullptr; }; diff --git a/plugin/plugin.pro b/plugin/plugin.pro index 8370364..a1f3c4c 100644 --- a/plugin/plugin.pro +++ b/plugin/plugin.pro @@ -1,14 +1,14 @@ TEMPLATE = lib TARGET = $$qtLibraryTarget(nymea_experiencepluginenergy) -CONFIG += plugin link_pkgconfig c++11 +include(../config.pri) + +CONFIG += plugin link_pkgconfig PKGCONFIG += nymea QT -= gui QT += network sql -include(../config.pri) - INCLUDEPATH += $$top_srcdir/libnymea-energy LIBS += -L$$top_builddir/libnymea-energy -lnymea-energy