From 061bd4251c04229153e278180ca44a53c9821664 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Fri, 16 Aug 2013 13:48:03 +0000 Subject: [PATCH] pedestalbug fixed, trylock changed to lock, binary has qtip git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@228 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_tab_plot.ui | 12 +- slsDetectorGui/src/qDrawPlot.cpp | 236 ++++++++++++-------------- 2 files changed, 115 insertions(+), 133 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 05e5c1283..47791aba3 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -999,6 +999,11 @@ Displays minimum, maximum and sum of values for each plot. + + <nobr> +All values between <b>from</b> and <b>to</b> will be reset to 1, others to 0. +</nobr> + @@ -1020,6 +1025,11 @@ Displays minimum, maximum and sum of values for each plot. 0 + + <nobr> +All values between <b>from</b> and <b>to</b> will be reset to 1, others to 0. +</nobr> + Binary @@ -1326,7 +1336,7 @@ Displays minimum, maximum and sum of values for each plot. 10 20 - 346 + 341 26 diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 38de07cb1..bf0e6019d 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -725,40 +725,36 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){ //angle plotting if(anglePlot){ - while(1){ - if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - // Title - histTitle[0] = temp_title; + LockLastImageArray(); + //set title + plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); + // Title + histTitle[0] = temp_title; - if(data->angles==NULL){ - cout<<"\n\nWARNING:RETURNED NULL instead of angles."<values,nAnglePixelsX*sizeof(double)); - SetHistXAxisTitle("Channel Number"); + if(data->angles==NULL){ + cout<<"\n\nWARNING:RETURNED NULL instead of angles."<values,nAnglePixelsX*sizeof(double)); + SetHistXAxisTitle("Channel Number"); - } - else{ - - lastImageNumber= currentFrame+1; - nAnglePixelsX = data->npoints; - histNBins = nAnglePixelsX; - nHists=1; - if(histXAngleAxis) delete [] histXAngleAxis; histXAngleAxis = new double[nAnglePixelsX]; - if(histYAngleAxis) delete [] histYAngleAxis; histYAngleAxis = new double[nAnglePixelsX]; - memcpy(histXAngleAxis,data->angles,nAnglePixelsX*sizeof(double)); - memcpy(histYAngleAxis,data->values,nAnglePixelsX*sizeof(double)); - SetHistXAxisTitle("Angles"); - } - pthread_mutex_unlock(&(last_image_complete_mutex)); - break; - } } + else{ + + lastImageNumber= currentFrame+1; + nAnglePixelsX = data->npoints; + histNBins = nAnglePixelsX; + nHists=1; + if(histXAngleAxis) delete [] histXAngleAxis; histXAngleAxis = new double[nAnglePixelsX]; + if(histYAngleAxis) delete [] histYAngleAxis; histYAngleAxis = new double[nAnglePixelsX]; + memcpy(histXAngleAxis,data->angles,nAnglePixelsX*sizeof(double)); + memcpy(histYAngleAxis,data->values,nAnglePixelsX*sizeof(double)); + SetHistXAxisTitle("Angles"); + } + UnlockLastImageArray(); currentFrame++; return 0; } @@ -796,98 +792,82 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){ //if scan //alframes if(scanArgument==qDefs::AllFrames){ - while(1){ - if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - //variables - lastImageNumber= currentFrame+1; - //title - imageTitle = temp_title; - //copy data - memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double)); - pthread_mutex_unlock(&(last_image_complete_mutex)); - break; - } - } + LockLastImageArray(); + //set title + plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); + //variables + lastImageNumber= currentFrame+1; + //title + imageTitle = temp_title; + //copy data + memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double)); + UnlockLastImageArray(); currentFrame++; currentScanDivLevel++; return 0; } //file index if(scanArgument==qDefs::FileIndex){ - while(1){ - if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - //variables - if(currentFrameIndex == 0) currentScanDivLevel = 0; - lastImageNumber= currentFrame+1; - //title - imageTitle = temp_title; - cout<<"lastImageNumber:"<values[px]; - pthread_mutex_unlock(&(last_image_complete_mutex)); - break; - } - } + LockLastImageArray(); + //set title + plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); + //variables + if(currentFrameIndex == 0) currentScanDivLevel = 0; + lastImageNumber= currentFrame+1; + //title + imageTitle = temp_title; + cout<<"lastImageNumber:"<values[px]; + UnlockLastImageArray(); currentFrame++; currentScanDivLevel++; return 0; } //level0 if(scanArgument==qDefs::Level0){ - while(1){ - if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - //get scanvariable0 - int ci = 0, fi = 0, p = 0, di = 0; double cs0 = 0 , cs1 = 0; - fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, p, cs0, cs1, di); - //variables - if(cs0!=currentScanValue) { - if(backwardScanPlot) currentScanDivLevel--; - else currentScanDivLevel++; - } - currentScanValue = cs0; - lastImageNumber= currentFrame+1; - //title - imageTitle = temp_title; - //copy data - for(unsigned int px=0;pxvalues[px]; - pthread_mutex_unlock(&(last_image_complete_mutex)); - break; - } + LockLastImageArray(); + //set title + plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); + //get scanvariable0 + int ci = 0, fi = 0, p = 0, di = 0; double cs0 = 0 , cs1 = 0; + fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, p, cs0, cs1, di); + //variables + if(cs0!=currentScanValue) { + if(backwardScanPlot) currentScanDivLevel--; + else currentScanDivLevel++; } + currentScanValue = cs0; + lastImageNumber= currentFrame+1; + //title + imageTitle = temp_title; + //copy data + for(unsigned int px=0;pxvalues[px]; + UnlockLastImageArray(); currentFrame++; return 0; } //level1 if(scanArgument==qDefs::Level1){ - while(1){ - if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ - //set title - plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - //get scanvariable1 - int ci = 0, fi = 0, p = 0, di = 0; double cs0 = 0 , cs1 = 0; - fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, p, cs0, cs1, di); - //variables - if(cs1!=currentScanValue){ - if(backwardScanPlot) currentScanDivLevel--; - else currentScanDivLevel++; - } - currentScanValue = cs1; - lastImageNumber= currentFrame+1; - //title - imageTitle = temp_title; - //copy data - for(unsigned int px=0;pxvalues[px]; - pthread_mutex_unlock(&(last_image_complete_mutex)); - break; - } + LockLastImageArray(); + //set title + plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); + //get scanvariable1 + int ci = 0, fi = 0, p = 0, di = 0; double cs0 = 0 , cs1 = 0; + fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, p, cs0, cs1, di); + //variables + if(cs1!=currentScanValue){ + if(backwardScanPlot) currentScanDivLevel--; + else currentScanDivLevel++; } + currentScanValue = cs1; + lastImageNumber= currentFrame+1; + //title + imageTitle = temp_title; + //copy data + for(unsigned int px=0;pxvalues[px]; + UnlockLastImageArray(); currentFrame++; return 0; } @@ -917,19 +897,20 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){ //recalculating pedestal if(startPedestalCal){ - pedestalCount++; + //start adding frames to get to the pedestal value if(pedestalCountvalues[px]; + tempPedestalVals[px] += data->values[px];//cout<<"tempPedestalVals[200]:"<values,nPixelsX*sizeof(double)); + pedestalCount++; } //calculate the pedestal value else if(pedestalCount==NUM_PEDESTAL_FRAMES){ cout << "Pedestal Calculated" << endl; for(unsigned int px=0;px