From 753387c34c4f38e83c2552dcf4b2dca9f365e41f Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 4 Feb 2022 13:29:42 +0100 Subject: [PATCH 1/3] gotthard type can only have max 2 modules --- slsDetectorSoftware/src/DetectorImpl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index 15454ab23..c28fe4c0c 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -281,6 +281,13 @@ void DetectorImpl::addModule(const std::string &hostname) { // get type by connecting detectorType type = Module::getTypeFromDetector(host, port); + + // gotthard cannot have more than 2 modules (50um=1, 25um=2 + if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) { + freeSharedMemory(); + throw sls::RuntimeError("Gotthard cannot have more than 2 modules"); + } + auto pos = modules.size(); modules.emplace_back( sls::make_unique(type, detectorIndex, pos, false)); From cfe627d3489422f4a6b6cbc5488345cb5a78cbc0 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 4 Feb 2022 14:47:52 +0100 Subject: [PATCH 2/3] gotthardu25 image reconstruction in gui --- slsDetectorGui/include/qDrawPlot.h | 3 +++ slsDetectorGui/src/qDrawPlot.cpp | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index df96214bf..b13768037 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -91,8 +91,10 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { void Update2dPlot(); void Update1dXYRange(); void Update2dXYRange(); + void rearrangeGotthard25data(double *data); static const int NUM_PEDESTAL_FRAMES = 20; + static const int NUM_GOTTHARD25_CHANS = 2560; sls::Detector *det; slsDetectorDefs::detectorType detType; @@ -164,4 +166,5 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { uint32_t pixelMask{0}; uint32_t gainMask{0}; int gainOffset{0}; + bool gotthard25; }; diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 40edc1538..54a4e129b 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -80,6 +80,10 @@ void qDrawPlot::SetupWidgetWindow() { fileSaveName = "Image"; } + gotthard25 = ((detType == slsDetectorDefs::GOTTHARD2 || + detType == slsDetectorDefs::GOTTHARD) && + det->size() == 2); + SetupPlots(); SetDataCallBack(true); det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), @@ -807,6 +811,11 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, isGainDataExtracted = false; } + // gotthard25um rearranging + if (gotthard25) { + rearrangeGotthard25data(rawData); + } + // title and frame index titles plotTitle = plotTitlePrefix + QString(data->fileName.c_str()).section('/', -1); @@ -1130,6 +1139,19 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, } } +void qDrawPlot::rearrangeGotthard25data(double *data) { + const int nChans = NUM_GOTTHARD25_CHANS; + double temp[nChans] = {0.0}; + int nChansMod = nChans / 2; + for (int i = 0; i != nChansMod; ++i) { + // master module (interleave from front) + temp[i * 2] = data[i]; + // slave module (reverse interleave) + temp[(nChansMod - 1 - i) * 2 + 1] = data[nChansMod + i]; + } + memcpy(data, temp, nChans * sizeof(double)); +} + void qDrawPlot::UpdatePlot() { std::lock_guard lock(mPlots); LOG(logDEBUG) << "Update Plot"; From 06281ccae9944ba709ad0da96d16374513091ec9 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 17 Mar 2022 12:11:51 +0100 Subject: [PATCH 3/3] firmware reverses slave channels --- slsDetectorGui/include/qDrawPlot.h | 2 +- slsDetectorGui/src/qDrawPlot.cpp | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index b13768037..2c8739040 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -94,7 +94,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { void rearrangeGotthard25data(double *data); static const int NUM_PEDESTAL_FRAMES = 20; - static const int NUM_GOTTHARD25_CHANS = 2560; + static const int NUM_GOTTHARD25_CHANS = 1280; sls::Detector *det; slsDetectorDefs::detectorType detType; diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 80b848b49..5101c11dd 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -1156,15 +1156,14 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, void qDrawPlot::rearrangeGotthard25data(double *data) { const int nChans = NUM_GOTTHARD25_CHANS; - double temp[nChans] = {0.0}; - int nChansMod = nChans / 2; - for (int i = 0; i != nChansMod; ++i) { - // master module (interleave from front) + double temp[nChans * 2] = {0.0}; + for (int i = 0; i != nChans; ++i) { + // master module temp[i * 2] = data[i]; - // slave module (reverse interleave) - temp[(nChansMod - 1 - i) * 2 + 1] = data[nChansMod + i]; + // slave module + temp[i * 2 + 1] = data[nChans + i]; } - memcpy(data, temp, nChans * sizeof(double)); + memcpy(data, temp, nChans * 2 * sizeof(double)); } void qDrawPlot::UpdatePlot() {