From d2731c77a3d2e131dde24d30fdb9337ed2ee2c32 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 17 Feb 2022 17:33:16 +0100 Subject: [PATCH] gui 12 bit mode done --- slsDetectorGui/forms/form_tab_settings.ui | 5 +++++ slsDetectorGui/include/qTabSettings.h | 8 +++++++- slsDetectorGui/src/qDrawPlot.cpp | 23 ++++++++++++++++++++++ slsDetectorGui/src/qTabSettings.cpp | 24 +++++++++++++++++------ 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_settings.ui b/slsDetectorGui/forms/form_tab_settings.ui index 32890e2d0..d99e9d9ba 100755 --- a/slsDetectorGui/forms/form_tab_settings.ui +++ b/slsDetectorGui/forms/form_tab_settings.ui @@ -97,6 +97,11 @@ 65535 + + + 4095 + + 255 diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h index 2a2a2c8af..a2a6ad73e 100644 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -69,5 +69,11 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject { enum { DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 }; bool isVisibleFixG0{false}; - enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 }; + enum { + DYNAMICRANGE_32, + DYNAMICRANGE_16, + DYNAMICRANGE_12, + DYNAMICRANGE_8, + DYNAMICRANGE_4 + }; }; diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 40edc1538..062bc2eb1 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -1064,6 +1064,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, // mythen3 / gotthard2 debugging int discardBits = numDiscardBits; + uint16_t temp = 0; switch (dr) { case 4: @@ -1083,6 +1084,28 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, } break; + case 12: + for (ichan = 0; ichan < size; ++ichan) { + // first 12 bit pixel + // lsb (8 bytes) + temp = (*((u_int8_t *)source)) & 0xFF; + ++source; + // msb (4 bytes) + temp |= (((*((u_int8_t *)source)) & 0xF) << 8); + dest[ichan] = (double)temp; + + // second 12bit pixel + ++ichan; + // lsb (4 bytes) + temp = (((*((u_int8_t *)source)) & 0xF0) >> 4); + ++source; + // msb (8 bytes) + temp |= (((*((u_int8_t *)source)) & 0xFF) << 4); + ++source; + dest[ichan] = (double)temp; + } + break; + case 16: if (detType == slsDetectorDefs::JUNGFRAU || detType == slsDetectorDefs::GOTTHARD2) { diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index dcee0a450..9a3d97132 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -60,13 +60,19 @@ void qTabSettings::SetupWidgetWindow() { QStandardItemModel *model = qobject_cast(comboDynamicRange->model()); if (model) { - QModelIndex index; QStandardItem *item; - index = - model->index(DYNAMICRANGE_4, comboDynamicRange->modelColumn(), - comboDynamicRange->rootModelIndex()); - item = model->itemFromIndex(index); - item->setEnabled(false); + int dr = DYNAMICRANGE_4; + for (int i = 0; i != 2; ++i) { + // disable dr 4 + QModelIndex index = + model->index(dr, comboDynamicRange->modelColumn(), + comboDynamicRange->rootModelIndex()); + item = model->itemFromIndex(index); + item->setEnabled(false); + + // disable dr 12 + dr = DYNAMICRANGE_12; + } } } else if (detType == slsDetectorDefs::EIGER) { lblDynamicRange->setEnabled(true); @@ -305,6 +311,9 @@ void qTabSettings::GetDynamicRange() { case 16: comboDynamicRange->setCurrentIndex(DYNAMICRANGE_16); break; + case 12: + comboDynamicRange->setCurrentIndex(DYNAMICRANGE_12); + break; case 8: comboDynamicRange->setCurrentIndex(DYNAMICRANGE_8); break; @@ -333,6 +342,9 @@ void qTabSettings::SetDynamicRange(int index) { case DYNAMICRANGE_16: det->setDynamicRange(16); break; + case DYNAMICRANGE_12: + det->setDynamicRange(12); + break; case DYNAMICRANGE_8: det->setDynamicRange(8); break;