HK helper simplification
This commit is contained in:
parent
b6b9d1d790
commit
bf980d74c0
@ -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`.
|
- Rename FW subsystem ID from `PCDU_2` to `POWER_SYSTEM_IF`.
|
||||||
- Add new `SWITCH_UNKNOWN` returnvalue in `PowerSwitchIF`.
|
- Add new `SWITCH_UNKNOWN` returnvalue in `PowerSwitchIF`.
|
||||||
|
- Simplify `PeriodicHousekeepingHelper`: No non-diagnostic handling
|
||||||
|
|
||||||
# [v6.0.0]
|
# [v6.0.0]
|
||||||
|
|
||||||
|
@ -8,10 +8,8 @@ PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(LocalPoolDataSetBase* own
|
|||||||
: owner(owner) {}
|
: owner(owner) {}
|
||||||
|
|
||||||
void PeriodicHousekeepingHelper::initialize(float collectionInterval,
|
void PeriodicHousekeepingHelper::initialize(float collectionInterval,
|
||||||
dur_millis_t minimumPeriodicInterval,
|
dur_millis_t minimumPeriodicInterval) {
|
||||||
uint8_t nonDiagIntervalFactor) {
|
|
||||||
this->minimumPeriodicInterval = minimumPeriodicInterval;
|
this->minimumPeriodicInterval = minimumPeriodicInterval;
|
||||||
this->nonDiagIntervalFactor = nonDiagIntervalFactor;
|
|
||||||
collectionIntervalTicks = intervalSecondsToIntervalTicks(collectionInterval);
|
collectionIntervalTicks = intervalSecondsToIntervalTicks(collectionInterval);
|
||||||
/* This will cause a checkOpNecessary call to be true immediately. I think it's okay
|
/* 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. */
|
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 */
|
/* Avoid division by zero */
|
||||||
if (minimumPeriodicInterval == 0) {
|
if (minimumPeriodicInterval == 0) {
|
||||||
if (isDiagnostics) {
|
|
||||||
/* Perform operation each cycle */
|
/* Perform operation each cycle */
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
|
||||||
return nonDiagIntervalFactor;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
dur_millis_t intervalInMs = collectionIntervalSeconds * 1000;
|
dur_millis_t intervalInMs = collectionIntervalSeconds * 1000;
|
||||||
uint32_t divisor = minimumPeriodicInterval;
|
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<float>(intervalInMs) / divisor);
|
uint32_t ticks = std::ceil(static_cast<float>(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;
|
return ticks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ class PeriodicHousekeepingHelper {
|
|||||||
public:
|
public:
|
||||||
PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner);
|
PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner);
|
||||||
|
|
||||||
void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval);
|
||||||
uint8_t nonDiagIntervalFactor);
|
|
||||||
|
|
||||||
void changeCollectionInterval(float newInterval);
|
void changeCollectionInterval(float newInterval);
|
||||||
float getCollectionIntervalInSeconds() const;
|
float getCollectionIntervalInSeconds() const;
|
||||||
@ -20,7 +19,6 @@ class PeriodicHousekeepingHelper {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
LocalPoolDataSetBase* owner = nullptr;
|
LocalPoolDataSetBase* owner = nullptr;
|
||||||
uint8_t nonDiagIntervalFactor = 0;
|
|
||||||
|
|
||||||
uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds);
|
uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds);
|
||||||
float intervalTicksToSeconds(uint32_t collectionInterval) const;
|
float intervalTicksToSeconds(uint32_t collectionInterval) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user