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 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">
<property name="geometry">
<rect>
@ -1020,6 +1025,11 @@ Displays minimum, maximum and sum of values for each plot.
<verstretch>0</verstretch>
</sizepolicy>
</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">
<string>Binary</string>
</property>
@ -1326,7 +1336,7 @@ Displays minimum, maximum and sum of values for each plot.
<rect>
<x>10</x>
<y>20</y>
<width>346</width>
<width>341</width>
<height>26</height>
</rect>
</property>

View File

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