mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
using xy instead of portGeometry
This commit is contained in:
parent
a2f46aa2dd
commit
bf43b003b6
@ -317,10 +317,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
|||||||
|
|
||||||
// basic setup
|
// basic setup
|
||||||
setDetectorType(arg.detType);
|
setDetectorType(arg.detType);
|
||||||
{
|
impl()->setDetectorSize(arg.numberOfModule);
|
||||||
int msize[2] = {arg.numberOfModule.x, arg.numberOfModule.y};
|
|
||||||
impl()->setDetectorSize(msize);
|
|
||||||
}
|
|
||||||
impl()->setModulePositionId(arg.moduleIndex);
|
impl()->setModulePositionId(arg.moduleIndex);
|
||||||
impl()->setDetectorHostname(arg.hostname);
|
impl()->setDetectorHostname(arg.hostname);
|
||||||
|
|
||||||
|
@ -17,11 +17,12 @@
|
|||||||
const std::string DataStreamer::TypeName = "DataStreamer";
|
const std::string DataStreamer::TypeName = "DataStreamer";
|
||||||
|
|
||||||
DataStreamer::DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi,
|
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),
|
: ThreadObject(ind, TypeName), fifo(f), dynamicRange(dr), roi(r),
|
||||||
fileIndex(fi), flipRows(fr), quadEnable(qe), totalNumFrames(tot) {
|
fileIndex(fi), flipRows(fr), quadEnable(qe), totalNumFrames(tot) {
|
||||||
numMods[0] = nm[0];
|
numMods.x = nm.x;
|
||||||
numMods[1] = nm[1];
|
numMods.y = nm.y;
|
||||||
|
|
||||||
LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
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::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||||
|
|
||||||
void DataStreamer::SetNumberofModules(int *nm) {
|
void DataStreamer::SetNumberofModules(xy nm) {
|
||||||
numMods[0] = nm[0];
|
numMods.x = nm.x;
|
||||||
numMods[1] = nm[1];
|
numMods.y = nm.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::SetFlipRows(bool fd) { flipRows = fd; }
|
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.dynamicRange = *dynamicRange;
|
||||||
zHeader.fileIndex = *fileIndex;
|
zHeader.fileIndex = *fileIndex;
|
||||||
zHeader.ndetx = numMods[0];
|
zHeader.ndetx = numMods.x;
|
||||||
zHeader.ndety = numMods[1];
|
zHeader.ndety = numMods.y;
|
||||||
zHeader.npixelsx = nx;
|
zHeader.npixelsx = nx;
|
||||||
zHeader.npixelsy = ny;
|
zHeader.npixelsy = ny;
|
||||||
zHeader.imageSize = size;
|
zHeader.imageSize = size;
|
||||||
|
@ -33,12 +33,12 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param r roi
|
* @param r roi
|
||||||
* @param fi pointer to file index
|
* @param fi pointer to file index
|
||||||
* @param fr flip rows
|
* @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 qe pointer to quad Enable
|
||||||
* @param tot pointer to total number of frames
|
* @param tot pointer to total number of frames
|
||||||
*/
|
*/
|
||||||
DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi, bool fr,
|
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
|
* Destructor
|
||||||
@ -65,9 +65,9 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set number of detectors
|
* 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
|
* Set Flipped rows
|
||||||
@ -196,7 +196,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
char *completeBuffer{nullptr};
|
char *completeBuffer{nullptr};
|
||||||
|
|
||||||
/** Number of Modules in X and Y dimension */
|
/** Number of Modules in X and Y dimension */
|
||||||
int numMods[2];
|
xy numMods{1, 1};
|
||||||
|
|
||||||
/** Quad Enable */
|
/** Quad Enable */
|
||||||
bool *quadEnable;
|
bool *quadEnable;
|
||||||
|
@ -198,39 +198,35 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
LOG(logDEBUG) << " Detector type set to " << sls::ToString(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() {
|
slsDetectorDefs::xy Implementation::GetPortGeometry() {
|
||||||
PortGeometry portGeometry = {{1, 1}};
|
xy portGeometry{1, 1};
|
||||||
if (detType == EIGER)
|
if (detType == EIGER)
|
||||||
portGeometry[X] = numUDPInterfaces;
|
portGeometry.x = numUDPInterfaces;
|
||||||
else // (jungfrau and gotthard2)
|
else // (jungfrau and gotthard2)
|
||||||
portGeometry[Y] = numUDPInterfaces;
|
portGeometry.y = numUDPInterfaces;
|
||||||
return portGeometry;
|
return portGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setDetectorSize(const int *size) {
|
void Implementation::setDetectorSize(const slsDetectorDefs::xy size) {
|
||||||
PortGeometry portGeometry = GetPortGeometry();
|
xy portGeometry = GetPortGeometry();
|
||||||
|
|
||||||
std::string log_message = "Detector Size (ports): (";
|
std::string log_message = "Detector Size (ports): (";
|
||||||
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
|
numModules.x = portGeometry.x * size.x;
|
||||||
numModules[i] = portGeometry[i] * size[i];
|
numModules.y = portGeometry.y * size.y;
|
||||||
log_message += std::to_string(numModules[i]);
|
xy nm{numModules.x, numModules.y};
|
||||||
if (i < MAX_DIMENSIONS - 1)
|
|
||||||
log_message += ", ";
|
|
||||||
}
|
|
||||||
log_message += ")";
|
|
||||||
|
|
||||||
int nm[2] = {numModules[X], numModules[Y]};
|
|
||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
nm[0] = 1;
|
nm.x = 1;
|
||||||
nm[1] = 2;
|
nm.y = 2;
|
||||||
}
|
}
|
||||||
for (const auto &it : dataStreamer) {
|
for (const auto &it : dataStreamer) {
|
||||||
it->SetNumberofModules(nm);
|
it->SetNumberofModules(nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << log_message;
|
LOG(logINFO) << "Detector Size (ports): " << sls::ToString(numModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Implementation::getModulePositionId() const { return modulePos; }
|
int Implementation::getModulePositionId() const { return modulePos; }
|
||||||
@ -240,17 +236,17 @@ void Implementation::setModulePositionId(const int id) {
|
|||||||
LOG(logINFO) << "Module Position Id:" << modulePos;
|
LOG(logINFO) << "Module Position Id:" << modulePos;
|
||||||
|
|
||||||
// update zmq port
|
// update zmq port
|
||||||
PortGeometry portGeometry = GetPortGeometry();
|
xy portGeometry = GetPortGeometry();
|
||||||
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry[X];
|
streamingPort = DEFAULT_ZMQ_RX_PORTNO + modulePos * portGeometry.x;
|
||||||
|
|
||||||
for (const auto &it : dataProcessor)
|
for (const auto &it : dataProcessor)
|
||||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
||||||
fileFormatType, modulePos, &hdf5Lib);
|
fileFormatType, modulePos, &hdf5Lib);
|
||||||
assert(numModules[Y] != 0);
|
assert(numModules.y != 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 = (modulePos % numModules[Y]) * portGeometry[Y];
|
row = (modulePos % numModules.y) * portGeometry.y;
|
||||||
col = (modulePos / numModules[Y]) * portGeometry[X] + i;
|
col = (modulePos / numModules.y) * portGeometry.x + i;
|
||||||
|
|
||||||
listener[i]->SetHardCodedPosition(row, col);
|
listener[i]->SetHardCodedPosition(row, col);
|
||||||
}
|
}
|
||||||
@ -569,12 +565,12 @@ void Implementation::stopReceiver() {
|
|||||||
if (modulePos == 0) {
|
if (modulePos == 0) {
|
||||||
// more than 1 file, create virtual file
|
// more than 1 file, create virtual file
|
||||||
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
|
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
|
||||||
(numModules[X] * numModules[Y]) > 1) {
|
(numModules.x * numModules.y) > 1) {
|
||||||
dataProcessor[0]->CreateVirtualFile(
|
dataProcessor[0]->CreateVirtualFile(
|
||||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||||
modulePos, numUDPInterfaces, framesPerFile,
|
modulePos, numUDPInterfaces, framesPerFile,
|
||||||
numberOfTotalFrames, dynamicRange, numModules[X],
|
numberOfTotalFrames, dynamicRange, numModules.x,
|
||||||
numModules[Y], &hdf5Lib);
|
numModules.y, &hdf5Lib);
|
||||||
}
|
}
|
||||||
// link file in master
|
// link file in master
|
||||||
dataProcessor[0]->LinkDataInMasterFile(silentMode);
|
dataProcessor[0]->LinkDataInMasterFile(silentMode);
|
||||||
@ -867,9 +863,9 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
if (numUDPInterfaces != n) {
|
if (numUDPInterfaces != n) {
|
||||||
|
|
||||||
// reduce number of detectors to size with 1 interface
|
// reduce number of detectors to size with 1 interface
|
||||||
PortGeometry portGeometry = GetPortGeometry();
|
xy portGeometry = GetPortGeometry();
|
||||||
numModules[X] /= portGeometry[X];
|
numModules.x /= portGeometry.x;
|
||||||
numModules[Y] /= portGeometry[Y];
|
numModules.y /= portGeometry.y;
|
||||||
|
|
||||||
// clear all threads and fifos
|
// clear all threads and fifos
|
||||||
listener.clear();
|
listener.clear();
|
||||||
@ -919,15 +915,15 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
if (dataStreamEnable) {
|
if (dataStreamEnable) {
|
||||||
try {
|
try {
|
||||||
bool flip = flipRows;
|
bool flip = flipRows;
|
||||||
int nm[2] = {numModules[X], numModules[Y]};
|
xy nm{numModules.x, numModules.y};
|
||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
flip = (i == 1 ? true : false);
|
flip = (i == 1 ? true : false);
|
||||||
nm[0] = 1;
|
nm.x = 1;
|
||||||
nm[1] = 2;
|
nm.y = 2;
|
||||||
}
|
}
|
||||||
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
||||||
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
|
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
|
||||||
(int *)nm, &quadEnable, &numberOfTotalFrames));
|
nm, &quadEnable, &numberOfTotalFrames));
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
dataStreamer[i]->CreateZmqSockets(
|
dataStreamer[i]->CreateZmqSockets(
|
||||||
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
||||||
@ -950,8 +946,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
SetThreadPriorities();
|
SetThreadPriorities();
|
||||||
|
|
||||||
// update (from 1 to 2 interface) & also for printout
|
// update (from 1 to 2 interface) & also for printout
|
||||||
int nm[2] = {numModules[X], numModules[Y]};
|
setDetectorSize(numModules);
|
||||||
setDetectorSize(nm);
|
|
||||||
// update row and column in dataprocessor
|
// update row and column in dataprocessor
|
||||||
setModulePositionId(modulePos);
|
setModulePositionId(modulePos);
|
||||||
|
|
||||||
@ -1050,15 +1045,15 @@ void Implementation::setDataStreamEnable(const bool enable) {
|
|||||||
for (int i = 0; i < numUDPInterfaces; ++i) {
|
for (int i = 0; i < numUDPInterfaces; ++i) {
|
||||||
try {
|
try {
|
||||||
bool flip = flipRows;
|
bool flip = flipRows;
|
||||||
int nm[2] = {numModules[X], numModules[Y]};
|
xy nm{numModules.x, numModules.y};
|
||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
flip = (i == 1 ? true : false);
|
flip = (i == 1 ? true : false);
|
||||||
nm[0] = 1;
|
nm.x = 1;
|
||||||
nm[1] = 2;
|
nm.y = 2;
|
||||||
}
|
}
|
||||||
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
||||||
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
|
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
|
||||||
(int *)nm, &quadEnable, &numberOfTotalFrames));
|
nm, &quadEnable, &numberOfTotalFrames));
|
||||||
dataStreamer[i]->SetGeneralData(generalData);
|
dataStreamer[i]->SetGeneralData(generalData);
|
||||||
dataStreamer[i]->CreateZmqSockets(
|
dataStreamer[i]->CreateZmqSockets(
|
||||||
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
&numUDPInterfaces, streamingPort, streamingSrcIP,
|
||||||
@ -1479,15 +1474,15 @@ void Implementation::setQuad(const bool b) {
|
|||||||
quadEnable = b;
|
quadEnable = b;
|
||||||
|
|
||||||
if (!quadEnable) {
|
if (!quadEnable) {
|
||||||
int nm[2] = {numModules[X], numModules[Y]};
|
xy nm{numModules.x, numModules.y};
|
||||||
for (const auto &it : dataStreamer) {
|
for (const auto &it : dataStreamer) {
|
||||||
it->SetNumberofModules(nm);
|
it->SetNumberofModules(nm);
|
||||||
it->SetFlipRows(flipRows);
|
it->SetFlipRows(flipRows);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int size[2] = {1, 2};
|
xy nm{1, 2};
|
||||||
for (const auto &it : dataStreamer) {
|
for (const auto &it : dataStreamer) {
|
||||||
it->SetNumberofModules(size);
|
it->SetNumberofModules(nm);
|
||||||
}
|
}
|
||||||
if (dataStreamer.size() == 2) {
|
if (dataStreamer.size() == 2) {
|
||||||
dataStreamer[0]->SetFlipRows(false);
|
dataStreamer[0]->SetFlipRows(false);
|
||||||
|
@ -21,8 +21,6 @@ class slsDetectorDefs;
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
using ns = std::chrono::nanoseconds;
|
using ns = std::chrono::nanoseconds;
|
||||||
|
|
||||||
typedef std::array<int, MAX_DIMENSIONS> PortGeometry;
|
|
||||||
|
|
||||||
class Implementation : private virtual slsDetectorDefs {
|
class Implementation : private virtual slsDetectorDefs {
|
||||||
public:
|
public:
|
||||||
explicit Implementation(const detectorType d);
|
explicit Implementation(const detectorType d);
|
||||||
@ -35,8 +33,8 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
* ************************************************/
|
* ************************************************/
|
||||||
|
|
||||||
void setDetectorType(const detectorType d);
|
void setDetectorType(const detectorType d);
|
||||||
PortGeometry getDetectorSize() const;
|
xy getDetectorSize() const;
|
||||||
void setDetectorSize(const int *size);
|
void setDetectorSize(const xy size);
|
||||||
int getModulePositionId() const;
|
int getModulePositionId() const;
|
||||||
void setModulePositionId(const int id);
|
void setModulePositionId(const int id);
|
||||||
std::string getDetectorHostname() const;
|
std::string getDetectorHostname() const;
|
||||||
@ -268,7 +266,7 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
void SetThreadPriorities();
|
void SetThreadPriorities();
|
||||||
void SetupFifoStructure();
|
void SetupFifoStructure();
|
||||||
|
|
||||||
PortGeometry GetPortGeometry();
|
xy GetPortGeometry();
|
||||||
void ResetParametersforNewAcquisition();
|
void ResetParametersforNewAcquisition();
|
||||||
void CreateUDPSockets();
|
void CreateUDPSockets();
|
||||||
void SetupWriter();
|
void SetupWriter();
|
||||||
@ -282,7 +280,7 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
// config parameters
|
// config parameters
|
||||||
detectorType detType{GENERIC};
|
detectorType detType{GENERIC};
|
||||||
PortGeometry numModules = {{1, 1}};
|
xy numModules{1, 1};
|
||||||
int modulePos{0};
|
int modulePos{0};
|
||||||
std::string detHostname;
|
std::string detHostname;
|
||||||
bool silentMode{false};
|
bool silentMode{false};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user