Files
Jungfraujoch/viewer/JFJochProcessController.h
leonarski_f 9aae0c2ba7
Build Packages / Create release (push) Successful in 21s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 9m40s
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 9m49s
Build Packages / build:viewer-tgz:cpu (push) Successful in 11m37s
Build Packages / build:viewer-tgz:cuda (push) Successful in 12m40s
Build Packages / build:windows:nocuda (push) Successful in 17m44s
Build Packages / build:windows:cuda (push) Successful in 20m13s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 14m41s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m59s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 15m5s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 14m35s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 15m53s
Build Packages / build:rugnux:windows (push) Successful in 11m29s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 18m51s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 18m43s
Build Packages / Generate python client (push) Successful in 51s
Build Packages / build:rpm (rocky8) (push) Successful in 18m51s
Build Packages / Build documentation (push) Successful in 1m21s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 18m38s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 18m24s
Build Packages / build:rpm (rocky9) (push) Successful in 19m19s
Build Packages / Unit tests (push) Successful in 1h37m15s
v1.0.0-rc.169 (#79)
* Building Jungfraujoch no longer needs zlib or Eigen installed on the machine, and the dependencies the build fetches are pinned and updated to current releases.
* rugnux: improvements in indexing, lattice selection and geometry post-refinement, which index crystals that previously returned no lattice and keep the better of the two geometries a run measures.
* rugnux: improvements in beam-centre measurement, beam-stop detection and space-group determination.
* rugnux: the unit cell reported with a determined space group now obeys that group - a cell whose symmetry was confirmed from the intensities is re-refined under it, and a cell the group cannot describe is reported with a warning rather than as it stands.
* rugnux drops the stretches of a rotation sweep whose removal measurably improves the merged intensities and reports what became of every frame, and decides the resolution cut on the crystal's own diffraction rather than on its ice rings.
* The rugnux results report is machine-readable - every line that is not `KEY= value` data starts with `#` - and states the build it was written by, its authorship and its terms of use (`REPORT_VERSION= 8`).
* `jfjoch_viewer`: improvements in the file manager (CBF frames beside HDF5 datasets, a remembered root), the dataset plots, the inspector and the image statistics, plus a settable font size, a view of the rugnux results report, usable performance over a remote display (`ssh -X`) and a reset of all settings to defaults; the reciprocal-space window is removed.
* Broker fixes around DECTRIS collections and dark-mask calibration: re-initialising after a run that never started no longer freezes the broker, a cancelled calibration is abandoned instead of reported as done, and a collection whose start message never arrives ends by itself.

Reviewed-on: #79
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-09-15 17:09:31 +02:00

73 lines
2.8 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <QObject>
#include <QString>
#include <atomic>
#include <chrono>
#include <memory>
#include <mutex>
#include <thread>
#include "../rugnux/Rugnux.h"
#include "../common/DiffractionExperiment.h"
#include "../common/PixelMask.h"
#include "../reader/JFJochReaderDataset.h"
Q_DECLARE_METATYPE(ProcessResult)
// Runs one Rugnux job off the GUI thread and reports back via queued Qt signals. The job
// opens its own private reader on the file (HDF5 access is globally serialized, so this
// is safe alongside the interactive reader), so the viewer becomes a processing frontend without
// blocking the UI. Cancel() is forwarded to Rugnux::Cancel() (atomic) and works from any
// thread / at any point of the run.
class JFJochProcessController : public QObject, private RugnuxObserver {
Q_OBJECT
public:
explicit JFJochProcessController(QObject *parent = nullptr);
~JFJochProcessController() override;
bool running() const { return running_; }
public slots:
// Start a job over `file_path` with the given (fully configured) experiment + mask + config.
// Ignored if a job is already running.
void start(const QString &file_path, DiffractionExperiment experiment,
PixelMask pixel_mask, ProcessConfig config);
void cancel();
signals:
void started();
void phaseChanged(QString phase);
void progress(quint64 done, quint64 total);
// `report` is the rugnux result report (the <prefix>_report.txt text), rendered from the run's
// own results so the viewer can show it without a file; empty for a cancelled run.
void finished(ProcessResult result, QString report);
void failed(QString error);
// Per-image results accumulated so far, for live dataset-info plots while a job runs (throttled).
void liveDataset(std::shared_ptr<const JFJochReaderDataset> dataset);
private:
// RugnuxObserver - called from worker threads, forwarded as queued signals.
void OnPhase(const std::string &phase) override;
void OnProgress(uint64_t done, uint64_t total) override;
void OnImageProcessed(const DataMessage &msg) override;
void run_(QString file_path, DiffractionExperiment experiment, PixelMask pixel_mask, ProcessConfig config);
void joinWorker_();
std::thread worker_;
std::atomic<Rugnux *> active_{nullptr};
std::atomic<bool> running_{false};
std::atomic<bool> cancel_pending_{false};
// Live per-image results, accumulated by OnImageProcessed (worker threads) and emitted as
// immutable copies. live_mutex_ guards both the dataset and the throttle timestamp.
std::mutex live_mutex_;
std::shared_ptr<JFJochReaderDataset> live_dataset_;
std::chrono::steady_clock::time_point last_live_emit_;
};