150 lines
4.3 KiB
C++
150 lines
4.3 KiB
C++
#pragma once
|
|
|
|
#include <xcliball.h>
|
|
#include <system_error>
|
|
|
|
#include "raptor_eagle_cameralink.h"
|
|
|
|
enum class RaptorEagleCCDError : int {
|
|
ERROR_OK,
|
|
ERROR_INVALID_UNITMAP,
|
|
ERROR_INVALID_ATTR_VALUE,
|
|
ERROR_CAMLINK_WRITE,
|
|
ERROR_CAMLINK_READ_TIMEOUT,
|
|
ERROR_CANNOT_INIT_CAMERA,
|
|
ERROR_CANNOT_RESET_MICRO,
|
|
ERROR_CANNOT_RESET_FPGA,
|
|
ERROR_EXT_TRIGGER_MODE,
|
|
ERROR_ACQUISITION_IN_PROGRESS,
|
|
ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS
|
|
};
|
|
|
|
|
|
namespace std
|
|
{
|
|
template <>
|
|
class is_error_code_enum<RaptorEagleCCDError> : public true_type
|
|
{
|
|
};
|
|
|
|
} // namespace std
|
|
|
|
|
|
struct RaptorEagleCCDErrorCategory : std::error_category {
|
|
RaptorEagleCCDErrorCategory() : std::error_category() {}
|
|
|
|
const char* name() const noexcept
|
|
{
|
|
return "EAGLE_CCD_ERROR_CATEGORY";
|
|
}
|
|
|
|
std::string message(int ec) const
|
|
{
|
|
RaptorEagleCCDError err = static_cast<RaptorEagleCCDError>(ec);
|
|
|
|
switch (err) {
|
|
case RaptorEagleCCDError::ERROR_OK:
|
|
return "OK";
|
|
case RaptorEagleCCDError::ERROR_INVALID_UNITMAP:
|
|
return "invalid EPIX-library unitmap";
|
|
case RaptorEagleCCDError::ERROR_INVALID_ATTR_VALUE:
|
|
return "invalid camera attribute value";
|
|
case RaptorEagleCCDError::ERROR_CAMLINK_WRITE:
|
|
return "not all data were transmitted via CameraLink connection";
|
|
case RaptorEagleCCDError::ERROR_CAMLINK_READ_TIMEOUT:
|
|
return "CameraLink reading operation timeout";
|
|
case RaptorEagleCCDError::ERROR_CANNOT_INIT_CAMERA:
|
|
return "cannot initialize camera hardware";
|
|
case RaptorEagleCCDError::ERROR_CANNOT_RESET_MICRO:
|
|
return "cannot reset camera microcontroller";
|
|
case RaptorEagleCCDError::ERROR_CANNOT_RESET_FPGA:
|
|
return "cannot reset FPGA board";
|
|
case RaptorEagleCCDError::ERROR_EXT_TRIGGER_MODE:
|
|
return "try to use software trigger while external trigger mode is enabled";
|
|
case RaptorEagleCCDError::ERROR_ACQUISITION_IN_PROGRESS:
|
|
return "acquisition is in progress";
|
|
case RaptorEagleCCDError::ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS:
|
|
return "insufficient filesystem permissions";
|
|
default:
|
|
return "UNKNOWN ERROR";
|
|
}
|
|
}
|
|
|
|
static const RaptorEagleCCDErrorCategory& get()
|
|
{
|
|
static const RaptorEagleCCDErrorCategory constInst;
|
|
return constInst;
|
|
}
|
|
};
|
|
|
|
|
|
/* Error category for XCLIB errors */
|
|
struct RaptorEagleControllerErrorCategory : std::error_category {
|
|
RaptorEagleControllerErrorCategory() : std::error_category() {}
|
|
|
|
const char* name() const noexcept
|
|
{
|
|
return "EAGLE_CCD_CONTROLLER_ERROR_CATEGORY";
|
|
}
|
|
|
|
std::string message(int ec) const
|
|
{
|
|
switch (ec) {
|
|
case CL_ETX:
|
|
return "controller OK";
|
|
case CL_ETX_SER_TIMEOUT:
|
|
return "partial controller command received (camera timed out)";
|
|
case CL_ETX_CK_SUM_ERR:
|
|
return "controller command checksum mismatch";
|
|
case CL_ETX_I2C_ERR:
|
|
return "controller I2C internal failure";
|
|
case CL_ETX_UNKNOWN_CMD:
|
|
return "controller unknown command";
|
|
case CL_ETX_DONE_LOW:
|
|
return "controller EPROM is busy (FPGA reboot)";
|
|
default:
|
|
return "UNKNOWN ERROR";
|
|
}
|
|
}
|
|
|
|
static const RaptorEagleControllerErrorCategory& get()
|
|
{
|
|
static const RaptorEagleControllerErrorCategory constInst;
|
|
return constInst;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
/* Error category for XCLIB errors */
|
|
struct XCLIBErrorCategory : std::error_category {
|
|
XCLIBErrorCategory() : std::error_category() {}
|
|
|
|
const char* name() const noexcept
|
|
{
|
|
return "XCLIB_Error_Category";
|
|
}
|
|
|
|
std::string message(int ec) const
|
|
{
|
|
return pxd_mesgErrorCode(ec);
|
|
}
|
|
|
|
static const XCLIBErrorCategory& get()
|
|
{
|
|
static const XCLIBErrorCategory constInst;
|
|
return constInst;
|
|
}
|
|
};
|
|
|
|
|
|
// namespace std
|
|
// {
|
|
|
|
inline std::error_code make_error_code(RaptorEagleCCDError ec)
|
|
{
|
|
return std::error_code(static_cast<int>(ec), RaptorEagleCCDErrorCategory::get());
|
|
}
|
|
|
|
// } // namespace std
|