From 66e0b6c71e31cba697b403fe9b52d6a32b8ccfd7 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Fri, 20 Dec 2024 11:07:29 +0300 Subject: [PATCH] ... --- raptor_eagle_acqproc.cpp | 5 +++- raptor_eagle_ccd.cpp | 58 +++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/raptor_eagle_acqproc.cpp b/raptor_eagle_acqproc.cpp index 4fdaaf5..957398d 100644 --- a/raptor_eagle_acqproc.cpp +++ b/raptor_eagle_acqproc.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "raptor_eagle_ccd.h" @@ -241,7 +242,9 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptrfilename.c_str(), "Original filename", &status); + // fits_update_key_str(fitsFilePtr, "FILE", _acqParams->filename.c_str(), "Original filename", &status); + std::filesystem::path pt = _acqParams->filename; + fits_update_key_str(fitsFilePtr, "FILE", pt.filename().c_str(), "Original filename", &status); fits_write_date(fitsFilePtr, &status); diff --git a/raptor_eagle_ccd.cpp b/raptor_eagle_ccd.cpp index f4fc88d..0299fa6 100644 --- a/raptor_eagle_ccd.cpp +++ b/raptor_eagle_ccd.cpp @@ -965,6 +965,35 @@ void RaptorEagleCCD::startAquisition() throw std::system_error(RaptorEagleCCDError::ERROR_EXT_TRIGGER_MODE); } + // check filesystem permissions + std::string fname = (*this)[CAMERA_ATTR_FITS_FILENAME]; + + std::error_code ec; + std::filesystem::path pt(fname); + + if (pt.filename().empty()) { + fname = ""; + } else { + pt = pt.parent_path(); + if (pt.empty()) { + pt = "."; + } + + auto pt_cn = std::filesystem::canonical(pt, ec); + if (ec) { + logError("Invalid FITS-image filename path: {}", pt.c_str()); + throw std::system_error(RaptorEagleCCDError::ERROR_INVALID_PATH); + } + + // still only for POSIX OSes + int res = access(pt_cn.c_str(), W_OK | X_OK); + if (res == -1) { + logError("Invalid FITS-image path! Insufficient filesystem permissions!"); + throw std::system_error(RaptorEagleCCDError::ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS); + } + + fname = pt_cn; // use canonical file path + } logInfo("Start acquisition process ..."); @@ -988,32 +1017,13 @@ void RaptorEagleCCD::startAquisition() .tecSetPoint = (*this)[CAMERA_ATTR_TECPOINT], .tecState = (*this)[CAMERA_ATTR_TECSTATE] == CAMERA_ATTR_TECSTATE_ON ? true : false, .pcbTemp = (*this)[CAMERA_ATTR_PCB_TEMP], - .filename = (*this)[CAMERA_ATTR_FITS_FILENAME], + // .filename = (*this)[CAMERA_ATTR_FITS_FILENAME], + .filename = fname, .templateFilename = (*this)[CAMERA_ATTR_FITS_TEMPLATE], .permanentKeywords = _permanentFitsKeywords, // copy .currentKeywords = std::move(_currentFitsKeywords) // move!!! })); - // check filesystem permissions - std::error_code ec; - std::filesystem::path pt(acq_pars->filename); - pt = pt.parent_path(); - if (pt.empty()) { - pt = "."; - } - - auto pt_cn = std::filesystem::canonical(pt, ec); - if (ec) { - logError("Invalid FITS-image filename path: {}", pt.c_str()); - throw std::system_error(RaptorEagleCCDError::ERROR_INVALID_PATH); - } - - int res = access(pt_cn.c_str(), W_OK | X_OK); - if (res == -1) { - logError("Invalid FITS-image path! Insufficient filesystem permissions!"); - throw std::system_error(RaptorEagleCCDError::ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS); - } - // adjust geometry @@ -1222,10 +1232,10 @@ void RaptorEagleCCD::initAttrComm() auto sptr = it->lock(); auto st = sptr->status(); if (st.substr(0, 3) == "ACQ") { // if the camera is acquiring then - s_head = st + ", "; // return it at the beginning of the status string + s_head = st + ","; // return it at the beginning of the status string } else { std::ranges::copy(st, std::back_inserter(s)); - s += ", "; + s += ","; } ++it; } @@ -1235,7 +1245,7 @@ void RaptorEagleCCD::initAttrComm() if (!s.empty() || !s_head.empty()) { s = s_head + s; if (_acqProcesses.size() == 1) { - s.resize(s.size() - 2); // delete trailing ", " + s.resize(s.size() - 1); // delete trailing "," } } else { s = std::string{CAMERA_ATTR_CAMERA_STATUS_IDLE.begin(), CAMERA_ATTR_CAMERA_STATUS_IDLE.end()};