removed the normal timer on the updateplot, it shold now plot as soon as it gets the data

This commit is contained in:
Dhanya Maliakal 2016-11-10 12:23:01 +01:00
parent a0b28503d0
commit 3c48065b5a
2 changed files with 211 additions and 213 deletions

View File

@ -101,7 +101,7 @@ public:
/** Get minimum Plot timer - between plots */ /** Get minimum Plot timer - between plots */
double GetMinimumPlotTimer(){return PLOT_TIMER_MS;}; double GetMinimumPlotTimer(){return PLOT_TIMER_MS;};
/** Set Plot timer - between plots in ms*/ /** Set Plot timer - between plots in ms*/
void SetPlotTimer(double time){timerValue = time;}; void SetPlotTimer(double time);
/** Set Plot frame factor - between plots, also for receiver if exists */ /** Set Plot frame factor - between plots, also for receiver if exists */
void SetFrameFactor(int frame); void SetFrameFactor(int frame);
@ -293,9 +293,6 @@ private slots:
/** To update plot /** To update plot
* */ * */
void UpdatePlot(); void UpdatePlot();
/** To stop updating plot
* */
void StopUpdatePlot();
/** To start or stop acquisition /** To start or stop acquisition
* @param start is 1 to start and 0 to stop acquisition * @param start is 1 to start and 0 to stop acquisition
* */ * */
@ -322,6 +319,8 @@ private:
/** The sls detector object */ /** The sls detector object */
multiSlsDetector *myDet; multiSlsDetector *myDet;
/** detectot type */
slsDetectorDefs::detectorType detType;
/** Widgets needed to plot the clone */ /** Widgets needed to plot the clone */
@ -423,7 +422,6 @@ double pixelWidth;
/** Current Image Number */ /** Current Image Number */
unsigned int lastImageNumber; unsigned int lastImageNumber;
int last_plot_number;
/** Number of graphs in 1D */ /** Number of graphs in 1D */
unsigned int nHists; unsigned int nHists;
@ -586,6 +584,7 @@ void ResetZMinZMaxSignal(bool,bool,double,double);
void SetCurrentMeasurementSignal(int); void SetCurrentMeasurementSignal(int);
void saveErrorSignal(QString); void saveErrorSignal(QString);
void AcquisitionErrorSignal(QString); void AcquisitionErrorSignal(QString);
void UpdatePlotSignal();
}; };

View File

