RaptorEagleV/raptor_eagle_ccd.h
2024-12-01 20:16:00 +03:00

89 lines
3.2 KiB
C++

#pragma once
#include <spdlog/sinks/null_sink.h>
#include <common/adc_spdlog.h>
#include <device/adc_device.h>
#include <device/adc_device_attribute.h>
#include <device/adc_device_command.h>
#include <xcliball.h>
#include "raptor_eagle_exception.h"
class RaptorEagleCCD : public adc::AdcGenericDevice<std::string, adc::AdcDeviceAttribute<>, adc::AdcDeviceCommand<>>,
adc::AdcSpdlogLogger
{
typedef adc::AdcGenericDevice<std::string, adc::AdcDeviceAttribute<>, adc::AdcDeviceCommand<>> base_t;
public:
static constexpr std::string_view CAMERA_ATTR_HBIN{"HBIN"};
static constexpr std::string_view CAMERA_ATTR_VBIN{"VBIN"};
static constexpr std::string_view CAMERA_ATTR_ROI_LEFT{"ROI_LEFT"};
static constexpr std::string_view CAMERA_ATTR_ROI_TOP{"ROI_TOP"};
static constexpr std::string_view CAMERA_ATTR_ROI_WIDTH{"ROI_WIDTH"};
static constexpr std::string_view CAMERA_ATTR_ROI_HEIGHT{"ROI_HEIGHT"};
static constexpr std::string_view CAMERA_ATTR_GAIN{"GAIN"};
static constexpr std::string_view CAMERA_ATTR_READ_RATE{"READ_RATE"};
static constexpr std::string_view CAMERA_ATTR_CCD_TEMP{"CCD_TEMP"};
static constexpr std::string_view CAMERA_ATTR_PCB_TEMP{"PCB_TEMP"};
static constexpr std::string_view CAMERA_ATTR_EXPTIME{"EXPTIME"};
static constexpr std::string_view CAMERA_ATTR_FRAME_RATE{"FRAME_RATE"};
static constexpr std::string_view CAMERA_ATTR_NEXP{"NEXP"};
static constexpr std::string_view CAMERA_ATTR_SHUTTER_STATE{"SHUTTER_STATE"};
static constexpr std::string_view CAMERA_ATTR_CCDDIM{"CCDDIM"};
static constexpr std::string_view CAMERA_CMD_START_EXP{"START_EXP"};
static constexpr std::string_view CAMERA_CMD_STOP_EXP{"STOP_EXP"};
// static constexpr std::string_view CAMERA_CMD_OPEN_SHUTTER{"OPEN_SHUTTER"};
// static constexpr std::string_view CAMERA_CMD_CLOSE_SHUTTER{"CLOSE_SHUTTER"};
RaptorEagleCCD(const adc::traits::adc_input_char_range auto& epix_video_fmt_filename,
std::shared_ptr<spdlog::logger> logger = spdlog::null_logger_mt("EAGLE_CCD_NULLLOGGER"));
RaptorEagleCCD(std::shared_ptr<spdlog::logger> logger = spdlog::null_logger_mt("EAGLE_CCD_NULLLOGGER"));
~RaptorEagleCCD();
private:
std::string _epixFmtVideoFilename;
int _cameraUnitmap;
void initAttrComm();
void initCamera(int unitmap);
void openPIXCI();
void closePIXCI();
template <bool NOEXCEPT = false>
void xclibApiCall(int err, const adc::traits::adc_input_char_range auto& func_name)
{
if (err) {
if (std::ranges::size(func_name)) {
logError("XCLIB API call ('{}') returns: {} ({})", func_name, err, pxd_mesgErrorCode(err));
} else {
logError("XCLIB API call returns: {} ({})", err, pxd_mesgErrorCode(err));
}
if constexpr (!NOEXCEPT) {
throw std::error_code(err, XCLIBErrorCategory::get());
}
} else {
if (std::ranges::size(func_name)) {
logDebug("XCLIB API call ('{}') finished successfully", func_name);
}
}
}
template <bool NOEXCEPT = false>
void xclibApiCall(int err)
{
xclibApiCall<NOEXCEPT>(err, std::string_view(""));
}
};