stop signal works, call back works, number of probes to expert mode, angular works

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@49 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-09-05 07:33:55 +00:00
parent 63fadd3633
commit e32c1de0af
8 changed files with 356 additions and 262 deletions

View File

@ -138,8 +138,8 @@ void SetLines(bool enable){lines = enable;};
void SetMarkers(bool enable){markers = enable;}; void SetMarkers(bool enable){markers = enable;};
/** sets the scan argument to prepare the plot*/ /** sets the scan argument to prepare the plot*/
void SetScanArgument(int scanArg){scanArgument = scanArg;}; void SetScanArgument(int scanArg){scanArgument = scanArg;};
/** sets stop_signal to true */
void StopAcquisition(){ stop_signal = true; };
@ -178,12 +178,24 @@ static void* DataStartAcquireThread(void *this_pointer);
static int GetDataCallBack(detectorData *data, void *this_pointer); static int GetDataCallBack(detectorData *data, void *this_pointer);
/** This is called by the GetDataCallBack function to copy the data */ /** This is called by the GetDataCallBack function to copy the data */
int GetData(detectorData *data); int GetData(detectorData *data);
/** This is called by detector class when acquisition is finished
* @param currentProgress current progress of measurement
* @param detectorStatus current status of the detector
* @param this_pointer is the pointer pointing to this object
* */
static int GetAcquisitionFinishedCallBack(double currentProgress,int detectorStatus, void *this_pointer);
/** This is called by detector class when acquisition is finished
* @param currentProgress current progress of measurement
* @param detectorStatus current status of the detector
* */
int AcquisitionFinished(double currentProgress,int detectorStatus);
/** Saves all the plots. All sets saveError to true if not saved.*/ /** Saves all the plots. All sets saveError to true if not saved.*/
void SavePlotAutomatic(); void SavePlotAutomatic();
/** Sets the style of the 1d plot */
void SetStyle(SlsQtH1D* h){ void SetStyle(SlsQtH1D* h){
if(lines) h->setStyle(QwtPlotCurve::Lines); else h->setStyle(QwtPlotCurve::Dots); if(lines) h->setStyle(QwtPlotCurve::Lines); else h->setStyle(QwtPlotCurve::Dots);
if(markers) h->setSymbol(*marker); else h->setSymbol(*noMarker);}; if(markers) h->setSymbol(*marker); else h->setSymbol(*noMarker);
};
@ -248,8 +260,8 @@ int number_of_measurements;
int currentMeasurement; int currentMeasurement;
/** currentFrame */ /** currentFrame */
int currentFrame; int currentFrame;
/** current Index */ /** variable to check if its the nth frame */
int currentIndex; int numFactor;
/** current Scan Division Level */ /** current Scan Division Level */
int currentScanDivLevel; int currentScanDivLevel;
/** current scan Value */ /** current scan Value */

View File