@ -63,7 +63,8 @@ void qDrawPlot::SetupWidgetWindow(){
#endif #endif
// Depending on whether the detector is 1d or 2d // Depending on whether the detector is 1d or 2d
switch(myDet->getDetectorsType()){ detType = myDet->getDetectorsType();
switch(detType){
case slsDetectorDefs::MYTHEN: originally2D = false; break; case slsDetectorDefs::MYTHEN: originally2D = false; break;
case slsDetectorDefs::EIGER: originally2D = true; break; case slsDetectorDefs::EIGER: originally2D = true; break;
case slsDetectorDefs::GOTTHARD: originally2D = false; break; case slsDetectorDefs::GOTTHARD: originally2D = false; break;
@ -77,7 +78,7 @@ void qDrawPlot::SetupWidgetWindow(){
//initialization //initialization
data_pause_over = true;//to get the first image data_pause_over = true;
currentMeasurement = 0; currentMeasurement = 0;
currentFrame = 0; currentFrame = 0;
@ -89,7 +90,7 @@ void qDrawPlot::SetupWidgetWindow(){
acquisitionPeriod = 0; acquisitionPeriod = 0;
exposureTime = 0; exposureTime = 0;
currentFileIndex = 0; currentFileIndex = 0;
currentFrameIndex = 0; currentFrameIndex = -1;
stop_signal = 0; stop_signal = 0;
pthread_mutex_init(&last_image_complete_mutex,NULL); pthread_mutex_init(&last_image_complete_mutex,NULL);
@ -120,7 +121,6 @@ void qDrawPlot::SetupWidgetWindow(){
pixelWidth = 0; pixelWidth = 0;
lastImageNumber = 0; lastImageNumber = 0;
last_plot_number = 0;
nHists = 0; nHists = 0;
histNBins = 0; histNBins = 0;
@ -234,8 +234,6 @@ void qDrawPlot::SetupWidgetWindow(){
boxPlot->setAlignment(Qt::AlignHCenter); boxPlot->setAlignment(Qt::AlignHCenter);
boxPlot->setFont(QFont("Sans Serif",11,QFont::Normal)); boxPlot->setFont(QFont("Sans Serif",11,QFont::Normal));
boxPlot->setTitle("Sample Plot"); boxPlot->setTitle("Sample Plot");
plot_update_timer = new QTimer(this);
connect(plot_update_timer, SIGNAL(timeout()), this, SLOT(UpdatePlot()));
data_pause_timer = new QTimer(this); data_pause_timer = new QTimer(this);
connect(data_pause_timer, SIGNAL(timeout()), this, SLOT(UpdatePause())); connect(data_pause_timer, SIGNAL(timeout()), this, SLOT(UpdatePause()));
@ -345,6 +343,7 @@ void qDrawPlot::SetupWidgetWindow(){
void qDrawPlot::Initialization(){ void qDrawPlot::Initialization(){
connect(this, SIGNAL(UpdatePlotSignal()), this, SLOT(UpdatePlot()));
connect(this, SIGNAL(InterpolateSignal(bool)),plot2D, SIGNAL(InterpolateSignal(bool))); connect(this, SIGNAL(InterpolateSignal(bool)),plot2D, SIGNAL(InterpolateSignal(bool)));
connect(this, SIGNAL(ContourSignal(bool)), plot2D, SIGNAL(ContourSignal(bool))); connect(this, SIGNAL(ContourSignal(bool)), plot2D, SIGNAL(ContourSignal(bool)));
connect(this, SIGNAL(LogzSignal(bool)), plot2D, SLOT(SetZScaleToLog(bool))); connect(this, SIGNAL(LogzSignal(bool)), plot2D, SLOT(SetZScaleToLog(bool)));
@ -374,7 +373,6 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
// Reset Current Measurement // Reset Current Measurement
currentMeasurement = 0; currentMeasurement = 0;
emit SetCurrentMeasurementSignal(currentMeasurement); emit SetCurrentMeasurementSignal(currentMeasurement);
//to get the first image
data_pause_over = true; data_pause_over = true;
//in case of error message //in case of error message
alreadyDisplayed = false; alreadyDisplayed = false;
@ -417,7 +415,7 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
fileName = QString(myDet->getFileName().c_str()); fileName = QString(myDet->getFileName().c_str());
//update index //update index
currentFileIndex = myDet->getFileIndex(); currentFileIndex = myDet->getFileIndex();
currentFrameIndex = 0; currentFrameIndex = -1;
StartDaq(true); StartDaq(true);
running=!running; running=!running;
@ -441,13 +439,11 @@ void qDrawPlot::StartDaq(bool start){
#endif #endif
ResetDaqForGui(); ResetDaqForGui();
StartDaqForGui(); StartDaqForGui();
UpdatePlot();
}else{ }else{
#ifdef VERBOSE #ifdef VERBOSE
cout << "Start Daq(false) function" << endl; cout << "Start Daq(false) function" << endl;
#endif #endif
StopDaqForGui(); StopDaqForGui();
StopUpdatePlot();
} }
} }
@ -459,7 +455,6 @@ int qDrawPlot::ResetDaqForGui(){
if(!StopDaqForGui()) return 0; if(!StopDaqForGui()) return 0;
cout << "Resetting image number" << endl; cout << "Resetting image number" << endl;
lastImageNumber = 0; lastImageNumber = 0;
last_plot_number = -1;
return 1; return 1;
} }
@ -642,6 +637,7 @@ void qDrawPlot::SetupMeasurement(){
// Defaults // Defaults
if(!running) if(!running)
stop_signal = 0; stop_signal = 0;
currentFrameIndex = -1;
currentFrame = 0; currentFrame = 0;
//for 2d scans //for 2d scans
currentScanDivLevel = 0; currentScanDivLevel = 0;
@ -778,11 +774,11 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
#endif #endif
// secondary title necessary to differentiate between frames when not saving data // secondary title necessary to differentiate between frames when not saving data
char temp_title[2000]; char temp_title[2000];
//findex is used because in the receiver, you cannot know the frame index as many frames are in 1 file. //findex is the frame index given by receiver, cannot be derived from file name
if(fIndex!=-1){ if(fIndex!=-1){
currentFrameIndex=fIndex; currentFrameIndex=fIndex;
sprintf(temp_title,"#%d",fIndex); sprintf(temp_title,"#%d",fIndex);
if((myDet->getDetectorsType()==slsDetectorDefs::EIGER) && (subIndex != -1)) if((detType==slsDetectorDefs::EIGER) && (subIndex != -1))
sprintf(temp_title,"#%d %d",fIndex,subIndex); sprintf(temp_title,"#%d %d",fIndex,subIndex);
}else{ }else{
if(fileSaveEnable) strcpy(temp_title,"#%d"); if(fileSaveEnable) strcpy(temp_title,"#%d");
@ -792,7 +788,8 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
sprintf(temp_title,"#%d %d",fIndex,subIndex); sprintf(temp_title,"#%d %d",fIndex,subIndex);
//Plot Disabled //Plot Disabled
if(!plotEnable) return 0; if(!plotEnable)
return 0;
//angle plotting //angle plotting
if(anglePlot){ if(anglePlot){
@ -830,16 +827,16 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
} }
} }
if (k>0) { if (k>0) {
cout << "*** ERROR: value at " << k << " places have infinity values!" << endl; cout << "*** ERROR: value at " << k << " places have infinity values!" << endl;
double m1,m2,s1; double m1,m2,s1;
GetStatistics(m1,m2,s1,data->angles,nAnglePixelsX); GetStatistics(m1,m2,s1,data->angles,nAnglePixelsX);
cout << "angle min:" << m1 << endl; cout << "angle min:" << m1 << endl;
cout << "angle max:" << m2 << endl; cout << "angle max:" << m2 << endl;
cout << "angle sum:" << s1 << endl; cout << "angle sum:" << s1 << endl;
GetStatistics(m1,m2,s1,data->values,nAnglePixelsX); GetStatistics(m1,m2,s1,data->values,nAnglePixelsX);
cout << "value min:" << m1 << endl; cout << "value min:" << m1 << endl;
cout << "value max:" << m2 << endl; cout << "value max:" << m2 << endl;
cout << "value sum:" << s1 << endl; cout << "value sum:" << s1 << endl;
} }
#endif #endif
memcpy(histXAngleAxis,data->angles,nAnglePixelsX*sizeof(double)); memcpy(histXAngleAxis,data->angles,nAnglePixelsX*sizeof(double));
@ -851,39 +848,38 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "Exiting GetData Function " << endl; cout << "Exiting GetData Function " << endl;
#endif #endif
emit UpdatePlotSignal();
return 0; return 0;
} }
//nth frame or delay decision (data copied later on)
if (detType == slsDetectorDefs::MYTHEN){
//Nth Frame
if(frameFactor){
//plots if numfactor becomes 0
if(!numFactor) numFactor=frameFactor-1;
//return if not
else{
numFactor--;
return 0;
}
}
//Nth Frame //Not Nth Frame, to check time out(NOT for Scans and angle plots)
if(frameFactor){ else{
//plots if numfactor becomes 0 if (scanArgument == qDefs::None) {
if(!numFactor) numFactor=frameFactor-1; //if the time is not over, RETURN
//return if not if(!data_pause_over){
else{ return 0;
numFactor--; }
return 0; data_pause_over=false;
} data_pause_timer->start((int)(timerValue));
}
}
} }
//Not Nth Frame, to check time out(NOT for Scans and angle plots)
else{
if (scanArgument == qDefs::None) {
//if the time is not over, RETURN
if(!data_pause_over){
return 0;
}
data_pause_over=false;
data_pause_timer->start((int)(PLOT_TIMER_MS/2));
}
}
//if scan //if scan
//alframes //alframes
if(scanArgument==qDefs::AllFrames){ if(scanArgument==qDefs::AllFrames){
@ -899,6 +895,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
UnlockLastImageArray(); UnlockLastImageArray();
currentFrame++; currentFrame++;
currentScanDivLevel++; currentScanDivLevel++;
emit UpdatePlotSignal();
return 0; return 0;
} }
//file index //file index
@ -916,6 +913,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
UnlockLastImageArray(); UnlockLastImageArray();
currentFrame++; currentFrame++;
currentScanDivLevel++; currentScanDivLevel++;
emit UpdatePlotSignal();
return 0; return 0;
} }
//level0 //level0
@ -939,6 +937,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px]; for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
UnlockLastImageArray(); UnlockLastImageArray();
currentFrame++; currentFrame++;
emit UpdatePlotSignal();
return 0; return 0;
} }
//level1 //level1
@ -962,174 +961,127 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px]; for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
UnlockLastImageArray(); UnlockLastImageArray();
currentFrame++; currentFrame++;
emit UpdatePlotSignal();
return 0; return 0;
} }
//normal measurement or 1d scans //normal measurement or 1d scans
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ LockLastImageArray();
//set title /*if(!pthread_mutex_trylock(&(last_image_complete_mutex))){*/
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); //set title
// only if you got the lock, do u need to remember lastimagenumber to plot plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
lastImageNumber= currentFrame+1; // only if you got the lock, do u need to remember lastimagenumber to plot
//cout<<"got last imagenumber:"<<lastImageNumber<<endl; lastImageNumber= currentFrame+1;
//1d //cout<<"got last imagenumber:"<<lastImageNumber<<endl;
if(plot_in_scope==1){ //1d
// Titles if(plot_in_scope==1){
histTitle[0] = temp_title; // Titles
histTitle[0] = temp_title;
//histogram //histogram
if(histogram){ if(histogram){
resetAccumulate = false; resetAccumulate = false;
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
int numValues = nPixelsX; int numValues = nPixelsX;
if(originally2D) if(originally2D)
numValues = nPixelsX*nPixelsY; numValues = nPixelsX*nPixelsY;
//clean up graph //clean up graph
if(histogramArgument == qDefs::Intensity){
for(int j=0;j<histogramSamples.size();j++){
histogramSamples[j].value = 0;
}
}
int val = 0 ;
for(int i=0;i<numValues;i++){
//frequency of intensity
if(histogramArgument == qDefs::Intensity){ if(histogramArgument == qDefs::Intensity){
for(int j=0;j<histogramSamples.size();j++){
histogramSamples[j].value = 0;
}
}
int val = 0 ;
for(int i=0;i<numValues;i++){
//frequency of intensity
if(histogramArgument == qDefs::Intensity){
//ignore outside limits
if ((data->values[i] < histFrom) || (data->values[i] > histTo))
continue;
//check for intervals, increment if validates
for(int j=0;j<histogramSamples.size();j++){
if(histogramSamples[j].interval.contains(data->values[i]))
histogramSamples[j].value += 1;
}
}
//get sum of data pixels
else
val += data->values[i];
}
if(histogramArgument != qDefs::Intensity){
val /= numValues;
//find scan value
int ci = 0, fi = 0; double cs0 = 0 , cs1 = 0;
fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, cs0, cs1);
int scanval=-1;
if(cs0 != -1)
scanval = cs0;
else scanval = cs1;
//ignore outside limits //ignore outside limits
if ((scanval < histFrom) || (scanval > histTo) || (scanval == -1)) if ((data->values[i] < histFrom) || (data->values[i] > histTo))
scanval = -1; continue;
//check for intervals, increment if validates //check for intervals, increment if validates
for(int j=0;j<histogramSamples.size();j++){ for(int j=0;j<histogramSamples.size();j++){
if(histogramSamples[j].interval.contains(scanval)){ if(histogramSamples[j].interval.contains(data->values[i]))
histogramSamples[j].value = val; histogramSamples[j].value += 1;
cout << "j:"<<j<<" scanval:"<<scanval<<" val:"<<val<<endl;
}
} }
} }
//get sum of data pixels
else
val += data->values[i];
} }
//not histogram
else{
// Persistency
if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;
nHists = currentPersistency+1;
histNBins = nPixelsX;
// copy data
for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
//recalculating pedestal if(histogramArgument != qDefs::Intensity){
if(startPedestalCal){ val /= numValues;
//start adding frames to get to the pedestal value
if(pedestalCount<NUM_PEDESTAL_FRAMES){ //find scan value
for(unsigned int px=0;px<nPixelsX;px++) int ci = 0, fi = 0; double cs0 = 0 , cs1 = 0;
tempPedestalVals[px] += data->values[px]; fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, cs0, cs1);
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
pedestalCount++; int scanval=-1;
} if(cs0 != -1)
//calculate the pedestal value scanval = cs0;
if(pedestalCount==NUM_PEDESTAL_FRAMES){ else scanval = cs1;
cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<nPixelsX;px++) //ignore outside limits
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES; if ((scanval < histFrom) || (scanval > histTo) || (scanval == -1))
memcpy(pedestalVals,tempPedestalVals,nPixelsX*sizeof(double)); scanval = -1;
startPedestalCal = 0; //check for intervals, increment if validates
for(int j=0;j<histogramSamples.size();j++){
if(histogramSamples[j].interval.contains(scanval)){
histogramSamples[j].value = val;
cout << "j:"<<j<<" scanval:"<<scanval<<" val:"<<val<<endl;
} }
} }
}
//normal data
if(((!pedestal)&(!accumulate)&(!binary)) || (resetAccumulate)){
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
resetAccumulate = false;
}
//pedestal or accumulate
else{
double temp;//cannot overwrite cuz of accumulate
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){
temp = data->values[px];
if(pedestal)
temp = data->values[px] - (pedestalVals[px]);
if(binary) {
if ((temp >= binaryFrom) && (temp <= binaryTo))
temp = 1;
else
temp = 0;
}
if(accumulate)
temp += histYAxis[0][px];
//after all processing
histYAxis[0][px] = temp;
}
}
}
} }
//2d //not histogram
else{ else{
// Titles // Persistency
imageTitle = temp_title; if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;
nHists = currentPersistency+1;
histNBins = nPixelsX;
// copy data
for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
//recalculating pedestal //recalculating pedestal
if(startPedestalCal){ if(startPedestalCal){
//start adding frames to get to the pedestal value //start adding frames to get to the pedestal value
if(pedestalCount<NUM_PEDESTAL_FRAMES){ if(pedestalCount<NUM_PEDESTAL_FRAMES){
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) for(unsigned int px=0;px<nPixelsX;px++)
tempPedestalVals[px] += data->values[px]; tempPedestalVals[px] += data->values[px];
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double)); memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
pedestalCount++; pedestalCount++;
} }
//calculate the pedestal value //calculate the pedestal value
if(pedestalCount==NUM_PEDESTAL_FRAMES){ if(pedestalCount==NUM_PEDESTAL_FRAMES){
cout << "Pedestal Calculated" << endl; cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) for(unsigned int px=0;px<nPixelsX;px++)
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES; tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
memcpy(pedestalVals,tempPedestalVals,nPixelsX*nPixelsY*sizeof(double)); memcpy(pedestalVals,tempPedestalVals,nPixelsX*sizeof(double));
startPedestalCal = 0; startPedestalCal = 0;
} }
} }
//normal data //normal data
if(((!pedestal)&(!accumulate)&(!binary)) || (resetAccumulate)){ if(((!pedestal)&(!accumulate)&(!binary)) || (resetAccumulate)){
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double)); memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
resetAccumulate = false; resetAccumulate = false;
} }
//pedestal or accumulate or binary //pedestal or accumulate
else{ else{
double temp; double temp;//cannot overwrite cuz of accumulate
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){ for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){
temp = data->values[px]; temp = data->values[px];
if(pedestal) if(pedestal)
@ -1141,24 +1093,74 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){
temp = 0; temp = 0;
} }
if(accumulate) if(accumulate)
temp += lastImageArray[px]; temp += histYAxis[0][px];
//after all processing //after all processing
lastImageArray[px] = temp; histYAxis[0][px] = temp;
} }
} }
} }
pthread_mutex_unlock(&(last_image_complete_mutex));
} }
//2d
else{
// Titles
imageTitle = temp_title;
//recalculating pedestal
if(startPedestalCal){
//start adding frames to get to the pedestal value
if(pedestalCount<NUM_PEDESTAL_FRAMES){
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
tempPedestalVals[px] += data->values[px];
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
pedestalCount++;
}
//calculate the pedestal value
if(pedestalCount==NUM_PEDESTAL_FRAMES){
cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
memcpy(pedestalVals,tempPedestalVals,nPixelsX*nPixelsY*sizeof(double));
startPedestalCal = 0;
}
}
//normal data
if(((!pedestal)&(!accumulate)&(!binary)) || (resetAccumulate)){
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
resetAccumulate = false;
}
//pedestal or accumulate or binary
else{
double temp;
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){
temp = data->values[px];
if(pedestal)
temp = data->values[px] - (pedestalVals[px]);
if(binary) {
if ((temp >= binaryFrom) && (temp <= binaryTo))
temp = 1;
else
temp = 0;
}
if(accumulate)
temp += lastImageArray[px];
//after all processing
lastImageArray[px] = temp;
}
}
}
/* pthread_mutex_unlock(&(last_image_complete_mutex));
}*/
UnlockLastImageArray();
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"currentframe:"<<currentFrame<<"\tcurrentframeindex:"<<currentFrameIndex<<endl; cprintf(BLUE,"currentframe:%d \tcurrentframeindex:%d\n",currentFrame,currentFrameIndex);
#endif #endif
emit UpdatePlotSignal();
currentFrame++; currentFrame++;
} }
//if(frameFactor)
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "Exiting GetData function" << endl; cout << "Exiting GetData function" << endl;
#endif #endif
@ -1264,10 +1266,12 @@ int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << endl; cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << endl;
#endif #endif
//to make sure it plots the last frame before setting lastimagearray all to 0
//if(plot_in_scope==2) //to make sure it plots the last frame
//usleep(5*1000*1000); while(currentFrameIndex!=-1){
//usleep(500*1000); usleep(2000);
}
currentMeasurement = currentMeasurementIndex+1; currentMeasurement = currentMeasurementIndex+1;
currentFileIndex = fileIndex; currentFileIndex = fileIndex;
#ifdef VERBOSE #ifdef VERBOSE
@ -1331,13 +1335,14 @@ void qDrawPlot::UpdatePlot(){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "Entering UpdatePlot function" << endl; cout << "Entering UpdatePlot function" << endl;
#endif #endif
plot_update_timer->stop();
// only if no plot isnt enabled // only if no plot isnt enabled
if(plotEnable){ if(plotEnable){
LockLastImageArray(); LockLastImageArray();
//so that it doesnt plot every single thing //so that it doesnt plot every single thing
if(lastImageNumber && lastImageNumber!=last_plot_number){ #ifdef VERYVERBOSE
cprintf(GREEN,"Updating Plot\n");
#endif
//so as to not plot it again and to let measurment finished know its done plotting it
//1-d plot stuff //1-d plot stuff
if(plot_in_scope==1){ if(plot_in_scope==1){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
@ -1453,20 +1458,12 @@ void qDrawPlot::UpdatePlot(){
if(saveAll) SavePlotAutomatic(); if(saveAll) SavePlotAutomatic();
} }
} }
last_plot_number=lastImageNumber;
//set plot title //set plot title
boxPlot->setTitle(plotTitle); boxPlot->setTitle(plotTitle);
} currentFrameIndex = -1;
UnlockLastImageArray(); UnlockLastImageArray();
} }
//if acq stopped before this line, it continues from here, shouldnt restart plotting timer
if(!stop_signal){
if(!frameFactor)
plot_update_timer->start((int)timerValue);
else
plot_update_timer->start((int)PLOT_TIMER_MS);
}
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "Exiting UpdatePlot function" << endl; cout << "Exiting UpdatePlot function" << endl;
#endif #endif
@ -1476,17 +1473,6 @@ void qDrawPlot::UpdatePlot(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::StopUpdatePlot(){
#ifdef VERYVERBOSE
cout << "Entering StopUpdatePlot()" << endl;
#endif
plot_update_timer->stop();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::ClonePlot(){ void qDrawPlot::ClonePlot(){
int i; int i;
@ -1732,7 +1718,6 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
LockLastImageArray(); LockLastImageArray();
slsDetectorDefs::detectorType detType = myDet->getDetectorsType();
if(detType == slsDetectorDefs::MYTHEN){ if(detType == slsDetectorDefs::MYTHEN){
//get trimbits //get trimbits
@ -1950,6 +1935,20 @@ void qDrawPlot::ResetAccumulate(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SetPlotTimer(double time){
timerValue = time;
/*if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){
time = myDet->setReceiverReadTimer(timerValue);
#ifdef VERBOSE
cout << "Receiver read timer set to : " << time << endl;
#endif
qDefs::checkErrorMessage(myDet,"qDrawPlot::SetPlotTimer");
}*/
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SetFrameFactor(int frame){ void qDrawPlot::SetFrameFactor(int frame){
frameFactor = frame; frameFactor = frame;
if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){ if(myDet->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG){