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)
|
2023-02-22 07:15:19 +01:00
|
|
|
: 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;
|
2023-02-23 15:19:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2023-02-23 15:19:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|