catch exception in NVM param base
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
2022-03-01 19:43:40 +01:00
parent e1b8debb27
commit d8240881cc
6 changed files with 41 additions and 21 deletions

View File

@ -180,6 +180,23 @@ class PlPcduParameter : public NVMParameterBase {
PlPcduParameter() : NVMParameterBase(""), mountPrefix("") {
using namespace plpcdu;
// Initialize with default values
resetValues();
}
ReturnValue_t initialize(std::string mountPrefix) {
setFullName(mountPrefix + "/conf/plpcdu.json");
ReturnValue_t result = readJsonFile();
if (result != HasReturnvaluesIF::RETURN_OK) {
// File does not exist or reading JSON failed for various reason. Rewrite the JSON file
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "Creating PL PCDU JSON file at " << getFullName() << std::endl;
#endif
resetValues();
writeJsonFile();
}
return HasReturnvaluesIF::RETURN_OK;
}
void resetValues() {
insertValue(PARAM_KEY_MAP[SSR_TO_DRO_WAIT_TIME], DFT_SSR_TO_DRO_WAIT_TIME);
insertValue(PARAM_KEY_MAP[DRO_TO_X8_WAIT_TIME], DFT_DRO_TO_X8_WAIT_TIME);
insertValue(PARAM_KEY_MAP[X8_TO_TX_WAIT_TIME], DFT_X8_TO_TX_WAIT_TIME);
@ -204,20 +221,6 @@ class PlPcduParameter : public NVMParameterBase {
insertValue(PARAM_KEY_MAP[HPA_I_UPPER_BOUND], DFT_HPA_I_UPPER_BOUND);
}
ReturnValue_t initialize(std::string mountPrefix) {
setFullName(mountPrefix + "/conf/plpcdu.json");
ReturnValue_t result = readJsonFile();
if (result != HasReturnvaluesIF::RETURN_OK) {
// File does not exist. Create it. Keys and appropriate init values were
// specified in constructor
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "Creating PL PCDU JSON file at " << getFullName() << std::endl;
#endif
writeJsonFile();
}
return HasReturnvaluesIF::RETURN_OK;
}
private:
std::string mountPrefix;
};