This commit is contained in:
maliakal_d 2019-06-19 15:01:57 +02:00
parent d2280b4414
commit f4bc255f2c
2 changed files with 131 additions and 148 deletions

View File

@ -316,53 +316,38 @@ void GainPlotSignal(bool);
private: private:
multiSlsDetector *myDet; multiSlsDetector *myDet;
slsDetectorDefs::detectorType detType; slsDetectorDefs::detectorType detType;
SlsQt1DPlot* plot1D; SlsQt1DPlot* plot1D;
SlsQt2DPlotLayout* plot2D;
QVector<SlsQtH1D*> plot1DHists; QVector<SlsQtH1D*> plot1DHists;
SlsQt2DPlotLayout* plot2D;
static const int MAXCloneWindows = 50; static const int MAXCloneWindows = 50;
qCloneWidget *cloneWidgets[MAXCloneWindows]; qCloneWidget *cloneWidgets[MAXCloneWindows];
/** Widgets needed to set up plot*/ /** Widgets needed to set up plot*/
QGroupBox *boxPlot; QGroupBox *boxPlot;
QGridLayout *layout; QGridLayout *layout;
QGridLayout *plotLayout; QGridLayout *plotLayout;
/**label with frame index for those with many frames per file*/
QLabel *histFrameIndexTitle; QLabel *histFrameIndexTitle;
/** Current Measurement */
int currentMeasurement; int currentMeasurement;
/** currentFrame */
int currentFrame; int currentFrame;
/** variable to check if its the nth frame */
int numFactor;
/** current Scan Division Level */
int currentScanDivLevel;
/** current scan Value */
double currentScanValue;
/** Number of Exposures */
int number_of_exposures;
/** Number of Frames Per Measurement */
int number_of_frames;
/** Duration between Exposures */
double acquisitionPeriod;
/** Acquisition Time */
double exposureTime;
/** Current file index*/
int currentFileIndex; int currentFileIndex;
/** Current frame index*/
int currentFrameIndex; int currentFrameIndex;
/**variables for threads */ int numberofFrames;
/** */ double acquisitionPeriod;
double exposureTime;
volatile bool stop_signal; volatile bool stop_signal;
/** */
pthread_mutex_t last_image_complete_mutex; pthread_mutex_t last_image_complete_mutex;
/**variables for histograms */ /**variables for histograms */

View File

