WIP Settings

This commit is contained in:
2019-06-07 10:58:47 +02:00
parent 48dd0fb084
commit ca5a0b4cc8
7 changed files with 129 additions and 172 deletions

View File

@ -101,11 +101,6 @@
<string>Very High Gain</string> <string>Very High Gain</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Low Noise</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Dynamic HG0</string> <string>Dynamic HG0</string>

View File

@ -9,7 +9,7 @@ class multiSlsDetector;
/** /**
*@short sets up the Settings parameters *@short sets up the Settings parameters
*/ */
class qTabSettings:public QWidget, private Ui::TabSettingsObject{ class qTabSettings: public QWidget, private Ui::TabSettingsObject{
Q_OBJECT Q_OBJECT
public: public:
@ -34,20 +34,21 @@ public:
private slots: private slots:
/** /**
* Set settings according to selection * Set settings according to selection
* @param index index of selection * @param index index of selection
*/ */
void SetSettings(int index); void SetSettings(int index);
/** /**
* Set dynamic range if possible * Set dynamic range if possible
* @param index selection * @param index selection
*/ */
void SetDynamicRange(int index); void SetDynamicRange(int index);
/** /**
* Set threshold energy * Set threshold energy
* @param index selection
*/ */
void SetEnergy(); void SetThresholdEnergy(int index);
private: private:
@ -85,9 +86,29 @@ private:
/** The sls detector object */ /** The sls detector object */
multiSlsDetector *myDet; multiSlsDetector *myDet;
enum{STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, LOWNOISE, enum {
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, VERLOWGAIN, STANDARD,
UNDEFINED, UNINITIALIZED, NUMSETTINGS}; FAST,
HIGHGAIN,
static const int THRESHOLD_TOLERANCE = 200; DYNAMICGAIN,
LOWGAIN,
MEDIUMGAIN,
VERYHIGHGAIN,
DYNAMICHG0,
FIXGAIN1,
FIXGAIN2,
FORCESWITCHG1,
FORCESWITCHG2,
VERLOWGAIN,
UNDEFINED,
UNINITIALIZED,
NUMSETTINGS
};
enum {
DYNAMICRANGE_32,
DYNAMICRANGE_16,
DYNAMICRANGE_8,
DYNAMICRANGE_4
};
}; };

View File

