mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
added counters for m3 gui
This commit is contained in:
parent
ac5dece221
commit
b9aa7bcc8e
@ -533,6 +533,61 @@ 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">
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include "qTabDataOutput.h"
|
||||
#include "qDefs.h"
|
||||
#include "sls/bit_utils.h"
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QCheckBox>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardItemModel>
|
||||
#include <QString>
|
||||
@ -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<QCheckBox *> 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<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";
|
||||
|
||||
@ -434,6 +505,9 @@ void qTabDataOutput::Refresh() {
|
||||
if (chkParallel->isEnabled()) {
|
||||
GetParallel();
|
||||
}
|
||||
if (chkCounter1->isEnabled()) {
|
||||
GetCounterMask();
|
||||
}
|
||||
if (comboClkDivider->isEnabled()) {
|
||||
GetSpeed();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user