From bf980d74c075c46ae50963619f7ef33746aaddaa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 17:40:39 +0100 Subject: [PATCH 1/4] HK helper simplification --- CHANGELOG.md | 1 + .../PeriodicHousekeepingHelper.cpp | 34 +++---------------- .../housekeeping/PeriodicHousekeepingHelper.h | 4 +-- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f73fd68a..8a6afee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Rename FW subsystem ID from `PCDU_2` to `POWER_SYSTEM_IF`. - Add new `SWITCH_UNKNOWN` returnvalue in `PowerSwitchIF`. +- Simplify `PeriodicHousekeepingHelper`: No non-diagnostic handling # [v6.0.0] diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp index 0c2bef96..25a9df96 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp @@ -8,10 +8,8 @@ PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(LocalPoolDataSetBase* own : owner(owner) {} void PeriodicHousekeepingHelper::initialize(float collectionInterval, - dur_millis_t minimumPeriodicInterval, - uint8_t nonDiagIntervalFactor) { + dur_millis_t minimumPeriodicInterval) { this->minimumPeriodicInterval = minimumPeriodicInterval; - this->nonDiagIntervalFactor = nonDiagIntervalFactor; collectionIntervalTicks = intervalSecondsToIntervalTicks(collectionInterval); /* This will cause a checkOpNecessary call to be true immediately. I think it's okay if a HK packet is generated immediately instead of waiting one generation cycle. */ @@ -40,38 +38,14 @@ uint32_t PeriodicHousekeepingHelper::intervalSecondsToIntervalTicks( /* Avoid division by zero */ if (minimumPeriodicInterval == 0) { - if (isDiagnostics) { - /* Perform operation each cycle */ - return 1; - } else { - return nonDiagIntervalFactor; - } + /* Perform operation each cycle */ + return 1; + } else { dur_millis_t intervalInMs = collectionIntervalSeconds * 1000; uint32_t divisor = minimumPeriodicInterval; - if (not isDiagnostics) { - /* We need to multiply the divisor because non-diagnostics only - allow a multiple of the minimum periodic interval */ - divisor *= nonDiagIntervalFactor; - } uint32_t ticks = std::ceil(static_cast(intervalInMs) / divisor); - if (not isDiagnostics) { - /* Now we need to multiply the calculated ticks with the factor as as well - because the minimum tick count to generate a non-diagnostic is the factor itself. - Example calculation for non-diagnostic with - 0.4 second interval and 0.2 second task interval. - Resultant tick count of 5 is equal to operation each second. - - Examle calculation for non-diagnostic with 2.0 second interval and 0.2 second - task interval. - Resultant tick count of 10 is equal to operatin every 2 seconds. - - Example calculation for diagnostic with 0.4 second interval and 0.3 - second task interval. Resulting tick count of 2 is equal to operation - every 0.6 seconds. */ - ticks *= nonDiagIntervalFactor; - } return ticks; } } diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h index 8b6245ba..1ec0febf 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.h @@ -11,8 +11,7 @@ class PeriodicHousekeepingHelper { public: PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner); - void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval, - uint8_t nonDiagIntervalFactor); + void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval); void changeCollectionInterval(float newInterval); float getCollectionIntervalInSeconds() const; @@ -20,7 +19,6 @@ class PeriodicHousekeepingHelper { private: LocalPoolDataSetBase* owner = nullptr; - uint8_t nonDiagIntervalFactor = 0; uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds); float intervalTicksToSeconds(uint32_t collectionInterval) const; -- 2.43.0 From aac32e763cca43e93182b7f0b24ada4c38bc5365 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 18:20:17 +0100 Subject: [PATCH 2/4] some compile fixes --- src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp | 5 ++--- src/fsfw/datapoollocal/LocalPoolDataSetBase.h | 3 +-- src/fsfw/datapoollocal/internal/LocalPoolDataSetAttorney.h | 6 ++---- src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp | 1 - 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp index 38aad828..28995446 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp @@ -250,9 +250,8 @@ void LocalPoolDataSetBase::setReportingEnabled(bool reportingEnabled) { bool LocalPoolDataSetBase::getReportingEnabled() const { return reportingEnabled; } void LocalPoolDataSetBase::initializePeriodicHelper(float collectionInterval, - dur_millis_t minimumPeriodicInterval, - uint8_t nonDiagIntervalFactor) { - periodicHelper->initialize(collectionInterval, minimumPeriodicInterval, nonDiagIntervalFactor); + dur_millis_t minimumPeriodicInterval) { + periodicHelper->initialize(collectionInterval, minimumPeriodicInterval); } void LocalPoolDataSetBase::setChanged(bool changed) { this->changed = changed; } diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.h b/src/fsfw/datapoollocal/LocalPoolDataSetBase.h index 9166cf34..7aec77ea 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.h +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.h @@ -191,8 +191,7 @@ class LocalPoolDataSetBase : public PoolDataSetBase, public MarkChangedIF { */ bool reportingEnabled = false; - void initializePeriodicHelper(float collectionInterval, dur_millis_t minimumPeriodicInterval, - uint8_t nonDiagIntervalFactor = 5); + void initializePeriodicHelper(float collectionInterval, dur_millis_t minimumPeriodicInterval); /** * If the valid state of a dataset is always relevant to the whole diff --git a/src/fsfw/datapoollocal/internal/LocalPoolDataSetAttorney.h b/src/fsfw/datapoollocal/internal/LocalPoolDataSetAttorney.h index e7dbd0c7..6f9a3b27 100644 --- a/src/fsfw/datapoollocal/internal/LocalPoolDataSetAttorney.h +++ b/src/fsfw/datapoollocal/internal/LocalPoolDataSetAttorney.h @@ -12,10 +12,8 @@ class LocalPoolDataSetAttorney { static bool isDiagnostics(LocalPoolDataSetBase& set) { return set.isDiagnostics(); } static void initializePeriodicHelper(LocalPoolDataSetBase& set, float collectionInterval, - uint32_t minimumPeriodicIntervalMs, - uint8_t nonDiagIntervalFactor = 5) { - set.initializePeriodicHelper(collectionInterval, minimumPeriodicIntervalMs, - nonDiagIntervalFactor); + uint32_t minimumPeriodicIntervalMs) { + set.initializePeriodicHelper(collectionInterval, minimumPeriodicIntervalMs); } static void setReportingEnabled(LocalPoolDataSetBase& set, bool enabled) { diff --git a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp index 25a9df96..b39e45c3 100644 --- a/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp +++ b/src/fsfw/housekeeping/PeriodicHousekeepingHelper.cpp @@ -34,7 +34,6 @@ uint32_t PeriodicHousekeepingHelper::intervalSecondsToIntervalTicks( if (owner == nullptr) { return 0; } - bool isDiagnostics = owner->isDiagnostics(); /* Avoid division by zero */ if (minimumPeriodicInterval == 0) { -- 2.43.0 From c61c85280b81d3506b5b4163e11f8f9d436cc3fb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 18:26:04 +0100 Subject: [PATCH 3/4] remove more code --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 7 +------ src/fsfw/datapoollocal/LocalDataPoolManager.h | 13 +------------ 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index a2712909..f66a328c 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -70,8 +70,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { return returnvalue::OK; } -ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation(uint8_t nonDiagInvlFactor) { - setNonDiagnosticIntervalFactor(nonDiagInvlFactor); +ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation() { return initializeHousekeepingPoolEntriesOnce(); } @@ -661,10 +660,6 @@ ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(HousekeepingPacke return hkPacket.serialize(&dataPtr, serializedSize, maxSize, SerializeIF::Endianness::MACHINE); } -void LocalDataPoolManager::setNonDiagnosticIntervalFactor(uint8_t nonDiagInvlFactor) { - this->nonDiagnosticIntervalFactor = nonDiagInvlFactor; -} - void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { sid_t sid = receiver.dataId.sid; LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index 8f369ea0..65d58d59 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -102,7 +102,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces * @param nonDiagInvlFactor * @return */ - ReturnValue_t initializeAfterTaskCreation(uint8_t nonDiagInvlFactor = 5); + ReturnValue_t initializeAfterTaskCreation(); /** * @brief This should be called in the periodic handler of the owner. @@ -152,17 +152,6 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces MessageQueueId_t targetQueueId, bool generateSnapshot) override; - /** - * Non-Diagnostics packets usually have a lower minimum sampling frequency - * than diagnostic packets. - * A factor can be specified to determine the minimum sampling frequency - * for non-diagnostic packets. The minimum sampling frequency of the - * diagnostics packets,which is usually jusst the period of the - * performOperation calls, is multiplied with that factor. - * @param factor - */ - void setNonDiagnosticIntervalFactor(uint8_t nonDiagInvlFactor); - /** * @brief The manager is also able to handle housekeeping messages. * @details -- 2.43.0 From 522bd41d6e760a9905a0346908cb8d891a506285 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 18:26:44 +0100 Subject: [PATCH 4/4] changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ab90249..d11ef73a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Rename FW subsystem ID from `PCDU_2` to `POWER_SYSTEM_IF`. - Add new `SWITCH_UNKNOWN` returnvalue in `PowerSwitchIF`. -- Simplify `PeriodicHousekeepingHelper`: No non-diagnostic handling +- Simplify `PeriodicHousekeepingHelper`: No non-diagnostic handling. + Start removing the distinction between diagnostics and regular + HK packets. - Pool Manager now allows enabling the `spillToHigherPools` option. # [v6.0.0] -- 2.43.0