diff --git a/cmk.sh b/cmk.sh index 52fda3004..898e6f96f 100755 --- a/cmk.sh +++ b/cmk.sh @@ -187,8 +187,8 @@ fi #Debug if [ $DEBUG -eq 1 ]; then - CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug " -# CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON " +# CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug " + CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SANITIZER=ON " echo "Debug Option enabled" fi diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 950154bae..fb6585db2 100755 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -12,7 +12,6 @@ class detectorData; #include "Detector.h" class QResizeEvent; -#include #include @@ -64,11 +63,11 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { private slots: void SetSaveFileName(QString val); - void AcquireFinished(); + void AcquireThread(); void UpdatePlot(); - signals: + void StartAcquireSignal(); void AcquireFinishedSignal(); void AbortSignal(); void UpdateSignal(); @@ -81,7 +80,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { void DetachHists(); static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer); static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer); - std::string AcquireThread(); void AcquisitionFinished(double currentProgress, int detectorStatus); void GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex); void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL); @@ -102,7 +100,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { SlsQtH1D * gainhist1d{nullptr}; SlsQt2DPlot *plot2d{nullptr}; SlsQt2DPlot *gainplot2d{nullptr}; - QFutureWatcher *acqResultWatcher; bool is1d{true}; bool isRunning{false}; diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h index a9b8a6028..76a63758a 100755 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h @@ -26,7 +26,7 @@ class SlsQt2DHist: public QwtRasterData{ double x_width,y_width; int nx,ny,nb; - double *data; + double *data{nullptr}; double z_min,z_mean,z_max; bool z_mean_has_been_calculated; diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx index ee6749f45..5fa7be29a 100755 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx @@ -55,9 +55,11 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) { SlsQt2DPlot::~SlsQt2DPlot() { if (d_spectrogram) { d_spectrogram->detach(); + //delete d_spectrogram; } - if (hist) + if (hist) { delete hist; + } if (colorMapLinearScale) delete colorMapLinearScale; if (colorMapLogScale) diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index d60492f4a..3b7d3c5c5 100755 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -13,7 +13,6 @@ #include #include - qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector) { setupUi(this); SetupWidgetWindow(); @@ -91,15 +90,12 @@ void qDrawPlot::SetupWidgetWindow() { SetupPlots(); SetDataCallBack(true); det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this); - // future watcher to watch result of AcquireThread only because it uses signals/slots to handle acquire exception - acqResultWatcher = new QFutureWatcher(); - Initialization(); } void qDrawPlot::Initialization() { connect(this, SIGNAL(UpdateSignal()), this, SLOT(UpdatePlot())); - connect(acqResultWatcher, SIGNAL(finished()), this, SLOT(AcquireFinished())); + connect(this, SIGNAL(StartAcquireSignal()), this, SLOT(AcquireThread())); } void qDrawPlot::SetupPlots() { @@ -640,16 +636,19 @@ void qDrawPlot::StartAcquisition() { xyRangeChanged = true; } - // acquisition in another thread - QFuture future = QtConcurrent::run(this, &qDrawPlot::AcquireThread); - acqResultWatcher->setFuture(future); - + emit StartAcquireSignal(); FILE_LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot"; } -void qDrawPlot::AcquireFinished() { - FILE_LOG(logDEBUG) << "Acquisition Finished"; - std::string mess = acqResultWatcher->result(); +void qDrawPlot::AcquireThread() { + FILE_LOG(logDEBUG) << "Acquire Thread"; + std::string mess; + try { + det->acquire(); + } catch (const std::exception &e) { + mess = std::string(e.what()); + } + FILE_LOG(logINFO) << "Acquisition Finished"; // exception in acquire will not call acquisition finished call back, so handle it if (!mess.empty()) { FILE_LOG(logERROR) << "Acquisition Finished with an exception: " << mess; @@ -662,17 +661,7 @@ void qDrawPlot::AcquireFinished() { } CATCH_DISPLAY("Could not stop receiver.", "qDrawPlot::AcquireFinished"); emit AbortSignal(); } - FILE_LOG(logDEBUG) << "End of Acquisition Finished"; -} - -std::string qDrawPlot::AcquireThread() { - FILE_LOG(logDEBUG) << "Acquire Thread"; - try { - det->acquire(); - } catch (const std::exception &e) { - return std::string(e.what()); - } - return std::string(""); + FILE_LOG(logDEBUG) << "End of Acquisition Finished"; } void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer) { @@ -786,6 +775,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra } else { Get2dData(rawData); } + delete [] rawData; FILE_LOG(logDEBUG) << "End of Get Data"; emit UpdateSignal(); diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 5e3272784..eefe1b900 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -492,7 +492,7 @@ std::string CmdProxy::ClockFrequency(int action) { } else { defs::detectorType type = det->getDetectorType().squash(defs::GENERIC); if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) { - throw sls::RuntimeError("Not implemented for this detector."); + throw sls::RuntimeError("clkfreq not implemented for this detector."); } if (action == defs::GET_ACTION) { if (args.size() != 1) { @@ -526,7 +526,7 @@ std::string CmdProxy::ClockPhase(int action) { } else { defs::detectorType type = det->getDetectorType().squash(defs::GENERIC); if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) { - throw sls::RuntimeError("Not implemented for this detector."); + throw sls::RuntimeError("clkphase not implemented for this detector."); } if (action == defs::GET_ACTION) { if (args.size() == 1) { @@ -576,7 +576,7 @@ std::string CmdProxy::MaxClockPhaseShift(int action) { } else { defs::detectorType type = det->getDetectorType().squash(defs::GENERIC); if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) { - throw sls::RuntimeError("Not implemented for this detector."); + throw sls::RuntimeError("maxclkphaseshift not implemented for this detector."); } if (action == defs::GET_ACTION) { if (args.size() != 1) { @@ -603,7 +603,7 @@ std::string CmdProxy::ClockDivider(int action) { } else { defs::detectorType type = det->getDetectorType().squash(defs::GENERIC); if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) { - throw sls::RuntimeError("Not implemented for this detector."); + throw sls::RuntimeError("clkdiv not implemented for this detector."); } if (action == defs::GET_ACTION) { if (args.size() != 1) { diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index ec597f0c1..0553a60e9 100755 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1083,7 +1083,7 @@ std::vector DetectorImpl::readProgrammingFile(const std::string &fname) { } break; default: - throw RuntimeError("Not implemented for this detector"); + throw RuntimeError("programfpga not implemented for this detector"); } FILE_LOG(logINFO) diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index fe4a9ab49..0bd6cbc3f 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -2920,7 +2920,7 @@ int slsDetector::enableGapPixels(int val) { int slsDetector::setTrimEn(const std::vector& energies) { if (shm()->myDetectorType != EIGER) { - throw RuntimeError("Not implemented for this detector."); + throw RuntimeError("setTrimEn not implemented for this detector."); } if (energies.size() > MAX_TRIMEN) { std::ostringstream os; @@ -2935,7 +2935,7 @@ int slsDetector::setTrimEn(const std::vector& energies) { std::vector slsDetector::getTrimEn() { if (shm()->myDetectorType != EIGER) { - throw RuntimeError("Not implemented for this detector."); + throw RuntimeError("getTrimEn not implemented for this detector."); } return std::vector(shm()->trimEnergies.begin(), shm()->trimEnergies.end());