Commit 85e2930e authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Core:

* Added CtControl::SaveOpen/CloseErrors for more specific error desc.
* Fixed CtSaving missing/incomplete exception catch points for
  open/write/close operations, not properly reporting a saving error
* Restored multiple save file open retries before throwing exception
* Allow CtSaving::writeFrame to save concatenated frames (stripes)
  as a single image
* Fixed CtImage Roi software rotation/flip code not taking into account
  current hardware binning
* Added Roi::complementX/Y helper to simplify getFlipped/[Un]Rotated

Espia:
* Improved Espia::Dev::open error message when
  driver is not loaded or board not present
* Perform Espia::Acq::setupSGRoi only if the corresponding
  memory buffers have been already allocated

Frelon:
* Implemented Frelon::Camera::waitIdleStatus, to be called
  after a Stop command is sent, using getMaxIdleWaitTime,
  which includes in the internal exposure time if 2.x <= FW < 3.0
* Added Frelon::Camera::syncRegsBadHTD to improve
  initialisation sequence if 2.x <= FW < 3.0:
  + If camera is not idle and not in ExtGate, send a Stop command
  + Always attempt to wait for idle status
  + Force an Aurora link reset on startup to trigger
    FPGA reconfiguration, solving blocking problems
  + Added Frelon::Model::hasHTDCmd (from v2.0c on), used to force
    hardware trigger enabled
* Improved Frelon::Camera::setExpTime:
  + Better error detection and simpler sequence
  + Round to MinExp (1 us) if positive but less than that
  + Only use Microseconds TimeUnit if Milliseconds is not precise enough
* Do not start Frelon::Camera if already started
* Better debug around waitIdleStatus in Frelon::Camera::stop,
  printing real time spent waiting
* Activate Espia SG Roi in Frelon::RoiCtrlObj::checkEspiaRoi only
  if Camera Roi is different than requested one
* Export to FrelonAcq new CtSaving feature allowing to manually
  save multiple concatenated frames (stripes) as a single image

TACO:
* Implemented TACO call DevCcdWriteAll, saving concatenated
  frames (stripes) as a single image
* Added espia_dev_nb resource to allow multiple Espia boards

