creating defautl template if missing
This commit is contained in:
@@ -14,6 +14,11 @@ bool DemandHandler::init() {
|
||||
if (!midas::odb::exists(this->path)) {
|
||||
TMFE::Instance()->Msg(MERROR, __FUNCTION__, "Key at %s doesn't exists",
|
||||
path.c_str());
|
||||
|
||||
midas::odb o(this->path);
|
||||
std::vector<float> v = {0.0};
|
||||
o = v;
|
||||
|
||||
initSuccess = false;
|
||||
}
|
||||
midas::odb o(this->path);
|
||||
|
||||
@@ -54,6 +54,15 @@ FeedbackHandler::FeedbackHandler(EventBus &eventBusReference,
|
||||
}
|
||||
|
||||
void FeedbackHandler::updatePressure() {
|
||||
// If the key doesn't exist, we create the template.
|
||||
if (!midas::odb::exists(path + FeedbackHandlerConf::OUTPUT_VARNAME)) {
|
||||
std::vector<float> v;
|
||||
v.resize(static_cast<int>(
|
||||
FeedbackHandlerConf::RegisterIndex::MAXIMUM_REGISTRY_INDEX));
|
||||
midas::odb o(path);
|
||||
o[FeedbackHandlerConf::OUTPUT_VARNAME] = v;
|
||||
}
|
||||
|
||||
{
|
||||
midas::odb o(path);
|
||||
o[FeedbackHandlerConf::OUTPUT_VARNAME]
|
||||
|
||||
@@ -20,7 +20,10 @@ enum class RegisterIndex {
|
||||
MINIMUM_PRESSURE = 8,
|
||||
MAXIMUM_PRESSURE = 9,
|
||||
CONSTANTE_1 = 10,
|
||||
CONSTANTE_2 = 11
|
||||
CONSTANTE_2 = 11,
|
||||
MAXIMUM_REGISTRY_INDEX =
|
||||
11 // Used as a safety guard for undersize array. Put this enum member
|
||||
// always as the same value as the highest member
|
||||
};
|
||||
} // namespace FeedbackHandlerConf
|
||||
|
||||
|
||||
@@ -90,9 +90,30 @@ bool SettingsHandler::init() {
|
||||
areKeysValids = false;
|
||||
}
|
||||
|
||||
if (!areKeysValids)
|
||||
if (!areKeysValids) {
|
||||
midas::odb o = {
|
||||
{SettingsHandlerConfig::EQUIPMENT_NAME.c_str(),
|
||||
{SettingsHandlerConfig::DEFAULT_EQUIPMENT_NAME.c_str()}},
|
||||
{SettingsHandlerConfig::OUTPUT_PRESSURE_SP_INDEX.c_str(),
|
||||
{SettingsHandlerConfig::DEFAULT_INDEX_VALUE}},
|
||||
{SettingsHandlerConfig::INPUT_SP_INDEX.c_str(),
|
||||
{SettingsHandlerConfig::DEFAULT_INDEX_VALUE}},
|
||||
{SettingsHandlerConfig::INPUT_TEMPERATURE_INDEX.c_str(),
|
||||
{SettingsHandlerConfig::DEFAULT_INDEX_VALUE}},
|
||||
{SettingsHandlerConfig::INPUT_POWER_INDEX.c_str(),
|
||||
{SettingsHandlerConfig::DEFAULT_INDEX_VALUE}},
|
||||
{SettingsHandlerConfig::TIME_WINDOW.c_str(),
|
||||
{SettingsHandlerConfig::DEFAULT_TIME_WINDOWS_SIZE}}};
|
||||
|
||||
TMFE::Instance()->Msg(
|
||||
MERROR, __FUNCTION__,
|
||||
"Some keys are missing at %s. Please fill the generated template.",
|
||||
path.c_str());
|
||||
|
||||
o.connect(this->path);
|
||||
throw std::runtime_error("SettinsHandler init failed - see MIDAS "
|
||||
"console and take care of all the errors\n");
|
||||
}
|
||||
|
||||
this->pullEquipmentName();
|
||||
this->pullOutputPressureSPIndex();
|
||||
|
||||
@@ -13,6 +13,11 @@ const std::string OUTPUT_PRESSURE_SP_INDEX = "MITC_OutputPressSPIndex";
|
||||
const std::string INPUT_SP_INDEX = "MITC_InputVarioxSPIndex";
|
||||
const std::string INPUT_TEMPERATURE_INDEX = "MITC_InputVarioxTempIndex";
|
||||
const std::string INPUT_POWER_INDEX = "MITC_InputVarioxPowIndex";
|
||||
const std::string TIME_WINDOW = "Average_Power_Time_Window";
|
||||
|
||||
const std::string DEFAULT_EQUIPMENT_NAME = "";
|
||||
const int DEFAULT_INDEX_VALUE = -1;
|
||||
const float DEFAULT_TIME_WINDOWS_SIZE = 30.0f;
|
||||
|
||||
} // namespace SettingsHandlerConfig
|
||||
|
||||
|
||||
Reference in New Issue
Block a user