2022-03-01 17:17:15 +01:00
|
|
|
#include "ProgressPrinter.h"
|
2022-03-04 15:14:02 +01:00
|
|
|
|
2022-03-01 17:17:15 +01:00
|
|
|
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
|
|
|
|
2022-04-16 17:19:32 +02:00
|
|
|
ProgressPrinter::ProgressPrinter(std::string name, uint32_t numSteps, uint32_t percentageResolution)
|
2022-04-19 13:33:37 +02:00
|
|
|
: name(name), numSteps(numSteps), percentageResolution(percentageResolution) {}
|
2022-03-01 17:17:15 +01:00
|
|
|
|
2022-03-04 15:14:02 +01:00
|
|
|
ProgressPrinter::~ProgressPrinter() {}
|
2022-03-01 17:17:15 +01:00
|
|
|
|
|
|
|
void ProgressPrinter::print(uint32_t currentStep) {
|
|
|
|
float progressInPercent = static_cast<float>(currentStep) / static_cast<float>(numSteps) * 100;
|
|
|
|
if (static_cast<uint32_t>(progressInPercent) >= nextProgressPrint) {
|
|
|
|
sif::info << name << " progress: " << progressInPercent << " %" << std::endl;
|
2022-04-19 13:33:37 +02:00
|
|
|
nextProgressPrint += percentageResolution;
|
2022-03-01 17:17:15 +01:00
|
|
|
}
|
|
|
|
}
|