mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-08-03 05:58:11 +02:00
implement initial checks
This commit is contained in:
@@ -85,9 +85,16 @@ BaseMatterhornServerImpl<
|
||||
template <typename DerivedMatterhornServerImpl>
|
||||
void BaseMatterhornServerImpl<DerivedMatterhornServerImpl>::setupDetector() {
|
||||
// TODO: extend
|
||||
set_num_frames(1); // maybe have a file with constexpr default values
|
||||
try {
|
||||
set_num_frames(1);
|
||||
set_num_triggers(1);
|
||||
} catch (const std::exception &e) {
|
||||
LOG(logERROR) << "Failed to setup detector: " << e.what();
|
||||
detectorSetupStatus.error_message = std::string(e.what());
|
||||
detectorSetupStatus.successful_setup = false;
|
||||
}
|
||||
|
||||
set_num_triggers(1);
|
||||
detectorSetupStatus.successful_setup = true;
|
||||
}
|
||||
|
||||
template <typename DerivedMatterhornServerImpl>
|
||||
|
||||
@@ -7,13 +7,6 @@ slsDetectorDefs::runStatus MatterhornServerImpl::get_run_status() const {
|
||||
return slsDetectorDefs::runStatus::IDLE; // TODO: implement
|
||||
}
|
||||
|
||||
bool MatterhornServerImpl::initial_checks() const {
|
||||
// TODO: add more checks here, for now just return true to be able to test
|
||||
// the should check firmware -client compatibility
|
||||
bool initial_checks_passed = true;
|
||||
return initial_checks_passed;
|
||||
}
|
||||
|
||||
void MatterhornServerImpl::set_module_position_and_update_srcudpmac(
|
||||
const std::array<int, 2> &position_info) {
|
||||
|
||||
|
||||
@@ -12,11 +12,6 @@ class MatterhornServerImpl
|
||||
|
||||
slsDetectorDefs::runStatus get_run_status() const; // TODO: impement
|
||||
|
||||
/// @brief return true if initial checks pass, false otherwise
|
||||
bool
|
||||
initial_checks() const; // TODO: Is it the same as for virtual server?
|
||||
// If yes, can be moved to base class implementation
|
||||
|
||||
void set_module_position_and_update_srcudpmac(
|
||||
const std::array<int, 2> &position_info);
|
||||
|
||||
|
||||
@@ -25,14 +25,6 @@ slsDetectorDefs::runStatus VirtualMatterhornServerImpl::get_run_status() const {
|
||||
return status;
|
||||
}
|
||||
|
||||
bool VirtualMatterhornServerImpl::initial_checks() const {
|
||||
|
||||
// TODO: add more checks here, for now just return true to be able to test
|
||||
// the should check firmware -client compatibility
|
||||
bool initial_checks_passed = true;
|
||||
return initial_checks_passed;
|
||||
}
|
||||
|
||||
void VirtualMatterhornServerImpl::set_module_position_and_update_srcudpmac(
|
||||
const std::array<int, 2> &position_info) {
|
||||
|
||||
|
||||
@@ -12,9 +12,6 @@ class VirtualMatterhornServerImpl
|
||||
|
||||
slsDetectorDefs::runStatus get_run_status() const;
|
||||
|
||||
/// @brief return true if initial checks pass, false otherwise
|
||||
bool initial_checks() const;
|
||||
|
||||
void set_module_position_and_update_srcudpmac(
|
||||
const std::array<int, 2> &position_info);
|
||||
|
||||
|
||||
@@ -479,10 +479,17 @@ ProcessedResult DetectorServer<DerivedDetectorServer>::get_run_status(
|
||||
template <typename DerivedDetectorServer>
|
||||
ProcessedResult DetectorServer<DerivedDetectorServer>::initial_checks(
|
||||
ServerInterface &socket) const {
|
||||
bool initial_checks_passed = getDerivedImpl()->initial_checks();
|
||||
auto detectorsetupstatus = getDerivedImpl()->initial_checks();
|
||||
|
||||
return ProcessedResult{
|
||||
static_cast<ReturnCode>(socket.sendResult(initial_checks_passed))};
|
||||
const bool setup_successful = detectorsetupstatus.successful_setup;
|
||||
|
||||
if (!setup_successful) {
|
||||
return return_fail("Initial checks failed: " +
|
||||
detectorsetupstatus.error_message);
|
||||
} else {
|
||||
return ProcessedResult{
|
||||
static_cast<ReturnCode>(socket.sendResult(setup_successful))};
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DerivedDetectorServer>
|
||||
|
||||
@@ -16,6 +16,14 @@ struct UDPInfo {
|
||||
uint32_t dstip{};
|
||||
};
|
||||
|
||||
/// @brief struct to store detector setup status
|
||||
struct detector_setup_status {
|
||||
/// @brief true if setupDetector() was successful, false otherwise
|
||||
bool successful_setup{false};
|
||||
/// @brief error message if setupDetector() failed, empty otherwise
|
||||
std::string error_message{};
|
||||
};
|
||||
|
||||
/// @brief Shared memory structure for stop server to store run status
|
||||
struct acquisitionStatus {
|
||||
|
||||
@@ -61,6 +69,8 @@ class DetectorServerImpl {
|
||||
|
||||
uint16_t get_destination_udp_port() const;
|
||||
|
||||
detector_setup_status initial_checks() const;
|
||||
|
||||
protected:
|
||||
std::array<UDPInfo, 1>
|
||||
udpDetails{}; // TODO: for now only one receiver per module
|
||||
@@ -78,6 +88,9 @@ class DetectorServerImpl {
|
||||
/// @param srcmac
|
||||
void updateSrcMacAddress(const uint64_t srcmac);
|
||||
|
||||
/// @brief true if setupDetector() was successful, false otherwise
|
||||
detector_setup_status detectorSetupStatus{};
|
||||
|
||||
private:
|
||||
/// @brief creates and maps shared memory
|
||||
void createSharedMemory();
|
||||
|
||||
@@ -77,4 +77,8 @@ uint16_t DetectorServerImpl::get_destination_udp_port() const {
|
||||
return udpDetails[0].dstport;
|
||||
}
|
||||
|
||||
detector_setup_status DetectorServerImpl::initial_checks() const {
|
||||
return detectorSetupStatus;
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
Reference in New Issue
Block a user