mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
wip, json master
This commit is contained in:
parent
de5c298d99
commit
90d1d0f8b8
@ -23,7 +23,7 @@ void BinaryMasterFile::CreateMasterFile(const std::string filePath,
|
|||||||
// create file name
|
// create file name
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << filePath << "/" << fileNamePrefix << "_master"
|
os << filePath << "/" << fileNamePrefix << "_master"
|
||||||
<< "_" << fileIndex << ".raw";
|
<< "_" << fileIndex << ".json";
|
||||||
fileName_ = os.str();
|
fileName_ = os.str();
|
||||||
|
|
||||||
// create file
|
// create file
|
||||||
|
@ -2,29 +2,61 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#include "MasterAttributes.h"
|
#include "MasterAttributes.h"
|
||||||
|
|
||||||
|
#include <rapidjson/stringbuffer.h>
|
||||||
|
|
||||||
|
|
||||||
void MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
void MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||||
LOG(logERROR) << "WriteMasterBinaryAttributes should have been called "
|
LOG(logERROR) << "WriteMasterBinaryAttributes should have been called "
|
||||||
"by a child class";
|
"by a child class";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MasterAttributes::GetBinaryMasterAttributes() {
|
void MasterAttributes::GetBinaryMasterAttributes(rapidjson::Writer<rapidjson::StringBuffer>* w) {
|
||||||
time_t t = time(nullptr);
|
time_t t = time(nullptr);
|
||||||
std::ostringstream oss;
|
|
||||||
oss << "Version : " << std::setprecision(2)
|
w->Key("Version");
|
||||||
<< BINARY_WRITER_VERSION << '\n'
|
w->SetMaxDecimalPlaces(2);
|
||||||
<< "TimeStamp : " << ctime(&t) << '\n'
|
w->Double(BINARY_WRITER_VERSION);
|
||||||
<< "Detector Type : " << sls::ToString(detType) << '\n'
|
|
||||||
<< "Timing Mode : " << sls::ToString(timingMode) << '\n'
|
w->Key("Timestamp");
|
||||||
<< "Geometry : " << sls::ToString(geometry) << '\n'
|
w->String(ctime(&t));
|
||||||
<< "Image Size : " << imageSize << " bytes" << '\n'
|
|
||||||
<< "Pixels : " << sls::ToString(nPixels) << '\n'
|
w->Key("Detector Type");
|
||||||
<< "Max Frames Per File : " << maxFramesPerFile << '\n'
|
w->String(sls::ToString(detType).c_str());
|
||||||
<< "Frame Discard Policy : " << sls::ToString(frameDiscardMode)
|
|
||||||
<< '\n'
|
w->Key("Timing Mode");
|
||||||
<< "Frame Padding : " << framePadding << '\n'
|
w->String(sls::ToString(timingMode).c_str());
|
||||||
<< "Scan Parameters : " << sls::ToString(scanParams) << '\n'
|
|
||||||
<< "Total Frames : " << totalFrames << '\n';
|
w->Key("Geometry");
|
||||||
return oss.str();
|
w->StartObject();
|
||||||
|
w->Key("x");
|
||||||
|
w->Uint(geometry.x);
|
||||||
|
w->Key("y");
|
||||||
|
w->Uint(geometry.y);
|
||||||
|
w->EndObject();
|
||||||
|
|
||||||
|
w->Key("Image Size in bytes");
|
||||||
|
w->Uint(imageSize);
|
||||||
|
|
||||||
|
w->Key("Pixels");
|
||||||
|
w->StartArray();
|
||||||
|
w->Uint(nPixels.x);
|
||||||
|
w->Uint(nPixels.y);
|
||||||
|
w->EndArray();
|
||||||
|
|
||||||
|
w->Key("Max Frames Per File");
|
||||||
|
w->Uint(maxFramesPerFile);
|
||||||
|
|
||||||
|
w->Key("Frame Discard Policy");
|
||||||
|
w->String(sls::ToString(frameDiscardMode).c_str());
|
||||||
|
|
||||||
|
w->Key("Frame Padding");
|
||||||
|
w->Uint(framePadding);
|
||||||
|
|
||||||
|
w->Key("Scan Parameters");
|
||||||
|
w->String(sls::ToString(scanParams).c_str());
|
||||||
|
|
||||||
|
w->Key("Total Frames");
|
||||||
|
w->Uint64(totalFrames);
|
||||||
};
|
};
|
||||||
|
|
||||||
void MasterAttributes::WriteBinaryAttributes(FILE *fd, std::string message) {
|
void MasterAttributes::WriteBinaryAttributes(FILE *fd, std::string message) {
|
||||||
@ -36,8 +68,30 @@ void MasterAttributes::WriteBinaryAttributes(FILE *fd, std::string message) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void MasterAttributes::WriteFinalBinaryAttributes(FILE *fd) {
|
void MasterAttributes::WriteFinalBinaryAttributes(FILE *fd) {
|
||||||
|
/*
|
||||||
|
FILE* fp = fopen(json_file_name.c_str(), "r");
|
||||||
|
char readBuffer[65536];
|
||||||
|
FileReadStream is(fp, readBuffer, sizeof(readBuffer));
|
||||||
|
|
||||||
|
Document d, d2;
|
||||||
|
d.ParseStream(is);
|
||||||
|
assert(d.IsArray());
|
||||||
|
fclose(fp);
|
||||||
|
d2.SetObject();
|
||||||
|
Value json_objects(kObjectType);
|
||||||
|
json_objects.AddMember("three", 3, d2.GetAllocator());
|
||||||
|
d.PushBack(json_objects, d2.GetAllocator());
|
||||||
|
|
||||||
|
FILE* outfile = fopen(json_file_name.c_str(), "w");
|
||||||
|
char writeBuffer[65536];
|
||||||
|
FileWriteStream os(outfile, writeBuffer, sizeof(writeBuffer));
|
||||||
|
|
||||||
|
Writer writer(os);
|
||||||
|
d.Accept (writer);
|
||||||
|
fclose(outfile);
|
||||||
|
*/
|
||||||
// adding few common parameters to the end
|
// adding few common parameters to the end
|
||||||
std::ostringstream oss;
|
/*std::ostringstream oss;
|
||||||
|
|
||||||
if (!additionalJsonHeader.empty()) {
|
if (!additionalJsonHeader.empty()) {
|
||||||
oss << "Additional Json Header : "
|
oss << "Additional Json Header : "
|
||||||
@ -70,7 +124,7 @@ void MasterAttributes::WriteFinalBinaryAttributes(FILE *fd) {
|
|||||||
message.length()) {
|
message.length()) {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError(
|
||||||
"Master binary file incorrect number of bytes written to file");
|
"Master binary file incorrect number of bytes written to file");
|
||||||
}
|
}*/
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
@ -270,7 +324,7 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
|
|
||||||
void GotthardMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
void GotthardMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
oss //<< MasterAttributes::GetBinaryMasterAttributes()
|
||||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||||
<< "Period : " << sls::ToString(period) << '\n'
|
<< "Period : " << sls::ToString(period) << '\n'
|
||||||
<< "Roi (xmin, xmax) : " << sls::ToString(roi) << '\n';
|
<< "Roi (xmin, xmax) : " << sls::ToString(roi) << '\n';
|
||||||
@ -301,13 +355,27 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void JungfrauMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
void JungfrauMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||||
std::ostringstream oss;
|
rapidjson::StringBuffer s;
|
||||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
|
||||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
writer.StartObject();
|
||||||
<< "Period : " << sls::ToString(period) << '\n'
|
|
||||||
<< "Number of UDP Interfaces : " << numUDPInterfaces << '\n'
|
MasterAttributes::GetBinaryMasterAttributes(&writer);
|
||||||
<< "Number of rows : " << readNRows << '\n';
|
|
||||||
std::string message = oss.str();
|
writer.Key("Exptime");
|
||||||
|
writer.String(sls::ToString(exptime).c_str());
|
||||||
|
|
||||||
|
writer.Key("Period");
|
||||||
|
writer.String(sls::ToString(period).c_str());
|
||||||
|
|
||||||
|
writer.Key("Number of UDP Interfaces");
|
||||||
|
writer.Uint(numUDPInterfaces);
|
||||||
|
|
||||||
|
writer.Key("Number of rows");
|
||||||
|
writer.Uint(readNRows);
|
||||||
|
|
||||||
|
writer.EndObject();
|
||||||
|
|
||||||
|
std::string message = s.GetString();
|
||||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -334,7 +402,7 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
|
|
||||||
void EigerMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
void EigerMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
oss //<< MasterAttributes::GetBinaryMasterAttributes()
|
||||||
<< "Dynamic Range : " << dynamicRange << '\n'
|
<< "Dynamic Range : " << dynamicRange << '\n'
|
||||||
<< "Ten Giga : " << tenGiga << '\n'
|
<< "Ten Giga : " << tenGiga << '\n'
|
||||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||||
@ -420,7 +488,7 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
|
|
||||||
void Mythen3MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
void Mythen3MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
oss //<< MasterAttributes::GetBinaryMasterAttributes()
|
||||||
<< "Dynamic Range : " << dynamicRange << '\n'
|
<< "Dynamic Range : " << dynamicRange << '\n'
|
||||||
<< "Ten Giga : " << tenGiga << '\n'
|
<< "Ten Giga : " << tenGiga << '\n'
|
||||||
<< "Period : " << sls::ToString(period) << '\n'
|
<< "Period : " << sls::ToString(period) << '\n'
|
||||||
@ -535,7 +603,7 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
|
|
||||||
void Gotthard2MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
void Gotthard2MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
oss //<< MasterAttributes::GetBinaryMasterAttributes()
|
||||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||||
<< "Period : " << sls::ToString(period) << '\n'
|
<< "Period : " << sls::ToString(period) << '\n'
|
||||||
<< "Burst Mode : " << sls::ToString(burstMode)
|
<< "Burst Mode : " << sls::ToString(burstMode)
|
||||||
@ -565,7 +633,7 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
|
|
||||||
void MoenchMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
void MoenchMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
oss //<< MasterAttributes::GetBinaryMasterAttributes()
|
||||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||||
<< "Period : " << sls::ToString(period) << '\n'
|
<< "Period : " << sls::ToString(period) << '\n'
|
||||||
<< "Ten Giga : " << tenGiga << '\n'
|
<< "Ten Giga : " << tenGiga << '\n'
|
||||||
@ -601,7 +669,7 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
|
|
||||||
void CtbMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
void CtbMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
oss //<< MasterAttributes::GetBinaryMasterAttributes()
|
||||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||||
<< "Period : " << sls::ToString(period) << '\n'
|
<< "Period : " << sls::ToString(period) << '\n'
|
||||||
<< "Ten Giga : " << tenGiga << '\n'
|
<< "Ten Giga : " << tenGiga << '\n'
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
|
#include <rapidjson/writer.h>
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
#include "H5Cpp.h"
|
#include "H5Cpp.h"
|
||||||
#ifndef H5_NO_NAMESPACE
|
#ifndef H5_NO_NAMESPACE
|
||||||
@ -68,7 +70,7 @@ class MasterAttributes {
|
|||||||
MasterAttributes() = default;
|
MasterAttributes() = default;
|
||||||
virtual ~MasterAttributes() = default;
|
virtual ~MasterAttributes() = default;
|
||||||
virtual void WriteMasterBinaryAttributes(FILE *fd);
|
virtual void WriteMasterBinaryAttributes(FILE *fd);
|
||||||
std::string GetBinaryMasterAttributes();
|
void GetBinaryMasterAttributes(rapidjson::Writer<rapidjson::StringBuffer>* w);
|
||||||
void WriteBinaryAttributes(FILE *fd, std::string message);
|
void WriteBinaryAttributes(FILE *fd, std::string message);
|
||||||
void WriteFinalBinaryAttributes(FILE *fd);
|
void WriteFinalBinaryAttributes(FILE *fd);
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
// versions
|
// versions
|
||||||
#define HDF5_WRITER_VERSION (6.4) // 1 decimal places
|
#define HDF5_WRITER_VERSION (6.4) // 1 decimal places
|
||||||
#define BINARY_WRITER_VERSION (6.4) // 1 decimal places
|
#define BINARY_WRITER_VERSION (7.0) // 1 decimal places
|
||||||
|
|
||||||
#define MAX_FRAMES_PER_FILE 20000
|
#define MAX_FRAMES_PER_FILE 20000
|
||||||
#define SHORT_MAX_FRAMES_PER_FILE 100000
|
#define SHORT_MAX_FRAMES_PER_FILE 100000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user