From 0363611d0acde217a72d3769a868d92bc6e71d25 Mon Sep 17 00:00:00 2001 From: Hugo Jean Ponsin Date: Tue, 28 Apr 2026 13:11:00 +0200 Subject: [PATCH] removing hardcoded values --- include/ePowerSwitchConfig.h | 3 +++ src/ePowerSwitchFront.cpp | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/ePowerSwitchConfig.h b/include/ePowerSwitchConfig.h index 509f590..3e1dea1 100644 --- a/include/ePowerSwitchConfig.h +++ b/include/ePowerSwitchConfig.h @@ -4,4 +4,7 @@ #define EPOWERSWITCH_SOCKET_COMMAND_PREFIX "ePowerSwitch_command_outlet_" #define EPOWERSWITCH_SOCKETNUMBER_INFO_PREFIX "ePowerSwitch_config_maxOutlet" +#define DEFAULT_FRONTEND_NAME "ePowerSwitch" +#define DEFAULT_EQUIPMENT_NAME "powerswitch" + #endif diff --git a/src/ePowerSwitchFront.cpp b/src/ePowerSwitchFront.cpp index b13cf7f..b6caf04 100644 --- a/src/ePowerSwitchFront.cpp +++ b/src/ePowerSwitchFront.cpp @@ -6,8 +6,8 @@ #include /** - * @brief local function, append an integer at the end of a string - * @param str string prfix + * @brief local function: append an integer to the end of a string. + * @param str string prefix * @param value integer to append * @return "str" + integer */ @@ -22,17 +22,30 @@ int main(int argc, char *argv[]) { if (argv[0][0] == '.') { TMFE::Instance()->Msg(MERROR, __FUNCTION__, - "Relative path are strongly not recommended, " - "please use an absolut path"); + "Relative paths are strongly not recommended; " + "please use an absolute path"); } - std::string frontendName = "ePowerSwitch"; - std::string equipmentName = "powerswitch"; + std::string frontendName; + std::string equipmentName; + if (argc == 1) { + frontendName = DEFAULT_FRONTEND_NAME; + TMFE::Instance()->Msg(MINFO, __FUNCTION__, + "no frontend name provided; %s will be used", + DEFAULT_FRONTEND_NAME); + equipmentName = DEFAULT_EQUIPMENT_NAME; + TMFE::Instance()->Msg(MINFO, __FUNCTION__, + "no equipment name provided; %s will be used", + DEFAULT_EQUIPMENT_NAME); + } if (argc == 2) { frontendName = std::string(argv[1]); argv++; argc--; + TMFE::Instance()->Msg(MINFO, __FUNCTION__, + "no equipment name provided; %s will be use", + DEFAULT_EQUIPMENT_NAME); } else if (argc == 3) { frontendName = std::string(argv[1]); equipmentName = std::string(argv[2]); @@ -71,7 +84,6 @@ void ePowerSwitchEquipment::refreshSocket(int socketId) { if (midasSocketState != this->outletLastState.at(socketId)) { this->outletCommandRecords.at(socketId)->put(&midasSocketState); - printf("send command : %d\n", midasSocketState); } this->outletLastState.at(socketId) = midasSocketState;