diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui
index 596c11aef..ae3259e73 100755
--- a/slsDetectorGui/forms/form_tab_plot.ui
+++ b/slsDetectorGui/forms/form_tab_plot.ui
@@ -99,7 +99,7 @@
- 4
+ 3
@@ -278,7 +278,7 @@
8
0
- 316
+ 328
35
@@ -536,7 +536,7 @@
9
0
- 318
+ 322
35
@@ -871,7 +871,7 @@ Displays minimum, maximum and sum of values for each plot.
- 2
+ 4
@@ -1826,7 +1826,7 @@ Displays minimum, maximum and sum of values for each plot.
15
190
746
- 149
+ 150
@@ -1844,7 +1844,7 @@ Displays minimum, maximum and sum of values for each plot.
10
20
726
- 125
+ 126
@@ -2207,7 +2207,7 @@ Displays minimum, maximum and sum of values for each plot.
-
+
true
@@ -2500,7 +2500,7 @@ Streaming Interval between 2 plots. Default is time interval with 200 ms.
400
130
- 351
+ 355
60
@@ -2518,7 +2518,7 @@ Streaming Interval between 2 plots. Default is time interval with 200 ms.
10
23
- 339
+ 342
37
@@ -2745,7 +2745,7 @@ Streaming Interval between 2 plots. Default is time interval with 200 ms.
box2D
boxSave
boxPlotAxis
- groupBox_3
+ boxPlotType
boxFrequency
boxSnapshot
diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h
index e427d12b0..1e7084ea0 100755
--- a/slsDetectorGui/include/qDefs.h
+++ b/slsDetectorGui/include/qDefs.h
@@ -130,18 +130,45 @@ class qDefs : public QWidget {
};
/**
- * returns the time in the appropriate time unit
+ * returns the value in ms
* @param unit unit of time
- * @param value time in seconds
- * returns the corresponding time value
+ * @param value time
+ * returns time value in ms
*/
- static double getCorrectTime(timeUnit &unit, double value) {
+ static double getMSTime(timeUnit unit, double value) {
+ double valueMS = value;
+ switch (unit) {
+ case NANOSECONDS:
+ valueMS /= 1000;
+ case MICROSECONDS:
+ valueMS /= 1000;
+ return valueMs;
+
+ case HOURS:
+ valueMS *= 60;
+ case MINUTES:
+ valueMS *= 60;
+ case SECONDS:
+ valueMS *= 1000;
+ default:
+ break;
+ }
+ return valueMS;
+ };
+
+ /**
+ * returns the time in the appropriate time unit
+ * @param value time in seconds
+ * returns the time in an appropriate time and unit
+ */
+ static std::pair getCorrectTime(double value) {
+ timeUnit unit;
int intUnit = (int)SECONDS;
/**0 ms*/
if (!value) {
unit = MILLISECONDS;
- return value;
+ return std::make_pair(value, unit);
}
/** hr, min, sec */
@@ -155,7 +182,7 @@ class qDefs : public QWidget {
}
/** returning the previous value*/
unit = (timeUnit)(intUnit + 1);
- return value;
+ return std::make_pair(value, unit);
}
/** ms, us, ns */
else {
@@ -164,7 +191,7 @@ class qDefs : public QWidget {
intUnit++;
}
unit = (timeUnit)(intUnit);
- return value;
+ return std::make_pair(value, unit);
}
};
diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h
index cd45afaee..1f62fc6b9 100755
--- a/slsDetectorGui/include/qDrawPlot.h
+++ b/slsDetectorGui/include/qDrawPlot.h
@@ -112,6 +112,8 @@ public:
/** Set Plot frame factor - between plots, also for receiver if exists */
void SetFrameFactor(int frame);
+ void SetCallBacks(bool enable);
+
/** Starts or stop acquisition
* Calls startDaq() function
* @param stop_if_running is 0 to stop acquisition and 1 to start acquisition
@@ -206,7 +208,6 @@ void DisplayStatistics(bool enable);
-
private:
/** Initializes all its members and the thread */
void Initialization();
diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h
index 5bd9106a3..a904b9481 100755
--- a/slsDetectorGui/include/qTabMeasurement.h
+++ b/slsDetectorGui/include/qTabMeasurement.h
@@ -67,8 +67,6 @@ private:
signals:
void StartSignal();
void StopSignal();
- void CheckPlotIntervalSignal();
-
private:
multiSlsDetector *myDet;
diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h
index 312b60fd4..d21726351 100755
--- a/slsDetectorGui/include/qTabPlot.h
+++ b/slsDetectorGui/include/qTabPlot.h
@@ -22,13 +22,8 @@ public:
void SetScanArgument();
void Refresh();
-public slots:
- void SetFrequency();
- void EnableScanBox();
-
private slots:
-
-xxxxxxxxxxxxxxx
+ void SetPlot();
void Set1DPlotOptionsRight();
void Set1DPlotOptionsLeft();
void Set2DPlotOptionsRight();
@@ -41,17 +36,7 @@ xxxxxxxxxxxxxxx
void SetYRange();
void CheckAspectRatio();
void SetZRange();
-
-
-
-
- void Select1DPlot(bool b);
- void SetPlot();
-
-
-
-
-
+ void SetStreamingFrequency();
signals:
void DisableZoomSignal(bool);
@@ -60,14 +45,15 @@ signals:
private:
void SetupWidgetWindow();
void Initialization();
+ void Select1DPlot(bool enable);
void GetGapPixels();
+ void GetStreamingFrequency();
void SetXYRange();
void MaintainAspectRatio(int dimension);
multiSlsDetector *myDet;
qDrawPlot *myPlot;
bool isOneD;
- bool isOriginallyOneD;
QButtonGroup *btnGroupPlotType;
/** interval between plots */
diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp
index 508ad37d0..c11c0eac5 100755
--- a/slsDetectorGui/src/qDetectorMain.cpp
+++ b/slsDetectorGui/src/qDetectorMain.cpp
@@ -292,7 +292,6 @@ void qDetectorMain::Initialization() {
// Measurement tab
connect(tabMeasurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs()));
connect(tabMeasurement, SIGNAL(StopSignal()), myPlot,SLOT(StopAcquisition()));
- connect(tabMeasurement, SIGNAL(CheckPlotIntervalSignal()), tabPlot,SLOT(SetFrequency()));
// Plot tab
connect(tabPlot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool)));
diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp
index 034beb849..c27902c7d 100755
--- a/slsDetectorGui/src/qDrawPlot.cpp
+++ b/slsDetectorGui/src/qDrawPlot.cpp
@@ -175,8 +175,7 @@ void qDrawPlot::SetupWidgetWindow() {
IsXYRange[2] = false;
IsXYRange[3] = false;
- timerValue = DEFAULT_STREAMING_TIMER_IN_MS;
- frameFactor = 0;
+
isFrameEnabled = false;
isTriggerEnabled = false;
@@ -355,8 +354,7 @@ void qDrawPlot::SetupWidgetWindow() {
gainDataEnable = false;
// callbacks
- // Setting the callback function to get data from detector class
- myDet->registerDataCallback(&(GetDataCallBack), this); // also enables data streaming in client and receiver (if receiver exists)
+ SetCallBacks(true);
//Setting the callback function to alert when acquisition finished from detector class
myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this);
//Setting the callback function to alert when each measurement finished from detector class
@@ -383,6 +381,15 @@ void qDrawPlot::Initialization() {
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
+void qDrawPlot::SetCallBacks(bool enable) {
+ if (enable) {
+ // Setting the callback function to get data from detector class
+ myDet->registerDataCallback(&(GetDataCallBack), this); // also enables data streaming in client and receiver (if receiver exists)
+ } else {
+ myDet->registerDataCallback(nullptr, this);
+ }
+}
+
void qDrawPlot::StartStopDaqToggle(bool stop_if_running) {
#ifdef VERYVERBOSE
diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp
index b9d0ba1cf..a0d5a4b72 100755
--- a/slsDetectorGui/src/qTabAdvanced.cpp
+++ b/slsDetectorGui/src/qTabAdvanced.cpp
@@ -759,10 +759,9 @@ void qTabAdvanced::GetSubExposureTime() {
spinSubExpTime->setValue(-1);
} else {
double value = (double)( retval * (1E-9));
- qDefs::timeUnit unit;
- double time = qDefs::getCorrectTime(unit, value);
- spinSubExpTime->setValue(time);
- comboSubExpTimeUnit->setCurrentIndex((int)unit);
+ auto time = qDefs::getCorrectTime(value);
+ spinSubExpTime->setValue(time.first);
+ comboSubExpTimeUnit->setCurrentIndex(static_cast(time.second));
}
} catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get sub exposure time.", e.what(), "qTabSettings::GetSubExposureTime");
@@ -796,10 +795,9 @@ void qTabAdvanced::GetSubDeadTime() {
spinSubDeadTime->setValue(-1);
} else {
double value = (double)(retval * (1E-9));
- qDefs::timeUnit unit;
- double time = qDefs::getCorrectTime(unit, value);
- spinSubDeadTime->setValue(time);
- comboSubDeadTimeUnit->setCurrentIndex((int)unit);
+ auto time = qDefs::getCorrectTime(value);
+ spinSubDeadTime->setValue(time.first);
+ comboSubDeadTimeUnit->setCurrentIndex(static_cast(time.second));
}
} catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get sub dead time.", e.what(), "qTabSettings::GetSubDeadTime");
diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp
index 3718ab9f4..be7b41c73 100755
--- a/slsDetectorGui/src/qTabMeasurement.cpp
+++ b/slsDetectorGui/src/qTabMeasurement.cpp
@@ -365,10 +365,9 @@ void qTabMeasurement::GetExposureTime() {
qDefs::Message(qDefs::WARNING, "Exposure Time is inconsistent for all detectors.", "qTabMeasurement::GetExposureTime");
spinExpTime->setValue(-1);
} else {
- qDefs::timeUnit unit;
- auto time = qDefs::getCorrectTime(unit, (static_cast(retval) * (1E-9)));
- spinExpTime->setValue(time);
- comboExpUnit->setCurrentIndex(static_cast(unit));
+ auto time = qDefs::getCorrectTime(static_cast(retval) * (1E-9));
+ spinExpTime->setValue(time.first);
+ comboExpUnit->setCurrentIndex(static_cast(time.second));
CheckAcqPeriodGreaterThanExp();
}
@@ -406,10 +405,9 @@ void qTabMeasurement::GetAcquisitionPeriod() {
qDefs::Message(qDefs::WARNING, "Acquisition Period is inconsistent for all detectors.", "qTabMeasurement::GetAcquisitionPeriod");
spinPeriod->setValue(-1);
} else {
- qDefs::timeUnit unit;
- auto time = qDefs::getCorrectTime(unit, (static_cast(retval) * (1E-9)));
- spinPeriod->setValue(time);
- comboPeriodUnit->setCurrentIndex(static_cast(unit));
+ auto time = qDefs::getCorrectTime(static_cast(retval) * (1E-9));
+ spinPeriod->setValue(time.first);
+ comboPeriodUnit->setCurrentIndex(static_cast(time.second));
CheckAcqPeriodGreaterThanExp();
}
@@ -457,8 +455,6 @@ void qTabMeasurement::CheckAcqPeriodGreaterThanExp() {
lblPeriod->setPalette(lblTimingMode->palette());
lblPeriod->setText("Acquisition Period:");
}
-
- emit CheckPlotIntervalSignal();
}
void qTabMeasurement::GetDelay() {
@@ -472,10 +468,9 @@ void qTabMeasurement::GetDelay() {
qDefs::Message(qDefs::WARNING, "Delay is inconsistent for all detectors.", "qTabMeasurement::GetDelay");
spinDelay->setValue(-1);
} else {
- qDefs::timeUnit unit;
- auto time = qDefs::getCorrectTime(unit, (static_cast(retval) * (1E-9)));
- spinDelay->setValue(time);
- comboDelayUnit->setCurrentIndex(static_cast(unit));
+ auto time = qDefs::getCorrectTime(static_cast(retval) * (1E-9));
+ spinDelay->setValue(time.first);
+ comboDelayUnit->setCurrentIndex(static_cast(time.second));
CheckAcqPeriodGreaterThanExp();
}
diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp
index c107f99a2..e102427b2 100755
--- a/slsDetectorGui/src/qTabPlot.cpp
+++ b/slsDetectorGui/src/qTabPlot.cpp
@@ -20,9 +20,9 @@ QString qTabPlot::defaultImageZAxisTitle("Intensity");
qTabPlot::qTabPlot(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) :
- QWidget(parent), myDet(detector), myPlot(plot), isOneD(false), isOriginallyOneD(false), wrongInterval(0),
+ QWidget(parent), myDet(detector), myPlot(plot), isOneD(false),
stackedLayout(nullptr), spinNthFrame(nullptr), spinTimeGap(nullptr), comboTimeGapUnit(nullptr),
- btnGroupPlotType(0) {
+ btnGroupPlotType(0) {
setupUi(this);
SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Plot ready";
@@ -35,7 +35,6 @@ void qTabPlot::SetupWidgetWindow() {
btnGroupPlotType = new QButtonGroup(this);
btnGroupPlotType->addButton(radioNoPlot, 0);
btnGroupPlotType->addButton(radioDataGraph, 1);
- btnGroupPlotType->addButton(radioHistogram, 2);
// Plotting Frequency
stackedLayout = new QStackedLayout;
stackedLayout->setSpacing(0);
@@ -88,30 +87,25 @@ void qTabPlot::SetupWidgetWindow() {
myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
- // enabling according to det type
- switch(myDet->getDetectorTypeAsEnum()) {
- case slsDetectorDefs::GOTTHARD:
- isOriginallyOneD = true;
- break;
- case slsDetectorDefs::EIGER:
- isOriginallyOneD = false;
- pagePedestal->setEnabled(false);
- pagePedestal_2->setEnabled(false);
- chkGapPixels->setEnabled(true);
- break;
- case slsDetectorDefs::JUNGFRAU:
- case slsDetectorDefs::MOENCH:
- isOriginallyOneD = false;
- chkGainPlot->setEnabled(true);
- break;
- default:
- break;
+ // enabling according to det type
+ isOneD = false;
+ switch(myDet->getDetectorTypeAsEnum()) {
+ case slsDetectorDefs::GOTTHARD:
+ isOneD = true;
+ break;
+ case slsDetectorDefs::EIGER:
+ chkGapPixels->setEnabled(true);
+ break;
+ case slsDetectorDefs::JUNGFRAU:
+ case slsDetectorDefs::MOENCH:
+ chkGainPlot->setEnabled(true);
+ break;
+ default:
+ break;
}
- Select1DPlot(isOriginallyOneD);
-
+ Select1DPlot(isOneD);
Initialization();
-
Refresh();
}
@@ -120,10 +114,10 @@ void qTabPlot::Initialization() {
connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this, SLOT(SetPlot()));
// Plotting frequency box
- connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
+ connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
+ connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
+ connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
+ connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
// navigation buttons for options
connect(btnRight1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsRight()));
@@ -204,7 +198,52 @@ void qTabPlot::Initialization() {
connect(this, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double)), myPlot, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double)));
}
-xxxxxxxxxxxxxxx
+void qTabPlot::Select1DPlot(bool enable) {
+ FILE_LOG(logDEBUG) << "Selecting " << (enable ? "1" : "2") << "D Plot";
+ isOneD = enable;
+ box1D->setEnabled(enable);
+ box2D->setEnabled(!benable);
+ chkZAxis->setEnabled(!enable);
+ dispZAxis->setEnabled(!enable);
+ chkZMin->setEnabled(!enable);
+ chkZMax->setEnabled(!enable);
+ dispZMin->setEnabled(!enable);
+ dispZMax->setEnabled(!enable);
+ if(enable) {
+ myPlot->Select1DPlot();
+ } else {
+ myPlot->Select2DPlot();
+ }
+ SetTitles();
+ SetXYRange();
+ if (!isOneD) {
+ SetZRange();
+ }
+}
+
+void qTabPlot::SetPlot() {
+ bool plotEnable = false;
+ if (radioNoPlot->isChecked()) {
+ FILE_LOG(logINFO) << "Setting Plot Type: No Plot";
+ } else if (radioDataGraph->isChecked()) {
+ FILE_LOG(logINFO) << "Setting Plot Type: Datagraph";
+ plotEnable = true;
+ }
+ boxFrequency->setEnabled(plotEnable);
+ box1D->setEnabled(plotEnable);
+ box2D->setEnabled(plotEnable);
+ boxSave->setEnabled(plotEnable);
+ boxSnapshot->setEnabled(plotEnable);
+ boxPlotAxis->setEnabled(plotEnable);
+
+ if (plotEnable) {
+ SetTitles();
+ SetXYRange();
+ if (!isOneD) {
+ SetZRange();
+ }
+ }
+}
void qTabPlot::Set1DPlotOptionsRight() {
FILE_LOG(logDEBUG) << "1D Options Right";
@@ -560,7 +599,6 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
emit DisableZoomSignal(true);
}
-
void qTabPlot::SetZRange() {
bool isZmin = chkZMin->isChecked();
bool isZmax = chkZMax->isChecked();
@@ -574,682 +612,104 @@ void qTabPlot::SetZRange() {
emit ResetZMinZMaxSignal(isZmin, isZmax, zmin, zmax);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-void qTabPlot::Select1DPlot(bool b) {
-#ifdef VERBOSE
- if (b)
- cout << "Selecting 1D Plot" << endl;
- else
- cout << "Selecting 2D Plot" << endl;
-#endif
- isOneD = b;
- lblFrom->setEnabled(false);
- lblTo->setEnabled(false);
- lblFrom_2->setEnabled(false);
- lblTo_2->setEnabled(false);
- spinFrom->setEnabled(false);
- spinFrom_2->setEnabled(false);
- spinTo->setEnabled(false);
- spinTo_2->setEnabled(false);
- if (b) {
- box1D->show();
- box2D->hide();
- chkZAxis->setEnabled(false);
- chkZMin->setEnabled(false);
- chkZMax->setEnabled(false);
- myPlot->Select1DPlot();
- } else {
- box1D->hide();
- box2D->show();
- chkZAxis->setEnabled(true);
- chkZMin->setEnabled(true);
- chkZMax->setEnabled(true);
- myPlot->Select2DPlot();
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-void qTabPlot::SetPlot() {
-#ifdef VERBOSE
- cout << "Entering Set Plot()";
-#endif
- if (radioNoPlot->isChecked()) {
- cout << " - No Plot" << endl;
-
- boxScan->show();
- boxHistogram->hide();
- myPlot->EnablePlot(false);
- boxSnapshot->setEnabled(false);
- boxSave->setEnabled(false);
- boxFrequency->setEnabled(false);
- boxPlotAxis->setEnabled(false);
- boxScan->setEnabled(false);
-
- } else if (radioDataGraph->isChecked()) {
- cout << " - DataGraph" << endl;
-
- boxScan->show();
- boxHistogram->hide();
- myPlot->EnablePlot(true);
- Select1DPlot(isOriginallyOneD);
- boxSnapshot->setEnabled(true);
- boxSave->setEnabled(true);
- boxFrequency->setEnabled(true);
- boxPlotAxis->setEnabled(true);
- // if(!myPlot->isRunning())
- // EnableScanBox();
- // To remind the updateplot in qdrawplot to set range after updating plot
- myPlot->SetXYRange(true);
- } else {
- //histogram and 2d scans dont work
- if (boxScan->isChecked()) {
- qDefs::Message(qDefs::WARNING, "Histogram cannot be used together with 2D Scan Plots.
"
- "Uncheck 2D Scan plots to plot Histograms",
- "qTabPlot::SetPlot");
- radioDataGraph->setChecked(true);
- boxScan->show();
- boxHistogram->hide();
- return;
- }
-
- cout << " - Histogram" << endl;
-
- if (radioHistIntensity->isChecked()) {
- pageHistogram->setEnabled(true);
- pageHistogram_2->setEnabled(true);
- } else {
- pageHistogram->setEnabled(false);
- pageHistogram_2->setEnabled(false);
- }
- boxScan->hide();
- boxHistogram->show();
- myPlot->EnablePlot(true);
- Select1DPlot(isOriginallyOneD);
- boxSnapshot->setEnabled(true);
- boxSave->setEnabled(true);
- boxFrequency->setEnabled(true);
- boxPlotAxis->setEnabled(true);
- // if(!myPlot->isRunning())
- // EnableScanBox();
-
- //qDefs::Message(qDefs::INFORMATION,"Please check the Plot Histogram Options below "
- // "before Starting Acquitision","qTabPlot::SetPlot");
- }
-}
-
-
-void qTabPlot::SetFrequency() {
-#ifdef VERBOSE
- cout << "Setting Plot Interval Frequency" << endl;
-#endif
- disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- double timeMS, acqPeriodMS;
- double minPlotTimer = myPlot->GetMinimumPlotTimer();
- char cMin[200];
- sprintf(cMin, "%f ms", minPlotTimer);
-
- acqPeriodMS = (myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, -1) * (1E-6));
- //if period is 0, check exptime, if that is also 0, give warning and set to min timer
- if (acqPeriodMS == 0) {
- acqPeriodMS = (myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, -1) * (1E-6));
-
- if (acqPeriodMS == 0) {
- //to reduce the warnings displayed
- if ((comboFrequency->currentIndex() == 0) && (spinTimeGap->value() == minPlotTimer))
- ;
- else
- qDefs::Message(qDefs::WARNING, "Interval between Plots:
"
- "Every Nth Image: Period betwen Frames and Exposure Time cannot both be 0 ms.
"
- "Resetting to minimum plotting time interval",
- "qTabPlot::SetFrequency");
+void qTabPlot::GetStreamingFrequency() {
+ FILE_LOG(logDEBUG) << "Getting Streaming Frequency";
+ disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
+ disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
+ disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
+ disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
+
+ try {
+ int freq = myDet->setReceiverStreamingFrequency(-1);
+ if (freq < 0) {
+ qDefs::Message(qDefs::WARNING, "Streaming frequency is inconsistent for all detectors.", "qTabPlot::GetStreamingFrequency");
+ }
+ // time interval
+ else if (freq == 0) {
comboFrequency->setCurrentIndex(0);
- stackedLayout->setCurrentIndex(comboFrequency->currentIndex());
- spinTimeGap->setValue(minPlotTimer);
- comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS);
- timeMS = minPlotTimer;
- //This is done so that its known which one was selected
- myPlot->SetFrameFactor(0);
- // Setting the timer value(ms) between plots
- myPlot->SetPlotTimer(timeMS);
-
- connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- qDefs::checkErrorMessage(myDet, "qTabPlot::SetFrequency");
- return;
+ stackedLayout->setCurrentIndex(0);
+ try {
+ int timeMs = myDet->setReceiverStreamingTimer(-1);
+ if (freq < 0) {
+ qDefs::Message(qDefs::WARNING, "Streaming timer is inconsistent for all detectors.", "qTabPlot::GetStreamingFrequency");
+ } else {
+ double timeS = static_cast(timeMs) / 1000.00;
+ auto time = qDefs::getCorrectTime(timeS);
+ spinTimeGap->setValue(time.first);
+ comboTimeGapUnit->setcurrentIndex(static_cast(time.second));
+ }
+ } catch(const sls::NonCriticalError &e) {
+ qDefs::ExceptionMessage("Could not get streaming timer.", e.what(), "qTabPlot::GetStreamingFrequency");
+ }
}
- }
-
- stackedLayout->setCurrentIndex(comboFrequency->currentIndex());
- switch (comboFrequency->currentIndex()) {
- case 0:
- // Get the time interval from gui in ms
- timeMS = (qDefs::getNSTime((qDefs::timeUnit)comboTimeGapUnit->currentIndex(), spinTimeGap->value())) / (1e6);
-
- if ((int)timeMS == 0) {
- qDefs::Message(qDefs::WARNING, "Interval between Plots:
"
- "Time Interval must be atleast >= 1 ms. Resetting to minimum plotting time interval.",
- "qTabPlot::SetFrequency");
- spinTimeGap->setValue(minPlotTimer);
- comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS);
- timeMS = minPlotTimer;
- }
-
- //show red if min intervalInterval between Plots: You might be losing Images!","Plot");
- boxFrequency->setPalette(*red);
- boxFrequency->setTitle("Interval between Plots*");
- QString errTip = intervalTip + QString("
"
- "Time Interval Condition: min of ") +
- QString("%1").arg(minPlotTimer) +
- QString("ms.
You might be losing images!");
- boxFrequency->setToolTip(errTip);
- }
- //show red if acqPeriodInterval between Plots: You might be losing Images!","Plot");
- boxFrequency->setPalette(*red);
- boxFrequency->setTitle("Interval between Plots*");
- QString errTip = intervalTip + QString("
"
- "Time Interval Acquisition Period should be >= Time Interval between plots.
"
- "You might be losing images!");
- boxFrequency->setToolTip(errTip);
- }
- //correct
+ // every nth frame
else {
- boxFrequency->setPalette(boxSnapshot->palette());
- boxFrequency->setTitle("Interval between Plots");
- boxFrequency->setToolTip(intervalTip);
+ comboFrequency->setCurrentIndex(1);
+ stackedLayout->setCurrentIndex(1);
+ spinNthFrame->setValue(freq);
}
+ } catch (const sls::NonCriticalError &e) {
+ qDefs::ExceptionMessage("Could not get streaming frequency.", e.what(), "qTabPlot::GetStreamingFrequency");
+ }
- //This is done so that its known which one was selected
- myPlot->SetFrameFactor(0);
- // Setting the timer value(ms) between plots
- myPlot->SetPlotTimer(timeMS);
-#ifdef VERBOSE
- cout << "Plotting Frequency: Time Gap - " << spinTimeGap->value() << qDefs::getUnitString((qDefs::timeUnit)comboTimeGapUnit->currentIndex()) << endl;
-#endif
- break;
+ connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
+ connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
+ connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
+ connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
- case 1:
+}
- // gets the acq period * number of nth frames
- timeMS = (spinNthFrame->value()) * acqPeriodMS;
+void qTabPlot::SetStreamingFrequency() {
+ bool frequency = (comboFrequency->currentIndex() == 0) ? 0 : 1;
+ auto freqVal = spinNthFrame->value();
+ auto timeVal = spinTimeGap->value();
+ auto timeUnit = static_cast(comboTimeGapUnit->currentIndex());
- //Show red to make sure the period between plotting is not less than minimum plot timer in ms
- if (timeMS < minPlotTimer) {
- int minFrame = (int)(ceil)(minPlotTimer / acqPeriodMS);
- //qDefs::Message(qDefs::WARNING,"Interval between Plots: You might be losing Images!","Plot");
- boxFrequency->setPalette(*red);
- boxFrequency->setTitle("Interval between Plots*");
- QString errTip = intervalTip + QString("
"
- "Every nth Image Condition: min nth Image for this time period: ") +
- QString("%1").arg(minFrame) +
- QString(".
You might be losing images!");
- boxFrequency->setToolTip(errTip);
+ try {
+ if (frequency) {
+ FILE_LOG(logINFO) << "Setting Streaming Frequency to " << freqVal;
+ myDet->setReceiverStreamingFrequency(freqVal);
} else {
- boxFrequency->setPalette(boxSnapshot->palette());
- boxFrequency->setTitle("Interval between Plots");
- boxFrequency->setToolTip(intervalTip);
+ FILE_LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " " << qDefs::getUnitString(timeUnit);
+ double timeMS = qDefs::getMSTime(timeUnit, timeVal);
+ myDet->setReceiverStreamingTimer(timeMS);
}
-
- // Setting the timer value (nth frames) between plots
- myPlot->SetFrameFactor(spinNthFrame->value());
-
-#ifdef VERBOSE
- cout << "Plotting Frequency: Nth Frame - " << spinNthFrame->value() << endl;
-#endif
- break;
- }
-
- connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- qDefs::checkErrorMessage(myDet, "qTabPlot::SetFrequency");
-}
-
- void qTabPlot::EnableScanBox(){
- #ifdef VERBOSE
- cout << "Entering Enable Scan Box"<< endl;
- #endif
- disconnect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot()));
- disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
-
- int oldfreqvalue = myDet->setReadReceiverFrequency();
-
- int mode0 = myDet->getScanMode(0);
- int mode1 = myDet->getScanMode(1);
-
- radioHistLevel0->setEnabled(mode0);
- radioHistLevel1->setEnabled(mode1);
- int ang;
- bool angConvert = myDet->getAngularConversion(ang);
- myPlot->EnableAnglePlot(angConvert);
-
- radioDataGraph->setEnabled(true);
- radioHistogram->setEnabled(true);
- chkSuperimpose->setEnabled(true);
- pageAccumulate->setEnabled(true);
- pageAccumulate_2->setEnabled(true);
- if((myDet->getDetectorsType() == slsDetectorDefs::GOTTHARD) ||
- (myDet->getDetectorsType() == slsDetectorDefs::PROPIX) ||
- (myDet->getDetectorsType() == slsDetectorDefs::JUNGFRAU) ||
- (myDet->getDetectorsType() == slsDetectorDefs::MOENCH)){
- pagePedestal->setEnabled(true);
- pagePedestal_2->setEnabled(true);
- chkBinary->setEnabled(true);
- chkBinary_2->setEnabled(true);
- }
-
- //if angle plot or originally 2d, uncheck and disable scanbox
- if ((angConvert) || (!isOriginallyOneD)){
- boxScan->setChecked(false);
- boxScan->setEnabled(false);
-
- /**Newly added*/
- // To remind the updateplot in qdrawplot to set range after updating plot
- if(!isOriginallyOneD)
- myPlot->SetXYRange(true);
-
- //2d scans read every frame, not compulsory, but for historgrams
- if((!isOriginallyOneD) && (mode0 || mode1)){
- //read every frame
- disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- comboFrequency->setCurrentIndex(1);
- spinNthFrame->setValue(1);
- SetFrequency();
- connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- }
-
- //persistency, accumulate, pedestal, binary
- if(angConvert){
- if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false);
- if(chkPedestal->isChecked()) chkPedestal->setChecked(false);
- if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false);
- if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false);
- if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false);
- if(chkBinary->isChecked()) chkBinary->setChecked(false);
- if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false);
- pagePedestal->setEnabled(false);
- pagePedestal_2->setEnabled(false);
- chkBinary->setEnabled(false);
- chkBinary_2->setEnabled(false);
- pageAccumulate->setEnabled(false);
- pageAccumulate_2->setEnabled(false);
- }
-
- if(angConvert){
- boxScan->setToolTip("Only 1D Plots enabled for Angle Plots");
- //disable histogram
- if(radioHistogram->isChecked()){
- radioDataGraph->setChecked(true);
- radioHistogram->setEnabled(false);
- // To remind the updateplot in qdrawplot to set range after updating plot
- myPlot->SetXYRange(true);
- boxScan->show();
- boxHistogram->hide();
- }
- }
- }
-
- //originally1d && not angle plot
- else{
- boxScan->setToolTip("");
- boxScan->setEnabled(true);
- /*if(mode0 || mode1)
- boxScan->setChecked(true);*/
-
- //2d enabled with boxscan
- if(boxScan->isChecked()){
-
- //2d for 1d detctors and histogram dont go
- if(radioHistogram->isChecked()){
- radioDataGraph->setChecked(true);
- // To remind the updateplot in qdrawplot to set range after updating plot
- myPlot->SetXYRange(true);
- boxScan->show();
- boxHistogram->hide();
- }
-
- //read every frame
- disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- comboFrequency->setCurrentIndex(1);
- spinNthFrame->setValue(1);
- SetFrequency();
- connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
-
- //enabling options
- radioFileIndex->setEnabled(mode0||mode1);
- if(mode0 && mode1){
- radioLevel0->setEnabled(false);
- radioLevel1->setEnabled(false);
- }else{
- radioLevel0->setEnabled(mode0);
- radioLevel1->setEnabled(mode1);
- }
- //default is allframes if checked button is disabled
- if(!btnGroupScan->checkedButton()->isEnabled())
- radioAllFrames->setChecked(true);
- }
- }
-
- //histogram
- if(radioHistogram->isChecked()){
- if(radioHistIntensity->isChecked()){
- pageHistogram->setEnabled(true);
- pageHistogram_2->setEnabled(true);
- }else{
- pageHistogram->setEnabled(false);
- pageHistogram_2->setEnabled(false);
- }
- stackedWidget->setCurrentIndex(stackedWidget->count()-1);
- stackedWidget_2->setCurrentIndex(stackedWidget_2->count()-1);
- box1D->setTitle(QString("1D Plot Options %1 - Histogram").arg(stackedWidget->currentIndex()+1));
- box2D->setTitle(QString("2D Plot Options %1 - Histogram").arg(stackedWidget_2->currentIndex()+1));
-
- if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false);
- if(chkPedestal->isChecked()) chkPedestal->setChecked(false);
- if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false);
- if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false);
- if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false);
- if(chkBinary->isChecked()) chkBinary->setChecked(false);
- if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false);
- pagePedestal->setEnabled(false);
- pagePedestal_2->setEnabled(false);
- chkBinary->setEnabled(false);
- chkBinary_2->setEnabled(false);
- pageAccumulate->setEnabled(false);
- pageAccumulate_2->setEnabled(false);
-
- //read every frame
- disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- comboFrequency->setCurrentIndex(1);
- spinNthFrame->setValue(1);
- SetFrequency();
- connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
-
- }else{
- pageHistogram->setEnabled(false);
- pageHistogram_2->setEnabled(false);
- }
-
- // if it was set to read every frame
- if (oldfreqvalue != 0 && (comboFrequency->currentIndex() != 1 || spinNthFrame->value() != oldfreqvalue)) {
- disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- comboFrequency->setCurrentIndex(1);
- spinNthFrame->setValue(1);
- SetFrequency();
- connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
- connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
- }
-
- connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot()));
- connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
-
- }
-
-
- void qTabPlot::SetScanArgument(){
- #ifdef VERYVERBOSE
- cout << "Entering qTabPlot::SetScanArgument()" << endl;
- #endif
-
- //1d
- if(isOriginallyOneD){
- dispXAxis->setText(defaultHistXAxisTitle);
- dispYAxis->setText(defaultHistYAxisTitle);
- myPlot->SetHistXAxisTitle(defaultHistXAxisTitle);
- myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
- Select1DPlot(true);
- }
- //2d
- else{
- dispXAxis->setText(defaultImageXAxisTitle);
- dispYAxis->setText(defaultImageYAxisTitle);
- dispZAxis->setText(defaultImageZAxisTitle);
- myPlot->SetImageXAxisTitle(defaultImageXAxisTitle);
- myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
- myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
- Select1DPlot(false);
- }
-
- //histogram default - set before setscanargument
- int min = spinHistFrom->value();
- int max = spinHistTo->value();
- double size = spinHistSize->value();
- int histArg = qDefs::Intensity;
- if(radioHistogram->isChecked()){
- if(!radioHistIntensity->isChecked()){
-
- int mode = 0;
- histArg = qDefs::histLevel0;
- if(radioHistLevel1->isChecked()){
- mode = 1;
- histArg = qDefs::histLevel1;
- }
-
- int numSteps = myDet->getScanSteps(mode);
- double *values = NULL;
- min = 0;max = 1;size = 1;
-
- if(numSteps > 0){
- values = new double[numSteps];
- myDet->getScanSteps(mode,values);
- min = values[0];
- max = values[numSteps - 1];
- size = (max - min)/(numSteps - 1);
- }
- }
-
- }
-
- //cout <<"min:"<SetHistogram(radioHistogram->isChecked(),histArg,min,max,size);
-
- if(radioHistogram->isChecked()){
- if(radioHistIntensity->isChecked())
- dispXAxis->setText("Intensity");
- else if (radioHistLevel0->isChecked())
- dispXAxis->setText("Level 0");
- else
- dispXAxis->setText("Level 1");
- dispYAxis->setText("Frequency");
- myPlot->SetHistXAxisTitle("Intensity");
- myPlot->SetHistYAxisTitle("Frequency");
- Select1DPlot(true);
- }
-
- //angles (1D)
- int ang;
- if(myDet->getAngularConversion(ang)){
- dispXAxis->setText("Angles");
- myPlot->SetHistXAxisTitle("Angles");
- Select1DPlot(true);
- }
-
- //1d with scan
- if(boxScan->isChecked()){
- myPlot->SetScanArgument(btnGroupScan->checkedId()+1);
-
- switch(btnGroupScan->checkedId()){
- case 0://level0
- dispYAxis->setText("Scan Level 0");
- myPlot->SetImageYAxisTitle("Scan Level 0");
- break;
- case 1://level1
- dispYAxis->setText("Scan Level 1");
- myPlot->SetImageYAxisTitle("Scan Level 1");
- break;
- break;
- case 2://file index
- dispYAxis->setText("Frame Index");
- myPlot->SetImageYAxisTitle("Frame Index");
- break;
- case 3://all frames
- dispYAxis->setText("All Frames");
- myPlot->SetImageYAxisTitle("All Frames");
- break;
- }
- Select1DPlot(false);
- }else
- myPlot->SetScanArgument(qDefs::None);
-
- //update the from and to labels to be enabled
- SetBinary();
-
- qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument");
-
- }
-
-
-
-
-
-void qTabPlot::SetHistogramOptions() {
- if (radioHistIntensity->isChecked()) {
- pageHistogram->setEnabled(true);
- pageHistogram_2->setEnabled(true);
- } else {
- pageHistogram->setEnabled(false);
- pageHistogram_2->setEnabled(false);
+ } catch (const sls::NonCriticalError &e) {
+ qDefs::ExceptionMessage("Could not set streaming frequency/ timer.", e.what(), "qTabPlot::SetStreamingFrequency");
+ GetStreamingFrequency();
}
}
-
-
void qTabPlot::Refresh() {
+ FILE_LOG(logDEBUG) << "**Updating Plot Tab";
-
-
-#ifdef VERBOSE
- cout << endl
- << "**Updating Plot Tab" << endl;
-#endif
if (!myPlot->isRunning()) {
- if (!radioNoPlot->isChecked())
- boxFrequency->setEnabled(true);
- SetFrequency();
-
- if (chkGapPixels->isEnabled()) {
- GetGapPixels();
- }
+ boxPlotType->setEnabled(true);
+ // streaming frequency
+ if (!radioNoPlot->isChecked()) {
+ boxFrequency->setEnabled(true);
+ }
+ GetStreamingFrequency();
+ // gain plot, gap pixels enable
+ switch(myDet->getDetectorTypeAsEnum()) {
+ case slsDetectorDefs::EIGER:
+ chkGapPixels->setEnabled(true);
+ GetGapPixels();
+ break;
+ case slsDetectorDefs::JUNGFRAU:
+ case slsDetectorDefs::MOENCH:
+ chkGainPlot->setEnabled(true);
+ break;
+ default:
+ break;
+ }
} else {
+ boxPlotType->setEnabled(false);
boxFrequency->setEnabled(false);
- disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
- boxScan->setEnabled(false);
- pageHistogram->setEnabled(false);
- pageHistogram_2->setEnabled(false);
- if (radioHistogram->isChecked())
- radioDataGraph->setEnabled(false);
- else
- radioHistogram->setEnabled(false);
+ chkGainPlot->setEnabled(false);
+ chkGapPixels->setEnabled(false);
}
-#ifdef VERBOSE
- cout << "**Updated Plot Tab" << endl
- << endl;
-#endif
+
+ FILE_LOG(logDEBUG) << "**Updated Plot Tab";
}