Files
Jungfraujoch/reader/JFJochImageBufferReader.h
T
leonarski_fandClaude Opus 5.5 3a44779d79 broker: rugnux live - rugnux runs inside the broker while a DECTRIS rotation collection arrives (demo prototype)
A DECTRIS rotation collection, with the mode switched on (PUT /config/rugnux), goes to
JFJochReceiverRugnux instead of JFJochReceiverLite: the images are forwarded as before, without the
per-image analysis, and one rugnux thread reads them back from the image buffer
(JFJochImageBufferReader) as they arrive. END waits for rugnux and carries its lattice, refined
geometry and per-image results. A small second run on the first 60 degrees reports early whether
there is a lattice. The live state, steps and result are at GET /rugnux/status and on a new
"Rugnux live" frontend page.

rugnux: ProcessConfig::fast_live takes every decision where it is first made and does nothing again
once the sweep is in (near-tie re-checks and the run made again, rotation-scale walk, metric-symmetry
arms, geometry walk, the supercell and quality guards, the doubled cell), so the run ends a fixed
time after the last image. A cut (/cancel, or deadline_s after the last image) hands over what is
established. Off by default: the CLI and the battery are unchanged (--fast-live is hidden, with
--simulate-live).

With the mode off the broker is unchanged. Not built yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 12:20:38 +02:00

41 lines
1.7 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <atomic>
#include <string>
#include <vector>
#include "JFJochReader.h"
#include "../common/ImageBuffer.h"
// Reads a collection inside the broker while it arrives: the dataset comes from its start message,
// the images from the broker's image buffer, where the receiver puts each one as it forwards it. A
// read of an image not there yet waits for it; after Ended it returns false for an image that never
// came. The buffer must hold the whole collection (slots >= images) - a slot taken again for a later
// image would hand out that image instead.
class JFJochImageBufferReader : public JFJochReader {
public:
explicit JFJochImageBufferReader(ImageBuffer &buffer);
void Open(const StartMessage &start);
// No image comes after this: the collection is over, or abandoned.
void Ended();
[[nodiscard]] uint64_t GetNumberOfImages() const override;
void Close() override;
bool ReadRawImage(int64_t image_number, JFJochReaderRawImage &image) override;
std::vector<SpotToSave> ReadSpots(int64_t image) const override { return {}; }
private:
bool LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset, DataMessage &message,
std::vector<uint8_t> &buffer, int64_t image_number, bool update_dataset) override;
// The image's CBOR message, as the receiver put it in the buffer; false when it never came.
bool WaitForMessage(int64_t image_number, std::vector<uint8_t> &cbor);
ImageBuffer &buffer_;
uint64_t number_of_images_ = 0;
std::atomic<bool> ended_ = false;
};