diff --git a/slsDetectorGui/forms/form_tab_developer.ui b/slsDetectorGui/forms/form_tab_developer.ui index e16e86287..7a0140d97 100755 --- a/slsDetectorGui/forms/form_tab_developer.ui +++ b/slsDetectorGui/forms/form_tab_developer.ui @@ -32,17 +32,29 @@ Form - - + + - - 0 + + 5 0 - - Readout: + + 1 + + + DACs + + + + + + ADCs + + + @@ -77,145 +89,19 @@ - - + + 0 0 - - <html><head/><body><p>High Voltage</p><p> #highvoltage#</p></body></html> - - High Voltage: + Readout: - - - - - 0 - 0 - - - - - 0 - 28 - - - - <html><head/><body><p>High Voltage</p><p> #highvoltage#</p></body></html> - - - - 0 - - - - - 90 - - - - - 110 - - - - - 120 - - - - - 150 - - - - - 180 - - - - - 200 - - - - - - - - - 0 - 0 - - - - <html><head/><body><p>High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.</p><p>-1 corresponds to different values from detectors.</p><p>#highvoltage#</p></body></html> - - - High Voltage: - - - - - - - - 0 - 0 - - - - - 0 - 28 - - - - <html><head/><body><p>High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.</p><p>-1 corresponds to different values from detectors.</p><p>#highvoltage#</p></body></html> - - - false - - - -1 - - - 200 - - - - - - - - 5 - 0 - - - - 1 - - - - DACs - - - - - - ADCs - - - - - diff --git a/slsDetectorGui/forms/form_tab_settings.ui b/slsDetectorGui/forms/form_tab_settings.ui index 884f9e14e..526e31c72 100755 --- a/slsDetectorGui/forms/form_tab_settings.ui +++ b/slsDetectorGui/forms/form_tab_settings.ui @@ -7,7 +7,7 @@ 0 0 775 - 385 + 400 @@ -32,7 +32,77 @@ Form - + + + + + 0 + 0 + + + + + 140 + 28 + + + + <html><head/><body><p>High Voltage</p><p> #highvoltage#</p></body></html> + + + + 0 + + + + + 90 + + + + + 110 + + + + + 120 + + + + + 150 + + + + + 180 + + + + + 200 + + + + + + + + + 0 + 0 + + + + <html><head/><body><p>High Voltage</p><p> #highvoltage#</p></body></html> + + + High Voltage: + + + + false @@ -54,7 +124,7 @@ - + false @@ -73,7 +143,7 @@ - + Qt::Horizontal @@ -89,7 +159,7 @@ - + true @@ -111,7 +181,7 @@ - + false @@ -130,7 +200,7 @@ - + true @@ -144,7 +214,7 @@ 140 - 25 + 28 @@ -269,7 +339,7 @@ - + false @@ -306,7 +376,7 @@ - + true @@ -381,7 +451,7 @@ - + Qt::Horizontal @@ -397,7 +467,7 @@ - + false @@ -434,7 +504,23 @@ - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 190 + + + + + false @@ -471,7 +557,7 @@ - + false @@ -493,7 +579,7 @@ - + false @@ -515,23 +601,7 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 190 - - - - - + false @@ -553,7 +623,7 @@ - + false @@ -561,7 +631,7 @@ 140 - 25 + 28 @@ -597,7 +667,7 @@ - + false @@ -616,7 +686,7 @@ - + false @@ -630,7 +700,7 @@ 140 - 25 + 28 @@ -674,6 +744,50 @@ + + + + + 0 + 0 + + + + <html><head/><body><p>High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.</p><p>-1 corresponds to different values from detectors.</p><p>#highvoltage#</p></body></html> + + + High Voltage: + + + + + + + + 0 + 0 + + + + + 140 + 28 + + + + <html><head/><body><p>High Voltage. Range: 60 - 200V. Swich off high voltage by setting to 0.</p><p>-1 corresponds to different values from detectors.</p><p>#highvoltage#</p></body></html> + + + false + + + -1 + + + 200 + + + diff --git a/slsDetectorGui/include/qTabDeveloper.h b/slsDetectorGui/include/qTabDeveloper.h index 90b3da3cd..c672bc69f 100644 --- a/slsDetectorGui/include/qTabDeveloper.h +++ b/slsDetectorGui/include/qTabDeveloper.h @@ -20,25 +20,16 @@ class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject { public slots: void Refresh(); - private slots: - void SetHighVoltage(); - private: void SetupWidgetWindow(); void Initialization(); void PopulateDetectors(); - void GetHighVoltage(); slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, int index); Detector *det; std::vector dacWidgets; std::vector adcWidgets; - - enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 }; - int hvmin; - static const int HV_MIN = 60; - static const int HV_MAX = 200; }; } // namespace sls diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h index ef0997c91..6e70b9377 100644 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -18,6 +18,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject { void SetExportMode(bool exportMode); private slots: + void SetHighVoltage(); void SetSettings(int index); void SetGainMode(int index); void SetDynamicRange(int index); @@ -32,6 +33,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject { void ShowFixG0(bool expertMode); void Initialization(); + void GetHighVoltage(); void GetSettings(); void GetGainMode(); void GetDynamicRange(); @@ -42,6 +44,12 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject { Detector *det; std::vector counters; + enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 }; + + int hvmin; + static const int HV_MIN = 60; + static const int HV_MAX = 200; + enum { STANDARD, FAST, diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index c8ee4be6e..7fb6cfdfc 100644 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -18,12 +18,6 @@ qTabDeveloper::~qTabDeveloper() {} void qTabDeveloper::SetupWidgetWindow() { int tempid = 0; - comboHV->hide(); - lblComboHV->hide(); - lblSpinHV->hide(); - spinHV->hide(); - hvmin = HV_MIN; - try { slsDetectorDefs::detectorType detType = det->getDetectorType().squash(); switch (detType) { @@ -84,8 +78,6 @@ void qTabDeveloper::SetupWidgetWindow() { break; case slsDetectorDefs::GOTTHARD: - comboHV->show(); - lblComboHV->show(); dacWidgets.push_back(new qDacWidget( this, det, true, "v Reference: ", getSLSIndex(detType, tempid++))); @@ -119,8 +111,6 @@ void qTabDeveloper::SetupWidgetWindow() { break; case slsDetectorDefs::JUNGFRAU: - lblSpinHV->show(); - spinHV->show(); dacWidgets.push_back( new qDacWidget(this, det, true, "v vb comp: ", getSLSIndex(detType, tempid++))); @@ -150,8 +140,6 @@ void qTabDeveloper::SetupWidgetWindow() { break; case slsDetectorDefs::MOENCH: - lblSpinHV->show(); - spinHV->show(); dacWidgets.push_back( new qDacWidget(this, det, true, "vbp_colbuf: ", getSLSIndex(detType, tempid++))); @@ -175,9 +163,6 @@ void qTabDeveloper::SetupWidgetWindow() { break; case slsDetectorDefs::MYTHEN3: - lblSpinHV->show(); - spinHV->show(); - hvmin = 0; dacWidgets.push_back(new qDacWidget( this, det, true, "vcassh: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget( @@ -218,9 +203,6 @@ void qTabDeveloper::SetupWidgetWindow() { break; case slsDetectorDefs::GOTTHARD2: - lblSpinHV->show(); - spinHV->show(); - hvmin = 0; dacWidgets.push_back( new qDacWidget(this, det, true, "vref_h_adc: ", getSLSIndex(detType, tempid++))); @@ -292,9 +274,6 @@ void qTabDeveloper::SetupWidgetWindow() { void qTabDeveloper::Initialization() { connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh())); - connect(comboHV, SIGNAL(currentIndexChanged(int)), this, - SLOT(SetHighVoltage())); - connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage())); } void qTabDeveloper::PopulateDetectors() { @@ -311,75 +290,6 @@ void qTabDeveloper::PopulateDetectors() { comboDetector->setCurrentIndex(0); } -void qTabDeveloper::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 { - // dac units - auto retval = det->getHighVoltage({comboDetector->currentIndex() - 1}) - .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.", - "qTabDeveloper::GetHighVoltage") - connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage())); - connect(comboHV, SIGNAL(currentIndexChanged(int)), this, - SLOT(SetHighVoltage())); -} - -void qTabDeveloper::SetHighVoltage() { - int val = (comboHV->isVisible() ? comboHV->currentText().toInt() - : spinHV->value()); - LOG(logINFO) << "Setting high voltage:" << val; - - try { - det->setHighVoltage({comboDetector->currentIndex() - 1}); - } - CATCH_HANDLE("Could not set high voltage.", "qTabDeveloper::SetHighVoltage", - this, &qTabDeveloper::GetHighVoltage) -} - slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) { switch (detType) { @@ -606,7 +516,6 @@ void qTabDeveloper::Refresh() { for (const auto &it : adcWidgets) { it->SetDetectorIndex(comboDetector->currentIndex() - 1); } - GetHighVoltage(); LOG(logDEBUG) << "**Updated Developer Tab"; } diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 23a9f28d6..91f758f28 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -19,6 +19,12 @@ qTabSettings::~qTabSettings() {} void qTabSettings::SetupWidgetWindow() { + comboHV->hide(); + lblComboHV->hide(); + lblSpinHV->hide(); + spinHV->hide(); + hvmin = HV_MIN; + counters = std::vector{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 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 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(); }