countdown based HK generation #156

Merged
muellerr merged 4 commits from hk-generation-countdown-based into develop 2023-07-11 17:35:10 +02:00
2 changed files with 7 additions and 0 deletions
Showing only changes of commit 9c8b1c697b - Show all commits

View File

@ -14,6 +14,10 @@ void PeriodicHousekeepingHelper::initialize(float collectionInterval,
changeCollectionInterval(collectionInterval); changeCollectionInterval(collectionInterval);
} }
float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const {
return collectionInterval;
}
bool PeriodicHousekeepingHelper::checkOpNecessary() { bool PeriodicHousekeepingHelper::checkOpNecessary() {
if (hkGenerationCd.hasTimedOut()) { if (hkGenerationCd.hasTimedOut()) {
hkGenerationCd.resetTimer(); hkGenerationCd.resetTimer();
@ -26,6 +30,8 @@ void PeriodicHousekeepingHelper::changeCollectionInterval(float newIntervalSecon
uint32_t intervalMs = newIntervalSeconds * 1000; uint32_t intervalMs = newIntervalSeconds * 1000;
if (newIntervalSeconds <= 0) { if (newIntervalSeconds <= 0) {
intervalMs = minimumPeriodicInterval; intervalMs = minimumPeriodicInterval;
newIntervalSeconds = static_cast<float>(minimumPeriodicInterval) / 1000.0;
} }
collectionInterval = newIntervalSeconds;
hkGenerationCd.setTimeout(intervalMs); hkGenerationCd.setTimeout(intervalMs);
} }

View File

@ -22,6 +22,7 @@ class PeriodicHousekeepingHelper {
private: private:
LocalPoolDataSetBase* owner = nullptr; LocalPoolDataSetBase* owner = nullptr;
Countdown hkGenerationCd; Countdown hkGenerationCd;
float collectionInterval = 0.0;
dur_millis_t minimumPeriodicInterval = 0; dur_millis_t minimumPeriodicInterval = 0;
}; };