mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-19 18:40:01 +02:00
wip
This commit is contained in:
parent
8f53845698
commit
cd396a1f11
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>775</width>
|
||||
<height>345</height>
|
||||
<height>380</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -635,9 +635,38 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Settings of the detector.
|
||||
#settings#</string>
|
||||
<string><html><head/><body><p>Gain Mode of the detector</p><p> #gainmode#</p><p><br/></p><p>Fix G0 is to be used with utmost caution. Can damage the detector!</p></body></html></string>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -10,9 +10,12 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
||||
qTabSettings(QWidget *parent, sls::Detector *detector);
|
||||
~qTabSettings();
|
||||
void Refresh();
|
||||
public slots:
|
||||
void SetExportMode(bool exportMode);
|
||||
|
||||
private slots:
|
||||
void SetSettings(int index);
|
||||
void SetGainMode(int index);
|
||||
void SetDynamicRange(int index);
|
||||
void SetThresholdEnergy(int index);
|
||||
void SetThresholdEnergies();
|
||||
@ -22,9 +25,11 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
||||
void SetupWidgetWindow();
|
||||
void SetupDetectorSettings();
|
||||
void SetupGainMode();
|
||||
void ShowFixG0(bool expertMode);
|
||||
void Initialization();
|
||||
|
||||
void GetSettings();
|
||||
void GetGainMode();
|
||||
void GetDynamicRange();
|
||||
void GetThresholdEnergy();
|
||||
void GetThresholdEnergies();
|
||||
@ -58,5 +63,16 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
||||
UNINITIALIZED,
|
||||
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 };
|
||||
};
|
||||
|
@ -340,6 +340,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
actionLoadTrimbits->setVisible(enable &&
|
||||
(detType == slsDetectorDefs::EIGER ||
|
||||
detType == slsDetectorDefs::MYTHEN3));
|
||||
tabSettings->SetExportMode(enable);
|
||||
LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,16 @@ void qTabSettings::SetupWidgetWindow() {
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void qTabSettings::SetExportMode(bool exportMode) {
|
||||
if (comboGainMode->isVisible()) {
|
||||
ShowFixG0(exportMode);
|
||||
}
|
||||
}
|
||||
|
||||
void qTabSettings::SetupDetectorSettings() {
|
||||
comboSettings->setCurrentIndex(UNINITIALIZED);
|
||||
|
||||
// enable only those available to detector
|
||||
QStandardItemModel *model =
|
||||
qobject_cast<QStandardItemModel *>(comboSettings->model());
|
||||
const int numSettings = comboSettings->count();
|
||||
@ -123,14 +132,26 @@ void qTabSettings::SetupDetectorSettings() {
|
||||
}
|
||||
|
||||
void qTabSettings::SetupGainMode() {
|
||||
try {
|
||||
auto list = det->getGainModeList();
|
||||
for (auto it : list) {
|
||||
comboGainMode->addItem(sls::ToString(it).c_str());
|
||||
}
|
||||
comboGainMode->setCurrentIndex(DYNAMIC_GAIN_MODE);
|
||||
ShowFixG0(false);
|
||||
}
|
||||
|
||||
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"),
|
||||
"qTabSettings::SetupGainMode")
|
||||
isVisibleFixG0 = expertMode;
|
||||
}
|
||||
|
||||
void qTabSettings::Initialization() {
|
||||
@ -138,6 +159,10 @@ void qTabSettings::Initialization() {
|
||||
if (comboSettings->isEnabled())
|
||||
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSettings(int)));
|
||||
// Gain mode
|
||||
if (comboGainMode->isEnabled())
|
||||
connect(comboGainMode, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetGainMode(int)));
|
||||
|
||||
// Dynamic Range
|
||||
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() {
|
||||
LOG(logDEBUG) << "Getting dynamic range";
|
||||
disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
|
||||
@ -381,6 +460,10 @@ void qTabSettings::Refresh() {
|
||||
GetSettings();
|
||||
}
|
||||
|
||||
if (comboGainMode->isEnabled()) {
|
||||
GetGainMode();
|
||||
}
|
||||
|
||||
if (comboDynamicRange->isEnabled()) {
|
||||
GetDynamicRange();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user