@ -40,27 +40,29 @@ public:
*/ */
void Refresh(); void Refresh();
/** To enable expert mode
* @param enable to enable if true
*/
void SetExpertMode(bool enable){expertMode = enable;SetupTimingMode();};
public slots:
/** update plot is finished,
* changes start/stop text and enables/disables all widgets
*/
void UpdateFinished();
/** updates the current measurement
* @param val the value to be updated
*/
void SetCurrentMeasurement(int val);
private: private:
/** The sls detector object */
multiSlsDetector *myDet;
/** The Plot widget */
qDrawPlot *myPlot;
enum{None, Auto, Trigger_Exp_Series, Trigger_Frame, Trigger_Readout, Gated, Gated_Start, Trigger_Window, NumTimingModes};
QTimer *progressTimer;
int numMeasurement;
int currentMeasurement;
QString acqPeriodTip;
QString errPeriodTip;
QPalette red;
/** methods */
/** Sets up the widget /** Sets up the widget
*/ */
void SetupWidgetWindow(); void SetupWidgetWindow();
@ -86,88 +88,99 @@ private:
void Enable(bool enable); void Enable(bool enable);
public slots:
/** update plot is finished,
* changes start/stop text and enables/disables all widgets
*/
void UpdateFinished();
/** updates the current measurement
* @param val the value to be updated
*/
void SetCurrentMeasurement(int val);
private slots: private slots:
/** Sets the timing mode /** Sets the timing mode
* @ param mode cane be None, Auto, Gated, Trigger Exposure Series, * @ param mode cane be None, Auto, Gated, Trigger Exposure Series,
* Trigger Frame, Trigger Readout, External Trigger Window * Trigger Frame, Trigger Readout, External Trigger Window
*/ */
void SetTimingMode(int mode); void SetTimingMode(int mode);
/** Set number of measurements /** Set number of measurements
* @param num number of measurements to be set */ * @param num number of measurements to be set */
void setNumMeasurements(int num); void setNumMeasurements(int num);
/** Set file name /** Set file name
* @param fName name of file * @param fName name of file
*/ */
void setFileName(const QString& fName); void setFileName(const QString& fName);
/** Set index of file name /** Set index of file name
* @param index index of selection * @param index index of selection
*/ */
void setRunIndex(int index); void setRunIndex(int index);
/** starts/stops Acquisition /** starts/stops Acquisition
*/ */
void startStopAcquisition(); void startStopAcquisition();
/** Set number of frames /** Set number of frames
* @param val number of frames to be set * @param val number of frames to be set
*/ */
void setNumFrames(int val); void setNumFrames(int val);
/** Set acquisition time /** Set acquisition time
*/ */
void setExposureTime(); void setExposureTime();
/** Set frame period between exposures /** Set frame period between exposures
*/ */
void setAcquisitionPeriod(); void setAcquisitionPeriod();
/** Set number of triggers /** Set number of triggers
* @param val number of triggers to be set * @param val number of triggers to be set
*/ */
void setNumTriggers(int val); void setNumTriggers(int val);
/** Set delay /** Set delay
*/ */
void setDelay(); void setDelay();
/** Set number of gates /** Set number of gates
* @param val number of gates to be set * @param val number of gates to be set
*/ */
void setNumGates(int val); void setNumGates(int val);
/** Set number of probes /** Set number of probes
* @param val number of probes to be set * @param val number of probes to be set
*/ */
void setNumProbes(int val); void setNumProbes(int val);
/** Update progress*/ /** Update progress*/
void UpdateProgress(); void UpdateProgress();
/** Enable write to file */
void EnableFileWrite(bool enable);
private:
/** The sls detector object */
multiSlsDetector *myDet;
/** The Plot widget */
qDrawPlot *myPlot;
/** enum for the timing mode */
enum{None, Auto, Trigger_Exp_Series, Trigger_Frame, Trigger_Readout, Gated, Gated_Start, Trigger_Window, NumTimingModes};
/** timer to update the progress*/
QTimer *progressTimer;
/** number of measurements*/
int numMeasurement;
/** current measurement */
int currentMeasurement;
/** tool tip variables*/
QString acqPeriodTip;
QString errPeriodTip;
QPalette red;
/** expert mode */
bool expertMode;
/** Enable write to file */
void EnableFileWrite(bool enable);
signals: signals:
void StartSignal();
void StartSignal(); void StopSignal();
void StopSignal(); void CheckPlotIntervalSignal();
void CheckPlotIntervalSignal(); void EnableNthFrameSignal(bool);
void EnableNthFrameSignal(bool);
}; };

View File

