eive-obsw/mission/utility/ProgressPrinter.cpp
Jakob Meier 6d322c6e78
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
run clang format script
2022-04-30 16:21:59 +02:00

20 lines
703 B
C++

#include "ProgressPrinter.h"
#include <iomanip>
#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;
}
}