Files
leonarski_fandClaude Opus 5.5 9807bc40df Broker: log why a DECTRIS run ends in a detector error, reuse one SIMPLON connection
"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>
2026-10-08 22:45:42 +02:00

34 lines
1.0 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "DetectorWrapper.h"
#include "DectrisSimplonClient.h"
#include "../common/Logger.h"
class DectrisDetectorWrapper : public DetectorWrapper {
std::unique_ptr<DectrisSimplonClient> simplon;
mutable Logger logger{"DectrisDetectorWrapper"};
void CheckBusy();
void CheckBusyOrError();
public:
void Initialize(DiffractionExperiment &experiment,
const std::vector<AcquisitionDeviceNetConfig> &net_config) override;
void Configure(const DiffractionExperiment &experiment) override;
void Start(const DiffractionExperiment &experiment) override;
void Stop() override;
void Trigger() override;
void Deactivate() override;
void LoadPixelMask(PixelMask &mask) override;
DetectorState GetState() const override;
DetectorStatus GetStatus() const override;
std::string GetErrorDescription() const override;
};