r_framesperfile configurable to have infinite frames in file with option 0

This commit is contained in:
maliakal_d 2018-05-18 16:35:50 +02:00
parent 94ce042401
commit f393751771
6 changed files with 26 additions and 12 deletions

View File

@ -98,7 +98,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
uint64_t getFileIndex() const;
/**
* Get Frames per File
* Get Frames per File (0 means infinite)
* @return Frames per File
*/
uint32_t getFramesPerFile() const;
@ -363,7 +363,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
void setFileIndex(const uint64_t i);
/**
* Set Frames per File
* Set Frames per File (0 means infinite)
* @param i Frames per File
*/
void setFramesPerFile(const uint32_t i);
@ -751,7 +751,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
char filePath[MAX_STR_LENGTH];
/** File Index */
uint64_t fileIndex;
/** Frames per file */
/** Frames per file (0 means infinite) */
uint32_t framesPerFile;
/** Scan Tag */
int scanTag;

View File

@ -186,7 +186,7 @@ class UDPInterface {
virtual uint64_t getFileIndex() const = 0;
/**
* Get Frames per File
* Get Frames per File (0 means infinite)
* @return Frames per File
*/
virtual uint32_t getFramesPerFile() const = 0;
@ -450,7 +450,7 @@ class UDPInterface {
virtual void setFileIndex(const uint64_t i) = 0;
/**
* Set Frames per File
* Set Frames per File (0 means infinite)
* @param i Frames per File
*/
virtual void setFramesPerFile(const uint32_t i) = 0;

View File

@ -15,6 +15,8 @@
#define DO_NOTHING 0
#define DO_EVERYTHING 1
#define STATISTIC_FRAMENUMBER_INFINITE 20000
//binary
#define FILE_BUFFER_SIZE (16*1024*1024) //16mb

View File

@ -70,7 +70,8 @@ void BinaryFile::CloseAllFiles() {
}
int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
if (numFramesInFile >= (*maxFramesPerFile)) {
// check if maxframesperfile = 0 for infinite
if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) {
CloseCurrentFile();
CreateFile(fnum);
}

View File

@ -95,7 +95,10 @@ int HDF5File::CreateFile(uint64_t fnum) {
//first time
if(!fnum) UpdateDataType();
uint64_t framestosave = ((*numImages - fnum) > (*maxFramesPerFile)) ? (*maxFramesPerFile) : (*numImages-fnum);
uint64_t framestosave = ((*maxFramesPerFile == 0) ? *numImages : // infinite images
(((*numImages - fnum) > (*maxFramesPerFile)) ? // save up to maximum at a time
(*maxFramesPerFile) : (*numImages-fnum)));
pthread_mutex_lock(&Mutex);
if (HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, (*numImages > 1),
fnum, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
@ -136,7 +139,8 @@ void HDF5File::CloseAllFiles() {
int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
if (numFramesInFile >= (*maxFramesPerFile)) {
// check if maxframesperfile = 0 for infinite
if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) {
CloseCurrentFile();
CreateFile(fnum);
}
@ -144,12 +148,15 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
numActualPacketsInFile += nump;
pthread_mutex_lock(&Mutex);
if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_detector_header),
fnum%(*maxFramesPerFile), nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
// infinite then no need for %maxframesperfile
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
dataspace, dataset, datatype) == OK) {
sls_detector_header* header = (sls_detector_header*) (buffer);
/*header->xCoord = ((*detIndex) * (*numUnitsPerDetector) + index); */
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
fnum%(*maxFramesPerFile),
// infinite then no need for %maxframesperfile
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
dataset_para, header) == OK) {
pthread_mutex_unlock(&Mutex);
return OK;
@ -218,7 +225,9 @@ int HDF5File::CreateVirtualFile(uint64_t numf) {
virtualfd, masterFileName,
filePath, fileNamePrefix, *fileIndex, (*numImages > 1),
*detIndex, *numUnitsPerDetector,
*maxFramesPerFile, numf+1,
// infinite images in 1 file, then maxfrperfile = numf
((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile),
numf+1,
"data", datatype,
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
HDF5_WRITER_VERSION);

View File

@ -338,7 +338,9 @@ void Listener::ThreadExecution() {
//Statistics
if(!silentMode) {
numFramesStatistic++;
if (numFramesStatistic >= *framesPerFile)
if (numFramesStatistic >=
//second condition also for infinite #number of frames
(((*framesPerFile) == 0) ? STATISTIC_FRAMENUMBER_INFINITE : (*framesPerFile)) )
PrintFifoStatistics();
}
}