mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
r_framesperfile configurable to have infinite frames in file with option 0
This commit is contained in:
parent
94ce042401
commit
f393751771
@ -98,7 +98,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
|||||||
uint64_t getFileIndex() const;
|
uint64_t getFileIndex() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Frames per File
|
* Get Frames per File (0 means infinite)
|
||||||
* @return Frames per File
|
* @return Frames per File
|
||||||
*/
|
*/
|
||||||
uint32_t getFramesPerFile() const;
|
uint32_t getFramesPerFile() const;
|
||||||
@ -363,7 +363,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
|||||||
void setFileIndex(const uint64_t i);
|
void setFileIndex(const uint64_t i);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Frames per File
|
* Set Frames per File (0 means infinite)
|
||||||
* @param i Frames per File
|
* @param i Frames per File
|
||||||
*/
|
*/
|
||||||
void setFramesPerFile(const uint32_t i);
|
void setFramesPerFile(const uint32_t i);
|
||||||
@ -751,7 +751,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
|||||||
char filePath[MAX_STR_LENGTH];
|
char filePath[MAX_STR_LENGTH];
|
||||||
/** File Index */
|
/** File Index */
|
||||||
uint64_t fileIndex;
|
uint64_t fileIndex;
|
||||||
/** Frames per file */
|
/** Frames per file (0 means infinite) */
|
||||||
uint32_t framesPerFile;
|
uint32_t framesPerFile;
|
||||||
/** Scan Tag */
|
/** Scan Tag */
|
||||||
int scanTag;
|
int scanTag;
|
||||||
|
@ -186,7 +186,7 @@ class UDPInterface {
|
|||||||
virtual uint64_t getFileIndex() const = 0;
|
virtual uint64_t getFileIndex() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Frames per File
|
* Get Frames per File (0 means infinite)
|
||||||
* @return Frames per File
|
* @return Frames per File
|
||||||
*/
|
*/
|
||||||
virtual uint32_t getFramesPerFile() const = 0;
|
virtual uint32_t getFramesPerFile() const = 0;
|
||||||
@ -450,7 +450,7 @@ class UDPInterface {
|
|||||||
virtual void setFileIndex(const uint64_t i) = 0;
|
virtual void setFileIndex(const uint64_t i) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Frames per File
|
* Set Frames per File (0 means infinite)
|
||||||
* @param i Frames per File
|
* @param i Frames per File
|
||||||
*/
|
*/
|
||||||
virtual void setFramesPerFile(const uint32_t i) = 0;
|
virtual void setFramesPerFile(const uint32_t i) = 0;
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#define DO_NOTHING 0
|
#define DO_NOTHING 0
|
||||||
#define DO_EVERYTHING 1
|
#define DO_EVERYTHING 1
|
||||||
|
|
||||||
|
#define STATISTIC_FRAMENUMBER_INFINITE 20000
|
||||||
|
|
||||||
//binary
|
//binary
|
||||||
#define FILE_BUFFER_SIZE (16*1024*1024) //16mb
|
#define FILE_BUFFER_SIZE (16*1024*1024) //16mb
|
||||||
|
|
||||||
|
@ -70,7 +70,8 @@ void BinaryFile::CloseAllFiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
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();
|
CloseCurrentFile();
|
||||||
CreateFile(fnum);
|
CreateFile(fnum);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,10 @@ int HDF5File::CreateFile(uint64_t fnum) {
|
|||||||
|
|
||||||
//first time
|
//first time
|
||||||
if(!fnum) UpdateDataType();
|
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);
|
pthread_mutex_lock(&Mutex);
|
||||||
if (HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, (*numImages > 1),
|
if (HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, (*numImages > 1),
|
||||||
fnum, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
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) {
|
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();
|
CloseCurrentFile();
|
||||||
CreateFile(fnum);
|
CreateFile(fnum);
|
||||||
}
|
}
|
||||||
@ -144,12 +148,15 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
|||||||
numActualPacketsInFile += nump;
|
numActualPacketsInFile += nump;
|
||||||
pthread_mutex_lock(&Mutex);
|
pthread_mutex_lock(&Mutex);
|
||||||
if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_detector_header),
|
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) {
|
dataspace, dataset, datatype) == OK) {
|
||||||
sls_detector_header* header = (sls_detector_header*) (buffer);
|
sls_detector_header* header = (sls_detector_header*) (buffer);
|
||||||
/*header->xCoord = ((*detIndex) * (*numUnitsPerDetector) + index); */
|
/*header->xCoord = ((*detIndex) * (*numUnitsPerDetector) + index); */
|
||||||
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
|
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
|
||||||
fnum%(*maxFramesPerFile),
|
// infinite then no need for %maxframesperfile
|
||||||
|
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
|
||||||
dataset_para, header) == OK) {
|
dataset_para, header) == OK) {
|
||||||
pthread_mutex_unlock(&Mutex);
|
pthread_mutex_unlock(&Mutex);
|
||||||
return OK;
|
return OK;
|
||||||
@ -218,7 +225,9 @@ int HDF5File::CreateVirtualFile(uint64_t numf) {
|
|||||||
virtualfd, masterFileName,
|
virtualfd, masterFileName,
|
||||||
filePath, fileNamePrefix, *fileIndex, (*numImages > 1),
|
filePath, fileNamePrefix, *fileIndex, (*numImages > 1),
|
||||||
*detIndex, *numUnitsPerDetector,
|
*detIndex, *numUnitsPerDetector,
|
||||||
*maxFramesPerFile, numf+1,
|
// infinite images in 1 file, then maxfrperfile = numf
|
||||||
|
((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile),
|
||||||
|
numf+1,
|
||||||
"data", datatype,
|
"data", datatype,
|
||||||
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||||
HDF5_WRITER_VERSION);
|
HDF5_WRITER_VERSION);
|
||||||
|
@ -338,7 +338,9 @@ void Listener::ThreadExecution() {
|
|||||||
//Statistics
|
//Statistics
|
||||||
if(!silentMode) {
|
if(!silentMode) {
|
||||||
numFramesStatistic++;
|
numFramesStatistic++;
|
||||||
if (numFramesStatistic >= *framesPerFile)
|
if (numFramesStatistic >=
|
||||||
|
//second condition also for infinite #number of frames
|
||||||
|
(((*framesPerFile) == 0) ? STATISTIC_FRAMENUMBER_INFINITE : (*framesPerFile)) )
|
||||||
PrintFifoStatistics();
|
PrintFifoStatistics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user