diff --git a/raptor_eagle_acqproc.cpp b/raptor_eagle_acqproc.cpp index 9dac956..255e950 100644 --- a/raptor_eagle_acqproc.cpp +++ b/raptor_eagle_acqproc.cpp @@ -99,8 +99,10 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptrroiWidth and _acqParams->roiHeight are expected in CCD pixels (not binned)!!! + // auto div = std::div(_acqParams->roiWidth - _acqParams->roiStartX, _acqParams->binX); auto div = std::div(_acqParams->roiWidth, _acqParams->binX); auto dimx = div.quot + (div.rem ? 1 : 0); + // div = std::div(_acqParams->roiHeight - _acqParams->roiStartY, _acqParams->binY); div = std::div(_acqParams->roiHeight, _acqParams->binY); auto dimy = div.quot + (div.rem ? 1 : 0); @@ -111,12 +113,21 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptr_dimCCD[0]); _imageBufferRows = ldiv.quot + (ldiv.rem ? 1 : 0); + bool gap = false; + if ((_acqParams->roiWidth + _acqParams->roiStartX) < _manager->_dimCCD[0]) { + /* IT SEEMS IF MAX ROI X-COORDINATE IS LESS THAN CCD DIM + * EAGLE CAMERA CONTROLLER SETUP READING FOR WIDTH+1 ROI!!! */ + gap = true; + ++_imageBufferRows; + } + // _imageBufferRows = static_cast(std::ceil(npix / _manager->_dimCCD[0])); // read size size_t sz = _imageBufferRows * _manager->_dimCCD[0]; try { + // sz = _manager->_dimCCD[0] * _manager->_dimCCD[1]; if (_imageBufferSize < sz) { _manager->logDebug("Reallocate image buffer to {} elements", sz); _imageBufferSize = sz; @@ -126,6 +137,9 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptr_cameraUnitmap, _imageBufferRows, (void*)_imageBuffer.get(), _imageBufferSize, color_space); + // _manager->xclibApiCall(pxd_readushort(_manager->_cameraUnitmap, 1, 0, 0, -1, -1, + // (ushort*)_imageBuffer.get(), _imageBufferSize, (char*)color_space), + // log_str); _manager->xclibApiCall(pxd_readushort(_manager->_cameraUnitmap, 1, 0, 0, -1, _imageBufferRows, (ushort*)_imageBuffer.get(), _imageBufferSize, (char*)color_space), log_str); @@ -170,7 +184,19 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptrlogDebug("Write {} pixels to the HDU ...", npix); - fits_write_img(fitsFilePtr, TUSHORT, 1, npix, (void*)_imageBuffer.get(), &status); + if (gap) { + /* IT SEEMS IF MAX ROI X-COORDINATE IS LESS THAN CCD DIM + * EAGLE CAMERA CONTROLLER SETUP READING FOR WIDTH+1 ROI!!! + * SO ONE NEEDS TO WRITE IMAGE PER ROW WITH SKIPPING EXTRA PIXEL + * AT THE END OF EACH ROW + */ + auto ptr = _imageBuffer.get(); + for (size_t i = 0; i < dimy; ++i) { + fits_write_img(fitsFilePtr, TUSHORT, i * dimx + 1, dimx, _imageBuffer.get(), &status); + } + } else { + fits_write_img(fitsFilePtr, TUSHORT, 1, npix, (void*)_imageBuffer.get(), &status); + } // helper to convert std::string_view to C-lang null-terminated string diff --git a/raptor_eagle_ccd.cpp b/raptor_eagle_ccd.cpp index fd00d73..083daa4 100644 --- a/raptor_eagle_ccd.cpp +++ b/raptor_eagle_ccd.cpp @@ -967,21 +967,33 @@ void RaptorEagleCCD::startAquisition() // adjust geometry - auto dv = std::div(_dimCCD[0] - acq_pars->roiStartX, acq_pars->binX); - auto width_max = dv.quot + (dv.rem ? 1 : 0); + // auto dv = std::div(_dimCCD[0] - acq_pars->roiStartX, acq_pars->binX); + // auto width_max = dv.quot + (dv.rem ? 1 : 0); - dv = std::div(_dimCCD[1] - acq_pars->roiStartY, acq_pars->binY); - auto height_max = dv.quot + (dv.rem ? 1 : 0); + // dv = std::div(_dimCCD[1] - acq_pars->roiStartY, acq_pars->binY); + // auto height_max = dv.quot + (dv.rem ? 1 : 0); - if (acq_pars->roiWidth > width_max) { - acq_pars->roiWidth = width_max; + // if (acq_pars->roiWidth > width_max) { + // // acq_pars->roiWidth = width_max; + // logDebug("Adjust ROI width to {}", acq_pars->roiWidth); + // // (*this)[CAMERA_ATTR_ROI_WIDTH] = width_max; + // } + // if (acq_pars->roiHeight > height_max) { + // // acq_pars->roiHeight = height_max; + // logDebug("Adjust ROI height to {}", acq_pars->roiHeight); + // // (*this)[CAMERA_ATTR_ROI_HEIGHT] = height_max; + // } + + auto xmax = acq_pars->roiStartX + acq_pars->roiWidth; + auto ymax = acq_pars->roiStartY + acq_pars->roiHeight; + + if (xmax > _dimCCD[0]) { + acq_pars->roiWidth = _dimCCD[0] - acq_pars->roiStartX; logDebug("Adjust ROI width to {}", acq_pars->roiWidth); - (*this)[CAMERA_ATTR_ROI_WIDTH] = width_max; } - if (acq_pars->roiHeight > height_max) { - acq_pars->roiHeight = height_max; + if (ymax > _dimCCD[1]) { + acq_pars->roiHeight = _dimCCD[1] - acq_pars->roiStartY; logDebug("Adjust ROI height to {}", acq_pars->roiHeight); - (*this)[CAMERA_ATTR_ROI_HEIGHT] = height_max; }