mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-05 20:30:03 +02:00
a rough idea of a scan is implemented with all frames
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@37 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
parent
cc176ea404
commit
73152572a5
@ -126,6 +126,8 @@ void SavePlot();
|
||||
void SetPersistency(int val);
|
||||
/** sets style of plot to dotted */
|
||||
void SetDottedPlot(bool enable){plotDotted = enable;};
|
||||
/** sets the scan argument to prepare the plot*/
|
||||
void SetScanArgument(int scanArg){scanArgument = scanArg;};
|
||||
|
||||
|
||||
|
||||
@ -166,10 +168,7 @@ 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 the detector class to copy the scan data it jus acquired */
|
||||
static int GetScanDataCallBack(detectorData *data, void *this_pointer);
|
||||
/** This is called by the GetDataCallBack function to copy the scan data */
|
||||
int GetScanData(detectorData *data);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -195,7 +194,7 @@ void UpdatePause(){data_pause_over=true;};
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/** The sls detector object */
|
||||
multiSlsDetector *myDet;
|
||||
|
||||
@ -329,7 +328,8 @@ bool isFrameEnabled;
|
||||
bool isTriggerEnabled;
|
||||
|
||||
/** scan arguments*/
|
||||
enum scanArguments{None,Level0,Level1,FileIndex,AllFrames};
|
||||
enum scanArgumentList{None,Level0,Level1,FileIndex,AllFrames};
|
||||
int scanArgument;
|
||||
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@ class qDrawPlot;
|
||||
#include <QButtonGroup>
|
||||
#include <QAbstractButton>
|
||||
|
||||
|
||||
/**
|
||||
*@short sets up the Plot parameters
|
||||
*/
|
||||
@ -70,6 +71,11 @@ private:
|
||||
static QString defaultImageYAxisTitle;
|
||||
static QString defaultImageZAxisTitle;
|
||||
|
||||
/** scans */
|
||||
static const QString modeNames[5];
|
||||
|
||||
|
||||
|
||||
/** methods */
|
||||
/** Sets up the widget
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@ UI_HEADERS_DIR = forms/include
|
||||
RESOURCES += icons.qrc
|
||||
|
||||
|
||||
DEFINES += VERBOSE DACS_INT VERYVERBOSE
|
||||
DEFINES += VERBOSE DACS_INT #VERYVERBOSE
|
||||
|
||||
|
||||
target.path += $(DESTDIR)
|
||||
|
@ -86,6 +86,7 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
data_pause_over = true;//to get the first image
|
||||
isFrameEnabled = false;
|
||||
isTriggerEnabled = false;
|
||||
scanArgument = None;
|
||||
// This is so that it initially stop and plots
|
||||
running = 1;
|
||||
for(int i=0;i<MAX_1DPLOTS;i++) {histYAxis[i]=0;yvalues[i]=0; }
|
||||
@ -183,8 +184,22 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
|
||||
numFrames = ((numFrames==0)?1:numFrames);
|
||||
numTriggers = ((numTriggers==0)?1:numTriggers);
|
||||
|
||||
number_of_exposures= numFrames * numTriggers;
|
||||
number_of_exposures = numFrames * numTriggers;
|
||||
//cout << "\tNumber of Exposures:" << number_of_exposures << endl;
|
||||
/* have to also look at vector created using npixelsy as size*/
|
||||
if(scanArgument==AllFrames)
|
||||
nPixelsY = number_of_exposures;
|
||||
else nPixelsY = 100;
|
||||
|
||||
//get #pos and #scansets for level 0 and level 1
|
||||
int numPos = myDet->getPositions(); numPos = ((numPos==0)?1:numPos);
|
||||
int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0);
|
||||
int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1);
|
||||
|
||||
number_of_exposures = number_of_exposures * numPos * numScan0 * numScan1;
|
||||
cout << "\tNumber of Exposures:" << number_of_exposures << endl;
|
||||
|
||||
|
||||
// ExposureTime
|
||||
exposureTime= ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9);
|
||||
cout << "\tExposure Time:" << setprecision (10) << exposureTime << endl;
|
||||
@ -253,8 +268,15 @@ bool qDrawPlot::StartOrStopThread(bool start){
|
||||
stop_signal = 0;
|
||||
oldFrameNumber = 0;
|
||||
histNBins = nPixelsX;
|
||||
if(!image_data) image_data = new double[nPixelsX*nPixelsY];
|
||||
if(!lastImageArray) lastImageArray = new double[nPixelsX*nPixelsY];
|
||||
|
||||
/**delete it if it exists and create again and for originally 1d, initalize it with all 0*/
|
||||
if(image_data) delete [] image_data;
|
||||
image_data = new double[nPixelsY*nPixelsX];
|
||||
//if(!image_data) image_data = new double[nPixelsY*nPixelsX];
|
||||
//if(!lastImageArray) lastImageArray = new double[nPixelsY*nPixelsX];
|
||||
if(lastImageArray) delete [] lastImageArray;
|
||||
lastImageArray = new double[nPixelsY*nPixelsX];
|
||||
|
||||
if(!histXAxis) histXAxis = new double [nPixelsX];
|
||||
for(unsigned int px=0;px<nPixelsX;px++) histXAxis[px] = px+10;
|
||||
if(!yvalues[0]) yvalues[0] = new double [nPixelsX];
|
||||
@ -302,56 +324,59 @@ int qDrawPlot::GetData(detectorData *data){
|
||||
cout << "Entering GetDatafunction" << endl;
|
||||
#endif
|
||||
if(!stop_signal){
|
||||
//not frame factor
|
||||
if(!frameFactor){
|
||||
//if the time is not over, RETURN
|
||||
if(!data_pause_over){
|
||||
//lastImageNumber= currentFrame+1;
|
||||
currentFrame++;
|
||||
currentIndex++;
|
||||
return 0;
|
||||
}
|
||||
data_pause_over=false;
|
||||
data_pause_timer->start((int)(PLOT_TIMER_MS/2));
|
||||
}//if frame factor or last frame of last measurement... for all other factors, RETURN
|
||||
else{
|
||||
if(((currentFrame+1==number_of_exposures)&&(currentMeasurement+1==number_of_measurements))
|
||||
||(!((currentFrame)%frameFactor)))
|
||||
oldCopy = false;//if this works, then we forget old data
|
||||
else{
|
||||
//lastImageNumber= currentFrame+1;
|
||||
currentFrame++;
|
||||
currentIndex++;
|
||||
progress=(int)data->progressIndex;
|
||||
//if theres an old copy, try to get lock again
|
||||
if(oldCopy){
|
||||
#ifdef VERBOSE
|
||||
cout << "Copying old data: " << oldFrameNumber << endl;
|
||||
#endif
|
||||
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;
|
||||
//1d
|
||||
if(plot_in_scope==1){
|
||||
// Titles
|
||||
sprintf(temp_title,"Frame Index%d",oldFrameNumber); histTitle[0] = temp_title;
|
||||
// copy data//memcpy(histXAxis, xvalues,nPixelsX*sizeof(double));
|
||||
for(int i=currentPersistency;i>0;i--)
|
||||
memcpy(histYAxis[i],yvalues[i-1],nPixelsX*sizeof(double));
|
||||
memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double));
|
||||
}//2d
|
||||
else{
|
||||
// Titles
|
||||
sprintf(temp_title,"Image Index %d",oldFrameNumber);
|
||||
imageTitle = temp_title;
|
||||
// copy data
|
||||
//memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double));
|
||||
}
|
||||
pthread_mutex_unlock(&(last_image_complete_mutex));
|
||||
}
|
||||
/** all frames shouldnt go in here */
|
||||
if(scanArgument!=AllFrames){
|
||||
//not frame factor
|
||||
if(!frameFactor){
|
||||
//if the time is not over, RETURN
|
||||
if(!data_pause_over){
|
||||
//lastImageNumber= currentFrame+1;
|
||||
currentFrame++;
|
||||
currentIndex++;
|
||||
return 0;
|
||||
}
|
||||
data_pause_over=false;
|
||||
data_pause_timer->start((int)(PLOT_TIMER_MS/2));
|
||||
}//if frame factor or last frame of last measurement... for all other factors, RETURN
|
||||
else{
|
||||
if(((currentFrame+1==number_of_exposures)&&(currentMeasurement+1==number_of_measurements))
|
||||
||(!((currentFrame)%frameFactor)))
|
||||
oldCopy = false;//if this works, then we forget old data
|
||||
else{
|
||||
//lastImageNumber= currentFrame+1;
|
||||
currentFrame++;
|
||||
currentIndex++;
|
||||
progress=(int)data->progressIndex;
|
||||
//if theres an old copy, try to get lock again
|
||||
if(oldCopy){
|
||||
#ifdef VERBOSE
|
||||
cout << "Copying old data: " << oldFrameNumber << endl;
|
||||
#endif
|
||||
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;
|
||||
//1d
|
||||
if(plot_in_scope==1){
|
||||
// Titles
|
||||
sprintf(temp_title,"Frame Index%d",oldFrameNumber); histTitle[0] = temp_title;
|
||||
// copy data//memcpy(histXAxis, xvalues,nPixelsX*sizeof(double));
|
||||
for(int i=currentPersistency;i>0;i--)
|
||||
memcpy(histYAxis[i],yvalues[i-1],nPixelsX*sizeof(double));
|
||||
memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double));
|
||||
}//2d
|
||||
else{
|
||||
// Titles
|
||||
sprintf(temp_title,"Image Index %d",oldFrameNumber);
|
||||
imageTitle = temp_title;
|
||||
// copy data
|
||||
//memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double));
|
||||
}
|
||||
pthread_mutex_unlock(&(last_image_complete_mutex));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//if plot disabled, RETURN
|
||||
@ -369,6 +394,21 @@ int qDrawPlot::GetData(detectorData *data){
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Reading in image: " << currentIndex << endl;
|
||||
#endif
|
||||
|
||||
//if scan argument is all frames
|
||||
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+(currentFrame*nPixelsX),data->values,nPixelsX*sizeof(double));
|
||||
pthread_mutex_unlock(&(last_image_complete_mutex));
|
||||
}
|
||||
currentFrame++;
|
||||
currentIndex++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
@ -434,61 +474,6 @@ int qDrawPlot::GetData(detectorData *data){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
int qDrawPlot::GetScanDataCallBack(detectorData *data, void *this_pointer){
|
||||
((qDrawPlot*)this_pointer)->GetScanData(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
int qDrawPlot::GetScanData(detectorData *data){/*
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Entering GetScanDatafunction"<<endl;
|
||||
#endif
|
||||
if(!stop_signal){
|
||||
//if plot disabled, RETURN
|
||||
if(!plotEnable) {
|
||||
progress=(int)data->progressIndex;
|
||||
//lastImageNumber= currentFrame+1;
|
||||
currentThrehold++;
|
||||
return 0;
|
||||
}
|
||||
//what comes here has plot enabled AND (frame factor OR data pause over )
|
||||
progress=(int)data->progressIndex;
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
cout<<"Reading in image: "<<currentThrehold<<endl;
|
||||
#endif
|
||||
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= currentThrehold+1;
|
||||
|
||||
nPixelsY = currentThrehold+1;
|
||||
// Titles
|
||||
sprintf(temp_title,"Adding Threshold %f",threhold[currentThrehold]);
|
||||
imageTitle = temp_title;
|
||||
// copy data
|
||||
memcpy(lastImageArray[i],data->values,nPixelsX*sizeof(double));
|
||||
|
||||
pthread_mutex_unlock(&(last_image_complete_mutex));
|
||||
}
|
||||
currentThrehold++;
|
||||
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
cout<<"Exiting GetScanData function"<<endl;
|
||||
#endif*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -566,6 +551,7 @@ void qDrawPlot::UpdatePlot(){
|
||||
}
|
||||
}
|
||||
//2-d plot stuff
|
||||
//cout<<"npixelsx:"<<nPixelsX<<
|
||||
if(lastImageArray){
|
||||
if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot
|
||||
nPixelsX>0&&nPixelsY>0){
|
||||
@ -601,7 +587,7 @@ void qDrawPlot::UpdatePlot(){
|
||||
}
|
||||
// if a measurement is over
|
||||
else{
|
||||
currentMeasurement++;
|
||||
currentMeasurement++;cout<<"currentMeasurement:"<<currentMeasurement<<endl;
|
||||
// if all the measurements are over
|
||||
if(currentMeasurement==number_of_measurements){
|
||||
StartStopDaqToggle(true);
|
||||
|
@ -21,6 +21,7 @@ using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
const QString qTabPlot::modeNames[5]={"None","Energy Scan","Threshold Scan","Trimbits Scan","Custom Script Scan"};
|
||||
|
||||
QString qTabPlot::defaultPlotTitle("Measurement");
|
||||
QString qTabPlot::defaultHistXAxisTitle("Channel Number");
|
||||
@ -76,8 +77,6 @@ void qTabPlot::SetupWidgetWindow(){
|
||||
btnGroupScan->addButton(radioAllFrames,3);
|
||||
|
||||
// Plot Axis
|
||||
myPlot->SetPlotTitle(defaultPlotTitle);
|
||||
dispTitle->setText(defaultPlotTitle);
|
||||
dispTitle->setEnabled(false);
|
||||
dispXAxis->setEnabled(false);
|
||||
dispYAxis->setEnabled(false);
|
||||
@ -128,13 +127,18 @@ void qTabPlot::SetupWidgetWindow(){
|
||||
|
||||
// Depending on whether the detector is 1d or 2d
|
||||
switch(myDet->getDetectorsType()){
|
||||
case slsDetectorDefs::MYTHEN: isOrginallyOneD = true; Select1DPlot(true); break;
|
||||
case slsDetectorDefs::EIGER: isOrginallyOneD = false; Select1DPlot(false);break;
|
||||
case slsDetectorDefs::GOTTHARD: isOrginallyOneD = true; Select1DPlot(true);break;
|
||||
case slsDetectorDefs::MYTHEN: isOrginallyOneD = true; break;
|
||||
case slsDetectorDefs::EIGER: isOrginallyOneD = false; break;
|
||||
case slsDetectorDefs::GOTTHARD: isOrginallyOneD = true; break;
|
||||
default:
|
||||
cout << "ERROR: Detector Type is Generic" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Select1DPlot(isOrginallyOneD);
|
||||
|
||||
//to check if this should be enabled
|
||||
EnableScanBox();
|
||||
}
|
||||
|
||||
|
||||
@ -143,6 +147,8 @@ void qTabPlot::SetupWidgetWindow(){
|
||||
|
||||
void qTabPlot::Select1DPlot(bool b){
|
||||
isOneD = b;
|
||||
dispTitle->setText(defaultPlotTitle);
|
||||
myPlot->SetPlotTitle(defaultPlotTitle);
|
||||
if(b){
|
||||
box1D->show();
|
||||
box2D->hide();
|
||||
@ -169,7 +175,6 @@ void qTabPlot::Select1DPlot(bool b){
|
||||
myPlot->Select2DPlot();
|
||||
}
|
||||
|
||||
boxScan->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
@ -386,11 +391,13 @@ void qTabPlot::SetPlot(){
|
||||
#endif
|
||||
if(radioNoPlot->isChecked()){
|
||||
cout << " - No Plot" << endl;
|
||||
Select1DPlot(isOrginallyOneD);
|
||||
|
||||
//Select1DPlot(isOrginallyOneD);
|
||||
//if(isOrginallyOneD) {box1D->show(); box2D->hide();}
|
||||
//if(!isOrginallyOneD){box2D->show(); box1D->hide();}
|
||||
myPlot->EnablePlot(false);
|
||||
//if enable is true, disable everything
|
||||
if(isOrginallyOneD) {box1D->show(); box1D->setEnabled(false); box2D->hide();}
|
||||
if(!isOrginallyOneD){box2D->show(); box2D->setEnabled(false); box1D->hide();}
|
||||
|
||||
boxSnapshot->setEnabled(false);
|
||||
boxSave->setEnabled(false);
|
||||
boxFrequency->setEnabled(false);
|
||||
@ -398,10 +405,11 @@ void qTabPlot::SetPlot(){
|
||||
boxScan->setEnabled(false);
|
||||
}else if(radioDataGraph->isChecked()){
|
||||
cout << " - DataGraph" << endl;
|
||||
|
||||
myPlot->EnablePlot(true);
|
||||
//if enable is true, disable everything
|
||||
if(isOrginallyOneD) {box1D->show();box1D->setEnabled(true);} else box1D->hide();
|
||||
if(!isOrginallyOneD){box2D->show();box2D->setEnabled(true);} else box2D->hide();
|
||||
if(isOrginallyOneD) {box1D->show(); box2D->hide();}
|
||||
if(!isOrginallyOneD) {box2D->show(); box1D->hide();}
|
||||
Select1DPlot(isOrginallyOneD);
|
||||
boxSnapshot->setEnabled(true);
|
||||
boxSave->setEnabled(true);
|
||||
@ -504,6 +512,9 @@ void qTabPlot::EnableScanBox(int mode,int id){
|
||||
radioLevel0->setEnabled(mode0);
|
||||
radioLevel1->setEnabled(mode1);
|
||||
}else EnablingNthFrameFunction(enableNFrame);
|
||||
|
||||
//sets the scan argument
|
||||
SetScanArgument();
|
||||
}
|
||||
|
||||
|
||||
@ -533,27 +544,67 @@ void qTabPlot::EnablingNthFrameFunction(bool enable){
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabPlot::SetScanArgument(){
|
||||
switch(btnGroupScan->checkedId()){
|
||||
|
||||
//let qdrawplot know which scan argument
|
||||
//myPlot->
|
||||
//as default from histogram and default titles are set here if scanbox is disabled
|
||||
Select1DPlot(isOrginallyOneD);
|
||||
|
||||
//level0
|
||||
case 0:
|
||||
break;
|
||||
//this function is also called just to update, could be no scan
|
||||
if(boxScan->isEnabled()){
|
||||
|
||||
//level1
|
||||
case 1:
|
||||
break;
|
||||
//setting the title according to the scans
|
||||
QString mainTitle = QString(" Level 0 : ") + modeNames[myDet->getScanMode(0)] +
|
||||
QString(" | Level 1 : ") + modeNames[myDet->getScanMode(1)] + QString("");
|
||||
dispTitle->setText(mainTitle);
|
||||
myPlot->SetPlotTitle(mainTitle);
|
||||
|
||||
//file index
|
||||
case 2:
|
||||
break;
|
||||
|
||||
//all frames
|
||||
case 3:
|
||||
break;
|
||||
}
|
||||
//let qdrawplot know which scan argument
|
||||
myPlot->SetScanArgument(btnGroupScan->checkedId()+1);
|
||||
/** What happens for 2d????*/
|
||||
//settings the x and y titles
|
||||
switch(btnGroupScan->checkedId()){
|
||||
//level0
|
||||
case 0:
|
||||
dispXAxis->setText("Channel Number");
|
||||
dispYAxis->setText("Scan Level 0");
|
||||
myPlot->SetHistXAxisTitle("Channel Number");
|
||||
myPlot->SetHistYAxisTitle("Scan Level 0");
|
||||
myPlot->Select1DPlot();
|
||||
break;
|
||||
|
||||
//level1
|
||||
case 1:
|
||||
dispXAxis->setText("Channel Number");
|
||||
dispYAxis->setText("Scan Level 1");
|
||||
myPlot->SetHistXAxisTitle("Channel Number");
|
||||
myPlot->SetHistYAxisTitle("Scan Level 1");
|
||||
myPlot->Select1DPlot();
|
||||
break;
|
||||
|
||||
//file index
|
||||
case 2:
|
||||
dispXAxis->setText("Channel Number");
|
||||
dispYAxis->setText("File Index");
|
||||
myPlot->SetHistXAxisTitle("Channel Number");
|
||||
myPlot->SetHistYAxisTitle("File Index");
|
||||
myPlot->Select1DPlot();
|
||||
break;
|
||||
|
||||
//all frames
|
||||
case 3:
|
||||
Select1DPlot(false);
|
||||
dispXAxis->setText("Channel Number");
|
||||
dispYAxis->setText("Threshold");
|
||||
dispZAxis->setText("Intensity");
|
||||
myPlot->SetImageXAxisTitle("Channel Number");
|
||||
myPlot->SetImageYAxisTitle("Threshold");
|
||||
myPlot->SetImageZAxisTitle("Intensity");
|
||||
myPlot->Select2DPlot();
|
||||
break;
|
||||
}
|
||||
}else //done here so that it isnt set by default each time
|
||||
myPlot->SetScanArgument(0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user