mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
wip
This commit is contained in:
parent
61c5018a46
commit
d3c6996d80
@ -2234,8 +2234,12 @@ void *start_timer(void *arg) {
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
if (!eiger_virtual_activate) {
|
||||
return NULL;
|
||||
|
||||
int skipData = 0;
|
||||
if (!eiger_virtual_activate ||
|
||||
(!eiger_virtual_left_datastream && !eiger_virtual_right_datastream)) {
|
||||
skipData = 1;
|
||||
LOG(logWARNING, ("Not sending Left and Right datastream\n"));
|
||||
}
|
||||
if (!eiger_virtual_left_datastream) {
|
||||
LOG(logWARNING, ("Not sending Left datastream\n"));
|
||||
@ -2305,7 +2309,7 @@ void *start_timer(void *arg) {
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
if (!skipData) {
|
||||
uint64_t frameNr = 0;
|
||||
getNextFrameNumber(&frameNr);
|
||||
// loop over number of frames
|
||||
|
@ -65,14 +65,12 @@ void BinaryFile::CreateFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void BinaryFile::CloseCurrentFile() {
|
||||
if (filefd)
|
||||
fclose(filefd);
|
||||
filefd = nullptr;
|
||||
void BinaryFile::CloseAllFiles() {
|
||||
CloseCurrentDataFile();
|
||||
CloseMasterFile();
|
||||
}
|
||||
|
||||
void BinaryFile::CloseAllFiles() {
|
||||
CloseCurrentFile();
|
||||
void BinaryFile::CloseMasterFile() {
|
||||
if (master) {
|
||||
if (masterfd)
|
||||
fclose(masterfd);
|
||||
@ -80,6 +78,12 @@ void BinaryFile::CloseAllFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
void BinaryFile::CloseCurrentDataFile() {
|
||||
if (filefd)
|
||||
fclose(filefd);
|
||||
filefd = nullptr;
|
||||
}
|
||||
|
||||
int BinaryFile::WriteData(char *buf, int bsize) {
|
||||
if (!filefd)
|
||||
return 0;
|
||||
@ -133,14 +137,8 @@ void BinaryFile::WriteToFile(char *buffer, int buffersize,
|
||||
}
|
||||
}
|
||||
|
||||
void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
|
||||
MasterAttributes *attr) {
|
||||
// beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
|
||||
if (masterFileWriteEnable && master) {
|
||||
|
||||
void BinaryFile::CreateMasterFile(MasterAttributes *attr) {
|
||||
if (master) {
|
||||
std::ostringstream os;
|
||||
os << *filePath << "/" << *fileNamePrefix << "_master"
|
||||
<< "_" << *fileIndex << ".raw";
|
||||
@ -173,3 +171,8 @@ void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
|
||||
masterfd = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void BinaryFile::StartofAcquisition() {
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
}
|
||||
|
@ -41,10 +41,11 @@ class BinaryFile : private virtual slsDetectorDefs, public File {
|
||||
|
||||
void PrintMembers(TLogLevel level = logDEBUG1) override;
|
||||
void CreateFile() override;
|
||||
void CreateMasterFile(bool masterFileWriteEnable,
|
||||
MasterAttributes *attr) override;
|
||||
void CloseCurrentFile() override;
|
||||
void CreateMasterFile(MasterAttributes *attr) override;
|
||||
void StartofAcquisition() override;
|
||||
void CloseAllFiles() override;
|
||||
void CloseCurrentDataFile() override;
|
||||
void CloseMasterFile() override;
|
||||
void WriteToFile(char *buffer, int buffersize, uint64_t currentFrameNumber,
|
||||
uint32_t numPacketsCaught) override;
|
||||
|
||||
|
@ -22,25 +22,26 @@
|
||||
|
||||
const std::string DataProcessor::TypeName = "DataProcessor";
|
||||
|
||||
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo *f,
|
||||
fileFormat *ftype, bool fwenable, bool *mfwenable,
|
||||
bool *dsEnable, uint32_t *freq, uint32_t *timer,
|
||||
uint32_t *sfnum, bool *fp, bool *act,
|
||||
bool *depaden, bool *sm, std::vector<int> *cdl,
|
||||
int *cdo, int *cad)
|
||||
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo *f, bool act,
|
||||
bool depaden, bool *dsEnable, uint32_t *freq,
|
||||
uint32_t *timer, uint32_t *sfnum, bool *fp,
|
||||
bool *sm, std::vector<int> *cdl, int *cdo,
|
||||
int *cad)
|
||||
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype),
|
||||
dataStreamEnable(dsEnable), fileFormatType(ftype),
|
||||
fileWriteEnable(fwenable), masterFileWriteEnable(mfwenable),
|
||||
streamingFrequency(freq), streamingTimerInMs(timer),
|
||||
streamingStartFnum(sfnum), activated(act),
|
||||
deactivatedPaddingEnable(depaden), silentMode(sm), framePadding(fp),
|
||||
ctbDbitList(cdl), ctbDbitOffset(cdo), ctbAnalogDataBytes(cad),
|
||||
firstStreamerFrame(false) {
|
||||
dataStreamEnable(dsEnable), activated(act),
|
||||
deactivatedPaddingEnable(depaden), streamingFrequency(freq),
|
||||
streamingTimerInMs(timer), streamingStartFnum(sfnum), silentMode(sm),
|
||||
framePadding(fp), ctbDbitList(cdl), ctbDbitOffset(cdo),
|
||||
ctbAnalogDataBytes(cad), firstStreamerFrame(false) {
|
||||
LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
||||
memset((void *)&timerBegin, 0, sizeof(timespec));
|
||||
}
|
||||
|
||||
DataProcessor::~DataProcessor() { delete file; }
|
||||
DataProcessor::~DataProcessor() {
|
||||
delete file;
|
||||
delete masterFile;
|
||||
delete virtualFile;
|
||||
}
|
||||
|
||||
/** getters */
|
||||
|
||||
@ -83,74 +84,109 @@ void DataProcessor::SetGeneralData(GeneralData *g) {
|
||||
generalData->nPixelsY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataProcessor::SetFileFormat(const fileFormat f) {
|
||||
if ((file != nullptr) && file->GetFileType() != f) {
|
||||
// remember the pointer values before they are destroyed
|
||||
int nd[MAX_DIMENSIONS];
|
||||
nd[0] = 0;
|
||||
nd[1] = 0;
|
||||
uint32_t *maxf = nullptr;
|
||||
std::string *fname = nullptr;
|
||||
std::string *fpath = nullptr;
|
||||
uint64_t *findex = nullptr;
|
||||
bool *owenable = nullptr;
|
||||
int *dindex = nullptr;
|
||||
int *nunits = nullptr;
|
||||
uint64_t *nf = nullptr;
|
||||
uint32_t *dr = nullptr;
|
||||
uint32_t *port = nullptr;
|
||||
file->GetMemberPointerValues(nd, maxf, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, port);
|
||||
// create file writer with same pointers
|
||||
SetupFileWriter(fileWriteEnable, nd, maxf, fname, fpath, findex,
|
||||
owenable, dindex, nunits, nf, dr, port);
|
||||
if (masterFile != nullptr) {
|
||||
if (masterFile->GetFileType() == HDF5) {
|
||||
masterFile->SetNumberofPixels(generalData->nPixelsX,
|
||||
generalData->nPixelsY);
|
||||
}
|
||||
}
|
||||
if (virtualFile != nullptr) {
|
||||
if (virtualFile->GetFileType() == HDF5) {
|
||||
virtualFile->SetNumberofPixels(generalData->nPixelsX,
|
||||
generalData->nPixelsY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataProcessor::SetupFileWriter(bool fwe, int *nd, uint32_t *maxf,
|
||||
void DataProcessor::SetupFileWriter(fileFormat ftype, bool fwe, int act,
|
||||
int depaden, int *nd, uint32_t *maxf,
|
||||
std::string *fname, std::string *fpath,
|
||||
uint64_t *findex, bool *owenable,
|
||||
int *dindex, int *nunits, uint64_t *nf,
|
||||
uint32_t *dr, uint32_t *portno,
|
||||
GeneralData *g) {
|
||||
fileWriteEnable = fwe;
|
||||
activated = act;
|
||||
deactivatedPaddingEnable = depaden;
|
||||
if (g != nullptr)
|
||||
generalData = g;
|
||||
|
||||
// close existing file objects
|
||||
if (file != nullptr) {
|
||||
delete file;
|
||||
file = nullptr;
|
||||
}
|
||||
if (masterFile != nullptr) {
|
||||
delete masterFile;
|
||||
masterFile = nullptr;
|
||||
}
|
||||
if (virtualFile != nullptr) {
|
||||
delete virtualFile;
|
||||
virtualFile = nullptr;
|
||||
}
|
||||
// skip data file writing for deactivated non padded parts
|
||||
bool skipDataFileWriting = false;
|
||||
if (myDetectorType == EIGER && !activated && !deactivatedPaddingEnable) {
|
||||
skipDataFileWriting = true;
|
||||
}
|
||||
|
||||
if (fileWriteEnable) {
|
||||
switch (*fileFormatType) {
|
||||
// create file objects
|
||||
if (fwe) {
|
||||
switch (fileFormatType) {
|
||||
#ifdef HDF5C
|
||||
case HDF5:
|
||||
file = new HDF5File(index, maxf, nd, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, portno,
|
||||
generalData->nPixelsX, generalData->nPixelsY,
|
||||
silentMode);
|
||||
// data file
|
||||
if (!skipDataFileWriting) {
|
||||
file = new HDF5File(index, maxf, nd, fname, fpath, findex,
|
||||
owenable, dindex, nunits, nf, dr, portno,
|
||||
generalData->nPixelsX,
|
||||
generalData->nPixelsY, silentMode);
|
||||
}
|
||||
// master file
|
||||
if ((index == 0) && (*dindex == 0)) {
|
||||
masterFile = new HDF5File(index, maxf, nd, fname, fpath, findex,
|
||||
owenable, dindex, nunits, nf, dr,
|
||||
portno, generalData->nPixelsX,
|
||||
generalData->nPixelsY, silentMode);
|
||||
virtualFile = new HDF5File(index, maxf, nd, fname, fpath,
|
||||
findex, owenable, dindex, nunits, nf,
|
||||
dr, portno, generalData->nPixelsX,
|
||||
generalData->nPixelsY, silentMode);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
file =
|
||||
new BinaryFile(index, maxf, nd, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, portno, silentMode);
|
||||
// data file
|
||||
if (!skipDataFileWriting) {
|
||||
file = new BinaryFile(index, maxf, nd, fname, fpath, findex,
|
||||
owenable, dindex, nunits, nf, dr, portno,
|
||||
silentMode);
|
||||
}
|
||||
// master file
|
||||
if ((index == 0) && (*dindex == 0)) {
|
||||
masterFile = new BinaryFile(index, maxf, nd, fname, fpath,
|
||||
findex, owenable, dindex, nunits,
|
||||
nf, dr, portno, silentMode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only the first file
|
||||
void DataProcessor::CreateNewFile(MasterAttributes *attr) {
|
||||
void DataProcessor::CreateMasterFile(MasterAttributes *attr) {
|
||||
if (masterFile == nullptr) {
|
||||
throw sls::RuntimeError("master file object not contstructed");
|
||||
}
|
||||
masterFile->CloseMasterFile();
|
||||
masterFile->CreateMasterFile(attr);
|
||||
}
|
||||
|
||||
void DataProcessor::CreateFirstDataFile() {
|
||||
if (file == nullptr) {
|
||||
throw sls::RuntimeError("file object not contstructed");
|
||||
}
|
||||
file->CloseAllFiles();
|
||||
file->CloseCurrentDataFile();
|
||||
file->resetSubFileIndex();
|
||||
file->CreateMasterFile(*masterFileWriteEnable, attr);
|
||||
file->StartofAcquisition();
|
||||
file->CreateFile();
|
||||
}
|
||||
|
||||
@ -249,11 +285,11 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
||||
}
|
||||
|
||||
// frame padding
|
||||
if (*activated && *framePadding && nump < generalData->packetsPerFrame)
|
||||
if (activated && *framePadding && nump < generalData->packetsPerFrame)
|
||||
PadMissingPackets(buf);
|
||||
|
||||
// deactivated and padding enabled
|
||||
else if (!(*activated) && *deactivatedPaddingEnable)
|
||||
else if (!activated && deactivatedPaddingEnable)
|
||||
PadMissingPackets(buf);
|
||||
|
||||
// rearrange ctb digital bits (if ctbDbitlist is not empty)
|
||||
|
@ -31,27 +31,23 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* @param ind self index
|
||||
* @param dtype detector type
|
||||
* @param f address of Fifo pointer
|
||||
* @param ftype pointer to file format type
|
||||
* @param fwenable file writer enable
|
||||
* @param mfwenable pointer to master file write enable
|
||||
* @param act activated
|
||||
* @param depaden deactivated padding enable
|
||||
* @param dsEnable pointer to data stream enable
|
||||
* @param dr pointer to dynamic range
|
||||
* @param freq pointer to streaming frequency
|
||||
* @param timer pointer to timer if streaming frequency is random
|
||||
* @param sfnum pointer to streaming starting fnum
|
||||
* @param fp pointer to frame padding enable
|
||||
* @param act pointer to activated
|
||||
* @param depaden pointer to deactivated padding enable
|
||||
* @param sm pointer to silent mode
|
||||
* @param qe pointer to quad Enable
|
||||
* @param cdl pointer to vector or ctb digital bits enable
|
||||
* @param cdo pointer to digital bits offset
|
||||
* @param cad pointer to ctb analog databytes
|
||||
*/
|
||||
DataProcessor(int ind, detectorType dtype, Fifo *f, fileFormat *ftype,
|
||||
bool fwenable, bool *mfwenable, bool *dsEnable,
|
||||
uint32_t *freq, uint32_t *timer, uint32_t *sfnum, bool *fp,
|
||||
bool *act, bool *depaden, bool *sm, std::vector<int> *cdl,
|
||||
DataProcessor(int ind, detectorType dtype, Fifo *f, bool act, bool depaden,
|
||||
bool *dsEnable, uint32_t *freq, uint32_t *timer,
|
||||
uint32_t *sfnum, bool *fp, bool *sm, std::vector<int> *cdl,
|
||||
int *cdo, int *cad);
|
||||
|
||||
/**
|
||||
@ -104,15 +100,12 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
*/
|
||||
void SetGeneralData(GeneralData *g);
|
||||
|
||||
/**
|
||||
* Set File Format
|
||||
* @param fs file format
|
||||
*/
|
||||
void SetFileFormat(const fileFormat fs);
|
||||
|
||||
/**
|
||||
* Set up file writer object and call backs
|
||||
* @param ftype file format
|
||||
* @param fwe file write enable
|
||||
* @param act activated
|
||||
* @param depad deactivated padding enable
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param maxf pointer to max frames per file
|
||||
* @param fname pointer to file name prefix
|
||||
@ -126,16 +119,22 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* @param portno pointer to udp port number
|
||||
* @param g address of GeneralData (Detector Data) pointer
|
||||
*/
|
||||
void SetupFileWriter(bool fwe, int *nd, uint32_t *maxf, std::string *fname,
|
||||
void SetupFileWriter(fileFormat ftype, bool fwe, int act, int depaden,
|
||||
int *nd, uint32_t *maxf, std::string *fname,
|
||||
std::string *fpath, uint64_t *findex, bool *owenable,
|
||||
int *dindex, int *nunits, uint64_t *nf, uint32_t *dr,
|
||||
uint32_t *portno, GeneralData *g = nullptr);
|
||||
|
||||
/**
|
||||
* Create New File
|
||||
* Create Master File (also virtual if hdf5)
|
||||
* @param attr master file attributes
|
||||
*/
|
||||
void CreateNewFile(MasterAttributes *attr);
|
||||
void CreateMasterFile(MasterAttributes *attr);
|
||||
|
||||
/**
|
||||
* Create First Data File
|
||||
*/
|
||||
void CreatFirsteDataFile();
|
||||
|
||||
/**
|
||||
* Closes files
|
||||
@ -256,17 +255,20 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/** File writer implemented as binary or hdf5 File */
|
||||
File *file{nullptr};
|
||||
|
||||
/** master file */
|
||||
File *masterFile{nullptr};
|
||||
|
||||
/** virtual file (for hdf5) */
|
||||
File *virtualFile{nullptr};
|
||||
|
||||
/** Data Stream Enable */
|
||||
bool *dataStreamEnable;
|
||||
|
||||
/** File Format Type */
|
||||
fileFormat *fileFormatType;
|
||||
/** Activated/Deactivated */
|
||||
bool activated;
|
||||
|
||||
/** File Write Enable */
|
||||
bool fileWriteEnable;
|
||||
|
||||
/** Master File Write Enable */
|
||||
bool *masterFileWriteEnable;
|
||||
/** Deactivated padding enable */
|
||||
bool deactivatedPaddingEnable;
|
||||
|
||||
/** Pointer to Streaming frequency, if 0, sending random images with a timer
|
||||
*/
|
||||
@ -284,12 +286,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/** timer beginning stamp for random streaming */
|
||||
struct timespec timerBegin;
|
||||
|
||||
/** Activated/Deactivated */
|
||||
bool *activated;
|
||||
|
||||
/** Deactivated padding enable */
|
||||
bool *deactivatedPaddingEnable;
|
||||
|
||||
/** Silent Mode */
|
||||
bool *silentMode;
|
||||
|
||||
|
@ -70,8 +70,9 @@ class File : private virtual slsDetectorDefs {
|
||||
uint32_t *&portno);
|
||||
|
||||
virtual void CreateFile() = 0;
|
||||
virtual void CloseCurrentFile() = 0;
|
||||
virtual void CloseCurrentDataFile() = 0;
|
||||
virtual void CloseAllFiles() = 0;
|
||||
virtual void CloseMasterFile() = 0;
|
||||
|
||||
/**
|
||||
* Write data to file
|
||||
@ -85,10 +86,9 @@ class File : private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Create master file
|
||||
* @param mfwenable master file write enable
|
||||
* @param attr master file attributes
|
||||
*/
|
||||
virtual void CreateMasterFile(bool mfwenable, MasterAttributes *attr) = 0;
|
||||
virtual void CreateMasterFile(MasterAttributes *attr) = 0;
|
||||
|
||||
// HDf5 specific
|
||||
/**
|
||||
@ -101,6 +101,14 @@ class File : private virtual slsDetectorDefs {
|
||||
"should be overloaded by a derived class";
|
||||
}
|
||||
|
||||
/**
|
||||
* Start of Acquisition
|
||||
*/
|
||||
virtual void StartofAcquisition() {
|
||||
LOG(logERROR) << "This is a generic function StartofAcquisition that "
|
||||
"should be overloaded by a derived class";
|
||||
}
|
||||
|
||||
/**
|
||||
* End of Acquisition
|
||||
* @param anyPacketsCaught true if any packets are caught, else false
|
||||
|
@ -86,7 +86,26 @@ void HDF5File::CreateFile() {
|
||||
CreateDataFile();
|
||||
}
|
||||
|
||||
void HDF5File::CloseCurrentFile() {
|
||||
void HDF5File::CloseAllFiles() {
|
||||
CloseCurrentDataFile();
|
||||
CloseMasterFile();
|
||||
}
|
||||
|
||||
void HDF5File::CloseMasterFile() {
|
||||
if (master) {
|
||||
CloseFile(masterfd, true);
|
||||
// close virtual file
|
||||
// c code due to only c implementation of H5Pset_virtual available
|
||||
if (virtualfd != 0) {
|
||||
if (H5Fclose(virtualfd) < 0) {
|
||||
LOG(logERROR) << "Could not close virtual HDF5 handles";
|
||||
}
|
||||
virtualfd = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HDF5File::CloseCurrentDataFile() {
|
||||
CloseFile(filefd, false);
|
||||
for (unsigned int i = 0; i < dataset_para.size(); ++i)
|
||||
delete dataset_para[i];
|
||||
@ -105,30 +124,6 @@ void HDF5File::CloseCurrentFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void HDF5File::CloseAllFiles() {
|
||||
numFilesinAcquisition = 0;
|
||||
{
|
||||
CloseFile(filefd, false);
|
||||
if (master) {
|
||||
CloseFile(masterfd, true);
|
||||
// close virtual file
|
||||
// c code due to only c implementation of H5Pset_virtual available
|
||||
if (virtualfd != 0) {
|
||||
if (H5Fclose(virtualfd) < 0) {
|
||||
LOG(logERROR) << "Could not close virtual HDF5 handles";
|
||||
}
|
||||
virtualfd = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i < dataset_para.size(); ++i)
|
||||
delete dataset_para[i];
|
||||
dataset_para.clear();
|
||||
delete dataspace_para;
|
||||
delete dataset;
|
||||
delete dataspace;
|
||||
}
|
||||
|
||||
void HDF5File::WriteToFile(char *buffer, int bufferSize,
|
||||
uint64_t currentFrameNumber,
|
||||
uint32_t numPacketsCaught) {
|
||||
@ -152,20 +147,20 @@ void HDF5File::WriteToFile(char *buffer, int bufferSize,
|
||||
WriteParameterDatasets(currentFrameNumber, (sls_receiver_header *)(buffer));
|
||||
}
|
||||
|
||||
void HDF5File::CreateMasterFile(bool masterFileWriteEnable,
|
||||
MasterAttributes *attr) {
|
||||
|
||||
// beginning of every acquisition
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
extNumImages = *numImages;
|
||||
|
||||
if (masterFileWriteEnable && master) {
|
||||
void HDF5File::CreateMasterFile(MasterAttributes *attr) {
|
||||
if (master) {
|
||||
virtualfd = 0;
|
||||
CreateMasterDataFile(attr);
|
||||
}
|
||||
}
|
||||
|
||||
void HDF5File::StartofAcquisition() {
|
||||
numFilesinAcquisition = 0;
|
||||
numFramesInFile = 0;
|
||||
numActualPacketsInFile = 0;
|
||||
extNumImages = *numImages;
|
||||
}
|
||||
|
||||
void HDF5File::EndofAcquisition(bool anyPacketsCaught,
|
||||
uint64_t numImagesCaught) {
|
||||
// not created before
|
||||
|
@ -45,13 +45,14 @@ class HDF5File : private virtual slsDetectorDefs, public File {
|
||||
uint32_t nx, uint32_t ny, bool *smode);
|
||||
~HDF5File();
|
||||
void SetNumberofPixels(uint32_t nx, uint32_t ny);
|
||||
void CreateFile();
|
||||
void CloseCurrentFile();
|
||||
void CloseAllFiles();
|
||||
void CreateFile() override;
|
||||
void CloseAllFiles() override;
|
||||
void CloseCurrentDataFile() override;
|
||||
void CloseMasterFile() override;
|
||||
void WriteToFile(char *buffer, int bufferSize, uint64_t currentFrameNumber,
|
||||
uint32_t numPacketsCaught);
|
||||
void CreateMasterFile(bool masterFileWriteEnable,
|
||||
MasterAttributes *attr) override;
|
||||
uint32_t numPacketsCaught) override;
|
||||
void CreateMasterFile(MasterAttributes *attr) override;
|
||||
void StartofAcquisition() override;
|
||||
void EndofAcquisition(bool anyPacketsCaught, uint64_t numImagesCaught);
|
||||
|
||||
private:
|
||||
|
@ -169,11 +169,11 @@ void Implementation::setDetectorType(const detectorType d) {
|
||||
&actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode,
|
||||
&activated, &deactivatedPaddingEnable, &silentMode));
|
||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(
|
||||
i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable,
|
||||
&masterFileWriteEnable, &dataStreamEnable, &streamingFrequency,
|
||||
&streamingTimerInMs, &streamingStartFnum, &framePadding,
|
||||
&activated, &deactivatedPaddingEnable, &silentMode,
|
||||
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
|
||||
i, myDetectorType, fifo_ptr, activated,
|
||||
deactivatedPaddingEnable, &dataStreamEnable,
|
||||
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum,
|
||||
&framePadding, &silentMode, &ctbDbitList, &ctbDbitOffset,
|
||||
&ctbAnalogDataBytes));
|
||||
} catch (...) {
|
||||
listener.clear();
|
||||
dataProcessor.clear();
|
||||
@ -236,7 +236,8 @@ void Implementation::setModulePositionId(const int id) {
|
||||
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->SetupFileWriter(
|
||||
fileWriteEnable, (int *)numDet, &framesPerFile, &fileName,
|
||||
fileFormatType, fileWriteEnable, masterFileWriteEnable, activated,
|
||||
deactivatedPaddingEnable, (int *)numDet, &framesPerFile, &fileName,
|
||||
&filePath, &fileIndex, &overwriteEnable, &modulePos, &numThreads,
|
||||
&numberOfTotalFrames, &dynamicRange, &udpPortNum[i], generalData);
|
||||
}
|
||||
@ -332,20 +333,30 @@ slsDetectorDefs::fileFormat Implementation::getFileFormat() const {
|
||||
}
|
||||
|
||||
void Implementation::setFileFormat(const fileFormat f) {
|
||||
switch (f) {
|
||||
if (f != fileFormatType) {
|
||||
switch (f) {
|
||||
#ifdef HDF5C
|
||||
case HDF5:
|
||||
fileFormatType = HDF5;
|
||||
break;
|
||||
case HDF5:
|
||||
fileFormatType = HDF5;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
fileFormatType = BINARY;
|
||||
break;
|
||||
default:
|
||||
fileFormatType = BINARY;
|
||||
break;
|
||||
}
|
||||
if (fileWriteEnable) {
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->SetupFileWriter(
|
||||
fileFormatType, fileWriteEnable, masterFileWriteEnable,
|
||||
activated, deactivatedPaddingEnable, (int *)numDet,
|
||||
&framesPerFile, &fileName, &filePath, &fileIndex,
|
||||
&overwriteEnable, &modulePos, &numThreads,
|
||||
&numberOfTotalFrames, &dynamicRange, &udpPortNum[i],
|
||||
generalData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetFileFormat(f);
|
||||
|
||||
LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
|
||||
}
|
||||
|
||||
@ -380,10 +391,11 @@ void Implementation::setFileWriteEnable(const bool b) {
|
||||
fileWriteEnable = b;
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->SetupFileWriter(
|
||||
fileWriteEnable, (int *)numDet, &framesPerFile, &fileName,
|
||||
&filePath, &fileIndex, &overwriteEnable, &modulePos,
|
||||
&numThreads, &numberOfTotalFrames, &dynamicRange,
|
||||
&udpPortNum[i], generalData);
|
||||
fileFormatType, fileWriteEnable, masterFileWriteEnable,
|
||||
activated, deactivatedPaddingEnable, (int *)numDet,
|
||||
&framesPerFile, &fileName, &filePath, &fileIndex,
|
||||
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
|
||||
&dynamicRange, &udpPortNum[i], generalData);
|
||||
}
|
||||
}
|
||||
LOG(logINFO) << "File Write Enable: "
|
||||
@ -395,7 +407,17 @@ bool Implementation::getMasterFileWriteEnable() const {
|
||||
}
|
||||
|
||||
void Implementation::setMasterFileWriteEnable(const bool b) {
|
||||
masterFileWriteEnable = b;
|
||||
if (masterFileWriteEnable != b) {
|
||||
masterFileWriteEnable = b;
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->SetupFileWriter(
|
||||
fileFormatType, fileWriteEnable, masterFileWriteEnable,
|
||||
activated, deactivatedPaddingEnable, (int *)numDet,
|
||||
&framesPerFile, &fileName, &filePath, &fileIndex,
|
||||
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
|
||||
&dynamicRange, &udpPortNum[i], generalData);
|
||||
}
|
||||
}
|
||||
LOG(logINFO) << "Master File Write Enable: "
|
||||
<< (masterFileWriteEnable ? "enabled" : "disabled");
|
||||
}
|
||||
@ -719,90 +741,104 @@ void Implementation::CreateUDPSockets() {
|
||||
}
|
||||
|
||||
void Implementation::SetupWriter() {
|
||||
std::unique_ptr<MasterAttributes> masterAttributes;
|
||||
switch (myDetectorType) {
|
||||
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");
|
||||
// master file
|
||||
if (masterFileWriteEnable) {
|
||||
std::unique_ptr<MasterAttributes> masterAttributes;
|
||||
switch (myDetectorType) {
|
||||
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 = myDetectorType;
|
||||
masterAttributes->timingMode = timingMode;
|
||||
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->numLinesReadout = numLinesReadout;
|
||||
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(masterAttributes.get());
|
||||
} catch (const sls::RuntimeError &e) {
|
||||
shutDownUDPSockets();
|
||||
closeFiles();
|
||||
throw sls::RuntimeError("Could not create master file.");
|
||||
}
|
||||
}
|
||||
masterAttributes->detType = myDetectorType;
|
||||
masterAttributes->timingMode = timingMode;
|
||||
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->numLinesReadout = numLinesReadout;
|
||||
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;
|
||||
|
||||
// first data file
|
||||
//->startofacquisition(which has all the start, and createfirstdatafile)
|
||||
try {
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->CreateNewFile(masterAttributes.get());
|
||||
dataProcessor[i]->CreateFirstDataFile();
|
||||
}
|
||||
} catch (const sls::RuntimeError &e) {
|
||||
shutDownUDPSockets();
|
||||
closeFiles();
|
||||
throw sls::RuntimeError("Could not create file.");
|
||||
throw sls::RuntimeError("Could not create first data file.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -872,12 +908,11 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
listener[i]->SetGeneralData(generalData);
|
||||
|
||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(
|
||||
i, myDetectorType, fifo_ptr, &fileFormatType,
|
||||
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable,
|
||||
i, myDetectorType, fifo_ptr, activated,
|
||||
deactivatedPaddingEnable, &dataStreamEnable,
|
||||
&streamingFrequency, &streamingTimerInMs,
|
||||
&streamingStartFnum, &framePadding, &activated,
|
||||
&deactivatedPaddingEnable, &silentMode, &ctbDbitList,
|
||||
&ctbDbitOffset, &ctbAnalogDataBytes));
|
||||
&streamingStartFnum, &framePadding, &silentMode,
|
||||
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
|
||||
dataProcessor[i]->SetGeneralData(generalData);
|
||||
} catch (...) {
|
||||
listener.clear();
|
||||
@ -1512,7 +1547,19 @@ void Implementation::setQuad(const bool b) {
|
||||
bool Implementation::getActivate() const { return activated; }
|
||||
|
||||
bool Implementation::setActivate(bool enable) {
|
||||
activated = enable;
|
||||
if (activated != enable) {
|
||||
activated = enable;
|
||||
// disable file writing if deactivated and no padding
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->SetupFileWriter(
|
||||
fileFormatType, fileWriteEnable, masterFileWriteEnable,
|
||||
activated, deactivatedPaddingEnable, (int *)numDet,
|
||||
&framesPerFile, &fileName, &filePath, &fileIndex,
|
||||
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
|
||||
&dynamicRange, &udpPortNum[i], generalData);
|
||||
}
|
||||
}
|
||||
|
||||
LOG(logINFO) << "Activation: " << (activated ? "enabled" : "disabled");
|
||||
return activated;
|
||||
}
|
||||
@ -1522,7 +1569,18 @@ bool Implementation::getDeactivatedPadding() const {
|
||||
}
|
||||
|
||||
void Implementation::setDeactivatedPadding(bool enable) {
|
||||
deactivatedPaddingEnable = enable;
|
||||
if (deactivatedPaddingEnable != enable) {
|
||||
deactivatedPaddingEnable = enable;
|
||||
// disable file writing if deactivated and no padding
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
dataProcessor[i]->SetupFileWriter(
|
||||
fileFormatType, fileWriteEnable, masterFileWriteEnable,
|
||||
activated, deactivatedPaddingEnable, (int *)numDet,
|
||||
&framesPerFile, &fileName, &filePath, &fileIndex,
|
||||
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
|
||||
&dynamicRange, &udpPortNum[i], generalData);
|
||||
}
|
||||
}
|
||||
LOG(logINFO) << "Deactivated Padding Enable: "
|
||||
<< (deactivatedPaddingEnable ? "enabled" : "disabled");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user