[MOS-278] Fixed frequency hold algorithm behaviour

fixed hold frequency algorithm behaviour
added basic tests for frequecy changing
updated catch for newer gcc
tests added
This commit is contained in:
Adam Dobrowolski
2022-03-08 16:48:14 +01:00
committed by Adam Dobrowolski
parent aacd665eb9
commit 43cd960523
17 changed files with 230 additions and 47 deletions

View File

@@ -30,4 +30,31 @@ namespace sys::cpu
{
algorithms.erase(id);
}
AlgorithmResult AlgorithmFactory::calculate(const std::list<sys::cpu::AlgoID> &algorithms,
cpu::AlgorithmData &data,
AlgoID *used)
{
for (auto id : algorithms) {
if (auto algo = get(id); algo != nullptr) {
if (auto result = algo->calculate(data); result.change != sys::cpu::algorithm::Change::NoChange) {
if (used != nullptr) {
*used = id;
}
return result;
}
}
}
return sys::cpu::AlgorithmResult{sys::cpu::algorithm::Change::NoChange, bsp::CpuFrequencyMHz::Level_6};
}
void AlgorithmFactory::reset(const std::list<sys::cpu::AlgoID> &algorithms)
{
for (auto again : algorithms) {
if (auto al = get(again); al != nullptr) {
al->reset();
}
}
}
} // namespace sys::cpu