Cleanups
This commit is contained in:
parent
2df41462ad
commit
2da2d9458b
@ -38,7 +38,7 @@ public:
|
||||
virtual PowerBalanceLogEntries powerBalanceLogs(SampleRate sampleRate, const QDateTime &from = QDateTime(), const QDateTime &to = QDateTime()) const = 0;
|
||||
|
||||
/*! Returns logs for the given sample rate for currentPower, totalEnergyConsumed and totalEnergyProduced for the given things.
|
||||
* From and to may be given to limie results to a time span.
|
||||
* From and to may be given to limit results to a time span.
|
||||
* If thingIds is empty, all things will be returned.
|
||||
*/
|
||||
virtual ThingPowerLogEntries thingPowerLogs(SampleRate sampleRate, const QList<ThingId> &thingIds, const QDateTime &from = QDateTime(), const QDateTime &to = QDateTime()) const = 0;
|
||||
|
||||
@ -488,7 +488,7 @@ void EnergyLogger::rectifySamples(SampleRate sampleRate, SampleRate baseSampleRa
|
||||
// Normally we'd need to find the newest available sample of a series and catch up from there.
|
||||
// However, it could happen a series does not have any samples at all yet. For example if we're logging since january,
|
||||
// and at new years the system was off, we missed the new years yearly sample and don't have any earlier. For those cases
|
||||
// we need to start resampling from the oldest timestamp we find in the DB at all (regardless of the sampleRate)
|
||||
// we need to start resampling from the oldest timestamp we find in the DB for the base sampleRate.
|
||||
QDateTime oldestBaseSample = getOldestPowerBalanceSampleTimestamp(baseSampleRate);
|
||||
QDateTime newestSample = getNewestPowerBalanceSampleTimestamp(sampleRate);
|
||||
|
||||
@ -577,8 +577,6 @@ bool EnergyLogger::samplePowerBalance(SampleRate sampleRate, SampleRate baseSamp
|
||||
{
|
||||
QDateTime sampleStart = sampleEnd.addMSecs(-sampleRate * 60 * 1000);
|
||||
|
||||
// FIXME: If base samplerate does not contain a single entry in the given timeframe (e.g. system has been off for more than 15 mins) we seem to mess up totalConsumption
|
||||
// Needs verifying that lower sample rates are always rectified first!
|
||||
qCDebug(dcEnergyExperience()) << "Sampling power balance" << sampleRate << "from" << sampleStart << "to" << sampleEnd;
|
||||
|
||||
double medianConsumption = 0;
|
||||
|
||||
@ -12,10 +12,11 @@ EnergyManagerImpl::EnergyManagerImpl(ThingManager *thingManager, QObject *parent
|
||||
m_thingManager(thingManager),
|
||||
m_logger(new EnergyLogger(this))
|
||||
{
|
||||
// Most of the time we get a bunch of signals at the same time (root meter, producers, consumers etc)
|
||||
// In order to decrease some load on the system, we'll wait for wee bit until we actually update to
|
||||
// accumulate those changes and calculate the change in one go.
|
||||
m_balanceUpdateTimer.setInterval(50);
|
||||
// Most of the time we get a bunch of state changes (currentPower, totals, for inverter, battery, rootmeter)
|
||||
// at the same time if they're implemented by the same plugin.
|
||||
// In order to decrease some load on the system, we'll wait for the event loop pass to finish until we actually
|
||||
// update to accumulate those changes and calculate the change in one go.
|
||||
m_balanceUpdateTimer.setInterval(0);
|
||||
m_balanceUpdateTimer.setSingleShot(true);
|
||||
connect(&m_balanceUpdateTimer, &QTimer::timeout, this, &EnergyManagerImpl::updatePowerBalance);
|
||||
|
||||
@ -125,7 +126,7 @@ void EnergyManagerImpl::watchThing(Thing *thing)
|
||||
|
||||
qCDebug(dcEnergyExperience()) << "Wathing thing:" << thing->name();
|
||||
|
||||
// React on things that requie us updating the power balance
|
||||
// React on things that require us updating the power balance
|
||||
if (thing->thingClass().interfaces().contains("energymeter")
|
||||
|| thing->thingClass().interfaces().contains("smartmeterproducer")
|
||||
|| thing->thingClass().interfaces().contains("energystorage")) {
|
||||
|
||||
Reference in New Issue
Block a user