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;};
/** sets the scan argument to prepare the plot*/
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);
/** This is called by the GetDataCallBack function to copy the 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.*/
void SavePlotAutomatic();
/** Sets the style of the 1d plot */
void SetStyle(SlsQtH1D* h){
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;
/** currentFrame */
int currentFrame;
/** current Index */
int currentIndex;
/** variable to check if its the nth frame */
int numFactor;
/** current Scan Division Level */
int currentScanDivLevel;
/** current scan Value */

View File

@ -40,27 +40,29 @@ public:
*/
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:
/** 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
*/
void SetupWidgetWindow();
@ -86,88 +88,99 @@ private:
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:
/** Sets the timing mode
* @ param mode cane be None, Auto, Gated, Trigger Exposure Series,
* Trigger Frame, Trigger Readout, External Trigger Window
*/
void SetTimingMode(int mode);
/** Sets the timing mode
* @ param mode cane be None, Auto, Gated, Trigger Exposure Series,
* Trigger Frame, Trigger Readout, External Trigger Window
*/
void SetTimingMode(int mode);
/** Set number of measurements
* @param num number of measurements to be set */
void setNumMeasurements(int num);
/** Set number of measurements
* @param num number of measurements to be set */
void setNumMeasurements(int num);
/** Set file name
* @param fName name of file
*/
void setFileName(const QString& fName);
/** Set file name
* @param fName name of file
*/
void setFileName(const QString& fName);
/** Set index of file name
* @param index index of selection
*/
void setRunIndex(int index);
/** Set index of file name
* @param index index of selection
*/
void setRunIndex(int index);
/** starts/stops Acquisition
*/
void startStopAcquisition();
/** starts/stops Acquisition
*/
void startStopAcquisition();
/** Set number of frames
* @param val number of frames to be set
*/
void setNumFrames(int val);
/** Set number of frames
* @param val number of frames to be set
*/
void setNumFrames(int val);
/** Set acquisition time
*/
void setExposureTime();
/** Set acquisition time
*/
void setExposureTime();
/** Set frame period between exposures
*/
void setAcquisitionPeriod();
/** Set frame period between exposures
*/
void setAcquisitionPeriod();
/** Set number of triggers
* @param val number of triggers to be set
*/
void setNumTriggers(int val);
/** Set number of triggers
* @param val number of triggers to be set
*/
void setNumTriggers(int val);
/** Set delay
*/
void setDelay();
/** Set delay
*/
void setDelay();
/** Set number of gates
* @param val number of gates to be set
*/
void setNumGates(int val);
/** Set number of gates
* @param val number of gates to be set
*/
void setNumGates(int val);
/** Set number of probes
* @param val number of probes to be set
*/
void setNumProbes(int val);
/** Set number of probes
* @param val number of probes to be set
*/
void setNumProbes(int val);
/** Update progress*/
void UpdateProgress();
/** Update progress*/
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:
void StartSignal();
void StopSignal();
void CheckPlotIntervalSignal();
void EnableNthFrameSignal(bool);
void StartSignal();
void StopSignal();
void CheckPlotIntervalSignal();
void EnableNthFrameSignal(bool);
};

View File

