diff --git a/slsDetectorGui/forms/form_tab_dataoutput.ui b/slsDetectorGui/forms/form_tab_dataoutput.ui
index a7b0bb707..c102d8c49 100755
--- a/slsDetectorGui/forms/form_tab_dataoutput.ui
+++ b/slsDetectorGui/forms/form_tab_dataoutput.ui
@@ -533,6 +533,61 @@ Directory where one saves the data.
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Expanding
+
+
+
+ 10
+ 20
+
+
+
+
+ -
+
+
+ false
+
+
+ Counter 1
+
+
+ true
+
+
+
+ -
+
+
+ false
+
+
+ Counter 2
+
+
+ true
+
+
+
+ -
+
+
+ false
+
+
+ Counter 3
+
+
+ true
+
+
+
-
diff --git a/slsDetectorGui/include/qTabDataOutput.h b/slsDetectorGui/include/qTabDataOutput.h
index 8f753a6db..35d088268 100644
--- a/slsDetectorGui/include/qTabDataOutput.h
+++ b/slsDetectorGui/include/qTabDataOutput.h
@@ -22,6 +22,7 @@ class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
void SetRateCorrection();
void SetSpeed(int speed);
void SetParallel(bool enable);
+ void SetCounterMask();
private:
void SetupWidgetWindow();
@@ -36,6 +37,7 @@ class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
void GetRateCorrection();
void GetSpeed();
void GetParallel();
+ void GetCounterMask();
sls::Detector *det;
// Button group for radiobuttons for rate
diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp
index f750b7cba..dec28ecad 100644
--- a/slsDetectorGui/src/qTabDataOutput.cpp
+++ b/slsDetectorGui/src/qTabDataOutput.cpp
@@ -1,7 +1,9 @@
#include "qTabDataOutput.h"
#include "qDefs.h"
+#include "sls/bit_utils.h"
#include
+#include
#include
#include
#include
@@ -23,6 +25,12 @@ 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()) {
@@ -41,6 +49,12 @@ 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);
@@ -87,6 +101,14 @@ 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,
@@ -416,6 +438,55 @@ 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 counters = {chkCounter1, chkCounter2,
+ chkCounter3};
+ for (unsigned int i = 0; i < counters.size(); ++i) {
+ counters[i]->setChecked(false);
+ }
+ 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(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 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";
@@ -434,6 +505,9 @@ void qTabDataOutput::Refresh() {
if (chkParallel->isEnabled()) {
GetParallel();
}
+ if (chkCounter1->isEnabled()) {
+ GetCounterMask();
+ }
if (comboClkDivider->isEnabled()) {
GetSpeed();
}