@ -24,21 +24,17 @@ void qTabAdvanced::SetupWidgetWindow(){
errOnlineTip = QString("<nobr><br><br><font color=\"red\"><nobr>It is offline!</nobr></font>"); errOnlineTip = QString("<nobr><br><br><font color=\"red\"><nobr>It is offline!</nobr></font>");
// enabling according to det type // enabling according to det type
switch((int)myDet->getDetectorTypeAsEnum()) { switch(myDet->getDetectorTypeAsEnum()) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
// trimming
tab_trimming->setEnabled(true); tab_trimming->setEnabled(true);
lblSubExpTime->setEnabled(true); lblSubExpTime->setEnabled(true);
// subexptime
spinSubExpTime->setEnabled(true); spinSubExpTime->setEnabled(true);
comboSubExpTimeUnit->setEnabled(true); comboSubExpTimeUnit->setEnabled(true);
// subdeadtime
lblSubDeadTime->setEnabled(true); lblSubDeadTime->setEnabled(true);
spinSubDeadTime->setEnabled(true); spinSubDeadTime->setEnabled(true);
comboSubDeadTimeUnit->setEnabled(true); comboSubDeadTimeUnit->setEnabled(true);
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
// roi
tab_roi->setEnabled(true); tab_roi->setEnabled(true);
break; break;
default: default:

View File

@ -15,24 +15,22 @@ qTabDataOutput::qTabDataOutput(QWidget *parent, multiSlsDetector *detector) : QW
FILE_LOG(logDEBUG) << "DataOutput ready"; FILE_LOG(logDEBUG) << "DataOutput ready";
} }
qTabDataOutput::~qTabDataOutput() {} qTabDataOutput::~qTabDataOutput() {}
void qTabDataOutput::SetupWidgetWindow() { void qTabDataOutput::SetupWidgetWindow() {
// button group for rate // button group for rate
btnGroupRate = new QButtonGroup(this); btnGroupRate = new QButtonGroup(this);
btnGroupRate->addButton(radioDefaultDeadtime, 0); btnGroupRate->addButton(radioDefaultDeadtime, 0);
btnGroupRate->addButton(radioCustomDeadtime, 1); btnGroupRate->addButton(radioCustomDeadtime, 1);
// enabling according to det type // enabling according to det type
switch((int)myDet->getDetectorTypeAsEnum()) { switch(myDet->getDetectorTypeAsEnum()) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
chkTenGiga->setEnabled(true); chkTenGiga->setEnabled(true);
chkRate->setEnabled(true); chkRate->setEnabled(true);
radioDefaultDeadtime->setEnabled(true); radioDefaultDeadtime->setEnabled(true);
radioCustomDeadtime->setEnabled(true); radioCustomDeadtime->setEnabled(true);
// flags and speed
widgetEiger->setVisible(true); widgetEiger->setVisible(true);
widgetEiger->setEnabled(true); widgetEiger->setEnabled(true);
break; break;
@ -50,6 +48,7 @@ void qTabDataOutput::SetupWidgetWindow() {
} }
void qTabDataOutput::Initialization() { void qTabDataOutput::Initialization() {
// ourdir, fileformat, overwrite enable
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir())); connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir()));
@ -58,11 +57,13 @@ void qTabDataOutput::Initialization() {
if (chkTenGiga->isEnabled()) { if (chkTenGiga->isEnabled()) {
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool))); connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
} }
// rate
if (chkRate->isEnabled()) { if (chkRate->isEnabled()) {
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection())); connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection())); connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
} }
// flags, speed
if (widgetEiger->isEnabled()) { if (widgetEiger->isEnabled()) {
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int))); connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
@ -170,7 +171,7 @@ void qTabDataOutput::GetFileFormat() {
comboFileFormat->setCurrentIndex(static_cast<int>(retval)); comboFileFormat->setCurrentIndex(static_cast<int>(retval));
break; break;
default: default:
qDefs::Message(qDefs::WARNING, std::string("Unknown file format.") + std::to_string(static_cast<int>(retval)), "qTabDataOutput::GetFileFormat"); qDefs::Message(qDefs::WARNING, std::string("Unknown file format: ") + std::to_string(static_cast<int>(retval)), "qTabDataOutput::GetFileFormat");
break; break;
} }
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
@ -325,7 +326,7 @@ void qTabDataOutput::GetSpeed() {
comboEigerClkDivider->setCurrentIndex(retval); comboEigerClkDivider->setCurrentIndex(retval);
break; break;
default: default:
qDefs::Message(qDefs::WARNING, std::string("Unknown speed.") + std::to_string(retval), "qTabDataOutput::GetFileFormat"); qDefs::Message(qDefs::WARNING, std::string("Unknown speed: ") + std::to_string(retval), "qTabDataOutput::GetFileFormat");
break; break;
} }
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
@ -361,7 +362,7 @@ void qTabDataOutput::GetFlags() {
else if (retval & slsDetectorDefs::CONTINOUS_RO) else if (retval & slsDetectorDefs::CONTINOUS_RO)
comboEigerFlags1->setCurrentIndex(CONTINUOUS); comboEigerFlags1->setCurrentIndex(CONTINUOUS);
else { else {
qDefs::Message(qDefs::WARNING, std::string("Unknown flag (Not Store in ram or Continous).") + std::to_string(retval), "qTabDataOutput::GetFlags"); qDefs::Message(qDefs::WARNING, std::string("Unknown flag (Not Store in ram or Continous): ") + std::to_string(retval), "qTabDataOutput::GetFlags");
} }
// parallel or non parallel // parallel or non parallel
@ -370,7 +371,7 @@ void qTabDataOutput::GetFlags() {
else if (retval & slsDetectorDefs::NONPARALLEL) else if (retval & slsDetectorDefs::NONPARALLEL)
comboEigerFlags2->setCurrentIndex(NONPARALLEL); comboEigerFlags2->setCurrentIndex(NONPARALLEL);
else { else {
qDefs::Message(qDefs::WARNING, std::string("Unknown flag (Not Parallel or Non Parallel).") + std::to_string(retval), "qTabDataOutput::GetFlags"); qDefs::Message(qDefs::WARNING, std::string("Unknown flag (Not Parallel or Non Parallel): ") + std::to_string(retval), "qTabDataOutput::GetFlags");
} }
} }
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {

View File

@ -7,9 +7,7 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
qTabSettings::qTabSettings(QWidget *parent, multiSlsDetector *detector) qTabSettings::qTabSettings(QWidget *parent, multiSlsDetector *detector): QWidget(parent), myDet(detector) {
: QWidget(parent), myDet(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Settings ready"; FILE_LOG(logDEBUG) << "Settings ready";
@ -19,96 +17,62 @@ qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() { void qTabSettings::SetupWidgetWindow() {
// enabling according to det type
switch(myDet->getDetectorTypeAsEnum()) { switch(myDet->getDetectorTypeAsEnum()) {
case slsDetectorDefs::MOENCH:
case MOENCH:
lblSettings->setEnabled(false); lblSettings->setEnabled(false);
comboSettings->setEnabled(false); comboSettings->setEnabled(false);
break; break;
case slsDetectorDefs::EIGER:
case EIGER:
lblDynamicRange->setEnabled(true); lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true); comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true); lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true); spinThreshold->setEnabled(true);
break; break;
default: default:
break; break;
} }
Initialization(); // default settings for the disabled
// Settings
comboSettings->setCurrentIndex(UNINITIALIZED); comboSettings->setCurrentIndex(UNINITIALIZED);
if (comboSettings->isEnabled()) { if (comboSettings->isEnabled()) {
SetupDetectorSettings(); SetupDetectorSettings();
GetSettings();
} }
spinThreshold->setValue(-1);
// Dynamic Range (update it anyway) Initialization();
// default for the disabled
GetDynamicRange(); GetDynamicRange();
// get threshold Refresh();
spinThreshold->setValue(-1);
if (spinThreshold->isEnabled())
GetThresholdEnergy();
} }
void qTabSettings::SetupDetectorSettings() { void qTabSettings::SetupDetectorSettings() {
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(comboSettings->model());
// To be able to index items on a combo box
QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboSettings->model());
if (model) { if (model) {
QModelIndex index[NUMSETTINGS]; QModelIndex index[NUMSETTINGS];
QStandardItem *item[NUMSETTINGS]; QStandardItem *item[NUMSETTINGS];
for (int i = 0; i < NUMSETTINGS; ++i) { for (int i = 0; i < NUMSETTINGS; ++i) {
index[i] = model->index(i, comboSettings->modelColumn(), index[i] = model->index(i, comboSettings->modelColumn(), comboSettings->rootModelIndex());
comboSettings->rootModelIndex());
item[i] = model->itemFromIndex(index[i]); item[i] = model->itemFromIndex(index[i]);
item[i]->setEnabled(false);
} }
switch (myDet->getDetectorTypeAsEnum()) {
item[(int)UNDEFINED]->setEnabled(false);
item[(int)UNINITIALIZED]->setEnabled(false);
switch (detType) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
item[(int)STANDARD]->setEnabled(true); item[(int)STANDARD]->setEnabled(true);
item[(int)HIGHGAIN]->setEnabled(true); item[(int)HIGHGAIN]->setEnabled(true);
item[(int)LOWGAIN]->setEnabled(true); item[(int)LOWGAIN]->setEnabled(true);
item[(int)VERYHIGHGAIN]->setEnabled(true); item[(int)VERYHIGHGAIN]->setEnabled(true);
item[(int)VERLOWGAIN]->setEnabled(true); item[(int)VERLOWGAIN]->setEnabled(true);
item[(int)FAST]->setEnabled(false);
item[(int)DYNAMICGAIN]->setEnabled(false);
item[(int)MEDIUMGAIN]->setEnabled(false);
item[(int)LOWNOISE]->setEnabled(false);
item[(int)DYNAMICHG0]->setEnabled(false);
item[(int)FIXGAIN1]->setEnabled(false);
item[(int)FIXGAIN2]->setEnabled(false);
item[(int)FORCESWITCHG1]->setEnabled(false);
item[(int)FORCESWITCHG2]->setEnabled(false);
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
item[(int)HIGHGAIN]->setEnabled(true); item[(int)HIGHGAIN]->setEnabled(true);
item[(int)DYNAMICGAIN]->setEnabled(true); item[(int)DYNAMICGAIN]->setEnabled(true);
item[(int)LOWGAIN]->setEnabled(true); item[(int)LOWGAIN]->setEnabled(true);
item[(int)MEDIUMGAIN]->setEnabled(true); item[(int)MEDIUMGAIN]->setEnabled(true);
item[(int)VERYHIGHGAIN]->setEnabled(true); item[(int)VERYHIGHGAIN]->setEnabled(true);
item[(int)STANDARD]->setEnabled(false);
item[(int)FAST]->setEnabled(false);
item[(int)LOWNOISE]->setEnabled(false);
item[(int)DYNAMICHG0]->setEnabled(false);
item[(int)FIXGAIN1]->setEnabled(false);
item[(int)FIXGAIN2]->setEnabled(false);
item[(int)FORCESWITCHG1]->setEnabled(false);
item[(int)FORCESWITCHG2]->setEnabled(false);
item[(int)VERLOWGAIN]->setEnabled(false);
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
item[(int)DYNAMICGAIN]->setEnabled(true); item[(int)DYNAMICGAIN]->setEnabled(true);
item[(int)DYNAMICHG0]->setEnabled(true); item[(int)DYNAMICHG0]->setEnabled(true);
@ -116,22 +80,11 @@ void qTabSettings::SetupDetectorSettings() {
item[(int)FIXGAIN2]->setEnabled(true); item[(int)FIXGAIN2]->setEnabled(true);
item[(int)FORCESWITCHG1]->setEnabled(true); item[(int)FORCESWITCHG1]->setEnabled(true);
item[(int)FORCESWITCHG2]->setEnabled(true); item[(int)FORCESWITCHG2]->setEnabled(true);
item[(int)STANDARD]->setEnabled(false);
item[(int)FAST]->setEnabled(false);
item[(int)HIGHGAIN]->setEnabled(false);
item[(int)LOWGAIN]->setEnabled(false);
item[(int)MEDIUMGAIN]->setEnabled(false);
item[(int)VERYHIGHGAIN]->setEnabled(false);
item[(int)LOWNOISE]->setEnabled(false);
item[(int)VERLOWGAIN]->setEnabled(false);
break; break;
default: default:
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI."; FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
qDefs::Message(qDefs::CRITICAL, qDefs::Message(qDefs::CRITICAL,
"Unknown detector type. Exiting GUI.", "Unknown detector type. Exiting GUI.", "qTabSettings::SetupDetectorSettings");
"qTabSettings::SetupDetectorSettings");
exit(-1); exit(-1);
} }
} }
@ -148,7 +101,7 @@ void qTabSettings::Initialization() {
// Threshold // Threshold
if (spinThreshold->isEnabled()) if (spinThreshold->isEnabled())
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int)));
} }
void qTabSettings::GetSettings() { void qTabSettings::GetSettings() {
@ -156,12 +109,10 @@ void qTabSettings::GetSettings() {
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
try{ try{
int sett = myDet->getSettings(-1); auto retval = myDet->getSettings(-1);
FILE_LOG(logDEBUG) << "Settings from Detector:" << sett; switch (retval) {
switch (sett) {
case -1: case -1:
qDefs::Message(qDefs::WARNING, "Different values for settings.", "qTabSettings::GetSettings"); qDefs::Message(qDefs::WARNING, "Settings are inconsistent for all detectors.", "qTabSettings::GetSettings");
comboSettings->setCurrentIndex(UNDEFINED);
break; break;
case slsDetectorDefs::UNDEFINED: case slsDetectorDefs::UNDEFINED:
comboSettings->setCurrentIndex(UNDEFINED); comboSettings->setCurrentIndex(UNDEFINED);
@ -170,16 +121,17 @@ void qTabSettings::GetSettings() {
comboSettings->setCurrentIndex(UNINITIALIZED); comboSettings->setCurrentIndex(UNINITIALIZED);
break; break;
default: default:
if (sett >= NUMSETTINGS) { if ((int)retval < -1 || (int)retval >= NUMSETTINGS) {
qDefs::Message(qDefs::WARNING, "Unknown settings " + std::to_string(sett) + ".", "qTabSettings::GetSettings"); qDefs::Message(qDefs::WARNING, std::string("Unknown settings: ") + std::to_string(retval), "qTabSettings::GetSettings");
return; } else {
comboSettings->setCurrentIndex(retval);
} }
comboSettings->setCurrentIndex(sett);
break; break;
} }
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get settings.", e.what(), "qTabSettings::GetSettings"); qDefs::ExceptionMessage("Could not get settings.", e.what(), "qTabSettings::GetSettings");
} }
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
} }
@ -188,53 +140,62 @@ void qTabSettings::GetDynamicRange() {
disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
try { try {
int ret = myDet->setDynamicRange(-1); auto retval = myDet->setDynamicRange(-1);
// set the final value on gui // set the final value on gui
switch (ret) { switch (retval) {
case -1: case -1:
qDefs::Message(qDefs::WARNING, "Different values for dynamic range.", "qTabSettings::GetDynamicRange"); qDefs::Message(qDefs::WARNING, "Dynamic Range is inconsistent for all detectors.", "qTabSettings::GetDynamicRange");
break; break;
case 32: case 32:
comboDynamicRange->setCurrentIndex(0); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_32);
break; break;
case 16: case 16:
comboDynamicRange->setCurrentIndex(1); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_16);
break; break;
case 8: case 8:
comboDynamicRange->setCurrentIndex(2); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_8);
break; break;
case 4: case 4:
comboDynamicRange->setCurrentIndex(3); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
break; break;
default: default:
qDefs::Message(qDefs::WARNING, "Unknown Dynamic Range " + std::to_string(ret) + ".", "qTabSettings::GetDynamicRange"); qDefs::Message(qDefs::WARNING, std::string("Unknown dynamic range: ") + std::to_string(retval), "qTabSettings::GetDynamicRange");
break; break;
} }
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get dynamic range.", e.what(), "qTabSettings::GetDynamicRange"); qDefs::ExceptionMessage("Could not get dynamic range.", e.what(), "qTabSettings::GetDynamicRange");
} }
connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int))); connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int)));
} }
void qTabSettings::GetThresholdEnergy() { void qTabSettings::GetThresholdEnergy() {
FILE_LOG(logDEBUG) << "Getting theshold energy"; FILE_LOG(logDEBUG) << "Getting theshold energy";
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy()));
qDefs::IgnoreNonCriticalExceptions<QSpinBox>(
myDet, try {
"Could not get threshold energy." auto retval = myDet->getThresholdEnergy();
"qTabSettings::GetThresholdEnergy", if (retval == -1) {
spinThreshold, qDefs::Message(qDefs::WARNING, "Threshold Energy is inconsistent for all detectors.", "qTabDataOutput::GetThresholdEnergy");
&QSpinBox::setValue, spinThreshold->setValue(-1);
&multiSlsDetector::getThresholdEnergy, -1); } else {
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); spinThreshold->setValue(retval);
}
} catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get threshold energy.", e.what(), "qTabDataOutput::GetThresholdEnergy");
}
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy()));
} }
void qTabSettings::SetSettings(int index) { void qTabSettings::SetSettings(int index) {
// settings // settings
auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
FILE_LOG(logINFO) << "Setting Settings to " << myDet->slsDetectorDefs::getDetectorSettings(val);
try { try {
myDet->setSettings((slsDetectorDefs::detectorSettings)index); myDet->setSettings(val);
FILE_LOG(logINFO) << "Settings set to " << myDet->slsDetectorDefs::getDetectorSettings(sett);
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not set settings.", e.what(), "qTabSettings::SetSettings"); qDefs::ExceptionMessage("Could not set settings.", e.what(), "qTabSettings::SetSettings");
GetSettings(); GetSettings();
@ -242,75 +203,63 @@ void qTabSettings::SetSettings(int index) {
// threshold // threshold
if (spinThreshold->isEnabled()) { if (spinThreshold->isEnabled()) {
SetEnergy(); SetThresholdEnergy(spinThreshold->value());
} }
} }
void qTabSettings::SetDynamicRange(int index) { void qTabSettings::SetDynamicRange(int index) {
int dr = -1;
switch (index) {
case 0:
dr = 32;
break;
case 1:
dr = 16;
break;
case 2:
dr = 8;
break;
case 3:
dr = 4;
break;
default:
qDefs::Message(qDefs::WARNING, "Unknown dynamic range " + std::to_string(index) + ".", "qTabSettings::SetDynamicRange");
return;
}
try { try {
myDet->setDynamicRange(dr); switch (index) {
FILE_LOG(logINFO) << "Setting dynamic range to " << dr; case DYNAMICRANGE_32:
FILE_LOG(logINFO) << "Setting dynamic range to 32";
myDet->setDynamicRange(32);
break;
case DYNAMICRANGE_16:
FILE_LOG(logINFO) << "Setting dynamic range to 16";
myDet->setDynamicRange(16);
break;
case DYNAMICRANGE_8:
FILE_LOG(logINFO) << "Setting dynamic range to 8";
myDet->setDynamicRange(8);
break;
case DYNAMICRANGE_4:
FILE_LOG(logINFO) << "Setting dynamic range to 4";
myDet->setDynamicRange(4);
break;
default:
qDefs::Message(qDefs::WARNING, std::string("Unknown dynamic range: ") + std::to_string(index), "qTabSettings::SetDynamicRange");
break;
}
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not set dynamic range.", e.what(), "qTabSettings::SetDynamicRange"); qDefs::ExceptionMessage("Could not set dynamic range.", e.what(), "qTabSettings::SetDynamicRange");
GetDynamicRange(); GetDynamicRange();
} }
} }
void qTabSettings::SetEnergy() { void qTabSettings::SetThresholdEnergy(int index) {
FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
try { try {
// set myDet->setThresholdEnergy(index);
int index = spinThreshold->value();
int ret = myDet->setThresholdEnergy(index);
FILE_LOG(logINFO) << "Threshold energy set to " << index;
// validate
if ((ret - index) > THRESHOLD_TOLERANCE) {
qDefs::Message(qDefs::WARNING,
"Threshold energy could not be set (tolerance 200 eV).",
"qTabSettings::SetEnergy");
}
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get threshold energy."), e.what(), "qTabSettings::SetEnergy"); qDefs::ExceptionMessage("Could not get threshold energy.", e.what(), "qTabSettings::SetThresholdEnergy");
} }
// set the right value anyway (exception or no) // set the right value anyway (due to tolerance)
GetThresholdEnergy(); GetThresholdEnergy();
} }
void qTabSettings::Refresh() { void qTabSettings::Refresh() {
FILE_LOG(logDEBUG) << "\n**Updating Settings Tab"; FILE_LOG(logDEBUG) << "**Updating Settings Tab";
// settings
if (comboSettings->isEnabled()) { if (comboSettings->isEnabled()) {
GetSettings(); GetSettings();
} }
// threshold
if (spinThreshold->isEnabled()) {
GetThresholdEnergy();
}
// Dynamic Range
if (comboDynamicRange->isEnabled()) { if (comboDynamicRange->isEnabled()) {
GetDynamicRange(); GetDynamicRange();
} }
if (spinThreshold->isEnabled())
GetThresholdEnergy();
FILE_LOG(logDEBUG) << "**Updated Settings Tab"; FILE_LOG(logDEBUG) << "**Updated Settings Tab";
} }

View File

@ -918,7 +918,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
/*! \page settings /*! \page settings
- <b>settings [s]</b> sets/gets the settings of the detector. Options: \c standard, \c fast, \c highgain, \c dynamicgain, \c lowgain, \c mediumgain, \c veryhighgain, - <b>settings [s]</b> sets/gets the settings of the detector. Options: \c standard, \c fast, \c highgain, \c dynamicgain, \c lowgain, \c mediumgain, \c veryhighgain,
\c lownoise, \c dynamichg0, \c fixgain1, \c fixgain2, \c forceswitchg1, \c forceswitchg2. \c dynamichg0, \c fixgain1, \c fixgain2, \c forceswitchg1, \c forceswitchg2.
\n In Eiger, only sets in client shared memory. Use \c threshold or \c thresholdnotb to pass to detector. Gets from detector. \c Returns \c (string) s \n In Eiger, only sets in client shared memory. Use \c threshold or \c thresholdnotb to pass to detector. Gets from detector. \c Returns \c (string) s
*/ */
descrToFuncMap[i].m_pFuncName = "settings"; descrToFuncMap[i].m_pFuncName = "settings";
@ -3590,7 +3590,7 @@ std::string slsDetectorCommand::helpSettings(int action) {
std::ostringstream os; std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) { if (action == PUT_ACTION || action == HELP_ACTION) {
os << "settings s \n sets the settings of the detector - can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain" os << "settings s \n sets the settings of the detector - can be standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain"
"lownoise, dynamichg0,fixgain1,fixgain2,forceswitchg1, forceswitchg2" "dynamichg0,fixgain1,fixgain2,forceswitchg1, forceswitchg2"
<< std::endl; << std::endl;
os << "threshold eV [sett]\n sets the detector threshold in eV. If sett is provided for eiger, uses settings sett" << std::endl; os << "threshold eV [sett]\n sets the detector threshold in eV. If sett is provided for eiger, uses settings sett" << std::endl;
os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett" << std::endl; os << "thresholdnotb eV [sett]\n sets the detector threshold in eV without loading trimbits. If sett is provided for eiger, uses settings sett" << std::endl;

View File

@ -471,7 +471,6 @@ format
LOWGAIN, /**< low gain settings */ LOWGAIN, /**< low gain settings */
MEDIUMGAIN, /**< medium gain settings */ MEDIUMGAIN, /**< medium gain settings */
VERYHIGHGAIN, /**< very high gain settings */ VERYHIGHGAIN, /**< very high gain settings */
LOWNOISE, /**< low noise settings */
DYNAMICHG0, /**< dynamic high gain 0 */ DYNAMICHG0, /**< dynamic high gain 0 */
FIXGAIN1, /**< fix gain 1 */ FIXGAIN1, /**< fix gain 1 */
FIXGAIN2, /**< fix gain 2 */ FIXGAIN2, /**< fix gain 2 */
@ -786,9 +785,9 @@ format
/** returns detector settings std::string from index /** returns detector settings std::string from index
\param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, \param s can be STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN,
MEDIUMGAIN, VERYHIGHGAIN, LOWNOISE, DYNAMICHG0, FIXGAIN1, FIXGAIN2, MEDIUMGAIN, VERYHIGHGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2,
FORCESWITCHG1, FORCESWITCHG2, GET_SETTINGS \returns standard, fast, FORCESWITCHG1, FORCESWITCHG2, GET_SETTINGS \returns standard, fast,
highgain, dynamicgain, lowgain, mediumgain, veryhighgain, lownoise, highgain, dynamicgain, lowgain, mediumgain, veryhighgain,
dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2,
verylowgain, undefined verylowgain, undefined
*/ */
@ -808,8 +807,6 @@ format
return std::string("mediumgain"); return std::string("mediumgain");
case VERYHIGHGAIN: case VERYHIGHGAIN:
return std::string("veryhighgain"); return std::string("veryhighgain");
case LOWNOISE:
return std::string("lownoise");
case DYNAMICHG0: case DYNAMICHG0:
return std::string("dynamichg0"); return std::string("dynamichg0");
case FIXGAIN1: case FIXGAIN1:
@ -831,10 +828,10 @@ format
/** returns detector settings std::string from index /** returns detector settings std::string from index
\param s can be standard, fast, highgain, dynamicgain, lowgain, \param s can be standard, fast, highgain, dynamicgain, lowgain,
mediumgain, veryhighgain, lownoise, dynamichg0, fixgain1, fixgain2, mediumgain, veryhighgain, dynamichg0, fixgain1, fixgain2,
forceswitchg1, forceswitchg2, undefined \returns setting index forceswitchg1, forceswitchg2, undefined \returns setting index
STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN,
VERYHIGHGAIN,LOWNOISE, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, VERYHIGHGAIN,DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1,
FORCESWITCHG2, VERYLOWGAIN, GET_SETTINGS FORCESWITCHG2, VERYLOWGAIN, GET_SETTINGS
*/ */
@ -853,8 +850,6 @@ format
return MEDIUMGAIN; return MEDIUMGAIN;
if (s == "veryhighgain") if (s == "veryhighgain")
return VERYHIGHGAIN; return VERYHIGHGAIN;
if (s == "lownoise")
return LOWNOISE;
if (s == "dynamichg0") if (s == "dynamichg0")
return DYNAMICHG0; return DYNAMICHG0;
if (s == "fixgain1") if (s == "fixgain1")