This commit is contained in:
maliakal_d 2022-03-29 11:49:30 +02:00
parent f2be834d55
commit 6cd780ae99
9 changed files with 701 additions and 780 deletions

View File

@ -47,12 +47,6 @@ std::string BinaryMasterFile::CreateMasterFile(const std::string filePath,
std::string BinaryMasterFile::GetMasterAttributes(MasterAttributes *attr) {
rapidjson::StringBuffer s;
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
writer.StartObject();
attr->GetCommonBinaryAttributes(&writer);
attr->GetSpecificBinaryAttributes(&writer);
attr->GetFinalBinaryAttributes(&writer);
writer.EndObject();
attr->GetBinaryAttributes(&writer);
return s.GetString();
}

View File

@ -2,7 +2,6 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include "File.h"
#include "MasterAttributes.h"
class BinaryMasterFile : private virtual slsDetectorDefs {

View File

@ -200,7 +200,7 @@ void DataProcessor::CreateVirtualFile(
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes());
}
void DataProcessor::LinkDataInMasterFile(const string &masterFileName,
void DataProcessor::LinkDataInMasterFile(const std::string &masterFileName,
const bool silentMode,
std::mutex *hdf5LibMutex) {
std::string fname, datasetName;

View File

@ -68,7 +68,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
const uint64_t numImages,
const uint32_t dynamicRange, const int numModX,
const int numModY, std::mutex *hdf5LibMutex);
void LinkDataInMasterFile(const string &masterFileName,
void LinkDataInMasterFile(const std::string &masterFileName,
const bool silentMode, std::mutex *hdf5LibMutex);
#endif

View File

@ -99,7 +99,7 @@ std::string HDF5MasterFile::CreateMasterFile(
Group group5(group3.createGroup("detector"));
Group group6(group1.createGroup("sample"));
attr->WriteMasterHDF5Attributes(&fd, &group5);
attr->WriteHDF5Attributes(&fd, &group5);
fd.close();
} catch (const Exception &error) {
error.printErrorStack();

View File

@ -2,15 +2,15 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include "File.h"
#include "MasterAttributes.h"
#include <mutex>
class HDF5MasterFile : private virtual slsDetectorDefs, public File {
class HDF5MasterFile : private virtual slsDetectorDefs {
public:
void LinkDataFile(const std::string &masterFileName,
const std::string &dataFilename,
const &std::string dataSetname,
const std::string &dataSetname,
const std::vector<std::string> parameterNames,
const bool silentMode, std::mutex *hdf5LibMutex);
std::string CreateMasterFile(const std::string &filePath,

View File

@ -745,95 +745,68 @@ void Implementation::StartMasterWriter() {
std::string masterFileName;
// master file
if (masterFileWriteEnable) {
std::unique_ptr<MasterAttributes> masterAttributes{nullptr};
switch (detType) {
case GOTTHARD:
masterAttributes = sls::make_unique<GotthardMasterAttributes>();
break;
case JUNGFRAU:
masterAttributes = sls::make_unique<JungfrauMasterAttributes>();
break;
case EIGER:
masterAttributes = sls::make_unique<EigerMasterAttributes>();
break;
case MYTHEN3:
masterAttributes = sls::make_unique<Mythen3MasterAttributes>();
break;
case GOTTHARD2:
masterAttributes =
sls::make_unique<Gotthard2MasterAttributes>();
break;
case MOENCH:
masterAttributes = sls::make_unique<MoenchMasterAttributes>();
break;
case CHIPTESTBOARD:
masterAttributes = sls::make_unique<CtbMasterAttributes>();
break;
default:
throw sls::RuntimeError(
"Unknown detector type to set up master file attributes");
}
masterAttributes->detType = detType;
masterAttributes->timingMode = timingMode;
MasterAttributes masterAttributes;
masterAttributes.detType = detType;
masterAttributes.timingMode = timingMode;
xy nm{numModules.x, numModules.y};
if (quadEnable) {
nm.x = 1;
nm.y = 2;
}
masterAttributes->geometry = xy(nm.x, nm.y);
masterAttributes->imageSize = generalData->imageSize;
masterAttributes->nPixels =
masterAttributes.geometry = xy(nm.x, nm.y);
masterAttributes.imageSize = generalData->imageSize;
masterAttributes.nPixels =
xy(generalData->nPixelsX, generalData->nPixelsY);
masterAttributes->maxFramesPerFile = framesPerFile;
masterAttributes->frameDiscardMode = frameDiscardMode;
masterAttributes->framePadding = framePadding;
masterAttributes->scanParams = scanParams;
masterAttributes->totalFrames = numberOfTotalFrames;
masterAttributes->exptime = acquisitionTime;
masterAttributes->period = acquisitionPeriod;
masterAttributes->burstMode = burstMode;
masterAttributes->numUDPInterfaces = numUDPInterfaces;
masterAttributes->dynamicRange = dynamicRange;
masterAttributes->tenGiga = tengigaEnable;
masterAttributes->thresholdEnergyeV = thresholdEnergyeV;
masterAttributes->thresholdAllEnergyeV = thresholdAllEnergyeV;
masterAttributes->subExptime = subExpTime;
masterAttributes->subPeriod = subPeriod;
masterAttributes->quad = quadEnable;
masterAttributes->readNRows = readNRows;
masterAttributes->ratecorr = rateCorrections;
masterAttributes->adcmask =
masterAttributes.maxFramesPerFile = framesPerFile;
masterAttributes.frameDiscardMode = frameDiscardMode;
masterAttributes.framePadding = framePadding;
masterAttributes.scanParams = scanParams;
masterAttributes.totalFrames = numberOfTotalFrames;
masterAttributes.exptime = acquisitionTime;
masterAttributes.period = acquisitionPeriod;
masterAttributes.burstMode = burstMode;
masterAttributes.numUDPInterfaces = numUDPInterfaces;
masterAttributes.dynamicRange = dynamicRange;
masterAttributes.tenGiga = tengigaEnable;
masterAttributes.thresholdEnergyeV = thresholdEnergyeV;
masterAttributes.thresholdAllEnergyeV = thresholdAllEnergyeV;
masterAttributes.subExptime = subExpTime;
masterAttributes.subPeriod = subPeriod;
masterAttributes.quad = quadEnable;
masterAttributes.readNRows = readNRows;
masterAttributes.ratecorr = rateCorrections;
masterAttributes.adcmask =
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
masterAttributes->analog = (readoutType == ANALOG_ONLY ||
masterAttributes.analog = (readoutType == ANALOG_ONLY ||
readoutType == ANALOG_AND_DIGITAL)
? 1
: 0;
masterAttributes.analogSamples = numberOfAnalogSamples;
masterAttributes.digital = (readoutType == DIGITAL_ONLY ||
readoutType == ANALOG_AND_DIGITAL)
? 1
: 0;
masterAttributes->analogSamples = numberOfAnalogSamples;
masterAttributes->digital = (readoutType == DIGITAL_ONLY ||
readoutType == ANALOG_AND_DIGITAL)
? 1
: 0;
masterAttributes->digitalSamples = numberOfDigitalSamples;
masterAttributes->dbitoffset = ctbDbitOffset;
masterAttributes->dbitlist = 0;
masterAttributes.digitalSamples = numberOfDigitalSamples;
masterAttributes.dbitoffset = ctbDbitOffset;
masterAttributes.dbitlist = 0;
for (auto &i : ctbDbitList) {
masterAttributes->dbitlist |= (1 << i);
masterAttributes.dbitlist |= (1 << i);
}
masterAttributes->roi = roi;
masterAttributes->counterMask = counterMask;
masterAttributes->exptime1 = acquisitionTime1;
masterAttributes->exptime2 = acquisitionTime2;
masterAttributes->exptime3 = acquisitionTime3;
masterAttributes->gateDelay1 = gateDelay1;
masterAttributes->gateDelay2 = gateDelay2;
masterAttributes->gateDelay3 = gateDelay3;
masterAttributes->gates = numberOfGates;
masterAttributes->additionalJsonHeader = additionalJsonHeader;
masterAttributes.roi = roi;
masterAttributes.counterMask = counterMask;
masterAttributes.exptimeArray[0] = acquisitionTime1;
masterAttributes.exptimeArray[1] = acquisitionTime2;
masterAttributes.exptimeArray[2] = acquisitionTime3;
masterAttributes.gateDelayArray[0] = gateDelay1;
masterAttributes.gateDelayArray[1] = gateDelay2;
masterAttributes.gateDelayArray[2] = gateDelay3;
masterAttributes.gates = numberOfGates;
masterAttributes.additionalJsonHeader = additionalJsonHeader;
// create master file
masterFileName = dataProcessor[0]->CreateMasterFile(
filePath, fileName, fileIndex, overwriteEnable, silentMode,
fileFormatType, masterAttributes.get(), &hdf5LibMutex);
fileFormatType, &masterAttributes, &hdf5LibMutex);
}
#ifdef HDF5C
if (fileFormatType == HDF5) {

File diff suppressed because it is too large Load Diff

View File

@ -56,103 +56,92 @@ class MasterAttributes {
uint64_t dbitlist{0};
slsDetectorDefs::ROI roi{};
uint32_t counterMask{0};
ns exptime1{0};
ns exptime2{0};
ns exptime3{0};
ns gateDelay1{0};
ns gateDelay2{0};
ns gateDelay3{0};
std::array<ns, 3> exptimeArray{};
std::array<ns, 3> gateDelayArray{};
uint32_t gates;
std::map<std::string, std::string> additionalJsonHeader;
// Final Attributes (after acquisition)
uint64_t framesInFile{0};
MasterAttributes() = default;
virtual ~MasterAttributes() = default;
virtual void
GetSpecificBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
~MasterAttributes() = default;
void GetBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetCommonBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
void
GetFinalBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
virtual void WriteMasterHDF5Attributes(H5File *fd, Group *group);
void WriteHDF5Attributes(H5File *fd, Group *group);
void WriteCommonHDF5Attributes(H5File *fd, Group *group);
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
void WriteHDF5Exptime(H5File *fd, Group *group);
void WriteHDF5Period(H5File *fd, Group *group);
void WriteHDF5DynamicRange(H5File *fd, Group *group);
void WriteHDF5TenGiga(H5File *fd, Group *group);
void WriteHDF5ROI(H5File *fd, Group *group);
void WriteHDF5NumUDPInterfaces(H5File *fd, Group *group);
void WriteHDF5ReadNRows(H5File *fd, Group *group);
void WriteHDF5ThresholdEnergy(H5File *fd, Group *group);
void WriteHDF5ThresholdEnergies(H5File *fd, Group *group);
void WriteHDF5SubExpTime(H5File *fd, Group *group);
void WriteHDF5SubPeriod(H5File *fd, Group *group);
void WriteHDF5SubQuad(H5File *fd, Group *group);
void WriteHDF5RateCorrections(H5File *fd, Group *group);
void WriteHDF5CounterMask(H5File *fd, Group *group);
void WriteHDF5ExptimeArray(H5File *fd, Group *group);
void WriteHDF5GateDelayArray(H5File *fd, Group *group);
void WriteHDF5Gates(H5File *fd, Group *group);
void WriteHDF5BurstMode(H5File *fd, Group *group);
void WriteHDF5AdcMask(H5File *fd, Group *group);
void WriteHDF5AnalogFlag(H5File *fd, Group *group);
void WriteHDF5AnalogSamples(H5File *fd, Group *group);
void WriteHDF5DigitalFlag(H5File *fd, Group *group);
void WriteHDF5DigitalSamples(H5File *fd, Group *group);
void WriteHDF5DbitOffset(H5File *fd, Group *group);
void WriteHDF5DbitList(H5File *fd, Group *group);
#endif
};
class GotthardMasterAttributes : public MasterAttributes {
public:
GotthardMasterAttributes() = default;
void GetSpecificBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
void
GetGotthardBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
void WriteGotthardHDF5Attributes(H5File *fd, Group *group);
#endif
};
class JungfrauMasterAttributes : public MasterAttributes {
public:
JungfrauMasterAttributes() = default;
void GetSpecificBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
void
GetJungfrauBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
void WriteJungfrauHDF5Attributes(H5File *fd, Group *group);
#endif
};
class EigerMasterAttributes : public MasterAttributes {
public:
EigerMasterAttributes() = default;
void GetSpecificBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
void
GetEigerBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
void WriteEigerHDF5Attributes(H5File *fd, Group *group);
#endif
};
class Mythen3MasterAttributes : public MasterAttributes {
public:
Mythen3MasterAttributes() = default;
void GetSpecificBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
void
GetMythen3BinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
void WriteMythen3HDF5Attributes(H5File *fd, Group *group);
#endif
};
class Gotthard2MasterAttributes : public MasterAttributes {
public:
Gotthard2MasterAttributes() = default;
void GetSpecificBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
void
GetGotthard2BinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
void WriteGotthard2HDF5Attributes(H5File *fd, Group *group);
#endif
};
class MoenchMasterAttributes : public MasterAttributes {
public:
MoenchMasterAttributes() = default;
void GetSpecificBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
void
GetMoenchBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
void WriteMoenchHDF5Attributes(H5File *fd, Group *group);
#endif
};
class CtbMasterAttributes : public MasterAttributes {
public:
CtbMasterAttributes() = default;
void GetSpecificBinaryAttributes(
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
void GetCtbBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
void WriteCtbHDF5Attributes(H5File *fd, Group *group);
#endif
};