#include "ProgressPrinter.h" #include #include #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(currentStep) / static_cast(numSteps) * 100; if (progressInPercent >= nextProgressPrint) { sif::info << name << " progress: " << std::setprecision(4) << progressInPercent << " %" << std::endl; nextProgressPrint += percentageResolution; } if (nextProgressPrint - progressInPercent < 0) { nextProgressPrint = (std::floor(progressInPercent / percentageResolution) * percentageResolution) + percentageResolution; } }