generated python enums, moved ReturnCode to slsDetectorDefs class (#1467)
Build on RHEL9 docker image / build (push) Successful in 3m43s
Build on RHEL8 docker image / build (push) Successful in 5m24s
Build and Deploy on local RHEL9 / build (push) Successful in 2m0s
Build and Deploy on local RHEL8 / build (push) Successful in 5m2s
Run Simulator Tests on local RHEL9 / build (push) Successful in 18m17s
Run Simulator Tests on local RHEL8 / build (push) Successful in 21m53s

This commit is contained in:
2026-05-27 10:36:16 +02:00
committed by GitHub
parent 53d966d23b
commit 4c02ce65cc
5 changed files with 29 additions and 16 deletions
+12
View File
@@ -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_<slsDetectorDefs::ReturnCode>(Defs, "ReturnCode")
.value("OK", slsDetectorDefs::ReturnCode::OK)
.value("FAIL", slsDetectorDefs::ReturnCode::FAIL)
.export_values();
py::enum_<slsDetectorDefs::boolFormat>(Defs, "boolFormat")
@@ -50,6 +56,12 @@ void init_enums(py::module &m) {
.value("Y", slsDetectorDefs::dimension::Y)
.export_values();
py::enum_<slsDetectorDefs::FrequencyUnit>(Defs, "FrequencyUnit")
.value("Hz", slsDetectorDefs::FrequencyUnit::Hz)
.value("kHz", slsDetectorDefs::FrequencyUnit::kHz)
.value("MHz", slsDetectorDefs::FrequencyUnit::MHz)
.export_values();
py::enum_<slsDetectorDefs::frameDiscardPolicy>(Defs, "frameDiscardPolicy")
.value("NO_DISCARD", slsDetectorDefs::frameDiscardPolicy::NO_DISCARD)
.value("DISCARD_EMPTY_FRAMES",
@@ -25,6 +25,8 @@ struct UDPInfo {
uint32_t dstip{};
};
using ReturnCode = slsDetectorDefs::ReturnCode;
template <typename DerivedDetectorServer> class DetectorServer {
public:
@@ -19,8 +19,8 @@ class TCPInterface {
public:
~TCPInterface();
TCPInterface(std::function<ReturnCode(const detFuncs &, ServerInterface &)>
&processFunction_,
TCPInterface(std::function<slsDetectorDefs::ReturnCode(
const detFuncs &, ServerInterface &)> &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<ReturnCode(const detFuncs &, ServerInterface &)>
std::function<slsDetectorDefs::ReturnCode(const detFuncs &,
ServerInterface &)>
processFunction;
/// @brief TCP/IP port number for the detector server
@@ -8,8 +8,8 @@
namespace sls {
TCPInterface::TCPInterface(
std::function<ReturnCode(const detFuncs &, ServerInterface &)>
&processFunction_,
std::function<slsDetectorDefs::ReturnCode(
const detFuncs &, ServerInterface &)> &processFunction_,
const uint16_t portNumber_)
: processFunction(processFunction_), portNumber(portNumber_),
server(portNumber_) {
@@ -53,7 +53,7 @@ void TCPInterface::startTCPServerClientConnection() {
auto returncode = processReceivedData(
static_cast<detFuncs>(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)
@@ -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 };