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
This commit is contained in:
l_maliakal_d 2013-08-16 13:48:03 +00:00
parent 3c92f26be7
commit 061bd4251c
2 changed files with 115 additions and 133 deletions

View File

@ -999,6 +999,11 @@ Displays minimum, maximum and sum of values for each plot.
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="page_8"> <widget class="QWidget" name="page_8">
<property name="toolTip">
<string>&lt;nobr&gt;
All values between &lt;b&gt;from&lt;/b&gt; and &lt;b&gt;to&lt;/b&gt; will be reset to 1, others to 0.
&lt;/nobr&gt;</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_11"> <widget class="QWidget" name="horizontalLayoutWidget_11">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -1020,6 +1025,11 @@ Displays minimum, maximum and sum of values for each plot.
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>&lt;nobr&gt;
All values between &lt;b&gt;from&lt;/b&gt; and &lt;b&gt;to&lt;/b&gt; will be reset to 1, others to 0.
&lt;/nobr&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Binary</string> <string>Binary</string>
</property> </property>
@ -1326,7 +1336,7 @@ Displays minimum, maximum and sum of values for each plot.
<rect> <rect>
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>346</width> <width>341</width>
<height>26</height> <height>26</height>
</rect> </rect>
</property> </property>

View File

@ -725,8 +725,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
//angle plotting //angle plotting
if(anglePlot){ if(anglePlot){
while(1){ LockLastImageArray();
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//set title //set title
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
// Title // Title
@ -755,10 +754,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
memcpy(histYAngleAxis,data->values,nAnglePixelsX*sizeof(double)); memcpy(histYAngleAxis,data->values,nAnglePixelsX*sizeof(double));
SetHistXAxisTitle("Angles"); SetHistXAxisTitle("Angles");
} }
pthread_mutex_unlock(&(last_image_complete_mutex)); UnlockLastImageArray();
break;
}
}
currentFrame++; currentFrame++;
return 0; return 0;
} }
@ -796,8 +792,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
//if scan //if scan
//alframes //alframes
if(scanArgument==qDefs::AllFrames){ if(scanArgument==qDefs::AllFrames){
while(1){ LockLastImageArray();
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//set title //set title
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
//variables //variables
@ -806,18 +801,14 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
imageTitle = temp_title; imageTitle = temp_title;
//copy data //copy data
memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double)); memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double));
pthread_mutex_unlock(&(last_image_complete_mutex)); UnlockLastImageArray();
break;
}
}
currentFrame++; currentFrame++;
currentScanDivLevel++; currentScanDivLevel++;
return 0; return 0;
} }
//file index //file index
if(scanArgument==qDefs::FileIndex){ if(scanArgument==qDefs::FileIndex){
while(1){ LockLastImageArray();
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//set title //set title
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
//variables //variables
@ -829,18 +820,14 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
cout<<"currentScanDivLevel:"<<currentScanDivLevel<<endl; cout<<"currentScanDivLevel:"<<currentScanDivLevel<<endl;
//copy data //copy data
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];
pthread_mutex_unlock(&(last_image_complete_mutex)); UnlockLastImageArray();
break;
}
}
currentFrame++; currentFrame++;
currentScanDivLevel++; currentScanDivLevel++;
return 0; return 0;
} }
//level0 //level0
if(scanArgument==qDefs::Level0){ if(scanArgument==qDefs::Level0){
while(1){ LockLastImageArray();
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//set title //set title
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
//get scanvariable0 //get scanvariable0
@ -857,17 +844,13 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
imageTitle = temp_title; imageTitle = temp_title;
//copy data //copy data
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];
pthread_mutex_unlock(&(last_image_complete_mutex)); UnlockLastImageArray();
break;
}
}
currentFrame++; currentFrame++;
return 0; return 0;
} }
//level1 //level1
if(scanArgument==qDefs::Level1){ if(scanArgument==qDefs::Level1){
while(1){ LockLastImageArray();
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//set title //set title
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
//get scanvariable1 //get scanvariable1
@ -884,10 +867,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
imageTitle = temp_title; imageTitle = temp_title;
//copy data //copy data
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];
pthread_mutex_unlock(&(last_image_complete_mutex)); UnlockLastImageArray();
break;
}
}
currentFrame++; currentFrame++;
return 0; return 0;
} }
@ -917,19 +897,20 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
//recalculating pedestal //recalculating pedestal
if(startPedestalCal){ if(startPedestalCal){
pedestalCount++;
//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;px++) for(unsigned int px=0;px<nPixelsX;px++)
tempPedestalVals[px] += data->values[px]; tempPedestalVals[px] += data->values[px];//cout<<"tempPedestalVals[200]:"<<tempPedestalVals[200]<<endl;
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double)); memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
pedestalCount++;
} }
//calculate the pedestal value //calculate the pedestal value
else if(pedestalCount==NUM_PEDESTAL_FRAMES){ else if(pedestalCount==NUM_PEDESTAL_FRAMES){
cout << "Pedestal Calculated" << endl; cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<nPixelsX;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;//cout<<"tempPedestalVals[200]:"<<tempPedestalVals[200]<<endl;
memcpy(pedestalVals,tempPedestalVals,nPixelsX*sizeof(double)); memcpy(pedestalVals,tempPedestalVals,nPixelsX*sizeof(double));//cout<<"pedestalVals[200]:"<<pedestalVals[200]<<endl;
startPedestalCal = 0; startPedestalCal = 0;
} }
} }
@ -1733,8 +1714,7 @@ void qDrawPlot::RecalculatePedestal(){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Recalculating Pedestal" << endl; cout << "Recalculating Pedestal" << endl;
#endif #endif
while(1){ LockLastImageArray();
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
startPedestalCal = 1; startPedestalCal = 1;
pedestalCount = 0; pedestalCount = 0;
@ -1746,11 +1726,7 @@ void qDrawPlot::RecalculatePedestal(){
pedestalVals[px] = 0; pedestalVals[px] = 0;
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
tempPedestalVals[px] = 0; tempPedestalVals[px] = 0;
UnlockLastImageArray();
pthread_mutex_unlock(&(last_image_complete_mutex));
break;
}
}
} }
@ -1771,13 +1747,9 @@ void qDrawPlot::ResetAccumulate(){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Resetting Accumulation" << endl; cout << "Resetting Accumulation" << endl;
#endif #endif
while(1){ LockLastImageArray();
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
resetAccumulate = true; resetAccumulate = true;
pthread_mutex_unlock(&(last_image_complete_mutex)); UnlockLastImageArray();
break;
}
}
} }