moved counters in gui from data output tab to settings tab

This commit is contained in:
maliakal_d 2021-06-10 18:07:52 +02:00
parent 1bcf10a211
commit f01e5fd5ec
6 changed files with 304 additions and 273 deletions

View File

@ -533,61 +533,6 @@ Directory where one saves the data.
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="chkCounter1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Counter 1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCounter2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Counter 2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCounter3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Counter 3</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">

View File

@ -32,8 +32,85 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="4">
<widget class="QSpinBox" name="spinThreshold3">
<item row="3" column="3">
<widget class="QCheckBox" name="chkCounter2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="chkCounter3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>3</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2" colspan="3">
<widget class="QComboBox" name="comboDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>1.67772e+07</string>
</property>
</item>
<item>
<property name="text">
<string>65535</string>
</property>
</item>
<item>
<property name="text">
<string>255</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2" colspan="3">
<widget class="QSpinBox" name="spinThreshold">
<property name="enabled">
<bool>false</bool>
</property>
@ -69,8 +146,8 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="spinThreshold">
<item row="1" column="6">
<widget class="QSpinBox" name="spinThreshold3">
<property name="enabled">
<bool>false</bool>
</property>
@ -128,7 +205,7 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="4" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -144,46 +221,7 @@
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="comboDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>1.67772e+07</string>
</property>
</item>
<item>
<property name="text">
<string>65535</string>
</property>
</item>
<item>
<property name="text">
<string>255</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
</widget>
</item>
<item row="1" column="6">
<item row="1" column="8">
<widget class="QPushButton" name="btnSetThreshold">
<property name="enabled">
<bool>true</bool>
@ -280,7 +318,139 @@
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QSpinBox" name="spinThreshold2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="1" column="9">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblCounter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Counters:</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="chkCounter1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2" colspan="3">
<widget class="QComboBox" name="comboSettings">
<property name="enabled">
<bool>true</bool>
@ -424,97 +594,6 @@
</item>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="spinThreshold2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="1" column="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
@ -523,7 +602,6 @@
<tabstop>spinThreshold2</tabstop>
<tabstop>spinThreshold3</tabstop>
<tabstop>btnSetThreshold</tabstop>
<tabstop>comboDynamicRange</tabstop>
</tabstops>
<resources>
<include location="../include/icons.qrc"/>

View File

@ -22,7 +22,6 @@ class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
void SetRateCorrection();
void SetSpeed(int speed);
void SetParallel(bool enable);
void SetCounterMask();
private:
void SetupWidgetWindow();
@ -37,7 +36,6 @@ class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
void GetRateCorrection();
void GetSpeed();
void GetParallel();
void GetCounterMask();
sls::Detector *det;
// Button group for radiobuttons for rate

View File

