From 2c047e25d3e30a9c25d6c67e019aa07f6bc48057 Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Thu, 11 Jun 2026 11:37:57 +0200 Subject: [PATCH] code review --- src/utils/outlet.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/utils/outlet.cpp b/src/utils/outlet.cpp index 953cb7c..70573d5 100644 --- a/src/utils/outlet.cpp +++ b/src/utils/outlet.cpp @@ -9,7 +9,7 @@ Outlet::Outlet(int index, std::string inputRecordName, : input(mEpicsCa(inputRecordName)), output(mEpicsCa(outputRecordName)) { this->index = index; - this->innerState = State::UNKNOW; + this->innerState = State::UNKNOWN; this->isOutputConnected = true; this->isInputConnected = true; @@ -32,7 +32,7 @@ bool Outlet::commandHasChange() { } void Outlet::setState(State state) { - this->buffered = state; + this->bufferedcommand = state; this->updateState(); } @@ -97,7 +97,7 @@ void Outlet::updateState() { // Adding a grace period to prevent reseting at start if (this->gracePeriod > 0) { this->gracePeriod--; - buffered.reset(); + bufferedcommand.reset(); } std::string value; @@ -112,8 +112,8 @@ void Outlet::updateState() { this->innerState = stringToState(value); - if (buffered.has_value()) { - State state = buffered.value(); + if (bufferedcommand.has_value()) { + State state = bufferedcommand.value(); switch (this->innerState) { case State::ON: @@ -121,36 +121,35 @@ void Outlet::updateState() { this->turnOff(); if (state == State::RST) this->restart(); - buffered.reset(); + bufferedcommand.reset(); break; case State::OFF: if (state == State::ON) this->turnOn(); if (state == State::RST) this->restart(); - buffered.reset(); + bufferedcommand.reset(); break; case State::RST: - TMFE::Instance()->Msg(MERROR, __FUNCTION__, - "Outlet %d in restarting state, command " - "pending in a buffered state", - this->index); + // Do nothing break; - case State::UNKNOW: + case State::UNKNOWN: TMFE::Instance()->Msg(MINFO, __FUNCTION__, - "Outlet %d : Unknow state", this->index); + "Outlet %d : Unknown state, sending command " + "and continuing as normal", + this->index); if (state == State::ON) this->turnOn(); if (state == State::OFF) this->turnOff(); if (state == State::RST) this->restart(); - buffered.reset(); + bufferedcommand.reset(); break; default: // This state doesn't exist TMFE::Instance()->Msg(MERROR, __FUNCTION__, - "Outlet %d : FATAL ERROR : unvalide state", + "Outlet %d : new state left unmapped", this->index); exit(EXIT_FAILURE); break; @@ -169,7 +168,7 @@ Outlet::State Outlet::stringToState(std::string value) { value == "RESTART" || value == "Restart") { return State::RST; } - return State::UNKNOW; + return State::UNKNOWN; } std::string Outlet::stateToString(State state) { @@ -184,7 +183,7 @@ std::string Outlet::stateToString(State state) { return std::string("Restart"); break; default: - return std::string("Unknow"); + return std::string("UNKNOWN"); break; }; }