eive-obsw/bsp_q7s/memory/LocalParameterHandler.cpp

42 lines
1.2 KiB
C++
Raw Normal View History

2023-02-13 11:28:27 +01:00
#include "LocalParameterHandler.h"
2023-02-23 15:27:24 +01:00
2023-02-13 11:28:27 +01:00
#include <fsfw/serviceinterface/ServiceInterface.h>
LocalParameterHandler::LocalParameterHandler(std::string sdRelativeName, SdCardMountedIF* sdcMan)
: NVMParameterBase(), sdRelativeName(sdRelativeName), sdcMan(sdcMan) {}
2023-02-13 11:28:27 +01:00
2023-02-23 15:27:24 +01:00
LocalParameterHandler::~LocalParameterHandler() {}
2023-02-13 11:28:27 +01:00
ReturnValue_t LocalParameterHandler::initialize() {
2023-02-23 15:27:24 +01:00
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() {
2023-02-23 15:27:24 +01:00
ReturnValue_t result = updateFullName();
if (result != returnvalue::OK) {
return result;
}
return NVMParameterBase::writeJsonFile();
}
ReturnValue_t LocalParameterHandler::updateFullName() {
2023-02-23 15:27:24 +01:00
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;
2023-02-13 11:28:27 +01:00
}