#include "fsfw/housekeeping/PeriodicHousekeepingHelper.h" #include #include "fsfw/datapoollocal/LocalPoolDataSetBase.h" #include "fsfw/serviceinterface.h" PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner) : owner(owner) {} void PeriodicHousekeepingHelper::initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval) { this->minimumPeriodicInterval = minimumPeriodicInterval; changeCollectionInterval(collectionInterval); } float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const { return collectionInterval; } bool PeriodicHousekeepingHelper::checkOpNecessary() { if (hkGenerationCd.hasTimedOut()) { hkGenerationCd.resetTimer(); return true; } return false; } void PeriodicHousekeepingHelper::changeCollectionInterval(float newIntervalSeconds) { uint32_t intervalMs = newIntervalSeconds * 1000; if (newIntervalSeconds <= 0) { intervalMs = minimumPeriodicInterval; newIntervalSeconds = static_cast(minimumPeriodicInterval) / 1000.0; } collectionInterval = newIntervalSeconds; hkGenerationCd.setTimeout(intervalMs); // We want an immediate HK packet at the start, so time out the generation CD immediately. hkGenerationCd.timeOut(); }