Commit 10b5e7b5 authored by Arafat Noureddine's avatar Arafat Noureddine Committed by Sebastien Petitdemange

Add a std::string 'options'' field in CtSaving :: Parameters.

This 'options' allow user client to set some options when using a specific file format.

For Nexus file format, this 'options' field must be formatted like this :
options = "thewritemode|thememorymode"
thewritemode must be : IMMEDIATE or SYNCHRONOUS or DELAYED
thememorymode must be : COPY or NO_COPY
parent dcebff97
......@@ -95,6 +95,7 @@ namespace lima {
std::string directory; ///< base path where the files will be saved
std::string prefix; ///< prefix of the filename
std::string suffix; ///< suffix of the filename
std::string options;
ImageType imageType;
long nextNumber; ///< next file number
FileFormat fileFormat; ///< the saving format (EDF,CBF...)
......@@ -126,6 +127,9 @@ namespace lima {
void setSuffix(const std::string &suffix, int stream_idx=0);
void getSuffix(std::string& suffix, int stream_idx=0) const;
void setOptions(const std::string &options, int stream_idx=0);
void getOptions(std::string& options, int stream_idx=0) const;
void setNextNumber(long number, int stream_idx=0);
void getNextNumber(long& number, int stream_idx=0) const;
......
......@@ -174,7 +174,7 @@ void CtSaving::Parameters::checkValid() const
break;
#endif
#ifndef __unix
#pragma message ( "--- WARNING / TODO - no cases???" )
#pragma message ( "--- WARNING / TODO - no cases???" )
#endif
default:
break;
......@@ -451,6 +451,7 @@ public:
saving_setting.set("directory",pars.directory);
saving_setting.set("prefix",pars.prefix);
saving_setting.set("suffix",pars.suffix);
saving_setting.set("options",pars.options);
saving_setting.set("imageType",convert_2_string(pars.imageType));
saving_setting.set("nextNumber",pars.nextNumber);
saving_setting.set("fileFormat",convert_2_string(pars.fileFormat));
......@@ -472,6 +473,7 @@ public:
saving_setting.get("directory",pars.directory);
saving_setting.get("prefix",pars.prefix);
saving_setting.get("suffix",pars.suffix);
saving_setting.get("options",pars.options);
std::string strimageType;
if(saving_setting.get("imageType",strimageType))
......@@ -691,6 +693,35 @@ void CtSaving::getSuffix(std::string& suffix, int stream_idx) const
DEB_RETURN() << DEB_VAR1(suffix);
}
/** @brief set the additional options for a saving stream
*/
void CtSaving::setOptions(const std::string &options, int stream_idx)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(options, stream_idx);
AutoMutex aLock(m_cond.mutex());
Stream& stream = getStream(stream_idx);
Parameters pars = stream.getParameters(Auto);
pars.options = options;
stream.setParameters(pars);
}
/** @brief get the additional options for a saving stream
*/
void CtSaving::getOptions(std::string& options, int stream_idx) const
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(stream_idx);
AutoMutex aLock(m_cond.mutex());
const Stream& stream = getStream(stream_idx);
const Parameters& pars = stream.getParameters(Auto);
options = pars.options;
DEB_RETURN() << DEB_VAR1(options);
}
/** @brief set the next number for the filename for a saving stream
*/
void CtSaving::setNextNumber(long number, int stream_idx)
......@@ -1647,6 +1678,7 @@ void CtSaving::_prepare(CtControl& ct)
m_hwsaving->setDirectory(params.directory);
m_hwsaving->setPrefix(params.prefix);
m_hwsaving->setSuffix(params.suffix);
m_hwsaving->setOptions(params.options);
m_hwsaving->setNextNumber(params.nextNumber);
m_hwsaving->setIndexFormat(params.indexFormat);
std::string fileFormat;
......@@ -2003,14 +2035,14 @@ void CtSaving::Stream::checkWriteAccess()
int lastFileNumber = m_acquisition_pars.nextNumber + nbFiles - 1;
#ifdef WIN32
HANDLE hFind;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
WIN32_FIND_DATA FindFileData;
const int maxNameLen = FILENAME_MAX;
char filesToSearch[ maxNameLen];
sprintf_s(filesToSearch,FILENAME_MAX, "%s/*.*", m_pars.directory.c_str());
if((hFind = FindFirstFile(filesToSearch, &FindFileData)) == INVALID_HANDLE_VALUE)
#else
char filesToSearch[ maxNameLen];
sprintf_s(filesToSearch,FILENAME_MAX, "%s/*.*", m_pars.directory.c_str());
if((hFind = FindFirstFile(filesToSearch, &FindFileData)) == INVALID_HANDLE_VALUE)
#else
struct dirent buffer;
struct dirent* result;
const int maxNameLen = 256;
......@@ -2044,8 +2076,8 @@ void CtSaving::Stream::checkWriteAccess()
#ifdef WIN32
BOOL doIt = true;
while(!errorFlag && doIt) {
fname = FindFileData.cFileName;
doIt = FindNextFile(hFind, &FindFileData);
fname = FindFileData.cFileName;
doIt = FindNextFile(hFind, &FindFileData);
if(sscanf_s(fname,testString, &fileIndex) == 1)
#else
......@@ -2071,7 +2103,7 @@ void CtSaving::Stream::checkWriteAccess()
#ifdef WIN32
FindClose(hFind);
FindClose(hFind);
#else
closedir(aDirPt);
#endif
......
This diff is collapsed.
......@@ -44,8 +44,9 @@ namespace lima
virtual void _clear();
private:
nxcpp::DataStreamer* m_writer;
CtSaving::Parameters m_pars;
nxcpp::DataStreamer* m_writer;
CtSaving::Parameters m_pars;
std::vector<std::string> m_options;
};
}
......
......@@ -57,6 +57,7 @@ namespace lima
void setDirectory(const std::string&);
void setPrefix(const std::string&);
void setSuffix(const std::string&);
void setOptions(const std::string&);
void setNextNumber(long number);
void setIndexFormat(const std::string&);
......@@ -102,6 +103,7 @@ namespace lima
std::string m_directory;
std::string m_prefix;
std::string m_suffix;
std::string m_options;
long m_next_number;
std::string m_file_format;
std::string m_index_format;
......
......@@ -125,6 +125,10 @@ void HwSavingCtrlObj::setSuffix(const std::string& suffix)
{
m_suffix = suffix;
}
void HwSavingCtrlObj::setOptions(const std::string& options)
{
m_options = options;
}
void HwSavingCtrlObj::setNextNumber(long number)
{
m_next_number = number;
......
Markdown is supported
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