"Error in detector operation" was raised whenever the wait-for-idle loop in JFJochServices::Stop() ended in any state other than idle. For DECTRIS that includes a single failed status request (connect/read timeout, non-200), which GetState() silently turned into NOT_CONNECTED, and a cancel whose disarm failed - none of them distinguishable in the log. - DectrisDetectorWrapper::GetState() logs the failure reason before returning NOT_CONNECTED. - Stop() logs the state that ended the loop, whether the stop command failed, and what the detector reports (DetectorWrapper::GetErrorDescription(); for DECTRIS the SIMPLON state and the detector status "error" list). - Cancel() logs why the stop command failed. - A non-200 GET now reports the HTTP status and body (it printed "Success"). - DectrisSimplonClient keeps one keep-alive httplib::Client, serialised by a mutex, instead of opening a new TCP connection per request. - The wait-for-idle loop polls every 100 ms instead of every 5 ms. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
#include "../common/DiffractionExperiment.h"
|
|
#include "../common/PixelMask.h"
|
|
|
|
enum class DetectorState {IDLE, ERROR, BUSY, WAITING, NOT_CONNECTED};
|
|
enum class DetectorPowerState {ON, OFF, PARTIAL};
|
|
|
|
inline std::string to_string(DetectorState state) {
|
|
switch (state) {
|
|
case DetectorState::IDLE: return "idle";
|
|
case DetectorState::ERROR: return "error";
|
|
case DetectorState::BUSY: return "busy";
|
|
case DetectorState::WAITING: return "waiting";
|
|
case DetectorState::NOT_CONNECTED: return "not connected";
|
|
default: return "unknown";
|
|
}
|
|
}
|
|
|
|
struct DetectorStatus {
|
|
std::vector<int64_t> temperature_fpga_degC;
|
|
std::vector<int64_t> high_voltage_V;
|
|
DetectorState detector_state;
|
|
DetectorPowerState power_state;
|
|
std::string detector_server_version;
|
|
int64_t remaining_triggers;
|
|
};
|
|
|
|
class DetectorWrapper {
|
|
public:
|
|
virtual ~DetectorWrapper() = default;
|
|
|
|
[[nodiscard]] virtual DetectorState GetState() const = 0;
|
|
virtual void Initialize(DiffractionExperiment& experiment, const std::vector<AcquisitionDeviceNetConfig>& net_config) = 0;
|
|
virtual void Configure(const DiffractionExperiment& experiment) = 0;
|
|
virtual void Start(const DiffractionExperiment& experiment) = 0;
|
|
virtual void Stop() = 0;
|
|
virtual void Trigger() = 0;
|
|
virtual void Deactivate() = 0;
|
|
|
|
virtual void LoadPixelMask(PixelMask &mask) = 0;
|
|
[[nodiscard]] virtual DetectorStatus GetStatus() const = 0;
|
|
// What the detector itself says about a fault, for the log; empty if it has nothing to add
|
|
[[nodiscard]] virtual std::string GetErrorDescription() const { return {}; }
|
|
};
|
|
|
|
|