From 96e75fe16b75a8b0c635c31ad9261a365fe17ecd Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Fri, 1 May 2026 14:48:10 +0200 Subject: [PATCH] removing redundancy error message, and exiting if we are disconnected from midas --- src/device/ePowerSwitchEquipment.cpp | 37 ++++++++-------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/device/ePowerSwitchEquipment.cpp b/src/device/ePowerSwitchEquipment.cpp index 0f3b7d6..02c5efa 100644 --- a/src/device/ePowerSwitchEquipment.cpp +++ b/src/device/ePowerSwitchEquipment.cpp @@ -64,7 +64,6 @@ void ePowerSwitchEquipment::refreshOutlet(int outletId) { } std::string midasRequestedOutletState = std::string("Off"); MVOdbError ovbError; - int mepicscaReturnCode; fOdbEqVariables->RS(usernameVarname.c_str(), &midasUsername, true, midasUsername.length() + 1, &ovbError); if (ovbError.fError) { @@ -91,28 +90,18 @@ void ePowerSwitchEquipment::refreshOutlet(int outletId) { } std::string epicsCurrentOutletState; - mepicscaReturnCode = + int mepicscaReturnCode = this->outletGetRecords.at(outletId)->get(&epicsCurrentOutletState); - if (mepicscaReturnCode != CM_SUCCESS) { - fMfe->Msg(MERROR, __FUNCTION__, - "Couldn't get the value, skipping refreshing outlet %d. " - "Error code %d", - outletId, mepicscaReturnCode); + if (mepicscaReturnCode != CM_SUCCESS) return; - } if (epicsCurrentOutletState != midasRequestedOutletState) { mepicscaReturnCode = this->outletSetRecords.at(outletId)->put( &midasRequestedOutletState); - if (mepicscaReturnCode != CM_SUCCESS) { - fMfe->Msg(MERROR, __FUNCTION__, - "Couldn't put the value, skipping refreshing outlet %d. " - "Error code %d", - outletId, mepicscaReturnCode); + if (mepicscaReturnCode != CM_SUCCESS) return; - } } fOdbEqVariables->WS(currentVarname.c_str(), epicsCurrentOutletState.c_str(), @@ -133,20 +122,10 @@ void ePowerSwitchEquipment::refreshAllOutlets() { void ePowerSwitchEquipment::updateOutletNumber() { int epicsOutletNumber = 0; - if (!outletNumberRecord.connected()) { - fMfe->Msg(MERROR, __FUNCTION__, - "Couldn't connect to outlet number record."); - return; - } int returnCode = outletNumberRecord.get(&epicsOutletNumber); - if (returnCode < 0) { - fMfe->Msg(MERROR, __FUNCTION__, - "Couldn't get outlet number record. [ERROR_CODE : %d]\n " - "Skipping function execution", - returnCode); + if (returnCode != CM_SUCCESS) return; - } if (this->numberOfOutlet < epicsOutletNumber) fMfe->Msg(MDEBUG, __FUNCTION__, @@ -204,12 +183,16 @@ void ePowerSwitchEquipment::updateOutletNumber() { MVOdbError ovbError; fOdbEqVariables->Delete(requestedVarname.c_str(), &ovbError); - if (ovbError.fError) + if (ovbError.fError) { fMfe->Msg(MERROR, __FUNCTION__, ovbError.fErrorString); + exit(EXIT_FAILURE); + } fOdbEqVariables->Delete(currentVarname.c_str(), &ovbError); - if (ovbError.fError) + if (ovbError.fError) { fMfe->Msg(MERROR, __FUNCTION__, ovbError.fErrorString); + exit(EXIT_FAILURE); + } this->outletSetRecords.pop_back(); this->outletGetRecords.pop_back();