From df01ca7e4b7983425429e20d70b0da83a0da57df Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 22 Jun 2017 16:44:13 +0200 Subject: [PATCH] ensuring acquire, p receiver start and the gui enables and disables data streaming accordingly. those with api will have to know what they want before acquiring --- slsDetectorGui/include/qDrawPlot.h | 2 ++ slsDetectorGui/src/qDetectorMain.cpp | 2 +- slsDetectorGui/src/qDrawPlot.cpp | 19 +++++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index a600acee4..10393b386 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -571,6 +571,8 @@ QVector histogramSamples; bool plotRequired; + + signals: void UpdatingPlotFinished(); void InterpolateSignal(bool); diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 369f1e473..d83b52680 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -296,7 +296,7 @@ void qDetectorMain::SetUpDetector(const string fName){ //#endif myDet->setOnline(slsDetectorDefs::ONLINE_FLAG); if(detType != slsDetectorDefs::MYTHEN) { - if(myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG) == slsDetectorDefs::ONLINE_FLAG) {cprintf(GREEN,"is online!\n"); + if(myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG) == slsDetectorDefs::ONLINE_FLAG) { myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG); }else cprintf(RED,"is not online!\n"); } diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 624073cbb..c68150f3b 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -332,11 +332,6 @@ void qDrawPlot::SetupWidgetWindow(){ myDet->registerMeasurementFinishedCallback(&(GetMeasurementFinishedCallBack),this); //Setting the callback function to get progress from detector class(using receivers) myDet->registerProgressCallback(&(GetProgressCallBack),this); - //stream data from receiver to the gui - if(detType != slsDetectorDefs::MYTHEN && myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG) == slsDetectorDefs::ONLINE_FLAG) { - myDet->enableDataStreamingFromReceiver(1); - } - qDefs::checkErrorMessage(myDet,"qDrawPlot::SetupWidgetWindow"); } @@ -496,7 +491,7 @@ bool qDrawPlot::StartOrStopThread(bool start){ /*XYRangeChanged = true;*/ boxPlot->setTitle("Old_Plot.raw"); - cout << "Starting new acquisition thread ...." << endl; + cprintf(BLUE, "Starting new acquisition thread ....\n"); // Start acquiring data from server if(!firstTime) pthread_join(gui_acquisition_thread,NULL);//wait until he's finished, ie. exits pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this); @@ -731,6 +726,18 @@ void qDrawPlot::SetupMeasurement(){ void* qDrawPlot::DataStartAcquireThread(void *this_pointer){ + //stream data from receiver to the gui + if(((qDrawPlot*)this_pointer)->myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG) == slsDetectorDefs::ONLINE_FLAG) { + //if it was not on + if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingFromReceiver(-1)!= 1){ + //switch it on, if error + if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingFromReceiver(1) != 1) { + qDefs::checkErrorMessage(((qDrawPlot*)this_pointer)->myDet,"qDrawPlot::DataStartAcquireThread"); + return this_pointer; + } + } + } + ((qDrawPlot*)this_pointer)->myDet->acquire(1); return this_pointer; }