mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Rxpointers (#504)
* gui message doesnt show if it has a '>' symbol in error msg * minor refactoring for readability (size_t calc fifo size) * refactoring listening udp socket code: activated and datastream dont create udp sockets anyway, rc<=- should be discarded in any case * wip * refactoring memory structure access * wip: bugfix write header + data to binary * wip * wip * wip * wip * wip * wip * wip * wip * wip * portRoi no roi effecto on progress * fail at receiver progress, wip * segfaults for char pointer in struct * reference to header to get header and data * refactoring * use const defined for size of header of fifo * updated release notes * remove pointer in callback for sls_receiver_header pointer * rx same name arguments in constructors * rx: same name arguments in constructor * rx: removing the '_' suffix in class data members * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * diff undo for clang later * wip * Wip * const string&
This commit is contained in:
parent
9ac8dab8af
commit
89e293cb5a
@ -20,22 +20,17 @@ void BinaryDataFile::CloseFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BinaryDataFile::CreateFirstBinaryDataFile(
|
void BinaryDataFile::CreateFirstBinaryDataFile(
|
||||||
const std::string fPath, const std::string fNamePrefix,
|
const std::string& fNamePrefix,
|
||||||
const uint64_t fIndex, const bool ovEnable, const bool sMode,
|
const uint64_t fIndex, const bool ovEnable, const bool sMode,
|
||||||
const int modulePos, const int nUnitsPerReadout,
|
|
||||||
const uint32_t uPortNumber, const uint32_t mFramesPerFile) {
|
const uint32_t uPortNumber, const uint32_t mFramesPerFile) {
|
||||||
|
|
||||||
subFileIndex = 0;
|
subFileIndex = 0;
|
||||||
numFramesInFile = 0;
|
numFramesInFile = 0;
|
||||||
|
|
||||||
filePath = fPath;
|
|
||||||
fileNamePrefix = fNamePrefix;
|
fileNamePrefix = fNamePrefix;
|
||||||
fileIndex = fIndex;
|
fileIndex = fIndex;
|
||||||
overWriteEnable = ovEnable;
|
overWriteEnable = ovEnable;
|
||||||
|
|
||||||
silentMode = sMode;
|
silentMode = sMode;
|
||||||
detIndex = modulePos;
|
|
||||||
numUnitsPerReadout = nUnitsPerReadout;
|
|
||||||
udpPortNumber = uPortNumber;
|
udpPortNumber = uPortNumber;
|
||||||
maxFramesPerFile = mFramesPerFile;
|
maxFramesPerFile = mFramesPerFile;
|
||||||
|
|
||||||
@ -46,8 +41,7 @@ void BinaryDataFile::CreateFile() {
|
|||||||
numFramesInFile = 0;
|
numFramesInFile = 0;
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << filePath << "/" << fileNamePrefix << "_d"
|
os << fileNamePrefix << "_f" << subFileIndex
|
||||||
<< (detIndex * numUnitsPerReadout + index) << "_f" << subFileIndex
|
|
||||||
<< '_' << fileIndex << ".raw";
|
<< '_' << fileIndex << ".raw";
|
||||||
fileName = os.str();
|
fileName = os.str();
|
||||||
|
|
||||||
|
@ -14,12 +14,10 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File {
|
|||||||
|
|
||||||
fileFormat GetFileFormat() const override;
|
fileFormat GetFileFormat() const override;
|
||||||
void CloseFile() override;
|
void CloseFile() override;
|
||||||
void CreateFirstBinaryDataFile(const std::string fPath,
|
void CreateFirstBinaryDataFile(const std::string& fNamePrefix,
|
||||||
const std::string fNamePrefix,
|
|
||||||
const uint64_t fIndex,
|
const uint64_t fIndex,
|
||||||
const bool ovEnable,
|
const bool ovEnable,
|
||||||
const bool sMode, const int modulePos,
|
const bool sMode,
|
||||||
const int nUnitsPerReadout,
|
|
||||||
const uint32_t uPortNumber,
|
const uint32_t uPortNumber,
|
||||||
const uint32_t mFramesPerFile) override;
|
const uint32_t mFramesPerFile) override;
|
||||||
|
|
||||||
@ -34,13 +32,10 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File {
|
|||||||
uint32_t numFramesInFile{0};
|
uint32_t numFramesInFile{0};
|
||||||
uint32_t subFileIndex{0};
|
uint32_t subFileIndex{0};
|
||||||
|
|
||||||
std::string filePath;
|
|
||||||
std::string fileNamePrefix;
|
std::string fileNamePrefix;
|
||||||
uint64_t fileIndex{0};
|
uint64_t fileIndex{0};
|
||||||
bool overWriteEnable{false};
|
bool overWriteEnable{false};
|
||||||
bool silentMode{false};
|
bool silentMode{false};
|
||||||
int detIndex{0};
|
|
||||||
int numUnitsPerReadout{0};
|
|
||||||
uint32_t udpPortNumber{0};
|
uint32_t udpPortNumber{0};
|
||||||
uint32_t maxFramesPerFile{0};
|
uint32_t maxFramesPerFile{0};
|
||||||
};
|
};
|
||||||
|
@ -28,8 +28,8 @@ namespace sls {
|
|||||||
|
|
||||||
const std::string DataProcessor::typeName = "DataProcessor";
|
const std::string DataProcessor::typeName = "DataProcessor";
|
||||||
|
|
||||||
DataProcessor::DataProcessor(int index, detectorType detType, Fifo *fifo, bool *dataStreamEnable, uint32_t *streamingFrequency, uint32_t *streamingTimerInMs, uint32_t *streamingStartFnum, bool *framePadding, std::vector<int> *ctbDbitList, int *ctbDbitOffset, int *ctbAnalogDataBytes)
|
DataProcessor::DataProcessor(int index)
|
||||||
: ThreadObject(index, typeName), fifo(fifo), detType(detType), dataStreamEnable(dataStreamEnable), streamingFrequency(streamingFrequency), streamingTimerInMs(streamingTimerInMs), streamingStartFnum(streamingStartFnum), framePadding(framePadding), ctbDbitList(ctbDbitList), ctbDbitOffset(ctbDbitOffset), ctbAnalogDataBytes(ctbAnalogDataBytes) {
|
: ThreadObject(index, typeName) {
|
||||||
|
|
||||||
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
||||||
}
|
}
|
||||||
@ -38,7 +38,11 @@ DataProcessor::~DataProcessor() { DeleteFiles(); }
|
|||||||
|
|
||||||
bool DataProcessor::GetStartedFlag() const { return startedFlag; }
|
bool DataProcessor::GetStartedFlag() const { return startedFlag; }
|
||||||
|
|
||||||
void DataProcessor::SetFifo(Fifo *fifo) { fifo = fifo; }
|
void DataProcessor::SetFifo(Fifo *f) { fifo = f; }
|
||||||
|
|
||||||
|
void DataProcessor::SetGeneralData(GeneralData *g) {
|
||||||
|
generalData = g;
|
||||||
|
}
|
||||||
|
|
||||||
void DataProcessor::SetActivate(bool enable) { activated = enable; }
|
void DataProcessor::SetActivate(bool enable) { activated = enable; }
|
||||||
|
|
||||||
@ -48,6 +52,30 @@ void DataProcessor::SetReceiverROI(ROI roi) {
|
|||||||
receiverNoRoi = receiverRoi.noRoi();
|
receiverNoRoi = receiverRoi.noRoi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetDataStreamEnable(bool enable) { dataStreamEnable = enable; }
|
||||||
|
|
||||||
|
void DataProcessor::SetStreamingFrequency(uint32_t value) {
|
||||||
|
streamingFrequency = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetStreamingTimerInMs(uint32_t value) {
|
||||||
|
streamingTimerInMs = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetStreamingStartFnum(uint32_t value) {
|
||||||
|
streamingStartFnum = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetFramePadding(bool enable) { framePadding = enable; }
|
||||||
|
|
||||||
|
void DataProcessor::SetCtbDbitList(std::vector<int> value) {
|
||||||
|
ctbDbitList = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetCtbDbitOffset(int value) {
|
||||||
|
ctbDbitOffset = value;
|
||||||
|
}
|
||||||
|
|
||||||
void DataProcessor::ResetParametersforNewAcquisition() {
|
void DataProcessor::ResetParametersforNewAcquisition() {
|
||||||
StopRunning();
|
StopRunning();
|
||||||
startedFlag = false;
|
startedFlag = false;
|
||||||
@ -67,10 +95,6 @@ void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
|||||||
LOG(logDEBUG1) << index << " First Index:" << firstIndex;
|
LOG(logDEBUG1) << index << " First Index:" << firstIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::SetGeneralData(GeneralData *g) {
|
|
||||||
generalData = g;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataProcessor::CloseFiles() {
|
void DataProcessor::CloseFiles() {
|
||||||
if (dataFile)
|
if (dataFile)
|
||||||
dataFile->CloseFile();
|
dataFile->CloseFile();
|
||||||
@ -103,11 +127,10 @@ void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::CreateFirstFiles(
|
void DataProcessor::CreateFirstFiles(
|
||||||
const std::string &filePath, const std::string &fileNamePrefix,
|
const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const uint32_t udpPortNumber,
|
||||||
const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
|
const uint64_t numImages,
|
||||||
const uint64_t numImages, const uint32_t dynamicRange,
|
|
||||||
const bool detectorDataStream) {
|
const bool detectorDataStream) {
|
||||||
if (dataFile == nullptr) {
|
if (dataFile == nullptr) {
|
||||||
throw RuntimeError("file object not contstructed");
|
throw RuntimeError("file object not contstructed");
|
||||||
@ -134,15 +157,15 @@ void DataProcessor::CreateFirstFiles(
|
|||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
case HDF5:
|
case HDF5:
|
||||||
dataFile->CreateFirstHDF5DataFile(
|
dataFile->CreateFirstHDF5DataFile(
|
||||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile,
|
udpPortNumber, generalData->framesPerFile,
|
||||||
numImages, nx, ny, dynamicRange);
|
numImages, nx, ny, generalData->dynamicRange);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case BINARY:
|
case BINARY:
|
||||||
dataFile->CreateFirstBinaryDataFile(
|
dataFile->CreateFirstBinaryDataFile(
|
||||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile);
|
udpPortNumber, generalData->framesPerFile);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError("Unknown file format (compile with hdf5 flags");
|
throw RuntimeError("Unknown file format (compile with hdf5 flags");
|
||||||
@ -161,9 +184,9 @@ uint32_t DataProcessor::GetFilesInAcquisition() const {
|
|||||||
std::string DataProcessor::CreateVirtualFile(
|
std::string DataProcessor::CreateVirtualFile(
|
||||||
const std::string &filePath, const std::string &fileNamePrefix,
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const int modulePos,
|
||||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
const uint64_t numImages,
|
||||||
const int numModX, const int numModY, const uint32_t dynamicRange,
|
const int numModX, const int numModY,
|
||||||
std::mutex *hdf5LibMutex) {
|
std::mutex *hdf5LibMutex) {
|
||||||
|
|
||||||
if (receiverRoiEnabled) {
|
if (receiverRoiEnabled) {
|
||||||
@ -171,12 +194,12 @@ std::string DataProcessor::CreateVirtualFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool gotthard25um =
|
bool gotthard25um =
|
||||||
((detType == GOTTHARD || detType == GOTTHARD2) &&
|
((generalData->detType == GOTTHARD || generalData->detType == GOTTHARD2) &&
|
||||||
(numModX * numModY) == 2);
|
(numModX * numModY) == 2);
|
||||||
|
|
||||||
// maxframesperfile = 0 for infinite files
|
// 0 for infinite files
|
||||||
uint32_t framesPerFile =
|
uint32_t framesPerFile =
|
||||||
((maxFramesPerFile == 0) ? numFramesCaught : maxFramesPerFile);
|
((generalData->framesPerFile == 0) ? numFramesCaught : generalData->framesPerFile);
|
||||||
|
|
||||||
// TODO: assumption 1: create virtual file even if no data in other
|
// TODO: assumption 1: create virtual file even if no data in other
|
||||||
// files (they exist anyway) assumption2: virtual file max frame index
|
// files (they exist anyway) assumption2: virtual file max frame index
|
||||||
@ -184,8 +207,8 @@ std::string DataProcessor::CreateVirtualFile(
|
|||||||
// stop acquisition)
|
// stop acquisition)
|
||||||
return masterFileUtility::CreateVirtualHDF5File(
|
return masterFileUtility::CreateVirtualHDF5File(
|
||||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
modulePos, numUnitsPerReadout, framesPerFile,
|
modulePos, generalData->numUDPInterfaces, framesPerFile,
|
||||||
generalData->nPixelsX, generalData->nPixelsY, dynamicRange,
|
generalData->nPixelsX, generalData->nPixelsY, generalData->dynamicRange,
|
||||||
numFramesCaught, numModX, numModY, dataFile->GetPDataType(),
|
numFramesCaught, numModX, numModY, dataFile->GetPDataType(),
|
||||||
dataFile->GetParameterNames(), dataFile->GetParameterDataTypes(),
|
dataFile->GetParameterNames(), dataFile->GetParameterDataTypes(),
|
||||||
hdf5LibMutex, gotthard25um);
|
hdf5LibMutex, gotthard25um);
|
||||||
@ -273,7 +296,7 @@ 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);
|
||||||
@ -292,29 +315,29 @@ void DataProcessor::ProcessAnImage(sls_receiver_header & header, size_t &size, s
|
|||||||
|
|
||||||
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 (*framePadding && nump < generalData->packetsPerFrame)
|
if (framePadding && nump < generalData->packetsPerFrame)
|
||||||
PadMissingPackets(header, data);
|
PadMissingPackets(header, data);
|
||||||
|
|
||||||
// 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(size, data);
|
RearrangeDbitData(size, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'stream Image' check has to be done here before crop image
|
// 'stream Image' check has to be done here before crop image
|
||||||
// stream (if time/freq to stream) or free
|
// stream (if time/freq to stream) or free
|
||||||
if (*dataStreamEnable && SendToStreamer()) {
|
if (dataStreamEnable && SendToStreamer()) {
|
||||||
if (firstStreamerFrame) {
|
if (firstStreamerFrame) {
|
||||||
firstStreamerFrame = false;
|
firstStreamerFrame = false;
|
||||||
// write to memory structure of first streamer frame
|
// write to memory structure of first streamer frame
|
||||||
@ -362,7 +385,7 @@ void DataProcessor::ProcessAnImage(sls_receiver_header & header, size_t &size, s
|
|||||||
|
|
||||||
bool DataProcessor::SendToStreamer() {
|
bool DataProcessor::SendToStreamer() {
|
||||||
// skip
|
// skip
|
||||||
if ((*streamingFrequency) == 0u) {
|
if (streamingFrequency == 0u) {
|
||||||
if (!CheckTimer())
|
if (!CheckTimer())
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -378,7 +401,7 @@ bool DataProcessor::CheckTimer() {
|
|||||||
|
|
||||||
auto elapsed_s = (end.tv_sec - timerbegin.tv_sec) +
|
auto elapsed_s = (end.tv_sec - timerbegin.tv_sec) +
|
||||||
(end.tv_nsec - timerbegin.tv_nsec) / 1e9;
|
(end.tv_nsec - timerbegin.tv_nsec) / 1e9;
|
||||||
double timer_s = *streamingTimerInMs / 1e3;
|
double timer_s = streamingTimerInMs / 1e3;
|
||||||
|
|
||||||
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
|
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
|
||||||
<< " seconds";
|
<< " seconds";
|
||||||
@ -393,7 +416,7 @@ bool DataProcessor::CheckTimer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DataProcessor::CheckCount() {
|
bool DataProcessor::CheckCount() {
|
||||||
if (currentFreqCount == *streamingFrequency) {
|
if (currentFreqCount == streamingFrequency) {
|
||||||
currentFreqCount = 1;
|
currentFreqCount = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -422,7 +445,7 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char* data) {
|
|||||||
sls_bitset pmask = header.packetsMask;
|
sls_bitset pmask = header.packetsMask;
|
||||||
|
|
||||||
uint32_t dsize = generalData->dataSize;
|
uint32_t dsize = generalData->dataSize;
|
||||||
if (detType == GOTTHARD2 && index != 0) {
|
if (generalData->detType == GOTTHARD2 && index != 0) {
|
||||||
dsize = generalData->vetoDataSize;
|
dsize = generalData->vetoDataSize;
|
||||||
}
|
}
|
||||||
uint32_t corrected_dsize =
|
uint32_t corrected_dsize =
|
||||||
@ -443,7 +466,7 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char* data) {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// missing packet
|
// missing packet
|
||||||
switch (detType) {
|
switch (generalData->detType) {
|
||||||
// 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 +
|
||||||
@ -471,8 +494,9 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char* data) {
|
|||||||
|
|
||||||
/** ctb specific */
|
/** ctb specific */
|
||||||
void DataProcessor::RearrangeDbitData(size_t & size, char *data) {
|
void DataProcessor::RearrangeDbitData(size_t & size, char *data) {
|
||||||
|
int nAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
|
||||||
// TODO! (Erik) Refactor and add tests
|
// TODO! (Erik) Refactor and add tests
|
||||||
int ctbDigitalDataBytes = size - (*ctbAnalogDataBytes) - (*ctbDbitOffset);
|
int ctbDigitalDataBytes = size - nAnalogDataBytes - ctbDbitOffset;
|
||||||
|
|
||||||
// no digital data
|
// no digital data
|
||||||
if (ctbDigitalDataBytes == 0) {
|
if (ctbDigitalDataBytes == 0) {
|
||||||
@ -485,15 +509,15 @@ void DataProcessor::RearrangeDbitData(size_t & size, char *data) {
|
|||||||
|
|
||||||
// ceil as numResult8Bits could be decimal
|
// ceil as numResult8Bits could be decimal
|
||||||
const int numResult8Bits =
|
const int numResult8Bits =
|
||||||
ceil((numSamples * (*ctbDbitList).size()) / 8.00);
|
ceil((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 *)(data + (*ctbAnalogDataBytes) + (*ctbDbitOffset));
|
auto *source = (uint64_t *)(data + nAnalogDataBytes + 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;
|
||||||
@ -515,7 +539,7 @@ void DataProcessor::RearrangeDbitData(size_t & size, char *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy back to memory and update size
|
// copy back to memory and update size
|
||||||
memcpy(data + (*ctbAnalogDataBytes), result.data(), numResult8Bits * sizeof(uint8_t));
|
memcpy(data + nAnalogDataBytes, result.data(), numResult8Bits * sizeof(uint8_t));
|
||||||
size = numResult8Bits * sizeof(uint8_t);
|
size = numResult8Bits * sizeof(uint8_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,31 +29,36 @@ struct MasterAttributes;
|
|||||||
class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataProcessor(int index, detectorType detType, Fifo *fifo, bool *dataStreamEnable, uint32_t *streamingFrequency, uint32_t *streamingTimerInMs, uint32_t *streamingStartFnum, bool *framePadding, std::vector<int> *ctbDbitList, int *ctbDbitOffset, int *ctbAnalogDataBytes);
|
DataProcessor(int index);
|
||||||
~DataProcessor() override;
|
~DataProcessor() override;
|
||||||
|
|
||||||
bool GetStartedFlag() const;
|
bool GetStartedFlag() const;
|
||||||
|
|
||||||
void SetFifo(Fifo *f);
|
void SetFifo(Fifo *f);
|
||||||
void SetActivate(bool enable);
|
|
||||||
void SetReceiverROI(ROI roi);
|
|
||||||
void ResetParametersforNewAcquisition();
|
|
||||||
void SetGeneralData(GeneralData *generalData);
|
void SetGeneralData(GeneralData *generalData);
|
||||||
|
|
||||||
|
void SetActivate(bool enable);
|
||||||
|
void SetReceiverROI(ROI roi);
|
||||||
|
void SetDataStreamEnable(bool enable);
|
||||||
|
void SetStreamingFrequency(uint32_t value);
|
||||||
|
void SetStreamingTimerInMs(uint32_t value);
|
||||||
|
void SetStreamingStartFnum(uint32_t value);
|
||||||
|
void SetFramePadding(bool enable);
|
||||||
|
void SetCtbDbitList(std::vector<int> value);
|
||||||
|
void SetCtbDbitOffset(int value);
|
||||||
|
|
||||||
|
void ResetParametersforNewAcquisition();
|
||||||
void CloseFiles();
|
void CloseFiles();
|
||||||
void DeleteFiles();
|
void DeleteFiles();
|
||||||
void SetupFileWriter(const bool filewriteEnable,
|
void SetupFileWriter(const bool filewriteEnable,
|
||||||
const fileFormat fileFormatType,
|
const fileFormat fileFormatType,
|
||||||
std::mutex *hdf5LibMutex);
|
std::mutex *hdf5LibMutex);
|
||||||
|
|
||||||
void CreateFirstFiles(const std::string &filePath,
|
void CreateFirstFiles(const std::string &fileNamePrefix,
|
||||||
const std::string &fileNamePrefix,
|
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode,
|
||||||
const int numUnitsPerReadout,
|
|
||||||
const uint32_t udpPortNumber,
|
const uint32_t udpPortNumber,
|
||||||
const uint32_t maxFramesPerFile,
|
const uint64_t numImages,
|
||||||
const uint64_t numImages, const uint32_t dynamicRange,
|
|
||||||
const bool detectorDataStream);
|
const bool detectorDataStream);
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
uint32_t GetFilesInAcquisition() const;
|
uint32_t GetFilesInAcquisition() const;
|
||||||
@ -61,9 +66,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
const std::string &filePath, const std::string &fileNamePrefix,
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode, const int modulePos,
|
||||||
const int numUnitsPerReadout, const uint32_t maxFramesPerFile,
|
|
||||||
const uint64_t numImages, const int numModX, const int numModY,
|
const uint64_t numImages, const int numModX, const int numModY,
|
||||||
const uint32_t dynamicRange, std::mutex *hdf5LibMutex);
|
std::mutex *hdf5LibMutex);
|
||||||
void LinkFileInMaster(const std::string &masterFileName,
|
void LinkFileInMaster(const std::string &masterFileName,
|
||||||
const std::string &virtualFileName,
|
const std::string &virtualFileName,
|
||||||
const bool silentMode, std::mutex *hdf5LibMutex);
|
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||||
@ -137,25 +141,23 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
|
|
||||||
static const std::string typeName;
|
static const std::string typeName;
|
||||||
|
|
||||||
const GeneralData *generalData{nullptr};
|
GeneralData *generalData{nullptr};
|
||||||
Fifo *fifo;
|
Fifo *fifo;
|
||||||
detectorType detType;
|
bool dataStreamEnable;
|
||||||
bool *dataStreamEnable;
|
|
||||||
bool activated{false};
|
bool activated{false};
|
||||||
ROI receiverRoi{};
|
ROI receiverRoi{};
|
||||||
bool receiverRoiEnabled{false};
|
bool receiverRoiEnabled{false};
|
||||||
bool receiverNoRoi{false};
|
bool receiverNoRoi{false};
|
||||||
std::unique_ptr<char[]> completeImageToStreamBeforeCropping;
|
std::unique_ptr<char[]> completeImageToStreamBeforeCropping;
|
||||||
/** if 0, sending random images with a timer */
|
/** if 0, sending random images with a timer */
|
||||||
uint32_t *streamingFrequency;
|
uint32_t streamingFrequency;
|
||||||
uint32_t *streamingTimerInMs;
|
uint32_t streamingTimerInMs;
|
||||||
uint32_t *streamingStartFnum;
|
uint32_t streamingStartFnum;
|
||||||
uint32_t currentFreqCount{0};
|
uint32_t currentFreqCount{0};
|
||||||
struct timespec timerbegin {};
|
struct timespec timerbegin {};
|
||||||
bool *framePadding;
|
bool framePadding;
|
||||||
std::vector<int> *ctbDbitList;
|
std::vector<int> ctbDbitList;
|
||||||
int *ctbDbitOffset;
|
int ctbDbitOffset;
|
||||||
int *ctbAnalogDataBytes;
|
|
||||||
std::atomic<bool> startedFlag{false};
|
std::atomic<bool> startedFlag{false};
|
||||||
std::atomic<uint64_t> firstIndex{0};
|
std::atomic<uint64_t> firstIndex{0};
|
||||||
|
|
||||||
|
@ -18,9 +18,7 @@ namespace sls {
|
|||||||
|
|
||||||
const std::string DataStreamer::TypeName = "DataStreamer";
|
const std::string DataStreamer::TypeName = "DataStreamer";
|
||||||
|
|
||||||
DataStreamer::DataStreamer(int index, Fifo *fifo, uint32_t *dynamicRange, ROI *detectorRoi, uint64_t *fileIndex, bool flipRows, slsDetectorDefs::xy numPorts, bool *quadEnable, uint64_t *totalNumFrames)
|
DataStreamer::DataStreamer(int index) : ThreadObject(index, TypeName) {
|
||||||
: ThreadObject(index, TypeName), fifo(fifo), dynamicRange(dynamicRange), detectorRoi(detectorRoi), fileIndex(fileIndex), flipRows(flipRows), numPorts(numPorts), quadEnable(quadEnable), totalNumFrames(totalNumFrames) {
|
|
||||||
|
|
||||||
LOG(logDEBUG) << "DataStreamer " << index << " created";
|
LOG(logDEBUG) << "DataStreamer " << index << " created";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +29,35 @@ DataStreamer::~DataStreamer() {
|
|||||||
|
|
||||||
void DataStreamer::SetFifo(Fifo *f) { fifo = f; }
|
void DataStreamer::SetFifo(Fifo *f) { fifo = f; }
|
||||||
|
|
||||||
|
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||||
|
|
||||||
|
void DataStreamer::SetFileIndex(uint64_t value) {
|
||||||
|
fileIndex = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataStreamer::SetNumberofPorts(xy np) { numPorts = np; }
|
||||||
|
|
||||||
|
void DataStreamer::SetFlipRows(bool fd) {
|
||||||
|
flipRows = fd;
|
||||||
|
// flip only right port of quad
|
||||||
|
if (quadEnable) {
|
||||||
|
flipRows = (index == 1 ? true : false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataStreamer::SetQuadEnable(bool value) { quadEnable = value; }
|
||||||
|
|
||||||
|
void DataStreamer::SetNumberofTotalFrames(uint64_t value) {
|
||||||
|
nTotalFrames = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataStreamer::SetAdditionalJsonHeader(
|
||||||
|
const std::map<std::string, std::string> &json) {
|
||||||
|
std::lock_guard<std::mutex> lock(additionalJsonMutex);
|
||||||
|
additionalJsonHeader = json;
|
||||||
|
isAdditionalJsonUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
|
void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
|
||||||
StopRunning();
|
StopRunning();
|
||||||
startedFlag = false;
|
startedFlag = false;
|
||||||
@ -41,8 +68,8 @@ void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
|
|||||||
delete[] completeBuffer;
|
delete[] completeBuffer;
|
||||||
completeBuffer = nullptr;
|
completeBuffer = nullptr;
|
||||||
}
|
}
|
||||||
if (generalData->detType == GOTTHARD && detectorRoi->xmin != -1) {
|
if (generalData->detType == GOTTHARD && generalData->detectorRoi.xmin != -1) {
|
||||||
adcConfigured = generalData->GetAdcConfigured(index, *detectorRoi);
|
adcConfigured = generalData->GetAdcConfigured(index, generalData->detectorRoi);
|
||||||
completeBuffer = new char[generalData->imageSizeComplete];
|
completeBuffer = new char[generalData->imageSizeComplete];
|
||||||
memset(completeBuffer, 0, generalData->imageSizeComplete);
|
memset(completeBuffer, 0, generalData->imageSizeComplete);
|
||||||
}
|
}
|
||||||
@ -55,20 +82,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, size_t firstImageIndex) {
|
|||||||
<< ", First Streamer Index:" << fnum;
|
<< ", First Streamer Index:" << fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
|
void DataStreamer::CreateZmqSockets(uint32_t port,
|
||||||
|
|
||||||
void DataStreamer::SetNumberofPorts(xy np) { numPorts = np; }
|
|
||||||
|
|
||||||
void DataStreamer::SetFlipRows(bool fd) { flipRows = fd; }
|
|
||||||
|
|
||||||
void DataStreamer::SetAdditionalJsonHeader(
|
|
||||||
const std::map<std::string, std::string> &json) {
|
|
||||||
std::lock_guard<std::mutex> lock(additionalJsonMutex);
|
|
||||||
additionalJsonHeader = json;
|
|
||||||
isAdditionalJsonUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataStreamer::CreateZmqSockets(int *nunits, uint32_t port,
|
|
||||||
const IpAddr ip, int hwm) {
|
const IpAddr ip, int hwm) {
|
||||||
uint32_t portnum = port + index;
|
uint32_t portnum = port + index;
|
||||||
std::string sip = ip.str();
|
std::string sip = ip.str();
|
||||||
@ -193,8 +207,8 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
|
|||||||
uint64_t frameIndex = header.frameNumber - firstIndex;
|
uint64_t frameIndex = header.frameNumber - firstIndex;
|
||||||
uint64_t acquisitionIndex = header.frameNumber;
|
uint64_t acquisitionIndex = header.frameNumber;
|
||||||
|
|
||||||
zHeader.dynamicRange = *dynamicRange;
|
zHeader.dynamicRange = generalData->dynamicRange;
|
||||||
zHeader.fileIndex = *fileIndex;
|
zHeader.fileIndex = fileIndex;
|
||||||
zHeader.ndetx = numPorts.x;
|
zHeader.ndetx = numPorts.x;
|
||||||
zHeader.ndety = numPorts.y;
|
zHeader.ndety = numPorts.y;
|
||||||
zHeader.npixelsx = nx;
|
zHeader.npixelsx = nx;
|
||||||
@ -203,7 +217,7 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
|
|||||||
zHeader.acqIndex = acquisitionIndex;
|
zHeader.acqIndex = acquisitionIndex;
|
||||||
zHeader.frameIndex = frameIndex;
|
zHeader.frameIndex = frameIndex;
|
||||||
zHeader.progress =
|
zHeader.progress =
|
||||||
100 * ((double)(frameIndex + 1) / (double)(*totalNumFrames));
|
100 * ((double)(frameIndex + 1) / (double)(nTotalFrames));
|
||||||
zHeader.fname = fileNametoStream;
|
zHeader.fname = fileNametoStream;
|
||||||
zHeader.frameNumber = header.frameNumber;
|
zHeader.frameNumber = header.frameNumber;
|
||||||
zHeader.expLength = header.expLength;
|
zHeader.expLength = header.expLength;
|
||||||
@ -219,7 +233,7 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
|
|||||||
zHeader.detType = header.detType;
|
zHeader.detType = header.detType;
|
||||||
zHeader.version = header.version;
|
zHeader.version = header.version;
|
||||||
zHeader.flipRows = static_cast<int>(flipRows);
|
zHeader.flipRows = static_cast<int>(flipRows);
|
||||||
zHeader.quad = *quadEnable;
|
zHeader.quad = quadEnable;
|
||||||
zHeader.completeImage =
|
zHeader.completeImage =
|
||||||
(header.packetNumber < generalData->packetsPerFrame ? false : true);
|
(header.packetNumber < generalData->packetsPerFrame ? false : true);
|
||||||
|
|
||||||
|
@ -25,26 +25,29 @@ class ZmqSocket;
|
|||||||
class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataStreamer(int index, Fifo *fifo, uint32_t *dynamicRange, ROI *detectorRoi, uint64_t *fileIndex, bool flipRows, slsDetectorDefs::xy numPorts, bool *quadEnable, uint64_t *totalNumFrames);
|
DataStreamer(int index);
|
||||||
~DataStreamer();
|
~DataStreamer();
|
||||||
|
|
||||||
void SetFifo(Fifo *f);
|
void SetFifo(Fifo *f);
|
||||||
void ResetParametersforNewAcquisition(const std::string &fname);
|
|
||||||
void SetGeneralData(GeneralData *g);
|
void SetGeneralData(GeneralData *g);
|
||||||
|
|
||||||
|
void SetFileIndex(uint64_t value);
|
||||||
void SetNumberofPorts(xy np);
|
void SetNumberofPorts(xy np);
|
||||||
void SetFlipRows(bool fd);
|
void SetFlipRows(bool fd);
|
||||||
|
void SetQuadEnable(bool value);
|
||||||
|
void SetNumberofTotalFrames(uint64_t value);
|
||||||
void
|
void
|
||||||
SetAdditionalJsonHeader(const std::map<std::string, std::string> &json);
|
SetAdditionalJsonHeader(const std::map<std::string, std::string> &json);
|
||||||
|
|
||||||
|
void ResetParametersforNewAcquisition(const std::string &fname);
|
||||||
/**
|
/**
|
||||||
* Creates Zmq Sockets
|
* Creates Zmq Sockets
|
||||||
* (throws an exception if it couldnt create zmq sockets)
|
* (throws an exception if it couldnt create zmq sockets)
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
|
||||||
* @param port streaming port start index
|
* @param port streaming port start index
|
||||||
* @param ip streaming source ip
|
* @param ip streaming source ip
|
||||||
* @param hwm streaming high water mark
|
* @param hwm streaming high water mark
|
||||||
*/
|
*/
|
||||||
void CreateZmqSockets(int *nunits, uint32_t port, const IpAddr ip,
|
void CreateZmqSockets(uint32_t port, const IpAddr ip,
|
||||||
int hwm);
|
int hwm);
|
||||||
void CloseZmqSocket();
|
void CloseZmqSocket();
|
||||||
void RestreamStop();
|
void RestreamStop();
|
||||||
@ -85,13 +88,11 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
|
|
||||||
static const std::string TypeName;
|
static const std::string TypeName;
|
||||||
const GeneralData *generalData{nullptr};
|
const GeneralData *generalData{nullptr};
|
||||||
Fifo *fifo;
|
Fifo *fifo{nullptr};
|
||||||
ZmqSocket *zmqSocket{nullptr};
|
ZmqSocket *zmqSocket{nullptr};
|
||||||
uint32_t *dynamicRange;
|
|
||||||
ROI *detectorRoi;
|
|
||||||
int adcConfigured{-1};
|
int adcConfigured{-1};
|
||||||
uint64_t *fileIndex;
|
uint64_t fileIndex{0};
|
||||||
bool flipRows;
|
bool flipRows{false};
|
||||||
std::map<std::string, std::string> additionalJsonHeader;
|
std::map<std::string, std::string> additionalJsonHeader;
|
||||||
|
|
||||||
/** Used by streamer thread to update local copy (reduce number of locks
|
/** Used by streamer thread to update local copy (reduce number of locks
|
||||||
@ -111,8 +112,8 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
char *completeBuffer{nullptr};
|
char *completeBuffer{nullptr};
|
||||||
|
|
||||||
xy numPorts{1, 1};
|
xy numPorts{1, 1};
|
||||||
bool *quadEnable;
|
bool quadEnable{false};
|
||||||
uint64_t *totalNumFrames;
|
uint64_t nTotalFrames{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -60,10 +60,9 @@ class File : private virtual slsDetectorDefs {
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual void CreateFirstHDF5DataFile(
|
virtual void CreateFirstHDF5DataFile(
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const std::string& fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode, const uint32_t udpPortNumber,
|
||||||
const int numUnitsPerReadout, const uint32_t udpPortNumber,
|
|
||||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
||||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||||
const uint32_t dynamicRange) {
|
const uint32_t dynamicRange) {
|
||||||
@ -72,10 +71,9 @@ class File : private virtual slsDetectorDefs {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
virtual void CreateFirstBinaryDataFile(
|
virtual void CreateFirstBinaryDataFile(
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const std::string& fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode, const uint32_t udpPortNumber,
|
||||||
const int numUnitsPerReadout, const uint32_t udpPortNumber,
|
|
||||||
const uint32_t maxFramesPerFile) {
|
const uint32_t maxFramesPerFile) {
|
||||||
LOG(logERROR) << "This is a generic function CreateFirstBinaryDataFile that "
|
LOG(logERROR) << "This is a generic function CreateFirstBinaryDataFile that "
|
||||||
"should be overloaded by a derived class";
|
"should be overloaded by a derived class";
|
||||||
|
@ -36,9 +36,9 @@ class GeneralData {
|
|||||||
uint32_t frameIndexOffset{0};
|
uint32_t frameIndexOffset{0};
|
||||||
uint32_t packetIndexMask{0};
|
uint32_t packetIndexMask{0};
|
||||||
uint32_t packetIndexOffset{0};
|
uint32_t packetIndexOffset{0};
|
||||||
uint32_t maxFramesPerFile{0};
|
uint32_t framesPerFile{0};
|
||||||
uint32_t defaultFifoDepth{0};
|
uint32_t fifoDepth{0};
|
||||||
uint32_t numUDPInterfaces{1};
|
int numUDPInterfaces{1};
|
||||||
uint32_t headerPacketSize{0};
|
uint32_t headerPacketSize{0};
|
||||||
/** Streaming (for ROI - mainly short Gotthard) */
|
/** Streaming (for ROI - mainly short Gotthard) */
|
||||||
uint32_t nPixelsXComplete{0};
|
uint32_t nPixelsXComplete{0};
|
||||||
@ -48,7 +48,7 @@ class GeneralData {
|
|||||||
uint32_t imageSizeComplete{0};
|
uint32_t imageSizeComplete{0};
|
||||||
/** if standard header implemented in firmware */
|
/** if standard header implemented in firmware */
|
||||||
bool standardheader{false};
|
bool standardheader{false};
|
||||||
uint32_t defaultUdpSocketBufferSize{RECEIVE_SOCKET_BUFFER_SIZE};
|
uint32_t udpSocketBufferSize{RECEIVE_SOCKET_BUFFER_SIZE};
|
||||||
uint32_t vetoDataSize{0};
|
uint32_t vetoDataSize{0};
|
||||||
uint32_t vetoPacketSize{0};
|
uint32_t vetoPacketSize{0};
|
||||||
uint32_t vetoImageSize{0};
|
uint32_t vetoImageSize{0};
|
||||||
@ -61,7 +61,7 @@ class GeneralData {
|
|||||||
slsDetectorDefs::readoutMode readoutType{slsDetectorDefs::ANALOG_ONLY};
|
slsDetectorDefs::readoutMode readoutType{slsDetectorDefs::ANALOG_ONLY};
|
||||||
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
||||||
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
||||||
slsDetectorDefs::ROI roi{};
|
slsDetectorDefs::ROI detectorRoi{};
|
||||||
uint32_t counterMask{0};
|
uint32_t counterMask{0};
|
||||||
|
|
||||||
GeneralData(){};
|
GeneralData(){};
|
||||||
@ -164,7 +164,7 @@ class GotthardData : public GeneralData {
|
|||||||
detType = slsDetectorDefs::GOTTHARD;
|
detType = slsDetectorDefs::GOTTHARD;
|
||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
headerSizeinPacket = 6;
|
headerSizeinPacket = 6;
|
||||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
framesPerFile = MAX_FRAMES_PER_FILE;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ class GotthardData : public GeneralData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void SetDetectorROI(slsDetectorDefs::ROI i) {
|
void SetDetectorROI(slsDetectorDefs::ROI i) {
|
||||||
roi = i;
|
detectorRoi = i;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -255,18 +255,18 @@ class GotthardData : public GeneralData {
|
|||||||
void UpdateImageSize() {
|
void UpdateImageSize() {
|
||||||
|
|
||||||
// all adcs
|
// all adcs
|
||||||
if (roi.xmin == -1) {
|
if (detectorRoi.xmin == -1) {
|
||||||
nPixelsX = 1280;
|
nPixelsX = 1280;
|
||||||
dataSize = 1280;
|
dataSize = 1280;
|
||||||
packetsPerFrame = 2;
|
packetsPerFrame = 2;
|
||||||
frameIndexMask = 0xFFFFFFFE;
|
frameIndexMask = 0xFFFFFFFE;
|
||||||
frameIndexOffset = 1;
|
frameIndexOffset = 1;
|
||||||
packetIndexMask = 1;
|
packetIndexMask = 1;
|
||||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
framesPerFile = MAX_FRAMES_PER_FILE;
|
||||||
nPixelsXComplete = 0;
|
nPixelsXComplete = 0;
|
||||||
nPixelsYComplete = 0;
|
nPixelsYComplete = 0;
|
||||||
imageSizeComplete = 0;
|
imageSizeComplete = 0;
|
||||||
defaultFifoDepth = 50000;
|
fifoDepth = 50000;
|
||||||
} else {
|
} else {
|
||||||
nPixelsX = 256;
|
nPixelsX = 256;
|
||||||
dataSize = 512;
|
dataSize = 512;
|
||||||
@ -274,11 +274,11 @@ class GotthardData : public GeneralData {
|
|||||||
frameIndexMask = 0xFFFFFFFF;
|
frameIndexMask = 0xFFFFFFFF;
|
||||||
frameIndexOffset = 0;
|
frameIndexOffset = 0;
|
||||||
packetIndexMask = 0;
|
packetIndexMask = 0;
|
||||||
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
framesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
||||||
nPixelsXComplete = 1280;
|
nPixelsXComplete = 1280;
|
||||||
nPixelsYComplete = 1;
|
nPixelsYComplete = 1;
|
||||||
imageSizeComplete = 1280 * 2;
|
imageSizeComplete = 1280 * 2;
|
||||||
defaultFifoDepth = 75000;
|
fifoDepth = 75000;
|
||||||
}
|
}
|
||||||
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
||||||
packetSize = headerSizeinPacket + dataSize;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
@ -292,7 +292,7 @@ class EigerData : public GeneralData {
|
|||||||
EigerData() {
|
EigerData() {
|
||||||
detType = slsDetectorDefs::EIGER;
|
detType = slsDetectorDefs::EIGER;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
framesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
||||||
numUDPInterfaces = 2;
|
numUDPInterfaces = 2;
|
||||||
headerPacketSize = 40;
|
headerPacketSize = 40;
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
@ -318,7 +318,7 @@ class EigerData : public GeneralData {
|
|||||||
packetSize = headerSizeinPacket + dataSize;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
||||||
packetsPerFrame = imageSize / dataSize;
|
packetsPerFrame = imageSize / dataSize;
|
||||||
defaultFifoDepth = (dynamicRange == 32 ? 100 : 1000);
|
fifoDepth = (dynamicRange == 32 ? 100 : 1000);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -330,8 +330,8 @@ class JungfrauData : public GeneralData {
|
|||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
dataSize = 8192;
|
dataSize = 8192;
|
||||||
packetSize = headerSizeinPacket + dataSize;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
framesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
||||||
defaultFifoDepth = 2500;
|
fifoDepth = 2500;
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
maxRowsPerReadout = 512;
|
maxRowsPerReadout = 512;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
@ -348,7 +348,7 @@ class JungfrauData : public GeneralData {
|
|||||||
nPixelsY = (256 * 2) / numUDPInterfaces;
|
nPixelsY = (256 * 2) / numUDPInterfaces;
|
||||||
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
||||||
packetsPerFrame = imageSize / dataSize;
|
packetsPerFrame = imageSize / dataSize;
|
||||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
udpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -362,10 +362,10 @@ class Mythen3Data : public GeneralData {
|
|||||||
detType = slsDetectorDefs::MYTHEN3;
|
detType = slsDetectorDefs::MYTHEN3;
|
||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
maxFramesPerFile = MYTHEN3_MAX_FRAMES_PER_FILE;
|
framesPerFile = MYTHEN3_MAX_FRAMES_PER_FILE;
|
||||||
defaultFifoDepth = 50000;
|
fifoDepth = 50000;
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
|
udpSocketBufferSize = (1000 * 1024 * 1024);
|
||||||
dynamicRange = 32;
|
dynamicRange = 32;
|
||||||
tengigaEnable = true;
|
tengigaEnable = true;
|
||||||
SetCounterMask(0x7);
|
SetCounterMask(0x7);
|
||||||
@ -432,8 +432,8 @@ class Gotthard2Data : public GeneralData {
|
|||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
dataSize = 2560; // 1280 channels * 2 bytes
|
dataSize = 2560; // 1280 channels * 2 bytes
|
||||||
maxFramesPerFile = GOTTHARD2_MAX_FRAMES_PER_FILE;
|
framesPerFile = GOTTHARD2_MAX_FRAMES_PER_FILE;
|
||||||
defaultFifoDepth = 50000;
|
fifoDepth = 50000;
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
vetoDataSize = 160;
|
vetoDataSize = 160;
|
||||||
vetoHsize = 16;
|
vetoHsize = 16;
|
||||||
@ -469,7 +469,7 @@ class Gotthard2Data : public GeneralData {
|
|||||||
packetsPerFrame = imageSize / dataSize;
|
packetsPerFrame = imageSize / dataSize;
|
||||||
vetoPacketSize = vetoHsize + vetoDataSize;
|
vetoPacketSize = vetoHsize + vetoDataSize;
|
||||||
vetoImageSize = vetoDataSize * packetsPerFrame;
|
vetoImageSize = vetoDataSize * packetsPerFrame;
|
||||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
udpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -488,8 +488,8 @@ class ChipTestBoardData : public GeneralData {
|
|||||||
frameIndexMask = 0xFFFFFF; // 10g
|
frameIndexMask = 0xFFFFFF; // 10g
|
||||||
frameIndexOffset = 8; // 10g
|
frameIndexOffset = 8; // 10g
|
||||||
packetIndexMask = 0xFF; // 10g
|
packetIndexMask = 0xFF; // 10g
|
||||||
maxFramesPerFile = CTB_MAX_FRAMES_PER_FILE;
|
framesPerFile = CTB_MAX_FRAMES_PER_FILE;
|
||||||
defaultFifoDepth = 2500;
|
fifoDepth = 2500;
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
@ -575,8 +575,8 @@ class MoenchData : public GeneralData {
|
|||||||
detType = slsDetectorDefs::MOENCH;
|
detType = slsDetectorDefs::MOENCH;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
frameIndexMask = 0xFFFFFF;
|
frameIndexMask = 0xFFFFFF;
|
||||||
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
framesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
||||||
defaultFifoDepth = 2500;
|
fifoDepth = 2500;
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
@ -90,9 +90,8 @@ void HDF5DataFile::CloseFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::CreateFirstHDF5DataFile(
|
void HDF5DataFile::CreateFirstHDF5DataFile(
|
||||||
const std::string fPath, const std::string fNamePrefix,
|
const std::string& fNamePrefix,
|
||||||
const uint64_t fIndex, const bool owEnable, const bool sMode,
|
const uint64_t fIndex, const bool owEnable, const bool sMode,
|
||||||
const int modulePos, const int nUnitsPerReadout,
|
|
||||||
const uint32_t uPortNumber, const uint32_t mFramesPerFile,
|
const uint32_t uPortNumber, const uint32_t mFramesPerFile,
|
||||||
const uint64_t nImages, const uint32_t nX, const uint32_t nY,
|
const uint64_t nImages, const uint32_t nX, const uint32_t nY,
|
||||||
const uint32_t dr) {
|
const uint32_t dr) {
|
||||||
@ -108,13 +107,10 @@ void HDF5DataFile::CreateFirstHDF5DataFile(
|
|||||||
nPixelsY = nY;
|
nPixelsY = nY;
|
||||||
dynamicRange = dr;
|
dynamicRange = dr;
|
||||||
|
|
||||||
filePath = fPath;
|
|
||||||
fileNamePrefix = fNamePrefix;
|
fileNamePrefix = fNamePrefix;
|
||||||
fileIndex = fIndex;
|
fileIndex = fIndex;
|
||||||
overWriteEnable = owEnable;
|
overWriteEnable = owEnable;
|
||||||
silentMode = sMode;
|
silentMode = sMode;
|
||||||
detIndex = modulePos;
|
|
||||||
numUnitsPerReadout = nUnitsPerReadout;
|
|
||||||
udpPortNumber = uPortNumber;
|
udpPortNumber = uPortNumber;
|
||||||
|
|
||||||
switch (dynamicRange) {
|
switch (dynamicRange) {
|
||||||
@ -138,8 +134,7 @@ void HDF5DataFile::CreateFile() {
|
|||||||
numFilesInAcquisition++;
|
numFilesInAcquisition++;
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << filePath << "/" << fileNamePrefix << "_d"
|
os << fileNamePrefix << "_f" << subFileIndex
|
||||||
<< (detIndex * numUnitsPerReadout + index) << "_f" << subFileIndex
|
|
||||||
<< '_' << fileIndex << ".h5";
|
<< '_' << fileIndex << ".h5";
|
||||||
fileName = os.str();
|
fileName = os.str();
|
||||||
|
|
||||||
|
@ -24,10 +24,9 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
|||||||
void CloseFile() override;
|
void CloseFile() override;
|
||||||
|
|
||||||
void CreateFirstHDF5DataFile(
|
void CreateFirstHDF5DataFile(
|
||||||
const std::string fPath, const std::string fNamePrefix,
|
const std::string& fNamePrefix,
|
||||||
const uint64_t fIndex, const bool owEnable,
|
const uint64_t fIndex, const bool owEnable,
|
||||||
const bool sMode, const int modulePos,
|
const bool sMode, const uint32_t uPortNumber,
|
||||||
const int nUnitsPerReadout, const uint32_t uPortNumber,
|
|
||||||
const uint32_t mFramesPerFile, const uint64_t nImages,
|
const uint32_t mFramesPerFile, const uint64_t nImages,
|
||||||
const uint32_t nX, const uint32_t nY,
|
const uint32_t nX, const uint32_t nY,
|
||||||
const uint32_t dr) override;
|
const uint32_t dr) override;
|
||||||
@ -65,13 +64,10 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
|||||||
uint32_t nPixelsY{0};
|
uint32_t nPixelsY{0};
|
||||||
uint32_t dynamicRange{0};
|
uint32_t dynamicRange{0};
|
||||||
|
|
||||||
std::string filePath;
|
|
||||||
std::string fileNamePrefix;
|
std::string fileNamePrefix;
|
||||||
uint64_t fileIndex{0};
|
uint64_t fileIndex{0};
|
||||||
bool overWriteEnable{false};
|
bool overWriteEnable{false};
|
||||||
bool silentMode{false};
|
bool silentMode{false};
|
||||||
int detIndex{0};
|
|
||||||
int numUnitsPerReadout{0};
|
|
||||||
uint32_t udpPortNumber{0};
|
uint32_t udpPortNumber{0};
|
||||||
|
|
||||||
static const int EIGER_NUM_PIXELS{256 * 2 * 256};
|
static const int EIGER_NUM_PIXELS{256 * 2 * 256};
|
||||||
|
@ -66,20 +66,20 @@ void Implementation::SetThreadPriorities() {
|
|||||||
|
|
||||||
void Implementation::SetupFifoStructure() {
|
void Implementation::SetupFifoStructure() {
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
for (int i = 0; i < numUDPInterfaces; ++i) {
|
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||||
size_t datasize = generalData->imageSize;
|
size_t datasize = generalData->imageSize;
|
||||||
// veto data size
|
// veto data size
|
||||||
if (detType == GOTTHARD2 && i != 0) {
|
if (generalData->detType == GOTTHARD2 && i != 0) {
|
||||||
datasize = generalData->vetoImageSize;
|
datasize = generalData->vetoImageSize;
|
||||||
}
|
}
|
||||||
datasize += IMAGE_STRUCTURE_HEADER_SIZE;
|
datasize += IMAGE_STRUCTURE_HEADER_SIZE;
|
||||||
|
|
||||||
// create fifo structure
|
// create fifo structure
|
||||||
try {
|
try {
|
||||||
fifo.push_back(sls::make_unique<Fifo>(i, datasize, fifoDepth));
|
fifo.push_back(sls::make_unique<Fifo>(i, datasize, generalData->fifoDepth));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
fifoDepth = 0;
|
generalData->fifoDepth = 0;
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not allocate memory for fifo structure " +
|
"Could not allocate memory for fifo structure " +
|
||||||
std::to_string(i) + ". FifoDepth is now 0.");
|
std::to_string(i) + ". FifoDepth is now 0.");
|
||||||
@ -93,11 +93,11 @@ void Implementation::SetupFifoStructure() {
|
|||||||
dataStreamer[i]->SetFifo(fifo[i].get());
|
dataStreamer[i]->SetFifo(fifo[i].get());
|
||||||
|
|
||||||
LOG(logINFO) << "Memory Allocated for Fifo " << i << ": "
|
LOG(logINFO) << "Memory Allocated for Fifo " << i << ": "
|
||||||
<< (double)(datasize * (size_t)fifoDepth) /
|
<< (double)(datasize * (size_t)generalData->fifoDepth) /
|
||||||
(double)(1024 * 1024)
|
(double)(1024 * 1024)
|
||||||
<< " MB";
|
<< " MB";
|
||||||
}
|
}
|
||||||
LOG(logINFO) << numUDPInterfaces << " Fifo structure(s) reconstructed";
|
LOG(logINFO) << generalData->numUDPInterfaces << " Fifo structure(s) reconstructed";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
@ -108,8 +108,7 @@ void Implementation::SetupFifoStructure() {
|
|||||||
|
|
||||||
void Implementation::setDetectorType(const detectorType d) {
|
void Implementation::setDetectorType(const detectorType d) {
|
||||||
|
|
||||||
detType = d;
|
switch (d) {
|
||||||
switch (detType) {
|
|
||||||
case GOTTHARD:
|
case GOTTHARD:
|
||||||
case EIGER:
|
case EIGER:
|
||||||
case JUNGFRAU:
|
case JUNGFRAU:
|
||||||
@ -128,7 +127,7 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
generalData = nullptr;
|
generalData = nullptr;
|
||||||
|
|
||||||
// set detector specific variables
|
// set detector specific variables
|
||||||
switch (detType) {
|
switch (d) {
|
||||||
case GOTTHARD:
|
case GOTTHARD:
|
||||||
generalData = new GotthardData();
|
generalData = new GotthardData();
|
||||||
break;
|
break;
|
||||||
@ -154,40 +153,18 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
framesPerFile = generalData->maxFramesPerFile;
|
|
||||||
fifoDepth = generalData->defaultFifoDepth;
|
|
||||||
numUDPInterfaces = generalData->numUDPInterfaces;
|
|
||||||
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
|
||||||
dynamicRange = generalData->dynamicRange;
|
|
||||||
tengigaEnable = generalData->tengigaEnable;
|
|
||||||
numberOfAnalogSamples = generalData->nAnalogSamples;
|
|
||||||
numberOfDigitalSamples = generalData->nDigitalSamples;
|
|
||||||
readoutType = generalData->readoutType;
|
|
||||||
adcEnableMaskOneGiga = generalData->adcEnableMaskOneGiga;
|
|
||||||
adcEnableMaskTenGiga = generalData->adcEnableMaskTenGiga;
|
|
||||||
detectorRoi = generalData->roi;
|
|
||||||
counterMask = generalData->counterMask;
|
|
||||||
|
|
||||||
SetLocalNetworkParameters();
|
SetLocalNetworkParameters();
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
|
|
||||||
// create threads
|
// create threads
|
||||||
for (int i = 0; i < numUDPInterfaces; ++i) {
|
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto fifo_ptr = fifo[i].get();
|
|
||||||
listener.push_back(sls::make_unique<Listener>(
|
listener.push_back(sls::make_unique<Listener>(
|
||||||
i, fifo_ptr, &status, &udpPortNum[i], ð[i],
|
i, &status));
|
||||||
&udpSocketBufferSize, &actualUDPSocketBufferSize,
|
SetupListener(i);
|
||||||
&framesPerFile, &frameDiscardMode, &silentMode));
|
dataProcessor.push_back(sls::make_unique<DataProcessor>(i));
|
||||||
int ctbAnalogDataBytes = 0;
|
SetupDataProcessor(i);
|
||||||
if (detType == CHIPTESTBOARD) {
|
|
||||||
ctbAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
|
|
||||||
}
|
|
||||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(
|
|
||||||
i, detType, fifo_ptr, &dataStreamEnable, &streamingFrequency,
|
|
||||||
&streamingTimerInMs, &streamingStartFnum, &framePadding,
|
|
||||||
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
listener.clear();
|
listener.clear();
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
@ -197,31 +174,59 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up writer and callbacks
|
|
||||||
for (int i = 0; i != (int)listener.size(); ++i) {
|
|
||||||
listener[i]->SetGeneralData(generalData);
|
|
||||||
listener[i]->SetActivate(activated);
|
|
||||||
listener[i]->SetDetectorDatastream(detectorDataStream[i]);
|
|
||||||
}
|
|
||||||
for (const auto &it : dataProcessor) {
|
|
||||||
it->SetGeneralData(generalData);
|
|
||||||
it->SetActivate(activated);
|
|
||||||
}
|
|
||||||
SetThreadPriorities();
|
SetThreadPriorities();
|
||||||
|
|
||||||
LOG(logDEBUG) << " Detector type set to " << ToString(d);
|
LOG(logDEBUG) << " Detector type set to " << ToString(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Implementation::SetupListener(int i) {
|
||||||
|
listener[i]->SetFifo(fifo[i].get());
|
||||||
|
listener[i]->SetGeneralData(generalData);
|
||||||
|
listener[i]->SetUdpPortNumber(udpPortNum[i]);
|
||||||
|
listener[i]->SetEthernetInterface(eth[i]);
|
||||||
|
listener[i]->SetActivate(activated);
|
||||||
|
listener[i]->SetNoRoi(portRois[i].noRoi());
|
||||||
|
listener[i]->SetDetectorDatastream(detectorDataStream[i]);
|
||||||
|
listener[i]->SetFrameDiscardPolicy(frameDiscardMode);
|
||||||
|
listener[i]->SetSilentMode(silentMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Implementation::SetupDataProcessor(int i) {
|
||||||
|
dataProcessor[i]->SetFifo(fifo[i].get());
|
||||||
|
dataProcessor[i]->SetGeneralData(generalData);
|
||||||
|
dataProcessor[i]->SetActivate(activated);
|
||||||
|
dataProcessor[i]->SetReceiverROI(portRois[i]);
|
||||||
|
dataProcessor[i]->SetDataStreamEnable(dataStreamEnable);
|
||||||
|
dataProcessor[i]->SetStreamingFrequency(streamingFrequency);
|
||||||
|
dataProcessor[i]->SetStreamingTimerInMs(streamingTimerInMs);
|
||||||
|
dataProcessor[i]->SetStreamingStartFnum(streamingStartFnum);
|
||||||
|
dataProcessor[i]->SetFramePadding(framePadding);
|
||||||
|
dataProcessor[i]->SetCtbDbitList(ctbDbitList);
|
||||||
|
dataProcessor[i]->SetCtbDbitOffset(ctbDbitOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Implementation::SetupDataStreamer(int i) {
|
||||||
|
dataStreamer[i]->SetFifo(fifo[i].get());
|
||||||
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
|
dataStreamer[i]->CreateZmqSockets(streamingPort, streamingSrcIP, streamingHwm);
|
||||||
|
dataStreamer[i]->SetAdditionalJsonHeader(additionalJsonHeader);
|
||||||
|
dataStreamer[i]->SetFileIndex(fileIndex);
|
||||||
|
dataStreamer[i]->SetFlipRows(flipRows);
|
||||||
|
dataStreamer[i]->SetNumberofPorts(numPorts);
|
||||||
|
dataStreamer[i]->SetQuadEnable(quadEnable);
|
||||||
|
dataStreamer[i]->SetNumberofTotalFrames(numberOfTotalFrames);
|
||||||
|
}
|
||||||
|
|
||||||
slsDetectorDefs::xy Implementation::getDetectorSize() const {
|
slsDetectorDefs::xy Implementation::getDetectorSize() const {
|
||||||
return numModules;
|
return numModules;
|
||||||
}
|
}
|
||||||
|
|
||||||
const slsDetectorDefs::xy Implementation::GetPortGeometry() const {
|
const slsDetectorDefs::xy Implementation::GetPortGeometry() const {
|
||||||
xy portGeometry{1, 1};
|
xy portGeometry{1, 1};
|
||||||
if (detType == EIGER)
|
if (generalData->detType == EIGER)
|
||||||
portGeometry.x = numUDPInterfaces;
|
portGeometry.x = generalData->numUDPInterfaces;
|
||||||
else if (detType == JUNGFRAU)
|
else if (generalData->detType == JUNGFRAU)
|
||||||
portGeometry.y = numUDPInterfaces;
|
portGeometry.y = generalData->numUDPInterfaces;
|
||||||
return portGeometry;
|
return portGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,14 +288,16 @@ bool Implementation::getSilentMode() const { return silentMode; }
|
|||||||
|
|
||||||
void Implementation::setSilentMode(const bool i) {
|
void Implementation::setSilentMode(const bool i) {
|
||||||
silentMode = i;
|
silentMode = i;
|
||||||
|
for (const auto &it : listener)
|
||||||
|
it->SetSilentMode(silentMode);
|
||||||
LOG(logINFO) << "Silent Mode: " << i;
|
LOG(logINFO) << "Silent Mode: " << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getFifoDepth() const { return fifoDepth; }
|
uint32_t Implementation::getFifoDepth() const { return generalData->fifoDepth; }
|
||||||
|
|
||||||
void Implementation::setFifoDepth(const uint32_t i) {
|
void Implementation::setFifoDepth(const uint32_t i) {
|
||||||
if (fifoDepth != i) {
|
if (generalData->fifoDepth != i) {
|
||||||
fifoDepth = i;
|
generalData->fifoDepth = i;
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Fifo Depth: " << i;
|
LOG(logINFO) << "Fifo Depth: " << i;
|
||||||
@ -303,6 +310,8 @@ Implementation::getFrameDiscardPolicy() const {
|
|||||||
|
|
||||||
void Implementation::setFrameDiscardPolicy(const frameDiscardPolicy i) {
|
void Implementation::setFrameDiscardPolicy(const frameDiscardPolicy i) {
|
||||||
frameDiscardMode = i;
|
frameDiscardMode = i;
|
||||||
|
for (const auto &it : listener)
|
||||||
|
it->SetFrameDiscardPolicy(frameDiscardMode);
|
||||||
LOG(logINFO) << "Frame Discard Policy: " << ToString(frameDiscardMode);
|
LOG(logINFO) << "Frame Discard Policy: " << ToString(frameDiscardMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,6 +319,8 @@ bool Implementation::getFramePaddingEnable() const { return framePadding; }
|
|||||||
|
|
||||||
void Implementation::setFramePaddingEnable(const bool i) {
|
void Implementation::setFramePaddingEnable(const bool i) {
|
||||||
framePadding = i;
|
framePadding = i;
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetFramePadding(framePadding);
|
||||||
LOG(logINFO) << "Frame Padding: " << framePadding;
|
LOG(logINFO) << "Frame Padding: " << framePadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +341,7 @@ std::array<pid_t, NUM_RX_THREAD_IDS> Implementation::getThreadIds() const {
|
|||||||
} else {
|
} else {
|
||||||
retval[id++] = 0;
|
retval[id++] = 0;
|
||||||
}
|
}
|
||||||
if (numUDPInterfaces == 2) {
|
if (generalData->numUDPInterfaces == 2) {
|
||||||
retval[id++] = listener[1]->GetThreadId();
|
retval[id++] = listener[1]->GetThreadId();
|
||||||
retval[id++] = dataProcessor[1]->GetThreadId();
|
retval[id++] = dataProcessor[1]->GetThreadId();
|
||||||
if (dataStreamEnable) {
|
if (dataStreamEnable) {
|
||||||
@ -354,9 +365,9 @@ void Implementation::setArping(const bool i,
|
|||||||
arping.StopThread();
|
arping.StopThread();
|
||||||
} else {
|
} else {
|
||||||
// setup interface
|
// setup interface
|
||||||
for (int i = 0; i != numUDPInterfaces; ++i) {
|
for (int i = 0; i != generalData->numUDPInterfaces; ++i) {
|
||||||
// ignore eiger with 2 interfaces (only udp port)
|
// ignore eiger with 2 interfaces (only udp port)
|
||||||
if (i == 1 && (numUDPInterfaces == 1 || detType == EIGER)) {
|
if (i == 1 && (generalData->numUDPInterfaces == 1 || generalData->detType == EIGER)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
arping.SetInterfacesAndIps(i, eth[i], ips[i]);
|
arping.SetInterfacesAndIps(i, eth[i], ips[i]);
|
||||||
@ -373,13 +384,13 @@ slsDetectorDefs::ROI Implementation::getReceiverROI() const {
|
|||||||
void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
|
void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
|
||||||
receiverRoi = arg;
|
receiverRoi = arg;
|
||||||
|
|
||||||
if (numUDPInterfaces == 1 || detType == slsDetectorDefs::GOTTHARD2) {
|
if (generalData->numUDPInterfaces == 1 || generalData->detType == slsDetectorDefs::GOTTHARD2) {
|
||||||
portRois[0] = arg;
|
portRois[0] = arg;
|
||||||
} else {
|
} else {
|
||||||
slsDetectorDefs::xy nPortDim(generalData->nPixelsX,
|
slsDetectorDefs::xy nPortDim(generalData->nPixelsX,
|
||||||
generalData->nPixelsY);
|
generalData->nPixelsY);
|
||||||
|
|
||||||
for (int iPort = 0; iPort != numUDPInterfaces; ++iPort) {
|
for (int iPort = 0; iPort != generalData->numUDPInterfaces; ++iPort) {
|
||||||
// default init = complete roi
|
// default init = complete roi
|
||||||
slsDetectorDefs::ROI portRoi{};
|
slsDetectorDefs::ROI portRoi{};
|
||||||
|
|
||||||
@ -443,7 +454,7 @@ void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
|
|||||||
for (size_t i = 0; i != dataProcessor.size(); ++i)
|
for (size_t i = 0; i != dataProcessor.size(); ++i)
|
||||||
dataProcessor[i]->SetReceiverROI(portRois[i]);
|
dataProcessor[i]->SetReceiverROI(portRois[i]);
|
||||||
LOG(logINFO) << "receiver roi: " << ToString(receiverRoi);
|
LOG(logINFO) << "receiver roi: " << ToString(receiverRoi);
|
||||||
if (numUDPInterfaces == 2 && detType != slsDetectorDefs::GOTTHARD2) {
|
if (generalData->numUDPInterfaces == 2 && generalData->detType != slsDetectorDefs::GOTTHARD2) {
|
||||||
LOG(logINFO) << "port rois: " << ToString(portRois);
|
LOG(logINFO) << "port rois: " << ToString(portRois);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,6 +515,8 @@ uint64_t Implementation::getFileIndex() const { return fileIndex; }
|
|||||||
|
|
||||||
void Implementation::setFileIndex(const uint64_t i) {
|
void Implementation::setFileIndex(const uint64_t i) {
|
||||||
fileIndex = i;
|
fileIndex = i;
|
||||||
|
for (const auto &it : dataStreamer)
|
||||||
|
it->SetFileIndex(fileIndex);
|
||||||
LOG(logINFO) << "File Index: " << fileIndex;
|
LOG(logINFO) << "File Index: " << fileIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,11 +552,11 @@ void Implementation::setOverwriteEnable(const bool b) {
|
|||||||
<< (overwriteEnable ? "enabled" : "disabled");
|
<< (overwriteEnable ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getFramesPerFile() const { return framesPerFile; }
|
uint32_t Implementation::getFramesPerFile() const { return generalData->framesPerFile; }
|
||||||
|
|
||||||
void Implementation::setFramesPerFile(const uint32_t i) {
|
void Implementation::setFramesPerFile(const uint32_t i) {
|
||||||
framesPerFile = i;
|
generalData->framesPerFile = i;
|
||||||
LOG(logINFO) << "Frames per file: " << framesPerFile;
|
LOG(logINFO) << "Frames per file: " << generalData->framesPerFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
@ -554,7 +567,7 @@ void Implementation::setFramesPerFile(const uint32_t i) {
|
|||||||
slsDetectorDefs::runStatus Implementation::getStatus() const { return status; }
|
slsDetectorDefs::runStatus Implementation::getStatus() const { return status; }
|
||||||
|
|
||||||
std::vector<int64_t> Implementation::getFramesCaught() const {
|
std::vector<int64_t> Implementation::getFramesCaught() const {
|
||||||
std::vector<int64_t> numFramesCaught(numUDPInterfaces);
|
std::vector<int64_t> numFramesCaught(generalData->numUDPInterfaces);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (const auto &it : listener) {
|
for (const auto &it : listener) {
|
||||||
if (it->GetStartedFlag()) {
|
if (it->GetStartedFlag()) {
|
||||||
@ -566,7 +579,7 @@ std::vector<int64_t> Implementation::getFramesCaught() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int64_t> Implementation::getCurrentFrameIndex() const {
|
std::vector<int64_t> Implementation::getCurrentFrameIndex() const {
|
||||||
std::vector<int64_t> frameIndex(numUDPInterfaces);
|
std::vector<int64_t> frameIndex(generalData->numUDPInterfaces);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (const auto &it : listener) {
|
for (const auto &it : listener) {
|
||||||
if (it->GetStartedFlag()) {
|
if (it->GetStartedFlag()) {
|
||||||
@ -611,8 +624,8 @@ double Implementation::getProgress() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int64_t> Implementation::getNumMissingPackets() const {
|
std::vector<int64_t> Implementation::getNumMissingPackets() const {
|
||||||
std::vector<int64_t> mp(numUDPInterfaces);
|
std::vector<int64_t> mp(generalData->numUDPInterfaces);
|
||||||
for (int i = 0; i < numUDPInterfaces; ++i) {
|
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||||
int np = generalData->packetsPerFrame;
|
int np = generalData->packetsPerFrame;
|
||||||
uint64_t totnp = np;
|
uint64_t totnp = np;
|
||||||
// ReadNRows
|
// ReadNRows
|
||||||
@ -716,7 +729,7 @@ void Implementation::stopReceiver() {
|
|||||||
auto mp = getNumMissingPackets();
|
auto mp = getNumMissingPackets();
|
||||||
// print summary
|
// print summary
|
||||||
uint64_t tot = 0;
|
uint64_t tot = 0;
|
||||||
for (int i = 0; i < numUDPInterfaces; i++) {
|
for (int i = 0; i < generalData->numUDPInterfaces; i++) {
|
||||||
int nf = listener[i]->GetNumCompleteFramesCaught();
|
int nf = listener[i]->GetNumCompleteFramesCaught();
|
||||||
tot += nf;
|
tot += nf;
|
||||||
std::string mpMessage = std::to_string(mp[i]);
|
std::string mpMessage = std::to_string(mp[i]);
|
||||||
@ -750,7 +763,7 @@ void Implementation::stopReceiver() {
|
|||||||
// callback
|
// callback
|
||||||
if (acquisitionFinishedCallBack) {
|
if (acquisitionFinishedCallBack) {
|
||||||
try {
|
try {
|
||||||
acquisitionFinishedCallBack((tot / numUDPInterfaces),
|
acquisitionFinishedCallBack((tot / generalData->numUDPInterfaces),
|
||||||
pAcquisitionFinished);
|
pAcquisitionFinished);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
// change status
|
// change status
|
||||||
@ -836,7 +849,7 @@ void Implementation::ResetParametersforNewAcquisition() {
|
|||||||
void Implementation::CreateUDPSockets() {
|
void Implementation::CreateUDPSockets() {
|
||||||
try {
|
try {
|
||||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||||
listener[i]->CreateUDPSockets();
|
listener[i]->CreateUDPSocket(actualUDPSocketBufferSize);
|
||||||
}
|
}
|
||||||
} catch (const RuntimeError &e) {
|
} catch (const RuntimeError &e) {
|
||||||
shutDownUDPSockets();
|
shutDownUDPSockets();
|
||||||
@ -848,10 +861,12 @@ void Implementation::CreateUDPSockets() {
|
|||||||
void Implementation::SetupWriter() {
|
void Implementation::SetupWriter() {
|
||||||
try {
|
try {
|
||||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << filePath << "/" << fileName << "_d" << (modulePos * generalData->numUDPInterfaces + i);
|
||||||
|
std::string fileNamePrefix = os.str();
|
||||||
dataProcessor[i]->CreateFirstFiles(
|
dataProcessor[i]->CreateFirstFiles(
|
||||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
fileNamePrefix, fileIndex, overwriteEnable, silentMode,
|
||||||
modulePos, numUDPInterfaces, udpPortNum[i], framesPerFile,
|
udpPortNum[i], numberOfTotalFrames, detectorDataStream[i]);
|
||||||
numberOfTotalFrames, dynamicRange, detectorDataStream[i]);
|
|
||||||
}
|
}
|
||||||
} catch (const RuntimeError &e) {
|
} catch (const RuntimeError &e) {
|
||||||
shutDownUDPSockets();
|
shutDownUDPSockets();
|
||||||
@ -867,13 +882,13 @@ void Implementation::StartMasterWriter() {
|
|||||||
// master file
|
// master file
|
||||||
if (masterFileWriteEnable) {
|
if (masterFileWriteEnable) {
|
||||||
MasterAttributes masterAttributes;
|
MasterAttributes masterAttributes;
|
||||||
masterAttributes.detType = detType;
|
masterAttributes.detType = generalData->detType;
|
||||||
masterAttributes.timingMode = timingMode;
|
masterAttributes.timingMode = timingMode;
|
||||||
masterAttributes.geometry = numPorts;
|
masterAttributes.geometry = numPorts;
|
||||||
masterAttributes.imageSize = generalData->imageSize;
|
masterAttributes.imageSize = generalData->imageSize;
|
||||||
masterAttributes.nPixels =
|
masterAttributes.nPixels =
|
||||||
xy(generalData->nPixelsX, generalData->nPixelsY);
|
xy(generalData->nPixelsX, generalData->nPixelsY);
|
||||||
masterAttributes.maxFramesPerFile = framesPerFile;
|
masterAttributes.maxFramesPerFile = generalData->framesPerFile;
|
||||||
masterAttributes.frameDiscardMode = frameDiscardMode;
|
masterAttributes.frameDiscardMode = frameDiscardMode;
|
||||||
masterAttributes.framePadding = framePadding;
|
masterAttributes.framePadding = framePadding;
|
||||||
masterAttributes.scanParams = scanParams;
|
masterAttributes.scanParams = scanParams;
|
||||||
@ -883,9 +898,9 @@ void Implementation::StartMasterWriter() {
|
|||||||
masterAttributes.exptime = acquisitionTime;
|
masterAttributes.exptime = acquisitionTime;
|
||||||
masterAttributes.period = acquisitionPeriod;
|
masterAttributes.period = acquisitionPeriod;
|
||||||
masterAttributes.burstMode = burstMode;
|
masterAttributes.burstMode = burstMode;
|
||||||
masterAttributes.numUDPInterfaces = numUDPInterfaces;
|
masterAttributes.numUDPInterfaces = generalData->numUDPInterfaces;
|
||||||
masterAttributes.dynamicRange = dynamicRange;
|
masterAttributes.dynamicRange = generalData->dynamicRange;
|
||||||
masterAttributes.tenGiga = tengigaEnable;
|
masterAttributes.tenGiga = generalData->tengigaEnable;
|
||||||
masterAttributes.thresholdEnergyeV = thresholdEnergyeV;
|
masterAttributes.thresholdEnergyeV = thresholdEnergyeV;
|
||||||
masterAttributes.thresholdAllEnergyeV = thresholdAllEnergyeV;
|
masterAttributes.thresholdAllEnergyeV = thresholdAllEnergyeV;
|
||||||
masterAttributes.subExptime = subExpTime;
|
masterAttributes.subExptime = subExpTime;
|
||||||
@ -894,24 +909,24 @@ void Implementation::StartMasterWriter() {
|
|||||||
masterAttributes.readNRows = readNRows;
|
masterAttributes.readNRows = readNRows;
|
||||||
masterAttributes.ratecorr = rateCorrections;
|
masterAttributes.ratecorr = rateCorrections;
|
||||||
masterAttributes.adcmask =
|
masterAttributes.adcmask =
|
||||||
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
|
generalData->tengigaEnable ? generalData->adcEnableMaskTenGiga : generalData->adcEnableMaskOneGiga;
|
||||||
masterAttributes.analog = (readoutType == ANALOG_ONLY ||
|
masterAttributes.analog = (generalData->readoutType == ANALOG_ONLY ||
|
||||||
readoutType == ANALOG_AND_DIGITAL)
|
generalData->readoutType == ANALOG_AND_DIGITAL)
|
||||||
? 1
|
? 1
|
||||||
: 0;
|
: 0;
|
||||||
masterAttributes.analogSamples = numberOfAnalogSamples;
|
masterAttributes.analogSamples = generalData->nAnalogSamples;
|
||||||
masterAttributes.digital = (readoutType == DIGITAL_ONLY ||
|
masterAttributes.digital = (generalData->readoutType == DIGITAL_ONLY ||
|
||||||
readoutType == ANALOG_AND_DIGITAL)
|
generalData->readoutType == ANALOG_AND_DIGITAL)
|
||||||
? 1
|
? 1
|
||||||
: 0;
|
: 0;
|
||||||
masterAttributes.digitalSamples = numberOfDigitalSamples;
|
masterAttributes.digitalSamples = generalData->nDigitalSamples;
|
||||||
masterAttributes.dbitoffset = ctbDbitOffset;
|
masterAttributes.dbitoffset = ctbDbitOffset;
|
||||||
masterAttributes.dbitlist = 0;
|
masterAttributes.dbitlist = 0;
|
||||||
for (auto &i : ctbDbitList) {
|
for (auto &i : ctbDbitList) {
|
||||||
masterAttributes.dbitlist |= (1 << i);
|
masterAttributes.dbitlist |= (1 << i);
|
||||||
}
|
}
|
||||||
masterAttributes.detectorRoi = detectorRoi;
|
masterAttributes.detectorRoi = generalData->detectorRoi;
|
||||||
masterAttributes.counterMask = counterMask;
|
masterAttributes.counterMask = generalData->counterMask;
|
||||||
masterAttributes.exptimeArray[0] = acquisitionTime1;
|
masterAttributes.exptimeArray[0] = acquisitionTime1;
|
||||||
masterAttributes.exptimeArray[1] = acquisitionTime2;
|
masterAttributes.exptimeArray[1] = acquisitionTime2;
|
||||||
masterAttributes.exptimeArray[2] = acquisitionTime3;
|
masterAttributes.exptimeArray[2] = acquisitionTime3;
|
||||||
@ -935,9 +950,8 @@ void Implementation::StartMasterWriter() {
|
|||||||
virtualFileName =
|
virtualFileName =
|
||||||
dataProcessor[0]->CreateVirtualFile(
|
dataProcessor[0]->CreateVirtualFile(
|
||||||
filePath, fileName, fileIndex, overwriteEnable,
|
filePath, fileName, fileIndex, overwriteEnable,
|
||||||
silentMode, modulePos, numUDPInterfaces, framesPerFile,
|
silentMode, modulePos, numberOfTotalFrames, numPorts.x, numPorts.y,
|
||||||
numberOfTotalFrames, numPorts.x, numPorts.y,
|
&hdf5LibMutex);
|
||||||
dynamicRange, &hdf5LibMutex);
|
|
||||||
}
|
}
|
||||||
// link file in master
|
// link file in master
|
||||||
if (masterFileWriteEnable) {
|
if (masterFileWriteEnable) {
|
||||||
@ -976,17 +990,17 @@ void Implementation::StartRunning() {
|
|||||||
* *
|
* *
|
||||||
* ************************************************/
|
* ************************************************/
|
||||||
int Implementation::getNumberofUDPInterfaces() const {
|
int Implementation::getNumberofUDPInterfaces() const {
|
||||||
return numUDPInterfaces;
|
return generalData->numUDPInterfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not Eiger
|
// not Eiger
|
||||||
void Implementation::setNumberofUDPInterfaces(const int n) {
|
void Implementation::setNumberofUDPInterfaces(const int n) {
|
||||||
if (detType == EIGER) {
|
if (generalData->detType == EIGER) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Cannot set number of UDP interfaces for Eiger");
|
"Cannot set number of UDP interfaces for Eiger");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numUDPInterfaces != n) {
|
if (generalData->numUDPInterfaces != n) {
|
||||||
// clear all threads and fifos
|
// clear all threads and fifos
|
||||||
listener.clear();
|
listener.clear();
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
@ -995,41 +1009,22 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
|
|
||||||
// set local variables
|
// set local variables
|
||||||
generalData->SetNumberofInterfaces(n);
|
generalData->SetNumberofInterfaces(n);
|
||||||
numUDPInterfaces = n;
|
generalData->numUDPInterfaces = n;
|
||||||
|
|
||||||
// fifo
|
// fifo
|
||||||
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
|
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
// recalculate port rois
|
// recalculate port rois
|
||||||
setReceiverROI(receiverRoi);
|
setReceiverROI(receiverRoi);
|
||||||
|
|
||||||
// create threads
|
// create threads
|
||||||
for (int i = 0; i < numUDPInterfaces; ++i) {
|
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||||
// listener and dataprocessor threads
|
// listener and dataprocessor threads
|
||||||
try {
|
try {
|
||||||
auto fifo_ptr = fifo[i].get();
|
|
||||||
listener.push_back(sls::make_unique<Listener>(
|
listener.push_back(sls::make_unique<Listener>(
|
||||||
i, fifo_ptr, &status, &udpPortNum[i], ð[i],
|
i, &status));
|
||||||
&udpSocketBufferSize, &actualUDPSocketBufferSize,
|
SetupListener(i);
|
||||||
&framesPerFile, &frameDiscardMode, &silentMode));
|
dataProcessor.push_back(sls::make_unique<DataProcessor>(i));
|
||||||
listener[i]->SetGeneralData(generalData);
|
SetupDataProcessor(i);
|
||||||
listener[i]->SetActivate(activated);
|
|
||||||
listener[i]->SetNoRoi(portRois[i].noRoi());
|
|
||||||
listener[i]->SetDetectorDatastream(detectorDataStream[i]);
|
|
||||||
|
|
||||||
int ctbAnalogDataBytes = 0;
|
|
||||||
if (detType == CHIPTESTBOARD) {
|
|
||||||
ctbAnalogDataBytes =
|
|
||||||
generalData->GetNumberOfAnalogDatabytes();
|
|
||||||
}
|
|
||||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(
|
|
||||||
i, detType, fifo_ptr, &dataStreamEnable,
|
|
||||||
&streamingFrequency, &streamingTimerInMs,
|
|
||||||
&streamingStartFnum, &framePadding, &ctbDbitList,
|
|
||||||
&ctbDbitOffset, &ctbAnalogDataBytes));
|
|
||||||
dataProcessor[i]->SetGeneralData(generalData);
|
|
||||||
dataProcessor[i]->SetActivate(activated);
|
|
||||||
dataProcessor[i]->SetReceiverROI(portRois[i]);
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
listener.clear();
|
listener.clear();
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
@ -1037,27 +1032,18 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
"Could not create listener/dataprocessor threads (index:" +
|
"Could not create listener/dataprocessor threads (index:" +
|
||||||
std::to_string(i) + ")");
|
std::to_string(i) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
// streamer threads
|
// streamer threads
|
||||||
if (dataStreamEnable) {
|
if (dataStreamEnable) {
|
||||||
try {
|
try {
|
||||||
bool flip = flipRows;
|
dataStreamer.push_back(sls::make_unique<DataStreamer>(i));
|
||||||
if (quadEnable) {
|
SetupDataStreamer(i);
|
||||||
flip = (i == 1 ? true : false);
|
|
||||||
}
|
|
||||||
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
|
||||||
i, fifo[i].get(), &dynamicRange, &detectorRoi,
|
|
||||||
&fileIndex, flip, numPorts, &quadEnable,
|
|
||||||
&numberOfTotalFrames));
|
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
|
||||||
dataStreamer[i]->CreateZmqSockets(
|
|
||||||
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
|
||||||
streamingHwm);
|
|
||||||
dataStreamer[i]->SetAdditionalJsonHeader(
|
|
||||||
additionalJsonHeader);
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (dataStreamEnable) {
|
if (dataStreamEnable) {
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
dataStreamEnable = false;
|
dataStreamEnable = false;
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetDataStreamEnable(dataStreamEnable);
|
||||||
}
|
}
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not create datastreamer threads (index:" +
|
"Could not create datastreamer threads (index:" +
|
||||||
@ -1089,13 +1075,14 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
setUDPSocketBufferSize(0);
|
setUDPSocketBufferSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << "Number of Interfaces: " << numUDPInterfaces;
|
LOG(logINFO) << "Number of Interfaces: " << generalData->numUDPInterfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Implementation::getEthernetInterface() const { return eth[0]; }
|
std::string Implementation::getEthernetInterface() const { return eth[0]; }
|
||||||
|
|
||||||
void Implementation::setEthernetInterface(const std::string &c) {
|
void Implementation::setEthernetInterface(const std::string &c) {
|
||||||
eth[0] = c;
|
eth[0] = c;
|
||||||
|
listener[0]->SetEthernetInterface(c);
|
||||||
LOG(logINFO) << "Ethernet Interface: " << eth[0];
|
LOG(logINFO) << "Ethernet Interface: " << eth[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1103,6 +1090,9 @@ std::string Implementation::getEthernetInterface2() const { return eth[1]; }
|
|||||||
|
|
||||||
void Implementation::setEthernetInterface2(const std::string &c) {
|
void Implementation::setEthernetInterface2(const std::string &c) {
|
||||||
eth[1] = c;
|
eth[1] = c;
|
||||||
|
if (listener.size() > 1) {
|
||||||
|
listener[1]->SetEthernetInterface(c);
|
||||||
|
}
|
||||||
LOG(logINFO) << "Ethernet Interface 2: " << eth[1];
|
LOG(logINFO) << "Ethernet Interface 2: " << eth[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,6 +1100,7 @@ uint32_t Implementation::getUDPPortNumber() const { return udpPortNum[0]; }
|
|||||||
|
|
||||||
void Implementation::setUDPPortNumber(const uint32_t i) {
|
void Implementation::setUDPPortNumber(const uint32_t i) {
|
||||||
udpPortNum[0] = i;
|
udpPortNum[0] = i;
|
||||||
|
listener[0]->SetUdpPortNumber(i);
|
||||||
LOG(logINFO) << "UDP Port Number[0]: " << udpPortNum[0];
|
LOG(logINFO) << "UDP Port Number[0]: " << udpPortNum[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1117,32 +1108,27 @@ uint32_t Implementation::getUDPPortNumber2() const { return udpPortNum[1]; }
|
|||||||
|
|
||||||
void Implementation::setUDPPortNumber2(const uint32_t i) {
|
void Implementation::setUDPPortNumber2(const uint32_t i) {
|
||||||
udpPortNum[1] = i;
|
udpPortNum[1] = i;
|
||||||
|
if (listener.size() > 1) {
|
||||||
|
listener[1]->SetUdpPortNumber(i);
|
||||||
|
}
|
||||||
LOG(logINFO) << "UDP Port Number[1]: " << udpPortNum[1];
|
LOG(logINFO) << "UDP Port Number[1]: " << udpPortNum[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Implementation::getUDPSocketBufferSize() const {
|
int Implementation::getUDPSocketBufferSize() const {
|
||||||
return udpSocketBufferSize;
|
return generalData->udpSocketBufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setUDPSocketBufferSize(const int s) {
|
void Implementation::setUDPSocketBufferSize(const int s) {
|
||||||
// custom setup is not 0 (must complain if set up didnt work)
|
|
||||||
// testing default setup at startup, argument is 0 to use default values
|
|
||||||
int size = (s == 0) ? udpSocketBufferSize : s;
|
|
||||||
size_t listSize = listener.size();
|
size_t listSize = listener.size();
|
||||||
if ((detType == JUNGFRAU || detType == GOTTHARD2) &&
|
if ((generalData->detType == JUNGFRAU || generalData->detType == GOTTHARD2) &&
|
||||||
(int)listSize != numUDPInterfaces) {
|
(int)listSize != generalData->numUDPInterfaces) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Number of Interfaces " + std::to_string(numUDPInterfaces) +
|
"Number of Interfaces " + std::to_string(generalData->numUDPInterfaces) +
|
||||||
" do not match listener size " + std::to_string(listSize));
|
" do not match listener size " + std::to_string(listSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &l : listener) {
|
for (auto &l : listener) {
|
||||||
l->CreateDummySocketForUDPSocketBufferSize(size);
|
l->CreateDummySocketForUDPSocketBufferSize(s, actualUDPSocketBufferSize);
|
||||||
}
|
|
||||||
// custom and didnt set, throw error
|
|
||||||
if (s != 0 && udpSocketBufferSize != s) {
|
|
||||||
throw RuntimeError("Could not set udp socket buffer size. (No "
|
|
||||||
"CAP_NET_ADMIN privileges?)");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1165,31 +1151,23 @@ void Implementation::setDataStreamEnable(const bool enable) {
|
|||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
for (int i = 0; i < numUDPInterfaces; ++i) {
|
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||||
try {
|
try {
|
||||||
bool flip = flipRows;
|
dataStreamer.push_back(sls::make_unique<DataStreamer>(i));
|
||||||
if (quadEnable) {
|
SetupDataStreamer(i);
|
||||||
flip = (i == 1 ? true : false);
|
|
||||||
}
|
|
||||||
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
|
||||||
i, fifo[i].get(), &dynamicRange, &detectorRoi,
|
|
||||||
&fileIndex, flip, numPorts, &quadEnable,
|
|
||||||
&numberOfTotalFrames));
|
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
|
||||||
dataStreamer[i]->CreateZmqSockets(
|
|
||||||
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
|
||||||
streamingHwm);
|
|
||||||
dataStreamer[i]->SetAdditionalJsonHeader(
|
|
||||||
additionalJsonHeader);
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
dataStreamEnable = false;
|
dataStreamEnable = false;
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetDataStreamEnable(dataStreamEnable);
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not set data stream enable.");
|
"Could not set data stream enable.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetThreadPriorities();
|
SetThreadPriorities();
|
||||||
}
|
}
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetDataStreamEnable(dataStreamEnable);
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable;
|
LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable;
|
||||||
}
|
}
|
||||||
@ -1200,6 +1178,8 @@ uint32_t Implementation::getStreamingFrequency() const {
|
|||||||
|
|
||||||
void Implementation::setStreamingFrequency(const uint32_t freq) {
|
void Implementation::setStreamingFrequency(const uint32_t freq) {
|
||||||
streamingFrequency = freq;
|
streamingFrequency = freq;
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetStreamingFrequency(streamingFrequency);
|
||||||
LOG(logINFO) << "Streaming Frequency: " << streamingFrequency;
|
LOG(logINFO) << "Streaming Frequency: " << streamingFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1209,6 +1189,8 @@ uint32_t Implementation::getStreamingTimer() const {
|
|||||||
|
|
||||||
void Implementation::setStreamingTimer(const uint32_t time_in_ms) {
|
void Implementation::setStreamingTimer(const uint32_t time_in_ms) {
|
||||||
streamingTimerInMs = time_in_ms;
|
streamingTimerInMs = time_in_ms;
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetStreamingTimerInMs(streamingTimerInMs);
|
||||||
LOG(logINFO) << "Streamer Timer: " << streamingTimerInMs;
|
LOG(logINFO) << "Streamer Timer: " << streamingTimerInMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1218,6 +1200,8 @@ uint32_t Implementation::getStreamingStartingFrameNumber() const {
|
|||||||
|
|
||||||
void Implementation::setStreamingStartingFrameNumber(const uint32_t fnum) {
|
void Implementation::setStreamingStartingFrameNumber(const uint32_t fnum) {
|
||||||
streamingStartFnum = fnum;
|
streamingStartFnum = fnum;
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetStreamingStartFnum(streamingStartFnum);
|
||||||
LOG(logINFO) << "Streaming Start Frame num: " << streamingStartFnum;
|
LOG(logINFO) << "Streaming Start Frame num: " << streamingStartFnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1313,7 +1297,7 @@ void Implementation::updateTotalNumberOfFrames() {
|
|||||||
int64_t repeats = numberOfTriggers;
|
int64_t repeats = numberOfTriggers;
|
||||||
int64_t numFrames = numberOfFrames;
|
int64_t numFrames = numberOfFrames;
|
||||||
// gotthard2
|
// gotthard2
|
||||||
if (detType == GOTTHARD2) {
|
if (generalData->detType == GOTTHARD2) {
|
||||||
// auto
|
// auto
|
||||||
if (timingMode == AUTO_TIMING) {
|
if (timingMode == AUTO_TIMING) {
|
||||||
// burst mode, repeats = #bursts
|
// burst mode, repeats = #bursts
|
||||||
@ -1336,6 +1320,8 @@ void Implementation::updateTotalNumberOfFrames() {
|
|||||||
}
|
}
|
||||||
numberOfTotalFrames =
|
numberOfTotalFrames =
|
||||||
numFrames * repeats * (int64_t)(numberOfAdditionalStorageCells + 1);
|
numFrames * repeats * (int64_t)(numberOfAdditionalStorageCells + 1);
|
||||||
|
for (const auto &it : dataStreamer)
|
||||||
|
it->SetNumberofTotalFrames(numberOfTotalFrames);
|
||||||
if (numberOfTotalFrames == 0) {
|
if (numberOfTotalFrames == 0) {
|
||||||
throw RuntimeError("Invalid total number of frames to receive: 0");
|
throw RuntimeError("Invalid total number of frames to receive: 0");
|
||||||
}
|
}
|
||||||
@ -1475,91 +1461,77 @@ void Implementation::setSubPeriod(const ns i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getNumberofAnalogSamples() const {
|
uint32_t Implementation::getNumberofAnalogSamples() const {
|
||||||
return numberOfAnalogSamples;
|
return generalData->nAnalogSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setNumberofAnalogSamples(const uint32_t i) {
|
void Implementation::setNumberofAnalogSamples(const uint32_t i) {
|
||||||
if (numberOfAnalogSamples != i) {
|
if ( generalData->nAnalogSamples != i) {
|
||||||
numberOfAnalogSamples = i;
|
|
||||||
|
|
||||||
generalData->SetNumberOfAnalogSamples(i);
|
generalData->SetNumberOfAnalogSamples(i);
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Number of Analog Samples: " << numberOfAnalogSamples;
|
LOG(logINFO) << "Number of Analog Samples: " << generalData->nAnalogSamples;
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getNumberofDigitalSamples() const {
|
uint32_t Implementation::getNumberofDigitalSamples() const {
|
||||||
return numberOfDigitalSamples;
|
return generalData->nDigitalSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setNumberofDigitalSamples(const uint32_t i) {
|
void Implementation::setNumberofDigitalSamples(const uint32_t i) {
|
||||||
if (numberOfDigitalSamples != i) {
|
if ( generalData->nDigitalSamples != i) {
|
||||||
numberOfDigitalSamples = i;
|
|
||||||
|
|
||||||
generalData->SetNumberOfDigitalSamples(i);
|
generalData->SetNumberOfDigitalSamples(i);
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Number of Digital Samples: " << numberOfDigitalSamples;
|
LOG(logINFO) << "Number of Digital Samples: " << generalData->nDigitalSamples;
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getCounterMask() const { return counterMask; }
|
uint32_t Implementation::getCounterMask() const { return generalData->counterMask; }
|
||||||
|
|
||||||
void Implementation::setCounterMask(const uint32_t i) {
|
void Implementation::setCounterMask(const uint32_t i) {
|
||||||
if (counterMask != i) {
|
if (generalData->counterMask != i) {
|
||||||
generalData->SetCounterMask(i);
|
generalData->SetCounterMask(i);
|
||||||
counterMask = i;
|
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Counter mask: " << ToStringHex(counterMask);
|
LOG(logINFO) << "Counter mask: " << ToStringHex(generalData->counterMask);
|
||||||
int ncounters = __builtin_popcount(counterMask);
|
int ncounters = __builtin_popcount(generalData->counterMask);
|
||||||
LOG(logINFO) << "Number of counters: " << ncounters;
|
LOG(logINFO) << "Number of counters: " << ncounters;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getDynamicRange() const { return dynamicRange; }
|
uint32_t Implementation::getDynamicRange() const { return generalData->dynamicRange; }
|
||||||
|
|
||||||
void Implementation::setDynamicRange(const uint32_t i) {
|
void Implementation::setDynamicRange(const uint32_t i) {
|
||||||
if (dynamicRange != i) {
|
if (generalData->dynamicRange != i) {
|
||||||
dynamicRange = i;
|
if (generalData->detType == EIGER || generalData->detType == MYTHEN3) {
|
||||||
|
|
||||||
if (detType == EIGER || detType == MYTHEN3) {
|
|
||||||
generalData->SetDynamicRange(i);
|
generalData->SetDynamicRange(i);
|
||||||
fifoDepth = generalData->defaultFifoDepth;
|
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Dynamic Range: " << dynamicRange;
|
LOG(logINFO) << "Dynamic Range: " << generalData->dynamicRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
slsDetectorDefs::ROI Implementation::getROI() const { return detectorRoi; }
|
slsDetectorDefs::ROI Implementation::getROI() const { return generalData->detectorRoi; }
|
||||||
|
|
||||||
void Implementation::setDetectorROI(slsDetectorDefs::ROI arg) {
|
void Implementation::setDetectorROI(slsDetectorDefs::ROI arg) {
|
||||||
if (detectorRoi.xmin != arg.xmin || detectorRoi.xmax != arg.xmax) {
|
if (generalData->detectorRoi.xmin != arg.xmin || generalData->detectorRoi.xmax != arg.xmax) {
|
||||||
detectorRoi.xmin = arg.xmin;
|
|
||||||
detectorRoi.xmax = arg.xmax;
|
|
||||||
|
|
||||||
// only for gotthard
|
// only for gotthard
|
||||||
generalData->SetDetectorROI(arg);
|
generalData->SetDetectorROI(arg);
|
||||||
framesPerFile = generalData->maxFramesPerFile;
|
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << "Detector ROI: " << ToString(detectorRoi);
|
LOG(logINFO) << "Detector ROI: " << ToString(generalData->detectorRoi);
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Implementation::getTenGigaEnable() const { return tengigaEnable; }
|
bool Implementation::getTenGigaEnable() const { return generalData->tengigaEnable; }
|
||||||
|
|
||||||
void Implementation::setTenGigaEnable(const bool b) {
|
void Implementation::setTenGigaEnable(const bool b) {
|
||||||
if (tengigaEnable != b) {
|
if ( generalData->tengigaEnable != b) {
|
||||||
tengigaEnable = b;
|
|
||||||
|
|
||||||
generalData->SetTenGigaEnable(b);
|
generalData->SetTenGigaEnable(b);
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
|
|
||||||
// datastream can be disabled/enabled only for Eiger 10GbE
|
// datastream can be disabled/enabled only for Eiger 10GbE
|
||||||
if (detType == EIGER) {
|
if (generalData->detType == EIGER) {
|
||||||
if (!b) {
|
if (!b) {
|
||||||
detectorDataStream[LEFT] = 1;
|
detectorDataStream[LEFT] = 1;
|
||||||
detectorDataStream[RIGHT] = 1;
|
detectorDataStream[RIGHT] = 1;
|
||||||
@ -1573,7 +1545,7 @@ void Implementation::setTenGigaEnable(const bool b) {
|
|||||||
<< ToString(detectorDataStream[RIGHT]) << "]";
|
<< ToString(detectorDataStream[RIGHT]) << "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Ten Giga: " << (tengigaEnable ? "enabled" : "disabled");
|
LOG(logINFO) << "Ten Giga: " << ( generalData->tengigaEnable ? "enabled" : "disabled");
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1581,19 +1553,8 @@ bool Implementation::getFlipRows() const { return flipRows; }
|
|||||||
|
|
||||||
void Implementation::setFlipRows(bool enable) {
|
void Implementation::setFlipRows(bool enable) {
|
||||||
flipRows = enable;
|
flipRows = enable;
|
||||||
|
for (const auto &it : dataStreamer)
|
||||||
if (!quadEnable) {
|
|
||||||
for (const auto &it : dataStreamer) {
|
|
||||||
it->SetFlipRows(flipRows);
|
it->SetFlipRows(flipRows);
|
||||||
}
|
|
||||||
}
|
|
||||||
// quad
|
|
||||||
else {
|
|
||||||
if (dataStreamer.size() == 2) {
|
|
||||||
dataStreamer[0]->SetFlipRows(false);
|
|
||||||
dataStreamer[1]->SetFlipRows(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LOG(logINFO) << "Flip Rows: " << flipRows;
|
LOG(logINFO) << "Flip Rows: " << flipRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1603,16 +1564,10 @@ void Implementation::setQuad(const bool b) {
|
|||||||
if (quadEnable != b) {
|
if (quadEnable != b) {
|
||||||
quadEnable = b;
|
quadEnable = b;
|
||||||
setDetectorSize(numModules);
|
setDetectorSize(numModules);
|
||||||
if (!quadEnable) {
|
|
||||||
for (const auto &it : dataStreamer) {
|
for (const auto &it : dataStreamer) {
|
||||||
|
it->SetQuadEnable(quadEnable);
|
||||||
it->SetFlipRows(flipRows);
|
it->SetFlipRows(flipRows);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (dataStreamer.size() == 2) {
|
|
||||||
dataStreamer[0]->SetFlipRows(false);
|
|
||||||
dataStreamer[1]->SetFlipRows(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Quad Enable: " << quadEnable;
|
LOG(logINFO) << "Quad Enable: " << quadEnable;
|
||||||
}
|
}
|
||||||
@ -1641,7 +1596,7 @@ void Implementation::setDetectorDataStream(const portPosition port,
|
|||||||
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
|
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
|
||||||
<< " Port): " << ToString(detectorDataStream10GbE[index]);
|
<< " Port): " << ToString(detectorDataStream10GbE[index]);
|
||||||
// update datastream for 10g
|
// update datastream for 10g
|
||||||
if (tengigaEnable) {
|
if ( generalData->tengigaEnable) {
|
||||||
detectorDataStream[index] = detectorDataStream10GbE[index];
|
detectorDataStream[index] = detectorDataStream10GbE[index];
|
||||||
LOG(logDEBUG) << "Detector datastream updated ["
|
LOG(logDEBUG) << "Detector datastream updated ["
|
||||||
<< (index == 0 ? "Left" : "Right")
|
<< (index == 0 ? "Left" : "Right")
|
||||||
@ -1673,59 +1628,63 @@ void Implementation::setRateCorrections(const std::vector<int64_t> &t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
slsDetectorDefs::readoutMode Implementation::getReadoutMode() const {
|
slsDetectorDefs::readoutMode Implementation::getReadoutMode() const {
|
||||||
return readoutType;
|
return generalData->readoutType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setReadoutMode(const readoutMode f) {
|
void Implementation::setReadoutMode(const readoutMode f) {
|
||||||
if (readoutType != f) {
|
if (generalData->readoutType != f) {
|
||||||
readoutType = f;
|
|
||||||
|
|
||||||
generalData->SetReadoutMode(f);
|
generalData->SetReadoutMode(f);
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Readout Mode: " << ToString(f);
|
LOG(logINFO) << "Readout Mode: " << ToString(generalData->readoutType);
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getADCEnableMask() const {
|
uint32_t Implementation::getADCEnableMask() const {
|
||||||
return adcEnableMaskOneGiga;
|
return generalData->adcEnableMaskOneGiga;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setADCEnableMask(uint32_t mask) {
|
void Implementation::setADCEnableMask(uint32_t mask) {
|
||||||
if (adcEnableMaskOneGiga != mask) {
|
if (generalData->adcEnableMaskOneGiga != mask) {
|
||||||
adcEnableMaskOneGiga = mask;
|
|
||||||
|
|
||||||
generalData->SetOneGigaAdcEnableMask(mask);
|
generalData->SetOneGigaAdcEnableMask(mask);
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "ADC Enable Mask for 1Gb mode: 0x" << std::hex
|
LOG(logINFO) << "ADC Enable Mask for 1Gb mode: 0x" << std::hex
|
||||||
<< adcEnableMaskOneGiga << std::dec;
|
<< generalData->adcEnableMaskOneGiga << std::dec;
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getTenGigaADCEnableMask() const {
|
uint32_t Implementation::getTenGigaADCEnableMask() const {
|
||||||
return adcEnableMaskTenGiga;
|
return generalData->adcEnableMaskTenGiga;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setTenGigaADCEnableMask(uint32_t mask) {
|
void Implementation::setTenGigaADCEnableMask(uint32_t mask) {
|
||||||
if (adcEnableMaskTenGiga != mask) {
|
if (generalData->adcEnableMaskTenGiga != mask) {
|
||||||
adcEnableMaskTenGiga = mask;
|
|
||||||
|
|
||||||
generalData->SetTenGigaAdcEnableMask(mask);
|
generalData->SetTenGigaAdcEnableMask(mask);
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "ADC Enable Mask for 10Gb mode: 0x" << std::hex
|
LOG(logINFO) << "ADC Enable Mask for 10Gb mode: 0x" << std::hex
|
||||||
<< adcEnableMaskTenGiga << std::dec;
|
<< generalData->adcEnableMaskTenGiga << std::dec;
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> Implementation::getDbitList() const { return ctbDbitList; }
|
std::vector<int> Implementation::getDbitList() const { return ctbDbitList; }
|
||||||
|
|
||||||
void Implementation::setDbitList(const std::vector<int> &v) { ctbDbitList = v; }
|
void Implementation::setDbitList(const std::vector<int> &v) {
|
||||||
|
ctbDbitList = v;
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetCtbDbitList(ctbDbitList);
|
||||||
|
LOG(logINFO) << "Dbit list: " << ToString(ctbDbitList);
|
||||||
|
}
|
||||||
|
|
||||||
int Implementation::getDbitOffset() const { return ctbDbitOffset; }
|
int Implementation::getDbitOffset() const { return ctbDbitOffset; }
|
||||||
|
|
||||||
void Implementation::setDbitOffset(const int s) { ctbDbitOffset = s; }
|
void Implementation::setDbitOffset(const int s) {
|
||||||
|
ctbDbitOffset = s;
|
||||||
|
for (const auto &it : dataProcessor)
|
||||||
|
it->SetCtbDbitOffset(ctbDbitOffset);
|
||||||
|
LOG(logINFO) << "Dbit offset: " << ctbDbitOffset;
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -287,6 +287,9 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
void SetupWriter();
|
void SetupWriter();
|
||||||
void StartMasterWriter();
|
void StartMasterWriter();
|
||||||
void StartRunning();
|
void StartRunning();
|
||||||
|
void SetupListener(int i);
|
||||||
|
void SetupDataProcessor(int i);
|
||||||
|
void SetupDataStreamer(int i);
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
@ -295,13 +298,11 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
* ************************************************/
|
* ************************************************/
|
||||||
|
|
||||||
// config parameters
|
// config parameters
|
||||||
detectorType detType{GENERIC};
|
|
||||||
xy numModules{1, 1};
|
xy numModules{1, 1};
|
||||||
xy numPorts{1, 1};
|
xy numPorts{1, 1};
|
||||||
int modulePos{0};
|
int modulePos{0};
|
||||||
std::string detHostname;
|
std::string detHostname;
|
||||||
bool silentMode{false};
|
bool silentMode{false};
|
||||||
uint32_t fifoDepth{0};
|
|
||||||
frameDiscardPolicy frameDiscardMode{NO_DISCARD};
|
frameDiscardPolicy frameDiscardMode{NO_DISCARD};
|
||||||
bool framePadding{true};
|
bool framePadding{true};
|
||||||
pid_t parentThreadId;
|
pid_t parentThreadId;
|
||||||
@ -319,7 +320,6 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
bool fileWriteEnable{false};
|
bool fileWriteEnable{false};
|
||||||
bool masterFileWriteEnable{true};
|
bool masterFileWriteEnable{true};
|
||||||
bool overwriteEnable{true};
|
bool overwriteEnable{true};
|
||||||
uint32_t framesPerFile{0};
|
|
||||||
|
|
||||||
// acquisition
|
// acquisition
|
||||||
std::atomic<runStatus> status{IDLE};
|
std::atomic<runStatus> status{IDLE};
|
||||||
@ -327,11 +327,9 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
scanParameters scanParams{};
|
scanParameters scanParams{};
|
||||||
|
|
||||||
// network configuration (UDP)
|
// network configuration (UDP)
|
||||||
int numUDPInterfaces{1};
|
|
||||||
std::array<std::string, MAX_NUMBER_OF_LISTENING_THREADS> eth;
|
std::array<std::string, MAX_NUMBER_OF_LISTENING_THREADS> eth;
|
||||||
std::array<uint32_t, MAX_NUMBER_OF_LISTENING_THREADS> udpPortNum{
|
std::array<uint32_t, MAX_NUMBER_OF_LISTENING_THREADS> udpPortNum{
|
||||||
{DEFAULT_UDP_PORTNO, DEFAULT_UDP_PORTNO + 1}};
|
{DEFAULT_UDP_PORTNO, DEFAULT_UDP_PORTNO + 1}};
|
||||||
int udpSocketBufferSize{0};
|
|
||||||
int actualUDPSocketBufferSize{0};
|
int actualUDPSocketBufferSize{0};
|
||||||
|
|
||||||
// zmq parameters
|
// zmq parameters
|
||||||
@ -363,12 +361,6 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
ns gateDelay3 = std::chrono::nanoseconds(0);
|
ns gateDelay3 = std::chrono::nanoseconds(0);
|
||||||
ns subExpTime = std::chrono::nanoseconds(0);
|
ns subExpTime = std::chrono::nanoseconds(0);
|
||||||
ns subPeriod = std::chrono::nanoseconds(0);
|
ns subPeriod = std::chrono::nanoseconds(0);
|
||||||
uint32_t numberOfAnalogSamples{0};
|
|
||||||
uint32_t numberOfDigitalSamples{0};
|
|
||||||
uint32_t counterMask{0};
|
|
||||||
uint32_t dynamicRange{16};
|
|
||||||
ROI detectorRoi{};
|
|
||||||
bool tengigaEnable{false};
|
|
||||||
bool flipRows{false};
|
bool flipRows{false};
|
||||||
bool quadEnable{false};
|
bool quadEnable{false};
|
||||||
bool activated{true};
|
bool activated{true};
|
||||||
@ -379,9 +371,6 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
int thresholdEnergyeV{-1};
|
int thresholdEnergyeV{-1};
|
||||||
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
|
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
|
||||||
std::vector<int64_t> rateCorrections;
|
std::vector<int64_t> rateCorrections;
|
||||||
readoutMode readoutType{ANALOG_ONLY};
|
|
||||||
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
|
||||||
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
|
||||||
std::vector<int> ctbDbitList;
|
std::vector<int> ctbDbitList;
|
||||||
int ctbDbitOffset{0};
|
int ctbDbitOffset{0};
|
||||||
|
|
||||||
|
@ -24,9 +24,8 @@ namespace sls {
|
|||||||
|
|
||||||
const std::string Listener::TypeName = "Listener";
|
const std::string Listener::TypeName = "Listener";
|
||||||
|
|
||||||
Listener::Listener(int index, Fifo *fifo, std::atomic<runStatus> *status, uint32_t *udpPortNumber, std::string *eth, int *udpSocketBufferSize, int *actualUDPSocketBufferSize, uint32_t *framesPerFile, frameDiscardPolicy *frameDiscardMode, bool *silentMode)
|
Listener::Listener(int index, std::atomic<runStatus> *status)
|
||||||
: ThreadObject(index, TypeName), fifo(fifo), status(status),
|
: ThreadObject(index, TypeName), status(status) {
|
||||||
udpPortNumber(udpPortNumber), eth(eth), udpSocketBufferSize(udpSocketBufferSize), actualUDPSocketBufferSize(actualUDPSocketBufferSize), framesPerFile(framesPerFile), frameDiscardMode(frameDiscardMode), silentMode(silentMode) {
|
|
||||||
LOG(logDEBUG) << "Listener " << index << " created";
|
LOG(logDEBUG) << "Listener " << index << " created";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +71,47 @@ uint64_t Listener::GetListenedIndex() const {
|
|||||||
|
|
||||||
void Listener::SetFifo(Fifo *f) { fifo = f; }
|
void Listener::SetFifo(Fifo *f) { fifo = f; }
|
||||||
|
|
||||||
|
void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||||
|
|
||||||
|
void Listener::SetUdpPortNumber(const uint32_t portNumber) {
|
||||||
|
udpPortNumber = portNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetEthernetInterface(const std::string e) {
|
||||||
|
eth = e;
|
||||||
|
// if eth is mistaken with ip address
|
||||||
|
if (eth.find('.') != std::string::npos) {
|
||||||
|
eth = "";
|
||||||
|
}
|
||||||
|
if (!eth.length()) {
|
||||||
|
LOG(logWARNING) << "ethernet interface for udp port " << udpPortNumber << " is empty. Listening to all";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetActivate(bool enable) {
|
||||||
|
activated = enable;
|
||||||
|
disabledPort = (!activated || !detectorDataStream || noRoi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetDetectorDatastream(bool enable) {
|
||||||
|
detectorDataStream = enable;
|
||||||
|
disabledPort = (!activated || !detectorDataStream || noRoi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetNoRoi(bool enable) {
|
||||||
|
noRoi = enable;
|
||||||
|
disabledPort = (!activated || !detectorDataStream || noRoi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetFrameDiscardPolicy(frameDiscardPolicy value) {
|
||||||
|
frameDiscardMode = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetSilentMode(bool enable) {
|
||||||
|
silentMode = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Listener::ResetParametersforNewAcquisition() {
|
void Listener::ResetParametersforNewAcquisition() {
|
||||||
StopRunning();
|
StopRunning();
|
||||||
startedFlag = false;
|
startedFlag = false;
|
||||||
@ -104,43 +144,17 @@ void Listener::RecordFirstIndex(uint64_t fnum) {
|
|||||||
startedFlag = true;
|
startedFlag = true;
|
||||||
firstIndex = fnum;
|
firstIndex = fnum;
|
||||||
|
|
||||||
if (!(*silentMode)) {
|
if (!silentMode) {
|
||||||
if (!index) {
|
if (!index) {
|
||||||
LOG(logINFOBLUE) << index << " First Index: " << firstIndex;
|
LOG(logINFOBLUE) << index << " First Index: " << firstIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
|
void Listener::CreateUDPSocket(int& actualSize) {
|
||||||
|
|
||||||
void Listener::SetActivate(bool enable) {
|
|
||||||
activated = enable;
|
|
||||||
disabledPort = (!activated || !detectorDataStream || noRoi);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Listener::SetDetectorDatastream(bool enable) {
|
|
||||||
detectorDataStream = enable;
|
|
||||||
disabledPort = (!activated || !detectorDataStream || noRoi);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Listener::SetNoRoi(bool enable) {
|
|
||||||
noRoi = enable;
|
|
||||||
disabledPort = (!activated || !detectorDataStream || noRoi);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Listener::CreateUDPSockets() {
|
|
||||||
if (disabledPort) {
|
if (disabledPort) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if eth is mistaken with ip address
|
|
||||||
if ((*eth).find('.') != std::string::npos) {
|
|
||||||
(*eth) = "";
|
|
||||||
}
|
|
||||||
if (!(*eth).length()) {
|
|
||||||
LOG(logWARNING) << "eth is empty. Listening to all";
|
|
||||||
}
|
|
||||||
|
|
||||||
ShutDownUDPSocket();
|
ShutDownUDPSocket();
|
||||||
|
|
||||||
uint32_t packetSize = generalData->packetSize;
|
uint32_t packetSize = generalData->packetSize;
|
||||||
@ -148,23 +162,20 @@ void Listener::CreateUDPSockets() {
|
|||||||
packetSize = generalData->vetoPacketSize;
|
packetSize = generalData->vetoPacketSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// InterfaceNameToIp(eth).str().c_str()
|
|
||||||
try {
|
try {
|
||||||
udpSocket = make_unique<UdpRxSocket>(
|
udpSocket = make_unique<UdpRxSocket>(udpPortNumber, packetSize,
|
||||||
*udpPortNumber, packetSize,
|
(eth.length() ? InterfaceNameToIp(eth).str().c_str()
|
||||||
((*eth).length() ? InterfaceNameToIp(*eth).str().c_str()
|
: nullptr), generalData->udpSocketBufferSize);
|
||||||
: nullptr),
|
LOG(logINFO) << index << ": UDP port opened at port " << udpPortNumber;
|
||||||
*udpSocketBufferSize);
|
|
||||||
LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw RuntimeError("Could not create UDP socket on port " +
|
throw RuntimeError("Could not create UDP socket on port " +
|
||||||
std::to_string(*udpPortNumber));
|
std::to_string(udpPortNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
udpSocketAlive = true;
|
udpSocketAlive = true;
|
||||||
|
|
||||||
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
||||||
*actualUDPSocketBufferSize = udpSocket->getBufferSize();
|
actualSize = udpSocket->getBufferSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::ShutDownUDPSocket() {
|
void Listener::ShutDownUDPSocket() {
|
||||||
@ -173,27 +184,24 @@ void Listener::ShutDownUDPSocket() {
|
|||||||
// give other thread time after udpSocketAlive is changed
|
// give other thread time after udpSocketAlive is changed
|
||||||
usleep(0);
|
usleep(0);
|
||||||
udpSocket->Shutdown();
|
udpSocket->Shutdown();
|
||||||
LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber;
|
LOG(logINFO) << "Shut down of UDP port " << udpPortNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
|
void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int& actualSize) {
|
||||||
LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port "
|
// custom setup (s != 0)
|
||||||
<< *udpPortNumber;
|
// default setup at startup (s = 0)
|
||||||
|
int size = (s == 0 ? generalData->udpSocketBufferSize : s);
|
||||||
|
LOG(logINFO) << "Testing UDP Socket Buffer size " << size << " with test port "
|
||||||
|
<< udpPortNumber;
|
||||||
|
int previousSize = generalData->udpSocketBufferSize;
|
||||||
|
generalData->udpSocketBufferSize = size;
|
||||||
|
|
||||||
if (disabledPort) {
|
if (disabledPort) {
|
||||||
*actualUDPSocketBufferSize = (s * 2);
|
actualSize = (generalData->udpSocketBufferSize * 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int temp = *udpSocketBufferSize;
|
|
||||||
*udpSocketBufferSize = s;
|
|
||||||
|
|
||||||
// if eth is mistaken with ip address
|
|
||||||
if ((*eth).find('.') != std::string::npos) {
|
|
||||||
(*eth) = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t packetSize = generalData->packetSize;
|
uint32_t packetSize = generalData->packetSize;
|
||||||
if (generalData->detType == GOTTHARD2 && index != 0) {
|
if (generalData->detType == GOTTHARD2 && index != 0) {
|
||||||
packetSize = generalData->vetoPacketSize;
|
packetSize = generalData->vetoPacketSize;
|
||||||
@ -201,24 +209,29 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
|
|||||||
|
|
||||||
// create dummy socket
|
// create dummy socket
|
||||||
try {
|
try {
|
||||||
UdpRxSocket g(*udpPortNumber, packetSize,
|
UdpRxSocket g(udpPortNumber, packetSize,
|
||||||
((*eth).length()
|
(eth.length()
|
||||||
? InterfaceNameToIp(*eth).str().c_str()
|
? InterfaceNameToIp(eth).str().c_str()
|
||||||
: nullptr),
|
: nullptr), generalData->udpSocketBufferSize);
|
||||||
*udpSocketBufferSize);
|
|
||||||
|
|
||||||
// doubled due to kernel bookkeeping (could also be less due to
|
// doubled due to kernel bookkeeping (could also be less due to
|
||||||
// permissions)
|
// permissions)
|
||||||
*actualUDPSocketBufferSize = g.getBufferSize();
|
actualSize = g.getBufferSize();
|
||||||
if (*actualUDPSocketBufferSize == -1) {
|
if (actualSize == -1) {
|
||||||
*udpSocketBufferSize = temp;
|
generalData->udpSocketBufferSize = previousSize;
|
||||||
} else {
|
} else {
|
||||||
*udpSocketBufferSize = (*actualUDPSocketBufferSize) / 2;
|
generalData->udpSocketBufferSize = actualSize / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw RuntimeError("Could not create a test UDP socket on port " +
|
throw RuntimeError("Could not create a test UDP socket on port " +
|
||||||
std::to_string(*udpPortNumber));
|
std::to_string(udpPortNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
// custom and didnt set, throw error
|
||||||
|
if (s != 0 && static_cast<int>(generalData->udpSocketBufferSize) != s) {
|
||||||
|
throw RuntimeError("Could not set udp socket buffer size. (No "
|
||||||
|
"CAP_NET_ADMIN privileges?)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,12 +270,12 @@ void Listener::ThreadExecution() {
|
|||||||
fifo->PushAddress(buffer);
|
fifo->PushAddress(buffer);
|
||||||
|
|
||||||
// Statistics
|
// Statistics
|
||||||
if (!(*silentMode)) {
|
if (!silentMode) {
|
||||||
numFramesStatistic++;
|
numFramesStatistic++;
|
||||||
if (numFramesStatistic >=
|
if (numFramesStatistic >=
|
||||||
// second condition also for infinite #number of frames
|
// second condition also for infinite #number of frames
|
||||||
(((*framesPerFile) == 0) ? STATISTIC_FRAMENUMBER_INFINITE
|
(generalData->framesPerFile == 0 ? STATISTIC_FRAMENUMBER_INFINITE
|
||||||
: (*framesPerFile)))
|
: generalData->framesPerFile))
|
||||||
PrintFifoStatistics();
|
PrintFifoStatistics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,7 +284,7 @@ void Listener::StopListening(char *buf, size_t & size) {
|
|||||||
size = DUMMY_PACKET_VALUE;
|
size = DUMMY_PACKET_VALUE;
|
||||||
fifo->PushAddress(buf);
|
fifo->PushAddress(buf);
|
||||||
StopRunning();
|
StopRunning();
|
||||||
LOG(logDEBUG1) << index << ": Listening Completed. Packets (" << *udpPortNumber
|
LOG(logDEBUG1) << index << ": Listening Completed. Packets (" << udpPortNumber
|
||||||
<< ") : " << numPacketsCaught;
|
<< ") : " << numPacketsCaught;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +355,7 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
|
|||||||
|
|
||||||
// Eiger Firmware in a weird state
|
// Eiger Firmware in a weird state
|
||||||
if (generalData->detType == EIGER && fnum == 0) {
|
if (generalData->detType == EIGER && fnum == 0) {
|
||||||
LOG(logERROR) << "[" << *udpPortNumber
|
LOG(logERROR) << "[" << udpPortNumber
|
||||||
<< "]: Got Frame Number "
|
<< "]: Got Frame Number "
|
||||||
"Zero from Firmware. Discarding Packet";
|
"Zero from Firmware. Discarding Packet";
|
||||||
numPacketsCaught--;
|
numPacketsCaught--;
|
||||||
@ -385,7 +398,7 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t Listener::HandleFuturePacket(bool EOA, uint32_t numpackets, uint64_t fnum, bool isHeaderEmpty, size_t imageSize, sls_receiver_header& dstHeader) {
|
size_t Listener::HandleFuturePacket(bool EOA, uint32_t numpackets, uint64_t fnum, bool isHeaderEmpty, size_t imageSize, sls_receiver_header& dstHeader) {
|
||||||
switch (*frameDiscardMode) {
|
switch (frameDiscardMode) {
|
||||||
case DISCARD_EMPTY_FRAMES:
|
case DISCARD_EMPTY_FRAMES:
|
||||||
if (!numpackets) {
|
if (!numpackets) {
|
||||||
if (!EOA) {
|
if (!EOA) {
|
||||||
@ -495,7 +508,7 @@ void Listener::PrintFifoStatistics() {
|
|||||||
numFramesStatistic = 0;
|
numFramesStatistic = 0;
|
||||||
|
|
||||||
const auto color = loss ? logINFORED : logINFOGREEN;
|
const auto color = loss ? logINFORED : logINFOGREEN;
|
||||||
LOG(color) << "[" << *udpPortNumber
|
LOG(color) << "[" << udpPortNumber
|
||||||
<< "]: "
|
<< "]: "
|
||||||
"Packet_Loss:"
|
"Packet_Loss:"
|
||||||
<< loss << " (" << lossPercent << "%)"
|
<< loss << " (" << lossPercent << "%)"
|
||||||
|
@ -24,8 +24,7 @@ class Fifo;
|
|||||||
class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Listener(int index, std::atomic<runStatus> *status);
|
||||||
Listener(int index, Fifo *fifo, std::atomic<runStatus> *status, uint32_t *udpPortNumber, std::string *eth, int *udpSocketBufferSize, int *actualUDPSocketBufferSize, uint32_t *framesPerFile, frameDiscardPolicy *frameDiscardMode, bool *silentMode);
|
|
||||||
~Listener();
|
~Listener();
|
||||||
|
|
||||||
bool isPortDisabled() const;
|
bool isPortDisabled() const;
|
||||||
@ -39,20 +38,21 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
uint64_t GetListenedIndex() const;
|
uint64_t GetListenedIndex() const;
|
||||||
|
|
||||||
void SetFifo(Fifo *f);
|
void SetFifo(Fifo *f);
|
||||||
void ResetParametersforNewAcquisition();
|
|
||||||
void SetGeneralData(GeneralData *g);
|
void SetGeneralData(GeneralData *g);
|
||||||
|
void SetUdpPortNumber(const uint32_t portNumber);
|
||||||
|
void SetEthernetInterface(const std::string e);
|
||||||
void SetActivate(bool enable);
|
void SetActivate(bool enable);
|
||||||
void SetDetectorDatastream(bool enable);
|
void SetDetectorDatastream(bool enable);
|
||||||
void SetNoRoi(bool enable);
|
void SetNoRoi(bool enable);
|
||||||
void CreateUDPSockets();
|
void SetFrameDiscardPolicy(frameDiscardPolicy value);
|
||||||
void ShutDownUDPSocket();
|
void SetSilentMode(bool enable);
|
||||||
|
|
||||||
/**
|
|
||||||
* Create & closes a dummy UDP socket
|
void ResetParametersforNewAcquisition();
|
||||||
* to set & get actual buffer size
|
void CreateUDPSocket(int& actualSize);
|
||||||
* @param s UDP socket buffer size to be set
|
void ShutDownUDPSocket();
|
||||||
*/
|
/** to set & get actual buffer size */
|
||||||
void CreateDummySocketForUDPSocketBufferSize(int s);
|
void CreateDummySocketForUDPSocketBufferSize(int s, int & actualSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set hard coded (calculated but not from detector) row and column
|
* Set hard coded (calculated but not from detector) row and column
|
||||||
@ -102,17 +102,14 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
// individual members
|
// individual members
|
||||||
std::atomic<runStatus> *status;
|
std::atomic<runStatus> *status;
|
||||||
std::unique_ptr<UdpRxSocket> udpSocket{nullptr};
|
std::unique_ptr<UdpRxSocket> udpSocket{nullptr};
|
||||||
uint32_t *udpPortNumber;
|
|
||||||
std::string *eth;
|
uint32_t udpPortNumber{0};
|
||||||
int *udpSocketBufferSize;
|
std::string eth;
|
||||||
/** double due to kernel bookkeeping */
|
frameDiscardPolicy frameDiscardMode;
|
||||||
int *actualUDPSocketBufferSize;
|
|
||||||
uint32_t *framesPerFile;
|
|
||||||
frameDiscardPolicy *frameDiscardMode;
|
|
||||||
bool activated{false};
|
bool activated{false};
|
||||||
bool detectorDataStream{true};
|
bool detectorDataStream{true};
|
||||||
bool noRoi{false};
|
bool noRoi{false};
|
||||||
bool *silentMode;
|
bool silentMode;
|
||||||
bool disabledPort{false};
|
bool disabledPort{false};
|
||||||
|
|
||||||
/** row hardcoded as 1D or 2d,
|
/** row hardcoded as 1D or 2d,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user