fixed the problem with multiple frame scan, frame index and file index included in gui

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@111 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-11-14 13:39:04 +00:00
parent 6e529f1c06
commit 7a6bba3c77
6 changed files with 67 additions and 48 deletions

View File

@ -75,13 +75,13 @@
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Current Index: </string> <string>Current Frame: </string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="lblProgressIndex"> <widget class="QLabel" name="lblProgressIndex">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>100</x> <x>101</x>
<y>25</y> <y>25</y>
<width>101</width> <width>101</width>
<height>16</height> <height>16</height>
@ -912,7 +912,7 @@ Frame period between exposures.
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>Start Run Index:</string> <string>Run Index:</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -52,6 +52,8 @@ public:
int GetProgress(){return progress;}; int GetProgress(){return progress;};
/** gets the file index to the measurement tab*/ /** gets the file index to the measurement tab*/
int GetFileIndex(){return currentFileIndex;}; int GetFileIndex(){return currentFileIndex;};
/** gets the frame index to the measurement tab*/
int GetFrameIndex(){return currentFrameIndex;};
/** sets file write enable , if not enabled, /** sets file write enable , if not enabled,
* file index wont increase and so you need secondary titles to differentitate between plots*/ * file index wont increase and so you need secondary titles to differentitate between plots*/
void SetEnableFileWrite(bool enable){fileSaveEnable = enable;}; void SetEnableFileWrite(bool enable){fileSaveEnable = enable;};
@ -180,9 +182,8 @@ int StopDaqForGui() {return StartOrStopThread(0) ? 0:1;}
bool StartOrStopThread(bool start); bool StartOrStopThread(bool start);
/** Sets up measurement each time /** Sets up measurement each time
* @param currentIndex file index given by detector class
* */ * */
void SetupMeasurement(int currentIndex); void SetupMeasurement();
/** Resets the acquisition parameter like lastimagenumber */ /** Resets the acquisition parameter like lastimagenumber */
int ResetDaqForGui(); int ResetDaqForGui();
@ -321,10 +322,10 @@ int number_of_frames;
double acquisitionPeriod; double acquisitionPeriod;
/** Acquisition Time */ /** Acquisition Time */
double exposureTime; double exposureTime;
/** Current index*/ /** Current file index*/
int currentFileIndex; int currentFileIndex;
/** Current frame index*/
int currentFrameIndex;
/**variables for threads */ /**variables for threads */
/** */ /** */

View File

@ -260,9 +260,13 @@ void SlsQt2DPlot::Update(){
plotLayout()->setAlignCanvasToScales(true); plotLayout()->setAlignCanvasToScales(true);
cout << "layout" << endl; cout << "layout" << endl;
#endif #endif
#ifdef VERYVERBOSE
cout << "going to replot" << endl; cout << "going to replot" << endl;
#endif
replot(); replot();
#ifdef VERYVERBOSE
cout << "done" << endl; cout << "done" << endl;
#endif
} }

View File

@ -223,6 +223,7 @@ void qCloneWidget::SavePlot(){
if(cloneBox->title().contains('.')){ if(cloneBox->title().contains('.')){
fName.append(QString('/')+cloneBox->title()); fName.append(QString('/')+cloneBox->title());
fName.replace(".dat",".png"); fName.replace(".dat",".png");
fName.replace(".raw",".png");
}else fName.append(QString("/Snapshot_unknown_title.png")); }else fName.append(QString("/Snapshot_unknown_title.png"));
//save //save
QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32); QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32);
@ -250,7 +251,9 @@ int qCloneWidget::SavePlotAutomatic(){
if(cloneBox->title().contains('.')){ if(cloneBox->title().contains('.')){
fName.append(QString('/')+cloneBox->title()); fName.append(QString('/')+cloneBox->title());
fName.replace(".dat",".png"); fName.replace(".dat",".png");
fName.replace(".raw",".png");
}else fName.append(QString("/Snapshot_unknown_title.png")); }else fName.append(QString("/Snapshot_unknown_title.png"));
cout<<"fname:"<<fName.toAscii().constData()<<endl;
//save //save
QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32); QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32);
QPainter painter(&img); QPainter painter(&img);

View File

