eive-obsw/mission/utility/ProgressPrinter.cpp
2022-04-25 11:03:02 +02:00

18 lines
701 B
C++

#include <iomanip>
#include "ProgressPrinter.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
ProgressPrinter::ProgressPrinter(std::string name, uint32_t numSteps, float percentageResolution)
: name(name), numSteps(numSteps), percentageResolution(percentageResolution) {}
ProgressPrinter::~ProgressPrinter() {}
void ProgressPrinter::print(uint32_t currentStep) {
float progressInPercent = static_cast<float>(currentStep) / static_cast<float>(numSteps) * 100;
if (progressInPercent >= nextProgressPrint) {
sif::info << name << " progress: " << std::setprecision(4) << progressInPercent << " %"
<< std::endl;
nextProgressPrint += percentageResolution;
}
}