From 4f0634fe6271dfb6aae32637aa33d28094f7244f Mon Sep 17 00:00:00 2001 From: Dhanya Thattil <33750417+thattil@users.noreply.github.com> Date: Thu, 29 Aug 2019 10:12:10 +0200 Subject: [PATCH] adc invert for highz (#59) --- slsDetectorGui/forms/form_tab_plot.ui | 23 +++++++++- slsDetectorGui/include/qDrawPlot.h | 2 + slsDetectorGui/src/qDrawPlot.cpp | 66 ++++++++++++++++++++++----- slsDetectorGui/src/qTabPlot.cpp | 6 +++ 4 files changed, 84 insertions(+), 13 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 66c98e264..45beba9fa 100755 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -164,7 +164,7 @@ - 0 + 5 @@ -643,6 +643,27 @@ Displays minimum, maximum and sum of values for each plot. + + + + false + + + + 0 + 0 + + + + <nobr> +Displays minimum, maximum and sum of values for each plot. +<nobr> + + + ADC Invert + + + diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 053a8c86a..2496ce16e 100755 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -55,6 +55,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { void ResetAccumulate(); void DisplayStatistics(bool enable); void EnableGainPlot(bool enable); + void EnableADCInvert(bool enable); void ClonePlot(); void SavePlot(); @@ -147,6 +148,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { QString fileSaveName{"Image"}; bool hasGainData{false}; bool isGainDataExtracted{false}; + bool isADCInvert{false}; bool disableZoom{false}; int progress{0}; diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 9fd26c670..75f93390d 100755 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -416,6 +416,11 @@ void qDrawPlot::EnableGainPlot(bool enable) { hasGainData = enable; } +void qDrawPlot::EnableADCInvert(bool enable) { + FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " ADC Invert"; + isADCInvert = enable; +} + void qDrawPlot::SetSaveFileName(QString val) { FILE_LOG(logDEBUG) << "Setting Clone/Save File Name to " << val.toAscii().constData(); fileSaveName = val; @@ -895,25 +900,62 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data // show gain plot if (gaindest != NULL) { - for (ichan = 0; ichan < size; ++ichan) { - if ((*((u_int16_t *)source)) == 0xFFFF) { - gaindest[ichan] = 0xFFFF; - dest[ichan] = 0xFFFF; - } else { - gaindest[ichan] = - (((*((u_int16_t *)source)) & 0xC000) >> 14); - dest[ichan] = ((*((u_int16_t *)source)) & 0x3FFF); + // adcinvert + if (isADCInvert) { + for (ichan = 0; ichan < size; ++ichan) { + uint16_t temp = (*((u_int16_t *)source)); + if (temp == 0xFFFF) { + gaindest[ichan] = 0xFFFF; + dest[ichan] = 0xFFFF; + } else { + gaindest[ichan] = ((temp & 0xC000) >> 14); + dest[ichan] = 0x4000 - (temp & 0x3FFF); + } + source += 2; + } + } + // normal + else { + for (ichan = 0; ichan < size; ++ichan) { + uint16_t temp = (*((u_int16_t *)source)); + if (temp == 0xFFFF) { + gaindest[ichan] = 0xFFFF; + dest[ichan] = 0xFFFF; + } else { + gaindest[ichan] = ((temp & 0xC000) >> 14); + dest[ichan] = (temp & 0x3FFF); + } + source += 2; } - source += 2; } } // only data plot else { - for (ichan = 0; ichan < size; ++ichan) { - dest[ichan] = ((*((u_int16_t *)source)) & 0x3FFF); - source += 2; + // adcinvert + if (isADCInvert) { + for (ichan = 0; ichan < size; ++ichan) { + uint16_t temp = (*((u_int16_t *)source)); + if (temp == 0xFFFF) { + dest[ichan] = 0xFFFF; + } else { + dest[ichan] = 0x4000 - (temp & 0x3FFF); + } + source += 2; + } } + // normal + else { + for (ichan = 0; ichan < size; ++ichan) { + uint16_t temp = (*((u_int16_t *)source)); + if (temp == 0xFFFF) { + dest[ichan] = 0xFFFF; + } else { + dest[ichan] = (temp & 0x3FFF); + } + source += 2; + } + } } break; } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 85a0b150e..d21f2e125 100755 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -67,6 +67,7 @@ void qTabPlot::SetupWidgetWindow() { case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::MOENCH: chkGainPlot->setEnabled(true); + chkADCInvert->setEnabled(true); break; default: break; @@ -129,6 +130,9 @@ void qTabPlot::Initialization() { // gap pixels if (chkGapPixels->isEnabled()) connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); + // adc invert + if (chkADCInvert->isEnabled()) + connect(chkADCInvert, SIGNAL(toggled(bool)), plot, SLOT(EnableADCInvert(bool))); // Save, clone connect(btnSave, SIGNAL(clicked()), plot, SLOT(SavePlot())); @@ -576,6 +580,7 @@ void qTabPlot::Refresh() { case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::MOENCH: chkGainPlot->setEnabled(true); + chkADCInvert->setEnabled(true); break; default: break; @@ -585,6 +590,7 @@ void qTabPlot::Refresh() { boxFrequency->setEnabled(false); chkGainPlot->setEnabled(false); chkGapPixels->setEnabled(false); + chkADCInvert->setEnabled(false); } FILE_LOG(logDEBUG) << "**Updated Plot Tab";