From 4f60fddd64be897a5bd5af2b9e1b014b915529cf Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Thu, 23 Jul 2026 16:48:21 +0200 Subject: [PATCH] OutputHandler cleaned --- src/device/handlers/InputHandler.cpp | 2 ++ src/device/handlers/OutputHandler.cpp | 28 +++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/device/handlers/InputHandler.cpp b/src/device/handlers/InputHandler.cpp index f239e73..8799a4c 100644 --- a/src/device/handlers/InputHandler.cpp +++ b/src/device/handlers/InputHandler.cpp @@ -68,12 +68,14 @@ void InputHandler::pullSPValue() { Event event = {EventType::SP_VALUE, SPValue}; eventBus.publish(event); } + void InputHandler::pullTemperatureValue() { midas::odb o(this->path); float temperatureValue = o[temperatureIndex]; Event event = {EventType::TEMPERATURE_VALUE, temperatureValue}; eventBus.publish(event); } + void InputHandler::pullPowerValue() { midas::odb o(this->path); float powerValue = o[powerIndex]; diff --git a/src/device/handlers/OutputHandler.cpp b/src/device/handlers/OutputHandler.cpp index e99f197..e27d60a 100644 --- a/src/device/handlers/OutputHandler.cpp +++ b/src/device/handlers/OutputHandler.cpp @@ -3,6 +3,7 @@ #include "OutputHandlerConfig.h" #include "PressureCalculator.h" #include "SettingsHandler.h" +#include "tmfe.h" #include void OutputHandler::enableSetPressure(bool enable) { @@ -27,13 +28,28 @@ void OutputHandler::setEquipmentPath(std::string equipmentName) { } void OutputHandler::update() { - if (isSetPressureEnable) { - midas::odb o(equipmentPath); - if (o.exists(OutputHandlerConfig::OUTPUT_VARIABLE)) { - o(OutputHandlerConfig::OUTPUT_VARIABLE)[outputPressureSPIndex] = - pressure; - } + bool isKeyValid = true; + midas::odb o(equipmentPath); + + if (o.exists(OutputHandlerConfig::OUTPUT_VARIABLE)) { + TMFE::Instance()->Msg(MERROR, __FUNCTION__, "Key at %s doesn't exists", + equipmentPath.c_str()); + isKeyValid = false; } + + if (o.size() < outputPressureSPIndex) { + TMFE::Instance()->Msg(MERROR, __FUNCTION__, + "SP index is %i, where array size is %i.", + outputPressureSPIndex, o.size()); + isKeyValid = false; + } + + //// SHOULD I CRASH IF KEY NOT VALID ? + //// FOR NOW, FAILED SILENTLY + + if (isSetPressureEnable && isKeyValid) + o(OutputHandlerConfig::OUTPUT_VARIABLE)[outputPressureSPIndex] = + pressure; } OutputHandler::OutputHandler(EventBus &eventBusReference) {