bug fix + generating template for names
CI / build-and-test (push) Successful in 8s

This commit is contained in:
2026-07-30 09:26:53 +02:00
parent 8365f72788
commit a7a2ba019b
4 changed files with 73 additions and 39 deletions
+2 -1
View File
@@ -5,7 +5,8 @@ project(generic VERSION 1.0)
add_compile_options(
-Wall
-Wformat=2
-O2
-O0
-g
-Wuninitialized
-Wno-unused-function
)
+51 -36
View File
@@ -6,14 +6,14 @@
using namespace SettingsHandlerConfig;
void SettingsHandler::pullEquipmentName() {
midas::odb o(this->path);
midas::odb o(this->pathLong);
std::string equipmentName = o[SettingsHandlerConfig::EQUIPMENT_NAME];
Event event = {EventType::EQUIPMENT_NAME, equipmentName};
eventBus.publish(event);
}
void SettingsHandler::pullOutputPressureSPIndex() {
midas::odb o(this->path);
midas::odb o(this->pathLong);
int outputPressureSPIndex =
o[SettingsHandlerConfig::OUTPUT_PRESSURE_SP_INDEX];
Event event = {EventType::OUTPUT_PRESSURE_SP_INDEX, outputPressureSPIndex};
@@ -21,28 +21,28 @@ void SettingsHandler::pullOutputPressureSPIndex() {
}
void SettingsHandler::pullInputSPIndex() {
midas::odb o(this->path);
midas::odb o(this->pathLong);
int inputSPIndex = o[SettingsHandlerConfig::INPUT_SP_INDEX];
Event event = {EventType::INPUT_SP_INDEX, inputSPIndex};
eventBus.publish(event);
}
void SettingsHandler::pullInputTemperatureIndex() {
midas::odb o(this->path);
midas::odb o(this->pathLong);
int temperatureIndex = o[SettingsHandlerConfig::INPUT_TEMPERATURE_INDEX];
Event event = {EventType::INPUT_TEMPERATURE_INDEX, temperatureIndex};
eventBus.publish(event);
}
void SettingsHandler::pullInputPowerIndex() {
midas::odb o(this->path);
midas::odb o(this->pathLong);
int powerIndex = o[SettingsHandlerConfig::INPUT_POWER_INDEX];
Event event = {EventType::INPUT_POWER_INDEX, powerIndex};
eventBus.publish(event);
}
void SettingsHandler::pullAverageTimeWindow() {
midas::odb o(this->path);
midas::odb o(this->pathLong);
float average_time_window = o[SettingsHandlerConfig::TIME_WINDOW];
Event event = {EventType::AVERAGE_TIME_WINDOW, average_time_window};
eventBus.publish(event);
@@ -50,8 +50,10 @@ void SettingsHandler::pullAverageTimeWindow() {
SettingsHandler::SettingsHandler(EventBus &eventBusReference,
std::string equipmentName)
: path(SettingsHandlerConfig::PATH_PREFIX + equipmentName +
SettingsHandlerConfig::PATH_SUFFIX),
: pathShort(SettingsHandlerConfig::PATH_PREFIX + equipmentName +
SettingsHandlerConfig::PATH_SUFFIX_SHORT),
pathLong(SettingsHandlerConfig::PATH_PREFIX + equipmentName +
SettingsHandlerConfig::PATH_SUFFIX_LONG),
eventBus(eventBusReference) {
eventBus.subscribe<itcPressureOptimizer::EquipmentInitEvent>(
[this](const itcPressureOptimizer::EquipmentInitEvent &e) {
@@ -60,70 +62,83 @@ SettingsHandler::SettingsHandler(EventBus &eventBusReference,
}
bool SettingsHandler::init() {
midas::odb o(this->path);
bool areKeysValids = true;
if (!midas::odb::exists(path + SettingsHandlerConfig::EQUIPMENT_NAME)) {
if (!midas::odb::exists(pathLong + SettingsHandlerConfig::EQUIPMENT_NAME)) {
TMFE::Instance()->Msg(MERROR, __FUNCTION__,
"Key at %s%s doesn't exists", path.c_str(),
"Key at %s%s doesn't exists", pathLong.c_str(),
SettingsHandlerConfig::EQUIPMENT_NAME.c_str());
areKeysValids = false;
}
if (!midas::odb::exists(path +
if (!midas::odb::exists(pathLong +
SettingsHandlerConfig::OUTPUT_PRESSURE_SP_INDEX)) {
TMFE::Instance()->Msg(
MERROR, __FUNCTION__, "Key at %s%s doesn't exists", path.c_str(),
MERROR, __FUNCTION__, "Key at %s%s doesn't exists",
pathLong.c_str(),
SettingsHandlerConfig::OUTPUT_PRESSURE_SP_INDEX.c_str());
areKeysValids = false;
}
if (!midas::odb::exists(path + SettingsHandlerConfig::INPUT_SP_INDEX)) {
if (!midas::odb::exists(pathLong + SettingsHandlerConfig::INPUT_SP_INDEX)) {
TMFE::Instance()->Msg(MERROR, __FUNCTION__,
"Key at %s%s doesn't exists", path.c_str(),
"Key at %s%s doesn't exists", pathLong.c_str(),
SettingsHandlerConfig::INPUT_SP_INDEX.c_str());
areKeysValids = false;
}
if (!midas::odb::exists(path +
if (!midas::odb::exists(pathLong +
SettingsHandlerConfig::INPUT_TEMPERATURE_INDEX)) {
TMFE::Instance()->Msg(
MERROR, __FUNCTION__, "Key at %s%s doesn't exists", path.c_str(),
MERROR, __FUNCTION__, "Key at %s%s doesn't exists",
pathLong.c_str(),
SettingsHandlerConfig::INPUT_TEMPERATURE_INDEX.c_str());
areKeysValids = false;
}
if (!midas::odb::exists(path + SettingsHandlerConfig::INPUT_POWER_INDEX)) {
if (!midas::odb::exists(pathLong +
SettingsHandlerConfig::INPUT_POWER_INDEX)) {
TMFE::Instance()->Msg(MERROR, __FUNCTION__,
"Key at %s%s doesn't exists", path.c_str(),
"Key at %s%s doesn't exists", pathLong.c_str(),
SettingsHandlerConfig::INPUT_POWER_INDEX.c_str());
areKeysValids = false;
}
if (!midas::odb::exists(path + SettingsHandlerConfig::TIME_WINDOW)) {
if (!midas::odb::exists(pathLong + SettingsHandlerConfig::TIME_WINDOW)) {
TMFE::Instance()->Msg(MERROR, __FUNCTION__,
"Key at %s%s doesn't exists", path.c_str(),
"Key at %s%s doesn't exists", pathLong.c_str(),
SettingsHandlerConfig::TIME_WINDOW.c_str());
areKeysValids = false;
}
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}}};
midas::odb o = {
{SettingsHandlerConfig::DEVICES_DIRNAME.c_str(),
{{SettingsHandlerConfig::ITC_PRESSURE_OPTIMIZER_DIRNAME.c_str(),
{{SettingsHandlerConfig::DD_DIRNAME.c_str(),
{{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}}}}}}}};
o.connect(this->pathShort);
TMFE::Instance()->Msg(
MERROR, __FUNCTION__,
"Some keys are missing at %s. Please fill the generated template.",
path.c_str());
pathLong.c_str());
midas::odb k = {{SettingsHandlerConfig::NAMES.c_str(), {""}}};
k.connect(this->pathShort);
midas::odb l(this->pathShort);
l[SettingsHandlerConfig::NAMES.c_str()] =
SettingsHandlerConfig::NAMES_LIST;
o.connect(this->path);
throw std::runtime_error("SettinsHandler init failed - see MIDAS "
"console and take care of all the errors\n");
}
+2 -1
View File
@@ -25,7 +25,8 @@ class SettingsHandler {
};
private:
std::string path;
std::string pathShort;
std::string pathLong;
EventBus &eventBus;
/*
+18 -1
View File
@@ -6,7 +6,16 @@
namespace SettingsHandlerConfig {
const std::string PATH_PREFIX = "/Equipment/";
const std::string PATH_SUFFIX = "/Settings/Devices/ItcPressureOptimizer/DD/";
const std::string SETTINGS_DIRNAME = "Settings";
const std::string DEVICES_DIRNAME = "Devices";
const std::string ITC_PRESSURE_OPTIMIZER_DIRNAME = "ItcPressureOptimizer";
const std::string DD_DIRNAME = "DD";
const std::string PATH_SUFFIX_SHORT = "/" + SETTINGS_DIRNAME + "/";
const std::string PATH_SUFFIX_LONG =
"/" + SETTINGS_DIRNAME + "/" + DEVICES_DIRNAME + "/" +
ITC_PRESSURE_OPTIMIZER_DIRNAME + "/" + DD_DIRNAME + "/";
const std::string EQUIPMENT_NAME = "Equipment name";
const std::string OUTPUT_PRESSURE_SP_INDEX = "Output Pressure SetPoint Index";
@@ -15,6 +24,14 @@ const std::string INPUT_TEMPERATURE_INDEX = "Input Temperature Index";
const std::string INPUT_POWER_INDEX = "Input Power Index";
const std::string TIME_WINDOW = "Average Power Time Window";
const std::string NAMES = "Names";
const std::vector<std::string> NAMES_LIST = {
"Pressure Setpoint", "ITC SetPoint",
"ITC Temperature", "ITC Power",
"Average Power", "Calculated Pressure",
"Pressure Control Mode", "Set Pressure",
"Minimum Pressure Value", "Maximum Pressure Value",
"Pressure Constant 1", "Pressure Contrant 2"};
const std::string DEFAULT_EQUIPMENT_NAME = "";
const int DEFAULT_INDEX_VALUE = -1;
const float DEFAULT_TIME_WINDOWS_SIZE = 30.0f;