Fixes
parent
034f90d7a9
commit
a34dd7642b
|
|
@ -102,7 +102,7 @@ Q_DECLARE_METATYPE(PowerBalanceLogEntries)
|
||||||
|
|
||||||
class ThingPowerLogEntry {
|
class ThingPowerLogEntry {
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
Q_PROPERTY(QDateTime timstamp READ timestamp)
|
Q_PROPERTY(QDateTime timestamp READ timestamp)
|
||||||
Q_PROPERTY(QUuid thingId READ thingId)
|
Q_PROPERTY(QUuid thingId READ thingId)
|
||||||
Q_PROPERTY(double currentPower READ currentPower)
|
Q_PROPERTY(double currentPower READ currentPower)
|
||||||
Q_PROPERTY(double totalConsumption READ totalConsumption)
|
Q_PROPERTY(double totalConsumption READ totalConsumption)
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,6 @@ JsonReply *EnergyJsonHandler::GetThingPowerLogs(const QVariantMap ¶ms)
|
||||||
QDateTime from = params.contains("from") ? QDateTime::fromMSecsSinceEpoch(params.value("from").toLongLong() * 1000) : QDateTime();
|
QDateTime from = params.contains("from") ? QDateTime::fromMSecsSinceEpoch(params.value("from").toLongLong() * 1000) : QDateTime();
|
||||||
QDateTime to = params.contains("to") ? QDateTime::fromMSecsSinceEpoch(params.value("to").toLongLong() * 1000) : QDateTime();
|
QDateTime to = params.contains("to") ? QDateTime::fromMSecsSinceEpoch(params.value("to").toLongLong() * 1000) : QDateTime();
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
returns.insert("thingPowerLogEntries",pack(m_energyManager->logs()->thingPowerLogs(sampleRate, thingIds, from, to)));
|
returns.insert("thingPowerLogEntries", pack(m_energyManager->logs()->thingPowerLogs(sampleRate, thingIds, from, to)));
|
||||||
return createReply(returns);
|
return createReply(returns);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,13 +139,15 @@ ThingPowerLogEntries EnergyLogger::thingPowerLogs(SampleRate sampleRate, const Q
|
||||||
QVariantList bindValues;
|
QVariantList bindValues;
|
||||||
bindValues << sampleRate;
|
bindValues << sampleRate;
|
||||||
|
|
||||||
|
qCDebug(dcEnergyExperience()) << "Fetching thing power logs for" << thingIds;
|
||||||
|
|
||||||
QStringList thingsQuery;
|
QStringList thingsQuery;
|
||||||
foreach (const ThingId &thingId, thingIds) {
|
foreach (const ThingId &thingId, thingIds) {
|
||||||
thingsQuery.append("thingId = ?");
|
thingsQuery.append("thingId = ?");
|
||||||
bindValues << thingId;
|
bindValues << thingId;
|
||||||
}
|
}
|
||||||
if (!thingsQuery.isEmpty()) {
|
if (!thingsQuery.isEmpty()) {
|
||||||
queryString += "AND (" + thingsQuery.join(" OR ") + " )";
|
queryString += " AND (" + thingsQuery.join(" OR ") + " )";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from.isNull()) {
|
if (!from.isNull()) {
|
||||||
|
|
@ -598,7 +600,7 @@ bool EnergyLogger::insertPowerBalance(const QDateTime ×tamp, SampleRate sam
|
||||||
query.addBindValue(totalReturn);
|
query.addBindValue(totalReturn);
|
||||||
query.exec();
|
query.exec();
|
||||||
if (query.lastError().isValid()) {
|
if (query.lastError().isValid()) {
|
||||||
qCWarning(dcEnergyExperience()) << "Error logging consumption sample:" << query.lastError();
|
qCWarning(dcEnergyExperience()) << "Error logging consumption sample:" << query.lastError() << query.executedQuery();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
emit powerBalanceEntryAdded(sampleRate, PowerBalanceLogEntry(timestamp, consumption, production, acquisition, storage, totalConsumption, totalProduction, totalAcquisition, totalReturn));
|
emit powerBalanceEntryAdded(sampleRate, PowerBalanceLogEntry(timestamp, consumption, production, acquisition, storage, totalConsumption, totalProduction, totalAcquisition, totalReturn));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue