This commit is contained in:
maliakal_d 2021-07-01 14:23:33 +02:00
parent 0e7c643cf9
commit 9d8c68b1d0
15 changed files with 370 additions and 320 deletions

View File

@ -1,7 +1,6 @@
#include "BinaryDataFile.h" #include "BinaryDataFile.h"
#include "sls/logger.h"
BinaryDataFile::BinaryDataFile(int index) : File(BINARY), index_(index) {} BinaryDataFile::BinaryDataFile(const int index) : File(BINARY), index_(index) {}
BinaryDataFile::~BinaryDataFile() { CloseFile(); } BinaryDataFile::~BinaryDataFile() { CloseFile(); }
@ -13,10 +12,10 @@ void BinaryDataFile::CloseFile() {
} }
void BinaryDataFile::CreateFirstBinaryDataFile( void BinaryDataFile::CreateFirstBinaryDataFile(
std::string filePath, std::string fileNamePrefix, uint64_t fileIndex, const std::string filePath, const std::string fileNamePrefix,
bool overWriteEnable, bool silentMode, int detIndex, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
int numUnitsPerDetector, uint32_t udpPortNumber, const int modulePos, const int numUnitsPerReadout,
uint32_t maxFramesPerFile) { const uint32_t udpPortNumber, const uint32_t maxFramesPerFile) {
subFileIndex_ = 0; subFileIndex_ = 0;
numFramesInFile_ = 0; numFramesInFile_ = 0;
@ -26,8 +25,8 @@ void BinaryDataFile::CreateFirstBinaryDataFile(
fileIndex_ = fileIndex; fileIndex_ = fileIndex;
overWriteEnable_ = overWriteEnable; overWriteEnable_ = overWriteEnable;
silentMode_ = silentMode; silentMode_ = silentMode;
detIndex_ = detIndex; detIndex_ = modulePos;
numUnitsPerDetector_ = numUnitsPerDetector; numUnitsPerReadout_ = numUnitsPerReadout;
udpPortNumber_ = udpPortNumber; udpPortNumber_ = udpPortNumber;
maxFramesPerFile_ = maxFramesPerFile; maxFramesPerFile_ = maxFramesPerFile;
@ -39,7 +38,7 @@ void BinaryDataFile::CreateFile() {
std::ostringstream os; std::ostringstream os;
os << filePath_ << "/" << fileNamePrefix_ << "_d" os << filePath_ << "/" << fileNamePrefix_ << "_d"
<< (detIndex_ * numUnitsPerDetector_ + index_) << "_f" << subFileIndex_ << (detIndex_ * numUnitsPerReadout_ + index_) << "_f" << subFileIndex_
<< '_' << fileIndex_ << ".raw"; << '_' << fileIndex_ << ".raw";
fileName_ = os.str(); fileName_ = os.str();
@ -62,9 +61,9 @@ void BinaryDataFile::CreateFile() {
} }
} }
void BinaryDataFile::WriteToFile(char *buffer, int buffersize, void BinaryDataFile::WriteToFile(char *buffer, const int buffersize,
uint64_t currentFrameNumber, const uint64_t currentFrameNumber,
uint32_t numPacketsCaught) { const uint32_t numPacketsCaught) {
// check if maxframesperfile = 0 for infinite // check if maxframesperfile = 0 for infinite
if (maxFramesPerFile_ && (numFramesInFile_ >= maxFramesPerFile_)) { if (maxFramesPerFile_ && (numFramesInFile_ >= maxFramesPerFile_)) {
CloseFile(); CloseFile();

View File

@ -5,20 +5,22 @@
class BinaryDataFile : private virtual slsDetectorDefs, public File { class BinaryDataFile : private virtual slsDetectorDefs, public File {
public: public:
BinaryDataFile(int index); BinaryDataFile(const int index);
~BinaryDataFile(); ~BinaryDataFile();
void CloseFile() override; void CloseFile() override;
void CreateFirstBinaryDataFile(std::string filePath, void CreateFirstBinaryDataFile(const std::string filePath,
std::string fileNamePrefix, const std::string fileNamePrefix,
uint64_t fileIndex, bool overWriteEnable, const uint64_t fileIndex,
bool silentMode, int detIndex, const bool overWriteEnable,
int numUnitsPerDetector, const bool silentMode, const int modulePos,
uint32_t udpPortNumber, const int numUnitsPerReadout,
uint32_t maxFramesPerFile) override; const uint32_t udpPortNumber,
const uint32_t maxFramesPerFile) override;
void WriteToFile(char *buffer, int buffersize, uint64_t currentFrameNumber, void WriteToFile(char *buffer, const int buffersize,
uint32_t numPacketsCaught) override; const uint64_t currentFrameNumber,
const uint32_t numPacketsCaught) override;
private: private:
void CreateFile(); void CreateFile();
@ -35,7 +37,7 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File {
bool overWriteEnable_{false}; bool overWriteEnable_{false};
bool silentMode_{false}; bool silentMode_{false};
int detIndex_{0}; int detIndex_{0};
int numUnitsPerDetector_{0}; int numUnitsPerReadout_{0};
uint32_t udpPortNumber_{0}; uint32_t udpPortNumber_{0};
uint32_t maxFramesPerFile_{0}; uint32_t maxFramesPerFile_{0};
}; };

View File

@ -1,6 +1,5 @@
#include "BinaryMasterFile.h" #include "BinaryMasterFile.h"
#include "MasterAttributes.h" #include "MasterAttributes.h"
#include "sls/logger.h"
BinaryMasterFile::BinaryMasterFile() : File(BINARY) {} BinaryMasterFile::BinaryMasterFile() : File(BINARY) {}
@ -13,10 +12,11 @@ void BinaryMasterFile::CloseFile() {
fd_ = nullptr; fd_ = nullptr;
} }
void BinaryMasterFile::CreateMasterFile(std::string filePath, void BinaryMasterFile::CreateMasterFile(const std::string filePath,
std::string fileNamePrefix, const std::string fileNamePrefix,
uint64_t fileIndex, const uint64_t fileIndex,
bool overWriteEnable, bool silentMode, const bool overWriteEnable,
const bool silentMode,
MasterAttributes *attr) { MasterAttributes *attr) {
// create file name // create file name
std::ostringstream os; std::ostringstream os;

View File

@ -10,9 +10,11 @@ class BinaryMasterFile : private virtual slsDetectorDefs, public File {
~BinaryMasterFile(); ~BinaryMasterFile();
void CloseFile() override; void CloseFile() override;
void CreateMasterFile(std::string filePath, std::string fileNamePrefix, void CreateMasterFile(const std::string filePath,
uint64_t fileIndex, bool overWriteEnable, const std::string fileNamePrefix,
bool silentMode, MasterAttributes *attr) override; const uint64_t fileIndex, const bool overWriteEnable,
const bool silentMode,
MasterAttributes *attr) override;
private: private:
FILE *fd_{nullptr}; FILE *fd_{nullptr};

View File

@ -23,63 +23,162 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
const std::string DataProcessor::TypeName = "DataProcessor"; const std::string DataProcessor::typeName_ = "DataProcessor";
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo *f, bool act, DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
bool depaden, bool *dsEnable, uint32_t *freq, bool *activated, bool *deactivatedPaddingEnable,
uint32_t *timer, uint32_t *sfnum, bool *fp, bool *dataStreamEnable,
bool *sm, std::vector<int> *cdl, int *cdo, uint32_t *streamingFrequency,
int *cad) uint32_t *streamingTimerInMs,
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), uint32_t *streamingStartFnum, bool *framePadding,
dataStreamEnable(dsEnable), activated(act), std::vector<int> *ctbDbitList, int *ctbDbitOffset,
deactivatedPaddingEnable(depaden), streamingFrequency(freq), int *ctbAnalogDataBytes, std::mutex *hdf5Lib)
streamingTimerInMs(timer), streamingStartFnum(sfnum), silentMode(sm), : ThreadObject(index, typeName_), fifo_(fifo), detectorType_(detectorType),
framePadding(fp), ctbDbitList(cdl), ctbDbitOffset(cdo), dataStreamEnable_(dataStreamEnable), activated_(activated),
ctbAnalogDataBytes(cad), firstStreamerFrame(false) { deactivatedPaddingEnable_(deactivatedPaddingEnable),
LOG(logDEBUG) << "DataProcessor " << ind << " created"; streamingFrequency_(streamingFrequency),
memset((void *)&timerBegin, 0, sizeof(timespec)); streamingTimerInMs_(streamingTimerInMs),
streamingStartFnum_(streamingStartFnum), framePadding_(framePadding),
ctbDbitList_(ctbDbitList), ctbDbitOffset_(ctbDbitOffset),
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false),
hdf5Lib_(hdf5Lib) {
LOG(logDEBUG) << "DataProcessor " << index << " created";
memset((void *)&timerbegin_, 0, sizeof(timespec));
} }
DataProcessor::~DataProcessor() {} DataProcessor::~DataProcessor() { DeleteFiles(); }
/** getters */ /** getters */
bool DataProcessor::GetStartedFlag() { return startedFlag; } bool DataProcessor::GetStartedFlag() { return startedFlag_; }
uint64_t DataProcessor::GetNumFramesCaught() { return numFramesCaught; } uint64_t DataProcessor::GetNumFramesCaught() { return numFramesCaught_; }
uint64_t DataProcessor::GetCurrentFrameIndex() { return currentFrameIndex; } uint64_t DataProcessor::GetCurrentFrameIndex() { return currentFrameIndex_; }
uint64_t DataProcessor::GetProcessedIndex() { uint64_t DataProcessor::GetProcessedIndex() {
return currentFrameIndex - firstIndex; return currentFrameIndex_ - firstIndex_;
} }
void DataProcessor::SetFifo(Fifo *f) { fifo = f; } void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
void DataProcessor::ResetParametersforNewAcquisition() { void DataProcessor::ResetParametersforNewAcquisition() {
StopRunning(); StopRunning();
startedFlag = false; startedFlag_ = false;
numFramesCaught = 0; numFramesCaught_ = 0;
firstIndex = 0; firstIndex_ = 0;
currentFrameIndex = 0; currentFrameIndex_ = 0;
firstStreamerFrame = true; firstStreamerFrame_ = true;
} }
void DataProcessor::RecordFirstIndex(uint64_t fnum) { void DataProcessor::RecordFirstIndex(uint64_t fnum) {
// listen to this fnum, later +1 // listen to this fnum, later +1
currentFrameIndex = fnum; currentFrameIndex_ = fnum;
startedFlag = true; startedFlag_ = true;
firstIndex = fnum; firstIndex_ = fnum;
LOG(logDEBUG1) << index << " First Index:" << firstIndex; LOG(logDEBUG1) << index << " First Index:" << firstIndex_;
} }
void DataProcessor::SetGeneralData(GeneralData *g) { generalData = g; } void DataProcessor::SetGeneralData(GeneralData *generalData) {
generalData_ = generalData;
}
void DataProcessor::DeleteFiles() {
if (dataFile_ != nullptr) {
delete dataFile_;
dataFile_ = nullptr;
}
if (masterFile_ != nullptr) {
delete masterFile_;
masterFile_ = nullptr;
}
}
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
const bool masterFilewriteEnable,
const fileFormat fileFormatType,
const int modulePos) {
DeleteFiles();
if (filewriteEnable) {
switch (fileFormatType) {
#ifdef HDF5C
case HDF5:
dataFile_ = new HDF5DataFile(index, hdf5Lib_);
if (modulePos == 0 && index == 0) {
if (masterFilewriteEnable) {
masterFile_ = new HDF5MasterFile(hdf5Lib_);
}
// virtual file
}
break;
#endif
case BINARY:
dataFile_ = new BinaryDataFile(index);
if (modulePos == 0 && index == 0 && masterFilewriteEnable) {
masterFile_ = new BinaryMasterFile();
}
break;
default:
throw sls::RuntimeError(
"Unknown file format (compile with hdf5 flags");
}
}
}
void DataProcessor::CreateFirstFiles(
MasterAttributes *attr, const std::string filePath,
const std::string fileNamePrefix, const uint64_t fileIndex,
const bool overWriteEnable, const bool silentMode, const int modulePos,
const int numUnitsPerReadout, const uint32_t udpPortNumber,
const uint32_t maxFramesPerFile, const uint64_t numImages,
const uint32_t nPIxelsX, const uint32_t nPIxelsY,
const uint32_t dynamicRange) {
if (dataFile_ == nullptr) {
throw sls::RuntimeError("file object not contstructed");
}
dataFile_->CloseFile();
/*
#ifdef HDF5C
if (virtualFile_) {
virtualFile_->CloseFile();
}
#endif
*/
// master file write enabled
if (masterFile_) {
masterFile_->CloseFile();
masterFile_->CreateMasterFile(filePath, fileNamePrefix, fileIndex,
overWriteEnable, silentMode, attr);
}
switch (dataFile_->GetFileFormat()) {
#ifdef HDF5C
case HDF5:
dataFile_->CreateFirstHDF5DataFile(
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile,
numImages, nPIxelsX, nPIxelsY, dynamicRange);
/*if (virtualFile_) {
virtualFile_->CreateFile();
}*/
break;
#endif
case BINARY:
dataFile_->CreateFirstBinaryDataFile(
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile);
break;
default:
throw sls::RuntimeError("Unknown file format (compile with hdf5 flags");
}
}
void DataProcessor::ThreadExecution() { void DataProcessor::ThreadExecution() {
char *buffer = nullptr; char *buffer = nullptr;
fifo->PopAddress(buffer); fifo_->PopAddress(buffer);
LOG(logDEBUG5) << "DataProcessor " << index LOG(logDEBUG5) << "DataProcessor " << index
<< ", " << ", "
"pop 0x" "pop 0x"
@ -97,21 +196,21 @@ void DataProcessor::ThreadExecution() {
try { try {
fnum = ProcessAnImage(buffer); fnum = ProcessAnImage(buffer);
} catch (const std::exception &e) { } catch (const std::exception &e) {
fifo->FreeAddress(buffer); fifo_->FreeAddress(buffer);
return; return;
} }
// stream (if time/freq to stream) or free // stream (if time/freq to stream) or free
if (*dataStreamEnable && SendToStreamer()) { if (*dataStreamEnable_ && SendToStreamer()) {
// if first frame to stream, add frame index to fifo header (might // if first frame to stream, add frame index to fifo header (might
// not be the first) // not be the first)
if (firstStreamerFrame) { if (firstStreamerFrame_) {
firstStreamerFrame = false; firstStreamerFrame_ = false;
(*((uint32_t *)(buffer + FIFO_DATASIZE_NUMBYTES))) = (*((uint32_t *)(buffer + FIFO_DATASIZE_NUMBYTES))) =
(uint32_t)(fnum - firstIndex); (uint32_t)(fnum - firstIndex_);
} }
fifo->PushAddressToStream(buffer); fifo_->PushAddressToStream(buffer);
} else { } else {
fifo->FreeAddress(buffer); fifo_->FreeAddress(buffer);
} }
} }
@ -119,10 +218,10 @@ void DataProcessor::StopProcessing(char *buf) {
LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy"; LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy";
// stream or free // stream or free
if (*dataStreamEnable) if (*dataStreamEnable_)
fifo->PushAddressToStream(buf); fifo_->PushAddressToStream(buf);
else else
fifo->FreeAddress(buf); fifo_->FreeAddress(buf);
StopRunning(); StopRunning();
LOG(logDEBUG1) << index << ": Processing Completed"; LOG(logDEBUG1) << index << ": Processing Completed";
@ -133,37 +232,37 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
auto *rheader = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES); auto *rheader = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
sls_detector_header header = rheader->detHeader; sls_detector_header header = rheader->detHeader;
uint64_t fnum = header.frameNumber; uint64_t fnum = header.frameNumber;
currentFrameIndex = fnum; currentFrameIndex_ = fnum;
uint32_t nump = header.packetNumber; uint32_t nump = header.packetNumber;
if (nump == generalData->packetsPerFrame) { if (nump == generalData_->packetsPerFrame) {
numFramesCaught++; numFramesCaught_++;
} }
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum; LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
if (!startedFlag) { if (!startedFlag_) {
RecordFirstIndex(fnum); RecordFirstIndex(fnum);
if (*dataStreamEnable) { if (*dataStreamEnable_) {
// restart timer // restart timer
clock_gettime(CLOCK_REALTIME, &timerBegin); clock_gettime(CLOCK_REALTIME, &timerbegin_);
timerBegin.tv_sec -= (*streamingTimerInMs) / 1000; timerbegin_.tv_sec -= (*streamingTimerInMs_) / 1000;
timerBegin.tv_nsec -= ((*streamingTimerInMs) % 1000) * 1000000; timerbegin_.tv_nsec -= ((*streamingTimerInMs_) % 1000) * 1000000;
// to send first image // to send first image
currentFreqCount = *streamingFrequency - *streamingStartFnum; currentFreqCount_ = *streamingFrequency_ - *streamingStartFnum_;
} }
} }
// frame padding // frame padding
if (activated && *framePadding && nump < generalData->packetsPerFrame) if (*activated_ && *framePadding_ && nump < generalData_->packetsPerFrame)
PadMissingPackets(buf); PadMissingPackets(buf);
// deactivated and padding enabled // deactivated and padding enabled
else if (!activated && deactivatedPaddingEnable) else if (!*activated_ && *deactivatedPaddingEnable_)
PadMissingPackets(buf); PadMissingPackets(buf);
// rearrange ctb digital bits (if ctbDbitlist is not empty) // rearrange ctb digital bits (if ctbDbitlist is not empty)
if (!(*ctbDbitList).empty()) { if (!(*ctbDbitList_).empty()) {
RearrangeDbitData(buf); RearrangeDbitData(buf);
} }
@ -195,7 +294,7 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
bool DataProcessor::SendToStreamer() { bool DataProcessor::SendToStreamer() {
// skip // skip
if ((*streamingFrequency) == 0u) { if ((*streamingFrequency_) == 0u) {
if (!CheckTimer()) if (!CheckTimer())
return false; return false;
} else { } else {
@ -210,26 +309,26 @@ bool DataProcessor::CheckTimer() {
clock_gettime(CLOCK_REALTIME, &end); clock_gettime(CLOCK_REALTIME, &end);
LOG(logDEBUG1) << index << " Timer elapsed time:" LOG(logDEBUG1) << index << " Timer elapsed time:"
<< ((end.tv_sec - timerBegin.tv_sec) + << ((end.tv_sec - timerbegin_.tv_sec) +
(end.tv_nsec - timerBegin.tv_nsec) / 1000000000.0) (end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0)
<< " seconds"; << " seconds";
// still less than streaming timer, keep waiting // still less than streaming timer, keep waiting
if (((end.tv_sec - timerBegin.tv_sec) + if (((end.tv_sec - timerbegin_.tv_sec) +
(end.tv_nsec - timerBegin.tv_nsec) / 1000000000.0) < (end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0) <
((double)*streamingTimerInMs / 1000.00)) ((double)*streamingTimerInMs_ / 1000.00))
return false; return false;
// restart timer // restart timer
clock_gettime(CLOCK_REALTIME, &timerBegin); clock_gettime(CLOCK_REALTIME, &timerbegin_);
return true; return true;
} }
bool DataProcessor::CheckCount() { bool DataProcessor::CheckCount() {
if (currentFreqCount == *streamingFrequency) { if (currentFreqCount_ == *streamingFrequency_) {
currentFreqCount = 1; currentFreqCount_ = 1;
return true; return true;
} }
currentFreqCount++; currentFreqCount_++;
return false; return false;
} }
@ -249,18 +348,18 @@ void DataProcessor::registerCallBackRawDataModifyReady(
void DataProcessor::PadMissingPackets(char *buf) { void DataProcessor::PadMissingPackets(char *buf) {
LOG(logDEBUG) << index << ": Padding Missing Packets"; LOG(logDEBUG) << index << ": Padding Missing Packets";
uint32_t pperFrame = generalData->packetsPerFrame; uint32_t pperFrame = generalData_->packetsPerFrame;
auto *header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES); auto *header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
uint32_t nmissing = pperFrame - header->detHeader.packetNumber; uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
sls_bitset pmask = header->packetsMask; sls_bitset pmask = header->packetsMask;
uint32_t dsize = generalData->dataSize; uint32_t dsize = generalData_->dataSize;
if (myDetectorType == GOTTHARD2 && index != 0) { if (detectorType_ == GOTTHARD2 && index != 0) {
dsize = generalData->vetoDataSize; dsize = generalData_->vetoDataSize;
} }
uint32_t fifohsize = generalData->fifoBufferHeaderSize; uint32_t fifohsize = generalData_->fifoBufferHeaderSize;
uint32_t corrected_dsize = uint32_t corrected_dsize =
dsize - ((pperFrame * dsize) - generalData->imageSize); dsize - ((pperFrame * dsize) - generalData_->imageSize);
LOG(logDEBUG1) << "bitmask: " << pmask.to_string(); LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
for (unsigned int pnum = 0; pnum < pperFrame; ++pnum) { for (unsigned int pnum = 0; pnum < pperFrame; ++pnum) {
@ -277,7 +376,7 @@ void DataProcessor::PadMissingPackets(char *buf) {
<< std::endl; << std::endl;
// missing packet // missing packet
switch (myDetectorType) { switch (detectorType_) {
// for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes // for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes
// data // data
// 2nd packet: 4 bytes fnum, previous 1*2 bytes data + // 2nd packet: 4 bytes fnum, previous 1*2 bytes data +
@ -308,7 +407,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
// TODO! (Erik) Refactor and add tests // TODO! (Erik) Refactor and add tests
int totalSize = (int)(*((uint32_t *)buf)); int totalSize = (int)(*((uint32_t *)buf));
int ctbDigitalDataBytes = int ctbDigitalDataBytes =
totalSize - (*ctbAnalogDataBytes) - (*ctbDbitOffset); totalSize - (*ctbAnalogDataBytes_) - (*ctbDbitOffset_);
// no digital data // no digital data
if (ctbDigitalDataBytes == 0) { if (ctbDigitalDataBytes == 0) {
@ -319,19 +418,19 @@ void DataProcessor::RearrangeDbitData(char *buf) {
const int numSamples = (ctbDigitalDataBytes / sizeof(uint64_t)); const int numSamples = (ctbDigitalDataBytes / sizeof(uint64_t));
const int digOffset = FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header) + const int digOffset = FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header) +
(*ctbAnalogDataBytes); (*ctbAnalogDataBytes_);
// ceil as numResult8Bits could be decimal // ceil as numResult8Bits could be decimal
const int numResult8Bits = const int numResult8Bits =
ceil((double)(numSamples * (*ctbDbitList).size()) / 8.00); ceil((double)(numSamples * (*ctbDbitList_).size()) / 8.00);
std::vector<uint8_t> result(numResult8Bits); std::vector<uint8_t> result(numResult8Bits);
uint8_t *dest = &result[0]; uint8_t *dest = &result[0];
auto *source = (uint64_t *)(buf + digOffset + (*ctbDbitOffset)); auto *source = (uint64_t *)(buf + digOffset + (*ctbDbitOffset_));
// loop through digital bit enable vector // loop through digital bit enable vector
int bitoffset = 0; int bitoffset = 0;
for (auto bi : (*ctbDbitList)) { for (auto bi : (*ctbDbitList_)) {
// where numbits * numsamples is not a multiple of 8 // where numbits * numsamples is not a multiple of 8
if (bitoffset != 0) { if (bitoffset != 0) {
bitoffset = 0; bitoffset = 0;

View File

@ -19,86 +19,47 @@ class DataStreamer;
struct MasterAttributes; struct MasterAttributes;
#include <atomic> #include <atomic>
#include <mutex>
#include <vector> #include <vector>
class DataProcessor : private virtual slsDetectorDefs, public ThreadObject { class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
public: public:
/** DataProcessor(int index, detectorType detectorType, Fifo *fifo,
* Constructor bool *activated, bool *deactivatedPaddingEnable,
* Calls Base Class CreateThread(), sets ErrorMask if error and increments bool *dataStreamEnable, uint32_t *streamingFrequency,
* NumberofDataProcessors uint32_t *streamingTimerInMs, uint32_t *streamingStartFnum,
* @param ind self index bool *framePadding, std::vector<int> *ctbDbitList,
* @param dtype detector type int *ctbDbitOffset, int *ctbAnalogDataBytes,
* @param f address of Fifo pointer std::mutex *hdf5Lib);
* @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 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, 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);
/**
* Destructor
* Calls Base Class DestroyThread() and decrements NumberofDataProcessors
*/
~DataProcessor() override; ~DataProcessor() override;
//*** getters ***
/**
* Get acquisition started flag
* @return acquisition started flag
*/
bool GetStartedFlag(); bool GetStartedFlag();
/**
* Get Frames Complete Caught
* @return number of frames
*/
uint64_t GetNumFramesCaught(); uint64_t GetNumFramesCaught();
/** (-1 if no frames have been caught */
/**
* Gets Actual Current Frame Index (that has not been subtracted from
* firstIndex) thats been processed
* @return -1 if no frames have been caught, else current frame index
*/
uint64_t GetCurrentFrameIndex(); uint64_t GetCurrentFrameIndex();
/** (-1 if no frames have been caught) */
/**
* Get Current Frame Index thats been processed
* @return -1 if no frames have been caught, else current frame index
*/
uint64_t GetProcessedIndex(); uint64_t GetProcessedIndex();
/**
* Set Fifo pointer to the one given
* @param f address of Fifo pointer
*/
void SetFifo(Fifo *f); void SetFifo(Fifo *f);
/**
* Reset parameters for new acquisition
*/
void ResetParametersforNewAcquisition(); void ResetParametersforNewAcquisition();
void SetGeneralData(GeneralData *generalData);
/** void DeleteFiles();
* Set GeneralData pointer to the one given void SetupFileWriter(const bool filewriteEnable,
* @param g address of GeneralData (Detector Data) pointer const bool masterFilewriteEnable,
*/ const fileFormat fileFormatType, const int modulePos);
void SetGeneralData(GeneralData *g);
void CreateFirstFiles(MasterAttributes *attr, const std::string filePath,
const std::string fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable,
const bool silentMode, const int modulePos,
const int numUnitsPerReadout,
const uint32_t udpPortNumber,
const uint32_t maxFramesPerFile,
const uint64_t numImages, const uint32_t nPIxelsX,
const uint32_t nPIxelsY, const uint32_t dynamicRange);
/** /**
* Call back for raw data * Call back for raw data
@ -125,10 +86,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
void *arg); void *arg);
private: private:
/**
* Record First Index
* @param fnum frame index to record
*/
void RecordFirstIndex(uint64_t fnum); void RecordFirstIndex(uint64_t fnum);
/** /**
@ -141,14 +98,12 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
/** /**
* Frees dummy buffer, * Frees dummy buffer,
* reset running mask by calling StopRunning() * reset running mask by calling StopRunning()
* @param buf address of pointer
*/ */
void StopProcessing(char *buf); void StopProcessing(char *buf);
/** /**
* Process an image popped from fifo, * Process an image popped from fifo,
* write to file if fw enabled & update parameters * write to file if fw enabled & update parameters
* @param buf address of pointer
* @returns frame number * @returns frame number
*/ */
uint64_t ProcessAnImage(char *buf); uint64_t ProcessAnImage(char *buf);
@ -174,10 +129,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
*/ */
bool CheckCount(); bool CheckCount();
/**
* Pad Missing Packets from the bit mask
* @param buf buffer
*/
void PadMissingPackets(char *buf); void PadMissingPackets(char *buf);
/** /**
@ -186,75 +137,40 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
*/ */
void RearrangeDbitData(char *buf); void RearrangeDbitData(char *buf);
/** type of thread */ static const std::string typeName_;
static const std::string TypeName;
/** GeneralData (Detector Data) object */ const GeneralData *generalData_{nullptr};
const GeneralData *generalData{nullptr}; Fifo *fifo_;
detectorType detectorType_;
/** Fifo structure */ bool *dataStreamEnable_;
Fifo *fifo; bool *activated_;
bool *deactivatedPaddingEnable_;
// individual members /** if 0, sending random images with a timer */
/** Detector Type */ uint32_t *streamingFrequency_;
detectorType myDetectorType; uint32_t *streamingTimerInMs_;
uint32_t *streamingStartFnum_;
/** Data Stream Enable */ uint32_t currentFreqCount_{0};
bool *dataStreamEnable; struct timespec timerbegin_;
bool *framePadding_;
/** Activated/Deactivated */ std::vector<int> *ctbDbitList_;
bool activated; int *ctbDbitOffset_;
int *ctbAnalogDataBytes_;
/** Deactivated padding enable */ std::atomic<bool> startedFlag_{false};
bool deactivatedPaddingEnable; std::atomic<uint64_t> firstIndex_{0};
/** Pointer to Streaming frequency, if 0, sending random images with a timer
*/
uint32_t *streamingFrequency;
/** Pointer to the timer if Streaming frequency is random */
uint32_t *streamingTimerInMs;
/** Pointer to streaming starting fnum */
uint32_t *streamingStartFnum;
/** Current frequency count */
uint32_t currentFreqCount{0};
/** timer beginning stamp for random streaming */
struct timespec timerBegin;
/** Silent Mode */
bool *silentMode;
/** frame padding */
bool *framePadding;
/** ctb digital bits enable list */
std::vector<int> *ctbDbitList;
/** ctb digital bits offset */
int *ctbDbitOffset;
/** ctb analog databytes */
int *ctbAnalogDataBytes;
// acquisition start
/** Aquisition Started flag */
std::atomic<bool> startedFlag{false};
/** Frame Number of First Frame */
std::atomic<uint64_t> firstIndex{0};
// for statistics // for statistics
/** Number of complete frames caught */ /** Number of complete frames caught */
uint64_t numFramesCaught{0}; uint64_t numFramesCaught_{0};
/** Frame Number of latest processed frame number */ /** Frame Number of latest processed frame number */
std::atomic<uint64_t> currentFrameIndex{0}; std::atomic<uint64_t> currentFrameIndex_{0};
/** first streamer frame to add frame index in fifo header */ /** first streamer frame to add frame index in fifo header */
bool firstStreamerFrame{false}; bool firstStreamerFrame_{false};
File *dataFile_{nullptr};
File *masterFile_{nullptr};
std::mutex *hdf5Lib_;
// call back // call back
/** /**

View File

@ -2,8 +2,8 @@
#include <iostream> #include <iostream>
File::File(slsDetectorDefs::fileFormat type) : type_(type) {} File::File(const slsDetectorDefs::fileFormat format) : format_(format) {}
File::~File() {} File::~File() {}
slsDetectorDefs::fileFormat File::GetFileType() { return type_; } slsDetectorDefs::fileFormat File::GetFileFormat() const { return format_; }

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "sls/logger.h"
#include "sls/sls_detector_defs.h" #include "sls/sls_detector_defs.h"
struct MasterAttributes; struct MasterAttributes;
@ -7,36 +8,60 @@ struct MasterAttributes;
class File : private virtual slsDetectorDefs { class File : private virtual slsDetectorDefs {
public: public:
File(slsDetectorDefs::fileFormat type); File(const slsDetectorDefs::fileFormat format);
virtual ~File(); virtual ~File();
fileFormat GetFileType(); fileFormat GetFileFormat() const;
virtual uint32_t GetFilesInAcquisition() = 0;
virtual void CloseFile() = 0; virtual void CloseFile() = 0;
virtual void CreateMasterFile(std::string filePath, virtual uint32_t GetFilesInAcquisition() const {
std::string fileNamePrefix, LOG(logERROR)
uint64_t fileIndex, bool overWriteEnable, << "This is a generic function GetFilesInAcquisition that "
bool silentMode, MasterAttributes *attr) = 0; "should be overloaded by a derived class";
return 0;
};
virtual void virtual void CreateMasterFile(const std::string filePath,
CreateFirstBinaryDataFile(std::string filePath, std::string fileNamePrefix, const std::string fileNamePrefix,
uint64_t fileIndex, bool overWriteEnable, const uint64_t fileIndex,
bool silentMode, int detIndex, const bool overWriteEnable,
int numUnitsPerDetector, uint32_t udpPortNumber, const bool silentMode,
uint32_t maxFramesPerFile) = 0; MasterAttributes *attr) {
LOG(logERROR) << "This is a generic function CreateMasterFile that "
"should be overloaded by a derived class";
};
virtual void CreateFirstBinaryDataFile(
const std::string filePath, const std::string fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable,
const bool silentMode, const int modulePos,
const int numUnitsPerReadout, const uint32_t udpPortNumber,
const uint32_t maxFramesPerFile) {
LOG(logERROR)
<< "This is a generic function CreateFirstBinaryDataFile that "
"should be overloaded by a derived class";
};
virtual void CreateFirstHDF5DataFile( virtual void CreateFirstHDF5DataFile(
std::string filePath, std::string fileNamePrefix, uint64_t fileIndex, const std::string filePath, const std::string fileNamePrefix,
bool overWriteEnable, bool silentMode, int detIndex, const uint64_t fileIndex, const bool overWriteEnable,
int numUnitsPerDetector, uint32_t udpPortNumber, const bool silentMode, const int modulePos,
uint32_t maxFramesPerFile, uint64_t numImages, uint32_t nPIxelsX, const int numUnitsPerReadout, const uint32_t udpPortNumber,
uint32_t nPIxelsY, uint32_t dynamicRange) = 0; const uint32_t maxFramesPerFile, const uint64_t numImages,
const uint32_t nPIxelsX, const uint32_t nPIxelsY,
const uint32_t dynamicRange) {
LOG(logERROR)
<< "This is a generic function CreateFirstHDF5DataFile that "
"should be overloaded by a derived class";
};
virtual void WriteToFile(char *buffer, int buffersize, virtual void WriteToFile(char *buffer, const int buffersize,
uint64_t currentFrameNumber, const uint64_t currentFrameNumber,
uint32_t numPacketsCaught) = 0; const uint32_t numPacketsCaught) {
LOG(logERROR) << "This is a generic function WriteToFile that "
"should be overloaded by a derived class";
};
protected: protected:
slsDetectorDefs::fileFormat type_; slsDetectorDefs::fileFormat format_;
}; };

View File

@ -1,6 +1,5 @@
#include "HDF5DataFile.h" #include "HDF5DataFile.h"
#include "receiver_defs.h" #include "receiver_defs.h"
#include "sls/logger.h"
#include <iomanip> #include <iomanip>
@ -34,7 +33,7 @@ HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
HDF5DataFile::~HDF5DataFile() { CloseFile(); } HDF5DataFile::~HDF5DataFile() { CloseFile(); }
uint32_t HDF5DataFile::GetFilesInAcquisition() { uint32_t HDF5DataFile::GetFilesInAcquisition() const {
return numFilesInAcquisition_; return numFilesInAcquisition_;
} }
@ -70,11 +69,12 @@ void HDF5DataFile::CloseFile() {
} }
void HDF5DataFile::CreateFirstHDF5DataFile( void HDF5DataFile::CreateFirstHDF5DataFile(
std::string filePath, std::string fileNamePrefix, uint64_t fileIndex, const std::string filePath, const std::string fileNamePrefix,
bool overWriteEnable, bool silentMode, int detIndex, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
int numUnitsPerDetector, uint32_t udpPortNumber, uint32_t maxFramesPerFile, const int modulePos, const int numUnitsPerReadout,
uint64_t numImages, uint32_t nPIxelsX, uint32_t nPIxelsY, const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
uint32_t dynamicRange) { const uint64_t numImages, const uint32_t nPIxelsX, const uint32_t nPIxelsY,
const uint32_t dynamicRange) {
subFileIndex_ = 0; subFileIndex_ = 0;
numFramesInFile_ = 0; numFramesInFile_ = 0;
@ -92,8 +92,8 @@ void HDF5DataFile::CreateFirstHDF5DataFile(
fileIndex_ = fileIndex; fileIndex_ = fileIndex;
overWriteEnable_ = overWriteEnable; overWriteEnable_ = overWriteEnable;
silentMode_ = silentMode; silentMode_ = silentMode;
detIndex_ = detIndex; detIndex_ = modulePos;
numUnitsPerDetector_ = numUnitsPerDetector; numUnitsPerReadout_ = numUnitsPerReadout;
udpPortNumber_ = udpPortNumber; udpPortNumber_ = udpPortNumber;
switch (dynamicRange_) { switch (dynamicRange_) {
@ -117,7 +117,7 @@ void HDF5DataFile::CreateFile() {
std::ostringstream os; std::ostringstream os;
os << filePath_ << "/" << fileNamePrefix_ << "_d" os << filePath_ << "/" << fileNamePrefix_ << "_d"
<< (detIndex_ * numUnitsPerDetector_ + index_) << "_f" << subFileIndex_ << (detIndex_ * numUnitsPerReadout_ + index_) << "_f" << subFileIndex_
<< '_' << fileIndex_ << ".h5"; << '_' << fileIndex_ << ".h5";
fileName_ = os.str(); fileName_ = os.str();
@ -211,9 +211,9 @@ void HDF5DataFile::CreateFile() {
} }
} }
void HDF5DataFile::WriteToFile(char *buffer, int bufferSize, void HDF5DataFile::WriteToFile(char *buffer, const int buffersize,
uint64_t currentFrameNumber, const uint64_t currentFrameNumber,
uint32_t numPacketsCaught) { const uint32_t numPacketsCaught) {
// check if maxframesperfile = 0 for infinite // check if maxframesperfile = 0 for infinite
if (maxFramesPerFile_ && (numFramesInFile_ >= maxFramesPerFile_)) { if (maxFramesPerFile_ && (numFramesInFile_ >= maxFramesPerFile_)) {
@ -233,7 +233,8 @@ void HDF5DataFile::WriteToFile(char *buffer, int bufferSize,
WriteParameterDatasets(currentFrameNumber, (sls_receiver_header *)(buffer)); WriteParameterDatasets(currentFrameNumber, (sls_receiver_header *)(buffer));
} }
void HDF5DataFile::WriteDataFile(uint64_t currentFrameNumber, char *buffer) { void HDF5DataFile::WriteDataFile(const uint64_t currentFrameNumber,
char *buffer) {
std::lock_guard<std::mutex> lock(*hdf5Lib_); std::lock_guard<std::mutex> lock(*hdf5Lib_);
uint64_t nDimx = uint64_t nDimx =
@ -260,7 +261,7 @@ void HDF5DataFile::WriteDataFile(uint64_t currentFrameNumber, char *buffer) {
} }
} }
void HDF5DataFile::WriteParameterDatasets(uint64_t currentFrameNumber, void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
sls_receiver_header *rheader) { sls_receiver_header *rheader) {
std::lock_guard<std::mutex> lock(*hdf5Lib_); std::lock_guard<std::mutex> lock(*hdf5Lib_);

View File

@ -12,29 +12,30 @@ using namespace H5;
class HDF5DataFile : private virtual slsDetectorDefs, public File { class HDF5DataFile : private virtual slsDetectorDefs, public File {
public: public:
HDF5DataFile(int index, std::mutex *hdf5Lib); HDF5DataFile(const int index, std::mutex *hdf5Lib);
~HDF5DataFile(); ~HDF5DataFile();
uint32_t GetFilesInAcquisition() override; uint32_t GetFilesInAcquisition() const override;
void CloseFile() override; void CloseFile() override;
void CreateFirstHDF5DataFile(std::string filePath, void CreateFirstHDF5DataFile(
std::string fileNamePrefix, uint64_t fileIndex, const std::string filePath, const std::string fileNamePrefix,
bool overWriteEnable, bool silentMode, const uint64_t fileIndex, const bool overWriteEnable,
int detIndex, int numUnitsPerDetector, const bool silentMode, const int modulePos,
uint32_t udpPortNumber, const int numUnitsPerReadout, const uint32_t udpPortNumber,
uint32_t maxFramesPerFile, uint64_t numImages, const uint32_t maxFramesPerFile, const uint64_t numImages,
uint32_t nPIxelsX, uint32_t nPIxelsY, const uint32_t nPIxelsX, const uint32_t nPIxelsY,
uint32_t dynamicRange) override; const uint32_t dynamicRange) override;
void WriteToFile(char *buffer, int buffersize, uint64_t currentFrameNumber, void WriteToFile(char *buffer, const int buffersize,
uint32_t numPacketsCaught) override; const uint64_t currentFrameNumber,
const uint32_t numPacketsCaught) override;
private: private:
void CreateFile(); void CreateFile();
void WriteDataFile(uint64_t currentFrameNumber, char *buffer); void WriteDataFile(const uint64_t currentFrameNumber, char *buffer);
void WriteParameterDatasets(uint64_t currentFrameNumber, void WriteParameterDatasets(const uint64_t currentFrameNumber,
sls_receiver_header *rheader); sls_receiver_header *rheader);
void ExtendDataset(); void ExtendDataset();
@ -67,6 +68,6 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
bool overWriteEnable_{false}; bool overWriteEnable_{false};
bool silentMode_{false}; bool silentMode_{false};
int detIndex_{0}; int detIndex_{0};
int numUnitsPerDetector_{0}; int numUnitsPerReadout_{0};
uint32_t udpPortNumber_{0}; uint32_t udpPortNumber_{0};
}; };

View File

@ -1,6 +1,5 @@
#include "HDF5MasterFile.h" #include "HDF5MasterFile.h"
#include "MasterAttributes.h" #include "MasterAttributes.h"
#include "sls/logger.h"
HDF5MasterFile::HDF5MasterFile(std::mutex *hdf5Lib) HDF5MasterFile::HDF5MasterFile(std::mutex *hdf5Lib)
: File(HDF5), hdf5Lib_(hdf5Lib) {} : File(HDF5), hdf5Lib_(hdf5Lib) {}
@ -22,10 +21,12 @@ void HDF5MasterFile::CloseFile() {
} }
} }
void HDF5MasterFile::CreateMasterFile(std::string filePath, void HDF5MasterFile::CreateMasterFile(const std::string filePath,
std::string fileNamePrefix, const std::string fileNamePrefix,
uint64_t fileIndex, bool overWriteEnable, const uint64_t fileIndex,
bool silentMode, MasterAttributes *attr) { const bool overWriteEnable,
const bool silentMode,
MasterAttributes *attr) {
std::ostringstream os; std::ostringstream os;
os << filePath << "/" << fileNamePrefix << "_master" os << filePath << "/" << fileNamePrefix << "_master"

View File

@ -16,9 +16,11 @@ class HDF5MasterFile : private virtual slsDetectorDefs, public File {
~HDF5MasterFile(); ~HDF5MasterFile();
void CloseFile() override; void CloseFile() override;
void CreateMasterFile(std::string filePath, std::string fileNamePrefix, void CreateMasterFile(const std::string filePath,
uint64_t fileIndex, bool overWriteEnable, const std::string fileNamePrefix,
bool silentMode, MasterAttributes *attr) override; const uint64_t fileIndex, const bool overWriteEnable,
const bool silentMode,
MasterAttributes *attr) override;
private: private:
std::mutex *hdf5Lib_; std::mutex *hdf5Lib_;

View File

@ -1,5 +1,4 @@
#include "HDF5VirtualFile.h" #include "HDF5VirtualFile.h"
#include "sls/logger.h"
HDF5VirtualFile::HDF5VirtualFile(std::mutex *hdf5Lib) HDF5VirtualFile::HDF5VirtualFile(std::mutex *hdf5Lib)
: File(HDF5), hdf5Lib_(hdf5Lib) {} : File(HDF5), hdf5Lib_(hdf5Lib) {}

View File

@ -169,11 +169,11 @@ void Implementation::setDetectorType(const detectorType d) {
&actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode, &actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode,
&activated, &deactivatedPaddingEnable, &silentMode)); &activated, &deactivatedPaddingEnable, &silentMode));
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, activated, i, myDetectorType, fifo_ptr, &activated,
deactivatedPaddingEnable, &dataStreamEnable, &deactivatedPaddingEnable, &dataStreamEnable,
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum, &streamingFrequency, &streamingTimerInMs, &streamingStartFnum,
&framePadding, &silentMode, &ctbDbitList, &ctbDbitOffset, &framePadding, &ctbDbitList, &ctbDbitOffset,
&ctbAnalogDataBytes)); &ctbAnalogDataBytes, &hdf5Lib));
} catch (...) { } catch (...) {
listener.clear(); listener.clear();
dataProcessor.clear(); dataProcessor.clear();
@ -236,8 +236,8 @@ void Implementation::setModulePositionId(const int id) {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
/*dataProcessor[i]->SetupFileWriter( /*dataProcessor[i]->SetupFileWriter(
fileFormatType, fileWriteEnable, masterFileWriteEnable, activated, fileFormatType, fileWriteEnable, masterFileWriteEnable, &activated,
deactivatedPaddingEnable, (int *)numDet, &framesPerFile, &fileName, &deactivatedPaddingEnable, (int *)numDet, &framesPerFile, &fileName,
&filePath, &fileIndex, &overwriteEnable, &modulePos, &numThreads, &filePath, &fileIndex, &overwriteEnable, &modulePos, &numThreads,
&numberOfTotalFrames, &dynamicRange, &udpPortNum[i], generalData);*/ &numberOfTotalFrames, &dynamicRange, &udpPortNum[i], generalData);*/
} }
@ -348,7 +348,7 @@ void Implementation::setFileFormat(const fileFormat f) {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
/*dataProcessor[i]->SetupFileWriter( /*dataProcessor[i]->SetupFileWriter(
fileFormatType, fileWriteEnable, masterFileWriteEnable, fileFormatType, fileWriteEnable, masterFileWriteEnable,
activated, deactivatedPaddingEnable, (int *)numDet, &activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex, &framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads, &overwriteEnable, &modulePos, &numThreads,
&numberOfTotalFrames, &dynamicRange, &udpPortNum[i], &numberOfTotalFrames, &dynamicRange, &udpPortNum[i],
@ -392,7 +392,7 @@ void Implementation::setFileWriteEnable(const bool b) {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
/*dataProcessor[i]->SetupFileWriter( /*dataProcessor[i]->SetupFileWriter(
fileFormatType, fileWriteEnable, masterFileWriteEnable, fileFormatType, fileWriteEnable, masterFileWriteEnable,
activated, deactivatedPaddingEnable, (int *)numDet, &activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex, &framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames, &overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
&dynamicRange, &udpPortNum[i], generalData);*/ &dynamicRange, &udpPortNum[i], generalData);*/
@ -412,7 +412,7 @@ void Implementation::setMasterFileWriteEnable(const bool b) {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
/*dataProcessor[i]->SetupFileWriter( /*dataProcessor[i]->SetupFileWriter(
fileFormatType, fileWriteEnable, masterFileWriteEnable, fileFormatType, fileWriteEnable, masterFileWriteEnable,
activated, deactivatedPaddingEnable, (int *)numDet, &activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex, &framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames, &overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
&dynamicRange, &udpPortNum[i], generalData);*/ &dynamicRange, &udpPortNum[i], generalData);*/
@ -908,11 +908,11 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
listener[i]->SetGeneralData(generalData); listener[i]->SetGeneralData(generalData);
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, activated, i, myDetectorType, fifo_ptr, &activated,
deactivatedPaddingEnable, &dataStreamEnable, &deactivatedPaddingEnable, &dataStreamEnable,
&streamingFrequency, &streamingTimerInMs, &streamingFrequency, &streamingTimerInMs,
&streamingStartFnum, &framePadding, &silentMode, &streamingStartFnum, &framePadding, &ctbDbitList,
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes)); &ctbDbitOffset, &ctbAnalogDataBytes, &hdf5Lib));
dataProcessor[i]->SetGeneralData(generalData); dataProcessor[i]->SetGeneralData(generalData);
} catch (...) { } catch (...) {
listener.clear(); listener.clear();
@ -1553,7 +1553,7 @@ bool Implementation::setActivate(bool enable) {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
/*dataProcessor[i]->SetupFileWriter( /*dataProcessor[i]->SetupFileWriter(
fileFormatType, fileWriteEnable, masterFileWriteEnable, fileFormatType, fileWriteEnable, masterFileWriteEnable,
activated, deactivatedPaddingEnable, (int *)numDet, &activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex, &framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames, &overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
&dynamicRange, &udpPortNum[i], generalData);*/ &dynamicRange, &udpPortNum[i], generalData);*/
@ -1575,7 +1575,7 @@ void Implementation::setDeactivatedPadding(bool enable) {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
; /*dataProcessor[i]->SetupFileWriter( ; /*dataProcessor[i]->SetupFileWriter(
fileFormatType, fileWriteEnable, masterFileWriteEnable, fileFormatType, fileWriteEnable, masterFileWriteEnable,
activated, deactivatedPaddingEnable, (int *)numDet, &activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex, &framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads, &overwriteEnable, &modulePos, &numThreads,
&numberOfTotalFrames, &dynamicRange, &udpPortNum[i], &numberOfTotalFrames, &dynamicRange, &udpPortNum[i],

View File

@ -15,6 +15,7 @@ class slsDetectorDefs;
#include <exception> #include <exception>
#include <map> #include <map>
#include <memory> #include <memory>
#include <mutex>
#include <vector> #include <vector>
using ns = std::chrono::nanoseconds; using ns = std::chrono::nanoseconds;
@ -375,4 +376,6 @@ class Implementation : private virtual slsDetectorDefs {
std::vector<std::unique_ptr<DataProcessor>> dataProcessor; std::vector<std::unique_ptr<DataProcessor>> dataProcessor;
std::vector<std::unique_ptr<DataStreamer>> dataStreamer; std::vector<std::unique_ptr<DataStreamer>> dataStreamer;
std::vector<std::unique_ptr<Fifo>> fifo; std::vector<std::unique_ptr<Fifo>> fifo;
std::mutex hdf5Lib;
}; };