add CAMERA_STATUS attribute (still unusable)
This commit is contained in:
parent
86eb2b8ba7
commit
3fee70b445
@ -233,6 +233,9 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptr<acq_params_
|
||||
|
||||
if (_acqParams->startTime < _acqParams->abortTime) { // acquisition was aborted
|
||||
std::chrono::duration<double> real_exp = _acqParams->abortTime - _acqParams->startTime;
|
||||
_manager->logTrace("Acq. start time: {}; acq. abort time: {}", _acqParams->startTime,
|
||||
_acqParams->abortTime);
|
||||
_manager->logDebug("Exposure was stopped! Recompute the exposure duration to {} secs", real_exp.count());
|
||||
_acqParams->expTime = real_exp.count();
|
||||
}
|
||||
|
||||
|
||||
@ -518,7 +518,7 @@ size_t RaptorEagleCCD::clRead(byte_seq_t& bytes)
|
||||
|
||||
// how many byte are available
|
||||
xclibApiCall(nbytes = pxd_serialRead(_cameraUnitmap, 0, nullptr, 0),
|
||||
std::format("pxd_serialRead({}, 0, NULL, 0)", _cameraUnitmap));
|
||||
std::format("pxd_serialRead({}, 0, NULL, 0)", _cameraUnitmap), spdlog::level::trace);
|
||||
|
||||
if (!nbytes) {
|
||||
logWarn("There are no bytes in Rx-buffer! Polling buffer during {} ...", CL_DEFAULT_TIMEOUT);
|
||||
@ -538,7 +538,7 @@ size_t RaptorEagleCCD::clRead(byte_seq_t& bytes)
|
||||
|
||||
// here the call is only for logging purpose
|
||||
xclibApiCall(nbytes = pxd_serialRead(_cameraUnitmap, 0, nullptr, 0),
|
||||
std::format("pxd_serialRead({}, 0, NULL, 0)", _cameraUnitmap));
|
||||
std::format("pxd_serialRead({}, 0, NULL, 0)", _cameraUnitmap), spdlog::level::trace);
|
||||
}
|
||||
|
||||
|
||||
@ -550,7 +550,8 @@ size_t RaptorEagleCCD::clRead(byte_seq_t& bytes)
|
||||
|
||||
xclibApiCall(pxd_serialRead(_cameraUnitmap, 0, (char*)bytes.data(), nbytes),
|
||||
std::format("pxd_serialRead({}, 0, {}, {}) -> [{}]", _cameraUnitmap, (void*)bytes.data(), nbytes,
|
||||
details::formatByteArr(bytes | std::views::take(nbytes))));
|
||||
details::formatByteArr(bytes | std::views::take(nbytes))),
|
||||
spdlog::level::trace);
|
||||
|
||||
|
||||
// if (_loggerSPtr->level() == spdlog::level::trace) {
|
||||
@ -613,7 +614,7 @@ size_t RaptorEagleCCD::clWrite(const byte_seq_t& bytes)
|
||||
|
||||
// how many bytes are available in Tx-buffer
|
||||
xclibApiCall(nbytes = pxd_serialWrite(_cameraUnitmap, 0, nullptr, 0),
|
||||
std::format("pxd_serialWrite({}, 0, NULL, 0)", _cameraUnitmap));
|
||||
std::format("pxd_serialWrite({}, 0, NULL, 0)", _cameraUnitmap), spdlog::level::trace);
|
||||
|
||||
if (nbytes) {
|
||||
if (nbytes < (bytes.size() + tr_nbytes)) {
|
||||
@ -628,7 +629,8 @@ size_t RaptorEagleCCD::clWrite(const byte_seq_t& bytes)
|
||||
|
||||
xclibApiCall(nbytes = pxd_serialWrite(_cameraUnitmap, 0, (char*)bytes.data(), bytes.size()),
|
||||
std::format("pxd_serialWrite({}, 0, [{}], {})", _cameraUnitmap, details::formatByteArr(bytes),
|
||||
bytes.size()));
|
||||
bytes.size()),
|
||||
spdlog::level::trace);
|
||||
// xclibApiCall(
|
||||
// nbytes = pxd_serialWrite(_cameraUnitmap, 0, (char*)bytes.data(), bytes.size()),
|
||||
// std::format("pxd_serialWrite({}, 0, {}, {})", _cameraUnitmap, (void*)bytes.data(), bytes.size()));
|
||||
@ -645,7 +647,8 @@ size_t RaptorEagleCCD::clWrite(const byte_seq_t& bytes)
|
||||
std::format("pxd_serialWrite({}, 0, [{}], {})", _cameraUnitmap,
|
||||
details::formatByteArr(std::string_view((const char*)etx_checksum_bytes, 2) |
|
||||
std::views::take(tr_nbytes)),
|
||||
tr_nbytes));
|
||||
tr_nbytes),
|
||||
spdlog::level::trace);
|
||||
// xclibApiCall(
|
||||
// pxd_serialWrite(_cameraUnitmap, 0, (char*)etx_checksum_bytes, tr_nbytes),
|
||||
// std::format("pxd_serialWrite({}, 0, {}, {})", _cameraUnitmap, (void*)etx_checksum_bytes, tr_nbytes));
|
||||
@ -1170,6 +1173,45 @@ void RaptorEagleCCD::initAttrComm()
|
||||
|
||||
/* ------- ATTRIBUTES ------- */
|
||||
|
||||
/* CAMERA CURRENT STATUS */
|
||||
|
||||
addAttribute(
|
||||
CAMERA_ATTR_CAMERA_STATUS,
|
||||
[this]() {
|
||||
logTrace("Return current camera status as {}", _cameraStatus);
|
||||
return _cameraStatus;
|
||||
},
|
||||
[this](const std::string_view& status) {
|
||||
logDebug("Try to set current status to {}", status);
|
||||
|
||||
if (status != CAMERA_ATTR_CAMERA_STATUS_ACQ && status != CAMERA_ATTR_CAMERA_STATUS_READ &&
|
||||
status != CAMERA_ATTR_CAMERA_STATUS_SAVE && status != CAMERA_ATTR_CAMERA_STATUS_IDLE) {
|
||||
logError("Invalid value of camera status!!!");
|
||||
throw std::system_error();
|
||||
}
|
||||
|
||||
_cameraStatus = status;
|
||||
logDebug("Camera status is {}", _cameraStatus);
|
||||
},
|
||||
adc::utils::AdcDefaultValueConverter<>::serialize<attribute_t::serialized_t, std::string_view>,
|
||||
[&comp_case_ignore](const attribute_t::serialized_t& v) {
|
||||
if (std::ranges::equal(v, CAMERA_ATTR_CAMERA_STATUS_ACQ, comp_case_ignore)) {
|
||||
return CAMERA_ATTR_CAMERA_STATUS_ACQ;
|
||||
} else if (std::ranges::equal(v, CAMERA_ATTR_CAMERA_STATUS_READ, comp_case_ignore)) {
|
||||
return CAMERA_ATTR_CAMERA_STATUS_READ;
|
||||
} else if (std::ranges::equal(v, CAMERA_ATTR_CAMERA_STATUS_SAVE, comp_case_ignore)) {
|
||||
return CAMERA_ATTR_CAMERA_STATUS_SAVE;
|
||||
} else if (std::ranges::equal(v, CAMERA_ATTR_CAMERA_STATUS_IDLE, comp_case_ignore)) {
|
||||
return CAMERA_ATTR_CAMERA_STATUS_IDLE;
|
||||
} else {
|
||||
return CAMERA_ATTR_STR_INVALID;
|
||||
}
|
||||
|
||||
return CAMERA_ATTR_STR_INVALID;
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* CURRENT FITS IMAGE FILENAME AND ITS HEADER TEMPLATE, PERMANENT AND CURRENT USER FITS KEYWORDS */
|
||||
|
||||
addAttribute(
|
||||
@ -1727,7 +1769,7 @@ void RaptorEagleCCD::initAttrComm()
|
||||
val = CAMERA_ATTR_STR_INVALID;
|
||||
}
|
||||
|
||||
logTrace("Return readout rate as '()' string", val);
|
||||
logTrace("Return readout rate as '{}' string", val);
|
||||
|
||||
return val;
|
||||
},
|
||||
|
||||
@ -103,6 +103,8 @@ public:
|
||||
static constexpr std::string_view CAMERA_ATTR_PERM_KEYW{"PERM_FITS_KEY"};
|
||||
static constexpr std::string_view CAMERA_ATTR_CURR_KEYW{"CURR_FITS_KEY"};
|
||||
|
||||
static constexpr std::string_view CAMERA_ATTR_CAMERA_STATUS{"CAMERA_STATUS"};
|
||||
|
||||
static constexpr std::string_view CAMERA_CMD_INITCAM{"INITCAM"};
|
||||
static constexpr std::string_view CAMERA_CMD_START_EXP{"STARTEXP"};
|
||||
static constexpr std::string_view CAMERA_CMD_STOP_EXP{"STOPEXP"};
|
||||
@ -144,6 +146,14 @@ public:
|
||||
// idle
|
||||
static constexpr std::string_view CAMERA_ATTR_TRIGGER_MODE_IDLE{"IDLE"};
|
||||
|
||||
|
||||
// camera status
|
||||
static constexpr std::string_view CAMERA_ATTR_CAMERA_STATUS_IDLE{"IDLE"};
|
||||
static constexpr std::string_view CAMERA_ATTR_CAMERA_STATUS_ACQ{"ACQ"}; // camera is acquiring
|
||||
static constexpr std::string_view CAMERA_ATTR_CAMERA_STATUS_READ{"READING"}; // camera is reading from CCD
|
||||
static constexpr std::string_view CAMERA_ATTR_CAMERA_STATUS_SAVE{"SAVING"}; // camera is saving to FITS file
|
||||
|
||||
|
||||
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_NULL_LOGGER"));
|
||||
|
||||
@ -238,8 +248,9 @@ private:
|
||||
std::atomic_size_t _frameNumbers;
|
||||
std::string _currentFitsFile; // current acquisition FITS filename
|
||||
std::string _currentTemplateFile; // CFITSIO template filename
|
||||
std::vector<std::string> _currentFitsKeywords; // current acquisition FITS keywords
|
||||
std::vector<std::string> _permanentFitsKeywords; // permanent user FITS keywords
|
||||
std::vector<std::string> _currentFitsKeywords{}; // current acquisition FITS keywords
|
||||
std::vector<std::string> _permanentFitsKeywords{}; // permanent user FITS keywords
|
||||
std::string_view _cameraStatus = CAMERA_ATTR_CAMERA_STATUS_IDLE; // camera current status
|
||||
|
||||
// std::list<std::unique_ptr<ushort>> _acqRingBuffer;
|
||||
std::list<std::pair<std::unique_ptr<ushort>, size_t>> _acqRingBuffer;
|
||||
@ -338,7 +349,9 @@ private:
|
||||
// logging helper methods
|
||||
|
||||
template <bool NOEXCEPT = false>
|
||||
void xclibApiCall(int err, const adc::traits::adc_input_char_range auto& func_name)
|
||||
void xclibApiCall(int err,
|
||||
const adc::traits::adc_input_char_range auto& func_name,
|
||||
loglevel_t log_level = spdlog::level::debug)
|
||||
{
|
||||
if (err < 0) {
|
||||
auto s_err = pxd_mesgErrorCode(err);
|
||||
@ -354,17 +367,19 @@ private:
|
||||
}
|
||||
} else {
|
||||
if (std::ranges::size(func_name)) {
|
||||
logDebug("XCLIB API call ('{}') finished successfully (exitcode = {})", func_name, err);
|
||||
// logDebug("XCLIB API call ('{}') finished successfully (exitcode = {})", func_name, err);
|
||||
logMessage(log_level, "XCLIB API call ('{}') finished successfully (exitcode = {})", func_name, err);
|
||||
} else {
|
||||
logDebug("XCLIB API call finished successfully (exitcode = {})", err);
|
||||
// logDebug("XCLIB API call finished successfully (exitcode = {})", err);
|
||||
logMessage(log_level, "XCLIB API call finished successfully (exitcode = {})", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <bool NOEXCEPT = false>
|
||||
void xclibApiCall(int err)
|
||||
void xclibApiCall(int err, loglevel_t log_level = spdlog::level::debug)
|
||||
{
|
||||
xclibApiCall<NOEXCEPT>(err, std::string_view(""));
|
||||
xclibApiCall<NOEXCEPT>(err, std::string_view(""), log_level);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user