Fix trimming of logs
parent
10d323a3aa
commit
6e312fe02c
|
|
@ -313,7 +313,7 @@ void EnergyLogger::sample()
|
||||||
// and then trim them
|
// and then trim them
|
||||||
if (now > m_nextSamples.value(SampleRate1Min)) {
|
if (now > m_nextSamples.value(SampleRate1Min)) {
|
||||||
QDateTime sampleTime = m_nextSamples.value(SampleRate1Min);
|
QDateTime sampleTime = m_nextSamples.value(SampleRate1Min);
|
||||||
QDateTime oldestTimestamp = sampleTime.addMSecs(-m_maxMinuteSamples * 60 * 1000);
|
QDateTime oldestTimestamp = sampleTime.addMSecs(-(qulonglong)m_maxMinuteSamples * 60 * 1000);
|
||||||
trimPowerBalance(SampleRate1Min, oldestTimestamp);
|
trimPowerBalance(SampleRate1Min, oldestTimestamp);
|
||||||
foreach (const ThingId &thingId, m_thingsPowerLiveLogs.keys()) {
|
foreach (const ThingId &thingId, m_thingsPowerLiveLogs.keys()) {
|
||||||
trimThingPower(thingId, SampleRate1Min, oldestTimestamp);
|
trimThingPower(thingId, SampleRate1Min, oldestTimestamp);
|
||||||
|
|
@ -322,7 +322,7 @@ void EnergyLogger::sample()
|
||||||
foreach (SampleRate sampleRate, m_configs.keys()) {
|
foreach (SampleRate sampleRate, m_configs.keys()) {
|
||||||
if (now >= m_nextSamples.value(sampleRate)) {
|
if (now >= m_nextSamples.value(sampleRate)) {
|
||||||
QDateTime sampleTime = m_nextSamples.value(sampleRate);
|
QDateTime sampleTime = m_nextSamples.value(sampleRate);
|
||||||
QDateTime oldestTimestamp = sampleTime.addMSecs(-m_configs.value(sampleRate).maxSamples * sampleRate * 60 * 1000);
|
QDateTime oldestTimestamp = sampleTime.addMSecs(-(qulonglong)m_configs.value(sampleRate).maxSamples * sampleRate * 60 * 1000);
|
||||||
trimPowerBalance(sampleRate, oldestTimestamp);
|
trimPowerBalance(sampleRate, oldestTimestamp);
|
||||||
foreach (const ThingId &thingId, m_thingsPowerLiveLogs.keys()) {
|
foreach (const ThingId &thingId, m_thingsPowerLiveLogs.keys()) {
|
||||||
trimThingPower(thingId, sampleRate, oldestTimestamp);
|
trimThingPower(thingId, sampleRate, oldestTimestamp);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ EnergyManagerImpl::EnergyManagerImpl(ThingManager *thingManager, QObject *parent
|
||||||
m_totalProduction = latestEntry.totalProduction();
|
m_totalProduction = latestEntry.totalProduction();
|
||||||
m_totalAcquisition = latestEntry.totalAcquisition();
|
m_totalAcquisition = latestEntry.totalAcquisition();
|
||||||
m_totalReturn = latestEntry.totalReturn();
|
m_totalReturn = latestEntry.totalReturn();
|
||||||
qCDebug(dcEnergyExperience()) << "Loader power balance totals. Consumption:" << m_totalConsumption << "Production:" << m_totalProduction << "Acquisition:" << m_totalAcquisition << "Return:" << m_totalReturn;
|
qCDebug(dcEnergyExperience()) << "Loaded power balance totals. Consumption:" << m_totalConsumption << "Production:" << m_totalProduction << "Acquisition:" << m_totalAcquisition << "Return:" << m_totalReturn;
|
||||||
|
|
||||||
foreach (Thing *thing, m_thingManager->configuredThings()) {
|
foreach (Thing *thing, m_thingManager->configuredThings()) {
|
||||||
watchThing(thing);
|
watchThing(thing);
|
||||||
|
|
@ -171,7 +171,7 @@ void EnergyManagerImpl::updatePowerBalance()
|
||||||
|
|
||||||
double oldAcquisition = m_totalEnergyConsumedCache.value(m_rootMeter);
|
double oldAcquisition = m_totalEnergyConsumedCache.value(m_rootMeter);
|
||||||
double newAcquisition = m_rootMeter->stateValue("totalEnergyConsumed").toDouble();
|
double newAcquisition = m_rootMeter->stateValue("totalEnergyConsumed").toDouble();
|
||||||
qCDebug(dcEnergyExperience()) << "Root meteter total consumption diff" << "old" << oldAcquisition << " new" << newAcquisition << (newAcquisition -oldAcquisition);
|
qCDebug(dcEnergyExperience()) << "Root meteter total consumption: Previous value:" << oldAcquisition << "New value:" << newAcquisition << "Diff:" << (newAcquisition -oldAcquisition);
|
||||||
m_totalAcquisition += newAcquisition - oldAcquisition;
|
m_totalAcquisition += newAcquisition - oldAcquisition;
|
||||||
m_totalEnergyConsumedCache[m_rootMeter] = newAcquisition;
|
m_totalEnergyConsumedCache[m_rootMeter] = newAcquisition;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue