mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-20 16:48:01 +02:00
WIP
This commit is contained in:
@ -74,7 +74,7 @@ void BinaryFile::CloseCurrentFile() {
|
|||||||
|
|
||||||
void BinaryFile::CloseAllFiles() {
|
void BinaryFile::CloseAllFiles() {
|
||||||
CloseCurrentFile();
|
CloseCurrentFile();
|
||||||
if (master && (*detIndex==0)) {
|
if (master) {
|
||||||
if (masterfd)
|
if (masterfd)
|
||||||
fclose(masterfd);
|
fclose(masterfd);
|
||||||
masterfd = 0;
|
masterfd = 0;
|
||||||
@ -137,7 +137,7 @@ void BinaryFile::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
|||||||
numFramesInFile = 0;
|
numFramesInFile = 0;
|
||||||
numActualPacketsInFile = 0;
|
numActualPacketsInFile = 0;
|
||||||
|
|
||||||
if (mfwenable && master && (*detIndex==0)) {
|
if (mfwenable && master) {
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << *filePath << "/" << *fileNamePrefix << "_master"
|
os << *filePath << "/" << *fileNamePrefix << "_master"
|
||||||
|
@ -140,7 +140,8 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
|
|||||||
|
|
||||||
|
|
||||||
if (file != nullptr) {
|
if (file != nullptr) {
|
||||||
delete file; file = nullptr;
|
delete file;
|
||||||
|
file = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileWriteEnable) {
|
if (fileWriteEnable) {
|
||||||
|
@ -118,7 +118,7 @@ void HDF5File::CreateFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HDF5File::CloseCurrentFile() {
|
void HDF5File::CloseCurrentFile() {
|
||||||
CloseFile(filefd, false, false);
|
CloseFile(filefd, false);
|
||||||
for (unsigned int i = 0; i < dataset_para.size(); ++i)
|
for (unsigned int i = 0; i < dataset_para.size(); ++i)
|
||||||
delete dataset_para[i];
|
delete dataset_para[i];
|
||||||
dataset_para.clear();
|
dataset_para.clear();
|
||||||
@ -139,10 +139,17 @@ void HDF5File::CloseCurrentFile() {
|
|||||||
void HDF5File::CloseAllFiles() {
|
void HDF5File::CloseAllFiles() {
|
||||||
numFilesinAcquisition = 0;
|
numFilesinAcquisition = 0;
|
||||||
{
|
{
|
||||||
CloseFile(filefd, false, false);
|
CloseFile(filefd, false);
|
||||||
if (master) {
|
if (master) {
|
||||||
CloseFile(masterfd, false, true);
|
CloseFile(masterfd, true);
|
||||||
CloseFile(nullptr, true, false);
|
// close virtual file
|
||||||
|
// c code due to only c implementation of H5Pset_virtual available
|
||||||
|
if (virtualfd != 0) {
|
||||||
|
if (H5Fclose(virtualfd) < 0 ) {
|
||||||
|
LOG(logERROR) << "Could not close virtual HDF5 handles";
|
||||||
|
}
|
||||||
|
virtualfd = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < dataset_para.size(); ++i)
|
for (unsigned int i = 0; i < dataset_para.size(); ++i)
|
||||||
@ -151,7 +158,6 @@ void HDF5File::CloseAllFiles() {
|
|||||||
if(dataspace_para) delete dataspace_para;
|
if(dataspace_para) delete dataspace_para;
|
||||||
if(dataset) delete dataset;
|
if(dataset) delete dataset;
|
||||||
if(dataspace) delete dataspace;
|
if(dataspace) delete dataspace;
|
||||||
if(filefd) delete filefd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5File::WriteToFile(char* buffer, int bufferSize, uint64_t currentFrameNumber, uint32_t numPacketsCaught) {
|
void HDF5File::WriteToFile(char* buffer, int bufferSize, uint64_t currentFrameNumber, uint32_t numPacketsCaught) {
|
||||||
@ -217,21 +223,12 @@ void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numImagesCaught)
|
|||||||
numFilesinAcquisition = 0;
|
numFilesinAcquisition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5File::CloseFile(H5File* fd, bool virtualFile, bool masterFile) {
|
void HDF5File::CloseFile(H5File*& fd, bool masterFile) {
|
||||||
std::lock_guard<std::mutex> lock(HDF5File::hdf5Lib);
|
std::lock_guard<std::mutex> lock(HDF5File::hdf5Lib);
|
||||||
|
|
||||||
// c code due to only c implementation of H5Pset_virtual available
|
|
||||||
if (virtualFile) {
|
|
||||||
if (virtualfd != 0) {
|
|
||||||
if (H5Fclose(virtualfd) < 0 ) {
|
|
||||||
LOG(logERROR) << "Could not close virtual HDF5 handles";
|
|
||||||
}
|
|
||||||
virtualfd = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
Exception::dontPrint(); // to handle errors
|
Exception::dontPrint(); // to handle errors
|
||||||
if (fd) {
|
if (fd) {
|
||||||
|
fd->close();
|
||||||
delete fd;
|
delete fd;
|
||||||
fd = 0;
|
fd = 0;
|
||||||
}
|
}
|
||||||
@ -242,7 +239,6 @@ void HDF5File::CloseFile(H5File* fd, bool virtualFile, bool masterFile) {
|
|||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void HDF5File::WriteDataFile(uint64_t currentFrameNumber, char* buffer) {
|
void HDF5File::WriteDataFile(uint64_t currentFrameNumber, char* buffer) {
|
||||||
std::lock_guard<std::mutex> lock(HDF5File::hdf5Lib);
|
std::lock_guard<std::mutex> lock(HDF5File::hdf5Lib);
|
||||||
@ -462,7 +458,9 @@ void HDF5File::CreateDataFile() {
|
|||||||
}
|
}
|
||||||
catch(const Exception& error){
|
catch(const Exception& error){
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
if (filefd) filefd->close();
|
if (filefd) {
|
||||||
|
filefd->close();
|
||||||
|
}
|
||||||
throw sls::RuntimeError("Could not create HDF5 handles in object " + index);
|
throw sls::RuntimeError("Could not create HDF5 handles in object " + index);
|
||||||
}
|
}
|
||||||
if(!(*silentMode)) {
|
if(!(*silentMode)) {
|
||||||
@ -686,7 +684,9 @@ void HDF5File::CreateMasterDataFile(masterAttributes& masterFileAttributes) {
|
|||||||
|
|
||||||
} catch(const Exception& error) {
|
} catch(const Exception& error) {
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
if (masterfd) masterfd->close();
|
if (masterfd) {
|
||||||
|
masterfd->close();
|
||||||
|
}
|
||||||
throw sls::RuntimeError("Could not create master HDF5 handles");
|
throw sls::RuntimeError("Could not create master HDF5 handles");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class HDF5File : private virtual slsDetectorDefs, public File {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void CloseFile(H5File* fd, bool virtualFile, bool masterFile);
|
void CloseFile(H5File*& fd, bool masterFile);
|
||||||
void WriteDataFile(uint64_t currentFrameNumber, char* buffer);
|
void WriteDataFile(uint64_t currentFrameNumber, char* buffer);
|
||||||
void WriteParameterDatasets(uint64_t currentFrameNumber, sls_receiver_header* rheader);
|
void WriteParameterDatasets(uint64_t currentFrameNumber, sls_receiver_header* rheader);
|
||||||
void ExtendDataset();
|
void ExtendDataset();
|
||||||
|
Reference in New Issue
Block a user