@ -157,7 +157,13 @@ void qCloneWidget::SavePlot(){
//QString fName = QString(filePath.c_str())+'/'+dispFName->text()+comboFormat->currentText(); //QString fName = QString(filePath.c_str())+'/'+dispFName->text()+comboFormat->currentText();
char cID[10]; char cID[10];
sprintf(cID,"%d",id); sprintf(cID,"%d",id);
QString fName = QString(filePath.c_str())+"/Snapshot_"+QString(cID)+".png"; //title
QString fName = QString(filePath.c_str());
if(cloneBox->title().contains('.')){
fName.append(QString('/')+cloneBox->title());
fName.replace(".dat",".png");
}else fName.append(QString("/Snapshot_unknown_title.png"));
//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);
cloneBox->render(&painter); cloneBox->render(&painter);
@ -178,7 +184,13 @@ void qCloneWidget::SavePlot(){
int qCloneWidget::SavePlotAutomatic(){ int qCloneWidget::SavePlotAutomatic(){
char cID[10]; char cID[10];
sprintf(cID,"%d",id); sprintf(cID,"%d",id);
QString fName = QString(filePath.c_str())+"/Snapshot_"+QString(cID)+".png"; //title
QString fName = QString(filePath.c_str());
if(cloneBox->title().contains('.')){
fName.append(QString('/')+cloneBox->title());
fName.replace(".dat",".png");
}else fName.append(QString("/Snapshot_unknown_title.png"));
//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);
cloneBox->render(&painter); cloneBox->render(&painter);

View File

@ -227,6 +227,7 @@ void qDetectorMain::Initialization(){
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*))); connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*)));
// Measurement tab // Measurement tab
connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs())); connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs()));
connect(tab_measurement, SIGNAL(StopSignal()), myPlot,SLOT(StopAcquisition()));
connect(tab_measurement, SIGNAL(StopSignal()), this,SLOT(EnableTabs())); connect(tab_measurement, SIGNAL(StopSignal()), this,SLOT(EnableTabs()));
connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency())); connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency()));
connect(tab_measurement, SIGNAL(EnableNthFrameSignal(bool)), tab_plot,SLOT(EnableNthFrame(bool))); connect(tab_measurement, SIGNAL(EnableNthFrameSignal(bool)), tab_plot,SLOT(EnableNthFrame(bool)));
@ -274,21 +275,20 @@ void qDetectorMain::EnableModes(QAction *action){
#endif #endif
} }
//Set ExpertMode //Set ExpertMode(comes here only if its a digital detector)
else if(action==actionExpert){ else if(action==actionExpert){
enable = actionExpert->isChecked(); enable = actionExpert->isChecked();
tabs->setTabEnabled(Advanced,enable); tabs->setTabEnabled(Advanced,enable);
if((enable)&&(digitalDetector)){ actionLoadTrimbits->setVisible(enable);
actionLoadTrimbits->setVisible(true); actionSaveTrimbits->setVisible(enable);
actionSaveTrimbits->setVisible(true); actionLoadCalibration->setVisible(enable);
actionLoadCalibration->setVisible(true); actionSaveCalibration->setVisible(enable);
actionSaveCalibration->setVisible(true);
}else{ if(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN)
actionLoadTrimbits->setVisible(false); tab_measurement->SetExpertMode(enable);
actionSaveTrimbits->setVisible(false);
actionLoadCalibration->setVisible(false);
actionSaveCalibration->setVisible(false);
}
#ifdef VERBOSE #ifdef VERBOSE
cout << "Setting Expert Mode to " << enable << endl; cout << "Setting Expert Mode to " << enable << endl;
#endif #endif
@ -387,7 +387,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
QString fName = QString(myDet->getSettingsDir()); QString fName = QString(myDet->getSettingsDir());
fName = QFileDialog::getOpenFileName(this, fName = QFileDialog::getOpenFileName(this,
tr("Load Detector Trimbits"),fName, tr("Load Detector Trimbits"),fName,
tr("Trimbit files (*.trim *.sn*)")); tr("Trimbit files (*.trim noise.sn*)"));
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
@ -402,7 +402,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
QString fName = QString(myDet->getSettingsDir()); QString fName = QString(myDet->getSettingsDir());
fName = QFileDialog::getSaveFileName(this, fName = QFileDialog::getSaveFileName(this,
tr("Save Current Detector Trimbits"),fName, tr("Save Current Detector Trimbits"),fName,
tr("Trimbit files (*.trim *.sn*) ")); tr("Trimbit files (*.trim noise.sn*) "));
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
@ -417,7 +417,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
QString fName = QString(myDet->getCalDir()); QString fName = QString(myDet->getCalDir());
fName = QFileDialog::getOpenFileName(this, fName = QFileDialog::getOpenFileName(this,
tr("Load Detector Calibration Data"),fName, tr("Load Detector Calibration Data"),fName,
tr("Calibration files (*.cal *.sn*)")); tr("Calibration files (*.cal calibration.sn*)"));
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->loadCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) if(myDet->loadCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
@ -432,7 +432,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
QString fName = QString(myDet->getCalDir()); QString fName = QString(myDet->getCalDir());
fName = QFileDialog::getSaveFileName(this, fName = QFileDialog::getSaveFileName(this,
tr("Save Current Detector Calibration Data"),fName, tr("Save Current Detector Calibration Data"),fName,
tr("Calibration files (*.cal *.sn*) ")); tr("Calibration files (*.cal calibration.sn*) "));
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()){ if (!fName.isEmpty()){
if(myDet->saveCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) if(myDet->saveCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)

View File

@ -184,6 +184,9 @@ void qDrawPlot::Initialization(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::StartStopDaqToggle(bool stop_if_running){ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
#ifdef VERYVERBOSE
cout << "Entering StartStopDaqToggle(" << stop_if_running << ")" <<endl;
#endif
//static bool running = 1; //static bool running = 1;
if(running){ //stopping if(running){ //stopping
StartDaq(false); StartDaq(false);
@ -226,6 +229,8 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9); acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9);
cout << "\tAcquisition Period:" << setprecision (10) << acquisitionPeriod << endl; cout << "\tAcquisition Period:" << setprecision (10) << acquisitionPeriod << endl;
//to take the first data if frameFactor
numFactor = 0;
//for save automatically, //for save automatically,
saveError = false; saveError = false;
@ -286,8 +291,8 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(start){ if(start){
if(myDet->getRunStatus()==slsDetectorDefs::IDLE) if(myDet->getRunStatus()==slsDetectorDefs::IDLE)
cout<<endl<<endl<<"IDLE"<<endl<<endl; cout<<endl<<endl<<"IDLE"<<endl;
else cout<<endl<<endl<<"ERRORRRRRR: "<<myDet->getRunStatus()<<endl<<endl; else cout<<endl<<endl<<"ERRORRRRRR: "<<myDet->getRunStatus()<<endl;
// Defaults // Defaults
progress = 0; progress = 0;
currentFrame = 0; currentFrame = 0;
@ -335,7 +340,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
startPixel = minPixelsY -(pixelWidth/2); startPixel = minPixelsY -(pixelWidth/2);
endPixel = maxPixelsY + (pixelWidth/2); endPixel = maxPixelsY + (pixelWidth/2);
}else{//no scan }else{//no scan
nPixelsY = number_of_exposures; nPixelsY = 100;//number_of_exposures;
maxPixelsY = 100; maxPixelsY = 100;
minPixelsY = 0; minPixelsY = 0;
startPixel = -0.5; startPixel = -0.5;
@ -372,11 +377,11 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(plot_in_scope==1) Clear1DPlot();
cout << "Starting new acquisition threadddd ...." << endl; cout << "Starting new acquisition threadddd ...." << endl;
// Setting the callback function to get data from software client // Setting the callback function to get data from detector class
myDet->registerDataCallback(&(GetDataCallBack),this); myDet->registerDataCallback(&(GetDataCallBack),this);
//Setting the callback function to alert when acquisition finished from detector class
myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack),this);
// Start acquiring data from server // Start acquiring data from server
if(!firstTime) pthread_join(gui_acquisition_thread,NULL);//wait until he's finished, ie. exits if(!firstTime) pthread_join(gui_acquisition_thread,NULL);//wait until he's finished, ie. exits
pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this); pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this);
@ -414,40 +419,36 @@ int qDrawPlot::GetData(detectorData *data){
cout << "Entering GetDatafunction" << endl; cout << "Entering GetDatafunction" << endl;
#endif #endif
if(!stop_signal){ if(!stop_signal){
//set title //set title
SetPlotTitle(QString(data->fileName).section('/',-1)); SetPlotTitle(QString(data->fileName).section('/',-1));
//set progress
progress=(int)data->progressIndex;
//Plot Disabled //Plot Disabled
if(!plotEnable) { if(!plotEnable) return 0;
progress=(int)data->progressIndex;
currentFrame++;
return 0;
}
//Nth Frame //Nth Frame
if(frameFactor){ if(frameFactor){
//when to copy data //plots if numfactor becomes 0
if(((currentFrame+1==number_of_exposures)&&(currentMeasurement+1==number_of_measurements)) if(!numFactor) numFactor=frameFactor-1;
||(!((currentFrame)%frameFactor)));
//return if not //return if not
else{ else{
progress=(int)data->progressIndex; numFactor--;
currentFrame++;
return 0; return 0;
} }
} }
//Not Nth Frame, Not time out yet //Not Nth Frame, to check time out(NOT for 2dScans and angle plots)
else{ else{
if((scanArgument==None)&&(!anglePlot)){ if((scanArgument==None)&&(!anglePlot)){
//if the time is not over, RETURN //if the time is not over, RETURN
if(!data_pause_over){ if(!data_pause_over){
progress=(int)data->progressIndex;
currentFrame++;
return 0; return 0;
} }
data_pause_over=false; data_pause_over=false;
@ -456,22 +457,8 @@ int qDrawPlot::GetData(detectorData *data){
} }
//what comes here has plot enabled AND (frame factor OR data pause over )
progress=(int)data->progressIndex;
//current index
currentIndex = myDet->getFileIndexFromFileName(string(data->fileName));
//scan variable
int currentScanVariable0 = myDet->getCurrentScanVariable(0);
int currentScanVariable1 = myDet->getCurrentScanVariable(1);
if((currentFrame)<(number_of_exposures)){
#ifdef VERYVERBOSE
cout << "Reading in image: " << currentIndex << endl;
#endif
//angle plotting //angle plotting
if(anglePlot){ if(anglePlot){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
@ -488,13 +475,21 @@ int qDrawPlot::GetData(detectorData *data){
currentFrame++; currentFrame++;
return 0; return 0;
} }
//if scan argument is 2d //if scan argument is 2d
if(scanArgument!=None){ if(scanArgument!=None){
//alframes //alframes
if(scanArgument==AllFrames){ if(scanArgument==AllFrames){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//variables
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title; //title
char temp_title[2000];
sprintf(temp_title,"Image Index %d",myDet->getFileIndexFromFileName(string(data->fileName)));
imageTitle = temp_title;
//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));
} }
@ -505,9 +500,15 @@ int qDrawPlot::GetData(detectorData *data){
//file index //file index
if(scanArgument==FileIndex){ if(scanArgument==FileIndex){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//variables
int currentIndex = myDet->getFileIndexFromFileName(string(data->fileName));
if(currentIndex == minPixelsY) currentScanDivLevel = 0; if(currentIndex == minPixelsY) currentScanDivLevel = 0;
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title; //title
char temp_title[2000];
sprintf(temp_title,"Image Index %d",currentIndex);
imageTitle = temp_title;
//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));
} }
@ -518,10 +519,19 @@ int qDrawPlot::GetData(detectorData *data){
//level0 //level0
if(scanArgument==Level0){ if(scanArgument==Level0){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//get scanvariable0
int currentIndex = 0, p = 0; double cs0 = 0 , cs1 = 0;
myDet->getVariablesFromFileName(string(data->fileName), currentIndex, p, cs0, cs1);
int currentScanVariable0 = (int)cs0;
//variables
if(currentScanVariable0!=currentScanValue) currentScanDivLevel++; if(currentScanVariable0!=currentScanValue) currentScanDivLevel++;
currentScanValue = currentScanVariable0; currentScanValue = currentScanVariable0;
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title; //title
char temp_title[2000];
sprintf(temp_title,"Image Index %d",currentIndex);
imageTitle = temp_title;
//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));
} }
@ -530,10 +540,19 @@ int qDrawPlot::GetData(detectorData *data){
} }
//level1 //level1
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//get scanvariable1
int currentIndex = 0, p = 0; double cs0 = 0 , cs1 = 0;
myDet->getVariablesFromFileName(string(data->fileName), currentIndex, p, cs0, cs1);
int currentScanVariable1 = (int)cs1;
//variables
if(currentScanVariable1!=currentScanValue) currentScanDivLevel++; if(currentScanVariable1!=currentScanValue) currentScanDivLevel++;
currentScanValue = currentScanVariable1; currentScanValue = currentScanVariable1;
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title; //title
char temp_title[2000];
sprintf(temp_title,"Image Index %d",currentIndex);
imageTitle = temp_title;
//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));
} }
@ -564,7 +583,7 @@ int qDrawPlot::GetData(detectorData *data){
//2d //2d
else{ else{
// Titles // Titles
sprintf(temp_title,"Image Index %d",currentIndex); sprintf(temp_title,"Image Index %d",myDet->getFileIndexFromFileName(string(data->fileName)));
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++)
@ -577,7 +596,7 @@ int qDrawPlot::GetData(detectorData *data){
pthread_mutex_unlock(&(last_image_complete_mutex)); pthread_mutex_unlock(&(last_image_complete_mutex));
} }
currentFrame++; currentFrame++;
}
} }
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "Exiting GetData function" << endl; cout << "Exiting GetData function" << endl;
@ -585,6 +604,50 @@ int qDrawPlot::GetData(detectorData *data){
return 0; return 0;
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,int detectorStatus, void *this_pointer){
((qDrawPlot*)this_pointer)->AcquisitionFinished(currentProgress,detectorStatus);
return 0;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::AcquisitionFinished(double currentProgress,int detectorStatus){
#ifdef VERBOSE
cout << "Entering Acquisition Finished with status " <<
slsDetectorBase::runStatusType((slsDetectorDefs::runStatus(detectorStatus))) << " and progress " << currentProgress << endl;
#endif
//error
if((detectorStatus==slsDetectorDefs::IDLE) && (currentProgress!=100)){
cout<<"in here"<<endl;
StartStopDaqToggle(true);
}
else if(!stop_signal){
cout<<"COMMENCING"<<endl;
currentMeasurement++;
cout<<"currentMeasurement:"<<currentMeasurement<<endl;
// To start the next measurement
if(currentMeasurement!=number_of_measurements){
emit SetCurrentMeasurementSignal(currentMeasurement);
StopDaqForGui();
StartDaq(true);
}// if all the measurements are over
else{
StartStopDaqToggle(true);
emit UpdatingPlotFinished();
}
}
return 0;
}
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -619,7 +682,7 @@ void qDrawPlot::Clear1DPlot(){
void qDrawPlot::UpdatePlot(){ void qDrawPlot::UpdatePlot(){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
/*cout << "Entering UpdatePlot function" << endl;*/ cout << "Entering UpdatePlot function" << endl;
#endif #endif
plot_update_timer->stop(); plot_update_timer->stop();
@ -630,9 +693,6 @@ void qDrawPlot::UpdatePlot(){
//1-d plot stuff //1-d plot stuff
if(lastImageNumber){ if(lastImageNumber){
if(histNBins){ if(histNBins){
#ifdef VERYVERBOSE
/*cout << "Last Image Number: " << lastImageNumber << endl;*/
#endif
Clear1DPlot(); Clear1DPlot();
plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
@ -699,33 +759,21 @@ void qDrawPlot::UpdatePlot(){
last_plot_number=lastImageNumber; last_plot_number=lastImageNumber;
if(plotEnable) UnlockLastImageArray(); if(plotEnable) UnlockLastImageArray();
// Measurement not over, continue
if(number_of_exposures!=currentFrame){//las plot number?
//if the interval is a timer and not nth frame *
if(!frameFactor) if(!frameFactor)
plot_update_timer->start((int)timerValue); plot_update_timer->start((int)timerValue);
else else
plot_update_timer->start((int)PLOT_TIMER_MS); plot_update_timer->start((int)PLOT_TIMER_MS);
}
// if a measurement is over
else{
currentMeasurement++;cout<<"currentMeasurement:"<<currentMeasurement<<endl;
// if all the measurements are over
if(currentMeasurement==number_of_measurements){
StartStopDaqToggle(true);
emit UpdatingPlotFinished();
}// To start the next measurement
else{
emit SetCurrentMeasurementSignal(currentMeasurement);
StopDaqForGui();
StartDaq(true);
}
}
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::StopUpdatePlot(){ void qDrawPlot::StopUpdatePlot(){
#ifdef VERYVERBOSE
cout << "Entering StopUpdatePlot()" << endl;
#endif
plot_update_timer->stop(); plot_update_timer->stop();
} }
@ -832,8 +880,12 @@ void qDrawPlot::SavePlot(){
QPainter painter(&savedImage); QPainter painter(&savedImage);
render(&painter); render(&painter);
// save image QString fName = QString(myDet->getFilePath().c_str());
QString fName = QString(myDet->getFilePath().c_str())+"/Image.png"; if(boxPlot->title().contains('.')){
fName.append(QString('/')+boxPlot->title());
fName.replace(".dat",".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);
if (!fName.isEmpty()) if (!fName.isEmpty())
@ -851,7 +903,7 @@ void qDrawPlot::SavePlot(){
void qDrawPlot::SaveAll(bool enable){ void qDrawPlot::SaveAll(bool enable){
string msg = string("The Files will be saved as:\n")+ string msg = string("The Files will be saved as:\n")+
string(myDet->getFilePath().c_str())+string("/")+ string(myDet->getFilePath().c_str())+string("/")+
string(myDet->getFileName().c_str())+string("_[File Index].png"); string(myDet->getFileName().c_str())+string("[title].png");
qDefs::InfoMessage(msg,"Dock"); qDefs::InfoMessage(msg,"Dock");
saveAll = enable; saveAll = enable;
} }
@ -866,9 +918,13 @@ void qDrawPlot::SavePlotAutomatic(){
lastSavedMeasurement = currentMeasurement; lastSavedMeasurement = currentMeasurement;
char cID[10]; char cID[10];
sprintf(cID,"%d",lastSavedFrame); sprintf(cID,"%d",lastSavedFrame);
QString fName = QString(myDet->getFilePath().c_str())+QString("/")+ //title
QString(myDet->getFileName().c_str())+QString("_")+ QString fName = QString(myDet->getFilePath().c_str());
QString(cID)+".png"; if(boxPlot->title().contains('.')){
fName.append(QString('/')+boxPlot->title());
fName.replace(".dat",".png");
}else fName.append(QString("/Image_unknown_title.png"));
//save
QImage img(size().width(),size().height(),QImage::Format_RGB32); QImage img(size().width(),size().height(),QImage::Format_RGB32);
QPainter painter(&img); QPainter painter(&img);
render(&painter); render(&painter);

View File

@ -337,7 +337,8 @@ void qTabActions::EnablePositions(bool enable){
//to collapse if it was expanded //to collapse if it was expanded
if(btnExpand[NumPositions]->text()=="-") if(btnExpand[NumPositions]->text()=="-")
Expand(group->button(NumPositions)); Expand(group->button(NumPositions));
comboPos->clear(); for(int i=0;i<comboPos->count();i++)
comboPos->removeItem(i);
cout<<"Number of Positions set to :"<<myDet->getPositions()<<endl; cout<<"Number of Positions set to :"<<myDet->getPositions()<<endl;
lblName[NumPositions]->setPalette(lblName[NumPositions-1]->palette()); lblName[NumPositions]->setPalette(lblName[NumPositions-1]->palette());
lblName[NumPositions]->setEnabled(false); lblName[NumPositions]->setEnabled(false);

View File

@ -357,6 +357,7 @@ void qTabDataOutput::SetAngularCorrection(){
cout << "Unsetting angular correction" << endl; cout << "Unsetting angular correction" << endl;
#endif #endif
} }
emit AngularConversionSignal(chkAngular->isChecked()); emit AngularConversionSignal(chkAngular->isChecked());
} }

View File

@ -26,7 +26,7 @@ using namespace std;
qTabMeasurement::qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot): qTabMeasurement::qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot):
QWidget(parent),myDet(detector),myPlot(plot){ QWidget(parent),myDet(detector),myPlot(plot),expertMode(false){
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
Initialization(); Initialization();
@ -80,8 +80,7 @@ void qTabMeasurement::SetupWidgetWindow(){
SetupTimingMode(); SetupTimingMode();
//file write enabled/disabled //file write enabled/disabled
myDet->enableWriteToFile(true); chkFile->setChecked(myDet->enableWriteToFile());
//check if file enabled
} }
@ -292,6 +291,7 @@ void qTabMeasurement::startStopAcquisition(){
progressTimer->start(100); progressTimer->start(100);
emit StartSignal(); emit StartSignal();
myPlot->StartStopDaqToggle();
}else{ }else{
#ifdef VERBOSE #ifdef VERBOSE
cout << "Stopping Acquisition" << endl<< endl; cout << "Stopping Acquisition" << endl<< endl;
@ -304,7 +304,6 @@ void qTabMeasurement::startStopAcquisition(){
Enable(1); Enable(1);
emit StopSignal(); emit StopSignal();
} }
myPlot->StartStopDaqToggle();
} }
@ -563,7 +562,7 @@ void qTabMeasurement::SetTimingMode(int mode){
if(mode!=None){//Number of Probes if(mode!=None){//Number of Probes
if(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN){ if((myDet->getDetectorsType()==slsDetectorDefs::MYTHEN)&&(expertMode)){
lblNumProbes->setEnabled(true); spinNumProbes->setEnabled(true); lblNumProbes->setEnabled(true); spinNumProbes->setEnabled(true);
} }
} }