From 4927bd73ddf2a922922eba57a41be07265e93bdb Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Tue, 28 Jul 2026 11:19:39 +0200 Subject: [PATCH 1/5] constante is without a e in English, add Enable in front of data type --- src/device/handlers/DemandHandler.cpp | 49 +++++++++++---------- src/device/handlers/DemandHandler.h | 12 ++--- src/device/handlers/DemandHandlerConfig.h | 4 +- src/device/handlers/FeedbackHandler.cpp | 18 ++++---- src/device/handlers/FeedbackHandler.h | 4 +- src/device/handlers/FeedbackHandlerConfig.h | 4 +- src/device/handlers/OutputHandler.cpp | 5 +-- src/device/handlers/PressureCalculator.cpp | 22 ++++----- src/device/handlers/PressureCalculator.h | 8 ++-- 9 files changed, 61 insertions(+), 65 deletions(-) diff --git a/src/device/handlers/DemandHandler.cpp b/src/device/handlers/DemandHandler.cpp index 8c3765d..5267a03 100644 --- a/src/device/handlers/DemandHandler.cpp +++ b/src/device/handlers/DemandHandler.cpp @@ -48,19 +48,19 @@ bool DemandHandler::init() { initSuccess = false; } if (o[DemandHandlerConfig::DEMAND].size() < - static_cast(ParameterIndex::CONSTANTE_1)) { - TMFE::Instance()->Msg( - MERROR, __FUNCTION__, - "Constante 1 index is %i, where array size is %i.", - static_cast(ParameterIndex::CONSTANTE_1), o.size()); + static_cast(ParameterIndex::CONSTANT_1)) { + TMFE::Instance()->Msg(MERROR, __FUNCTION__, + "Constant 1 index is %i, where array size is %i.", + static_cast(ParameterIndex::CONSTANT_1), + o.size()); initSuccess = false; } if (o[DemandHandlerConfig::DEMAND].size() < - static_cast(ParameterIndex::CONSTANTE_2)) { - TMFE::Instance()->Msg( - MERROR, __FUNCTION__, - "Constante 2 index is %i, where array size is %i.", - static_cast(ParameterIndex::CONSTANTE_2), o.size()); + static_cast(ParameterIndex::CONSTANT_2)) { + TMFE::Instance()->Msg(MERROR, __FUNCTION__, + "Constant 2 index is %i, where array size is %i.", + static_cast(ParameterIndex::CONSTANT_2), + o.size()); initSuccess = false; } if (o[DemandHandlerConfig::DEMAND].size() < @@ -86,8 +86,8 @@ bool DemandHandler::init() { this->pullMinimalPressure(); this->pullMaximalPressure(); - this->pullConstante1(); - this->pullConstante2(); + this->pullConstant1(); + this->pullConstant2(); this->pullPressureControlMode(); return true; } @@ -102,11 +102,11 @@ bool DemandHandler::setHotlink() { case static_cast(ParameterIndex::MAXIMAL_PRESSURE): pullMaximalPressure(); break; - case static_cast(ParameterIndex::CONSTANTE_1): - pullConstante1(); + case static_cast(ParameterIndex::CONSTANT_1): + pullConstant1(); break; - case static_cast(ParameterIndex::CONSTANTE_2): - pullConstante2(); + case static_cast(ParameterIndex::CONSTANT_2): + pullConstant2(); break; case static_cast(ParameterIndex::PRESSURE_CONTROL_MODE): pullPressureControlMode(); @@ -140,19 +140,19 @@ void DemandHandler::pullMaximalPressure() { eventBus.publish(event); } -void DemandHandler::pullConstante1() { +void DemandHandler::pullConstant1() { midas::odb o(this->path); float constante1 = o[DemandHandlerConfig::DEMAND] - [static_cast(ParameterIndex::CONSTANTE_1)]; - Event event = {EventType::CONSTANTE_1, constante1}; + [static_cast(ParameterIndex::CONSTANT_1)]; + Event event = {EventType::CONSTANT_1, constante1}; eventBus.publish(event); } -void DemandHandler::pullConstante2() { +void DemandHandler::pullConstant2() { midas::odb o(this->path); float constance2 = o[DemandHandlerConfig::DEMAND] - [static_cast(ParameterIndex::CONSTANTE_2)]; - Event event = {EventType::CONSTANTE_2, constance2}; + [static_cast(ParameterIndex::CONSTANT_2)]; + Event event = {EventType::CONSTANT_2, constance2}; eventBus.publish(event); } @@ -161,7 +161,8 @@ void DemandHandler::pullPressureControlMode() { float pressureControlMode = o[DemandHandlerConfig::DEMAND] [static_cast(ParameterIndex::PRESSURE_CONTROL_MODE)]; - Event event = {EventType::PRESSURE_CONTROL_MODE, pressureControlMode != 0}; + Event event = {EventType::ENABLE_PRESSURE_CONTROL_MODE, + pressureControlMode != 0}; eventBus.publish(event); } @@ -169,7 +170,7 @@ void DemandHandler::pullSetPressure() { midas::odb o(this->path); float setPressure = o[DemandHandlerConfig::DEMAND] [static_cast(ParameterIndex::SET_PRESSURE)]; - Event event = {EventType::SET_PRESSURE, setPressure != 0}; + Event event = {EventType::ENABLE_SET_PRESSURE, setPressure != 0}; eventBus.publish(event); } diff --git a/src/device/handlers/DemandHandler.h b/src/device/handlers/DemandHandler.h index d9f4f00..0ee62c8 100644 --- a/src/device/handlers/DemandHandler.h +++ b/src/device/handlers/DemandHandler.h @@ -10,10 +10,10 @@ class DemandHandler { enum class EventType { MINIMAL_PRESSURE, MAXIMAL_PRESSURE, - CONSTANTE_1, - CONSTANTE_2, - PRESSURE_CONTROL_MODE, - SET_PRESSURE + CONSTANT_1, + CONSTANT_2, + ENABLE_PRESSURE_CONTROL_MODE, + ENABLE_SET_PRESSURE }; struct Event { @@ -32,8 +32,8 @@ class DemandHandler { */ void pullMinimalPressure(); void pullMaximalPressure(); - void pullConstante1(); - void pullConstante2(); + void pullConstant1(); + void pullConstant2(); void pullPressureControlMode(); void pullSetPressure(); diff --git a/src/device/handlers/DemandHandlerConfig.h b/src/device/handlers/DemandHandlerConfig.h index d08975c..39f24ad 100644 --- a/src/device/handlers/DemandHandlerConfig.h +++ b/src/device/handlers/DemandHandlerConfig.h @@ -14,8 +14,8 @@ enum class ParameterIndex { SET_PRESSURE = 7, MINIMAL_PRESSURE = 8, MAXIMAL_PRESSURE = 9, - CONSTANTE_1 = 10, - CONSTANTE_2 = 11, + CONSTANT_1 = 10, + CONSTANT_2 = 11, MAXIMUM_PARAMETER_INDEX = 11 }; diff --git a/src/device/handlers/FeedbackHandler.cpp b/src/device/handlers/FeedbackHandler.cpp index 1e34df6..2dec504 100644 --- a/src/device/handlers/FeedbackHandler.cpp +++ b/src/device/handlers/FeedbackHandler.cpp @@ -17,10 +17,10 @@ FeedbackHandler::FeedbackHandler(EventBus &eventBusReference, [this](const DemandHandler::Event &e) { generateOdbKeyIfNeeded(); switch (e.type) { - case DemandHandler::EventType::PRESSURE_CONTROL_MODE: + case DemandHandler::EventType::ENABLE_PRESSURE_CONTROL_MODE: enablePressureControlMode(std::get(e.value)); break; - case DemandHandler::EventType::SET_PRESSURE: + case DemandHandler::EventType::ENABLE_SET_PRESSURE: enableSetPressure(std::get(e.value)); break; default: @@ -48,8 +48,8 @@ FeedbackHandler::FeedbackHandler(EventBus &eventBusReference, eventBusReference.subscribe( [this](const PressureCalculator::Event &e) { generateOdbKeyIfNeeded(); - setConstante1(e.c1contrib); - setConstante2(e.c2contrib); + setConstant1(e.c1contrib); + setConstant2(e.c2contrib); setPressureMinimum(e.uncapedPressure); setPressureMaximum(e.uncapedPressure); setPressure(e.cappedPressure); @@ -109,11 +109,10 @@ void FeedbackHandler::setPressure(float value) { updatePressure(); } -void FeedbackHandler::setConstante1(float value) { +void FeedbackHandler::setConstant1(float value) { midas::odb o(path); o[FeedbackHandlerConf::OUTPUT_VARNAME] - [static_cast(FeedbackHandlerConf::RegisterIndex::CONSTANTE_1)] = - value; + [static_cast(FeedbackHandlerConf::RegisterIndex::CONSTANT_1)] = value; } void FeedbackHandler::setAveragePower(float value) { midas::odb o(path); @@ -122,11 +121,10 @@ void FeedbackHandler::setAveragePower(float value) { value; } -void FeedbackHandler::setConstante2(float value) { +void FeedbackHandler::setConstant2(float value) { midas::odb o(path); o[FeedbackHandlerConf::OUTPUT_VARNAME] - [static_cast(FeedbackHandlerConf::RegisterIndex::CONSTANTE_2)] = - value; + [static_cast(FeedbackHandlerConf::RegisterIndex::CONSTANT_2)] = value; } void FeedbackHandler::setPressureMinimum(float value) { diff --git a/src/device/handlers/FeedbackHandler.h b/src/device/handlers/FeedbackHandler.h index c3ef9e8..0e2ff68 100644 --- a/src/device/handlers/FeedbackHandler.h +++ b/src/device/handlers/FeedbackHandler.h @@ -30,8 +30,8 @@ class FeedbackHandler { void setPower(float value); void setAveragePower(float value); void setPressure(float value); - void setConstante1(float value); - void setConstante2(float value); + void setConstant1(float value); + void setConstant2(float value); /* Update pressure value diff --git a/src/device/handlers/FeedbackHandlerConfig.h b/src/device/handlers/FeedbackHandlerConfig.h index 16df396..2ef01b8 100644 --- a/src/device/handlers/FeedbackHandlerConfig.h +++ b/src/device/handlers/FeedbackHandlerConfig.h @@ -19,8 +19,8 @@ enum class RegisterIndex { PRESSURE = 5, MINIMUM_PRESSURE = 8, MAXIMUM_PRESSURE = 9, - CONSTANTE_1 = 10, - CONSTANTE_2 = 11, + CONSTANT_1 = 10, + CONSTANT_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 diff --git a/src/device/handlers/OutputHandler.cpp b/src/device/handlers/OutputHandler.cpp index 4ec7d83..b686361 100644 --- a/src/device/handlers/OutputHandler.cpp +++ b/src/device/handlers/OutputHandler.cpp @@ -58,9 +58,6 @@ void OutputHandler::update() { isIndexValid = true; } - //// SHOULD I CRASH IF KEY NOT VALID ? - //// FOR NOW, FAILED SILENTLY - if (isSetPressureEnable && isKeyValid) o(OutputHandlerConfig::OUTPUT_VARIABLE)[outputPressureSPIndex] = pressure; @@ -71,7 +68,7 @@ OutputHandler::OutputHandler(EventBus &eventBusReference) { eventBusReference.subscribe( [this](const DemandHandler::Event &e) { switch (e.type) { - case DemandHandler::EventType::SET_PRESSURE: + case DemandHandler::EventType::ENABLE_SET_PRESSURE: enableSetPressure(std::get(e.value)); break; default: diff --git a/src/device/handlers/PressureCalculator.cpp b/src/device/handlers/PressureCalculator.cpp index 1dba962..009dfbd 100644 --- a/src/device/handlers/PressureCalculator.cpp +++ b/src/device/handlers/PressureCalculator.cpp @@ -7,15 +7,15 @@ void PressureCalculator::update() { double averagePower = average.getAverage(); - double c2contrib = averagePower * cachedConstante2; + double c2contrib = averagePower * cachedConstant2; double c1contrib = - cachedConstante1 * (cachedTemperature - cachedSP - c2contrib); + cachedConstant1 * (cachedTemperature - cachedSP - c2contrib); double uncapedPressure = cachedMinimalPressure + c1contrib; double cappedPressure = uncapedPressure; if (c2contrib != 0) { - c2contrib = -c2contrib * cachedConstante1; + c2contrib = -c2contrib * cachedConstant1; } else { c2contrib = 0.0f; } @@ -48,11 +48,11 @@ PressureCalculator::PressureCalculator(EventBus &eventBusReference) case DemandHandler::EventType::MAXIMAL_PRESSURE: updateMaximalPressure(std::get(e.value)); break; - case DemandHandler::EventType::CONSTANTE_1: - updateConstante1(std::get(e.value)); + case DemandHandler::EventType::CONSTANT_1: + updateConstant1(std::get(e.value)); break; - case DemandHandler::EventType::CONSTANTE_2: - updateConstante2(std::get(e.value)); + case DemandHandler::EventType::CONSTANT_2: + updateConstant2(std::get(e.value)); break; default: break; @@ -108,12 +108,12 @@ void PressureCalculator::updateMaximalPressure(float value) { update(); } -void PressureCalculator::updateConstante1(float value) { - cachedConstante1 = value; +void PressureCalculator::updateConstant1(float value) { + cachedConstant1 = value; update(); } -void PressureCalculator::updateConstante2(float value) { - cachedConstante2 = value; +void PressureCalculator::updateConstant2(float value) { + cachedConstant2 = value; update(); } diff --git a/src/device/handlers/PressureCalculator.h b/src/device/handlers/PressureCalculator.h index e5a1f15..aa5e547 100644 --- a/src/device/handlers/PressureCalculator.h +++ b/src/device/handlers/PressureCalculator.h @@ -26,8 +26,8 @@ class PressureCalculator { float cachedMinimalPressure; float cachedMaximalPressure; - float cachedConstante1; - float cachedConstante2; + float cachedConstant1; + float cachedConstant2; /* Internal value setters (from InputHandler) @@ -40,8 +40,8 @@ class PressureCalculator { */ void updateMinimalPressure(float value); void updateMaximalPressure(float value); - void updateConstante1(float value); - void updateConstante2(float value); + void updateConstant1(float value); + void updateConstant2(float value); /* Update pressure value From 37589708caa7b5b8c311bb43183c4513ec72dbb8 Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Tue, 28 Jul 2026 11:23:07 +0200 Subject: [PATCH 2/5] maximal typo --- src/device/handlers/DemandHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/device/handlers/DemandHandler.cpp b/src/device/handlers/DemandHandler.cpp index 5267a03..715296e 100644 --- a/src/device/handlers/DemandHandler.cpp +++ b/src/device/handlers/DemandHandler.cpp @@ -43,7 +43,7 @@ bool DemandHandler::init() { static_cast(ParameterIndex::MAXIMAL_PRESSURE)) { TMFE::Instance()->Msg( MERROR, __FUNCTION__, - "maximal pressure index is %i, where array size is %i.", + "Maximal pressure index is %i, where array size is %i.", static_cast(ParameterIndex::MAXIMAL_PRESSURE), o.size()); initSuccess = false; } From a85c4f9c0398663535afaddf3b79e88b488ee302 Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Tue, 28 Jul 2026 11:24:52 +0200 Subject: [PATCH 3/5] uncaped --> uncapped --- src/device/handlers/FeedbackHandler.cpp | 4 ++-- src/device/handlers/PressureCalculator.cpp | 6 +++--- src/device/handlers/PressureCalculator.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/device/handlers/FeedbackHandler.cpp b/src/device/handlers/FeedbackHandler.cpp index 2dec504..9d1db2c 100644 --- a/src/device/handlers/FeedbackHandler.cpp +++ b/src/device/handlers/FeedbackHandler.cpp @@ -50,8 +50,8 @@ FeedbackHandler::FeedbackHandler(EventBus &eventBusReference, generateOdbKeyIfNeeded(); setConstant1(e.c1contrib); setConstant2(e.c2contrib); - setPressureMinimum(e.uncapedPressure); - setPressureMaximum(e.uncapedPressure); + setPressureMinimum(e.uncappedPressure); + setPressureMaximum(e.uncappedPressure); setPressure(e.cappedPressure); setAveragePower(e.averagePower); }); diff --git a/src/device/handlers/PressureCalculator.cpp b/src/device/handlers/PressureCalculator.cpp index 009dfbd..655fc04 100644 --- a/src/device/handlers/PressureCalculator.cpp +++ b/src/device/handlers/PressureCalculator.cpp @@ -10,9 +10,9 @@ void PressureCalculator::update() { double c2contrib = averagePower * cachedConstant2; double c1contrib = cachedConstant1 * (cachedTemperature - cachedSP - c2contrib); - double uncapedPressure = cachedMinimalPressure + c1contrib; + double uncappedPressure = cachedMinimalPressure + c1contrib; - double cappedPressure = uncapedPressure; + double cappedPressure = uncappedPressure; if (c2contrib != 0) { c2contrib = -c2contrib * cachedConstant1; @@ -30,7 +30,7 @@ void PressureCalculator::update() { event.c1contrib = c1contrib; event.c2contrib = c2contrib; - event.uncapedPressure = uncapedPressure; + event.uncappedPressure = uncappedPressure; event.cappedPressure = cappedPressure; event.averagePower = averagePower; diff --git a/src/device/handlers/PressureCalculator.h b/src/device/handlers/PressureCalculator.h index aa5e547..3a4e835 100644 --- a/src/device/handlers/PressureCalculator.h +++ b/src/device/handlers/PressureCalculator.h @@ -11,7 +11,7 @@ class PressureCalculator { struct Event { float c1contrib; float c2contrib; - float uncapedPressure; + float uncappedPressure; float cappedPressure; float averagePower; }; From 4847b9543f5c02ceddc49b2d2a57b8f4fd649255 Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Tue, 28 Jul 2026 11:31:17 +0200 Subject: [PATCH 4/5] cappedPressure : use std::clamp --- src/device/handlers/PressureCalculator.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/device/handlers/PressureCalculator.cpp b/src/device/handlers/PressureCalculator.cpp index 655fc04..58e3d93 100644 --- a/src/device/handlers/PressureCalculator.cpp +++ b/src/device/handlers/PressureCalculator.cpp @@ -3,16 +3,17 @@ #include "Average.h" #include "DemandHandler.h" #include "InputHandler.h" +#include #include void PressureCalculator::update() { - double averagePower = average.getAverage(); - double c2contrib = averagePower * cachedConstant2; - double c1contrib = + float averagePower = average.getAverage(); + float c2contrib = averagePower * cachedConstant2; + float c1contrib = cachedConstant1 * (cachedTemperature - cachedSP - c2contrib); - double uncappedPressure = cachedMinimalPressure + c1contrib; + float uncappedPressure = cachedMinimalPressure + c1contrib; - double cappedPressure = uncappedPressure; + float cappedPressure = uncappedPressure; if (c2contrib != 0) { c2contrib = -c2contrib * cachedConstant1; @@ -20,11 +21,8 @@ void PressureCalculator::update() { c2contrib = 0.0f; } - if (cappedPressure < cachedMinimalPressure) - cappedPressure = cachedMinimalPressure; - - if (cappedPressure > cachedMaximalPressure) - cappedPressure = cachedMaximalPressure; + cappedPressure = std::clamp(uncappedPressure, cachedMinimalPressure, + cachedMaximalPressure); Event event = {}; From 721bbf4d5217d3e13dafaf082c0eea5c297b9ee9 Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Tue, 28 Jul 2026 13:31:14 +0200 Subject: [PATCH 5/5] hiding itcPressureOptimizerScfe target behind a flag --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52be0fe..3da4b68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ target_include_directories( ################################################################################ ## Frontend ################################################################################ +if(${BUILD_FRONTEND}) add_executable(itcPressureOptimizerScfe src/frontend/itc_pressure_optimizer_scfe.cpp @@ -90,4 +91,7 @@ target_link_libraries( install( TARGETS itcPressureOptimizerScfe RUNTIME DESTINATION bin -) \ No newline at end of file +) + +endif() +