Merge remote-tracking branch 'origin/develop' into mueller/system-subsystems
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -19,7 +19,7 @@ ReturnValue_t NVMParameterBase::readJsonFile() {
|
||||
|
||||
ReturnValue_t NVMParameterBase::writeJsonFile() {
|
||||
std::ofstream o(fullName);
|
||||
o << std::setw(4) << json;
|
||||
o << std::setw(4) << json << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class NVMParameterBase : public HasReturnvaluesIF {
|
||||
ReturnValue_t setValue(std::string key, T value);
|
||||
|
||||
template <typename T>
|
||||
ReturnValue_t getValue(std::string key, T* value) const;
|
||||
ReturnValue_t getValue(std::string key, T& value) const;
|
||||
|
||||
void printKeys() const;
|
||||
void print() const;
|
||||
@ -67,11 +67,11 @@ inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const {
|
||||
inline ReturnValue_t NVMParameterBase::getValue(std::string key, T& value) const {
|
||||
if (!json.contains(key)) {
|
||||
return KEY_NOT_EXISTS;
|
||||
}
|
||||
*value = json[key];
|
||||
value = json[key];
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
target_sources(${LIB_EIVE_MISSION} PRIVATE
|
||||
TmFunnel.cpp
|
||||
Timestamp.cpp
|
||||
ProgressPrinter.cpp
|
||||
)
|
||||
|
||||
|
||||
|
16
mission/utility/ProgressPrinter.cpp
Normal file
16
mission/utility/ProgressPrinter.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "ProgressPrinter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
ProgressPrinter::ProgressPrinter(std::string name, uint32_t numSteps)
|
||||
: name(name), numSteps(numSteps) {}
|
||||
|
||||
ProgressPrinter::~ProgressPrinter() {
|
||||
}
|
||||
|
||||
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;
|
||||
nextProgressPrint += FIVE_PERCENT;
|
||||
}
|
||||
}
|
37
mission/utility/ProgressPrinter.h
Normal file
37
mission/utility/ProgressPrinter.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef MISSION_UTILITY_PROGRESSPRINTER_H_
|
||||
#define MISSION_UTILITY_PROGRESSPRINTER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @brief Class which can be used to print the progress of processes in percent.
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class ProgressPrinter {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param name Name of the process to monitor
|
||||
* @param numSteps Number of steps to execute
|
||||
*/
|
||||
ProgressPrinter(std::string name, uint32_t numSteps);
|
||||
virtual ~ProgressPrinter();
|
||||
|
||||
/**
|
||||
* @brief Will print the progress
|
||||
*
|
||||
* @param currentStep Current step from which to derive progress
|
||||
*/
|
||||
void print(uint32_t step);
|
||||
|
||||
private:
|
||||
static constexpr uint32_t FIVE_PERCENT = 5;
|
||||
|
||||
std::string name = "";
|
||||
uint32_t numSteps = 0;
|
||||
uint32_t nextProgressPrint = 0;
|
||||
};
|
||||
|
||||
#endif /* MISSION_UTILITY_PROGRESSPRINTER_H_ */
|
Reference in New Issue
Block a user