TANGO/Common:
* Added CtControl SaveOpen/CloseError codes in LimaCCDs state desc.
parent 728c5166
taco @ 276788c6
Subproject commit 177ec22e4d3fd5a383637c82bb7909083843d29d
Subproject commit 276788c6ce99721b0fd90a9a49e3eff3dbfbc80b
tango @ 0b74ced4
Subproject commit 318aa2893adfb1b09bb778ac8e9a824a442d0c54
Subproject commit 0b74ced4dfdb21a5d463e0e872c119a67c59d80b
espia @ 79bca8f0
Subproject commit 9a0c595243485361512cca621b7cb27e038b538c
Subproject commit 79bca8f0ced5db93bcf425df92d56c1031c8d6b0
frelon @ 2f8a47a2
Subproject commit eb40b17b8da1be0fba2951e345787ca522fbeec5
Subproject commit 2f8a47a27367024df80b8424247214540ca3881f
maxipix @ 4509ef11
Subproject commit c6e03c1267b04aab0dd45abc3671387463f6af08
Subproject commit 4509ef11e4e3b79259bd5f26cc95578e5238dd82
......@@ -466,10 +466,10 @@ class LIMACORE_API Roi
Roi getBinned(const Bin& b) const;
Roi getUnbinned(const Bin& b) const;
Roi getFlipped(const Flip& f,const Size &image_size) const;
Roi getFlipped(const Flip& f, const Size& image_size) const;
Roi getRotated(RotationMode r,const Size &image_size) const;
Roi getUnrotated(RotationMode r,const Size &image_size) const;
Roi getRotated(RotationMode r, const Size& image_size) const;
Roi getUnrotated(RotationMode r, const Size& image_size) const;
bool isActive() const;
......@@ -483,6 +483,9 @@ class LIMACORE_API Roi
static bool isValidCoord(int i);
static Point checkCorner(const Point& TopLeft);
int complementX(const Size& image_size, bool swapped=false) const;
int complementY(const Size& image_size, bool swapped=false) const;
Point m_top_left;
Size m_size;
};
......@@ -578,77 +581,77 @@ inline Roi Roi::getUnbinned(const Bin& b) const
return Roi(m_top_left * b, Size(m_size * b));
}
inline Roi Roi::getFlipped(const Flip& f,const Size &image_size) const
{
int x,y;
if(f.x)
x = image_size.getWidth() - m_top_left.x - m_size.getWidth();
else
x = m_top_left.x;
if(f.y)
y = image_size.getHeight() - m_top_left.y - m_size.getHeight();
else
y = m_top_left.y;
return Roi(x,y,m_size.getWidth(),m_size.getHeight());
}
inline Roi Roi::getRotated(RotationMode rotationMode,const Size &image_size) const
{
int x,y;
Size aSize = m_size;
switch(rotationMode)
{
case Rotation_90:
x = image_size.getHeight() - m_top_left.y - m_size.getHeight();
y = m_top_left.x;
aSize.swapDimensions();
break;
case Rotation_180:
x = image_size.getWidth() - m_top_left.x - m_size.getWidth();
y = image_size.getHeight() - m_top_left.y - m_size.getHeight();
break;
case Rotation_270:
x = m_top_left.y;
y = image_size.getWidth() - m_top_left.x - m_size.getWidth();
aSize.swapDimensions();
break;
default:
x = m_top_left.x,y = m_top_left.y;
aSize = m_size;
break;
}
return Roi(x,y,aSize.getWidth(),aSize.getHeight());
}
inline Roi Roi::getUnrotated(RotationMode rotationMode,const Size &image_size) const
{
int x,y;
Size aSize = m_size;
switch(rotationMode)
{
case Rotation_90:
x = m_top_left.y;
y = image_size.getHeight() - m_top_left.x - m_size.getWidth();
aSize.swapDimensions();
break;
case Rotation_180:
x = image_size.getWidth() - m_top_left.x - m_size.getWidth();
y = image_size.getHeight() - m_top_left.y - m_size.getHeight();
break;
case Rotation_270:
x = image_size.getWidth() - m_top_left.y - m_size.getHeight();
y = m_top_left.x;
aSize.swapDimensions();
break;
default:
x = m_top_left.x,y = m_top_left.y;
aSize = m_size;
break;
}
return Roi(x,y,aSize.getWidth(),aSize.getHeight());
inline int Roi::complementX(const Size& image_size, bool swapped) const
{
int width = swapped ? image_size.getHeight() : image_size.getWidth();
return width - m_top_left.x - m_size.getWidth();
}
inline int Roi::complementY(const Size& image_size, bool swapped) const
{
int height = swapped ? image_size.getWidth() : image_size.getHeight();
return height - m_top_left.y - m_size.getHeight();
}
inline Roi Roi::getFlipped(const Flip& f, const Size& image_size) const
{
int x = f.x ? complementX(image_size) : m_top_left.x;
int y = f.y ? complementY(image_size) : m_top_left.y;
return Roi(Point(x, y), m_size);
}
inline Roi Roi::getRotated(RotationMode rotationMode,
const Size& image_size) const
{
int x, y;
Size size = m_size;
switch (rotationMode) {
case Rotation_90:
x = complementY(image_size);
y = m_top_left.x;
size.swapDimensions();
break;
case Rotation_180:
x = complementX(image_size);
y = complementY(image_size);
break;
case Rotation_270:
x = m_top_left.y;
y = complementX(image_size);
size.swapDimensions();
break;
default:
x = m_top_left.x;
y = m_top_left.y;
}
return Roi(Point(x, y), size);
}
inline Roi Roi::getUnrotated(RotationMode rotationMode,
const Size& image_size) const
{
int x, y;
Size size = m_size;
switch (rotationMode) {
case Rotation_90:
x = m_top_left.y;
y = complementX(image_size, true);
size.swapDimensions();
break;
case Rotation_180:
x = complementX(image_size, false);
y = complementY(image_size, false);
break;
case Rotation_270:
x = complementY(image_size, true);
y = m_top_left.x;
size.swapDimensions();
break;
default:
x = m_top_left.x;
y = m_top_left.y;
}
return Roi(Point(x, y), size);
}
inline bool Roi::isActive() const
......
......@@ -239,10 +239,10 @@ using namespace lima;
Roi getBinned(const Bin& b) const;
Roi getUnbinned(const Bin& b) const;
Roi getFlipped(const Flip& f,const Size &image_size) const;
Roi getFlipped(const Flip& f,const Size& image_size) const;
Roi getRotated(RotationMode r,const Size &image_size) const;
Roi getUnrotated(RotationMode r,const Size &image_size) const;
Roi getRotated(RotationMode r,const Size& image_size) const;
Roi getUnrotated(RotationMode r,const Size& image_size) const;
bool isActive() const;
......
......@@ -96,7 +96,8 @@ namespace lima
};
enum ErrorCode {NoError,
SaveUnknownError,SaveAccessError,SaveOverwriteError,SaveDiskFull,SaveOverun,
SaveUnknownError,SaveOpenError,SaveCloseError,
SaveAccessError,SaveOverwriteError,SaveDiskFull,SaveOverun,
ProcessingOverun,
CameraError};
......@@ -243,6 +244,8 @@ namespace lima
{
case CtControl::NoError: desc = "No error"; break;
case CtControl::SaveUnknownError: desc = "Saving error"; break;
case CtControl::SaveOpenError: desc = "Save file open error"; break;
case CtControl::SaveCloseError: desc = "Save file close error"; break;
case CtControl::SaveAccessError: desc = "Save access error"; break;
case CtControl::SaveOverwriteError: desc = "Save overwrite error"; break;
case CtControl::SaveDiskFull: desc = "Save disk full"; break;
......
......@@ -91,12 +91,12 @@ class LIMACORE_API CtHwBinRoiFlip {
void resetFlip();
void reset();
const Bin& getBin() const { return m_bin; }
const Roi& getSetRoi() const { return m_set_roi; }
const Roi& getRealRoi() const { return m_real_roi; }
const Size& getSize() const { return m_size; }
const Size& getMaxSize() const { return m_max_size; }
const Flip& getFlip() const { return m_flip; }
const Bin& getBin() const { return m_bin; }
const Roi& getSetRoi() const { return m_set_roi; }
const Roi& getRealRoi() const { return m_real_roi; }
const Size& getSize() const { return m_size; }
const Size& getMaxRoiSize() const { return m_max_roi.getSize(); }
const Flip& getFlip() const { return m_flip; }
void apply();
......
......@@ -158,7 +158,9 @@ namespace lima {
// --- misc
void clear();
void writeFrame(int frame_nr = -1); ///< frame_nr == -1 => last frame
// frame_nr == -1 => last frame
void writeFrame(int frame_nr = -1, int nb_frames = 1);
void setStreamActive(int stream_idx, bool active);
void getStreamActive(int stream_idx, bool& active) const;
......
......@@ -61,7 +61,8 @@ using namespace lima;
};
enum ErrorCode {NoError,
SaveAccessError,SaveDiskFull,SaveOverun,
SaveUnknownError,SaveOpenError,SaveCloseError,
SaveAccessError,SaveOverwriteError,SaveDiskFull,SaveOverun,
ProcessingOverun,
CameraError};
......
......@@ -83,7 +83,7 @@ using namespace lima;
const Roi& getSetRoi() const;
const Roi& getRealRoi() const;
const Size& getSize() const;
const Size& getMaxSize() const;
const Size& getMaxRoiSize() const;
const Flip& getFlip() const;
void apply();
......
......@@ -220,7 +220,7 @@ using namespace lima;
// --- misc
void clear();
void writeFrame(int frame_nr = -1);
void writeFrame(int frame_nr = -1, int nb_frames = 1);
void setStreamActive(int stream_idx, bool active);
void getStreamActive(int stream_idx, bool& active /Out/) const;
......
......@@ -565,19 +565,20 @@ void CtImage::setRoi(Roi& roi)
break;
case HardOnly:
{
const Size& max_roi_size = m_hw->getMaxRoiSize();
// Remove the software Rotation to hardware Roi
RotationMode aSoftwareRotation = m_sw->getRotation();
roi = roi.getUnrotated(aSoftwareRotation,m_hw->getMaxSize());
roi = roi.getUnrotated(aSoftwareRotation,max_roi_size);
// Remove the software Flip to hardware Roi
const Flip &aSoftwareFlip = m_sw->getFlip();
roi = roi.getFlipped(aSoftwareFlip,m_hw->getMaxSize());
roi = roi.getFlipped(aSoftwareFlip,max_roi_size);
m_hw->setRoi(roi, false);
// Add Flip
roi = roi.getFlipped(aSoftwareFlip,m_hw->getMaxSize());
roi = roi.getFlipped(aSoftwareFlip,max_roi_size);
// Add Rotation
roi = roi.getRotated(aSoftwareRotation,m_hw->getMaxSize());
roi = roi.getRotated(aSoftwareRotation,max_roi_size);
}
break;
case HardAndSoft:
......@@ -627,12 +628,14 @@ void CtImage::_setHSRoi(const Roi &roi)
roi_unbin= roi.getUnbinned(bin_total);
roi_by_hw= roi_unbin.getBinned(bin_by_hw);
const Size& max_roi_size = m_hw->getMaxRoiSize();
// Remove the rotation to hardware Roi
roi_by_hw= roi_by_hw.getUnrotated(aSoftwareRotation,m_hw->getMaxSize());
roi_by_hw= roi_by_hw.getUnrotated(aSoftwareRotation,max_roi_size);
// Remove the software Flip to hardware Roi
const Flip &aSoftwareFlip = m_sw->getFlip();
roi_by_hw= roi_by_hw.getFlipped(aSoftwareFlip,m_hw->getMaxSize());
roi_by_hw= roi_by_hw.getFlipped(aSoftwareFlip,max_roi_size);
roi_set_hw= roi_by_hw;
......@@ -643,9 +646,9 @@ void CtImage::_setHSRoi(const Roi &roi)
m_sw->resetRoi();
} else {
// Apply software flip to hardware roi
roi_set_hw = roi_set_hw.getFlipped(aSoftwareFlip,m_hw->getMaxSize());
roi_set_hw = roi_set_hw.getFlipped(aSoftwareFlip,max_roi_size);
//Apply software rotation to hardware roi
roi_set_hw = roi_set_hw.getRotated(aSoftwareRotation,m_hw->getMaxSize());
roi_set_hw = roi_set_hw.getRotated(aSoftwareRotation,max_roi_size);
roi_by_sw= roi_set_hw.subRoiAbs2Rel(roi_by_hw);
roi_by_sw= roi_by_sw.getBinned(bin_by_sw);
m_sw->setRoi(roi_by_sw);
......@@ -667,8 +670,9 @@ void CtImage::setFlip(Flip &flip)
RotationMode currentRotation;
getRotation(currentRotation);
currentRoi = currentRoi.getUnrotated(currentRotation,m_hw->getMaxSize());
currentRoi = currentRoi.getFlipped(currentFlip,m_hw->getMaxSize());
const Size& max_roi_size = m_hw->getMaxRoiSize();
currentRoi = currentRoi.getUnrotated(currentRotation,max_roi_size);
currentRoi = currentRoi.getFlipped(currentFlip,max_roi_size);
if(!flip.x && ! flip.y)
_resetFlip();
......@@ -689,8 +693,8 @@ void CtImage::setFlip(Flip &flip)
}
//Set the previous roi
resetRoi();
currentRoi = currentRoi.getFlipped(flip,m_hw->getMaxSize());
currentRoi = currentRoi.getRotated(currentRotation,m_hw->getMaxSize());
currentRoi = currentRoi.getFlipped(flip,max_roi_size);
currentRoi = currentRoi.getRotated(currentRotation,max_roi_size);
setRoi(currentRoi);
}
......@@ -706,13 +710,14 @@ void CtImage::setRotation(RotationMode rotation)
Bin currentBin;
getBin(currentBin);
currentRoi = currentRoi.getUnrotated(currentRotation,m_hw->getMaxSize());
const Size& max_roi_size = m_hw->getMaxRoiSize();
currentRoi = currentRoi.getUnrotated(currentRotation,max_roi_size);
m_sw->setRotation(rotation);
resetRoi();
currentRoi = currentRoi.getRotated(rotation,m_hw->getMaxSize());
currentRoi = currentRoi.getRotated(rotation,max_roi_size);
setRoi(currentRoi);
}
......@@ -804,13 +809,14 @@ void CtImage::getRoi(Roi& roi) const
DEB_MEMBER_FUNCT();
if (m_hw->hasRoiCapability()) {
const Size& max_roi_size = m_hw->getMaxRoiSize();
Roi roi_by_hw= m_hw->getRealRoi();
// Add software Flip to Roi
const Flip &aSoftwareFlip = m_sw->getFlip();
roi_by_hw = roi_by_hw.getFlipped(aSoftwareFlip,m_hw->getMaxSize());
roi_by_hw = roi_by_hw.getFlipped(aSoftwareFlip,max_roi_size);
// Add rotation to Roi
RotationMode aSoftRotation = m_sw->getRotation();
roi_by_hw = roi_by_hw.getRotated(aSoftRotation,m_hw->getMaxSize());
roi_by_hw = roi_by_hw.getRotated(aSoftRotation,max_roi_size);
Roi roi_by_sw= m_sw->getRoi();
Bin bin_by_sw= m_sw->getBin();
......
......@@ -1020,7 +1020,7 @@ void CtSaving::clear()
}
void CtSaving::writeFrame(int aFrameNumber)
void CtSaving::writeFrame(int aFrameNumber, int aNbFrames)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(aFrameNumber);
......@@ -1054,7 +1054,7 @@ void CtSaving::writeFrame(int aFrameNumber)
wait_and_cleanup_ready_flag.toggleReadyFlag();
Data anImage2Save;
m_ctrl.ReadImage(anImage2Save,aFrameNumber);
m_ctrl.ReadImage(anImage2Save,aFrameNumber,aNbFrames);
// Saving
HeaderMap header;
......@@ -1296,25 +1296,41 @@ void CtSaving::SaveContainer::writeFile(Data &aData,HeaderMap &aHeader)
if(vfs.f_favail < 1024 || vfs.f_bavail < 1024)
{
m_stream.setSavingError(CtControl::SaveDiskFull);
close();
try {
close();
} catch (...) {
}
THROW_CTL_ERROR(Error) << "Disk full!!!";
}
};
#endif
close();
m_stream.setSavingError(CtControl::SaveUnknownError);
try {
close();
} catch (...) {
}
THROW_CTL_ERROR(Error) << "Save unknown error";
}
catch(...)
{
m_stream.setSavingError(CtControl::SaveUnknownError);
try {
close();
} catch (...) {
}
THROW_CTL_ERROR(Error) << "Save unknown error";
}
if(++m_written_frames == pars.framesPerFile)
close();
if(++m_written_frames == pars.framesPerFile) {
try {
close();
} catch (...) {
m_stream.setSavingError(CtControl::SaveCloseError);
THROW_CTL_ERROR(Error) << "Save file close error";
}
}
struct timeval end_write;
gettimeofday(&end_write, NULL);
......@@ -1393,15 +1409,20 @@ void CtSaving::SaveContainer::open(const CtSaving::Parameters &pars)
else if(pars.overwritePolicy == Overwrite)
openFlags |= std::ios_base::trunc;
std::string error_desc;
for(int nbTry = 0;nbTry < 5;++nbTry)
{
bool succeed = false;
try {
succeed = _open(aFileName,openFlags);
} catch (std::ios_base::failure &error) {
std::string output;
output = "Failure opening " + aFileName + ":" + error.what();
THROW_CTL_ERROR(Error) << output;
error_desc = error.what();
DEB_WARNING() << "Could not open " << aFileName << ": "
<< error_desc;
} catch (...) {
error_desc = "Unknown error";
DEB_WARNING() << "Could not open " << aFileName << ": "
<< error_desc;
}
if(!succeed)
......@@ -1422,6 +1443,16 @@ void CtSaving::SaveContainer::open(const CtSaving::Parameters &pars)
break;
}
}
if (!m_file_opened)
{
m_stream.setSavingError(CtControl::SaveOpenError);
std::string output;
output = "Failure opening " + aFileName;
if (!error_desc.empty())
output += ": " + error_desc;
THROW_CTL_ERROR(Error) << output;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment