From 6d1856daa217ecc1bea546237689bd9a06d706f6 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil <33750417+thattil@users.noreply.github.com> Date: Thu, 3 Sep 2020 10:47:02 +0200 Subject: [PATCH] gui: added burstmode (#159) Added burst mode in the GUI. Visible only for detectors that supports it. --- slsDetectorGui/forms/form_tab_measurement.ui | 76 +++++++++++++++----- slsDetectorGui/include/qTabMeasurement.h | 2 + slsDetectorGui/src/qTabMeasurement.cpp | 65 +++++++++++++---- 3 files changed, 113 insertions(+), 30 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index ba9da5c72..5a9766232 100755 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -432,7 +432,7 @@ 4 - + @@ -503,7 +503,7 @@ - + false @@ -572,7 +572,7 @@ Frame period between exposures. - + @@ -616,7 +616,7 @@ Frame period between exposures. - + @@ -674,7 +674,7 @@ Frame period between exposures. - + true @@ -718,7 +718,7 @@ Exposure Time of a frame. - + false @@ -735,7 +735,7 @@ Frame period between exposures. - + false @@ -745,7 +745,7 @@ Frame period between exposures. - + true @@ -762,7 +762,7 @@ Exposure Time of a frame. - + false @@ -809,7 +809,7 @@ Exposure Time of a frame. - + true @@ -871,7 +871,7 @@ Exposure Time of a frame. - + false @@ -931,7 +931,7 @@ Frame period between exposures. - + @@ -1070,7 +1070,7 @@ Frame period between exposures. - + @@ -1141,7 +1141,7 @@ Frame period between exposures. - + @@ -1268,7 +1268,7 @@ Frame period between exposures. - + @@ -1431,7 +1431,7 @@ Frame period between exposures. - + @@ -1502,7 +1502,7 @@ Frame period between exposures. - + @@ -1639,6 +1639,48 @@ Frame period between exposures. + + + + Burst Mode: + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Timing Mode of the detector. + #timing# + + + + Off + + + + + Burst Internal + + + + + Burst external + + + + diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index 091936ecc..3d8e5b844 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -20,6 +20,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject { private slots: void SetTimingMode(int val); + void SetBurstMode(int val); void SetNumMeasurements(int val); void SetNumFrames(int val); void SetNumTriggers(int val); @@ -52,6 +53,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject { void EnableWidgetsforTimingMode(); void GetTimingMode(); + void GetBurstMode(); void GetNumFrames(); void GetNumTriggers(); void GetNumBursts(); diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 06d283f15..a9c7fc92e 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -46,6 +46,8 @@ void qTabMeasurement::SetupWidgetWindow() { ShowGates(); // enabling according to det type + lblBurstMode->hide(); + comboBurstMode->hide(); switch (det->getDetectorType().squash()) { case slsDetectorDefs::MOENCH: lblNumSamples->setEnabled(true); @@ -64,6 +66,8 @@ void qTabMeasurement::SetupWidgetWindow() { startingFnumImplemented = true; break; case slsDetectorDefs::GOTTHARD2: + lblBurstMode->show(); + comboBurstMode->show(); lblNumBursts->setEnabled(true); spinNumBursts->setEnabled(true); lblBurstPeriod->setEnabled(true); @@ -89,6 +93,10 @@ void qTabMeasurement::SetupWidgetWindow() { void qTabMeasurement::Initialization() { connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); + if (comboBurstMode->isVisible()) { + connect(comboBurstMode, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetBurstMode(int))); + } connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(SetNumMeasurements(int))); connect(spinNumFrames, SIGNAL(valueChanged(int)), this, @@ -144,18 +152,11 @@ void qTabMeasurement::Initialization() { void qTabMeasurement::ShowTriggerDelay() { bool showTrigger = true; if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) { - try { - LOG(logDEBUG) << "Getting burst mode"; - auto retval = det->getBurstMode().tsquash( - "Inconsistent burst mode for all detectors."); - // burst mode and auto timing mode - if (retval != slsDetectorDefs::BURST_OFF && - comboTimingMode->currentIndex() == AUTO) { - showTrigger = false; - } + if ((comboBurstMode->currentIndex() != slsDetectorDefs::BURST_OFF) && + (comboTimingMode->currentIndex() == AUTO)) { + // show burst, burstperiod, not trigger or delay + showTrigger = false; } - CATCH_DISPLAY("Could not get burst mode.", - "qTabMeasurement::ShowTriggerDelay") } if (showTrigger) { @@ -248,7 +249,7 @@ void qTabMeasurement::EnableWidgetsforTimingMode() { spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) { - ShowTriggerDelay(); + GetBurstMode(); // also decides to show trigger or burst mode } break; case TRIGGER: @@ -272,7 +273,7 @@ void qTabMeasurement::EnableWidgetsforTimingMode() { spinDelay->setEnabled(true); comboDelayUnit->setEnabled(true); if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) { - ShowTriggerDelay(); + GetBurstMode(); // also decides to show trigger or burst mode } } break; @@ -359,6 +360,41 @@ void qTabMeasurement::SetTimingMode(int val) { this, &qTabMeasurement::GetTimingMode) } +void qTabMeasurement::GetBurstMode() { + LOG(logDEBUG) << "Getting burst mode"; + disconnect(comboBurstMode, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetBurstMode(int))); + try { + auto retval = det->getBurstMode().tsquash( + "Inconsistent burst mode for all detectors."); + switch (retval) { + case slsDetectorDefs::BURST_OFF: + case slsDetectorDefs::BURST_INTERNAL: + case slsDetectorDefs::BURST_EXTERNAL: + comboBurstMode->setCurrentIndex((int)retval); + ShowTriggerDelay(); + break; + default: + throw sls::RuntimeError(std::string("Unknown burst mode: ") + + std::to_string(retval)); + } + } + CATCH_DISPLAY("Could not get burst mode.", "qTabMeasurement::GetBurstMode") + connect(comboBurstMode, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetBurstMode(int))); +} + +void qTabMeasurement::SetBurstMode(int val) { + LOG(logINFO) << "Setting burst mode:" + << comboBurstMode->currentText().toAscii().data(); + try { + det->setBurstMode(static_cast(val)); + ShowTriggerDelay(); + } + CATCH_HANDLE("Could not set burst mode.", "qTabMeasurement::SetBurstMode", + this, &qTabMeasurement::GetBurstMode) +} + void qTabMeasurement::SetNumMeasurements(int val) { LOG(logINFO) << "Setting Number of Measurements to " << val; numMeasurements = val; @@ -913,6 +949,9 @@ void qTabMeasurement::Refresh() { if (!plot->GetIsRunning()) { GetTimingMode(); + if (comboBurstMode->isVisible()) { + GetBurstMode(); + } GetNumFrames(); GetExposureTime(); GetAcquisitionPeriod();