diff --git a/python/src/enums.cpp b/python/src/enums.cpp index f00b8105a..d391fe0f2 100644 --- a/python/src/enums.cpp +++ b/python/src/enums.cpp @@ -27,6 +27,12 @@ void init_enums(py::module &m) { .value("GOTTHARD2", slsDetectorDefs::detectorType::GOTTHARD2) .value("XILINX_CHIPTESTBOARD", slsDetectorDefs::detectorType::XILINX_CHIPTESTBOARD) + .value("MATTERHORN", slsDetectorDefs::detectorType::MATTERHORN) + .export_values(); + + py::enum_(Defs, "ReturnCode") + .value("OK", slsDetectorDefs::ReturnCode::OK) + .value("FAIL", slsDetectorDefs::ReturnCode::FAIL) .export_values(); py::enum_(Defs, "boolFormat") @@ -50,6 +56,12 @@ void init_enums(py::module &m) { .value("Y", slsDetectorDefs::dimension::Y) .export_values(); + py::enum_(Defs, "FrequencyUnit") + .value("Hz", slsDetectorDefs::FrequencyUnit::Hz) + .value("kHz", slsDetectorDefs::FrequencyUnit::kHz) + .value("MHz", slsDetectorDefs::FrequencyUnit::MHz) + .export_values(); + py::enum_(Defs, "frameDiscardPolicy") .value("NO_DISCARD", slsDetectorDefs::frameDiscardPolicy::NO_DISCARD) .value("DISCARD_EMPTY_FRAMES", diff --git a/slsDetectorServers/slsDetectorServer_cpp/include/DetectorServer.h b/slsDetectorServers/slsDetectorServer_cpp/include/DetectorServer.h index 7f1a6eb89..6773f17ba 100644 --- a/slsDetectorServers/slsDetectorServer_cpp/include/DetectorServer.h +++ b/slsDetectorServers/slsDetectorServer_cpp/include/DetectorServer.h @@ -25,6 +25,8 @@ struct UDPInfo { uint32_t dstip{}; }; +using ReturnCode = slsDetectorDefs::ReturnCode; + template class DetectorServer { public: diff --git a/slsDetectorServers/slsDetectorServer_cpp/include/TCPInterface.h b/slsDetectorServers/slsDetectorServer_cpp/include/TCPInterface.h index 9538a3e42..6d3ea2c29 100644 --- a/slsDetectorServers/slsDetectorServer_cpp/include/TCPInterface.h +++ b/slsDetectorServers/slsDetectorServer_cpp/include/TCPInterface.h @@ -19,8 +19,8 @@ class TCPInterface { public: ~TCPInterface(); - TCPInterface(std::function - &processFunction_, + TCPInterface(std::function &processFunction_, const uint16_t portNumber = DEFAULT_TCP_CNTRL_PORTNO); /// @brief creates tcp thread @@ -40,11 +40,12 @@ class TCPInterface { * @param function_id The ID of the function recived by the server and to * be executed */ - ReturnCode processReceivedData(const detFuncs function_id, - ServerInterface &socket); + slsDetectorDefs::ReturnCode processReceivedData(const detFuncs function_id, + ServerInterface &socket); /// @brief map of function IDs and corresponding functions - std::function + std::function processFunction; /// @brief TCP/IP port number for the detector server diff --git a/slsDetectorServers/slsDetectorServer_cpp/src/TCPInterface.cpp b/slsDetectorServers/slsDetectorServer_cpp/src/TCPInterface.cpp index 9d2d7911e..ea54d2f5a 100644 --- a/slsDetectorServers/slsDetectorServer_cpp/src/TCPInterface.cpp +++ b/slsDetectorServers/slsDetectorServer_cpp/src/TCPInterface.cpp @@ -8,8 +8,8 @@ namespace sls { TCPInterface::TCPInterface( - std::function - &processFunction_, + std::function &processFunction_, const uint16_t portNumber_) : processFunction(processFunction_), portNumber(portNumber_), server(portNumber_) { @@ -53,7 +53,7 @@ void TCPInterface::startTCPServerClientConnection() { auto returncode = processReceivedData( static_cast(function_id), socket); - if (returncode == FAIL) { + if (returncode == slsDetectorDefs::ReturnCode::FAIL) { throw RuntimeError(fmt::format( "Error processing command with fnum: {}", getFunctionNameFromEnum((enum detFuncs)function_id))); @@ -76,14 +76,16 @@ void TCPInterface::startTCPServerClientConnection() { LOG(logINFOBLUE) << "Exiting TCP Server"; } -ReturnCode TCPInterface::processReceivedData(const detFuncs function_id, - ServerInterface &socket) { +slsDetectorDefs::ReturnCode +TCPInterface::processReceivedData(const detFuncs function_id, + ServerInterface &socket) { LOG(logDEBUG1) << "calling function fnum: " << function_id << " (" << getFunctionNameFromEnum((enum detFuncs)function_id) << ")"; - ReturnCode returncode = processFunction(function_id, socket); + slsDetectorDefs::ReturnCode returncode = + processFunction(function_id, socket); LOG(logDEBUG1) << "Function " << getFunctionNameFromEnum((enum detFuncs)function_id) diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 283eb2f5e..9e996f891 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -89,9 +89,6 @@ // NOLINTEND(cppcoreguidelines-macro-usage) #ifdef __cplusplus -// TODO: why are all these defs inside a class? - why not static -enum ReturnCode { OK = 0, FAIL = 1 }; - class slsDetectorDefs { public: #endif @@ -111,8 +108,7 @@ class slsDetectorDefs { // slsDetectorDefs instead of grouped in a class }; - /** return values */ - enum { OK, FAIL }; + enum ReturnCode { OK, FAIL }; enum boolFormat { TrueFalse, OnOff, OneZero };