This commit is contained in:
maliakal_d 2021-08-04 17:28:51 +02:00
parent 8f53845698
commit cd396a1f11
4 changed files with 139 additions and 10 deletions

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>775</width> <width>775</width>
<height>345</height> <height>380</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -635,9 +635,38 @@
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Settings of the detector. <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Gain Mode of the detector&lt;/p&gt;&lt;p&gt; #gainmode#&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Fix G0 is to be used with utmost caution. Can damage the detector!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
#settings#</string>
</property> </property>
<item>
<property name="text">
<string>Dynamic Gain</string>
</property>
</item>
<item>
<property name="text">
<string>Force Switch G1</string>
</property>
</item>
<item>
<property name="text">
<string>Force Switch G2</string>
</property>
</item>
<item>
<property name="text">
<string>Fix G1</string>
</property>
</item>
<item>
<property name="text">
<string>Fix G2</string>
</property>
</item>
<item>
<property name="text">
<string>Fix G0</string>
</property>
</item>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -10,9 +10,12 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
qTabSettings(QWidget *parent, sls::Detector *detector); qTabSettings(QWidget *parent, sls::Detector *detector);
~qTabSettings(); ~qTabSettings();
void Refresh(); void Refresh();
public slots:
void SetExportMode(bool exportMode);
private slots: private slots:
void SetSettings(int index); void SetSettings(int index);
void SetGainMode(int index);
void SetDynamicRange(int index); void SetDynamicRange(int index);
void SetThresholdEnergy(int index); void SetThresholdEnergy(int index);
void SetThresholdEnergies(); void SetThresholdEnergies();
@ -22,9 +25,11 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void SetupWidgetWindow(); void SetupWidgetWindow();
void SetupDetectorSettings(); void SetupDetectorSettings();
void SetupGainMode(); void SetupGainMode();
void ShowFixG0(bool expertMode);
void Initialization(); void Initialization();
void GetSettings(); void GetSettings();
void GetGainMode();
void GetDynamicRange(); void GetDynamicRange();
void GetThresholdEnergy(); void GetThresholdEnergy();
void GetThresholdEnergies(); void GetThresholdEnergies();
@ -58,5 +63,16 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
UNINITIALIZED, UNINITIALIZED,
NUMSETTINGS NUMSETTINGS
}; };
enum {
DYNAMIC_GAIN_MODE,
FORCE_SWITCH_G1,
FORCE_SWITCH_G2,
FIX_G1,
FIX_G2,
FIX_G0
};
bool isVisibleFixG0{false};
enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 }; enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 };
}; };

View File

@ -340,6 +340,7 @@ void qDetectorMain::EnableModes(QAction *action) {
actionLoadTrimbits->setVisible(enable && actionLoadTrimbits->setVisible(enable &&
(detType == slsDetectorDefs::EIGER || (detType == slsDetectorDefs::EIGER ||
detType == slsDetectorDefs::MYTHEN3)); detType == slsDetectorDefs::MYTHEN3));
tabSettings->SetExportMode(enable);
LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable); LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable);
} }

View File