@ -85,17 +85,17 @@ void qDrawPlot::SetupWidgetWindow() {
currentMeasurement = 0; currentMeasurement = 0;
currentFrame = 0; currentFrame = 0;
numFactor = 0;
currentScanDivLevel = 0; currentScanDivLevel = 0;
currentScanValue = 0; currentScanValue = 0;
number_of_exposures = 0; number_of_exposures = 0;
number_of_frames = 0; numberofFrames = 0;
acquisitionPeriod = 0; acquisitionPeriod = 0;
exposureTime = 0; exposureTime = 0;
currentFileIndex = 0; currentFileIndex = 0;
currentFrameIndex = 0; currentFrameIndex = 0;
stop_signal = 0; stopSignal = 0;
pthread_mutex_init(&last_image_complete_mutex, NULL); pthread_mutex_init(&last_image_complete_mutex, NULL);
// Default titles- only for the initial picture // Default titles- only for the initial picture
@ -442,7 +442,7 @@ void qDrawPlot::SaveAll(bool enable){saveAll = enable;};
void qDrawPlot::SetLines(bool enable){lines = enable;}; void qDrawPlot::SetLines(bool enable){lines = enable;};
void qDrawPlot::SetMarkers(bool enable){markers = enable;}; void qDrawPlot::SetMarkers(bool enable){markers = enable;};
void qDrawPlot::StopAcquisition(){ stop_signal = true; }; void qDrawPlot::StopAcquisition(){ stopSignal = true; };
const char* qDrawPlot::GetImageTitle() {return imageTitle.c_str();} const char* qDrawPlot::GetImageTitle() {return imageTitle.c_str();}
@ -502,14 +502,14 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running) {
int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1));
numFrames = ((numFrames==0)?1:numFrames); numFrames = ((numFrames==0)?1:numFrames);
numTriggers = ((numTriggers==0)?1:numTriggers); numTriggers = ((numTriggers==0)?1:numTriggers);
number_of_frames = numFrames * numTriggers; numberofFrames = numFrames * numTriggers;
std::cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames <<'\n'; std::cout << "\tNumber of Frames per Scan/Measurement:" << numberofFrames <<'\n';
//get #scansets for level 0 and level 1 //get #scansets for level 0 and level 1
int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0); int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0);
int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1); int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1);
int numPos=myDet->getPositions(); int numPos=myDet->getPositions();
number_of_exposures = number_of_frames * numScan0 * numScan1; number_of_exposures = numberofFrames * numScan0 * numScan1;
if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos; if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos;
std::cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures <<'\n'; std::cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures <<'\n';
*/ */
@ -521,8 +521,7 @@ 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);
std::cout << "\tAcquisition Period:" << std::setprecision(10) << acquisitionPeriod << '\n'; std::cout << "\tAcquisition Period:" << std::setprecision(10) << acquisitionPeriod << '\n';
std::cout << "\tFile Index:" << myDet->getFileIndex() << '\n'; std::cout << "\tFile Index:" << myDet->getFileIndex() << '\n';
//to take the first data if frameFactor
numFactor = 0;
//for save automatically, //for save automatically,
saveError = false; saveError = false;
@ -588,7 +587,7 @@ bool qDrawPlot::StartOrStopThread(bool start) {
//stop part, before start or restart //stop part, before start or restart
if (gui_acquisition_thread_running) { if (gui_acquisition_thread_running) {
std::cout << "Stopping current acquisition thread ...." << '\n'; std::cout << "Stopping current acquisition thread ...." << '\n';
stop_signal = 1; //sorta useless right now stopSignal = 1; //sorta useless right now
gui_acquisition_thread_running = 0; gui_acquisition_thread_running = 0;
} }
@ -628,127 +627,127 @@ bool qDrawPlot::StartOrStopThread(bool start) {
// void qDrawPlot::SetScanArgument(int scanArg){ void qDrawPlot::SetScanArgument(int scanArg){
// #ifdef VERYVERBOSE #ifdef VERYVERBOSE
// std::cout << "SetScanArgument function:" << scanArg << " running:" << running <<'\n'; std::cout << "SetScanArgument function:" << scanArg << " running:" << running <<'\n';
// #endif #endif
// scanArgument = scanArg; scanArgument = scanArg;
// LockLastImageArray(); LockLastImageArray();
// if(plot_in_scope==1) Clear1DPlot(); if(plot_in_scope==1) Clear1DPlot();
// // Number of Exposures - must be calculated here to get npixelsy for allframes/frameindex scans // Number of Exposures - must be calculated here to get npixelsy for allframes/frameindex scans
// int numFrames = (isFrameEnabled)*((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); int numFrames = (isFrameEnabled)*((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1));
// int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1));
// int numStoragecells = 0; int numStoragecells = 0;
// if (detType == slsDetectorDefs::JUNGFRAU) if (detType == slsDetectorDefs::JUNGFRAU)
// numStoragecells = (int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, -1); numStoragecells = (int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, -1);
// numFrames = ((numFrames==0)?1:numFrames); numFrames = ((numFrames==0)?1:numFrames);
// numTriggers = ((numTriggers==0)?1:numTriggers); numTriggers = ((numTriggers==0)?1:numTriggers);
// numStoragecells = ((numStoragecells<=0)?1:numStoragecells+1); numStoragecells = ((numStoragecells<=0)?1:numStoragecells+1);
// number_of_frames = numFrames * numTriggers * numStoragecells; numberofFrames = numFrames * numTriggers * numStoragecells;
// std::cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames <<'\n'; std::cout << "\tNumber of Frames per Scan/Measurement:" << numberofFrames <<'\n';
// //get #scansets for level 0 and level 1 //get #scansets for level 0 and level 1
// int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0); int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0);
// int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1); int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1);
// //int numPos=myDet->getPositions(); //int numPos=myDet->getPositions();
// number_of_exposures = number_of_frames * numScan0 * numScan1; number_of_exposures = numberofFrames * numScan0 * numScan1;
// if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos; if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos;
// std::cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures <<'\n'; std::cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures <<'\n';
// maxPixelsY = 0; maxPixelsY = 0;
// minPixelsY = 0; minPixelsY = 0;
// nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X); nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X);
// nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y); nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y);
// if (detType == slsDetectorDefs::MOENCH) { if (detType == slsDetectorDefs::MOENCH) {
// npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES, -1) * 2)/25; // for moench 03 npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::SAMPLES, -1) * 2)/25; // for moench 03
// nPixelsX = npixelsx_jctb; nPixelsX = npixelsx_jctb;
// nPixelsY = npixelsy_jctb; nPixelsY = npixelsy_jctb;
// } }
// //cannot do this in between measurements , so update instantly //cannot do this in between measurements , so update instantly
// if(scanArgument==qDefs::Level0){ if(scanArgument==qDefs::Level0){
// //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab
// int numSteps = myDet->getScanSteps(0); int numSteps = myDet->getScanSteps(0);
// double *values = new double[numSteps]; double *values = new double[numSteps];
// myDet->getScanSteps(0,values); myDet->getScanSteps(0,values);
// maxPixelsY = values[numSteps-1]; maxPixelsY = values[numSteps-1];
// minPixelsY = values[0]; minPixelsY = values[0];
// nPixelsY = numSteps; nPixelsY = numSteps;
// }else if(scanArgument==qDefs::Level1) { }else if(scanArgument==qDefs::Level1) {
// //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab
// int numSteps = myDet->getScanSteps(1); int numSteps = myDet->getScanSteps(1);
// double *values = new double[numSteps]; double *values = new double[numSteps];
// myDet->getScanSteps(1,values); myDet->getScanSteps(1,values);
// maxPixelsY = values[numSteps-1]; maxPixelsY = values[numSteps-1];
// minPixelsY = values[0]; minPixelsY = values[0];
// nPixelsY = numSteps; nPixelsY = numSteps;
// }else if(scanArgument==qDefs::AllFrames) }else if(scanArgument==qDefs::AllFrames)
// nPixelsY = number_of_exposures; nPixelsY = number_of_exposures;
// else if(scanArgument==qDefs::FileIndex) else if(scanArgument==qDefs::FileIndex)
// nPixelsY = number_of_frames; nPixelsY = numberofFrames;
// if(minPixelsY>maxPixelsY){ if(minPixelsY>maxPixelsY){
// double temp = minPixelsY; double temp = minPixelsY;
// minPixelsY = maxPixelsY; minPixelsY = maxPixelsY;
// maxPixelsY = temp; maxPixelsY = temp;
// backwardScanPlot = true; backwardScanPlot = true;
// }else backwardScanPlot = false; }else backwardScanPlot = false;
// //1d //1d
// if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX]; if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX];
// if(histYAxis[0]) delete [] histYAxis[0]; histYAxis[0] = new double [nPixelsX]; if(histYAxis[0]) delete [] histYAxis[0]; histYAxis[0] = new double [nPixelsX];
// //2d //2d
// if(lastImageArray) delete [] lastImageArray; lastImageArray = new double[nPixelsY*nPixelsX]; if(lastImageArray) delete [] lastImageArray; lastImageArray = new double[nPixelsY*nPixelsX];
// if(gainImageArray) delete [] gainImageArray; gainImageArray = new double[nPixelsY*nPixelsX]; if(gainImageArray) delete [] gainImageArray; gainImageArray = new double[nPixelsY*nPixelsX];
// //initializing 1d x axis //initializing 1d x axis
// for(unsigned int px=0;px<nPixelsX;++px) histXAxis[px] = px;/*+10;*/ for(unsigned int px=0;px<nPixelsX;++px) histXAxis[px] = px;/*+10;*/
// //initializing 2d array //initializing 2d array
// memset(lastImageArray,0,nPixelsY *nPixelsX * sizeof(double)); memset(lastImageArray,0,nPixelsY *nPixelsX * sizeof(double));
// memset(gainImageArray,0,nPixelsY *nPixelsX * sizeof(double)); memset(gainImageArray,0,nPixelsY *nPixelsX * sizeof(double));
// /*for(int py=0;py<(int)nPixelsY;++py) /*for(int py=0;py<(int)nPixelsY;++py)
// for(int px=0;px<(int)nPixelsX;++px) { for(int px=0;px<(int)nPixelsX;++px) {
// lastImageArray[py*nPixelsX+px] = 0; lastImageArray[py*nPixelsX+px] = 0;
// gainImageArray[py*nPixelsX+px] = 0; gainImageArray[py*nPixelsX+px] = 0;
// } }
// */ */
// //histogram //histogram
// if(histogram){ if(histogram){
// int iloop = 0; int iloop = 0;
// int numSteps = ((histTo-histFrom)/(histSize)) + 1;std::cout<<"numSteps:"<<numSteps<<" histFrom:"<<histFrom<<" histTo:"<<histTo<<" histSize:"<<histSize<<endl; int numSteps = ((histTo-histFrom)/(histSize)) + 1;std::cout<<"numSteps:"<<numSteps<<" histFrom:"<<histFrom<<" histTo:"<<histTo<<" histSize:"<<histSize<<endl;
// histogramSamples.resize(numSteps); histogramSamples.resize(numSteps);
// startPixel = histFrom -(histSize/2);std::cout<<"startpixel:"<<startPixel<<endl; startPixel = histFrom -(histSize/2);std::cout<<"startpixel:"<<startPixel<<endl;
// endPixel = histTo + (histSize/2);std::cout<<"endpixel:"<<endPixel<<endl; endPixel = histTo + (histSize/2);std::cout<<"endpixel:"<<endPixel<<endl;
// while(startPixel < endPixel){ while(startPixel < endPixel){
// histogramSamples[iloop].interval.setInterval(startPixel,startPixel+histSize,QwtInterval::ExcludeMaximum); histogramSamples[iloop].interval.setInterval(startPixel,startPixel+histSize,QwtInterval::ExcludeMaximum);
// histogramSamples[iloop].value = 0; histogramSamples[iloop].value = 0;
// startPixel += histSize; startPixel += histSize;
// iloop++; iloop++;
// } }
// //print values //print values
// std::cout << "Histogram Intervals:" <<'\n'; std::cout << "Histogram Intervals:" <<'\n';
// for(int j=0;j<histogramSamples.size();++j){ for(int j=0;j<histogramSamples.size();++j){
// std::cout<<j<<":\tmin:"<<histogramSamples[j].interval.minValue()<<"" std::cout<<j<<":\tmin:"<<histogramSamples[j].interval.minValue()<<""
// "\t\tmax:"<<histogramSamples[j].interval.maxValue()<<"\t\tvalue:"<<histogramSamples[j].value<<endl; "\t\tmax:"<<histogramSamples[j].interval.maxValue()<<"\t\tvalue:"<<histogramSamples[j].value<<endl;
// } }
// } }
// UnlockLastImageArray(); UnlockLastImageArray();
// qDefs::checkErrorMessage(myDet,"qDrawPlot::SetScanArgument"); qDefs::checkErrorMessage(myDet,"qDrawPlot::SetScanArgument");
// } }
@ -762,11 +761,10 @@ void qDrawPlot::SetupMeasurement() {
#endif #endif
// Defaults // Defaults
if (!running) if (!running)
stop_signal = 0; stopSignal = 0;
plotRequired = 0; plotRequired = 0;
currentFrame = 0; currentFrame = 0;
//for 2d scans
currentScanDivLevel = 0;
//if(plot_in_scope==2) //if(plot_in_scope==2)
if (!running) if (!running)
lastImageNumber = 0; /**Just now */ lastImageNumber = 0; /**Just now */
@ -809,10 +807,10 @@ void qDrawPlot::SetupMeasurement() {
nPixelsY = number_of_exposures; nPixelsY = number_of_exposures;
} //frame index } //frame index
else if (scanArgument == qDefs::FileIndex) { else if (scanArgument == qDefs::FileIndex) {
maxPixelsY = number_of_frames - 1; maxPixelsY = numberofFrames - 1;
minPixelsY = 0; minPixelsY = 0;
if (!running) if (!running)
nPixelsY = number_of_frames; nPixelsY = numberofFrames;
} //level0 or level1 } //level0 or level1
else { else {
currentScanValue = minPixelsY; currentScanValue = minPixelsY;
@ -902,7 +900,7 @@ int qDrawPlot::GetData(detectorData *data, int fIndex, int subIndex) {
std::cout << "dynamicRange " << data->dynamicRange << '\n'; std::cout << "dynamicRange " << data->dynamicRange << '\n';
std::cout << "fileIndex " << data->fileIndex << '\n'; std::cout << "fileIndex " << data->fileIndex << '\n';
#endif #endif
if (!stop_signal) { if (!stopSignal) {
//set progress //set progress
progress = (int)data->progressIndex; progress = (int)data->progressIndex;
@ -1286,11 +1284,11 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus) {
std::cout << status.toAscii().constData() << " and progress " << currentProgress << '\n'; std::cout << status.toAscii().constData() << " and progress " << currentProgress << '\n';
#endif #endif
//error or stopped //error or stopped
if ((stop_signal) || (detectorStatus == slsDetectorDefs::ERROR)) { if ((stopSignal) || (detectorStatus == slsDetectorDefs::ERROR)) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Error in Acquisition\n\n"; std::cout << "Error in Acquisition\n\n";
#endif #endif
//stop_signal = 1;//just to be sure //stopSignal = 1;//just to be sure
emit AcquisitionErrorSignal(status); emit AcquisitionErrorSignal(status);
} }
#ifdef VERBOSE #ifdef VERBOSE