@ -15,6 +15,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void SetDynamicRange(int index);
void SetThresholdEnergy(int index);
void SetThresholdEnergies();
void SetCounterMask();
private:
void SetupWidgetWindow();
@ -25,6 +26,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void GetDynamicRange();
void GetThresholdEnergy();
void GetThresholdEnergies();
void GetCounterMask();
sls::Detector *det;
enum {

View File

@ -1,9 +1,7 @@
#include "qTabDataOutput.h"
#include "qDefs.h"
#include "sls/bit_utils.h"
#include <QButtonGroup>
#include <QCheckBox>
#include <QFileDialog>
#include <QStandardItemModel>
#include <QString>
@ -25,12 +23,6 @@ void qTabDataOutput::SetupWidgetWindow() {
btnGroupRate = new QButtonGroup(this);
btnGroupRate->addButton(radioDefaultDeadtime, 0);
btnGroupRate->addButton(radioCustomDeadtime, 1);
chkCounter1->setEnabled(false);
chkCounter2->setEnabled(false);
chkCounter3->setEnabled(false);
chkCounter1->hide();
chkCounter2->hide();
chkCounter3->hide();
// enabling according to det type
switch (det->getDetectorType().squash()) {
@ -49,12 +41,6 @@ void qTabDataOutput::SetupWidgetWindow() {
break;
case slsDetectorDefs::MYTHEN3:
chkParallel->setEnabled(true);
chkCounter1->setEnabled(true);
chkCounter2->setEnabled(true);
chkCounter3->setEnabled(true);
chkCounter1->show();
chkCounter2->show();
chkCounter3->show();
break;
case slsDetectorDefs::JUNGFRAU:
lblClkDivider->setEnabled(true);
@ -101,14 +87,6 @@ void qTabDataOutput::Initialization() {
connect(chkParallel, SIGNAL(toggled(bool)), this,
SLOT(SetParallel(bool)));
}
if (chkCounter1->isEnabled()) {
connect(chkCounter1, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
connect(chkCounter2, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
connect(chkCounter3, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
}
// speed
if (comboClkDivider->isEnabled()) {
connect(comboClkDivider, SIGNAL(currentIndexChanged(int)), this,
@ -438,57 +416,6 @@ void qTabDataOutput::SetParallel(bool enable) {
&qTabDataOutput::GetParallel)
}
void qTabDataOutput::GetCounterMask() {
LOG(logDEBUG) << "Getting counter mask";
disconnect(chkCounter1, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
disconnect(chkCounter2, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
disconnect(chkCounter3, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
try {
auto retval = sls::getSetBits(det->getCounterMask().tsquash(
"Counter mask is inconsistent for all detectors."));
std::vector<QCheckBox *> counters = {chkCounter1, chkCounter2,
chkCounter3};
// default to unchecked
for (unsigned int i = 0; i < counters.size(); ++i) {
counters[i]->setChecked(false);
}
// if retva[i] = 2, chkCounter2 is checked
for (unsigned int i = 0; i < retval.size(); ++i) {
if (retval[i] > 3) {
throw sls::RuntimeError(
std::string("Unknown counter index : ") +
std::to_string(static_cast<int>(retval[i])));
}
counters[retval[i]]->setChecked(true);
}
}
CATCH_DISPLAY("Could not get parallel readout.",
"qTabDataOutput::GetParallel")
connect(chkCounter1, SIGNAL(toggled(bool)), this, SLOT(SetCounterMask()));
connect(chkCounter2, SIGNAL(toggled(bool)), this, SLOT(SetCounterMask()));
connect(chkCounter3, SIGNAL(toggled(bool)), this, SLOT(SetCounterMask()));
}
void qTabDataOutput::SetCounterMask() {
std::vector<QCheckBox *> counters = {chkCounter1, chkCounter2, chkCounter3};
uint32_t mask = 0;
for (unsigned int i = 0; i < counters.size(); ++i) {
if (counters[i]->isChecked()) {
mask |= (1 << i);
}
}
LOG(logINFO) << "Setting counter mask to " << mask;
try {
det->setCounterMask(mask);
}
CATCH_HANDLE("Could not set counter mask.",
"qTabDataOutput::SetCounterMask", this,
&qTabDataOutput::GetCounterMask)
}
void qTabDataOutput::Refresh() {
LOG(logDEBUG) << "**Updating DataOutput Tab";
@ -507,9 +434,6 @@ void qTabDataOutput::Refresh() {
if (chkParallel->isEnabled()) {
GetParallel();
}
if (chkCounter1->isEnabled()) {
GetCounterMask();
}
if (comboClkDivider->isEnabled()) {
GetSpeed();
}

View File

@ -1,6 +1,8 @@
#include "qTabSettings.h"
#include "qDefs.h"
#include "sls/ToString.h"
#include "sls/bit_utils.h"
#include <QCheckBox>
#include <QStandardItemModel>
qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector)
@ -18,6 +20,15 @@ void qTabSettings::SetupWidgetWindow() {
spinThreshold3->hide();
btnSetThreshold->hide();
btnSetThreshold->setEnabled(false);
lblCounter->hide();
lblCounter->setEnabled(false);
chkCounter1->setEnabled(false);
chkCounter2->setEnabled(false);
chkCounter3->setEnabled(false);
chkCounter1->hide();
chkCounter2->hide();
chkCounter3->hide();
// enabling according to det type
slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
if (detType == slsDetectorDefs::MYTHEN3) {
@ -32,6 +43,16 @@ void qTabSettings::SetupWidgetWindow() {
spinThreshold3->setEnabled(true);
btnSetThreshold->setEnabled(true);
btnSetThreshold->show();
lblCounter->show();
lblCounter->setEnabled(true);
chkCounter1->setEnabled(true);
chkCounter2->setEnabled(true);
chkCounter3->setEnabled(true);
chkCounter1->show();
chkCounter2->show();
chkCounter3->show();
// disable dr
QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboDynamicRange->model());
@ -153,6 +174,16 @@ void qTabSettings::Initialization() {
else if (spinThreshold->isEnabled())
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetThresholdEnergy(int)));
// counters
if (lblCounter->isEnabled()) {
connect(chkCounter1, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
connect(chkCounter2, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
connect(chkCounter3, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
}
}
void qTabSettings::GetSettings() {
@ -269,7 +300,7 @@ void qTabSettings::GetThresholdEnergies() {
spinThreshold3->setValue(retval[2]);
}
CATCH_DISPLAY("Could not get threshold energy.",
"qTabDataOutput::GetThresholdEnergies")
"qTabSettings::GetThresholdEnergies")
connect(btnSetThreshold, SIGNAL(clicked()), this,
SLOT(SetThresholdEnergies()));
}
@ -284,7 +315,7 @@ void qTabSettings::GetThresholdEnergy() {
spinThreshold->setValue(retval);
}
CATCH_DISPLAY("Could not get threshold energy.",
"qTabDataOutput::GetThresholdEnergy")
"qTabSettings::GetThresholdEnergy")
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetThresholdEnergy(int)));
}
@ -317,6 +348,55 @@ void qTabSettings::SetThresholdEnergy(int index) {
GetThresholdEnergy();
}
void qTabSettings::GetCounterMask() {
LOG(logDEBUG) << "Getting counter mask";
disconnect(chkCounter1, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
disconnect(chkCounter2, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
disconnect(chkCounter3, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
try {
auto retval = sls::getSetBits(det->getCounterMask().tsquash(
"Counter mask is inconsistent for all detectors."));
std::vector<QCheckBox *> counters = {chkCounter1, chkCounter2,
chkCounter3};
// default to unchecked
for (unsigned int i = 0; i < counters.size(); ++i) {
counters[i]->setChecked(false);
}
// if retva[i] = 2, chkCounter2 is checked
for (unsigned int i = 0; i < retval.size(); ++i) {
if (retval[i] > 3) {
throw sls::RuntimeError(
std::string("Unknown counter index : ") +
std::to_string(static_cast<int>(retval[i])));
}
counters[retval[i]]->setChecked(true);
}
}
CATCH_DISPLAY("Could not get counter mask.", "qTabSettings::GetCounterMask")
connect(chkCounter1, SIGNAL(toggled(bool)), this, SLOT(SetCounterMask()));
connect(chkCounter2, SIGNAL(toggled(bool)), this, SLOT(SetCounterMask()));
connect(chkCounter3, SIGNAL(toggled(bool)), this, SLOT(SetCounterMask()));
}
void qTabSettings::SetCounterMask() {
std::vector<QCheckBox *> counters = {chkCounter1, chkCounter2, chkCounter3};
uint32_t mask = 0;
for (unsigned int i = 0; i < counters.size(); ++i) {
if (counters[i]->isChecked()) {
mask |= (1 << i);
}
}
LOG(logINFO) << "Setting counter mask to " << mask;
try {
det->setCounterMask(mask);
}
CATCH_HANDLE("Could not set counter mask.", "qTabSettings::SetCounterMask",
this, &qTabSettings::GetCounterMask)
}
void qTabSettings::Refresh() {
LOG(logDEBUG) << "**Updating Settings Tab";
@ -337,5 +417,9 @@ void qTabSettings::Refresh() {
GetThresholdEnergy();
}
if (lblCounter->isEnabled()) {
GetCounterMask();
}
LOG(logDEBUG) << "**Updated Settings Tab";
}