From 1484d038de0a1f02a3e12440cac2d1552d72d743 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 3 Oct 2023 17:22:03 +0200 Subject: [PATCH] 7.03.rc: update 2d gain plot color map (if no x and ymin/max changes or window resizing): setFixedWidth was updating for window resize, updated virtual servers for g2 and jungfrau to keep changing gain and data for every frame. the data value (#818) --- slsDetectorGui/src/qDrawPlot.cpp | 2 ++ .../slsDetectorFunctionList.c | 21 +++++++++++++++++ .../slsDetectorFunctionList.c | 23 +++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index d1a233731..8617c8206 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -193,6 +193,7 @@ void qDrawPlot::SetupPlots() { gainplot2d = new SlsQt2DPlot(boxPlot, true); gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); + gainplot2d->Update(); gainplot2d->hide(); connect(plot2d, SIGNAL(PlotZoomedSignal(const QRectF &)), this, SLOT(Zoom2DGainPlot(const QRectF &))); @@ -1009,6 +1010,7 @@ void qDrawPlot::Update2dPlot() { if (isGainDataExtracted) { gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); + gainplot2d->Update(); if (!gainplot2d->isVisible()) { gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 886d947ee..73d8a5eb0 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -3323,6 +3323,27 @@ void *start_timer(void *arg) { break; } + // change gain and data for every frame + { + const int nchannels = NCHIP * NCHAN; + int gainVal = 0; + for (int i = 0; i < nchannels; ++i) { + if ((i % nchannels) < 400) { + gainVal = 1 + frameNr; + } else if ((i % nchannels) < 800) { + gainVal = 2 + frameNr; + } else { + gainVal = 3 + frameNr; + } + int dataVal = + *((uint16_t *)(imageData + i * sizeof(uint16_t))); + dataVal += frameNr; + int channelVal = + (dataVal & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST); + *((uint16_t *)(imageData + i * sizeof(uint16_t))) = + (uint16_t)channelVal; + } + } // sleep for exposure time struct timespec begin, end; clock_gettime(CLOCK_REALTIME, &begin); diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 0309d5396..ca0a78a36 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -2632,6 +2632,7 @@ void *start_timer(void *arg) { if (i % pixelsPerPacket == 0) { ++dataVal; } + if ((i % 1024) < 300) { gainVal = 1; } else if ((i % 1024) < 600) { @@ -2672,6 +2673,28 @@ void *start_timer(void *arg) { clock_gettime(CLOCK_REALTIME, &begin); usleep(expUs); + // change gain and data for every frame + { + const int npixels = (NCHAN * NCHIP); + for (int i = 0; i < npixels; ++i) { + int gainVal = 0; + if ((i % 1024) < 300) { + gainVal = 1 + iframes; + } else if ((i % 1024) < 600) { + gainVal = 2 + iframes; + } else { + gainVal = 3 + iframes; + } + int dataVal = + *((uint16_t *)(imageData + i * sizeof(uint16_t))); + dataVal += iframes; + int pixelVal = + (dataVal & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST); + *((uint16_t *)(imageData + i * sizeof(uint16_t))) = + (uint16_t)pixelVal; + } + } + int srcOffset = 0; int srcOffset2 = DATA_BYTES / 2; int row0 = (numInterfaces == 1 ? detPos[1] : detPos[3]);