mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
WIP Settings
This commit is contained in:
@ -101,11 +101,6 @@
|
||||
<string>Very High Gain</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Low Noise</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dynamic HG0</string>
|
||||
|
@ -9,7 +9,7 @@ class multiSlsDetector;
|
||||
/**
|
||||
*@short sets up the Settings parameters
|
||||
*/
|
||||
class qTabSettings:public QWidget, private Ui::TabSettingsObject{
|
||||
class qTabSettings: public QWidget, private Ui::TabSettingsObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -34,20 +34,21 @@ public:
|
||||
private slots:
|
||||
/**
|
||||
* Set settings according to selection
|
||||
* @param index index of selection
|
||||
* @param index index of selection
|
||||
*/
|
||||
void SetSettings(int index);
|
||||
|
||||
/**
|
||||
* Set dynamic range if possible
|
||||
* @param index selection
|
||||
* @param index selection
|
||||
*/
|
||||
void SetDynamicRange(int index);
|
||||
|
||||
/**
|
||||
* Set threshold energy
|
||||
* @param index selection
|
||||
*/
|
||||
void SetEnergy();
|
||||
void SetThresholdEnergy(int index);
|
||||
|
||||
|
||||
private:
|
||||
@ -85,9 +86,29 @@ private:
|
||||
/** The sls detector object */
|
||||
multiSlsDetector *myDet;
|
||||
|
||||
enum{STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, LOWNOISE,
|
||||
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, VERLOWGAIN,
|
||||
UNDEFINED, UNINITIALIZED, NUMSETTINGS};
|
||||
|
||||
static const int THRESHOLD_TOLERANCE = 200;
|
||||
enum {
|
||||
STANDARD,
|
||||
FAST,
|
||||
HIGHGAIN,
|
||||
DYNAMICGAIN,
|
||||
LOWGAIN,
|
||||
MEDIUMGAIN,
|
||||
VERYHIGHGAIN,
|
||||
DYNAMICHG0,
|
||||
FIXGAIN1,
|
||||
FIXGAIN2,
|
||||
FORCESWITCHG1,
|
||||
FORCESWITCHG2,
|
||||
VERLOWGAIN,
|
||||
UNDEFINED,
|
||||
UNINITIALIZED,
|
||||
NUMSETTINGS
|
||||
};
|
||||
|
||||
enum {
|
||||
DYNAMICRANGE_32,
|
||||
DYNAMICRANGE_16,
|
||||
DYNAMICRANGE_8,
|
||||
DYNAMICRANGE_4
|
||||
};
|
||||
};
|
||||
|
@ -24,21 +24,17 @@ void qTabAdvanced::SetupWidgetWindow(){
|
||||
errOnlineTip = QString("<nobr><br><br><font color=\"red\"><nobr>It is offline!</nobr></font>");
|
||||
|
||||
// enabling according to det type
|
||||
switch((int)myDet->getDetectorTypeAsEnum()) {
|
||||
switch(myDet->getDetectorTypeAsEnum()) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
// trimming
|
||||
tab_trimming->setEnabled(true);
|
||||
lblSubExpTime->setEnabled(true);
|
||||
// subexptime
|
||||
spinSubExpTime->setEnabled(true);
|
||||
comboSubExpTimeUnit->setEnabled(true);
|
||||
// subdeadtime
|
||||
lblSubDeadTime->setEnabled(true);
|
||||
spinSubDeadTime->setEnabled(true);
|
||||
comboSubDeadTimeUnit->setEnabled(true);
|
||||
break;
|
||||
case slsDetectorDefs::GOTTHARD:
|
||||
// roi
|
||||
tab_roi->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
|
@ -15,24 +15,22 @@ qTabDataOutput::qTabDataOutput(QWidget *parent, multiSlsDetector *detector) : QW
|
||||
FILE_LOG(logDEBUG) << "DataOutput ready";
|
||||
}
|
||||
|
||||
|
||||
qTabDataOutput::~qTabDataOutput() {}
|
||||
|
||||
|
||||
void qTabDataOutput::SetupWidgetWindow() {
|
||||
// button group for rate
|
||||
btnGroupRate = new QButtonGroup(this);
|
||||
btnGroupRate->addButton(radioDefaultDeadtime, 0);
|
||||
btnGroupRate->addButton(radioCustomDeadtime, 1);
|
||||
|
||||
|
||||
// enabling according to det type
|
||||
switch((int)myDet->getDetectorTypeAsEnum()) {
|
||||
switch(myDet->getDetectorTypeAsEnum()) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
chkTenGiga->setEnabled(true);
|
||||
chkRate->setEnabled(true);
|
||||
radioDefaultDeadtime->setEnabled(true);
|
||||
radioCustomDeadtime->setEnabled(true);
|
||||
// flags and speed
|
||||
widgetEiger->setVisible(true);
|
||||
widgetEiger->setEnabled(true);
|
||||
break;
|
||||
@ -50,6 +48,7 @@ void qTabDataOutput::SetupWidgetWindow() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::Initialization() {
|
||||
// ourdir, fileformat, overwrite enable
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
|
||||
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
|
||||
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir()));
|
||||
@ -58,11 +57,13 @@ void qTabDataOutput::Initialization() {
|
||||
if (chkTenGiga->isEnabled()) {
|
||||
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
|
||||
}
|
||||
// rate
|
||||
if (chkRate->isEnabled()) {
|
||||
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
|
||||
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
|
||||
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
|
||||
}
|
||||
// flags, speed
|
||||
if (widgetEiger->isEnabled()) {
|
||||
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
|
||||
connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
|
||||
@ -170,7 +171,7 @@ void qTabDataOutput::GetFileFormat() {
|
||||
comboFileFormat->setCurrentIndex(static_cast<int>(retval));
|
||||
break;
|
||||
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;
|
||||
}
|
||||
} catch (const sls::NonCriticalError &e) {
|
||||
@ -325,7 +326,7 @@ void qTabDataOutput::GetSpeed() {
|
||||
comboEigerClkDivider->setCurrentIndex(retval);
|
||||
break;
|
||||
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;
|
||||
}
|
||||
} catch (const sls::NonCriticalError &e) {
|
||||
@ -361,7 +362,7 @@ void qTabDataOutput::GetFlags() {
|
||||
else if (retval & slsDetectorDefs::CONTINOUS_RO)
|
||||
comboEigerFlags1->setCurrentIndex(CONTINUOUS);
|
||||
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
|
||||
@ -370,7 +371,7 @@ void qTabDataOutput::GetFlags() {
|
||||
else if (retval & slsDetectorDefs::NONPARALLEL)
|
||||
comboEigerFlags2->setCurrentIndex(NONPARALLEL);
|
||||
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) {
|
||||
|
@ -7,9 +7,7 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
qTabSettings::qTabSettings(QWidget *parent, multiSlsDetector *detector)
|
||||
: QWidget(parent), myDet(detector) {
|
||||
|
||||
qTabSettings::qTabSettings(QWidget *parent, multiSlsDetector *detector): QWidget(parent), myDet(detector) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Settings ready";
|
||||
@ -19,96 +17,62 @@ qTabSettings::~qTabSettings() {}
|
||||
|
||||
void qTabSettings::SetupWidgetWindow() {
|
||||
|
||||
// enabling according to det type
|
||||
switch(myDet->getDetectorTypeAsEnum()) {
|
||||
|
||||
case MOENCH:
|
||||
case slsDetectorDefs::MOENCH:
|
||||
lblSettings->setEnabled(false);
|
||||
comboSettings->setEnabled(false);
|
||||
break;
|
||||
|
||||
case EIGER:
|
||||
case slsDetectorDefs::EIGER:
|
||||
lblDynamicRange->setEnabled(true);
|
||||
comboDynamicRange->setEnabled(true);
|
||||
lblThreshold->setEnabled(true);
|
||||
spinThreshold->setEnabled(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Initialization();
|
||||
|
||||
// Settings
|
||||
// default settings for the disabled
|
||||
comboSettings->setCurrentIndex(UNINITIALIZED);
|
||||
if (comboSettings->isEnabled()) {
|
||||
SetupDetectorSettings();
|
||||
GetSettings();
|
||||
}
|
||||
spinThreshold->setValue(-1);
|
||||
|
||||
// Dynamic Range (update it anyway)
|
||||
Initialization();
|
||||
|
||||
// default for the disabled
|
||||
GetDynamicRange();
|
||||
|
||||
// get threshold
|
||||
spinThreshold->setValue(-1);
|
||||
if (spinThreshold->isEnabled())
|
||||
GetThresholdEnergy();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void qTabSettings::SetupDetectorSettings() {
|
||||
|
||||
// To be able to index items on a combo box
|
||||
QStandardItemModel *model =
|
||||
qobject_cast<QStandardItemModel *>(comboSettings->model());
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(comboSettings->model());
|
||||
if (model) {
|
||||
QModelIndex index[NUMSETTINGS];
|
||||
QStandardItem *item[NUMSETTINGS];
|
||||
for (int i = 0; i < NUMSETTINGS; ++i) {
|
||||
index[i] = model->index(i, comboSettings->modelColumn(),
|
||||
comboSettings->rootModelIndex());
|
||||
index[i] = model->index(i, comboSettings->modelColumn(), comboSettings->rootModelIndex());
|
||||
item[i] = model->itemFromIndex(index[i]);
|
||||
item[i]->setEnabled(false);
|
||||
}
|
||||
|
||||
item[(int)UNDEFINED]->setEnabled(false);
|
||||
item[(int)UNINITIALIZED]->setEnabled(false);
|
||||
|
||||
switch (detType) {
|
||||
switch (myDet->getDetectorTypeAsEnum()) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
item[(int)STANDARD]->setEnabled(true);
|
||||
item[(int)HIGHGAIN]->setEnabled(true);
|
||||
item[(int)LOWGAIN]->setEnabled(true);
|
||||
item[(int)VERYHIGHGAIN]->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;
|
||||
|
||||
case slsDetectorDefs::GOTTHARD:
|
||||
item[(int)HIGHGAIN]->setEnabled(true);
|
||||
item[(int)DYNAMICGAIN]->setEnabled(true);
|
||||
item[(int)LOWGAIN]->setEnabled(true);
|
||||
item[(int)MEDIUMGAIN]->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;
|
||||
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
item[(int)DYNAMICGAIN]->setEnabled(true);
|
||||
item[(int)DYNAMICHG0]->setEnabled(true);
|
||||
@ -116,22 +80,11 @@ void qTabSettings::SetupDetectorSettings() {
|
||||
item[(int)FIXGAIN2]->setEnabled(true);
|
||||
item[(int)FORCESWITCHG1]->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;
|
||||
|
||||
default:
|
||||
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
|
||||
qDefs::Message(qDefs::CRITICAL,
|
||||
"Unknown detector type. Exiting GUI.",
|
||||
"qTabSettings::SetupDetectorSettings");
|
||||
"Unknown detector type. Exiting GUI.", "qTabSettings::SetupDetectorSettings");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@ -148,7 +101,7 @@ void qTabSettings::Initialization() {
|
||||
|
||||
// Threshold
|
||||
if (spinThreshold->isEnabled())
|
||||
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
|
||||
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int)));
|
||||
}
|
||||
|
||||
void qTabSettings::GetSettings() {
|
||||
@ -156,12 +109,10 @@ void qTabSettings::GetSettings() {
|
||||
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
|
||||
|
||||
try{
|
||||
int sett = myDet->getSettings(-1);
|
||||
FILE_LOG(logDEBUG) << "Settings from Detector:" << sett;
|
||||
switch (sett) {
|
||||
auto retval = myDet->getSettings(-1);
|
||||
switch (retval) {
|
||||
case -1:
|
||||
qDefs::Message(qDefs::WARNING, "Different values for settings.", "qTabSettings::GetSettings");
|
||||
comboSettings->setCurrentIndex(UNDEFINED);
|
||||
qDefs::Message(qDefs::WARNING, "Settings are inconsistent for all detectors.", "qTabSettings::GetSettings");
|
||||
break;
|
||||
case slsDetectorDefs::UNDEFINED:
|
||||
comboSettings->setCurrentIndex(UNDEFINED);
|
||||
@ -170,16 +121,17 @@ void qTabSettings::GetSettings() {
|
||||
comboSettings->setCurrentIndex(UNINITIALIZED);
|
||||
break;
|
||||
default:
|
||||
if (sett >= NUMSETTINGS) {
|
||||
qDefs::Message(qDefs::WARNING, "Unknown settings " + std::to_string(sett) + ".", "qTabSettings::GetSettings");
|
||||
return;
|
||||
if ((int)retval < -1 || (int)retval >= NUMSETTINGS) {
|
||||
qDefs::Message(qDefs::WARNING, std::string("Unknown settings: ") + std::to_string(retval), "qTabSettings::GetSettings");
|
||||
} else {
|
||||
comboSettings->setCurrentIndex(retval);
|
||||
}
|
||||
comboSettings->setCurrentIndex(sett);
|
||||
break;
|
||||
}
|
||||
} catch (const sls::NonCriticalError &e) {
|
||||
qDefs::ExceptionMessage("Could not get settings.", e.what(), "qTabSettings::GetSettings");
|
||||
}
|
||||
|
||||
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)));
|
||||
|
||||
try {
|
||||
int ret = myDet->setDynamicRange(-1);
|
||||
auto retval = myDet->setDynamicRange(-1);
|
||||
|
||||
// set the final value on gui
|
||||
switch (ret) {
|
||||
switch (retval) {
|
||||
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;
|
||||
case 32:
|
||||
comboDynamicRange->setCurrentIndex(0);
|
||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_32);
|
||||
break;
|
||||
case 16:
|
||||
comboDynamicRange->setCurrentIndex(1);
|
||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_16);
|
||||
break;
|
||||
case 8:
|
||||
comboDynamicRange->setCurrentIndex(2);
|
||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_8);
|
||||
break;
|
||||
case 4:
|
||||
comboDynamicRange->setCurrentIndex(3);
|
||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
|
||||
break;
|
||||
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;
|
||||
}
|
||||
} catch (const sls::NonCriticalError &e) {
|
||||
qDefs::ExceptionMessage("Could not get dynamic range.", e.what(), "qTabSettings::GetDynamicRange");
|
||||
}
|
||||
|
||||
connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int)));
|
||||
}
|
||||
|
||||
void qTabSettings::GetThresholdEnergy() {
|
||||
FILE_LOG(logDEBUG) << "Getting theshold energy";
|
||||
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
|
||||
qDefs::IgnoreNonCriticalExceptions<QSpinBox>(
|
||||
myDet,
|
||||
"Could not get threshold energy."
|
||||
"qTabSettings::GetThresholdEnergy",
|
||||
spinThreshold,
|
||||
&QSpinBox::setValue,
|
||||
&multiSlsDetector::getThresholdEnergy, -1);
|
||||
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
|
||||
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy()));
|
||||
|
||||
try {
|
||||
auto retval = myDet->getThresholdEnergy();
|
||||
if (retval == -1) {
|
||||
qDefs::Message(qDefs::WARNING, "Threshold Energy is inconsistent for all detectors.", "qTabDataOutput::GetThresholdEnergy");
|
||||
spinThreshold->setValue(-1);
|
||||
} else {
|
||||
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) {
|
||||
// settings
|
||||
auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
|
||||
FILE_LOG(logINFO) << "Setting Settings to " << myDet->slsDetectorDefs::getDetectorSettings(val);
|
||||
|
||||
try {
|
||||
myDet->setSettings((slsDetectorDefs::detectorSettings)index);
|
||||
FILE_LOG(logINFO) << "Settings set to " << myDet->slsDetectorDefs::getDetectorSettings(sett);
|
||||
myDet->setSettings(val);
|
||||
} catch (const sls::NonCriticalError &e) {
|
||||
qDefs::ExceptionMessage("Could not set settings.", e.what(), "qTabSettings::SetSettings");
|
||||
GetSettings();
|
||||
@ -242,75 +203,63 @@ void qTabSettings::SetSettings(int index) {
|
||||
|
||||
// threshold
|
||||
if (spinThreshold->isEnabled()) {
|
||||
SetEnergy();
|
||||
SetThresholdEnergy(spinThreshold->value());
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
myDet->setDynamicRange(dr);
|
||||
FILE_LOG(logINFO) << "Setting dynamic range to " << dr;
|
||||
switch (index) {
|
||||
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) {
|
||||
qDefs::ExceptionMessage("Could not set dynamic range.", e.what(), "qTabSettings::SetDynamicRange");
|
||||
GetDynamicRange();
|
||||
}
|
||||
}
|
||||
|
||||
void qTabSettings::SetEnergy() {
|
||||
void qTabSettings::SetThresholdEnergy(int index) {
|
||||
FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
|
||||
try {
|
||||
// set
|
||||
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");
|
||||
}
|
||||
myDet->setThresholdEnergy(index);
|
||||
} 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();
|
||||
}
|
||||
|
||||
void qTabSettings::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "\n**Updating Settings Tab";
|
||||
FILE_LOG(logDEBUG) << "**Updating Settings Tab";
|
||||
|
||||
// settings
|
||||
if (comboSettings->isEnabled()) {
|
||||
GetSettings();
|
||||
}
|
||||
|
||||
// threshold
|
||||
if (spinThreshold->isEnabled()) {
|
||||
GetThresholdEnergy();
|
||||
}
|
||||
|
||||
// Dynamic Range
|
||||
if (comboDynamicRange->isEnabled()) {
|
||||
GetDynamicRange();
|
||||
}
|
||||
|
||||
if (spinThreshold->isEnabled())
|
||||
GetThresholdEnergy();
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated Settings Tab";
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
|
||||
/*! \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,
|
||||
\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
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "settings";
|
||||
@ -3590,7 +3590,7 @@ std::string slsDetectorCommand::helpSettings(int action) {
|
||||
std::ostringstream os;
|
||||
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"
|
||||
"lownoise, dynamichg0,fixgain1,fixgain2,forceswitchg1, forceswitchg2"
|
||||
"dynamichg0,fixgain1,fixgain2,forceswitchg1, forceswitchg2"
|
||||
<< 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;
|
||||
|
@ -471,7 +471,6 @@ format
|
||||
LOWGAIN, /**< low gain settings */
|
||||
MEDIUMGAIN, /**< medium gain settings */
|
||||
VERYHIGHGAIN, /**< very high gain settings */
|
||||
LOWNOISE, /**< low noise settings */
|
||||
DYNAMICHG0, /**< dynamic high gain 0 */
|
||||
FIXGAIN1, /**< fix gain 1 */
|
||||
FIXGAIN2, /**< fix gain 2 */
|
||||
@ -786,9 +785,9 @@ format
|
||||
|
||||
/** returns detector settings std::string from index
|
||||
\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,
|
||||
highgain, dynamicgain, lowgain, mediumgain, veryhighgain, lownoise,
|
||||
highgain, dynamicgain, lowgain, mediumgain, veryhighgain,
|
||||
dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2,
|
||||
verylowgain, undefined
|
||||
*/
|
||||
@ -808,8 +807,6 @@ format
|
||||
return std::string("mediumgain");
|
||||
case VERYHIGHGAIN:
|
||||
return std::string("veryhighgain");
|
||||
case LOWNOISE:
|
||||
return std::string("lownoise");
|
||||
case DYNAMICHG0:
|
||||
return std::string("dynamichg0");
|
||||
case FIXGAIN1:
|
||||
@ -831,10 +828,10 @@ format
|
||||
|
||||
/** returns detector settings std::string from index
|
||||
\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
|
||||
STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN,
|
||||
VERYHIGHGAIN,LOWNOISE, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1,
|
||||
VERYHIGHGAIN,DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1,
|
||||
FORCESWITCHG2, VERYLOWGAIN, GET_SETTINGS
|
||||
*/
|
||||
|
||||
@ -853,8 +850,6 @@ format
|
||||
return MEDIUMGAIN;
|
||||
if (s == "veryhighgain")
|
||||
return VERYHIGHGAIN;
|
||||
if (s == "lownoise")
|
||||
return LOWNOISE;
|
||||
if (s == "dynamichg0")
|
||||
return DYNAMICHG0;
|
||||
if (s == "fixgain1")
|
||||
|
Reference in New Issue
Block a user