@ -107,6 +107,7 @@ void qDrawPlot::SetupWidgetWindow(){
backwardScanPlot = false; backwardScanPlot = false;
currentFileIndex = 0; currentFileIndex = 0;
currentFrameIndex = 0;
// This is so that it initially stop and plots // This is so that it initially stop and plots
running = 1; running = 1;
for(int i=0;i<MAX_1DPLOTS;i++) for(int i=0;i<MAX_1DPLOTS;i++)
@ -142,7 +143,8 @@ void qDrawPlot::SetupWidgetWindow(){
//sprintf(temp_title,"Frame -%d",i); //sprintf(temp_title,"Frame -%d",i);
//histTitle[i] = temp_title; //histTitle[i] = temp_title;
} }
imageTitle.assign("Start Image"); imageTitle="";
/*imageTitle.assign("Start Image");*/
imageXAxisTitle="Pixel"; imageXAxisTitle="Pixel";
imageYAxisTitle="Pixel"; imageYAxisTitle="Pixel";
imageZAxisTitle="Intensity"; imageZAxisTitle="Intensity";
@ -282,6 +284,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;
@ -344,7 +347,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(start){ if(start){
progress = 0; progress = 0;
//sets up the measurement parameters //sets up the measurement parameters
SetupMeasurement(myDet->getFileIndex()); SetupMeasurement();
cout << "Starting new acquisition threadddd ...." << endl; cout << "Starting new acquisition threadddd ...." << endl;
// Start acquiring data from server // Start acquiring data from server
@ -435,7 +438,7 @@ void qDrawPlot::SetScanArgument(int scanArg){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SetupMeasurement(int currentIndex){ void qDrawPlot::SetupMeasurement(){
#ifdef VERBOSE #ifdef VERBOSE
cout << "SetupMeasurement function:" << running << endl; cout << "SetupMeasurement function:" << running << endl;
#endif #endif
@ -468,13 +471,13 @@ void qDrawPlot::SetupMeasurement(int currentIndex){
} }
else {//all frames else {//all frames
if(scanArgument==AllFrames){ if(scanArgument==AllFrames){
maxPixelsY = currentIndex + number_of_exposures - 1; maxPixelsY = number_of_exposures - 1;
minPixelsY = currentIndex; minPixelsY = 0;
if(!running) nPixelsY = number_of_exposures; if(!running) nPixelsY = number_of_exposures;
}//file index }//file index
else if(scanArgument==FileIndex){ else if(scanArgument==FileIndex){
maxPixelsY = currentIndex + number_of_frames - 1; maxPixelsY = number_of_frames - 1;
minPixelsY = currentIndex; minPixelsY = 0;
if(!running) nPixelsY = number_of_frames; if(!running) nPixelsY = number_of_frames;
}//level0 or level1 }//level0 or level1
else { else {
@ -538,7 +541,8 @@ int qDrawPlot::GetData(detectorData *data){
//set progress //set progress
progress=(int)data->progressIndex; progress=(int)data->progressIndex;
currentFileIndex = fileIOStatic::getFileIndexFromFileName(string(data->fileName)); currentFrameIndex = fileIOStatic::getIndicesFromFileName(string(data->fileName),currentFileIndex);
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "progress:" << progress << endl; cout << "progress:" << progress << endl;
#endif #endif
@ -547,10 +551,10 @@ int qDrawPlot::GetData(detectorData *data){
if(!plotEnable) return 0; if(!plotEnable) return 0;
// 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];
if(fileSaveEnable) strcpy(temp_title,""); if(fileSaveEnable) strcpy(temp_title,"");
else sprintf(temp_title,"#%d",currentFrame); else sprintf(temp_title,"#%d",currentFrame);
*/
//angle plotting //angle plotting
if(anglePlot){ if(anglePlot){
@ -559,7 +563,7 @@ int qDrawPlot::GetData(detectorData *data){
//set title //set title
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
// Title // Title
histTitle[0] = temp_title; /*histTitle[0] = temp_title;*/
if(data->angles==NULL){ if(data->angles==NULL){
cout<<"\n\nWARNING:RETURNED NULL instead of angles."<<endl; cout<<"\n\nWARNING:RETURNED NULL instead of angles."<<endl;
@ -633,7 +637,7 @@ int qDrawPlot::GetData(detectorData *data){
//variables //variables
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
//title //title
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)); pthread_mutex_unlock(&(last_image_complete_mutex));
@ -651,10 +655,10 @@ int qDrawPlot::GetData(detectorData *data){
//set title //set title
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
//variables //variables
if(currentFileIndex == minPixelsY) currentScanDivLevel = 0; if(currentFrameIndex == 0) currentScanDivLevel = 0;
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
//title //title
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)); pthread_mutex_unlock(&(last_image_complete_mutex));
@ -672,8 +676,8 @@ int qDrawPlot::GetData(detectorData *data){
//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
int ci = 0, p = 0; double cs0 = 0 , cs1 = 0; int ci = 0, fi = 0, p = 0, di = 0; double cs0 = 0 , cs1 = 0;
fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, p, cs0, cs1); fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, p, cs0, cs1, di);
//variables //variables
if(cs0!=currentScanValue) { if(cs0!=currentScanValue) {
if(backwardScanPlot) currentScanDivLevel--; if(backwardScanPlot) currentScanDivLevel--;
@ -682,7 +686,7 @@ int qDrawPlot::GetData(detectorData *data){
currentScanValue = cs0; currentScanValue = cs0;
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
//title //title
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)); pthread_mutex_unlock(&(last_image_complete_mutex));
@ -698,8 +702,8 @@ int qDrawPlot::GetData(detectorData *data){
//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
int ci = 0, p = 0; double cs0 = 0 , cs1 = 0; int ci = 0, fi = 0, p = 0, di = 0; double cs0 = 0 , cs1 = 0;
fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, p, cs0, cs1); fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, p, cs0, cs1, di);
//variables //variables
if(cs1!=currentScanValue){ if(cs1!=currentScanValue){
if(backwardScanPlot) currentScanDivLevel--; if(backwardScanPlot) currentScanDivLevel--;
@ -708,7 +712,7 @@ int qDrawPlot::GetData(detectorData *data){
currentScanValue = cs1; currentScanValue = cs1;
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
//title //title
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)); pthread_mutex_unlock(&(last_image_complete_mutex));
@ -730,7 +734,7 @@ int qDrawPlot::GetData(detectorData *data){
//1d //1d
if(plot_in_scope==1){ if(plot_in_scope==1){
// Titles // Titles
histTitle[0] = temp_title; /*histTitle[0] = temp_title;*/
// Persistency // Persistency
if(currentPersistency < persistency)currentPersistency++; if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency; else currentPersistency=persistency;
@ -744,7 +748,7 @@ int qDrawPlot::GetData(detectorData *data){
//2d //2d
else{cout<<endl<<"****************************IN HERE-2D*******************************************"<<endl<<endl; else{cout<<endl<<"****************************IN HERE-2D*******************************************"<<endl<<endl;
// Titles // Titles
imageTitle = temp_title; /*imageTitle = temp_title;*/
// manufacture data for now // manufacture data for now
for(unsigned int px=0;px<nPixelsX;px++) for(unsigned int px=0;px<nPixelsX;px++)
for(unsigned int py=0;py<nPixelsY;py++) for(unsigned int py=0;py<nPixelsY;py++)
@ -755,7 +759,7 @@ int qDrawPlot::GetData(detectorData *data){
pthread_mutex_unlock(&(last_image_complete_mutex)); pthread_mutex_unlock(&(last_image_complete_mutex));
} }
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"currentframe:"<<currentFrame<<"\tcurrentfileIndex:"<<currentFileIndex<<endl; cout<<"currentframe:"<<currentFrame<<"\tcurrentframeindex:"<<currentFrameIndex<<endl;
#endif #endif
currentFrame++; currentFrame++;
} }
@ -852,12 +856,13 @@ int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){
//if(plot_in_scope==2) //if(plot_in_scope==2)
usleep(500000); usleep(500000);
currentMeasurement = currentMeasurementIndex + 1; currentMeasurement = currentMeasurementIndex+1;
currentFileIndex = fileIndex;
#ifdef VERBOSE #ifdef VERBOSE
cout << "currentMeasurement:" << currentMeasurement << endl; cout << "currentMeasurement:" << currentMeasurement << endl;
#endif #endif
emit SetCurrentMeasurementSignal(currentMeasurement); emit SetCurrentMeasurementSignal(currentMeasurement);
SetupMeasurement(fileIndex); SetupMeasurement();
return 0; return 0;
} }
@ -1154,6 +1159,7 @@ void qDrawPlot::SavePlot(){
if(boxPlot->title().contains('.')){ if(boxPlot->title().contains('.')){
fName.append(QString('/')+boxPlot->title()); fName.append(QString('/')+boxPlot->title());
fName.replace(".dat",".png"); fName.replace(".dat",".png");
fName.replace(".raw",".png");
}else fName.append(QString("/Image.png")); }else fName.append(QString("/Image.png"));
fName = QFileDialog::getSaveFileName(0,tr("Save Image"),fName,tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"),0,QFileDialog::ShowDirsOnly); fName = QFileDialog::getSaveFileName(0,tr("Save Image"),fName,tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"),0,QFileDialog::ShowDirsOnly);
@ -1188,6 +1194,7 @@ void qDrawPlot::SavePlotAutomatic(){
if(boxPlot->title().contains('.')){ if(boxPlot->title().contains('.')){
fName.append(QString('/')+boxPlot->title()); fName.append(QString('/')+boxPlot->title());
fName.replace(".dat",".png"); fName.replace(".dat",".png");
fName.replace(".raw",".png");
}else fName.append(QString("/Image_unknown_title.png")); }else fName.append(QString("/Image_unknown_title.png"));
//save //save
QImage img(size().width(),size().height(),QImage::Format_RGB32); QImage img(size().width(),size().height(),QImage::Format_RGB32);

View File

@ -72,7 +72,7 @@ void qTabMeasurement::SetupWidgetWindow(){
//File Index //File Index
spinIndex->setValue(myDet->getFileIndex()); spinIndex->setValue(myDet->getFileIndex());
//only initially //only initially
lblProgressIndex->setText(QString::number(myDet->getFileIndex())); lblProgressIndex->setText(QString::number(0));
//ly initially //ly initially
progressBar->setValue(0); progressBar->setValue(0);
@ -279,7 +279,6 @@ void qTabMeasurement::setFileName(const QString& fName){
void qTabMeasurement::setRunIndex(int index){ void qTabMeasurement::setRunIndex(int index){
myDet->setFileIndex(index); myDet->setFileIndex(index);
lblProgressIndex->setText(QString::number(index));
#ifdef VERBOSE #ifdef VERBOSE
cout << "Setting File Index to " << myDet->getFileIndex() << endl; cout << "Setting File Index to " << myDet->getFileIndex() << endl;
#endif #endif
@ -296,6 +295,7 @@ void qTabMeasurement::startStopAcquisition(){
//btnStartStop->setStyleSheet("color:red"); //btnStartStop->setStyleSheet("color:red");
btnStartStop->setText("Stop"); btnStartStop->setText("Stop");
btnStartStop->setIcon(*iconStop); btnStartStop->setIcon(*iconStop);
lblProgressIndex->setText(QString::number(0));
Enable(0); Enable(0);
progressBar->setValue(0); progressBar->setValue(0);
progressTimer->start(100); progressTimer->start(100);
@ -307,12 +307,13 @@ void qTabMeasurement::startStopAcquisition(){
#endif #endif
emit StopSignal(); emit StopSignal();
myDet->stopAcquisition(); myDet->stopAcquisition();
progressTimer->stop();
UpdateProgress();
//spin index //spin index
disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
spinIndex->setValue(myDet->getFileIndex()); spinIndex->setValue(myDet->getFileIndex());
lblProgressIndex->setText(QString::number(spinIndex->value()));
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
progressTimer->stop();
btnStartStop->setText("Start"); btnStartStop->setText("Start");
btnStartStop->setIcon(*iconStart); btnStartStop->setIcon(*iconStart);
@ -327,6 +328,13 @@ void qTabMeasurement::startStopAcquisition(){
void qTabMeasurement::UpdateFinished(){ void qTabMeasurement::UpdateFinished(){
if(btnStartStop->isChecked()){ if(btnStartStop->isChecked()){
UpdateProgress();
disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
spinIndex->setValue(myDet->getFileIndex());
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
progressTimer->stop();
disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
btnStartStop->setText("Start"); btnStartStop->setText("Start");
btnStartStop->setIcon(*iconStart); btnStartStop->setIcon(*iconStart);
@ -334,14 +342,7 @@ void qTabMeasurement::UpdateFinished(){
Enable(1); Enable(1);
connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
UpdateProgress();
//spin index
disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
spinIndex->setValue(myDet->getFileIndex());
lblProgressIndex->setText(QString::number(spinIndex->value()));
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int)));
progressTimer->stop();
} }
} }
@ -351,7 +352,7 @@ void qTabMeasurement::UpdateFinished(){
void qTabMeasurement::SetCurrentMeasurement(int val){ void qTabMeasurement::SetCurrentMeasurement(int val){
if((val)<spinNumMeasurements->value()) if((val)<spinNumMeasurements->value())
lblCurrentMeasurement->setText(QString::number(val+1)); lblCurrentMeasurement->setText(QString::number(val));
} }
@ -361,7 +362,7 @@ void qTabMeasurement::SetCurrentMeasurement(int val){
void qTabMeasurement::UpdateProgress(){ void qTabMeasurement::UpdateProgress(){
progressBar->setValue((int)myPlot->GetProgress()); progressBar->setValue((int)myPlot->GetProgress());
lblProgressIndex->setText(QString::number(myPlot->GetFileIndex())); lblProgressIndex->setText(QString::number(myPlot->GetFrameIndex()));
} }
@ -749,10 +750,13 @@ void qTabMeasurement::Refresh(){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Getting file index" << endl; cout << "Getting file index" << endl;
#endif #endif
spinIndex->setValue(myDet->getFileIndex());cout<<"file index:"<<myDet->getFileIndex()<<endl; spinIndex->setValue(myDet->getFileIndex());
//progress label index //progress label index
lblProgressIndex->setText(QString::number(myDet->getFileIndex())); if(myDet->getFrameIndex()==-1)
lblProgressIndex->setText("0");
else
lblProgressIndex->setText(QString::number(myDet->getFrameIndex()));
//Timing mode //Timing mode
SetupTimingMode(); SetupTimingMode();