gui hv moved to settings tab from developer tab, allowed also for eiger (#482)

This commit is contained in:
Dhanya Thattil
2022-06-08 17:06:08 +02:00
committed by GitHub
parent 364e0c6268
commit 3cee36a3db
6 changed files with 296 additions and 272 deletions

View File

@ -19,6 +19,12 @@ qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() {
comboHV->hide();
lblComboHV->hide();
lblSpinHV->hide();
spinHV->hide();
hvmin = HV_MIN;
counters = std::vector<QCheckBox *>{chkCounter1, chkCounter2, chkCounter3};
spinThreshold2->hide();
@ -37,6 +43,9 @@ void qTabSettings::SetupWidgetWindow() {
// enabling according to det type
slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
if (detType == slsDetectorDefs::MYTHEN3) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
@ -77,13 +86,28 @@ void qTabSettings::SetupWidgetWindow() {
}
}
} else if (detType == slsDetectorDefs::EIGER) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
} else if (detType == slsDetectorDefs::JUNGFRAU) {
lblSpinHV->show();
spinHV->show();
lblGainMode->setEnabled(true);
comboGainMode->setEnabled(true);
} else if (detType == slsDetectorDefs::GOTTHARD) {
comboHV->show();
lblComboHV->show();
} else if (detType == slsDetectorDefs::MOENCH) {
lblSpinHV->show();
spinHV->show();
} else if (detType == slsDetectorDefs::GOTTHARD2) {
lblSpinHV->show();
spinHV->show();
hvmin = 0;
}
// default settings for the disabled
@ -165,6 +189,11 @@ void qTabSettings::ShowFixG0(bool expertMode) {
}
void qTabSettings::Initialization() {
// High voltage
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
// Settings
if (comboSettings->isEnabled())
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
@ -201,6 +230,91 @@ void qTabSettings::Initialization() {
}
}
void qTabSettings::GetHighVoltage() {
// not enabled for eiger
if (!comboHV->isVisible() && !spinHV->isVisible())
return;
LOG(logDEBUG) << "Getting High Voltage";
disconnect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
try {
Result<int> retvals = det->getHighVoltage();
int retval = 0;
if (det->getDetectorType().squash() != slsDetectorDefs::EIGER) {
retval = retvals.tsquash("Inconsistent values for high voltage.");
}
// eiger slaves return -999
else {
auto is_master = det->getMaster();
Result<int> master_retvals;
for (size_t i = 0; i != retvals.size(); ++i) {
if (is_master[i]) {
master_retvals.push_back(retvals[i]);
}
}
retval = master_retvals.tsquash("Inconsistent values for high voltage.");
}
// spinHV
if (spinHV->isVisible()) {
if (retval != 0 && retval < hvmin && retval > HV_MAX) {
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
spinHV->setValue(retval);
}
// combo HV
else {
switch (retval) {
case 0:
comboHV->setCurrentIndex(HV_0);
break;
case 90:
comboHV->setCurrentIndex(HV_90);
break;
case 110:
comboHV->setCurrentIndex(HV_110);
break;
case 120:
comboHV->setCurrentIndex(HV_120);
break;
case 150:
comboHV->setCurrentIndex(HV_150);
break;
case 180:
comboHV->setCurrentIndex(HV_180);
break;
case 200:
comboHV->setCurrentIndex(HV_200);
break;
default:
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
}
}
CATCH_DISPLAY("Could not get high voltage.",
"qTabSettings::GetHighVoltage")
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
}
void qTabSettings::SetHighVoltage() {
int val = (comboHV->isVisible() ? comboHV->currentText().toInt()
: spinHV->value());
LOG(logINFO) << "Setting high voltage:" << val;
try {
det->setHighVoltage(val);
}
CATCH_HANDLE("Could not set high voltage.", "qTabSettings::SetHighVoltage",
this, &qTabSettings::GetHighVoltage)
}
void qTabSettings::GetSettings() {
LOG(logDEBUG) << "Getting settings";
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
@ -472,6 +586,8 @@ void qTabSettings::SetCounterMask() {
void qTabSettings::Refresh() {
LOG(logDEBUG) << "**Updating Settings Tab";
GetHighVoltage();
if (comboSettings->isEnabled()) {
GetSettings();
}