This commit is contained in:
maliakal_d 2021-07-01 16:10:33 +02:00
parent a1da362d2e
commit 4b81cfbd6c
2 changed files with 41 additions and 87 deletions

View File

@ -65,7 +65,7 @@ void Implementation::SetupFifoStructure() {
for (int i = 0; i < numThreads; ++i) { for (int i = 0; i < numThreads; ++i) {
uint32_t datasize = generalData->imageSize; uint32_t datasize = generalData->imageSize;
// veto data size // veto data size
if (myDetectorType == GOTTHARD2 && i != 0) { if (detType == GOTTHARD2 && i != 0) {
datasize = generalData->vetoImageSize; datasize = generalData->vetoImageSize;
} }
@ -105,8 +105,8 @@ void Implementation::SetupFifoStructure() {
* ************************************************/ * ************************************************/
void Implementation::setDetectorType(const detectorType d) { void Implementation::setDetectorType(const detectorType d) {
myDetectorType = d; detType = d;
switch (myDetectorType) { switch (detType) {
case GOTTHARD: case GOTTHARD:
case EIGER: case EIGER:
case JUNGFRAU: case JUNGFRAU:
@ -125,7 +125,7 @@ void Implementation::setDetectorType(const detectorType d) {
generalData = nullptr; generalData = nullptr;
// set detector specific variables // set detector specific variables
switch (myDetectorType) { switch (detType) {
case GOTTHARD: case GOTTHARD:
generalData = new GotthardData(); generalData = new GotthardData();
break; break;
@ -164,16 +164,15 @@ void Implementation::setDetectorType(const detectorType d) {
try { try {
auto fifo_ptr = fifo[i].get(); auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(
i, myDetectorType, fifo_ptr, &status, &udpPortNum[i], &eth[i], i, detType, fifo_ptr, &status, &udpPortNum[i], &eth[i],
&numberOfTotalFrames, &udpSocketBufferSize, &numberOfTotalFrames, &udpSocketBufferSize,
&actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode, &actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode,
&activated, &deactivatedPaddingEnable, &silentMode)); &activated, &deactivatedPaddingEnable, &silentMode));
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &activated, i, detType, fifo_ptr, &activated, &deactivatedPaddingEnable,
&deactivatedPaddingEnable, &dataStreamEnable, &dataStreamEnable, &streamingFrequency, &streamingTimerInMs,
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum, &streamingStartFnum, &framePadding, &ctbDbitList,
&framePadding, &ctbDbitList, &ctbDbitOffset, &ctbDbitOffset, &ctbAnalogDataBytes, &hdf5Lib));
&ctbAnalogDataBytes, &hdf5Lib));
} catch (...) { } catch (...) {
listener.clear(); listener.clear();
dataProcessor.clear(); dataProcessor.clear();
@ -199,7 +198,7 @@ void Implementation::setDetectorSize(const int *size) {
std::string log_message = "Detector Size (ports): ("; std::string log_message = "Detector Size (ports): (";
for (int i = 0; i < MAX_DIMENSIONS; ++i) { for (int i = 0; i < MAX_DIMENSIONS; ++i) {
// x dir (colums) each udp port // x dir (colums) each udp port
if (myDetectorType == EIGER && i == X) if (detType == EIGER && i == X)
numDet[i] = size[i] * 2; numDet[i] = size[i] * 2;
// y dir (rows) each udp port // y dir (rows) each udp port
else if (numUDPInterfaces == 2 && i == Y) else if (numUDPInterfaces == 2 && i == Y)
@ -232,21 +231,17 @@ void Implementation::setModulePositionId(const int id) {
// update zmq port // update zmq port
streamingPort = streamingPort =
DEFAULT_ZMQ_RX_PORTNO + (modulePos * (myDetectorType == EIGER ? 2 : 1)); DEFAULT_ZMQ_RX_PORTNO + (modulePos * (detType == EIGER ? 2 : 1));
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (const auto &it : dataProcessor)
/*dataProcessor[i]->SetupFileWriter( it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
fileFormatType, fileWriteEnable, masterFileWriteEnable, &activated, fileFormatType, modulePos);
&deactivatedPaddingEnable, (int *)numDet, &framesPerFile, &fileName,
&filePath, &fileIndex, &overwriteEnable, &modulePos, &numThreads,
&numberOfTotalFrames, &dynamicRange, &udpPortNum[i], generalData);*/
}
assert(numDet[1] != 0); assert(numDet[1] != 0);
for (unsigned int i = 0; i < listener.size(); ++i) { for (unsigned int i = 0; i < listener.size(); ++i) {
uint16_t row = 0, col = 0; uint16_t row = 0, col = 0;
row = row =
(modulePos % numDet[1]) * ((numUDPInterfaces == 2) ? 2 : 1); // row (modulePos % numDet[1]) * ((numUDPInterfaces == 2) ? 2 : 1); // row
col = (modulePos / numDet[1]) * ((myDetectorType == EIGER) ? 2 : 1) + col = (modulePos / numDet[1]) * ((detType == EIGER) ? 2 : 1) +
i; // col for horiz. udp ports i; // col for horiz. udp ports
listener[i]->SetHardCodedPosition(row, col); listener[i]->SetHardCodedPosition(row, col);
} }
@ -340,21 +335,15 @@ void Implementation::setFileFormat(const fileFormat f) {
fileFormatType = HDF5; fileFormatType = HDF5;
break; break;
#endif #endif
default: case BINARY:
fileFormatType = BINARY; fileFormatType = BINARY;
break; break;
default:
throw sls::RuntimeError("Unknown file format");
} }
if (fileWriteEnable) { for (const auto &it : dataProcessor)
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
/*dataProcessor[i]->SetupFileWriter( fileFormatType, modulePos);
fileFormatType, fileWriteEnable, masterFileWriteEnable,
&activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads,
&numberOfTotalFrames, &dynamicRange, &udpPortNum[i],
generalData);*/
}
}
} }
LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType); LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
@ -389,14 +378,9 @@ bool Implementation::getFileWriteEnable() const { return fileWriteEnable; }
void Implementation::setFileWriteEnable(const bool b) { void Implementation::setFileWriteEnable(const bool b) {
if (fileWriteEnable != b) { if (fileWriteEnable != b) {
fileWriteEnable = b; fileWriteEnable = b;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (const auto &it : dataProcessor)
/*dataProcessor[i]->SetupFileWriter( it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
fileFormatType, fileWriteEnable, masterFileWriteEnable, fileFormatType, modulePos);
&activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
&dynamicRange, &udpPortNum[i], generalData);*/
}
} }
LOG(logINFO) << "File Write Enable: " LOG(logINFO) << "File Write Enable: "
<< (fileWriteEnable ? "enabled" : "disabled"); << (fileWriteEnable ? "enabled" : "disabled");
@ -409,14 +393,9 @@ bool Implementation::getMasterFileWriteEnable() const {
void Implementation::setMasterFileWriteEnable(const bool b) { void Implementation::setMasterFileWriteEnable(const bool b) {
if (masterFileWriteEnable != b) { if (masterFileWriteEnable != b) {
masterFileWriteEnable = b; masterFileWriteEnable = b;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (const auto &it : dataProcessor)
/*dataProcessor[i]->SetupFileWriter( it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
fileFormatType, fileWriteEnable, masterFileWriteEnable, fileFormatType, modulePos);
&activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
&dynamicRange, &udpPortNum[i], generalData);*/
}
} }
LOG(logINFO) << "Master File Write Enable: " LOG(logINFO) << "Master File Write Enable: "
<< (masterFileWriteEnable ? "enabled" : "disabled"); << (masterFileWriteEnable ? "enabled" : "disabled");
@ -744,7 +723,7 @@ void Implementation::SetupWriter() {
// master file // master file
if (masterFileWriteEnable) { if (masterFileWriteEnable) {
std::unique_ptr<MasterAttributes> masterAttributes; std::unique_ptr<MasterAttributes> masterAttributes;
switch (myDetectorType) { switch (detType) {
case GOTTHARD: case GOTTHARD:
masterAttributes = sls::make_unique<GotthardMasterAttributes>(); masterAttributes = sls::make_unique<GotthardMasterAttributes>();
break; break;
@ -770,7 +749,7 @@ void Implementation::SetupWriter() {
throw sls::RuntimeError( throw sls::RuntimeError(
"Unknown detector type to set up master file attributes"); "Unknown detector type to set up master file attributes");
} }
masterAttributes->detType = myDetectorType; masterAttributes->detType = detType;
masterAttributes->timingMode = timingMode; masterAttributes->timingMode = timingMode;
masterAttributes->imageSize = generalData->imageSize; masterAttributes->imageSize = generalData->imageSize;
masterAttributes->nPixels = masterAttributes->nPixels =
@ -900,17 +879,16 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
try { try {
auto fifo_ptr = fifo[i].get(); auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(
i, myDetectorType, fifo_ptr, &status, &udpPortNum[i], i, detType, fifo_ptr, &status, &udpPortNum[i], &eth[i],
&eth[i], &numberOfTotalFrames, &udpSocketBufferSize, &numberOfTotalFrames, &udpSocketBufferSize,
&actualUDPSocketBufferSize, &framesPerFile, &actualUDPSocketBufferSize, &framesPerFile,
&frameDiscardMode, &activated, &deactivatedPaddingEnable, &frameDiscardMode, &activated, &deactivatedPaddingEnable,
&silentMode)); &silentMode));
listener[i]->SetGeneralData(generalData); listener[i]->SetGeneralData(generalData);
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &activated, i, detType, fifo_ptr, &activated, &deactivatedPaddingEnable,
&deactivatedPaddingEnable, &dataStreamEnable, &dataStreamEnable, &streamingFrequency, &streamingTimerInMs,
&streamingFrequency, &streamingTimerInMs,
&streamingStartFnum, &framePadding, &ctbDbitList, &streamingStartFnum, &framePadding, &ctbDbitList,
&ctbDbitOffset, &ctbAnalogDataBytes, &hdf5Lib)); &ctbDbitOffset, &ctbAnalogDataBytes, &hdf5Lib));
dataProcessor[i]->SetGeneralData(generalData); dataProcessor[i]->SetGeneralData(generalData);
@ -1016,7 +994,7 @@ void Implementation::setUDPSocketBufferSize(const int s) {
// testing default setup at startup, argument is 0 to use default values // testing default setup at startup, argument is 0 to use default values
int size = (s == 0) ? udpSocketBufferSize : s; int size = (s == 0) ? udpSocketBufferSize : s;
size_t listSize = listener.size(); size_t listSize = listener.size();
if (myDetectorType == JUNGFRAU && (int)listSize != numUDPInterfaces) { if (detType == JUNGFRAU && (int)listSize != numUDPInterfaces) {
throw sls::RuntimeError( throw sls::RuntimeError(
"Number of Interfaces " + std::to_string(numUDPInterfaces) + "Number of Interfaces " + std::to_string(numUDPInterfaces) +
" do not match listener size " + std::to_string(listSize)); " do not match listener size " + std::to_string(listSize));
@ -1201,7 +1179,7 @@ void Implementation::updateTotalNumberOfFrames() {
int64_t repeats = numberOfTriggers; int64_t repeats = numberOfTriggers;
int64_t numFrames = numberOfFrames; int64_t numFrames = numberOfFrames;
// gotthard2 // gotthard2
if (myDetectorType == GOTTHARD2) { if (detType == GOTTHARD2) {
// auto // auto
if (timingMode == AUTO_TIMING) { if (timingMode == AUTO_TIMING) {
// burst mode, repeats = #bursts // burst mode, repeats = #bursts
@ -1433,9 +1411,9 @@ void Implementation::setDynamicRange(const uint32_t i) {
if (dynamicRange != i) { if (dynamicRange != i) {
dynamicRange = i; dynamicRange = i;
if (myDetectorType == EIGER || myDetectorType == MYTHEN3) { if (detType == EIGER || detType == MYTHEN3) {
if (myDetectorType == EIGER) { if (detType == EIGER) {
generalData->SetDynamicRange(i, tengigaEnable); generalData->SetDynamicRange(i, tengigaEnable);
} else { } else {
int ncounters = __builtin_popcount(counterMask); int ncounters = __builtin_popcount(counterMask);
@ -1478,7 +1456,7 @@ void Implementation::setTenGigaEnable(const bool b) {
tengigaEnable = b; tengigaEnable = b;
int ncounters = __builtin_popcount(counterMask); int ncounters = __builtin_popcount(counterMask);
// side effects // side effects
switch (myDetectorType) { switch (detType) {
case EIGER: case EIGER:
generalData->SetTenGigaEnable(b, dynamicRange); generalData->SetTenGigaEnable(b, dynamicRange);
break; break;
@ -1547,19 +1525,7 @@ void Implementation::setQuad(const bool b) {
bool Implementation::getActivate() const { return activated; } bool Implementation::getActivate() const { return activated; }
bool Implementation::setActivate(bool enable) { bool Implementation::setActivate(bool enable) {
if (activated != enable) { activated = enable;
activated = enable;
// disable file writing if deactivated and no padding
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
/*dataProcessor[i]->SetupFileWriter(
fileFormatType, fileWriteEnable, masterFileWriteEnable,
&activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads, &numberOfTotalFrames,
&dynamicRange, &udpPortNum[i], generalData);*/
}
}
LOG(logINFO) << "Activation: " << (activated ? "enabled" : "disabled"); LOG(logINFO) << "Activation: " << (activated ? "enabled" : "disabled");
return activated; return activated;
} }
@ -1569,19 +1535,7 @@ bool Implementation::getDeactivatedPadding() const {
} }
void Implementation::setDeactivatedPadding(bool enable) { void Implementation::setDeactivatedPadding(bool enable) {
if (deactivatedPaddingEnable != enable) { deactivatedPaddingEnable = enable;
deactivatedPaddingEnable = enable;
// disable file writing if deactivated and no padding
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
; /*dataProcessor[i]->SetupFileWriter(
fileFormatType, fileWriteEnable, masterFileWriteEnable,
&activated, &deactivatedPaddingEnable, (int *)numDet,
&framesPerFile, &fileName, &filePath, &fileIndex,
&overwriteEnable, &modulePos, &numThreads,
&numberOfTotalFrames, &dynamicRange, &udpPortNum[i],
generalData);*/
}
}
LOG(logINFO) << "Deactivated Padding Enable: " LOG(logINFO) << "Deactivated Padding Enable: "
<< (deactivatedPaddingEnable ? "enabled" : "disabled"); << (deactivatedPaddingEnable ? "enabled" : "disabled");
} }

View File

@ -275,7 +275,7 @@ class Implementation : private virtual slsDetectorDefs {
// config parameters // config parameters
int numThreads{1}; int numThreads{1};
detectorType myDetectorType{GENERIC}; detectorType detType{GENERIC};
int numDet[MAX_DIMENSIONS] = {0, 0}; int numDet[MAX_DIMENSIONS] = {0, 0};
int modulePos{0}; int modulePos{0};
std::string detHostname; std::string detHostname;