mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 18:10:40 +02:00
removed binary master file as well
This commit is contained in:
parent
b9aa0f46e4
commit
f5cca7a98f
@ -6,7 +6,6 @@ set(SOURCES
|
||||
src/Receiver.cpp
|
||||
src/File.cpp
|
||||
src/BinaryDataFile.cpp
|
||||
src/BinaryMasterFile.cpp
|
||||
src/ThreadObject.cpp
|
||||
src/Listener.cpp
|
||||
src/DataProcessor.cpp
|
||||
@ -14,6 +13,7 @@ set(SOURCES
|
||||
src/Fifo.cpp
|
||||
src/Arping.cpp
|
||||
src/MasterAttributes.cpp
|
||||
src/MasterFileUtility.cpp
|
||||
)
|
||||
|
||||
set(PUBLICHEADERS
|
||||
@ -28,7 +28,6 @@ if (SLS_USE_HDF5)
|
||||
)
|
||||
list (APPEND SOURCES
|
||||
src/HDF5DataFile.cpp
|
||||
src/HDF5Utility.cpp
|
||||
)
|
||||
endif (SLS_USE_HDF5)
|
||||
|
||||
|
@ -1,52 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "BinaryMasterFile.h"
|
||||
#include "MasterAttributes.h"
|
||||
|
||||
std::string BinaryMasterFile::CreateMasterFile(const std::string filePath,
|
||||
const std::string fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode,
|
||||
MasterAttributes *attr) {
|
||||
// create file name
|
||||
std::ostringstream os;
|
||||
os << filePath << "/" << fileNamePrefix << "_master"
|
||||
<< "_" << fileIndex << ".json";
|
||||
std::string fileName = os.str();
|
||||
|
||||
// create file
|
||||
FILE *fd{nullptr};
|
||||
if (!overWriteEnable) {
|
||||
if (nullptr == (fd = fopen((const char *)fileName.c_str(), "wx"))) {
|
||||
fd = nullptr;
|
||||
throw sls::RuntimeError("Could not create binary master file " +
|
||||
fileName);
|
||||
}
|
||||
} else if (nullptr == (fd = fopen((const char *)fileName.c_str(), "w"))) {
|
||||
fd = nullptr;
|
||||
throw sls::RuntimeError(
|
||||
"Could not create/overwrite binary master file " + fileName);
|
||||
}
|
||||
|
||||
std::string message = BinaryMasterFile::GetMasterAttributes(attr);
|
||||
if (fwrite((void *)message.c_str(), 1, message.length(), fd) !=
|
||||
message.length()) {
|
||||
throw sls::RuntimeError(
|
||||
"Master binary file incorrect number of bytes written to file");
|
||||
}
|
||||
if (fd) {
|
||||
fclose(fd);
|
||||
}
|
||||
if (!silentMode) {
|
||||
LOG(logINFO) << "Master File: " << fileName;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
std::string BinaryMasterFile::GetMasterAttributes(MasterAttributes *attr) {
|
||||
rapidjson::StringBuffer s;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
|
||||
attr->GetBinaryAttributes(&writer);
|
||||
return s.GetString();
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include "MasterAttributes.h"
|
||||
|
||||
class BinaryMasterFile : private virtual slsDetectorDefs {
|
||||
|
||||
public:
|
||||
static std::string CreateMasterFile(const std::string filePath,
|
||||
const std::string fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode,
|
||||
MasterAttributes *attr);
|
||||
|
||||
private:
|
||||
static std::string GetMasterAttributes(MasterAttributes *attr);
|
||||
};
|
@ -13,9 +13,9 @@
|
||||
#include "Fifo.h"
|
||||
#include "GeneralData.h"
|
||||
#include "MasterAttributes.h"
|
||||
#include "MasterFileUtility.h"
|
||||
#ifdef HDF5C
|
||||
#include "HDF5DataFile.h"
|
||||
#include "HDF5Utility.h"
|
||||
#endif
|
||||
#include "DataStreamer.h"
|
||||
#include "sls/container_utils.h"
|
||||
@ -177,7 +177,7 @@ std::array<std::string, 2> DataProcessor::CreateVirtualFile(
|
||||
// files (they exist anyway) assumption2: virtual file max frame index
|
||||
// is from R0 P0 (difference from others when missing frames or for a
|
||||
// stop acquisition)
|
||||
return hdf5Utility::CreateVirtualFile(
|
||||
return masterFileUtility::CreateVirtualHDF5File(
|
||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||
modulePos, numUnitsPerReadout, framesPerFile, numImages,
|
||||
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
|
||||
@ -198,9 +198,9 @@ void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
|
||||
fname = res[0];
|
||||
datasetName = res[1];
|
||||
}
|
||||
hdf5Utility::LinkFileInMaster(masterFileName, fname, datasetName,
|
||||
dataFile_->GetParameterNames(), silentMode,
|
||||
hdf5LibMutex);
|
||||
masterFileUtility::LinkHDF5FileInMaster(masterFileName, fname, datasetName,
|
||||
dataFile_->GetParameterNames(),
|
||||
silentMode, hdf5LibMutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -216,14 +216,14 @@ std::string DataProcessor::CreateMasterFile(
|
||||
switch (fileFormatType) {
|
||||
#ifdef HDF5C
|
||||
case HDF5:
|
||||
return hdf5Utility::CreateMasterFile(filePath, fileNamePrefix,
|
||||
fileIndex, overWriteEnable,
|
||||
silentMode, attr, hdf5LibMutex);
|
||||
return masterFileUtility::CreateMasterHDF5File(
|
||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||
attr, hdf5LibMutex);
|
||||
#endif
|
||||
case BINARY:
|
||||
return BinaryMasterFile::CreateMasterFile(filePath, fileNamePrefix,
|
||||
fileIndex, overWriteEnable,
|
||||
silentMode, attr);
|
||||
return masterFileUtility::CreateMasterBinaryFile(
|
||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||
attr);
|
||||
default:
|
||||
throw sls::RuntimeError("Unknown file format (compile with hdf5 flags");
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include "MasterAttributes.h"
|
||||
|
||||
#ifdef HDF5C
|
||||
#include "H5Cpp.h"
|
||||
#ifndef H5_NO_NAMESPACE
|
||||
using namespace H5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace hdf5Utility {
|
||||
|
||||
void LinkFileInMaster(const std::string &masterFileName,
|
||||
const std::string &dataFilename,
|
||||
const std::string &dataSetname,
|
||||
const std::vector<std::string> parameterNames,
|
||||
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||
|
||||
std::string CreateMasterFile(const std::string &filePath,
|
||||
const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable, const bool silentMode,
|
||||
MasterAttributes *attr, std::mutex *hdf5LibMutex);
|
||||
|
||||
std::array<std::string, 2>
|
||||
CreateVirtualFile(const std::string &filePath,
|
||||
const std::string &fileNamePrefix, const uint64_t fileIndex,
|
||||
const bool overWriteEnable, const bool silentMode,
|
||||
const int modulePos, const int numUnitsPerReadout,
|
||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
||||
const int numModX, const int numModY, const DataType dataType,
|
||||
const std::vector<std::string> parameterNames,
|
||||
const std::vector<DataType> parameterDataTypes,
|
||||
std::mutex *hdf5LibMutex, bool gotthard25um);
|
||||
|
||||
} // namespace hdf5Utility
|
@ -1,13 +1,58 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "HDF5Utility.h"
|
||||
#include "MasterFileUtility.h"
|
||||
#include "sls/container_utils.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
namespace hdf5Utility {
|
||||
namespace masterFileUtility {
|
||||
|
||||
void LinkFileInMaster(const std::string &masterFileName,
|
||||
std::string CreateMasterBinaryFile(const std::string filePath,
|
||||
const std::string fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode,
|
||||
MasterAttributes *attr) {
|
||||
// create file name
|
||||
std::ostringstream os;
|
||||
os << filePath << "/" << fileNamePrefix << "_master"
|
||||
<< "_" << fileIndex << ".json";
|
||||
std::string fileName = os.str();
|
||||
|
||||
// create file
|
||||
FILE *fd{nullptr};
|
||||
if (!overWriteEnable) {
|
||||
if (nullptr == (fd = fopen((const char *)fileName.c_str(), "wx"))) {
|
||||
fd = nullptr;
|
||||
throw sls::RuntimeError("Could not create binary master file " +
|
||||
fileName);
|
||||
}
|
||||
} else if (nullptr == (fd = fopen((const char *)fileName.c_str(), "w"))) {
|
||||
fd = nullptr;
|
||||
throw sls::RuntimeError(
|
||||
"Could not create/overwrite binary master file " + fileName);
|
||||
}
|
||||
|
||||
rapidjson::StringBuffer s;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
|
||||
attr->GetBinaryAttributes(&writer);
|
||||
std::string message = s.GetString();
|
||||
if (fwrite((void *)message.c_str(), 1, message.length(), fd) !=
|
||||
message.length()) {
|
||||
throw sls::RuntimeError(
|
||||
"Master binary file incorrect number of bytes written to file");
|
||||
}
|
||||
if (fd) {
|
||||
fclose(fd);
|
||||
}
|
||||
if (!silentMode) {
|
||||
LOG(logINFO) << "Master File: " << fileName;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
#ifdef HDF5C
|
||||
void LinkHDF5FileInMaster(const std::string &masterFileName,
|
||||
const std::string &dataFilename,
|
||||
const std::string &dataSetname,
|
||||
const std::vector<std::string> parameterNames,
|
||||
@ -64,11 +109,12 @@ void LinkFileInMaster(const std::string &masterFileName,
|
||||
}
|
||||
}
|
||||
|
||||
std::string CreateMasterFile(const std::string &filePath,
|
||||
std::string CreateMasterHDF5File(const std::string &filePath,
|
||||
const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable, const bool silentMode,
|
||||
MasterAttributes *attr, std::mutex *hdf5LibMutex) {
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode, MasterAttributes *attr,
|
||||
std::mutex *hdf5LibMutex) {
|
||||
|
||||
std::ostringstream os;
|
||||
os << filePath << "/" << fileNamePrefix << "_master"
|
||||
@ -121,18 +167,17 @@ std::string CreateMasterFile(const std::string &filePath,
|
||||
return fileName;
|
||||
}
|
||||
|
||||
std::array<std::string, 2>
|
||||
CreateVirtualFile(const std::string &filePath,
|
||||
const std::string &fileNamePrefix, const uint64_t fileIndex,
|
||||
const bool overWriteEnable, const bool silentMode,
|
||||
std::array<std::string, 2> CreateVirtualHDF5File(
|
||||
const std::string &filePath, const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||
const int modulePos, const int numUnitsPerReadout,
|
||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
||||
const int numModX, const int numModY, const DataType dataType,
|
||||
const std::vector<std::string> parameterNames,
|
||||
const std::vector<DataType> parameterDataTypes,
|
||||
std::mutex *hdf5LibMutex, bool gotthard25um) {
|
||||
const std::vector<DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
|
||||
bool gotthard25um) {
|
||||
|
||||
// virtual file name
|
||||
std::ostringstream osfn;
|
||||
@ -308,5 +353,6 @@ CreateVirtualFile(const std::string &filePath,
|
||||
}
|
||||
return std::array<std::string, 2>{fileName, dataSetName};
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace hdf5Utility
|
||||
} // namespace masterFileUtility
|
50
slsReceiverSoftware/src/MasterFileUtility.h
Normal file
50
slsReceiverSoftware/src/MasterFileUtility.h
Normal file
@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include "MasterAttributes.h"
|
||||
|
||||
#ifdef HDF5C
|
||||
#include "H5Cpp.h"
|
||||
#include <mutex>
|
||||
#ifndef H5_NO_NAMESPACE
|
||||
using namespace H5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace masterFileUtility {
|
||||
|
||||
std::string CreateMasterBinaryFile(const std::string filePath,
|
||||
const std::string fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode,
|
||||
MasterAttributes *attr);
|
||||
|
||||
#ifdef HDF5C
|
||||
void LinkHDF5FileInMaster(const std::string &masterFileName,
|
||||
const std::string &dataFilename,
|
||||
const std::string &dataSetname,
|
||||
const std::vector<std::string> parameterNames,
|
||||
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||
|
||||
std::string CreateMasterHDF5File(const std::string &filePath,
|
||||
const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode, MasterAttributes *attr,
|
||||
std::mutex *hdf5LibMutex);
|
||||
|
||||
std::array<std::string, 2> CreateVirtualHDF5File(
|
||||
const std::string &filePath, const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||
const int modulePos, const int numUnitsPerReadout,
|
||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
||||
const int numModX, const int numModY, const DataType dataType,
|
||||
const std::vector<std::string> parameterNames,
|
||||
const std::vector<DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
|
||||
bool gotthard25um);
|
||||
#endif
|
||||
} // namespace masterFileUtility
|
Loading…
x
Reference in New Issue
Block a user