fixed gettrimbits, histogram(still more),start stop,scans,not accessign shared memory duign acquisition

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@55 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-09-12 15:44:23 +00:00
parent f7078c3700
commit 62b14f4199
16 changed files with 575 additions and 222 deletions

View File

@ -60,7 +60,7 @@
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
<widget class="QWidget" name="gridLayoutWidget_3">
<property name="geometry">
@ -120,7 +120,7 @@
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="spinExpTime">
<property name="enabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -167,7 +167,7 @@
<item row="3" column="3">
<widget class="QComboBox" name="comboExpUnit">
<property name="enabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -339,7 +339,7 @@ An extension given by the modules serial number will be attached.
<item row="3" column="7" colspan="2">
<widget class="QDoubleSpinBox" name="spinThreshold">
<property name="enabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -402,7 +402,7 @@ An extension given by the modules serial number will be attached.
<item row="0" column="5">
<widget class="QCheckBox" name="chkOptimize">
<property name="enabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -567,6 +567,9 @@ An extension given by the modules serial number will be attached.
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>

View File

@ -101,6 +101,12 @@ public:
* @param enable enable */
void setTriggerEnabled(bool enable){isTriggerEnabled = enable;};
/** Updates the trimbit plot
* @param fromDetector is true if the trimbits should be loaded from detector
* @param Histogram true if histogram, else data graph
* returns ok/fail
* */
int UpdateTrimbitPlot(bool fromDetector,bool Histogram);
@ -110,7 +116,7 @@ public slots:
@param i is 1 for 1D, else 2D plot */
void SelectPlot(int i=2);
/** To select 1D plot */
void Select1DPlot() {SelectPlot(1);}
void Select1DPlot() {Clear1DPlot();SelectPlot(1);}
/** To select 2D plot */
void Select2DPlot() {SelectPlot(2);}
/** To clear plot */
@ -124,7 +130,7 @@ void SaveClones();
/** To Save plot */
void SavePlot();
/** Save all plots **/
void SaveAll(bool enable);
void SaveAll(bool enable){saveAll = enable;};
/** Sets persistency from plot tab */
void SetPersistency(int val);
/** sets style of plot to lines*/
@ -132,7 +138,7 @@ void SetLines(bool enable){lines = enable;};
/** sets markers */
void SetMarkers(bool enable){markers = enable;};
/** sets the scan argument to prepare the plot*/
void SetScanArgument(int scanArg){scanArgument = scanArg;};
void SetScanArgument(int scanArg);
/** sets stop_signal to true */
void StopAcquisition(){ stop_signal = true; };
@ -140,6 +146,7 @@ void StopAcquisition(){ stop_signal = true; };
private:
/** Initializes all its members and the thread */
void Initialization();
@ -163,29 +170,53 @@ int UnlockLastImageArray() {return pthread_mutex_unlock(&last_image_complete
int StartDaqForGui() {return StartOrStopThread(1) ? 1:0;}
/** Stops the acquisition */
int StopDaqForGui() {return StartOrStopThread(0) ? 0:1;}
/** Starts/stops Acquisition Thread */
bool StartOrStopThread(bool start);
/** Sets up measurement each time */
void SetupMeasurement();
/** Sets up measurement each time
* @param currentIndex file index given by detector class
* */
void SetupMeasurement(int currentIndex);
/** Resets the acquisition parameter like lastimagenumber */
int ResetDaqForGui();
/** The function which is called when start acquisition thread is created */
static void* DataStartAcquireThread(void *this_pointer);
/** This is called by the detector class to copy the data it jus acquired */
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
/** This is called by static function when acquisition is finished
* @param currentProgress current progress of measurement
* @param detectorStatus current status of the detector
* */
int AcquisitionFinished(double currentProgress,int detectorStatus);
/** This is called by detector class when a measurement is finished
* @param currentMeasurementIndex current measurement index
* @param fileIndex current file index
* @param this_pointer is the pointer pointing to this object
* */
static int GetMeasurementFinishedCallBack(int currentMeasurementIndex, int fileIndex, void *this_pointer);
/** This is called by the static function when meausrement is finished
* @param currentMeasurementIndex current measurement index
* @param fileIndex current file index
* */
int MeasurementFinished(int currentMeasurementIndex, int fileIndex);
/** Saves all the plots. All sets saveError to true if not saved.*/
void SavePlotAutomatic();
/** Sets the style of the 1d plot */
@ -199,24 +230,32 @@ void SetStyle(SlsQtH1D* h){
private slots:
/** To update plot */
/** To update plot
* */
void UpdatePlot();
/** To stop updating plot */
/** To stop updating plot
* */
void StopUpdatePlot();
/** To start or stop acquisition
* @param start is 1 to start and 0 to stop acquisition */
* @param start is 1 to start and 0 to stop acquisition
* */
void StartDaq(bool start);
/** To set the reference to zero after closing a clone
* @param id is the id of the clone */
* @param id is the id of the clone
* */
void CloneCloseEvent(int id);
/**After a pause, the gui is allowed to collect the data
* this is called when it is over */
* this is called when it is over
* */
void UpdatePause(){data_pause_over=true;};
/** Shows the first save error message while automatic saving
* @param fileName file name of the first file that it tried to save.*/
* @param fileName file name of the first file that it tried to save.
* */
void ShowSaveErrorMessage(QString fileName);
/**Shows an error message when acquisition stopped unexpectedly*/
void ShowAcquisitionErrorMessage();
/**Shows an error message when acquisition stopped unexpectedly
* @param status is the status of the detector
* */
void ShowAcquisitionErrorMessage(QString status);
private:
@ -330,10 +369,6 @@ double* histXAngleAxis;
double* histYAngleAxis;
/** Current Image Values in 2D */
double* lastImageArray;
/** temporary Y Axis value in 1D */
double* yvalues[MAX_1DPLOTS];
/** temporary Image Values in 2D */
double* image_data;
/**persistency to be reached*/
int persistency;
@ -391,6 +426,13 @@ bool anglePlot;
/** prevents err msg displaying twice when detector stopped, "transmitting" */
bool alreadyDisplayed;
/**saves the file path and file name, not to access shared memory while running*/
QString filePath;
QString fileName;
/** Max Number of Clone Windows */
static const int TRIM_HISTOGRAM_XMAX = 600;
signals:
@ -402,7 +444,7 @@ void SetZRangeSignal(double,double);
void EnableZRangeSignal(bool);
void SetCurrentMeasurementSignal(int);
void saveErrorSignal(QString);
void AcquisitionErrorSignal();
void AcquisitionErrorSignal(QString);
};

View File

@ -13,6 +13,8 @@
/** Project Class Headers */
class multiSlsDetector;
#include "sls_detector_defs.h"
/** Qt Project Class Headers */
class qDrawPlot;
/** Qt Include Header */
#include <QStackedLayout>
@ -26,8 +28,9 @@ public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
* @param plot plot object reference
*/
qTabAdvanced(QWidget *parent,multiSlsDetector*& detector);
qTabAdvanced(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot);
/** Destructor
*/
@ -90,13 +93,17 @@ private slots:
*/
void StartTrimming();
/**Updates plot from shared memory
/** Updates the plot with trimbits from detector/shared memory
*/
void UpdatePlot();
void UpdateTrimbitPlot(int id);
private:
/** The sls detector object */
multiSlsDetector *myDet;
/** The Plot widget */
qDrawPlot *myPlot;
QButtonGroup *btnGroup;
/** Tool Tip for the output dir */
QString outputDirTip;

View File

@ -61,9 +61,8 @@ private:
private slots:
/** Sets the output directory
* @param path output path to be set
*/
void setOutputDir(const QString& path);
void setOutputDir();
/** Open dialog to choose the output directory */
void browseOutputDir();

View File

@ -38,9 +38,7 @@ public:
*/
~qTabPlot();
/** To refresh and update widgets
*/
void Refresh();
private:
@ -111,6 +109,11 @@ void EnableNthFrame(bool enable){enableNFrame = enable;};
*/
void SetScanArgument();
/** To refresh and update widgets
*/
void Refresh();
private slots:
/** Selects the plot to display, enables/disables widgets

View File

@ -37,6 +37,13 @@ public:
*/
void Refresh();
/** To enable expert mode
* @param enable to enable if true
*/
void SetExpertMode(bool enable){expertMode = enable;};
private:
/** The sls detector object */
@ -45,7 +52,8 @@ private:
/** detector type */
slsDetectorDefs::detectorType detType;
/** expert mode */
bool expertMode;
enum{Standard,Fast,HighGain,DynamicGain,LowGain,MediumGain,VeryHighGain,Undefined,Uninitialized,NumSettings};
@ -89,6 +97,11 @@ void SetDynamicRange(int index);
/** Set threshold energy
*/
void SetEnergy();
signals:
/**Update Trimbits after Set Settings */
void UpdateTrimbitSignal(int);
};

View File

@ -204,7 +204,7 @@ void qActionsWidget::Refresh(){
cout << "Updated\taction:" << id << "\t"
"mode:"<<mode<<"\t"
"script:" << script << "\t"
"parameter:" << parameter << endl << endl;
"parameter:" << parameter << "\t***" << endl;
#endif
}

View File

@ -103,7 +103,7 @@ void qDetectorMain::SetUpWidgetWindow(){
tab_plot = new qTabPlot (this, myDet,myPlot); cout<<"Plot ready"<<endl;
tab_actions = new qTabActions (this, myDet); cout<<"Actions ready"<<endl;
tab_settings = new qTabSettings (this, myDet); cout<<"Settings ready"<<endl;
tab_advanced = new qTabAdvanced (this, myDet); cout<<"Advanced ready"<<endl;
tab_advanced = new qTabAdvanced (this, myDet,myPlot); cout<<"Advanced ready"<<endl;
tab_debugging = new qTabDebugging (this, myDet); cout<<"Debugging ready"<<endl;
tab_developer = new qTabDeveloper (this, myDet); cout<<"Developer ready"<<endl;
// creating the scroll area widgets for the tabs
@ -229,8 +229,8 @@ 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(StartSignal()), tab_plot,SLOT(Refresh()));
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)));
// Data Output Tab
@ -239,10 +239,13 @@ void qDetectorMain::Initialization(){
connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool)));
// Actions tab (also for angles)
connect(tab_actions, SIGNAL(EnableScanBox()), tab_plot,SLOT(EnableScanBox()));
//settings to advanced tab(int=id is always 0 to only refresh)
connect(tab_settings, SIGNAL(UpdateTrimbitSignal(int)), tab_advanced,SLOT(UpdateTrimbitPlot(int)));
// Plotting
// When the acquisition is finished, must update the meas tab
connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs()));
connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_measurement, SLOT(UpdateFinished()));
connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_plot, SLOT(Refresh()));
connect(myPlot, SIGNAL(SetCurrentMeasurementSignal(int)), tab_measurement, SLOT(SetCurrentMeasurement(int)));
// menubar
// Modes Menu
@ -287,8 +290,10 @@ void qDetectorMain::EnableModes(QAction *action){
actionLoadCalibration->setVisible(enable);
actionSaveCalibration->setVisible(enable);
if(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN)
if(digitalDetector){
tab_measurement->SetExpertMode(enable);
tab_settings->SetExpertMode(enable);
}
#ifdef VERBOSE
@ -476,7 +481,14 @@ void qDetectorMain::Refresh(int index){
tabs->setCurrentIndex((index++)<(tabs->count()-1)?index:Measurement);
else{
switch(tabs->currentIndex()){
case Measurement: if(!myPlot->isRunning()) tab_measurement->Refresh(); break;
case Measurement:
if(!myPlot->isRunning()) {
tab_measurement->Refresh();
//to recover from a trimbit plot mode
tab_plot->Refresh();
}
break;
case Settings: tab_settings->Refresh(); break;
case DataOutput: tab_dataoutput->Refresh(); break;
case Plot: tab_plot->Refresh(); break;
@ -558,6 +570,17 @@ void qDetectorMain::EnableTabs(){
tabs->setTabEnabled(Settings,enable);
tabs->setTabEnabled(Messages,enable);
//actions check
actionOpenSetup->setEnabled(enable);
actionSaveSetup->setEnabled(enable);
actionOpenConfiguration->setEnabled(enable);
actionSaveConfiguration->setEnabled(enable);
actionMeasurementWizard->setEnabled(enable);
actionDebug->setEnabled(enable);
actionBeamline->setEnabled(enable);
actionExpert->setEnabled(enable);
// special tabs
if(enable==false){
tabs->setTabEnabled(Debugging,enable);
@ -589,6 +612,7 @@ void qDetectorMain::EnableTabs(){
if(isDeveloper)
tabs->setTabEnabled(Developer,enable);
}
}

View File

@ -8,6 +8,7 @@
#include "qDrawPlot.h"
#include "qCloneWidget.h"
#include "slsDetector.h"
#include"fileIOStatic.h"
// Project Class Headers
#include "slsDetector.h"
@ -76,7 +77,6 @@ void qDrawPlot::SetupWidgetWindow(){
minPixelsY = 0;
//2d
lastImageArray = 0;
image_data = 0;
//1d
nHists = 0;
histNBins = 0;
@ -103,7 +103,9 @@ void qDrawPlot::SetupWidgetWindow(){
alreadyDisplayed = false;
// 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; }
for(int i=0;i<MAX_1DPLOTS;i++)
histYAxis[i]=0;
// clone
for(int i=0;i<MAXCloneWindows;i++) winClone[i]=0;
@ -170,7 +172,9 @@ void qDrawPlot::SetupWidgetWindow(){
noMarker = new QwtSymbol();
//filepath and file name
filePath = QString(myDet->getFilePath().c_str());
fileName = QString(myDet->getFileName().c_str());
}
@ -186,7 +190,7 @@ void qDrawPlot::Initialization(){
connect(this, SIGNAL(SetZRangeSignal(double,double)), plot2D, SLOT(SetZRange(double,double)));
connect(this, SIGNAL(AcquisitionErrorSignal()), this, SLOT(ShowAcquisitionErrorMessage()));
connect(this, SIGNAL(AcquisitionErrorSignal(QString)), this, SLOT(ShowAcquisitionErrorMessage(QString)));
}
@ -205,8 +209,6 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
running=!running;
}else if(!stop_if_running){ //then start
//number of measurements
int numMeasurements = (int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1);
// Reset Current Measurement
currentMeasurement = 0;
emit SetCurrentMeasurementSignal(currentMeasurement);
@ -235,7 +237,7 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
if(anglePlot) number_of_exposures = numScan0 * numScan1;
cout << "\tNumber of Exposures:" << number_of_exposures << endl;
cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures << endl;
// ExposureTime
exposureTime= ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9);
@ -244,6 +246,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;
cout << "\tFile Index:" << myDet->getFileIndex() << endl;
//to take the first data if frameFactor
numFactor = 0;
@ -252,6 +256,10 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
lastSavedFrame = -1;
lastSavedMeasurement = -1;
//update file path and file name
filePath = QString(myDet->getFilePath().c_str());
fileName = QString(myDet->getFileName().c_str());
StartDaq(true);
running=!running;
@ -312,13 +320,15 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(start){
progress = 0;
//sets up the measurement parameters
SetupMeasurement();
SetupMeasurement(myDet->getFileIndex());
cout << "Starting new acquisition threadddd ...." << endl;
// 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);
//Setting the callback function to alert when each measurement finished from detector class
myDet->registerMeasurementFinishedCallback(&(GetMeasurementFinishedCallBack),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);
@ -337,31 +347,19 @@ bool qDrawPlot::StartOrStopThread(bool start){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SetupMeasurement(){
if(myDet->getRunStatus()==slsDetectorDefs::IDLE)
cout<<endl<<endl<<"IDLE"<<endl;
else cout<<endl<<endl<<"ERRORRRRRR: "<<myDet->getRunStatus()<<endl;
// Defaults
currentFrame = 0;
stop_signal = 0;
histTitle[0] = "";
void qDrawPlot::SetScanArgument(int scanArg){
#ifdef VERBOSE
cout << "SetScanArgument function" << endl;
#endif
scanArgument = scanArg;
//for 2d scans
int currentIndex = myDet->getFileIndex();
currentScanValue = 0;
currentScanDivLevel = 0;
LockLastImageArray();
nPixelsX = myDet->getTotalNumberOfChannels();
nPixelsY = 100;//if number of exposures, this should be checked before acquisition
if(scanArgument!=None){
if(scanArgument==AllFrames){
maxPixelsY = currentIndex + number_of_exposures - 1;
minPixelsY = currentIndex;
nPixelsY = number_of_exposures;
}else if(scanArgument==FileIndex){
maxPixelsY = currentIndex + number_of_frames - 1;
minPixelsY = currentIndex;
nPixelsY = number_of_frames;
}else if(scanArgument==Level0){
//cannot do this in between measurements , so update instantly
if(scanArgument==Level0){
//no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab
int numSteps = myDet->getScanSteps(0);
double *values = new double[numSteps];
@ -370,9 +368,7 @@ void qDrawPlot::SetupMeasurement(){
maxPixelsY = values[numSteps-1];
minPixelsY = values[0];
nPixelsY = numSteps;
currentScanValue = values[0];
}
else {
}else if(scanArgument==Level1) {
//no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab
int numSteps = myDet->getScanSteps(1);
double *values = new double[numSteps];
@ -381,25 +377,7 @@ void qDrawPlot::SetupMeasurement(){
maxPixelsY = values[numSteps-1];
minPixelsY = values[0];
nPixelsY = numSteps;
currentScanValue = values[0];
}
pixelWidth = (maxPixelsY -minPixelsY)/(nPixelsY-1);
startPixel = minPixelsY -(pixelWidth/2);
endPixel = maxPixelsY + (pixelWidth/2);
}else{//no scan
nPixelsY = 100;//number_of_exposures;
maxPixelsY = 100;
minPixelsY = 0;
startPixel = -0.5;
endPixel = nPixelsY-0.5;
}
cout<<"nPixelsY:"<<nPixelsY<<endl;
cout<<"minPixelsY:"<<minPixelsY<<endl;
cout<<"maxPixelsY:"<<maxPixelsY<<endl;
cout<<"startPixel:"<<startPixel<<endl;
cout<<"endPixel:"<<endPixel<<endl;
//1d
if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX];
@ -408,20 +386,87 @@ void qDrawPlot::SetupMeasurement(){
//2d
if(lastImageArray) delete [] lastImageArray; lastImageArray = new double[nPixelsY*nPixelsX];
//sorta useless
if(yvalues[0]) delete [] yvalues[0]; yvalues[0] = new double [nPixelsX];
if(image_data) delete [] image_data; image_data = new double[nPixelsY*nPixelsX];
//initializing 1d x axis
for(unsigned int px=0;px<nPixelsX;px++) histXAxis[px] = px;/*+10;*/
histYAxis[0][4] = 190.56;
for(unsigned int px=0;px<(int)nPixelsX;px++) histXAxis[px] = px;/*+10;*/
//initializing 2d array
for(int py=0;py<nPixelsY;py++)
for(int px=0;px<nPixelsX;px++)
for(int py=0;py<(int)nPixelsY;py++)
for(int px=0;px<(int)nPixelsX;px++)
lastImageArray[py*nPixelsX+px] = 0;
UnlockLastImageArray();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SetupMeasurement(int currentIndex){
#ifdef VERBOSE
cout << "SetupMeasurement function" << endl;
#endif
LockLastImageArray();
// Defaults
if(!running)
stop_signal = 0;
currentFrame = 0;
//for 2d scans
currentScanDivLevel = 0;
lastImageNumber = 0;
//initializing 2d array
for(int py=0;py<(int)nPixelsY;py++)
for(int px=0;px<(int)nPixelsX;px++)
lastImageArray[py*nPixelsX+px] = 0;
//no scan
if(scanArgument==None){
if(!running){
maxPixelsY = 100;
minPixelsY = 0;
startPixel = -0.5;
endPixel = nPixelsY-0.5;
}
}
else {//all frames
if(scanArgument==AllFrames){
maxPixelsY = currentIndex + number_of_exposures - 1;
minPixelsY = currentIndex;
if(!running) nPixelsY = number_of_exposures;
}//file index
else if(scanArgument==FileIndex){
maxPixelsY = currentIndex + number_of_frames - 1;
minPixelsY = currentIndex;
if(!running) nPixelsY = number_of_frames;
}//level0 or level1
else currentScanValue = minPixelsY;
//cannot divide by 0
if(nPixelsY==1){
pixelWidth = 0;
startPixel = minPixelsY-0.5;
endPixel = minPixelsY+0.5;
}else{
pixelWidth = (maxPixelsY -minPixelsY)/(nPixelsY-1);
startPixel = minPixelsY -(pixelWidth/2);
endPixel = maxPixelsY + (pixelWidth/2);
}
}
cout<<"\nnPixelsY:"<<nPixelsY<<endl;
cout<<"minPixelsY:"<<minPixelsY;
cout<<"\tmaxPixelsY:"<<maxPixelsY<<endl;
cout<<"startPixel:"<<startPixel;
cout<<"\tendPixel:"<<endPixel<<endl<<endl;
UnlockLastImageArray();
}
@ -452,15 +497,15 @@ int qDrawPlot::GetData(detectorData *data){
#ifdef VERYVERBOSE
cout << "Entering GetDatafunction" << endl;
#endif
cout<<"progress:"<<(int)data->progressIndex<<endl;
if(!stop_signal){
//set title
SetPlotTitle(QString(data->fileName).section('/',-1));
//set progress
progress=(int)data->progressIndex;
#ifdef VERBOSE
cout << "progress:" << progress << endl;
#endif
//Plot Disabled
if(!plotEnable) return 0;
@ -522,7 +567,7 @@ int qDrawPlot::GetData(detectorData *data){
lastImageNumber= currentFrame+1;
//title
char temp_title[2000];
sprintf(temp_title,"Image Index %d",myDet->getFileIndexFromFileName(string(data->fileName)));
sprintf(temp_title,"Image Index %d",fileIOStatic::getFileIndexFromFileName(string(data->fileName)));
imageTitle = temp_title;
//copy data
memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double));
@ -536,7 +581,7 @@ int qDrawPlot::GetData(detectorData *data){
if(scanArgument==FileIndex){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//variables
int currentIndex = myDet->getFileIndexFromFileName(string(data->fileName));
int currentIndex = fileIOStatic::getFileIndexFromFileName(string(data->fileName));
if(currentIndex == minPixelsY) currentScanDivLevel = 0;
lastImageNumber= currentFrame+1;
//title
@ -556,8 +601,10 @@ int qDrawPlot::GetData(detectorData *data){
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);
fileIOStatic::getVariablesFromFileName(string(data->fileName), currentIndex, p, cs0, cs1);
int currentScanVariable0 = (int)cs0;
cout<<"currentScanValue:"<<currentScanValue<<endl;
cout<<"currentScanVariable0:"<<currentScanVariable0<<endl;
//variables
if(currentScanVariable0!=currentScanValue) currentScanDivLevel++;
currentScanValue = currentScanVariable0;
@ -577,7 +624,7 @@ int qDrawPlot::GetData(detectorData *data){
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);
fileIOStatic::getVariablesFromFileName(string(data->fileName), currentIndex, p, cs0, cs1);
int currentScanVariable1 = (int)cs1;
//variables
if(currentScanVariable1!=currentScanValue) currentScanDivLevel++;
@ -618,14 +665,13 @@ int qDrawPlot::GetData(detectorData *data){
//2d
else{
// Titles
sprintf(temp_title,"Image Index %d",myDet->getFileIndexFromFileName(string(data->fileName)));
sprintf(temp_title,"Image Index %d",fileIOStatic::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);
lastImageArray[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));
@ -653,38 +699,30 @@ int qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,int detecto
int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){
QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str());
#ifdef VERBOSE
cout << "Entering Acquisition Finished with status " <<
slsDetectorBase::runStatusType((slsDetectorDefs::runStatus(detectorStatus))) << " and progress " << currentProgress << endl;
cout << "\nEntering Acquisition Finished with status " << status.toAscii().constData() << " and progress " << currentProgress << endl;
#endif
//error or stopped
if((stop_signal)||(detectorStatus==slsDetectorDefs::ERROR)){
#ifdef VERBOSE
cout << "Error in Acquisition" << endl;
cout << "Error in Acquisition" << endl << endl;
#endif
//just to be sure
stop_signal = 1;
StartStopDaqToggle(true);
emit AcquisitionErrorSignal();
//stop_signal = 1;//just to be sure
emit AcquisitionErrorSignal(status);
}
else{
//all measurements are over
if(currentProgress==100){
else if(currentProgress==100){
#ifdef VERBOSE
cout << "Acquisition Finished" << endl;
cout << "Acquisition Finished" << endl << endl;
#endif
}
StartStopDaqToggle(true);
//this lets the measurement tab know its over, and to enable tabs
emit UpdatingPlotFinished();
}
else{//next measurement
currentMeasurement++;
#ifdef VERBOSE
cout << "currentMeasurement:" << currentMeasurement << endl;
#endif
emit SetCurrentMeasurementSignal(currentMeasurement);
SetupMeasurement();
}
}
return 0;
}
@ -692,12 +730,12 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::ShowAcquisitionErrorMessage(){
void qDrawPlot::ShowAcquisitionErrorMessage(QString status){
if(!alreadyDisplayed){
alreadyDisplayed = true;
int detStatus = (int)myDet->getRunStatus();
string status = slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detStatus));
qDefs::Message(qDefs::WARNING,string("<nobr>The acquisiton has ended abruptly. Current Detector Status: ")+status+string(".</nobr>"),"Dock");
qDefs::Message(qDefs::WARNING,string("<nobr>The acquisiton has ended abruptly. "
"Current Detector Status: ")+status.toAscii().constData()+
string(".</nobr>"),"Dock");
}
}
@ -705,8 +743,38 @@ void qDrawPlot::ShowAcquisitionErrorMessage(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::GetMeasurementFinishedCallBack(int currentMeasurementIndex, int fileIndex, void *this_pointer){
((qDrawPlot*)this_pointer)->MeasurementFinished(currentMeasurementIndex, fileIndex);
return 0;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){
#ifdef VERBOSE
cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << endl;
#endif
//to make sure it plots the last frame before setting lastimagearray all to 0
if(plot_in_scope==2) usleep(500000);
currentMeasurement = currentMeasurementIndex + 1;
#ifdef VERBOSE
cout << "currentMeasurement:" << currentMeasurement << endl;
#endif
emit SetCurrentMeasurementSignal(currentMeasurement);
SetupMeasurement(fileIndex);
return 0;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
if(i==1){
Clear1DPlot();
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
plot1D->show();
@ -724,13 +792,16 @@ void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::Clear1DPlot(){
for(QVector<SlsQtH1D*>::iterator h = plot1D_hists.begin();
h!=plot1D_hists.end();h++) (*h)->Detach(plot1D); //clear plot
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -813,6 +884,7 @@ void qDrawPlot::UpdatePlot(){
if(plotEnable) UnlockLastImageArray();
//if acqq stopped before this line, it continues from here, shouldnt restart plotting timer
if(!stop_signal){
if(!frameFactor)
@ -823,8 +895,10 @@ void qDrawPlot::UpdatePlot(){
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::StopUpdatePlot(){
#ifdef VERYVERBOSE
cout << "Entering StopUpdatePlot()" << endl;
@ -832,8 +906,10 @@ void qDrawPlot::StopUpdatePlot(){
plot_update_timer->stop();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::ClonePlot(){
int i=0;
bool found = false;
@ -850,8 +926,16 @@ void qDrawPlot::ClonePlot(){
// save height to keep maintain same height of plot
int preheight = height();
string sFilePath;
if(running) sFilePath = filePath.toAscii().constData();
else sFilePath = myDet->getFilePath();
LockLastImageArray();
// create clone
winClone[i] = new qCloneWidget(this,i,boxPlot->title(),(int)plot_in_scope,plot1D,plot2D,myDet->getFilePath());
winClone[i] = new qCloneWidget(this,i,boxPlot->title(),(int)plot_in_scope,plot1D,plot2D,sFilePath);
if(plot_in_scope==1){
plot1D = new SlsQt1DPlot(boxPlot);
plot1D->setFont(QFont("Sans Serif",9,QFont::Normal));
@ -885,6 +969,10 @@ void qDrawPlot::ClonePlot(){
plot2D->SetZTitle(imageZAxisTitle);
plotLayout->addWidget(plot2D,1,1,1,1);
}
UnlockLastImageArray();
setMinimumHeight(preheight);
resize(width(),preheight);
@ -899,8 +987,10 @@ void qDrawPlot::ClonePlot(){
connect(winClone[i], SIGNAL(CloneClosedSignal(int)),this, SLOT(CloneCloseEvent(int)));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SaveClones(){
char errID[200];
string errMessage= "The Snapshots with ID's: ";
@ -922,6 +1012,7 @@ void qDrawPlot::SaveClones(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::CloseClones(){
for(int i=0;i<MAXCloneWindows;i++)
if(winClone[i])
@ -929,8 +1020,10 @@ void qDrawPlot::CloseClones(){
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::CloneCloseEvent(int id){
winClone[id]=0;
#ifdef VERBOSE
@ -938,15 +1031,20 @@ void qDrawPlot::CloneCloseEvent(int id){
#endif
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SavePlot(){
// render image
QImage savedImage(size().width(),size().height(),QImage::Format_RGB32);
QPainter painter(&savedImage);
render(&painter);
QString fName = QString(myDet->getFilePath().c_str());
QString fName;
if(running) fName = filePath;
else fName = QString(myDet->getFilePath().c_str());
if(boxPlot->title().contains('.')){
fName.append(QString('/')+boxPlot->title());
fName.replace(".dat",".png");
@ -965,6 +1063,7 @@ void qDrawPlot::SavePlot(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
/*
void qDrawPlot::SaveAll(bool enable){
string msg = string("The Files will be saved as:\n")+
@ -973,19 +1072,27 @@ void qDrawPlot::SaveAll(bool enable){
qDefs::Message(qDefs::INFORMATION,msg,"Dock");
saveAll = enable;
}
*/
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SavePlotAutomatic(){
//no need to save the same plot many times
if((currentFrame>lastSavedFrame)&&(currentMeasurement>=lastSavedMeasurement)){
QString qFilePath;
if(running) qFilePath = filePath;
else qFilePath = QString(myDet->getFilePath().c_str());
lastSavedFrame = currentFrame;
lastSavedMeasurement = currentMeasurement;
char cID[10];
sprintf(cID,"%d",lastSavedFrame);
//title
QString fName = QString(myDet->getFilePath().c_str());
QString fName = qFilePath;
if(boxPlot->title().contains('.')){
fName.append(QString('/')+boxPlot->title());
fName.replace(".dat",".png");
@ -1007,6 +1114,7 @@ void qDrawPlot::SavePlotAutomatic(){
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -1021,15 +1129,15 @@ void qDrawPlot::ShowSaveErrorMessage(QString fileName){
void qDrawPlot::SetPersistency(int val){
for(int i=0;i<=val;i++){
if(!yvalues[i]) yvalues[i] = new double [nPixelsX];
for(int i=0;i<=val;i++)
if(!histYAxis[i]) histYAxis[i] = new double [nPixelsX];
}
persistency = val;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::EnablePlot(bool enable){
#ifdef VERBOSE
cout << "Plotting set to:" << enable << endl;
@ -1041,8 +1149,10 @@ void qDrawPlot::EnablePlot(bool enable){
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::DisableZoom(bool disable){
if(plot_in_scope==1)
plot1D->DisableZoom(disable);
@ -1050,4 +1160,133 @@ void qDrawPlot::DisableZoom(bool disable){
plot2D->GetPlot()->DisableZoom(disable);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
int ret,i,actualPixelsX;
double *temp;
#ifdef VERBOSE
if(fromDetector) cout << "Geting Trimbits from Detector: ";
else cout << "Getting Trimbits from Shared Memory: ";
if(Histogram) cout << "Histogram" << endl;
else cout << "Data Graph" << endl;
#endif
switch(myDet->getDetectorsType()){
case slsDetectorDefs::MYTHEN:
//get trimbits
actualPixelsX = myDet->getTotalNumberOfChannels();
temp = new double[actualPixelsX];
ret = myDet->getChanRegs(temp,fromDetector);
if(!ret){
qDefs::Message(qDefs::WARNING,"No Trimbit data found in shared memory.","Dock");
return qDefs::FAIL;
}
//defining axes
if(Histogram) nPixelsX = TRIM_HISTOGRAM_XMAX;
else nPixelsX = actualPixelsX;
if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX];
if(histYAxis[0]) delete [] histYAxis[0];histYAxis[0] = new double [nPixelsX];
//initializing
for(unsigned int px=0;px<nPixelsX;px++) histXAxis[px] = px;
for(int i=0;i<nPixelsX;i++) histYAxis[0][i] = 0;
//clear/select plot and set titles
Clear1DPlot();
Select1DPlot();
if(!Histogram){
//data
memcpy(histYAxis[0],temp,nPixelsX*sizeof(double));
//title
SetPlotTitle("Trimbits Plot - Data Graph");
plot1D->SetXTitle("Channel Number");
plot1D->SetYTitle("Trimbits");
//set plot parameters
SlsQtH1D* h;
plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,GetHistYAxis(0)));
h->SetLineColor(1);
h->setTitle(GetHistTitle(0));
//attach plot
h->Attach(plot1D);
}else{
//data
for(i=0;i<actualPixelsX;i++){
if((temp[i]<=TRIM_HISTOGRAM_XMAX))/**shouldnt be the case*/
histYAxis[0][(int)temp[i]]+=1;
//else cout<<"OUT OF BOUNDS:"<<i<<"-"<<temp[i]<<endl;
}
/* for(i=0;i<TRIM_HISTOGRAM_XMAX;i++)
if((histYAxis[0][i]<=TRIM_HISTOGRAM_XMAX)&&(histYAxis[0][i]>0))
cout<<"HIsty["<<i<<"]:"<<histYAxis[0][i]<<endl;*/
//title
SetPlotTitle("Trimbits Plot - Histogram");
plot1D->SetXTitle("Trimbits");
plot1D->SetYTitle("Frequency");
//set plot parameters
SlsQtH1D* h;
plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,GetHistYAxis(0)));
h->SetLineColor(1);
h->setTitle(GetHistTitle(0));
//attach plot
h->Attach(plot1D);
}
#ifdef VERBOSE
cout << "Trimbits Plot updated" << endl;
#endif
break;
//2d
case slsDetectorDefs::EIGER:
//defining axes
nPixelsX = 100;/**??*/
nPixelsY = 100;
if(lastImageArray) delete [] lastImageArray; lastImageArray = new double[nPixelsY*nPixelsX];
//initializing 2d array
for(int py=0;py<(int)nPixelsY;py++)
for(int px=0;px<(int)nPixelsX;px++)
lastImageArray[py*nPixelsX+px] = 0;
//get trimbits
ret = 1;/*myDet->getChanRegs(lastImageArray,fromDetector);*/
if(!ret){
qDefs::Message(qDefs::WARNING,"No Trimbit data found in shared memory.","Dock");
return qDefs::FAIL;
}
//clear/select plot and set titles
Select2DPlot();
plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray);
plot2D->setTitle("Image");
plot2D->SetXTitle("Pixel");
plot2D->SetYTitle("Pixel");
plot2D->SetZTitle("Trimbits");
plot2D->UpdateNKeepSetRangeIfSet();
#ifdef VERBOSE
cout << "Trimbits Plot updated" << endl;
#endif
break;
//shouldnt be here
default:
break;
}
return qDefs::OK;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -1028,7 +1028,7 @@ void qScanWidget::Refresh(){
"numSteps:" << actualNumSteps << "\t"
//"values:" << arrSteps << "\t"
"parameter:" << parameter << "\t"
"precision:" << precision << endl << endl;
"precision:" << precision << "\t***" << endl;
#endif
}

View File

@ -354,19 +354,24 @@ void qTabActions::DeletePosition(){
void qTabActions::EnablePositions(bool enable){
#ifdef VERBOSE
cout << "\nEnable Positions: " << enable << endl;
cout << "Enable Positions: " << enable << endl;
#endif
if(enable){
lblName[NumPositions]->setEnabled(true);
btnExpand[NumPositions]->setEnabled(true);
}else{
//to collapse if it was expanded
if(btnExpand[NumPositions]->text()=="-")
Expand(group->button(NumPositions));
//deletes all positions
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());
//to collapse if it was expanded
if(btnExpand[NumPositions]->isChecked()){
disconnect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
btnExpand[NumPositions]->setChecked(false);
connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
Expand(group->button(NumPositions));
}
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}
@ -378,7 +383,7 @@ void qTabActions::EnablePositions(bool enable){
void qTabActions::Refresh(){
#ifdef VERBOSE
cout << "\nUpdating all action widgets " << endl;
cout << "\nUpdating all action widgets: " << endl;
#endif
if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::GOTTHARD)){
//positions is enabled only if angular conversion is enabled
@ -415,7 +420,7 @@ void qTabActions::Refresh(){
#ifdef VERBOSE
cout << "Updated position widget\tnum:" << numPos << endl << endl;
cout << "Updated position widget\tnum:" << numPos << "\t***" << endl;
#endif
}
}
@ -423,7 +428,7 @@ void qTabActions::Refresh(){
scanWidget[i]->Refresh();
for(int i=0;i<qActionsWidget::NUM_ACTION_WIDGETS;i++)
actionWidget[i]->Refresh();
cout << endl;
UpdateCollapseColors();
}

View File

@ -6,6 +6,7 @@
*/
#include "qTabAdvanced.h"
#include "qDefs.h"
#include "qDrawPlot.h"
/** Project Class Headers */
#include "slsDetector.h"
#include "multiSlsDetector.h"
@ -19,7 +20,8 @@ using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabAdvanced::qTabAdvanced(QWidget *parent,multiSlsDetector*& detector):QWidget(parent),myDet(detector){
qTabAdvanced::qTabAdvanced(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot):
QWidget(parent),myDet(detector),myPlot(plot),btnGroup(NULL){
setupUi(this);
SetupWidgetWindow();
Initialization();
@ -52,7 +54,12 @@ void qTabAdvanced::SetupWidgetWindow(){
boxTrimming->setChecked(false);
SetOptimize(false);
btnGroup = new QButtonGroup(this);
btnGroup->addButton(btnRefresh,0);
btnGroup->addButton(btnGetTrimbits,1);
}
}
@ -88,7 +95,8 @@ void qTabAdvanced::Initialization(){
connect(btnStart, SIGNAL(clicked()), this, SLOT(StartTrimming()));
//refresh
connect(btnRefresh, SIGNAL(clicked()), this, SLOT(UpdatePlot()));
connect(btnGroup, SIGNAL(buttonClicked(int)), this, SLOT(UpdateTrimbitPlot(int)));
}
@ -331,7 +339,7 @@ void qTabAdvanced::StartTrimming(){
qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","Advanced");
else qDefs::Message(qDefs::WARNING,string("Could not Save the Trimbits to file:\n")+dispFile->text().toAscii().constData(),"Advanced");
//updates plots
UpdatePlot();
myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked());
}
else
qDefs::Message(qDefs::WARNING,"Atleast 1 channel could not be trimmed.","Advanced");
@ -341,36 +349,17 @@ void qTabAdvanced::StartTrimming(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabAdvanced::UpdatePlot(){
#ifdef VERBOSE
cout << "Updating Plot" << endl;
#endif
int nPixelsX = myDet->getTotalNumberOfChannels();
int *histXAxis = new int[nPixelsX];
int *histYAxis = new int[100];
for(int i=0;i<nPixelsX;i++) histXAxis[i] = i;
int channelsPerDetector;
/*
for(int det=0;det<myDet->getNumberOfDetectors();det++){
slsDetector *s = myDet->getSlsDetector(det);
channelsPerDetector=s->getTotalNumberOfChannels();
if(s->chanregs){
for(int i=0;i<channelsPerDetector;i++){
memcpy(histYAxis + (det*channelsPerDetector*sizeof(int)),s->chanregs,channelsPerDetector*sizeof(int));
}
}
}
*/
cout<<"histyaxis[500]:"<<histYAxis[500]<<endl;
void qTabAdvanced::UpdateTrimbitPlot(int id){
//refresh
if(!id) myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked());
//from detector
else myPlot->UpdateTrimbitPlot(true,radioHistogram->isChecked());
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabAdvanced::Refresh(){
//disconnect
disconnect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs()));

View File

@ -46,7 +46,7 @@ qTabDataOutput::~qTabDataOutput(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDataOutput::SetupWidgetWindow(){cout<<"in here"<<endl;
void qTabDataOutput::SetupWidgetWindow(){
// Detector Type
detType=myDet->getDetectorsType();
@ -74,7 +74,7 @@ void qTabDataOutput::SetupWidgetWindow(){cout<<"in here"<<endl;
void qTabDataOutput::Initialization(){
//output dir
connect(dispOutputDir, SIGNAL(textChanged(const QString&)), this, SLOT(setOutputDir(const QString&)));
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(setOutputDir()));
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(browseOutputDir()));
//flat field correction
connect(chkFlatField, SIGNAL(toggled(bool)), this, SLOT(SetFlatField()));
@ -93,11 +93,20 @@ void qTabDataOutput::Initialization(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDataOutput::setOutputDir(const QString& path){
void qTabDataOutput::setOutputDir(){
QString path = dispOutputDir->text();
//gets rid of the end '/'s
disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(setOutputDir()));
while(path.endsWith('/')) path.chop(1);
dispOutputDir->setText(path);
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(setOutputDir()));
myDet->setFilePath(string(path.toAscii().constData()));
#ifdef VERBOSE
cout << "Output Directory changed to :"<<myDet->getFilePath() << endl;
#endif
}

View File

@ -306,6 +306,7 @@ void qTabMeasurement::startStopAcquisition(){
progressTimer->start(100);
emit StartSignal();
myPlot->StartStopDaqToggle();
}else{
#ifdef VERBOSE
@ -326,6 +327,7 @@ void qTabMeasurement::startStopAcquisition(){
void qTabMeasurement::UpdateFinished(){
if(btnStartStop->isChecked()){
disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
btnStartStop->setText("Start");
btnStartStop->setIcon(*iconStart);
@ -335,6 +337,7 @@ void qTabMeasurement::UpdateFinished(){
UpdateProgress();
progressTimer->stop();
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -723,12 +726,13 @@ void qTabMeasurement::EnableFileWrite(bool enable){
void qTabMeasurement::Refresh(){
if(!myPlot->isRunning()){
//Number of measurements
spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1));
//File Name
dispFileName->setText(QString(myDet->getFileName().c_str()));
//File Index
spinIndex->setValue(myDet->getFileIndex());
spinIndex->setValue(myDet->getFileIndex());cout<<"file index:"<<myDet->getFileIndex()<<endl;
//progress label index
lblProgressIndex->setText(QString::number(myDet->getFileIndex()));
//Timing mode*
@ -737,6 +741,7 @@ void qTabMeasurement::Refresh(){
// to let qdrawplot know that triggers or frames are used
myPlot->setFrameEnabled(lblNumFrames->isEnabled());
myPlot->setTriggerEnabled(lblNumTriggers->isEnabled());
}
}

View File

@ -504,7 +504,7 @@ void qTabPlot::EnableScanBox(){
int mode1 = myDet->getScanMode(1);
//if it was checked before or disabled before, it remembers to check it again
bool checkedBefore = (boxScan->isChecked()||(!boxScan->isEnabled()));
bool checkedBefore = boxScan->isChecked();//||(!boxScan->isEnabled()));
//none of these scan plotting options make sense if positions>0
@ -548,7 +548,8 @@ void qTabPlot::EnableScanBox(){
//positions
if((positionsExist)&&(chkSuperimpose->isChecked())) chkSuperimpose->setChecked(false);
chkSuperimpose->setEnabled(!positionsExist);
boxFrequency->setEnabled(!positionsExist);
//box frequency should be enabled cuz its a normal 1d plot
boxFrequency->setEnabled(positionsExist);
myPlot->EnableAnglePlot(positionsExist);
@ -673,8 +674,14 @@ void qTabPlot::SetScanArgument(){
void qTabPlot::Refresh(){
if(!myPlot->isRunning()){
connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
SetFrequency();
if(!myPlot->isRunning()) EnableScanBox();
EnableScanBox();
}else{
disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
boxScan->setEnabled(false);
}
}

View File

@ -18,7 +18,7 @@ using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabSettings::qTabSettings(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector){
QWidget(parent),myDet(detector),expertMode(false){
setupUi(this);
SetupWidgetWindow();
@ -170,7 +170,7 @@ void qTabSettings::setSettings(int index){
if((detType==slsDetectorDefs::GOTTHARD)||(detType==slsDetectorDefs::AGIPD)){
lblThreshold->setEnabled(false);
spinThreshold->setEnabled(false);
}else{
}else{//mythen or eiger
if((index==Undefined)||(index==Uninitialized)){
lblThreshold->setEnabled(false);
@ -179,8 +179,12 @@ void qTabSettings::setSettings(int index){
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
SetEnergy();
//also update trimbits plot
if(expertMode) emit UpdateTrimbitSignal(0);
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -234,10 +238,10 @@ void qTabSettings::SetDynamicRange(int index){
void qTabSettings::SetEnergy(){
int index = spinThreshold->value();
#ifdef VERBOSE
cout << "Settings threshold energy to "<< index << endl;
#endif
int index = spinThreshold->value();
myDet->setThresholdEnergy(index);
int ret = (int)myDet->getThresholdEnergy();
if((ret-index)>200){
@ -256,7 +260,11 @@ void qTabSettings::SetEnergy(){
void qTabSettings::Refresh(){
// Settings
SetupDetectorSettings();
//changin the combo settings also plots the trimbits for mythen and eiger, so disconnect
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
comboSettings->setCurrentIndex(myDet->getSettings());
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
// Number of Modules
spinNumModules->setValue(myDet->setNumberOfModules());