From 659b5da52d6c9c192593df9368fac1bd43c2b358 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 8 Nov 2026 10:04:06 +0100 Subject: [PATCH] Stream receivers: one Cancel, with the analysis cut through a virtual Cut JFJochReceiverRugnuxRotation and JFJochReceiverRugnuxStills had the same Cancel(bool). It now lives in JFJochReceiverStream, which calls a virtual Cut that does nothing for a receiver with no analysis after the images. The empty JFJochReceiverRugnuxRotation::SetSpotFindingSettings goes: the base only stores settings the service has already checked, and nothing in the rotation receiver reads them. Fixes the indentation RotationIndexer.cpp's settings key was left with. One difference for Lite and the dark mask: a non-silent cancel that comes after the end message no longer marks the collection cancelled, as for the rugnux receivers. Every image is in by then; the window is the end message and the writer's finalisation. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK --- .../rotation_indexer/RotationIndexer.cpp | 2 +- receiver/JFJochReceiverRugnuxRotation.cpp | 15 --------------- receiver/JFJochReceiverRugnuxRotation.h | 8 +------- receiver/JFJochReceiverRugnuxStills.cpp | 11 ----------- receiver/JFJochReceiverRugnuxStills.h | 6 +----- receiver/JFJochReceiverStream.cpp | 7 ++++++- receiver/JFJochReceiverStream.h | 1 + 7 files changed, 10 insertions(+), 40 deletions(-) diff --git a/image_analysis/rotation_indexer/RotationIndexer.cpp b/image_analysis/rotation_indexer/RotationIndexer.cpp index 2bf090d1c..5d84ba94b 100644 --- a/image_analysis/rotation_indexer/RotationIndexer.cpp +++ b/image_analysis/rotation_indexer/RotationIndexer.cpp @@ -152,7 +152,7 @@ namespace { static_cast(x.GetFFT_NumVectors()), x.GetFFT_HighResolution_A(), x.GetFFT_MinAngle_deg(), x.GetFFT_MaxAngle_deg(), x.GetUnitCellDistTolerance(), x.GetUnitCellAngleTolerance_deg(), static_cast(x.GetIndexIceRings()), - static_cast(x.GetMaxExtraLattices()), static_cast(x.GetLatticeClassDemoted()), + static_cast(x.GetMaxExtraLattices()), static_cast(x.GetLatticeClassDemoted()), static_cast(x.GetViableCellMinSpots()), static_cast(x.GetAlgorithm()), static_cast(x.GetGeomRefinementAlgorithm()), static_cast(x.GetIndexingThreads()), static_cast(x.GetRefineThreads())}); diff --git a/receiver/JFJochReceiverRugnuxRotation.cpp b/receiver/JFJochReceiverRugnuxRotation.cpp index f7e508959..47d14dbb7 100644 --- a/receiver/JFJochReceiverRugnuxRotation.cpp +++ b/receiver/JFJochReceiverRugnuxRotation.cpp @@ -392,17 +392,6 @@ void JFJochReceiverRugnuxRotation::AddToEndMessage(EndMessage &message) { } } -void JFJochReceiverRugnuxRotation::Cancel(bool silent) { - detector_finished = true; - // The silent cancel is the detector reading idle at the end of every collection: rugnux goes on. - if (silent) - return; - // Ends the collection while images still arrive; in every case the analysis is cut and the end message goes out - if (!end_message_received) - JFJochReceiver::Cancel(silent); - Cut("cancel"); -} - void JFJochReceiverRugnuxRotation::Cut(const std::string &reason) { std::unique_lock ul(rugnux_mutex); if (cut || rugnux_result) @@ -417,10 +406,6 @@ void JFJochReceiverRugnuxRotation::Cut(const std::string &reason) { logger.Debug("rugnux live: analysis cut ({}) - the end message carries what is established", reason); } -void JFJochReceiverRugnuxRotation::SetSpotFindingSettings(const SpotFindingSettings &in_spot_finding_settings) { - // A rotation run takes rugnux's own spot finding -} - JFJochReceiverOutput JFJochReceiverRugnuxRotation::GetFinalStatistics() const { JFJochReceiverOutput ret = JFJochReceiver::GetFinalStatistics(); ret.analysis_warning = skipped_warning; diff --git a/receiver/JFJochReceiverRugnuxRotation.h b/receiver/JFJochReceiverRugnuxRotation.h index 6e55d5720..2fbf4fc60 100644 --- a/receiver/JFJochReceiverRugnuxRotation.h +++ b/receiver/JFJochReceiverRugnuxRotation.h @@ -16,8 +16,6 @@ // A rotation collection forwarded to the writer and analysed by rugnux, which reads it back from the image buffer class JFJochReceiverRugnuxRotation : public JFJochReceiverStream { - using JFJochReceiverStream::Cancel; - JFJochImageBufferReader reader; const int rugnux_nthreads; @@ -47,7 +45,7 @@ class JFJochReceiverRugnuxRotation : public JFJochReceiverStream { void RugnuxThread(); void ProbeThread(); // Stops rugnux where it is, the end message goes out with what it established; reason "deadline" or "cancel" - void Cut(const std::string &reason); + void Cut(const std::string &reason) override; void AddToEndMessage(EndMessage &message) override; public: JFJochReceiverRugnuxRotation(const DiffractionExperiment &experiment, @@ -68,9 +66,5 @@ public: ZMQMetadataSocket *zmq_metadata_socket = nullptr); ~JFJochReceiverRugnuxRotation() override; - void Cancel(bool silent) override; - JFJochReceiverOutput GetFinalStatistics() const override; - - void SetSpotFindingSettings(const SpotFindingSettings &spot_finding_settings) override; }; diff --git a/receiver/JFJochReceiverRugnuxStills.cpp b/receiver/JFJochReceiverRugnuxStills.cpp index daf94a98f..67d08d590 100644 --- a/receiver/JFJochReceiverRugnuxStills.cpp +++ b/receiver/JFJochReceiverRugnuxStills.cpp @@ -186,17 +186,6 @@ void JFJochReceiverRugnuxStills::AddToEndMessage(EndMessage &message) { stills->FillEndMessage(message); } -void JFJochReceiverRugnuxStills::Cancel(bool silent) { - detector_finished = true; - // The silent cancel is the detector reading idle at the end of every collection: rugnux goes on. - if (silent) - return; - // Ends the collection while images still arrive; in every case the model step is cut and the end message goes out - if (!end_message_received) - JFJochReceiver::Cancel(silent); - Cut("cancel"); -} - void JFJochReceiverRugnuxStills::Cut(const std::string &reason) { std::unique_lock ul(stills_mutex); if (cut) diff --git a/receiver/JFJochReceiverRugnuxStills.h b/receiver/JFJochReceiverRugnuxStills.h index 46cf158ea..c36de3f9e 100644 --- a/receiver/JFJochReceiverRugnuxStills.h +++ b/receiver/JFJochReceiverRugnuxStills.h @@ -13,8 +13,6 @@ // A serial collection analysed frame by frame at the geometry of a pre-pass, which the start message waits for class JFJochReceiverRugnuxStills : public JFJochReceiverStream, public StillsSink { - using JFJochReceiverStream::Cancel; - const std::shared_ptr model; const double deadline_s; // after the last image, the model step is cut (0 = never) RugnuxLiveStatus &live_status; @@ -35,7 +33,7 @@ class JFJochReceiverRugnuxStills : public JFJochReceiverStream, public StillsSin void SendAnalysedImage(DataMessage &message, const AzimuthalIntegrationProfile &profile) override; SpotFindingSettings AnalysisSettings() override; void StillsSetupFailed(const JFJochException &error) override; - void Cut(const std::string &reason); + void Cut(const std::string &reason) override; void AddToEndMessage(EndMessage &message) override; public: JFJochReceiverRugnuxStills(const DiffractionExperiment &experiment, @@ -55,6 +53,4 @@ public: ZMQMetadataSocket *zmq_metadata_socket = nullptr, IndexerThreadPool *indexing_thread_pool = nullptr); ~JFJochReceiverRugnuxStills() override; - - void Cancel(bool silent) override; }; diff --git a/receiver/JFJochReceiverStream.cpp b/receiver/JFJochReceiverStream.cpp index d673a766c..2ab22a398 100644 --- a/receiver/JFJochReceiverStream.cpp +++ b/receiver/JFJochReceiverStream.cpp @@ -246,9 +246,14 @@ void JFJochReceiverStream::StopReceiver() { } void JFJochReceiverStream::Cancel(bool silent) { - JFJochReceiver::Cancel(silent); // A silent cancel is not a request to abort, it says the detector has finished. It bounds the wait for the start message. detector_finished = true; + if (silent) + return; + // Once the end message is in, the images are all there: a cancel only cuts the analysis that goes on after them. + if (!end_message_received) + JFJochReceiver::Cancel(silent); + Cut("cancel"); } void JFJochReceiverStream::AddToEndMessage(EndMessage &message) { diff --git a/receiver/JFJochReceiverStream.h b/receiver/JFJochReceiverStream.h index 0ad09d53e..01b2b8fe0 100644 --- a/receiver/JFJochReceiverStream.h +++ b/receiver/JFJochReceiverStream.h @@ -49,6 +49,7 @@ protected: virtual void OnImage(uint32_t id, DataMessage &message, std::chrono::steady_clock::time_point received) = 0; virtual void FinishCollection(); // all images are in: end message, writer, status virtual int64_t ExpectedImages() const; + virtual void Cut(const std::string &reason) {} // the analysis that goes on after the images, if there is one void AddToEndMessage(EndMessage &message) override; uint64_t GetImagesDropped() const override { return image_puller.GetDroppedImages(); }