diff --git a/detector_control/DectrisSimplonClient.cpp b/detector_control/DectrisSimplonClient.cpp index 8a9367f3..efc8d2b9 100644 --- a/detector_control/DectrisSimplonClient.cpp +++ b/detector_control/DectrisSimplonClient.cpp @@ -91,6 +91,12 @@ void DectrisSimplonClient::SetConfigIfDifferent(SimplonModule element, const std SetConfig(element, key, value); } +void DectrisSimplonClient::SetConfigIfDifferent(SimplonModule element, const std::string &key, int64_t value) { + auto curr_val = GetConfig(element, key).val.get(); + if (curr_val != value) + SetConfig(element, key, value); +} + std::string DectrisSimplonClient::GenAddr(SimplonModule element, SimplonTask task, const std::string& key) { std::string addr; switch (element) { @@ -232,18 +238,19 @@ void DectrisSimplonClient::EndAcquisitionFinished() { void DectrisSimplonClient::StartAcquisition(const DiffractionExperiment& experiment) { // For DECTRIS detectors we assume frame_time == count_time + // but give it 100 ns resolution if (experiment.GetFrameCountTimeAuto()) - SetConfig(SimplonModule::Detector, "count_time", experiment.GetFrameTime().count() / 1e6f); + SetConfigIfDifferent(SimplonModule::Detector, "count_time", experiment.GetFrameTime().count() / 1e6f, 1e-7); else - SetConfig(SimplonModule::Detector, "count_time", experiment.GetFrameCountTime().count() / 1e6f); + SetConfigIfDifferent(SimplonModule::Detector, "count_time", experiment.GetFrameCountTime().count() / 1e6f, 1e-9); - SetConfig(SimplonModule::Detector, "frame_time", experiment.GetFrameTime().count() / 1e6f); - SetConfig(SimplonModule::Detector, "nimages", experiment.GetFrameNumPerTrigger()); - SetConfig(SimplonModule::Detector, "ntrigger", experiment.GetNumTriggers()); + SetConfigIfDifferent(SimplonModule::Detector, "frame_time", experiment.GetFrameTime().count() / 1e6f, 1e-9); + SetConfigIfDifferent(SimplonModule::Detector, "nimages", experiment.GetFrameNumPerTrigger()); + SetConfigIfDifferent(SimplonModule::Detector, "ntrigger", experiment.GetNumTriggers()); - SetConfig(SimplonModule::Detector, "beam_center_x", experiment.GetBeamX_pxl()); - SetConfig(SimplonModule::Detector, "beam_center_y", experiment.GetBeamY_pxl()); - SetConfig(SimplonModule::Detector, "detector_distance", experiment.GetDetectorDistance_mm() / 1e3f); + SetConfigIfDifferent(SimplonModule::Detector, "beam_center_x", experiment.GetBeamX_pxl(), 1e-6); + SetConfigIfDifferent(SimplonModule::Detector, "beam_center_y", experiment.GetBeamY_pxl(), 1e-6); + SetConfigIfDifferent(SimplonModule::Detector, "detector_distance", experiment.GetDetectorDistance_mm() / 1e3f, 1e-9); SendDetectorCommand(SimplonDetectorCommand::Arm); } diff --git a/detector_control/DectrisSimplonClient.h b/detector_control/DectrisSimplonClient.h index 51f38d97..4cd35887 100644 --- a/detector_control/DectrisSimplonClient.h +++ b/detector_control/DectrisSimplonClient.h @@ -40,6 +40,7 @@ class DectrisSimplonClient { nlohmann::json GetStatus(SimplonModule element, const std::string &key); void SetConfig(SimplonModule element, const std::string &key, const nlohmann::json &value); void SetConfigIfDifferent(SimplonModule element, const std::string &key, float value, float tolerance); + void SetConfigIfDifferent(SimplonModule element, const std::string &key, int64_t value); void SendDetectorCommand(SimplonDetectorCommand cmd); public: