mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 02:20:42 +02:00
wip
This commit is contained in:
parent
f2be834d55
commit
6cd780ae99
@ -47,12 +47,6 @@ std::string BinaryMasterFile::CreateMasterFile(const std::string filePath,
|
|||||||
std::string BinaryMasterFile::GetMasterAttributes(MasterAttributes *attr) {
|
std::string BinaryMasterFile::GetMasterAttributes(MasterAttributes *attr) {
|
||||||
rapidjson::StringBuffer s;
|
rapidjson::StringBuffer s;
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
|
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
|
||||||
writer.StartObject();
|
attr->GetBinaryAttributes(&writer);
|
||||||
|
|
||||||
attr->GetCommonBinaryAttributes(&writer);
|
|
||||||
attr->GetSpecificBinaryAttributes(&writer);
|
|
||||||
attr->GetFinalBinaryAttributes(&writer);
|
|
||||||
|
|
||||||
writer.EndObject();
|
|
||||||
return s.GetString();
|
return s.GetString();
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "File.h"
|
|
||||||
#include "MasterAttributes.h"
|
#include "MasterAttributes.h"
|
||||||
|
|
||||||
class BinaryMasterFile : private virtual slsDetectorDefs {
|
class BinaryMasterFile : private virtual slsDetectorDefs {
|
||||||
|
@ -200,7 +200,7 @@ void DataProcessor::CreateVirtualFile(
|
|||||||
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes());
|
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::LinkDataInMasterFile(const string &masterFileName,
|
void DataProcessor::LinkDataInMasterFile(const std::string &masterFileName,
|
||||||
const bool silentMode,
|
const bool silentMode,
|
||||||
std::mutex *hdf5LibMutex) {
|
std::mutex *hdf5LibMutex) {
|
||||||
std::string fname, datasetName;
|
std::string fname, datasetName;
|
||||||
|
@ -68,7 +68,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
const uint64_t numImages,
|
const uint64_t numImages,
|
||||||
const uint32_t dynamicRange, const int numModX,
|
const uint32_t dynamicRange, const int numModX,
|
||||||
const int numModY, std::mutex *hdf5LibMutex);
|
const int numModY, std::mutex *hdf5LibMutex);
|
||||||
void LinkDataInMasterFile(const string &masterFileName,
|
void LinkDataInMasterFile(const std::string &masterFileName,
|
||||||
const bool silentMode, std::mutex *hdf5LibMutex);
|
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ std::string HDF5MasterFile::CreateMasterFile(
|
|||||||
Group group5(group3.createGroup("detector"));
|
Group group5(group3.createGroup("detector"));
|
||||||
Group group6(group1.createGroup("sample"));
|
Group group6(group1.createGroup("sample"));
|
||||||
|
|
||||||
attr->WriteMasterHDF5Attributes(&fd, &group5);
|
attr->WriteHDF5Attributes(&fd, &group5);
|
||||||
fd.close();
|
fd.close();
|
||||||
} catch (const Exception &error) {
|
} catch (const Exception &error) {
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "File.h"
|
#include "MasterAttributes.h"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
class HDF5MasterFile : private virtual slsDetectorDefs, public File {
|
class HDF5MasterFile : private virtual slsDetectorDefs {
|
||||||
public:
|
public:
|
||||||
void LinkDataFile(const std::string &masterFileName,
|
void LinkDataFile(const std::string &masterFileName,
|
||||||
const std::string &dataFilename,
|
const std::string &dataFilename,
|
||||||
const &std::string dataSetname,
|
const std::string &dataSetname,
|
||||||
const std::vector<std::string> parameterNames,
|
const std::vector<std::string> parameterNames,
|
||||||
const bool silentMode, std::mutex *hdf5LibMutex);
|
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||||
std::string CreateMasterFile(const std::string &filePath,
|
std::string CreateMasterFile(const std::string &filePath,
|
||||||
|
@ -745,95 +745,68 @@ void Implementation::StartMasterWriter() {
|
|||||||
std::string masterFileName;
|
std::string masterFileName;
|
||||||
// master file
|
// master file
|
||||||
if (masterFileWriteEnable) {
|
if (masterFileWriteEnable) {
|
||||||
std::unique_ptr<MasterAttributes> masterAttributes{nullptr};
|
MasterAttributes masterAttributes;
|
||||||
switch (detType) {
|
masterAttributes.detType = detType;
|
||||||
case GOTTHARD:
|
masterAttributes.timingMode = timingMode;
|
||||||
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;
|
|
||||||
xy nm{numModules.x, numModules.y};
|
xy nm{numModules.x, numModules.y};
|
||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
nm.x = 1;
|
nm.x = 1;
|
||||||
nm.y = 2;
|
nm.y = 2;
|
||||||
}
|
}
|
||||||
masterAttributes->geometry = xy(nm.x, nm.y);
|
masterAttributes.geometry = xy(nm.x, nm.y);
|
||||||
masterAttributes->imageSize = generalData->imageSize;
|
masterAttributes.imageSize = generalData->imageSize;
|
||||||
masterAttributes->nPixels =
|
masterAttributes.nPixels =
|
||||||
xy(generalData->nPixelsX, generalData->nPixelsY);
|
xy(generalData->nPixelsX, generalData->nPixelsY);
|
||||||
masterAttributes->maxFramesPerFile = framesPerFile;
|
masterAttributes.maxFramesPerFile = framesPerFile;
|
||||||
masterAttributes->frameDiscardMode = frameDiscardMode;
|
masterAttributes.frameDiscardMode = frameDiscardMode;
|
||||||
masterAttributes->framePadding = framePadding;
|
masterAttributes.framePadding = framePadding;
|
||||||
masterAttributes->scanParams = scanParams;
|
masterAttributes.scanParams = scanParams;
|
||||||
masterAttributes->totalFrames = numberOfTotalFrames;
|
masterAttributes.totalFrames = numberOfTotalFrames;
|
||||||
masterAttributes->exptime = acquisitionTime;
|
masterAttributes.exptime = acquisitionTime;
|
||||||
masterAttributes->period = acquisitionPeriod;
|
masterAttributes.period = acquisitionPeriod;
|
||||||
masterAttributes->burstMode = burstMode;
|
masterAttributes.burstMode = burstMode;
|
||||||
masterAttributes->numUDPInterfaces = numUDPInterfaces;
|
masterAttributes.numUDPInterfaces = numUDPInterfaces;
|
||||||
masterAttributes->dynamicRange = dynamicRange;
|
masterAttributes.dynamicRange = dynamicRange;
|
||||||
masterAttributes->tenGiga = tengigaEnable;
|
masterAttributes.tenGiga = tengigaEnable;
|
||||||
masterAttributes->thresholdEnergyeV = thresholdEnergyeV;
|
masterAttributes.thresholdEnergyeV = thresholdEnergyeV;
|
||||||
masterAttributes->thresholdAllEnergyeV = thresholdAllEnergyeV;
|
masterAttributes.thresholdAllEnergyeV = thresholdAllEnergyeV;
|
||||||
masterAttributes->subExptime = subExpTime;
|
masterAttributes.subExptime = subExpTime;
|
||||||
masterAttributes->subPeriod = subPeriod;
|
masterAttributes.subPeriod = subPeriod;
|
||||||
masterAttributes->quad = quadEnable;
|
masterAttributes.quad = quadEnable;
|
||||||
masterAttributes->readNRows = readNRows;
|
masterAttributes.readNRows = readNRows;
|
||||||
masterAttributes->ratecorr = rateCorrections;
|
masterAttributes.ratecorr = rateCorrections;
|
||||||
masterAttributes->adcmask =
|
masterAttributes.adcmask =
|
||||||
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
|
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)
|
readoutType == ANALOG_AND_DIGITAL)
|
||||||
? 1
|
? 1
|
||||||
: 0;
|
: 0;
|
||||||
masterAttributes->analogSamples = numberOfAnalogSamples;
|
masterAttributes.digitalSamples = numberOfDigitalSamples;
|
||||||
masterAttributes->digital = (readoutType == DIGITAL_ONLY ||
|
masterAttributes.dbitoffset = ctbDbitOffset;
|
||||||
readoutType == ANALOG_AND_DIGITAL)
|
masterAttributes.dbitlist = 0;
|
||||||
? 1
|
|
||||||
: 0;
|
|
||||||
masterAttributes->digitalSamples = numberOfDigitalSamples;
|
|
||||||
masterAttributes->dbitoffset = ctbDbitOffset;
|
|
||||||
masterAttributes->dbitlist = 0;
|
|
||||||
for (auto &i : ctbDbitList) {
|
for (auto &i : ctbDbitList) {
|
||||||
masterAttributes->dbitlist |= (1 << i);
|
masterAttributes.dbitlist |= (1 << i);
|
||||||
}
|
}
|
||||||
masterAttributes->roi = roi;
|
masterAttributes.roi = roi;
|
||||||
masterAttributes->counterMask = counterMask;
|
masterAttributes.counterMask = counterMask;
|
||||||
masterAttributes->exptime1 = acquisitionTime1;
|
masterAttributes.exptimeArray[0] = acquisitionTime1;
|
||||||
masterAttributes->exptime2 = acquisitionTime2;
|
masterAttributes.exptimeArray[1] = acquisitionTime2;
|
||||||
masterAttributes->exptime3 = acquisitionTime3;
|
masterAttributes.exptimeArray[2] = acquisitionTime3;
|
||||||
masterAttributes->gateDelay1 = gateDelay1;
|
masterAttributes.gateDelayArray[0] = gateDelay1;
|
||||||
masterAttributes->gateDelay2 = gateDelay2;
|
masterAttributes.gateDelayArray[1] = gateDelay2;
|
||||||
masterAttributes->gateDelay3 = gateDelay3;
|
masterAttributes.gateDelayArray[2] = gateDelay3;
|
||||||
masterAttributes->gates = numberOfGates;
|
masterAttributes.gates = numberOfGates;
|
||||||
masterAttributes->additionalJsonHeader = additionalJsonHeader;
|
masterAttributes.additionalJsonHeader = additionalJsonHeader;
|
||||||
|
|
||||||
// create master file
|
// create master file
|
||||||
masterFileName = dataProcessor[0]->CreateMasterFile(
|
masterFileName = dataProcessor[0]->CreateMasterFile(
|
||||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||||
fileFormatType, masterAttributes.get(), &hdf5LibMutex);
|
fileFormatType, &masterAttributes, &hdf5LibMutex);
|
||||||
}
|
}
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
if (fileFormatType == HDF5) {
|
if (fileFormatType == HDF5) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -56,103 +56,92 @@ class MasterAttributes {
|
|||||||
uint64_t dbitlist{0};
|
uint64_t dbitlist{0};
|
||||||
slsDetectorDefs::ROI roi{};
|
slsDetectorDefs::ROI roi{};
|
||||||
uint32_t counterMask{0};
|
uint32_t counterMask{0};
|
||||||
ns exptime1{0};
|
std::array<ns, 3> exptimeArray{};
|
||||||
ns exptime2{0};
|
std::array<ns, 3> gateDelayArray{};
|
||||||
ns exptime3{0};
|
|
||||||
ns gateDelay1{0};
|
|
||||||
ns gateDelay2{0};
|
|
||||||
ns gateDelay3{0};
|
|
||||||
uint32_t gates;
|
uint32_t gates;
|
||||||
std::map<std::string, std::string> additionalJsonHeader;
|
std::map<std::string, std::string> additionalJsonHeader;
|
||||||
|
|
||||||
// Final Attributes (after acquisition)
|
|
||||||
uint64_t framesInFile{0};
|
uint64_t framesInFile{0};
|
||||||
|
|
||||||
MasterAttributes() = default;
|
MasterAttributes() = default;
|
||||||
virtual ~MasterAttributes() = default;
|
~MasterAttributes() = default;
|
||||||
virtual void
|
|
||||||
GetSpecificBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
void GetBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
|
#ifdef HDF5C
|
||||||
|
void WriteHDF5Attributes(H5File *fd, Group *group);
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
GetCommonBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
GetCommonBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
void
|
void
|
||||||
GetFinalBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
GetFinalBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
virtual void WriteMasterHDF5Attributes(H5File *fd, Group *group);
|
void WriteCommonHDF5Attributes(H5File *fd, Group *group);
|
||||||
void WriteHDF5Attributes(H5File *fd, Group *group);
|
|
||||||
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
|
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
|
||||||
void WriteHDF5Exptime(H5File *fd, Group *group);
|
void WriteHDF5Exptime(H5File *fd, Group *group);
|
||||||
void WriteHDF5Period(H5File *fd, Group *group);
|
void WriteHDF5Period(H5File *fd, Group *group);
|
||||||
void WriteHDF5DynamicRange(H5File *fd, Group *group);
|
void WriteHDF5DynamicRange(H5File *fd, Group *group);
|
||||||
void WriteHDF5TenGiga(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
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class GotthardMasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetGotthardBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
GotthardMasterAttributes() = default;
|
|
||||||
void GetSpecificBinaryAttributes(
|
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteGotthardHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class JungfrauMasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetJungfrauBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
JungfrauMasterAttributes() = default;
|
|
||||||
void GetSpecificBinaryAttributes(
|
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteJungfrauHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class EigerMasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetEigerBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
EigerMasterAttributes() = default;
|
|
||||||
void GetSpecificBinaryAttributes(
|
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteEigerHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class Mythen3MasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetMythen3BinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
Mythen3MasterAttributes() = default;
|
|
||||||
void GetSpecificBinaryAttributes(
|
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteMythen3HDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class Gotthard2MasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetGotthard2BinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
Gotthard2MasterAttributes() = default;
|
|
||||||
void GetSpecificBinaryAttributes(
|
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteGotthard2HDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class MoenchMasterAttributes : public MasterAttributes {
|
void
|
||||||
public:
|
GetMoenchBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
MoenchMasterAttributes() = default;
|
|
||||||
void GetSpecificBinaryAttributes(
|
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteMoenchHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
class CtbMasterAttributes : public MasterAttributes {
|
void GetCtbBinaryAttributes(rapidjson::Writer<rapidjson::StringBuffer> *w);
|
||||||
public:
|
|
||||||
CtbMasterAttributes() = default;
|
|
||||||
void GetSpecificBinaryAttributes(
|
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> *w) override;
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
void WriteCtbHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user