using xy instead of portGeometry

This commit is contained in:
maliakal_d 2022-01-24 15:42:25 +01:00
parent a2f46aa2dd
commit bf43b003b6
5 changed files with 57 additions and 66 deletions

View File

@ -317,10 +317,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
// basic setup
setDetectorType(arg.detType);
{
int msize[2] = {arg.numberOfModule.x, arg.numberOfModule.y};
impl()->setDetectorSize(msize);
}
impl()->setDetectorSize(arg.numberOfModule);
impl()->setModulePositionId(arg.moduleIndex);
impl()->setDetectorHostname(arg.hostname);

View File

@ -17,11 +17,12 @@
const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi,
bool fr, int *nm, bool *qe, uint64_t *tot)
bool fr, slsDetectorDefs::xy nm, bool *qe,
uint64_t *tot)
: ThreadObject(ind, TypeName), fifo(f), dynamicRange(dr), roi(r),
fileIndex(fi), flipRows(fr), quadEnable(qe), totalNumFrames(tot) {
numMods[0] = nm[0];
numMods[1] = nm[1];
numMods.x = nm.x;
numMods.y = nm.y;
LOG(logDEBUG) << "DataStreamer " << ind << " created";
}
@ -62,9 +63,9 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, char *buf) {
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
void DataStreamer::SetNumberofModules(int *nm) {
numMods[0] = nm[0];
numMods[1] = nm[1];
void DataStreamer::SetNumberofModules(xy nm) {
numMods.x = nm.x;
numMods.y = nm.y;
}
void DataStreamer::SetFlipRows(bool fd) { flipRows = fd; }
@ -219,8 +220,8 @@ int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size,
zHeader.dynamicRange = *dynamicRange;
zHeader.fileIndex = *fileIndex;
zHeader.ndetx = numMods[0];
zHeader.ndety = numMods[1];
zHeader.ndetx = numMods.x;
zHeader.ndety = numMods.y;
zHeader.npixelsx = nx;
zHeader.npixelsy = ny;
zHeader.imageSize = size;

View File

@ -33,12 +33,12 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param r roi
* @param fi pointer to file index
* @param fr flip rows
* @param nm pointer to number of modules in each dimension
* @param nm number of modules in each dimension
* @param qe pointer to quad Enable
* @param tot pointer to total number of frames
*/
DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi, bool fr,
int *nm, bool *qe, uint64_t *tot);
xy nm, bool *qe, uint64_t *tot);
/**
* Destructor
@ -65,9 +65,9 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
/**
* Set number of detectors
* @param nm number of modules in both dimensions
* @param nm number of modules/ports in both dimensions
*/
void SetNumberofModules(int *nm);
void SetNumberofModules(xy nm);
/**
* Set Flipped rows
@ -196,7 +196,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
char *completeBuffer{nullptr};
/** Number of Modules in X and Y dimension */
int numMods[2];
xy numMods{1, 1};
/** Quad Enable */
bool *quadEnable;

View File

@ -198,39 +198,35 @@ void Implementation::setDetectorType(const detectorType d) {
LOG(logDEBUG) << " Detector type set to " << sls::ToString(d);
}
PortGeometry Implementation::getDetectorSize() const { return numModules; }
slsDetectorDefs::xy Implementation::getDetectorSize() const {
return numModules;
}
PortGeometry Implementation::GetPortGeometry() {
PortGeometry portGeometry = {{1, 1}};
slsDetectorDefs::xy Implementation::GetPortGeometry() {
xy portGeometry{1, 1};
if (detType == EIGER)
portGeometry[X] = numUDPInterfaces;
portGeometry.x = numUDPInterfaces;
else // (jungfrau and gotthard2)
portGeometry[Y] = numUDPInterfaces;
portGeometry.y = numUDPInterfaces;
return portGeometry;
}
void Implementation::setDetectorSize(const int *size) {
PortGeometry portGeometry = GetPortGeometry();
void Implementation::setDetectorSize(const slsDetectorDefs::xy size) {
xy portGeometry = GetPortGeometry();
std::string log_message = "Detector Size (ports): (";
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
numModules[i] = portGeometry[i] * size[i];
log_message += std::to_string(numModules[i]);
if (i < MAX_DIMENSIONS - 1)
log_message += ", ";
}
log_message += ")";
int nm[2] = {numModules[X], numModules[Y]};
numModules.x = portGeometry.x * size.x;
numModules.y = portGeometry.y * size.y;
xy nm{numModules.x, numModules.y};
if (quadEnable) {
nm[0] = 1;
nm[1] = 2;
nm.x = 1;
nm.y = 2;
}
for (const auto &it : dataStreamer) {
it->SetNumberofModules(nm);
}
LOG(logINFO) << log_message;
LOG(logINFO) << "Detector Size (ports): " << sls::ToString(numModules);
}
int Implementation::getModulePositionId() const { return modulePos; }
@ -240,17 +236,17 @@ void Implementation::setModulePositionId(const int id) {
LOG(logINFO) << "Module Position Id:" << modulePos;
// update zmq port
PortGeometry portGeometry = GetPortGeometry();
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry[X];
xy portGeometry = GetPortGeometry();
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry.x;
for (const auto &it : dataProcessor)
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
fileFormatType, modulePos, &hdf5Lib);
assert(numModules[Y] != 0);
assert(numModules.y != 0);
for (unsigned int i = 0; i < listener.size(); ++i) {
uint16_t row = 0, col = 0;
row = (modulePos % numModules[Y]) * portGeometry[Y];
col = (modulePos / numModules[Y]) * portGeometry[X] + i;
row = (modulePos % numModules.y) * portGeometry.y;
col = (modulePos / numModules.y) * portGeometry.x + i;
listener[i]->SetHardCodedPosition(row, col);
}
@ -569,12 +565,12 @@ void Implementation::stopReceiver() {
if (modulePos == 0) {
// more than 1 file, create virtual file
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
(numModules[X] * numModules[Y]) > 1) {
(numModules.x * numModules.y) > 1) {
dataProcessor[0]->CreateVirtualFile(
filePath, fileName, fileIndex, overwriteEnable, silentMode,
modulePos, numUDPInterfaces, framesPerFile,
numberOfTotalFrames, dynamicRange, numModules[X],
numModules[Y], &hdf5Lib);
numberOfTotalFrames, dynamicRange, numModules.x,
numModules.y, &hdf5Lib);
}
// link file in master
dataProcessor[0]->LinkDataInMasterFile(silentMode);
@ -867,9 +863,9 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
if (numUDPInterfaces != n) {
// reduce number of detectors to size with 1 interface
PortGeometry portGeometry = GetPortGeometry();
numModules[X] /= portGeometry[X];
numModules[Y] /= portGeometry[Y];
xy portGeometry = GetPortGeometry();
numModules.x /= portGeometry.x;
numModules.y /= portGeometry.y;
// clear all threads and fifos
listener.clear();
@ -919,15 +915,15 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
if (dataStreamEnable) {
try {
bool flip = flipRows;
int nm[2] = {numModules[X], numModules[Y]};
xy nm{numModules.x, numModules.y};
if (quadEnable) {
flip = (i == 1 ? true : false);
nm[0] = 1;
nm[1] = 2;
nm.x = 1;
nm.y = 2;
}
dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
(int *)nm, &quadEnable, &numberOfTotalFrames));
nm, &quadEnable, &numberOfTotalFrames));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(
&numUDPInterfaces, streamingPort, streamingSrcIP,
@ -950,8 +946,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
SetThreadPriorities();
// update (from 1 to 2 interface) & also for printout
int nm[2] = {numModules[X], numModules[Y]};
setDetectorSize(nm);
setDetectorSize(numModules);
// update row and column in dataprocessor
setModulePositionId(modulePos);
@ -1050,15 +1045,15 @@ void Implementation::setDataStreamEnable(const bool enable) {
for (int i = 0; i < numUDPInterfaces; ++i) {
try {
bool flip = flipRows;
int nm[2] = {numModules[X], numModules[Y]};
xy nm{numModules.x, numModules.y};
if (quadEnable) {
flip = (i == 1 ? true : false);
nm[0] = 1;
nm[1] = 2;
nm.x = 1;
nm.y = 2;
}
dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
(int *)nm, &quadEnable, &numberOfTotalFrames));
nm, &quadEnable, &numberOfTotalFrames));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(
&numUDPInterfaces, streamingPort, streamingSrcIP,
@ -1479,15 +1474,15 @@ void Implementation::setQuad(const bool b) {
quadEnable = b;
if (!quadEnable) {
int nm[2] = {numModules[X], numModules[Y]};
xy nm{numModules.x, numModules.y};
for (const auto &it : dataStreamer) {
it->SetNumberofModules(nm);
it->SetFlipRows(flipRows);
}
} else {
int size[2] = {1, 2};
xy nm{1, 2};
for (const auto &it : dataStreamer) {
it->SetNumberofModules(size);
it->SetNumberofModules(nm);
}
if (dataStreamer.size() == 2) {
dataStreamer[0]->SetFlipRows(false);

View File

@ -21,8 +21,6 @@ class slsDetectorDefs;
#include <vector>
using ns = std::chrono::nanoseconds;
typedef std::array<int, MAX_DIMENSIONS> PortGeometry;
class Implementation : private virtual slsDetectorDefs {
public:
explicit Implementation(const detectorType d);
@ -35,8 +33,8 @@ class Implementation : private virtual slsDetectorDefs {
* ************************************************/
void setDetectorType(const detectorType d);
PortGeometry getDetectorSize() const;
void setDetectorSize(const int *size);
xy getDetectorSize() const;
void setDetectorSize(const xy size);
int getModulePositionId() const;
void setModulePositionId(const int id);
std::string getDetectorHostname() const;
@ -268,7 +266,7 @@ class Implementation : private virtual slsDetectorDefs {
void SetThreadPriorities();
void SetupFifoStructure();
PortGeometry GetPortGeometry();
xy GetPortGeometry();
void ResetParametersforNewAcquisition();
void CreateUDPSockets();
void SetupWriter();
@ -282,7 +280,7 @@ class Implementation : private virtual slsDetectorDefs {
// config parameters
detectorType detType{GENERIC};
PortGeometry numModules = {{1, 1}};
xy numModules{1, 1};
int modulePos{0};
std::string detHostname;
bool silentMode{false};