mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-08-03 08:48:13 +02:00
check if detector already set up
This commit is contained in:
@@ -481,14 +481,19 @@ ProcessedResult DetectorServer<DerivedDetectorServer>::initial_checks(
|
||||
ServerInterface &socket) const {
|
||||
auto detectorsetupstatus = getDerivedImpl()->initial_checks();
|
||||
|
||||
const bool setup_successful = detectorsetupstatus.successful_setup;
|
||||
|
||||
if (!setup_successful) {
|
||||
// TODO: should there be a time limit?
|
||||
while (detectorsetupstatus.setup_status ==
|
||||
detector_setup_status::NOT_SETUP) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
detectorsetupstatus = getDerivedImpl()->initial_checks();
|
||||
}
|
||||
if (detectorsetupstatus.setup_status ==
|
||||
detector_setup_status::FAILED_SETUP) {
|
||||
return return_fail("Initial checks failed: " +
|
||||
detectorsetupstatus.error_message);
|
||||
} else {
|
||||
return ProcessedResult{
|
||||
static_cast<ReturnCode>(socket.sendResult(setup_successful))};
|
||||
static_cast<ReturnCode>(socket.sendResult(true))};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,15 @@ struct UDPInfo {
|
||||
|
||||
/// @brief struct to store detector setup status
|
||||
struct detector_setup_status {
|
||||
|
||||
enum SETUP_STATUS : uint8_t {
|
||||
FAILED_SETUP = 0,
|
||||
SUCCESSFUL_SETUP = 1,
|
||||
NOT_SETUP = 2
|
||||
};
|
||||
|
||||
/// @brief true if setupDetector() was successful, false otherwise
|
||||
bool successful_setup{false};
|
||||
SETUP_STATUS setup_status{NOT_SETUP};
|
||||
/// @brief error message if setupDetector() failed, empty otherwise
|
||||
std::string error_message{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user