mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-23 22:04:30 +01:00
slsReceiver HDF5: unlimited x dimension (#images) by extending by numImages if caught more images, fixed virtual mapping, fixed linking for jungfrau single module (removed virtual_ in all namings
This commit is contained in:
@@ -282,9 +282,9 @@ void DataProcessor::CloseFiles() {
|
||||
file->CloseAllFiles();
|
||||
}
|
||||
|
||||
void DataProcessor::EndofAcquisition(uint64_t numf) {
|
||||
void DataProcessor::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
|
||||
if (file && file->GetFileType() == HDF5) {
|
||||
file->EndofAcquisition(numf);
|
||||
file->EndofAcquisition(anyPacketsCaught, numf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ HDF5File::HDF5File(int ind, uint32_t maxf, const uint32_t* ppf,
|
||||
numFramesInFile(0),
|
||||
numActualPacketsInFile(0),
|
||||
numFilesinAcquisition(0),
|
||||
dataspace_para(0)
|
||||
dataspace_para(0),
|
||||
extNumImages(0)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
PrintMembers();
|
||||
@@ -97,7 +98,7 @@ int HDF5File::CreateFile(uint64_t fnum) {
|
||||
//first time
|
||||
if(!fnum) UpdateDataType();
|
||||
|
||||
uint64_t framestosave = ((*numImages - fnum) > maxFramesPerFile) ? maxFramesPerFile : (*numImages-fnum);
|
||||
uint64_t framestosave = ((extNumImages - fnum) > maxFramesPerFile) ? maxFramesPerFile : (extNumImages-fnum);
|
||||
pthread_mutex_lock(&Mutex);
|
||||
if (HDF5FileStatic::CreateDataFile(index, *overWriteEnable, currentFileName, *frameIndexEnable,
|
||||
fnum, framestosave, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
@@ -145,6 +146,19 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
||||
numFramesInFile++;
|
||||
numActualPacketsInFile += nump;
|
||||
pthread_mutex_lock(&Mutex);
|
||||
|
||||
// extend dataset (when receiver start followed by many status starts (jungfrau)))
|
||||
if (fnum >= extNumImages) {
|
||||
if (HDF5FileStatic::ExtendDataset(index, dataspace, dataset,
|
||||
dataspace_para, dataset_para, *numImages) == OK) {
|
||||
if (!silentMode) {
|
||||
cprintf(BLUE,"%d Extending HDF5 dataset by %llu, Total x Dimension: %u\n",
|
||||
index, extNumImages, extNumImages + *numImages);
|
||||
}
|
||||
extNumImages += *numImages;
|
||||
}
|
||||
}
|
||||
|
||||
if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_detector_header),
|
||||
fnum%maxFramesPerFile, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
dataspace, dataset, datatype) == OK) {
|
||||
@@ -163,12 +177,16 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int HDF5File::CreateMasterFile(bool en, uint32_t size,
|
||||
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t ap) {
|
||||
|
||||
//beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
extNumImages = *numImages;
|
||||
|
||||
if (master && (*detIndex==0)) {
|
||||
virtualfd = 0;
|
||||
@@ -185,11 +203,11 @@ int HDF5File::CreateMasterFile(bool en, uint32_t size,
|
||||
}
|
||||
|
||||
|
||||
void HDF5File::EndofAcquisition(uint64_t numf) {
|
||||
void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
|
||||
//not created before
|
||||
if (!virtualfd) {
|
||||
if (!virtualfd && anyPacketsCaught) {
|
||||
|
||||
//only one file and one sub image
|
||||
//only one file and one sub image (link current file in master)
|
||||
if (((numFilesinAcquisition == 1) && (numDetY*numDetX) == 1)) {
|
||||
//dataset name
|
||||
ostringstream osfn;
|
||||
@@ -217,7 +235,7 @@ int HDF5File::CreateVirtualFile(uint64_t numf) {
|
||||
virtualfd, masterFileName,
|
||||
filePath, fileNamePrefix, *fileIndex, *frameIndexEnable,
|
||||
*detIndex, *numUnitsPerDetector,
|
||||
maxFramesPerFile, numf,
|
||||
maxFramesPerFile, numf+1,
|
||||
"data", datatype,
|
||||
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
HDF5_WRITER_VERSION);
|
||||
|
||||
@@ -290,7 +290,7 @@ void UDPBaseImplementation::setFilePath(const char c[]){
|
||||
else
|
||||
FILE_LOG(logERROR) << "FilePath does not exist: " << filePath;
|
||||
}
|
||||
FILE_LOG(logINFO) << "Info: File path: " << filePath;
|
||||
FILE_LOG(logINFO) << "File path: " << filePath;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFileIndex(const uint64_t i){
|
||||
|
||||
@@ -462,8 +462,9 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
if((*it)->GetMeasurementStartedFlag())
|
||||
anycaught = true;
|
||||
}
|
||||
if (anycaught)
|
||||
dataProcessor[0]->EndofAcquisition(maxIndexCaught); //to create virtual file
|
||||
|
||||
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
||||
dataProcessor[0]->EndofAcquisition(anycaught, maxIndexCaught);
|
||||
}
|
||||
|
||||
while(DataStreamer::GetRunningMask()){
|
||||
@@ -480,7 +481,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
tot += dataProcessor[i]->GetNumFramesCaught();
|
||||
|
||||
uint64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught();
|
||||
if (missingpackets) {
|
||||
if ((int)missingpackets > 0) {
|
||||
cprintf(RED, "\n[Port %d]\n",udpPortNum[i]);
|
||||
cprintf(RED, "Missing Packets\t\t: %lld\n",(long long int)missingpackets);
|
||||
cprintf(RED, "Complete Frames\t\t: %lld\n",(long long int)dataProcessor[i]->GetNumFramesCaught());
|
||||
@@ -562,12 +563,15 @@ void UDPStandardImplementation::shutDownUDPSockets() {
|
||||
|
||||
void UDPStandardImplementation::closeFiles() {
|
||||
uint64_t maxIndexCaught = 0;
|
||||
bool anycaught = false;
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
(*it)->CloseFiles();
|
||||
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||
if((*it)->GetMeasurementStartedFlag())
|
||||
anycaught = true;
|
||||
}
|
||||
if (maxIndexCaught)
|
||||
dataProcessor[0]->EndofAcquisition(maxIndexCaught);
|
||||
//to create virtual file & set files/acquisition to 0 (only hdf5 at the moment)
|
||||
dataProcessor[0]->EndofAcquisition(anycaught, maxIndexCaught);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user