From d8bbbf1f43cf8c42a9fac4b60a1199177a259f24 Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Mon, 15 Jun 2026 16:35:28 +0200 Subject: [PATCH] renaming --- src/utils/outlet.cpp | 48 +++++++++++++++++++++++++++----------------- src/utils/outlet.h | 2 +- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/utils/outlet.cpp b/src/utils/outlet.cpp index 85e5c2a..fc912de 100644 --- a/src/utils/outlet.cpp +++ b/src/utils/outlet.cpp @@ -27,7 +27,7 @@ std::string Outlet::readSetRecord() { return this->stateToString(command); } -bool Outlet::commandHasChange() { +bool Outlet::hasGetRecordChanged() { return this->lastCommand != this->_getCommand(); } @@ -71,23 +71,8 @@ void Outlet::restart() { } void Outlet::updateState() { - bool outputConnected = this->output.connected(); - bool inputConnected = this->input.connected(); - - if (!outputConnected && this->isOutputConnected) { - TMFE::Instance()->Msg(MERROR, __FUNCTION__, - "Outlet %d : Output channel disconnected", - this->index); - } - - if (!inputConnected && this->isInputConnected) { - TMFE::Instance()->Msg(MERROR, __FUNCTION__, - "Outlet %d : Input channel disconnected", - this->index); - } - - this->isOutputConnected = outputConnected; - this->isInputConnected = inputConnected; + bool outputConnected = this->isOutputConnected(); + bool inputConnected = this->isInputConnected(); if (!outputConnected || !inputConnected) { // Error message are above @@ -189,6 +174,8 @@ std::string Outlet::stateToString(State state) { } Outlet::State Outlet::_getCommand() { + if (this->isInputConnected()) + return stringToState(this->lastCommand); std::string value; int returnCode = this->output.get(&value); if (returnCode != CM_SUCCESS) @@ -198,3 +185,28 @@ Outlet::State Outlet::_getCommand() { this->index, returnCode); return stringToState(value); } + +bool Outlet::isOutputConnected() { + bool outputConnected = this->output.connected(); + + if (!outputConnected && this->isOutputConnected) { + TMFE::Instance()->Msg(MERROR, __FUNCTION__, + "Outlet %d : Output channel disconnected", + this->index); + } + + this->isOutputConnected = outputConnected; + return outputConnected; +} + +bool Outlet::isInputConnected() { + bool inputConnected = this->input.connected(); + + if (!inputConnected && this->isInputConnected) { + TMFE::Instance()->Msg(MERROR, __FUNCTION__, + "Outlet %d : Input channel disconnected", + this->index); + } + + this->isInputConnected = inputConnected; +} diff --git a/src/utils/outlet.h b/src/utils/outlet.h index 7041358..0080222 100644 --- a/src/utils/outlet.h +++ b/src/utils/outlet.h @@ -25,7 +25,7 @@ class Outlet { * @brief return true if the last value readed from this object if not equal * to the current device state */ - bool commandHasChange(); + bool hasGetRecordChanged(); /** * @brief set to a new state the device */