Files
slsDetectorPackage/slsDetectorServers/slsDetectorServer_cpp/include/TCPInterface.h
T
mazzol_a 4c02ce65cc
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
generated python enums, moved ReturnCode to slsDetectorDefs class (#1467)
2026-05-27 10:36:16 +02:00

61 lines
1.7 KiB
C++

#pragma once
#include "sls/ServerSocket.h"
#include "sls/sls_detector_defs.h"
#include "sls/sls_detector_funcs.h"
#include <atomic>
#include <functional>
#include <thread>
#include <unordered_map>
namespace sls {
/**
* @brief TCPInterface class handles communication and processing of commands
* from Client to Server.
*/
class TCPInterface {
public:
~TCPInterface();
TCPInterface(std::function<slsDetectorDefs::ReturnCode(
const detFuncs &, ServerInterface &)> &processFunction_,
const uint16_t portNumber = DEFAULT_TCP_CNTRL_PORTNO);
/// @brief creates tcp thread
void startTCPServer();
std::atomic<bool> killTcpThread{false};
private:
/**
* @brief starts the TCP/IP server to listen for client commands and process
* them
*/
void startTCPServerClientConnection();
/**
* @brief decodes the received command and calls the corresponding function
* @param function_id The ID of the function recived by the server and to
* be executed
*/
slsDetectorDefs::ReturnCode processReceivedData(const detFuncs function_id,
ServerInterface &socket);
/// @brief map of function IDs and corresponding functions
std::function<slsDetectorDefs::ReturnCode(const detFuncs &,
ServerInterface &)>
processFunction;
/// @brief TCP/IP port number for the detector server
uint16_t portNumber{};
/// @brief socket for TCP/IP communication with the client
ServerSocket server;
/// @brief thread for running the TCP/IP server
std::unique_ptr<std::thread> tcpThread;
};
} // namespace sls