mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 21:37:13 +02:00
wip, binary file refactored for stringbuffer, hdf5 mid way, masterattributes to be de (inherited) :)
This commit is contained in:
@ -369,7 +369,7 @@ void Implementation::setFileFormat(const fileFormat f) {
|
||||
throw sls::RuntimeError("Unknown file format");
|
||||
}
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetupFileWriter(fileWriteEnable, fileFormatType, &hdf5Lib);
|
||||
it->SetupFileWriter(fileWriteEnable, fileFormatType, &hdf5LibMutex);
|
||||
}
|
||||
|
||||
LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
|
||||
@ -405,7 +405,7 @@ void Implementation::setFileWriteEnable(const bool b) {
|
||||
if (fileWriteEnable != b) {
|
||||
fileWriteEnable = b;
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetupFileWriter(fileWriteEnable, fileFormatType, &hdf5Lib);
|
||||
it->SetupFileWriter(fileWriteEnable, fileFormatType, &hdf5LibMutex);
|
||||
}
|
||||
LOG(logINFO) << "File Write Enable: "
|
||||
<< (fileWriteEnable ? "enabled" : "disabled");
|
||||
@ -741,116 +741,121 @@ void Implementation::SetupWriter() {
|
||||
}
|
||||
|
||||
void Implementation::StartMasterWriter() {
|
||||
// master file
|
||||
if (masterFileWriteEnable) {
|
||||
std::unique_ptr<MasterAttributes> masterAttributes;
|
||||
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;
|
||||
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 =
|
||||
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 =
|
||||
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
|
||||
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->digitalSamples = numberOfDigitalSamples;
|
||||
masterAttributes->dbitoffset = ctbDbitOffset;
|
||||
masterAttributes->dbitlist = 0;
|
||||
for (auto &i : ctbDbitList) {
|
||||
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;
|
||||
|
||||
try {
|
||||
dataProcessor[0]->CreateMasterFile(
|
||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||
fileFormatType, masterAttributes.get());
|
||||
} catch (...) {
|
||||
; // ignore it and just print it
|
||||
}
|
||||
}
|
||||
#ifdef HDF5C
|
||||
if (fileFormatType == HDF5) {
|
||||
// virtual hdf5 file (if multiple files)
|
||||
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
|
||||
(numModules.x * numModules.y) > 1) {
|
||||
dataProcessor[0]->CreateVirtualFile(
|
||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||
modulePos, numUDPInterfaces, framesPerFile, numberOfTotalFrames,
|
||||
dynamicRange, numModules.x, numModules.y, &hdf5Lib);
|
||||
}
|
||||
// link file in master
|
||||
try {
|
||||
std::string masterFileName;
|
||||
// master file
|
||||
if (masterFileWriteEnable) {
|
||||
dataProcessor[0]->LinkDataInMasterFile(silentMode);
|
||||
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;
|
||||
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 =
|
||||
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 =
|
||||
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
|
||||
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->digitalSamples = numberOfDigitalSamples;
|
||||
masterAttributes->dbitoffset = ctbDbitOffset;
|
||||
masterAttributes->dbitlist = 0;
|
||||
for (auto &i : ctbDbitList) {
|
||||
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;
|
||||
|
||||
// create master file
|
||||
masterFileName = dataProcessor[0]->CreateMasterFile(
|
||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||
fileFormatType, masterAttributes.get(), &hdf5LibMutex);
|
||||
}
|
||||
#ifdef HDF5C
|
||||
if (fileFormatType == HDF5) {
|
||||
// create virtual hdf5 file (if multiple files)
|
||||
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
|
||||
(numModules.x * numModules.y) > 1) {
|
||||
dataProcessor[0]->CreateVirtualFile(
|
||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||
modulePos, numUDPInterfaces, framesPerFile,
|
||||
numberOfTotalFrames, dynamicRange, numModules.x,
|
||||
numModules.y, &hdf5LibMutex);
|
||||
}
|
||||
// link file in master
|
||||
if (masterFileWriteEnable) {
|
||||
dataProcessor[0]->LinkDataInMasterFile(
|
||||
masterFileName, silentMode, &hdf5LibMutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} catch (...) {
|
||||
; // ignore it and just print it
|
||||
}
|
||||
}
|
||||
|
||||
void Implementation::StartRunning() {
|
||||
|
Reference in New Issue
Block a user