Files
Jungfraujoch/receiver/JFJochReceiverService.h
T
leonarski_f afbe844b20
Build Packages / Create release (push) Successful in 17s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 4m41s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 20m49s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 13m6s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 23m44s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 7m28s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 11m50s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 14m9s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 16m25s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 15m42s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 20m50s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 20m36s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 22m18s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 23m29s
Build Packages / Generate python client (push) Successful in 30s
Build Packages / Build documentation (push) Successful in 1m10s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 21m38s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 17m8s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 23m10s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 19m16s
Build Packages / Unit tests (push) Successful in 2h8m4s
Build Packages / Validation Battery (push) Successful in 40m53s
v1.0.0-rc.178 (#88)
* Rugnux: Processes serial crystallography data from XFELs - SACLA (MPCCD), PAL-XFEL and European XFEL (CXI), LCLS (XTC) and SwissFEL Alvra (JUNGFRAU with a CrystFEL module geometry) - with several files or Jungfraujoch master files merged in one run (`rugnux *_master.h5`).
* Rugnux: Stills processing takes a known unit cell and space group as a starting point, finds the beam centre (and, with a cell, the detector distance) from the images, detects the saturation level in other facilities' files and refines the placement of individual detector panels.
* Rugnux: The stills report gives R_split and CC1/2 from frame half-sets, comparable with CrystFEL.
* jfjoch_viewer: Opens the same XFEL file formats.
* Validation: A stills battery checks Rugnux against deposited structures from SACLA, PAL-XFEL, LCLS, European XFEL and SwissFEL.
* Rugnux: More reliable convergence of rotation scaling, and live molecular replacement starts as soon as the model is uploaded.
* jfjoch_broker: Initialize clears the previous dataset's bearer tokens, image buffer and live Rugnux status, and a slow CUDA JIT cache is reported at start.

Reviewed-on: #88
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-10-21 11:20:01 +02:00

111 lines
4.9 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "RugnuxLiveStatus.h"
#include <mutex>
#include <memory>
#include "JFJochReceiver.h"
#include "../acquisition_device/AcquisitionDeviceGroup.h"
#include "../preview/ZMQMetadataSocket.h"
#include "../preview/ZMQPreviewSocket.h"
struct RugnuxModel;
class JFJochReceiverService {
std::unique_ptr<JFJochReceiver> receiver;
AcquisitionDeviceGroup &aq_devices;
Logger &logger;
ImageBuffer image_buffer;
ImagePusher &image_pusher;
std::shared_ptr<ImagePuller> image_puller;
int64_t nthreads = 8;
// Rotation collections from a DECTRIS detector analysed by rugnux while they arrive
// (JFJochReceiverRugnux), instead of image by image. Off unless asked for.
bool rugnux_enable = false;
std::shared_ptr<const RugnuxModel> rugnux_model;
int rugnux_reserved_cpus = 4; // left to the forward threads and the pusher
double rugnux_deadline_s = 60; // the analysis is cut this long after the last image (0 = never)
RugnuxLiveStatus rugnux_status; // of the last collection, kept after it ends
enum class ReceiverState {Idle, Running};
ReceiverState state = ReceiverState::Idle;
mutable std::mutex state_mutex;
std::condition_variable measurement_done;
std::future<void> measurement;
void FinalizeMeasurement();
void FinalizeMeasurementChangeState();
SpotFindingSettings spot_finding_settings;
PreviewImage preview_image;
std::unique_ptr<ZMQPreviewSocket> zmq_preview_socket;
std::unique_ptr<ZMQMetadataSocket> zmq_metadata_socket;
std::unique_ptr<IndexerThreadPool> indexer_thread_pool;
JFJochReceiverCurrentStatus receiver_status;
JFJochReceiverPlots plots;
public:
JFJochReceiverService(AcquisitionDeviceGroup &aq_devices,
Logger &logger,
ImagePusher &pusher,
size_t send_buffer_size_MiB = 512);
JFJochReceiverService& NumThreads(int64_t input);
JFJochReceiverService& RugnuxLive(bool enable, std::shared_ptr<const RugnuxModel> model, int reserved_cpus,
double deadline_s);
RugnuxLiveSnapshot GetRugnuxStatus() const;
JFJochReceiverService& PreviewSocket(const std::string &addr, const std::optional<int32_t> &watermark = {});
JFJochReceiverService& MetadataSocket(const std::string &addr);
JFJochReceiverService& PreviewSocketSettings(const ZMQPreviewSettings &input);
JFJochReceiverService& MetadataSocketSettings(const ZMQMetadataSettings &input);
JFJochReceiverService& Indexing(const IndexingSettings& input);
ZMQPreviewSettings GetPreviewSocketSettings() const;
ZMQMetadataSettings GetMetadataSocketSettings() const;
std::string GetPreviewSocketAddress() const;
std::string GetMetadataSocketAddress() const;
void LoadInternalGeneratorImage(const DiffractionExperiment& experiment,
const std::vector<uint16_t> &raw_expected_image,
uint64_t image_number);
// Ask the writer whether this run's output could be written, before anything is started.
// Throws if it could not.
void Preflight(const DiffractionExperiment &experiment);
void Start(const DiffractionExperiment &experiment,
const PixelMask &pixel_mask,
const JFCalibration *calibration,
std::shared_ptr<ImagePuller> puller = {});
void Cancel(bool silent);
JFJochReceiverOutput Stop();
void SetSpotFindingSettings(const SpotFindingSettings& settings);
MultiLinePlot GetDataProcessingPlot(const PlotRequest& request);
void GetPlotRaw(std::vector<float> &v, PlotType type, const std::string &roi);
std::optional<JFJochReceiverStatus> GetStatus();
std::vector<AcquisitionDeviceNetConfig> GetNetworkConfig();
std::vector<DeviceStatus> GetDeviceStatus() const;
std::optional<float> GetProgress() const;
void GetXFELEventCode(std::vector<uint64_t> &v) const;
void GetXFELPulseID(std::vector<uint64_t> &v) const;
void GetStartMessageFromBuffer(std::vector<uint8_t> &v);
bool GetImageFromBuffer(std::vector<uint8_t> &v, int64_t image_number = ImageBuffer::MaxImage);
std::string GetTIFFFromBuffer(int64_t image_number = ImageBuffer::MaxImage);
std::string GetJPEGFromBuffer(const PreviewImageSettings &settings, int64_t image_number = ImageBuffer::MaxImage);
ImageBufferStatus GetImageBufferStatus() const;
void ClearImageBuffer();
// Drop everything the previous run left readable - its status, plots, live rugnux status and
// buffered images - so nothing of it is served under the next run's tokens. Idle only.
void ClearResults();
ImagePusherStatus GetImagePusherStatus() const;
LiveCollection *GetLiveCollection() { return image_pusher.GetLiveCollection(); }
};