Files
Jungfraujoch/detector_control/DectrisDetectorWrapper.cpp
T
leonarski_f 230480e390
Build Packages / XDS test (durin plugin) (push) Successful in 8m5s
Build Packages / DIALS test (push) Successful in 12m55s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 14m41s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 16m13s
Build Packages / build:rpm (rocky8) (push) Successful in 18m17s
Build Packages / build:rpm (rocky9) (push) Successful in 19m14s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m59s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 9m17s
Build Packages / Generate python client (push) Successful in 1m15s
Build Packages / XDS test (neggia plugin) (push) Successful in 9m58s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 14m14s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 11m9s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 18m21s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m14s
Build Packages / Build documentation (push) Successful in 1m43s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 10m14s
Build Packages / Unit tests (push) Successful in 57m40s
v1.0.0-rc.138 (#48)
This is an UNSTABLE release. The release has significant modifications and bug fixes, if things go wrong, it is better to revert to 1.0.0-rc.132.

    jfjoch_broker: Cleanup DECTRIS start-up code to enable a shorter start time
    jfjoch_broker: Allow for asynchronous start to allow overlapping detector configuration with other beamline preparations
    jfjoch_broker: Goniometer axis name is converted to lowercase
    jfjoch_broker: Fix bug, where wrong HTTP error codes were returned
    jfjoch_broker: Improve sigma estimation during merging (K. Takaba)

---------

Co-authored-by: takaba_k <kiyofumi.takaba@psi.ch>
Reviewed-on: #48
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-04-27 19:56:14 +02:00

125 lines
3.9 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "DectrisDetectorWrapper.h"
DetectorState DectrisDetectorWrapper::GetState() const {
if (!simplon)
return DetectorState::NOT_CONNECTED;
SimplonState simplon_state;
try {
simplon_state = simplon->GetState();
} catch (const JFJochException &e) {
return DetectorState::NOT_CONNECTED;
}
switch (simplon_state) {
case SimplonState::Ready:
return DetectorState::WAITING;
case SimplonState::Initialize:
case SimplonState::Configure:
case SimplonState::Acquire:
case SimplonState::Test:
return DetectorState::BUSY;
case SimplonState::Idle:
return DetectorState::IDLE;
default:
case SimplonState::Error:
case SimplonState::Na:
return DetectorState::ERROR;
}
}
void DectrisDetectorWrapper::CheckBusy() {
switch(GetState()) {
case DetectorState::BUSY:
case DetectorState::WAITING:
throw JFJochException(JFJochExceptionCategory::Detector,
"Detector busy");
case DetectorState::NOT_CONNECTED:
throw JFJochException(JFJochExceptionCategory::Detector,
"Detector not connected");
default:
break;
}
}
void DectrisDetectorWrapper::CheckBusyOrError() {
switch(GetState()) {
case DetectorState::ERROR:
throw JFJochException(JFJochExceptionCategory::Detector,
"Detector in error state");
case DetectorState::BUSY:
case DetectorState::WAITING:
throw JFJochException(JFJochExceptionCategory::Detector,
"Detector busy");
case DetectorState::NOT_CONNECTED:
throw JFJochException(JFJochExceptionCategory::Detector,
"Detector not connected");
default:
break;
}
}
void DectrisDetectorWrapper::Initialize(DiffractionExperiment &experiment,
const std::vector<AcquisitionDeviceNetConfig> &net_config) {
if (experiment.GetDetectorType() != DetectorType::DECTRIS)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"DectrisDetectorWrapper needs DECTRIS detector");
if (experiment.GetDetectorModuleHostname().empty()) {
simplon.reset();
return;
}
if (experiment.GetDetectorModuleHostname().size() != 1)
throw JFJochException(JFJochExceptionCategory::Detector,
"DectrisDetectorWrapper needs DECTRIS detector");
simplon = std::make_unique<DectrisSimplonClient>(experiment.GetDetectorSetup().GetDetectorModuleHostname()[0]);
CheckBusy();
simplon->InitializeDetector(experiment.Detector());
}
void DectrisDetectorWrapper::Configure(const DiffractionExperiment &experiment) {
CheckBusyOrError();
if (simplon)
simplon->ConfigureDetector(experiment);
}
void DectrisDetectorWrapper::Start(const DiffractionExperiment &experiment) {
CheckBusyOrError();
if (simplon)
simplon->StartAcquisition(experiment);
}
void DectrisDetectorWrapper::Stop() {
if (simplon)
simplon->EndAcquisitionFinished();
}
void DectrisDetectorWrapper::Trigger() {
if (simplon)
simplon->TriggerAcquisition();
}
void DectrisDetectorWrapper::Deactivate() {
CheckBusyOrError();
}
DetectorStatus DectrisDetectorWrapper::GetStatus() const {
if (!simplon)
return {.detector_state = DetectorState::NOT_CONNECTED};
return {
.detector_state = GetState()
};
}
void DectrisDetectorWrapper::LoadPixelMask(PixelMask &mask) {
if (simplon)
mask.LoadDECTRISBadPixelMask(simplon->GetPixelMask());
}