From 162eab63b729d8a641715cbf8f0099123ae504b4 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 28 Apr 2026 16:03:17 +0200 Subject: [PATCH] JFJochStateMachine: Notify everyone on CalibrateDetector finished + small modifications to handling state --- broker/JFJochStateMachine.cpp | 13 +++++-------- broker/JFJochStateMachine.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/broker/JFJochStateMachine.cpp b/broker/JFJochStateMachine.cpp index 0e5beff1..a51e4d85 100644 --- a/broker/JFJochStateMachine.cpp +++ b/broker/JFJochStateMachine.cpp @@ -82,7 +82,7 @@ void JFJochStateMachine::CalibrateJUNGFRAU(std::unique_lock &ul) { pixel_mask.LoadDetectorBadPixelMask(experiment, calibration.get()); } -void JFJochStateMachine::CalibrateDetector(std::unique_lock &ul) { +void JFJochStateMachine::CalibrateDetector(std::unique_lock ul) { cancel_sequence = false; pixel_mask = PixelMask(experiment); @@ -307,15 +307,12 @@ void JFJochStateMachine::Initialize() { void JFJochStateMachine::Pedestal() { std::unique_lock ul(m); + SetState(JFJochState::Busy, "Updating calibration", BrokerStatus::MessageSeverity::Info); + if (state != JFJochState::Idle) throw WrongDAQStateException("Must be idle to take pedestal"); - measurement = std::async(std::launch::async, &JFJochStateMachine::PedestalThread, this, std::move(ul)); -} - - -void JFJochStateMachine::PedestalThread(std::unique_lock ul) { - CalibrateDetector(ul); + measurement = std::async(std::launch::async, &JFJochStateMachine::CalibrateDetector, this, std::move(ul)); } void JFJochStateMachine::InitializeThread(std::unique_lock ul) { @@ -338,7 +335,7 @@ void JFJochStateMachine::InitializeThread(std::unique_lock ul) { SetState(JFJochState::Error, e.what(), BrokerStatus::MessageSeverity::Error); throw; } - CalibrateDetector(ul); + CalibrateDetector(std::move(ul)); } void JFJochStateMachine::Trigger() { diff --git a/broker/JFJochStateMachine.h b/broker/JFJochStateMachine.h index 2174e6b1..dbf2eb1e 100644 --- a/broker/JFJochStateMachine.h +++ b/broker/JFJochStateMachine.h @@ -134,7 +134,7 @@ class JFJochStateMachine { bool IsRunning() const; // Is state Busy/Pedestal/Measure void ResetError() noexcept; void TakeDarkMaskInternal(std::unique_lock &ul); - void CalibrateDetector(std::unique_lock &ul); + void CalibrateDetector(std::unique_lock ul); void CalibrateJUNGFRAU(std::unique_lock &ul); void TakePedestalInternalG0(std::unique_lock &ul); void TakePedestalInternalG1(std::unique_lock &ul, int32_t storage_cell = 0);