eive-obsw/bsp_q7s/memory/LocalParameterHandler.cpp
2023-02-23 15:19:48 +01:00

43 lines
1.1 KiB
C++

#include "LocalParameterHandler.h"
#include <fsfw/serviceinterface/ServiceInterface.h>
LocalParameterHandler::LocalParameterHandler(std::string sdRelativeName, SdCardMountedIF* sdcMan)
: NVMParameterBase(), sdRelativeName(sdRelativeName), sdcMan(sdcMan) {}
LocalParameterHandler::~LocalParameterHandler() {
}
ReturnValue_t LocalParameterHandler::initialize() {
ReturnValue_t result = updateFullName();
if (result != returnvalue::OK) {
return result;
}
result = readJsonFile();
if (result != returnvalue::OK) {
return result;
}
return returnvalue::OK;
}
ReturnValue_t LocalParameterHandler::writeJsonFile() {
ReturnValue_t result = updateFullName();
if (result != returnvalue::OK) {
return result;
}
return NVMParameterBase::writeJsonFile();
}
ReturnValue_t LocalParameterHandler::updateFullName() {
std::string mountPrefix;
auto activeSd = sdcMan->getActiveSdCard();
if (activeSd and sdcMan->isSdCardUsable(activeSd.value())) {
mountPrefix = sdcMan->getCurrentMountPrefix();
} else {
return SD_NOT_READY;
}
std::string fullname = mountPrefix + "/" + sdRelativeName;
NVMParameterBase::setFullName(fullname);
return returnvalue::OK;
}