diff --git a/.gitignore b/.gitignore index f30446f..78fb2cb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ CMakeFiles Makefile cmake_install.cmake midas.log +ePowerSwitchFront \ No newline at end of file diff --git a/src/ePowerSwitchFront.cpp b/src/ePowerSwitchFront.cpp index ed5e53d..b13cf7f 100644 --- a/src/ePowerSwitchFront.cpp +++ b/src/ePowerSwitchFront.cpp @@ -1,5 +1,5 @@ -#include "ePowerSwitchFront.h" -#include "ePowerSwitchConfig.h" +#include "../include/ePowerSwitchFront.h" +#include "../include/ePowerSwitchConfig.h" #include "m_epics_ca.h" #include "tmfe.h" #include @@ -19,29 +19,36 @@ std::string format(std::string str, int value) { } 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"); + } + std::string frontendName = "ePowerSwitch"; std::string equipmentName = "powerswitch"; - if (argc == 1) { + if (argc == 2) { frontendName = std::string(argv[1]); argv++; argc--; - } else if (argc == 2) { + } else if (argc == 3) { frontendName = std::string(argv[1]); equipmentName = std::string(argv[2]); argv += 2; argc -= 2; } - auto front = new ePowerSwitchFrontend(frontendName.c_str()); + auto front = new ePowerSwitchFrontend(frontendName, equipmentName); front->FeMain(argc, argv); } ePowerSwitchEquipment::ePowerSwitchEquipment(std::string equipmentName, const char *equipmentFileName) - : TMFeEquipment(equipmentName, equipmentFileName), - outletNumberRecord( - mEpicsCa(EPOWERSWITCH_SOCKETNUMBER_INFO_PREFIX, true)) { + : TMFeEquipment(equipmentName.c_str(), equipmentFileName), + outletNumberRecord(mEpicsCa( + std::string_view(EPOWERSWITCH_SOCKETNUMBER_INFO_PREFIX), true)) { fEqConfReadConfigFromOdb = false; fEqConfPeriodMilliSec = 1000; fEqConfLogHistory = 1; @@ -113,6 +120,6 @@ void ePowerSwitchEquipment::updateSocketNumber() { ePowerSwitchFrontend::ePowerSwitchFrontend(std::string frontendName, std::string equipmentName) { - FeSetName(frontname.c_str()); + FeSetName(frontendName.c_str()); FeAddEquipment(new ePowerSwitchEquipment(equipmentName.c_str(), __FILE__)); } \ No newline at end of file