@ -98,7 +98,16 @@ void qTabSettings::SetupWidgetWindow() {
Refresh(); Refresh();
} }
void qTabSettings::SetExportMode(bool exportMode) {
if (comboGainMode->isVisible()) {
ShowFixG0(exportMode);
}
}
void qTabSettings::SetupDetectorSettings() { void qTabSettings::SetupDetectorSettings() {
comboSettings->setCurrentIndex(UNINITIALIZED);
// enable only those available to detector
QStandardItemModel *model = QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboSettings->model()); qobject_cast<QStandardItemModel *>(comboSettings->model());
const int numSettings = comboSettings->count(); const int numSettings = comboSettings->count();
@ -123,14 +132,26 @@ void qTabSettings::SetupDetectorSettings() {
} }
void qTabSettings::SetupGainMode() { void qTabSettings::SetupGainMode() {
try { comboGainMode->setCurrentIndex(DYNAMIC_GAIN_MODE);
auto list = det->getGainModeList(); ShowFixG0(false);
for (auto it : list) { }
comboGainMode->addItem(sls::ToString(it).c_str());
} void qTabSettings::ShowFixG0(bool expertMode) {
LOG(logINFO) << (expertMode ? "Showing" : "Hiding") << " FIX_G0";
// enable.disable Fix G0
QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboGainMode->model());
const int numSettings = comboGainMode->count();
if (model) {
std::vector<QModelIndex> index(numSettings);
std::vector<QStandardItem *> item(numSettings);
index[FIX_G0] = model->index(FIX_G0, comboGainMode->modelColumn(),
comboGainMode->rootModelIndex());
item[FIX_G0] = model->itemFromIndex(index[FIX_G0]);
item[FIX_G0]->setEnabled(expertMode);
} }
CATCH_DISPLAY(std::string("Could not setup gain mode"), isVisibleFixG0 = expertMode;
"qTabSettings::SetupGainMode")
} }
void qTabSettings::Initialization() { void qTabSettings::Initialization() {
@ -138,6 +159,10 @@ void qTabSettings::Initialization() {
if (comboSettings->isEnabled()) if (comboSettings->isEnabled())
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int))); SLOT(SetSettings(int)));
// Gain mode
if (comboGainMode->isEnabled())
connect(comboGainMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetGainMode(int)));
// Dynamic Range // Dynamic Range
if (comboDynamicRange->isEnabled()) if (comboDynamicRange->isEnabled())
@ -209,6 +234,60 @@ void qTabSettings::SetSettings(int index) {
} }
} }
void qTabSettings::GetGainMode() {
LOG(logDEBUG) << "Getting gain mode";
disconnect(comboGainMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetGainMode(int)));
try {
auto retval = det->getGainMode().tsquash(
"Inconsistent gain mode for all detectors.");
if ((int)retval < 0 || (int)retval >= comboGainMode->count()) {
throw sls::RuntimeError(std::string("Unknown gain mode: ") +
std::to_string(retval));
}
// warning when using fix_g0 and not in export mode
if ((int)retval == FIX_G0 && !isVisibleFixG0) {
std::string message =
"<nobr>You are not in Expert Mode and Gain Mode is in FIX_G0. "
"</nobr><br><nobr>Could damage the detector when used without "
"caution! </nobr>";
qDefs::Message(qDefs::WARNING, message,
"qTabSettings::GetGainMode");
LOG(logWARNING) << message;
}
comboGainMode->setCurrentIndex((int)retval);
}
CATCH_DISPLAY("Could not get gain mode.", "qTabSettings::GetGainMode")
connect(comboGainMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetGainMode(int)));
}
void qTabSettings::SetGainMode(int index) {
// warning for fix_G0 even in export mode
if (index == FIX_G0) {
if (qDefs::Message(
qDefs::QUESTION,
"<nobr>You are in Export mode, "
"</nobr><br><nobr>but setting Gain Mode to FIX_G0 could "
"damage the detector! </nobr><br><nobr>Proceed and set "
"gainmode to FIX_G0 anyway?</nobr>",
"qTabSettings::SetGainMode") == slsDetectorDefs::FAIL) {
GetGainMode();
return;
}
}
LOG(logINFO) << "Setting Gain Mode to "
<< comboGainMode->currentText().toAscii().data();
auto val = static_cast<slsDetectorDefs::gainMode>(index);
try {
det->setGainMode(val);
}
CATCH_HANDLE("Could not set gain mode.", "qTabSettings::SetGainMode", this,
&qTabSettings::GetGainMode)
}
void qTabSettings::GetDynamicRange() { void qTabSettings::GetDynamicRange() {
LOG(logDEBUG) << "Getting dynamic range"; LOG(logDEBUG) << "Getting dynamic range";
disconnect(comboDynamicRange, SIGNAL(activated(int)), this, disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
@ -381,6 +460,10 @@ void qTabSettings::Refresh() {
GetSettings(); GetSettings();
} }
if (comboGainMode->isEnabled()) {
GetGainMode();
}
if (comboDynamicRange->isEnabled()) { if (comboDynamicRange->isEnabled()) {
GetDynamicRange(); GetDynamicRange();
} }