@ -157,7 +157,13 @@ void qCloneWidget::SavePlot(){
//QString fName = QString(filePath.c_str())+'/'+dispFName->text()+comboFormat->currentText();
char cID[10];
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);
QPainter painter(&img);
cloneBox->render(&painter);
@ -178,7 +184,13 @@ void qCloneWidget::SavePlot(){
int qCloneWidget::SavePlotAutomatic(){
char cID[10];
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);
QPainter painter(&img);
cloneBox->render(&painter);

View File

@ -227,6 +227,7 @@ void qDetectorMain::Initialization(){
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*)));
// Measurement tab
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(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency()));
connect(tab_measurement, SIGNAL(EnableNthFrameSignal(bool)), tab_plot,SLOT(EnableNthFrame(bool)));
@ -274,21 +275,20 @@ void qDetectorMain::EnableModes(QAction *action){
#endif
}
//Set ExpertMode
//Set ExpertMode(comes here only if its a digital detector)
else if(action==actionExpert){
enable = actionExpert->isChecked();
tabs->setTabEnabled(Advanced,enable);
if((enable)&&(digitalDetector)){
actionLoadTrimbits->setVisible(true);
actionSaveTrimbits->setVisible(true);
actionLoadCalibration->setVisible(true);
actionSaveCalibration->setVisible(true);
}else{
actionLoadTrimbits->setVisible(false);
actionSaveTrimbits->setVisible(false);
actionLoadCalibration->setVisible(false);
actionSaveCalibration->setVisible(false);
}
actionLoadTrimbits->setVisible(enable);
actionSaveTrimbits->setVisible(enable);
actionLoadCalibration->setVisible(enable);
actionSaveCalibration->setVisible(enable);
if(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN)
tab_measurement->SetExpertMode(enable);
#ifdef VERBOSE
cout << "Setting Expert Mode to " << enable << endl;
#endif
@ -387,7 +387,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
QString fName = QString(myDet->getSettingsDir());
fName = QFileDialog::getOpenFileName(this,
tr("Load Detector Trimbits"),fName,
tr("Trimbit files (*.trim *.sn*)"));
tr("Trimbit files (*.trim noise.sn*)"));
// Gets called when cancelled as well
if (!fName.isEmpty()){
if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
@ -402,7 +402,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
QString fName = QString(myDet->getSettingsDir());
fName = QFileDialog::getSaveFileName(this,
tr("Save Current Detector Trimbits"),fName,
tr("Trimbit files (*.trim *.sn*) "));
tr("Trimbit files (*.trim noise.sn*) "));
// Gets called when cancelled as well
if (!fName.isEmpty()){
if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
@ -417,7 +417,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
QString fName = QString(myDet->getCalDir());
fName = QFileDialog::getOpenFileName(this,
tr("Load Detector Calibration Data"),fName,
tr("Calibration files (*.cal *.sn*)"));
tr("Calibration files (*.cal calibration.sn*)"));
// Gets called when cancelled as well
if (!fName.isEmpty()){
if(myDet->loadCalibrationFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL)
@ -432,7 +432,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
QString fName = QString(myDet->getCalDir());
fName = QFileDialog::getSaveFileName(this,
tr("Save Current Detector Calibration Data"),fName,
tr("Calibration files (*.cal *.sn*) "));
tr("Calibration files (*.cal calibration.sn*) "));
// Gets called when cancelled as well
if (!fName.isEmpty()){
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){
#ifdef VERYVERBOSE
cout << "Entering StartStopDaqToggle(" << stop_if_running << ")" <<endl;
#endif
//static bool running = 1;
if(running){ //stopping
StartDaq(false);
@ -226,6 +229,8 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9);
cout << "\tAcquisition Period:" << setprecision (10) << acquisitionPeriod << endl;
//to take the first data if frameFactor
numFactor = 0;
//for save automatically,
saveError = false;
@ -286,8 +291,8 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(start){
if(myDet->getRunStatus()==slsDetectorDefs::IDLE)
cout<<endl<<endl<<"IDLE"<<endl<<endl;
else cout<<endl<<endl<<"ERRORRRRRR: "<<myDet->getRunStatus()<<endl<<endl;
cout<<endl<<endl<<"IDLE"<<endl;
else cout<<endl<<endl<<"ERRORRRRRR: "<<myDet->getRunStatus()<<endl;
// Defaults
progress = 0;
currentFrame = 0;
@ -335,7 +340,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
startPixel = minPixelsY -(pixelWidth/2);
endPixel = maxPixelsY + (pixelWidth/2);
}else{//no scan
nPixelsY = number_of_exposures;
nPixelsY = 100;//number_of_exposures;
maxPixelsY = 100;
minPixelsY = 0;
startPixel = -0.5;
@ -372,11 +377,11 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(plot_in_scope==1) Clear1DPlot();
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);
//Setting the callback function to alert when acquisition finished from detector class
myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack),this);
// Start acquiring data from server
if(!firstTime) pthread_join(gui_acquisition_thread,NULL);//wait until he's finished, ie. exits
pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this);
@ -414,40 +419,36 @@ int qDrawPlot::GetData(detectorData *data){
cout << "Entering GetDatafunction" << endl;
#endif
if(!stop_signal){
//set title
SetPlotTitle(QString(data->fileName).section('/',-1));
//set progress
progress=(int)data->progressIndex;
//Plot Disabled
if(!plotEnable) {
progress=(int)data->progressIndex;
currentFrame++;
return 0;
}
if(!plotEnable) return 0;
//Nth Frame
if(frameFactor){
//when to copy data
if(((currentFrame+1==number_of_exposures)&&(currentMeasurement+1==number_of_measurements))
||(!((currentFrame)%frameFactor)));
//plots if numfactor becomes 0
if(!numFactor) numFactor=frameFactor-1;
//return if not
else{
progress=(int)data->progressIndex;
currentFrame++;
numFactor--;
return 0;
}
}
//Not Nth Frame, Not time out yet
//Not Nth Frame, to check time out(NOT for 2dScans and angle plots)
else{
if((scanArgument==None)&&(!anglePlot)){
//if the time is not over, RETURN
if(!data_pause_over){
progress=(int)data->progressIndex;
currentFrame++;
return 0;
}
data_pause_over=false;
@ -456,128 +457,146 @@ 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);
//angle plotting
if(anglePlot){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
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));
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
return 0;
}
if((currentFrame)<(number_of_exposures)){
#ifdef VERYVERBOSE
cout << "Reading in image: " << currentIndex << endl;
#endif
//angle plotting
if(anglePlot){
//if scan argument is 2d
if(scanArgument!=None){
//alframes
if(scanArgument==AllFrames){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//variables
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));
//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));
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
currentScanDivLevel++;
return 0;
}
//if scan argument is 2d
if(scanArgument!=None){
//alframes
if(scanArgument==AllFrames){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double));
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
currentScanDivLevel++;
return 0;
}
//file index
if(scanArgument==FileIndex){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
if(currentIndex == minPixelsY) currentScanDivLevel = 0;
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
currentScanDivLevel++;
return 0;
}
//level0
if(scanArgument==Level0){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
if(currentScanVariable0!=currentScanValue) currentScanDivLevel++;
currentScanValue = currentScanVariable0;
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
return 0;
}
//level1
//file index
if(scanArgument==FileIndex){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
if(currentScanVariable1!=currentScanValue) currentScanDivLevel++;
currentScanValue = currentScanVariable1;
//variables
int currentIndex = myDet->getFileIndexFromFileName(string(data->fileName));
if(currentIndex == minPixelsY) currentScanDivLevel = 0;
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];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
currentScanDivLevel++;
return 0;
}
//level0
if(scanArgument==Level0){
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++;
currentScanValue = currentScanVariable0;
lastImageNumber= currentFrame+1;
//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];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
return 0;
}
//normal measurement or 1d scans
//level1
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000];
// only if you got the lock, do u need to remember lastimagenumber to plot
//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++;
currentScanValue = currentScanVariable1;
lastImageNumber= currentFrame+1;
//1d
if(plot_in_scope==1){
// Titles changed to "" inside startstopthread
// Persistency
if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;
nHists = currentPersistency+1;
histNBins = nPixelsX;
// copy data
for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
}
//2d
else{
// Titles
sprintf(temp_title,"Image Index %d",currentIndex);
imageTitle = temp_title;
// manufacture data for now
for(unsigned int px=0;px<nPixelsX;px++)
for(unsigned int py=0;py<nPixelsY;py++)
image_data[py*nPixelsX+px] = sqrt(pow(currentFrame+1,2)*pow(double(px)-nPixelsX/2,2)/pow(nPixelsX/2,2)/pow(number_of_exposures+1,2) + pow(double(py)-nPixelsY/2,2)/pow(nPixelsY/2,2))/sqrt(2);
// copy data
memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double));
//SHOULD BE memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
}
//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];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
return 0;
}
//normal measurement or 1d scans
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000];
// only if you got the lock, do u need to remember lastimagenumber to plot
lastImageNumber= currentFrame+1;
//1d
if(plot_in_scope==1){
// Titles changed to "" inside startstopthread
// Persistency
if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;
nHists = currentPersistency+1;
histNBins = nPixelsX;
// copy data
for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
}
//2d
else{
// Titles
sprintf(temp_title,"Image Index %d",myDet->getFileIndexFromFileName(string(data->fileName)));
imageTitle = temp_title;
// manufacture data for now
for(unsigned int px=0;px<nPixelsX;px++)
for(unsigned int py=0;py<nPixelsY;py++)
image_data[py*nPixelsX+px] = sqrt(pow(currentFrame+1,2)*pow(double(px)-nPixelsX/2,2)/pow(nPixelsX/2,2)/pow(number_of_exposures+1,2) + pow(double(py)-nPixelsY/2,2)/pow(nPixelsY/2,2))/sqrt(2);
// copy data
memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double));
//SHOULD BE memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
}
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
}
#ifdef VERYVERBOSE
cout << "Exiting GetData function" << endl;
@ -585,6 +604,50 @@ int qDrawPlot::GetData(detectorData *data){
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(){
#ifdef VERYVERBOSE
/*cout << "Entering UpdatePlot function" << endl;*/
cout << "Entering UpdatePlot function" << endl;
#endif
plot_update_timer->stop();
@ -630,9 +693,6 @@ void qDrawPlot::UpdatePlot(){
//1-d plot stuff
if(lastImageNumber){
if(histNBins){
#ifdef VERYVERBOSE
/*cout << "Last Image Number: " << lastImageNumber << endl;*/
#endif
Clear1DPlot();
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
@ -699,33 +759,21 @@ void qDrawPlot::UpdatePlot(){
last_plot_number=lastImageNumber;
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)
plot_update_timer->start((int)timerValue);
else
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);
}
}
if(!frameFactor)
plot_update_timer->start((int)timerValue);
else
plot_update_timer->start((int)PLOT_TIMER_MS);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::StopUpdatePlot(){
#ifdef VERYVERBOSE
cout << "Entering StopUpdatePlot()" << endl;
#endif
plot_update_timer->stop();
}
@ -832,8 +880,12 @@ void qDrawPlot::SavePlot(){
QPainter painter(&savedImage);
render(&painter);
// save image
QString fName = QString(myDet->getFilePath().c_str())+"/Image.png";
QString fName = QString(myDet->getFilePath().c_str());
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);
if (!fName.isEmpty())
@ -851,7 +903,7 @@ void qDrawPlot::SavePlot(){
void qDrawPlot::SaveAll(bool enable){
string msg = string("The Files will be saved as:\n")+
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");
saveAll = enable;
}
@ -866,9 +918,13 @@ void qDrawPlot::SavePlotAutomatic(){
lastSavedMeasurement = currentMeasurement;
char cID[10];
sprintf(cID,"%d",lastSavedFrame);
QString fName = QString(myDet->getFilePath().c_str())+QString("/")+
QString(myDet->getFileName().c_str())+QString("_")+
QString(cID)+".png";
//title
QString fName = QString(myDet->getFilePath().c_str());
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);
QPainter painter(&img);
render(&painter);

View File

@ -337,7 +337,8 @@ void qTabActions::EnablePositions(bool enable){
//to collapse if it was expanded
if(btnExpand[NumPositions]->text()=="-")
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;
lblName[NumPositions]->setPalette(lblName[NumPositions-1]->palette());
lblName[NumPositions]->setEnabled(false);

View File

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

View File

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