Commit b0707e35 authored by Laurent Claustre's avatar Laurent Claustre

New Saving format HDF5, based on version 1.8.12

Thanks to Goeffrey Mant for the nice job !

* Hdf5 third-party can be compiled now from scratch and installed as deps
* fixed with Geoff some bugs in CtSaving_HDF5

Made some progress, after discussion with Armando Sole and jerome Kieffer
improve the group/dataset organisation.

Modify CtSaving::_prepare to pass CtControl (needed for Hdf5)

Add Multiset saving mode

Close saving file at the end of acquisition or after a stopAcq

improved hdf5 format, acq/image/detinfo parameters now saved

added a calculate_chunk() function to optimized chunking vs image size

fixed scalar attribute and scalar datatset instead of array
parent 282344d1
...@@ -109,3 +109,6 @@ ...@@ -109,3 +109,6 @@
[submodule "camera/aviex"] [submodule "camera/aviex"]
path = camera/aviex path = camera/aviex
url = git://github.com/esrf-bliss/Lima-camera-aviex.git url = git://github.com/esrf-bliss/Lima-camera-aviex.git
[submodule "third-party/hdf5"]
path = third-party/hdf5
url = git://github.com/esrf-bliss/hdf5.git
...@@ -77,6 +77,13 @@ ifneq ($(COMPILE_TIFF_SAVING),0) ...@@ -77,6 +77,13 @@ ifneq ($(COMPILE_TIFF_SAVING),0)
CORE_LDLIBS += -ltiff CORE_LDLIBS += -ltiff
endif endif
ifneq ($(COMPILE_HDF5_SAVING),0)
PROCESSOR_TYPE := $(shell uname -m)
CORE_LDFLAGS += -L../third-party/hdf5/src/.libs -Wl,-rpath=$(shell pwd)/../third-party/hdf5/src/.libs
CORE_LDFLAGS += -L../third-party/hdf5/c++/src/.libs -Wl,-rpath=$(shell pwd)/../third-party/hdf5/c++/src/.libs
CORE_LDLIBS += -lhdf5_cpp -lhdf5
endif
ifneq ($(COMPILE_CONFIG),0) ifneq ($(COMPILE_CONFIG),0)
CORE_LDLIBS += -L../third-party/libconfig/lib/.libs -Wl,-rpath=$(shell pwd)/../third-party/libconfig/lib/.libs -lconfig++ CORE_LDLIBS += -L../third-party/libconfig/lib/.libs -Wl,-rpath=$(shell pwd)/../third-party/libconfig/lib/.libs -lconfig++
endif endif
...@@ -543,7 +550,7 @@ endif ...@@ -543,7 +550,7 @@ endif
############################ ############################
ifneq ($(COMPILE_POINTGREY),0) ifneq ($(COMPILE_POINTGREY),0)
POINTGREY_LDFLAGS := $(LDFLAGS) POINTGREY_LDFLAGS := $(LDFLAGS) -L../camera/pointgrey/sdk/lib
POINTGREY_LDLIBS := $(LDLIBS) -lflycapture POINTGREY_LDLIBS := $(LDLIBS) -lflycapture
pointgrey-name := pointgrey pointgrey-name := pointgrey
......
...@@ -52,6 +52,7 @@ COMPILE_NXS_SAVING=0 ...@@ -52,6 +52,7 @@ COMPILE_NXS_SAVING=0
COMPILE_FITS_SAVING=0 COMPILE_FITS_SAVING=0
COMPILE_EDFGZ_SAVING=0 COMPILE_EDFGZ_SAVING=0
COMPILE_TIFF_SAVING=0 COMPILE_TIFF_SAVING=0
COMPILE_HDF5_SAVING=0
COMPILE_CONFIG=1 COMPILE_CONFIG=1
COMPILE_GLDISPLAY=0 COMPILE_GLDISPLAY=0
LINK_STRICT_VERSION=0 LINK_STRICT_VERSION=0
...@@ -61,6 +62,6 @@ export COMPILE_CORE COMPILE_SPS_IMAGE COMPILE_SIMULATOR \ ...@@ -61,6 +62,6 @@ export COMPILE_CORE COMPILE_SPS_IMAGE COMPILE_SIMULATOR \
COMPILE_MYTHEN COMPILE_UEYE COMPILE_XH COMPILE_XSPRESS3 COMPILE_ULTRA COMPILE_XPAD COMPILE_PERKINELMER \ COMPILE_MYTHEN COMPILE_UEYE COMPILE_XH COMPILE_XSPRESS3 COMPILE_ULTRA COMPILE_XPAD COMPILE_PERKINELMER \
COMPILE_ANDOR COMPILE_PHOTONICSCIENCE COMPILE_PCO COMPILE_MARCCD COMPILE_DEXELA\ COMPILE_ANDOR COMPILE_PHOTONICSCIENCE COMPILE_PCO COMPILE_MARCCD COMPILE_DEXELA\
COMPILE_POINTGREY COMPILE_IMXPAD COMPILE_RAYONIXHS COMPILE_AVIEX COMPILE_CBF_SAVING COMPILE_NXS_SAVING \ COMPILE_POINTGREY COMPILE_IMXPAD COMPILE_RAYONIXHS COMPILE_AVIEX COMPILE_CBF_SAVING COMPILE_NXS_SAVING \
COMPILE_FITS_SAVING COMPILE_EDFGZ_SAVING COMPILE_TIFF_SAVING COMPILE_CONFIG\ COMPILE_FITS_SAVING COMPILE_EDFGZ_SAVING COMPILE_TIFF_SAVING COMPILE_HDF5_SAVING COMPILE_CONFIG\
COMPILE_GLDISPLAY \ COMPILE_GLDISPLAY \
LINK_STRICT_VERSION LINK_STRICT_VERSION
...@@ -56,7 +56,8 @@ namespace lima { ...@@ -56,7 +56,8 @@ namespace lima {
enum ManagedMode enum ManagedMode
{ {
Software, ///< Saving will be managed by Lima Core (Control) Software, ///< Saving will be managed by Lima Core (Control)
Hardware ///< Saving will be managed by Hardware or Camera SDK Hardware, ///< Saving will be managed by Hardware or Camera SDK
Camera ///< Saving will be managed by the Camera plugin
}; };
enum FileFormat enum FileFormat
...@@ -69,6 +70,7 @@ namespace lima { ...@@ -69,6 +70,7 @@ namespace lima {
FITS, ///< Flexible Image Transport Layer (NOST) FITS, ///< Flexible Image Transport Layer (NOST)
EDFGZ, ///< EDF format with gzip compression EDFGZ, ///< EDF format with gzip compression
TIFFFormat, ///< TIFF format TIFFFormat, ///< TIFF format
HDF5, ///< HDF5 format
}; };
enum SavingMode enum SavingMode
...@@ -83,6 +85,7 @@ namespace lima { ...@@ -83,6 +85,7 @@ namespace lima {
Abort, ///< Abort acquisition if file already exist Abort, ///< Abort acquisition if file already exist
Overwrite, ///< Overwrite old files Overwrite, ///< Overwrite old files
Append, ///< Append new data at the end of already existing files Append, ///< Append new data at the end of already existing files
MultiSet, ///< Like append but doesn't use file counter
}; };
struct LIMACORE_API Parameters struct LIMACORE_API Parameters
...@@ -187,6 +190,7 @@ namespace lima { ...@@ -187,6 +190,7 @@ namespace lima {
// --- misc // --- misc
void clear(); void clear();
void close();
// frame_nr == -1 => last frame // frame_nr == -1 => last frame
void writeFrame(int frame_nr = -1, int nb_frames = 1,bool synchronous = true); void writeFrame(int frame_nr = -1, int nb_frames = 1,bool synchronous = true);
...@@ -210,7 +214,7 @@ namespace lima { ...@@ -210,7 +214,7 @@ namespace lima {
void getStatistic(std::list<double>&) const; void getStatistic(std::list<double>&) const;
void getParameters(CtSaving::Parameters&) const; void getParameters(CtSaving::Parameters&) const;
void clear(); void clear();
void prepare(CtControl&);
/** @brief should return true if container has compression or /** @brief should return true if container has compression or
* havy task to do before saving * havy task to do before saving
* if return is true, getCompressionTask should return a Task * if return is true, getCompressionTask should return a Task
...@@ -231,6 +235,7 @@ namespace lima { ...@@ -231,6 +235,7 @@ namespace lima {
CtSaving::HeaderMap &aHeader, CtSaving::HeaderMap &aHeader,
FileFormat) = 0; FileFormat) = 0;
virtual void _clear() {}; virtual void _clear() {};
virtual void _prepare(CtControl&) {};
int m_written_frames; int m_written_frames;
Stream &m_stream; Stream &m_stream;
...@@ -239,6 +244,7 @@ namespace lima { ...@@ -239,6 +244,7 @@ namespace lima {
int m_statistic_size; int m_statistic_size;
mutable Cond m_cond; mutable Cond m_cond;
bool m_file_opened; bool m_file_opened;
long m_nb_frames_to_write;
}; };
friend class SaveContainer; friend class SaveContainer;
...@@ -266,7 +272,8 @@ namespace lima { ...@@ -266,7 +272,8 @@ namespace lima {
void setParameters(const Parameters& pars); void setParameters(const Parameters& pars);
void updateParameters(); void updateParameters();
void prepare(); void prepare(CtControl& ct);
void close();
void createSaveContainer(); void createSaveContainer();
void checkWriteAccess(); void checkWriteAccess();
void checkDirectoryAccess(const std::string&); void checkDirectoryAccess(const std::string&);
...@@ -354,7 +361,8 @@ namespace lima { ...@@ -354,7 +361,8 @@ namespace lima {
HwSavingCtrlObj* m_hwsaving; HwSavingCtrlObj* m_hwsaving;
_NewFrameSaveCBK* m_new_frame_save_cbk; _NewFrameSaveCBK* m_new_frame_save_cbk;
ManagedMode m_managed_mode; ///< two option either harware (manage by SDK,hardware) or software (Lima core) ManagedMode m_managed_mode; ///< two option either harware (manage by SDK,hardware) or software (Lima core)
std::string m_specific_hardware_format; std::string m_specific_hardware_format;
bool m_saving_stop;
Stream& getStream(int stream_idx) Stream& getStream(int stream_idx)
{ bool stream_ok = (stream_idx >= 0) && (stream_idx < m_nb_stream); { bool stream_ok = (stream_idx >= 0) && (stream_idx < m_nb_stream);
...@@ -386,7 +394,9 @@ namespace lima { ...@@ -386,7 +394,9 @@ namespace lima {
} }
// --- internal call // --- internal call
void _prepare(); void _prepare(CtControl&);
void _stop(CtControl&);
void _close();
void _getCommonHeader(HeaderMap&); void _getCommonHeader(HeaderMap&);
void _takeHeader(FrameHeaderMap::iterator&, HeaderMap& header, void _takeHeader(FrameHeaderMap::iterator&, HeaderMap& header,
bool keep_in_map); bool keep_in_map);
...@@ -426,6 +436,8 @@ namespace lima { ...@@ -426,6 +436,8 @@ namespace lima {
aFileFormatHumanPt = "EDF gzip";break; aFileFormatHumanPt = "EDF gzip";break;
case CtSaving::TIFFFormat: case CtSaving::TIFFFormat:
aFileFormatHumanPt = "TIFF";break; aFileFormatHumanPt = "TIFF";break;
case CtSaving::HDF5:
aFileFormatHumanPt = "HDF5";break;
default: default:
aFileFormatHumanPt = "RAW";break; aFileFormatHumanPt = "RAW";break;
} }
...@@ -445,6 +457,7 @@ namespace lima { ...@@ -445,6 +457,7 @@ namespace lima {
else if(buffer == "edf gzip") fileFormat = CtSaving::EDFGZ; else if(buffer == "edf gzip") fileFormat = CtSaving::EDFGZ;
else if(buffer == "raw") fileFormat = CtSaving::RAW; else if(buffer == "raw") fileFormat = CtSaving::RAW;
else if(buffer == "tiff") fileFormat = CtSaving::TIFFFormat; else if(buffer == "tiff") fileFormat = CtSaving::TIFFFormat;
else if(buffer == "hdf5") fileFormat = CtSaving::HDF5;
else else
{ {
std::ostringstream msg; std::ostringstream msg;
...@@ -494,6 +507,8 @@ namespace lima { ...@@ -494,6 +507,8 @@ namespace lima {
anOverwritePolicyHumanPt = "Overwrite";break; anOverwritePolicyHumanPt = "Overwrite";break;
case CtSaving::Append: case CtSaving::Append:
anOverwritePolicyHumanPt = "Append";break; anOverwritePolicyHumanPt = "Append";break;
case CtSaving::MultiSet:
anOverwritePolicyHumanPt = "MultiSet";break;
default: // Abort default: // Abort
anOverwritePolicyHumanPt = "Abort";break; anOverwritePolicyHumanPt = "Abort";break;
} }
...@@ -506,9 +521,10 @@ namespace lima { ...@@ -506,9 +521,10 @@ namespace lima {
std::transform(buffer.begin(),buffer.end(), std::transform(buffer.begin(),buffer.end(),
buffer.begin(),::tolower); buffer.begin(),::tolower);
if(buffer == "overwrite") overwritePolicy = CtSaving::Overwrite; if(buffer == "overwrite") overwritePolicy = CtSaving::Overwrite;
else if(buffer == "append") overwritePolicy = CtSaving::Append; else if(buffer == "append") overwritePolicy = CtSaving::Append;
else if(buffer == "abort") overwritePolicy = CtSaving::Abort; else if(buffer == "abort") overwritePolicy = CtSaving::Abort;
else if(buffer == "multiset") overwritePolicy = CtSaving::MultiSet;
else else
{ {
std::ostringstream msg; std::ostringstream msg;
......
...@@ -125,6 +125,7 @@ using namespace lima; ...@@ -125,6 +125,7 @@ using namespace lima;
FITS, FITS,
EDFGZ, EDFGZ,
TIFFFormat, TIFFFormat,
HDF5,
}; };
enum SavingMode { enum SavingMode {
...@@ -137,6 +138,7 @@ using namespace lima; ...@@ -137,6 +138,7 @@ using namespace lima;
Abort, Abort,
Overwrite, Overwrite,
Append, Append,
MultiSet,
}; };
struct Parameters { struct Parameters {
...@@ -233,6 +235,7 @@ using namespace lima; ...@@ -233,6 +235,7 @@ using namespace lima;
// --- misc // --- misc
void clear(); void clear();
void close();
void writeFrame(int frame_nr = -1, int nb_frames = 1, void writeFrame(int frame_nr = -1, int nb_frames = 1,
bool synchronous = true); bool synchronous = true);
......
...@@ -137,6 +137,7 @@ class CtControl::_ReconstructionChangeCallback : public HwReconstructionCtrlObj: ...@@ -137,6 +137,7 @@ class CtControl::_ReconstructionChangeCallback : public HwReconstructionCtrlObj:
public: public:
_ReconstructionChangeCallback(CtControl& ctrl) : m_ct(ctrl) {} _ReconstructionChangeCallback(CtControl& ctrl) : m_ct(ctrl) {}
virtual ~_ReconstructionChangeCallback() {}
virtual void change(LinkTask* aNewLinkTaskPt) virtual void change(LinkTask* aNewLinkTaskPt)
{ {
m_ct.setReconstructionTask(aNewLinkTaskPt); m_ct.setReconstructionTask(aNewLinkTaskPt);
...@@ -308,7 +309,7 @@ void CtControl::prepareAcq() ...@@ -308,7 +309,7 @@ void CtControl::prepareAcq()
m_ct_accumulation->prepare(); m_ct_accumulation->prepare();
DEB_TRACE() << "Prepare Saving if needed"; DEB_TRACE() << "Prepare Saving if needed";
m_ct_saving->_prepare(); m_ct_saving->_prepare(*this);
m_autosave= m_ct_saving->hasAutoSaveMode(); m_autosave= m_ct_saving->hasAutoSaveMode();
m_ready= true; m_ready= true;
...@@ -424,6 +425,7 @@ void CtControl::stopAcq() ...@@ -424,6 +425,7 @@ void CtControl::stopAcq()
m_running = false; m_running = false;
DEB_TRACE() << "Hardware Acquisition Stopped"; DEB_TRACE() << "Hardware Acquisition Stopped";
_calcAcqStatus(); _calcAcqStatus();
m_ct_saving->_stop(*this);
} }
void CtControl::getStatus(Status& status) const void CtControl::getStatus(Status& status) const
{ {
......
...@@ -53,6 +53,10 @@ ...@@ -53,6 +53,10 @@
#include "CtSaving_Tiff.h" #include "CtSaving_Tiff.h"
#endif #endif
#ifdef WITH_HDF5_SAVING
#include "CtSaving_Hdf5.h"
#endif
#include "TaskMgr.h" #include "TaskMgr.h"
#include "SinkTask.h" #include "SinkTask.h"
...@@ -246,7 +250,7 @@ void CtSaving::Stream::setActive(bool active) ...@@ -246,7 +250,7 @@ void CtSaving::Stream::setActive(bool active)
m_active = active; m_active = active;
} }
void CtSaving::Stream::prepare() void CtSaving::Stream::prepare(CtControl& ct)
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
...@@ -256,8 +260,13 @@ void CtSaving::Stream::prepare() ...@@ -256,8 +260,13 @@ void CtSaving::Stream::prepare()
updateParameters(); updateParameters();
checkWriteAccess(); checkWriteAccess();
} }
m_save_cnt->prepare(ct);
} }
void CtSaving::Stream::close()
{
m_save_cnt->close();
}
void CtSaving::Stream::updateParameters() void CtSaving::Stream::updateParameters()
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
...@@ -307,6 +316,12 @@ void CtSaving::Stream::createSaveContainer() ...@@ -307,6 +316,12 @@ void CtSaving::Stream::createSaveContainer()
#ifndef WITH_TIFF_SAVING #ifndef WITH_TIFF_SAVING
THROW_CTL_ERROR(NotSupported) << "Lima is not compiled with the tiff " THROW_CTL_ERROR(NotSupported) << "Lima is not compiled with the tiff "
"saving option, not managed"; "saving option, not managed";
#endif
goto common;
case HDF5:
#ifndef WITH_HDF5_SAVING
THROW_CTL_ERROR(NotSupported) << "Lima is not compiled with the hdf5 "
"saving option, not managed";
#endif #endif
goto common; goto common;
case RAW: case RAW:
...@@ -351,6 +366,11 @@ void CtSaving::Stream::createSaveContainer() ...@@ -351,6 +366,11 @@ void CtSaving::Stream::createSaveContainer()
m_save_cnt = new SaveContainerTiff(*this); m_save_cnt = new SaveContainerTiff(*this);
m_pars.framesPerFile = 1; m_pars.framesPerFile = 1;
break; break;
#endif
#ifdef WITH_HDF5_SAVING
case HDF5:
m_save_cnt = new SaveContainerHdf5(*this, m_pars.fileFormat);
break;
#endif #endif
default: default:
break; break;
...@@ -827,6 +847,8 @@ void CtSaving::setOverwritePolicy(OverwritePolicy policy, int stream_idx) ...@@ -827,6 +847,8 @@ void CtSaving::setOverwritePolicy(OverwritePolicy policy, int stream_idx)
Stream& stream = getStream(stream_idx); Stream& stream = getStream(stream_idx);
Parameters pars = stream.getParameters(Auto); Parameters pars = stream.getParameters(Auto);
pars.overwritePolicy = policy; pars.overwritePolicy = policy;
if(policy == MultiSet)
pars.nextNumber = -1,pars.framesPerFile = -1;
stream.setParameters(pars); stream.setParameters(pars);
} }
/** @brief get the overwrite policy for a saving stream /** @brief get the overwrite policy for a saving stream
...@@ -1337,6 +1359,14 @@ void CtSaving::clear() ...@@ -1337,6 +1359,14 @@ void CtSaving::clear()
m_frame_datas.clear(); m_frame_datas.clear();
} }
void CtSaving::close()
{
DEB_MEMBER_FUNCT();
AutoMutex aLock(m_cond.mutex());
_close();
}
/** @brief write manually a frame /** @brief write manually a frame
@param aFrameNumber the frame id you want to save @param aFrameNumber the frame id you want to save
...@@ -1524,6 +1554,7 @@ void CtSaving::_saveFinished(Data &aData, Stream& stream) ...@@ -1524,6 +1554,7 @@ void CtSaving::_saveFinished(Data &aData, Stream& stream)
if (!auto_saving || !data_available || if (!auto_saving || !data_available ||
((saving_mode == AutoHeader) && !header_available)) { ((saving_mode == AutoHeader) && !header_available)) {
m_ready_flag = true; m_ready_flag = true;
if(m_saving_stop) _close();
m_cond.signal(); m_cond.signal();
return; return;
} }
...@@ -1573,7 +1604,7 @@ void CtSaving::_setSavingError(CtControl::ErrorCode anErrorCode) ...@@ -1573,7 +1604,7 @@ void CtSaving::_setSavingError(CtControl::ErrorCode anErrorCode)
this methode will resetLastFrameNb if mode is AutoSave this methode will resetLastFrameNb if mode is AutoSave
and validate the parameter for this new acquisition and validate the parameter for this new acquisition
*/ */
void CtSaving::_prepare() void CtSaving::_prepare(CtControl& ct)
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
...@@ -1591,7 +1622,9 @@ void CtSaving::_prepare() ...@@ -1591,7 +1622,9 @@ void CtSaving::_prepare()
for (int s = 0; s < m_nb_stream; ++s) { for (int s = 0; s < m_nb_stream; ++s) {
Stream& stream = getStream(s); Stream& stream = getStream(s);
if (stream.isActive()) { if (stream.isActive()) {
stream.prepare(); aLock.unlock();
stream.prepare(ct);
aLock.lock();
if (stream.needCompression()) if (stream.needCompression())
m_need_compression = true; m_need_compression = true;
} }
...@@ -1624,6 +1657,7 @@ void CtSaving::_prepare() ...@@ -1624,6 +1657,7 @@ void CtSaving::_prepare()
case CBFFormat: fileFormat = HwSavingCtrlObj::CBF_FORMAT_STR;break; case CBFFormat: fileFormat = HwSavingCtrlObj::CBF_FORMAT_STR;break;
case HARDWARE_SPECIFIC: fileFormat = m_specific_hardware_format;break; case HARDWARE_SPECIFIC: fileFormat = m_specific_hardware_format;break;
case TIFFFormat: fileFormat = HwSavingCtrlObj::TIFF_FORMAT_STR;break; case TIFFFormat: fileFormat = HwSavingCtrlObj::TIFF_FORMAT_STR;break;
case HDF5: fileFormat = HwSavingCtrlObj::HDF5_FORMAT_STR;break;
default: default:
THROW_CTL_ERROR(NotSupported) << "Not supported yet";break; THROW_CTL_ERROR(NotSupported) << "Not supported yet";break;
} }
...@@ -1636,6 +1670,27 @@ void CtSaving::_prepare() ...@@ -1636,6 +1670,27 @@ void CtSaving::_prepare()
m_hwsaving->prepare(); m_hwsaving->prepare();
m_hwsaving->start(); m_hwsaving->start();
} }
m_saving_stop = false;
}
void CtSaving::_stop(CtControl&)
{
close();
}
void CtSaving::_close()
{
if(m_ready_flag)
{
for (int s = 0; s < m_nb_stream; ++s)
{
Stream& stream = getStream(s);
if(stream.isActive())
stream.close();
}
}
else
m_saving_stop = true;
} }
#ifdef WITH_CONFIG #ifdef WITH_CONFIG
...@@ -1723,7 +1778,11 @@ void CtSaving::SaveContainer::writeFile(Data &aData,HeaderMap &aHeader) ...@@ -1723,7 +1778,11 @@ void CtSaving::SaveContainer::writeFile(Data &aData,HeaderMap &aHeader)
THROW_CTL_ERROR(Error) << "Save unknown error"; THROW_CTL_ERROR(Error) << "Save unknown error";
} }
if(++m_written_frames == pars.framesPerFile) { ++m_written_frames;
if((pars.overwritePolicy != MultiSet &&
m_written_frames == pars.framesPerFile) ||
m_written_frames == m_nb_frames_to_write) // Close file at the end of acquisition
{
try { try {
close(); close();
} catch (...) { } catch (...) {
...@@ -1784,16 +1843,30 @@ void CtSaving::SaveContainer::clear() ...@@ -1784,16 +1843,30 @@ void CtSaving::SaveContainer::clear()
_clear(); // call inheritance if needed _clear(); // call inheritance if needed
} }
void CtSaving::SaveContainer::prepare(CtControl& ct)
{
DEB_MEMBER_FUNCT();
int nb_frames;
ct.acquisition()->getAcqNbFrames(nb_frames);
m_nb_frames_to_write = nb_frames;
_prepare(ct); // call inheritance if needed
}
void CtSaving::SaveContainer::open(const CtSaving::Parameters &pars) void CtSaving::SaveContainer::open(const CtSaving::Parameters &pars)
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
if(!m_file_opened) if(!m_file_opened)
{ {
char idx[64];
snprintf(idx,sizeof(idx),pars.indexFormat.c_str(),pars.nextNumber);
std::string aFileName = pars.directory + DIR_SEPARATOR + pars.prefix + idx + pars.suffix; std::string aFileName = pars.directory + DIR_SEPARATOR + pars.prefix;
if(pars.overwritePolicy != MultiSet)
{
char idx[64];
snprintf(idx,sizeof(idx),pars.indexFormat.c_str(),pars.nextNumber);
aFileName += idx;
}
aFileName += pars.suffix;
DEB_TRACE() << DEB_VAR1(aFileName); DEB_TRACE() << DEB_VAR1(aFileName);
if(pars.overwritePolicy == Abort && if(pars.overwritePolicy == Abort &&
...@@ -1804,8 +1877,9 @@ void CtSaving::SaveContainer::open(const CtSaving::Parameters &pars) ...@@ -1804,8 +1877,9 @@ void CtSaving::SaveContainer::open(const CtSaving::Parameters &pars)
output = "Try to over write file: " + aFileName; output = "Try to over write file: " + aFileName;
THROW_CTL_ERROR(Error) << output; THROW_CTL_ERROR(Error) << output;
} }
std::ios_base::openmode openFlags = std::ios_base::out | std::ios_base::binary; std::ios_base::openmode openFlags = std::ios_base::out | std::ios_base::binary;
if(pars.overwritePolicy == Append) if(pars.overwritePolicy == Append ||
pars.overwritePolicy == MultiSet)
openFlags |= std::ios_base::app; openFlags |= std::ios_base::app;
else if(pars.overwritePolicy == Overwrite) else if(pars.overwritePolicy == Overwrite)
openFlags |= std::ios_base::trunc; openFlags |= std::ios_base::trunc;
...@@ -1867,7 +1941,8 @@ void CtSaving::SaveContainer::close() ...@@ -1867,7 +1941,8 @@ void CtSaving::SaveContainer::close()
m_file_opened = false; m_file_opened = false;
m_written_frames = 0; m_written_frames = 0;
Parameters& pars = m_stream.getParameters(Acq); Parameters& pars = m_stream.getParameters(Acq);
++pars.nextNumber; if(pars.overwritePolicy != MultiSet)
++pars.nextNumber;
} }
/** @brief check if all file can be written /** @brief check if all file can be written
......
This diff is collapsed.
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License