merge fix

This commit is contained in:
maliakal_d 2022-03-31 15:09:58 +02:00
commit c2ef6d700e
10 changed files with 57 additions and 69 deletions

View File

@ -58,6 +58,7 @@ This document describes the differences between v7.0.0 and v6.x.x
- fpga/kernel programming, checks if drive is a special file and not a normal file
- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
- master binary file in json format now
- fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile
2. Resolved Issues
==================

View File

@ -72,7 +72,7 @@ void BinaryDataFile::WriteToFile(char *buffer, const int buffersize,
++subFileIndex_;
CreateFile();
}
numFramesInFile_++;
++numFramesInFile_;
// write to file
int ret = 0;

View File

@ -111,7 +111,7 @@ void DataProcessor::SetupFileWriter(const bool filewriteEnable,
}
void DataProcessor::CreateFirstFiles(
const std::string filePath, const std::string fileNamePrefix,
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 udpPortNumber, const uint32_t maxFramesPerFile,

View File

@ -48,8 +48,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
const fileFormat fileFormatType,
std::mutex *hdf5LibMutex);
void CreateFirstFiles(const std::string filePath,
const std::string fileNamePrefix,
void CreateFirstFiles(const std::string &filePath,
const std::string &fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable,
const bool silentMode, const int modulePos,
const int numUnitsPerReadout,

View File

@ -84,10 +84,7 @@ class File : private virtual slsDetectorDefs {
virtual void WriteToFile(char *buffer, const int buffersize,
const uint64_t currentFrameNumber,
const uint32_t numPacketsCaught) {
LOG(logERROR) << "This is a generic function WriteToFile that "
"should be overloaded by a derived class";
};
const uint32_t numPacketsCaught) = 0;
protected:
slsDetectorDefs::fileFormat format_;

View File

@ -128,7 +128,7 @@ void HDF5DataFile::CreateFirstHDF5DataFile(
}
void HDF5DataFile::CreateFile() {
numFramesInFile_ = 0;
numFilesInAcquisition_++;
std::ostringstream os;
@ -237,7 +237,7 @@ void HDF5DataFile::WriteToFile(char *buffer, const int buffersize,
++subFileIndex_;
CreateFile();
}
numFramesInFile_++;
++numFramesInFile_;
// extend dataset (when receiver start followed by many status starts
// (jungfrau)))

View File

@ -3,7 +3,7 @@
#include "MasterAttributes.h"
void MasterAttributes::GetBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->StartObject();
GetCommonBinaryAttributes(w);
switch (detType) {
@ -70,13 +70,15 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
#endif
void MasterAttributes::GetCommonBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->Key("Version");
w->SetMaxDecimalPlaces(2);
w->Double(BINARY_WRITER_VERSION);
w->Key("Timestamp");
time_t t = time(nullptr);
w->String(ctime(&t));
std::string sTime(ctime(&t));
std::replace(sTime.begin(), sTime.end(), '\n', '\0');
w->String(sTime.c_str());
w->Key("Detector Type");
w->String(sls::ToString(detType).c_str());
w->Key("Timing Mode");
@ -110,7 +112,7 @@ void MasterAttributes::GetCommonBinaryAttributes(
}
void MasterAttributes::GetFinalBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
// adding few common parameters to the end
if (!additionalJsonHeader.empty()) {
w->Key("Additional Json Header");
@ -153,8 +155,7 @@ void MasterAttributes::GetFinalBinaryAttributes(
#ifdef HDF5C
void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
char c[1024];
memset(c, 0, sizeof(c));
char c[1024]{};
// version
{
double version = BINARY_WRITER_VERSION;
@ -276,8 +277,7 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
}
void MasterAttributes::WriteFinalHDF5Attributes(H5File *fd, Group *group) {
char c[1024];
memset(c, 0, sizeof(c));
char c[1024]{};
// Total Frames in file
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
@ -302,8 +302,7 @@ void MasterAttributes::WriteHDF5Exptime(H5File *fd, Group *group) {
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
group->createDataSet("Exposure Time", strdatatype, dataspace);
char c[1024];
memset(c, 0, sizeof(c));
char c[1024]{};
sls::strcpy_safe(c, sls::ToString(exptime));
dataset.write(c, strdatatype);
}
@ -313,8 +312,7 @@ void MasterAttributes::WriteHDF5Period(H5File *fd, Group *group) {
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
group->createDataSet("Acquisition Period", strdatatype, dataspace);
char c[1024];
memset(c, 0, sizeof(c));
char c[1024]{};
sls::strcpy_safe(c, sls::ToString(period));
dataset.write(c, strdatatype);
}
@ -371,7 +369,7 @@ void MasterAttributes::WriteHDF5ReadNRows(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5ThresholdEnergy(H5File *fd, Group *group) {
char c[1024]{0};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Threshold Energy",
PredType::NATIVE_INT, dataspace);
@ -385,7 +383,7 @@ void MasterAttributes::WriteHDF5ThresholdEnergy(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5ThresholdEnergies(H5File *fd, Group *group) {
char c[1024]{0};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 1024);
DataSet dataset =
@ -395,7 +393,7 @@ void MasterAttributes::WriteHDF5ThresholdEnergies(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5SubExpTime(H5File *fd, Group *group) {
char c[1024]{0};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
@ -405,7 +403,7 @@ void MasterAttributes::WriteHDF5SubExpTime(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5SubPeriod(H5File *fd, Group *group) {
char c[1024]{0};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
@ -422,7 +420,7 @@ void MasterAttributes::WriteHDF5SubQuad(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5RateCorrections(H5File *fd, Group *group) {
char c[1024]{0};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 1024);
DataSet dataset =
@ -440,7 +438,7 @@ void MasterAttributes::WriteHDF5CounterMask(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5ExptimeArray(H5File *fd, Group *group) {
for (int i = 0; i != 3; ++i) {
char c[1024]{0};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
@ -452,7 +450,7 @@ void MasterAttributes::WriteHDF5ExptimeArray(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5GateDelayArray(H5File *fd, Group *group) {
for (int i = 0; i != 3; ++i) {
char c[1024]{0};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
@ -474,8 +472,7 @@ void MasterAttributes::WriteHDF5BurstMode(H5File *fd, Group *group) {
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
group->createDataSet("Burst Mode", strdatatype, dataspace);
char c[1024];
memset(c, 0, sizeof(c));
char c[1024]{};
sls::strcpy_safe(c, sls::ToString(burstMode));
dataset.write(c, strdatatype);
}
@ -531,7 +528,7 @@ void MasterAttributes::WriteHDF5DbitList(H5File *fd, Group *group) {
#endif
void MasterAttributes::GetGotthardBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->Key("Exptime");
w->String(sls::ToString(exptime).c_str());
w->Key("Period");
@ -549,7 +546,7 @@ void MasterAttributes::WriteGotthardHDF5Attributes(H5File *fd, Group *group) {
#endif
void MasterAttributes::GetJungfrauBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->Key("Exptime");
w->String(sls::ToString(exptime).c_str());
w->Key("Period");
@ -570,7 +567,7 @@ void MasterAttributes::WriteJungfrauHDF5Attributes(H5File *fd, Group *group) {
#endif
void MasterAttributes::GetEigerBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->Key("Dynamic Range");
w->Uint(dynamicRange);
w->Key("Ten Giga");
@ -609,7 +606,7 @@ void MasterAttributes::WriteEigerHDF5Attributes(H5File *fd, Group *group) {
#endif
void MasterAttributes::GetMythen3BinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->Key("Dynamic Range");
w->Uint(dynamicRange);
w->Key("Ten Giga");
@ -646,7 +643,7 @@ void MasterAttributes::WriteMythen3HDF5Attributes(H5File *fd, Group *group) {
#endif
void MasterAttributes::GetGotthard2BinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->Key("Exptime");
w->String(sls::ToString(exptime).c_str());
w->Key("Period");
@ -664,7 +661,7 @@ void MasterAttributes::WriteGotthard2HDF5Attributes(H5File *fd, Group *group) {
#endif
void MasterAttributes::GetMoenchBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->Key("Exptime");
w->String(sls::ToString(exptime).c_str());
w->Key("Period");
@ -688,7 +685,7 @@ void MasterAttributes::WriteMoenchHDF5Attributes(H5File *fd, Group *group) {
#endif
void MasterAttributes::GetCtbBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) {
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
w->Key("Exptime");
w->String(sls::ToString(exptime).c_str());
w->Key("Period");

View File

@ -8,7 +8,7 @@
#include "sls/sls_detector_defs.h"
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#include <rapidjson/prettywriter.h>
#ifdef HDF5C
#include "H5Cpp.h"
@ -65,15 +65,15 @@ class MasterAttributes {
MasterAttributes() = default;
~MasterAttributes() = default;
void GetBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
void GetBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetCommonBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
GetCommonBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void
GetFinalBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
GetFinalBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteCommonHDF5Attributes(H5File *fd, Group *group);
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
@ -105,42 +105,42 @@ class MasterAttributes {
#endif
void
GetGotthardBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
GetGotthardBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteGotthardHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetJungfrauBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
GetJungfrauBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteJungfrauHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetEigerBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
GetEigerBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteEigerHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetMythen3BinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
GetMythen3BinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMythen3HDF5Attributes(H5File *fd, Group *group);
#endif
void
GetGotthard2BinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
GetGotthard2BinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteGotthard2HDF5Attributes(H5File *fd, Group *group);
#endif
void
GetMoenchBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
GetMoenchBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMoenchHDF5Attributes(H5File *fd, Group *group);
#endif
void GetCtbBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
void GetCtbBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteCtbHDF5Attributes(H5File *fd, Group *group);
#endif

View File

@ -7,38 +7,31 @@
namespace masterFileUtility {
std::string CreateMasterBinaryFile(const std::string filePath,
const std::string fileNamePrefix,
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 " +
std::string mode = "w";
if (!overWriteEnable)
mode = "wx";
FILE *fd = fopen(fileName.c_str(), mode.c_str());
if(!fd) {
throw sls::RuntimeError("Could not create/overwrite 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);
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(s);
attr->GetBinaryAttributes(&writer);
std::string message = s.GetString();
if (fwrite((void *)message.c_str(), 1, message.length(), fd) !=
message.length()) {
if (fwrite(s.GetString(), 1, strlen(s.GetString()), fd) !=
strlen(s.GetString())) {
throw sls::RuntimeError(
"Master binary file incorrect number of bytes written to file");
}

View File

@ -14,8 +14,8 @@ using namespace H5;
namespace masterFileUtility {
std::string CreateMasterBinaryFile(const std::string filePath,
const std::string fileNamePrefix,
std::string CreateMasterBinaryFile(const std::string &filePath,
const std::string &fileNamePrefix,
const uint64_t fileIndex,
const bool overWriteEnable,
const bool silentMode,