snapshot works,id works, conversion from seconds to ms,us etc works, number of measurements works

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@14 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-06-26 15:06:55 +00:00
parent b3de7a9051
commit 824da9d4c4
20 changed files with 320 additions and 256 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

View File

@ -0,0 +1,5 @@
<RCC version="1.0">
<qresource prefix="/icons">
<file>../images/mountain.png</file>
</qresource>
</RCC>

View File

@ -13,7 +13,10 @@ class SlsQtH1D;
class SlsQt1DPlot; class SlsQt1DPlot;
class SlsQt2DPlotLayout; class SlsQt2DPlotLayout;
/** Qt Include Headers */ /** Qt Include Headers */
#include <QFrame> #include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QGridLayout> #include <QGridLayout>
#include <QCloseEvent> #include <QCloseEvent>
#include <QGroupBox> #include <QGroupBox>
@ -31,7 +34,7 @@ using namespace std;
/** /**
*@short Sets up the clone plot widget *@short Sets up the clone plot widget
*/ */
class qCloneWidget:public QFrame{ class qCloneWidget:public QMainWindow{
Q_OBJECT Q_OBJECT
public: public:
@ -77,6 +80,10 @@ private:
QVector<SlsQtH1D*> cloneplot1D_hists; QVector<SlsQtH1D*> cloneplot1D_hists;
QMenuBar *menubar;
// QMenu *menuFile;
QAction *actionSave;
QGridLayout *mainLayout; QGridLayout *mainLayout;
QGroupBox *cloneBox; QGroupBox *cloneBox;
QGridLayout *gridClone; QGridLayout *gridClone;
@ -90,6 +97,8 @@ private:
QCheckBox *chkAutoFName; QCheckBox *chkAutoFName;
QCheckBox *chkSaveAll; QCheckBox *chkSaveAll;
/** Gets the current time stamp for the window title*/
char* GetCurrentTimeStamp();
private slots: private slots:

View File

@ -54,6 +54,40 @@ public:
return valueNS; return valueNS;
}; };
//-------------------------------------------------------------------------------------------------------------------------------------------------
/** returns the time in the appropriate time unit
* @param unit unit of time
* @param value time in seconds
* returns the corresponding time value
*/
static float getCorrectTime(timeUnit& unit, float value){
int intUnit = (int)SECONDS;
/** hr, min, sec */
if(value>=1){
float newVal = value;
while((newVal>=1)&&(intUnit>=(int)HOURS)){
/** value retains the old value */
value = newVal;
newVal = value/60;
intUnit--;
}
/** returning the previous value*/
unit = (timeUnit)(intUnit+1);
return value;
}
/** ms, us, ns */
else{
while((value<1)&&(intUnit<(int)NANOSECONDS)){
value = value*1000;
intUnit++;
}
unit = (timeUnit)(intUnit);
return value;
}
};
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
/**displays an error message /**displays an error message

View File

@ -62,6 +62,8 @@ private:
QApplication *theApp; QApplication *theApp;
/** The sls detector object */ /** The sls detector object */
slsDetectorUtils *myDet; slsDetectorUtils *myDet;
/** sls detector id */
int detID;
/** The Plot widget */ /** The Plot widget */
qDrawPlot *myPlot; qDrawPlot *myPlot;
/**Tab Widget */ /**Tab Widget */
@ -74,6 +76,7 @@ private:
int heightCentralWidget; int heightCentralWidget;
/** The default zooming tool tip */ /** The default zooming tool tip */
QString zoomToolTip; QString zoomToolTip;
/** The default tab heading color */ /** The default tab heading color */
QColor defaultTabColor; QColor defaultTabColor;
/** enumeration of the tabs */ /** enumeration of the tabs */
@ -97,6 +100,7 @@ private:
/**Developer tab */ /**Developer tab */
qTabDeveloper *tab_developer; qTabDeveloper *tab_developer;
/**if the developer tab should be enabled,known from command line */ /**if the developer tab should be enabled,known from command line */
int isDeveloper; int isDeveloper;
/**Sets up the layout of the widget /**Sets up the layout of the widget
*/ */

View File

@ -108,22 +108,24 @@ private:
/** Number of Measurements */ /** Number of Measurements */
static int numberOfMeasurements; int number_of_measurements;
/** Current Measurement */
int currentMeasurement;
/** currentFrame */ /** currentFrame */
static int currentFrame; int currentFrame;
/** Number of Exposures */ /** Number of Exposures */
static int number_of_exposures; int number_of_exposures;
/** Duration between Exposures */ /** Duration between Exposures */
double framePeriod; double acquisitionPeriod;
/** Acquisition Time */ /** Acquisition Time */
double acquisitionTime; double exposureTime;
/**variables for threads */ /**variables for threads */
/** */ /** */
volatile bool stop_signal; volatile bool stop_signal;
/** */ /** */
static pthread_mutex_t last_image_complete_mutex; pthread_mutex_t last_image_complete_mutex;
/**variables for histograms */ /**variables for histograms */
/** X Axis Title in 2D */ /** X Axis Title in 2D */
@ -137,37 +139,38 @@ private:
/** Y Axis Title in 1D */ /** Y Axis Title in 1D */
QString histYAxisTitle; QString histYAxisTitle;
/** Title for all the graphs in 1D */ /** Title for all the graphs in 1D */
static std::string histTitle[MAX_1DPLOTS]; std::string histTitle[MAX_1DPLOTS];
/** Title in 2D */ /** Title in 2D */
static std::string imageTitle; std::string imageTitle;
/** 1D or 2D */ /** 1D or 2D */
static unsigned int plot_in_scope; unsigned int plot_in_scope;
/** Number of Pixels in X Axis */ /** Number of Pixels in X Axis */
static unsigned int nPixelsX; unsigned int nPixelsX;
/** Number of Pixels in Y Axis */ /** Number of Pixels in Y Axis */
static unsigned int nPixelsY; unsigned int nPixelsY;
/** Current Image Number */ /** Current Image Number */
static unsigned int lastImageNumber; unsigned int lastImageNumber;
int last_plot_number;
/** Number of graphs in 1D */ /** Number of graphs in 1D */
static unsigned int nHists; unsigned int nHists;
/** Total Number of X axis values/channels in 1D */ /** Total Number of X axis values/channels in 1D */
static int histNBins; int histNBins;
/** X Axis value in 1D */ /** X Axis value in 1D */
static double* histXAxis; double* histXAxis;
/** Y Axis value in 1D */ /** Y Axis value in 1D */
static double* histYAxis[MAX_1DPLOTS]; double* histYAxis[MAX_1DPLOTS];
/** Current Image Values in 2D */ /** Current Image Values in 2D */
static double* lastImageArray; double* lastImageArray;
/** temporary Y Axis value in 1D */ /** temporary Y Axis value in 1D */
static double* yvalues[MAX_1DPLOTS]; double* yvalues[MAX_1DPLOTS];
/** temporary Image Values in 2D */ /** temporary Image Values in 2D */
static double* image_data; double* image_data;
static bool gui_acquisition_thread_running; //bool gui_acquisition_thread_running;
static int persistency; int persistency;
static int currentPersistency; int currentPersistency;
static int progress; int progress;
static bool plotEnable; bool plotEnable;
/** Initializes all its members and the thread */ /** Initializes all its members and the thread */
void Initialization(); void Initialization();
@ -197,8 +200,10 @@ private:
int ResetDaqForGui(); int ResetDaqForGui();
/** The function which is called when start acquisition thread is created */ /** The function which is called when start acquisition thread is created */
static void* DataStartAcquireThread(void *this_pointer); static void* DataStartAcquireThread(void *this_pointer);
/** This is called by the detector class to copt the data it jus acquired */ /** This is called by the detector class to copy the data it jus acquired */
static int GetDataCallBack(detectorData *data); static int GetDataCallBack(detectorData *data, void *this_pointer);
/** This is called by the GetDataCallBack function to copy the data */
int GetData(detectorData *data);
public slots: public slots:

View File

@ -23,8 +23,9 @@ public:
/** \short The constructor /** \short The constructor
* @param parent is the parent tab widget * @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab * @param detector is the detector returned from the detector tab
* @param detID is the id of the detector
*/ */
qTabSettings(QWidget *parent,slsDetectorUtils*& detector); qTabSettings(QWidget *parent,slsDetectorUtils*& detector,int detID);
/** Destructor /** Destructor
*/ */
@ -35,6 +36,10 @@ private:
/** The sls detector object */ /** The sls detector object */
slsDetectorUtils *myDet; slsDetectorUtils *myDet;
/** sls detector id */
int detID;
/** Sets up the widget /** Sets up the widget
*/ */
void SetupWidgetWindow(); void SetupWidgetWindow();
@ -43,9 +48,6 @@ private:
*/ */
void Initialization(); void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
private slots: private slots:

View File

@ -3,6 +3,9 @@ MOC_DIR = mocs
OBJECTS_DIR = objs OBJECTS_DIR = objs
UI_HEADERS_DIR = forms/include UI_HEADERS_DIR = forms/include
RESOURCES += icons.qrc
DEFINES += VERBOSE DEFINES += VERBOSE

View File

@ -24,7 +24,6 @@
using namespace std; using namespace std;
#define Detector_Index 0
ActionsWidget::ActionsWidget(QWidget *parent, int scanType): QFrame(parent){ ActionsWidget::ActionsWidget(QWidget *parent, int scanType): QFrame(parent){

View File

@ -7,30 +7,33 @@
/** Qt Project Class Headers */ /** Qt Project Class Headers */
#include "qCloneWidget.h" #include "qCloneWidget.h"
#include "qDefs.h"
#include "SlsQt1DPlot.h" #include "SlsQt1DPlot.h"
#include "SlsQt2DPlotLayout.h" #include "SlsQt2DPlotLayout.h"
/** Qt Include Headers */ /** Qt Include Headers */
#include <QImage> #include <QImage>
#include <QPainter> #include <QPainter>
#include <QFileDialog>
/** C++ Include Headers */ /** C++ Include Headers */
#include <iostream> #include <iostream>
using namespace std; using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath):
QMainWindow(parent),id(id),filePath(FilePath){
qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath):QFrame(parent,Qt::Popup|Qt::SubWindow),id(id),filePath(FilePath){
/** Window title*/ /** Window title*/
char winTitle[100]; char winTitle[300],currTime[50];
sprintf(winTitle,"SLS Detector GUI Clone %d",id); strcpy(currTime,GetCurrentTimeStamp());
sprintf(winTitle,"Snapshot:%d - %s",id,currTime);
setWindowTitle(QString(winTitle)); setWindowTitle(QString(winTitle));
/** Set up widget*/ /** Set up widget*/
SetupWidgetWindow(title,numDim,plot1D,plot2D); SetupWidgetWindow(title,numDim,plot1D,plot2D);
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
qCloneWidget::~qCloneWidget(){ qCloneWidget::~qCloneWidget(){
delete cloneplot1D; delete cloneplot1D;
@ -39,13 +42,22 @@ qCloneWidget::~qCloneWidget(){
delete boxSave; delete boxSave;
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D){ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D){
menubar = new QMenuBar(this);
//menuFile = new QMenu("&File",menubar);
actionSave = new QAction("&Save",this);
// menubar->addAction(menuFile->menuAction());
menubar->addAction(actionSave);
setMenuBar(menubar);
/** Main Window Layout */ /** Main Window Layout */
mainLayout = new QGridLayout(this); QWidget *centralWidget = new QWidget(this);
setLayout(mainLayout); mainLayout = new QGridLayout(centralWidget);
centralWidget->setLayout(mainLayout);
/** plot group box*/ /** plot group box*/
cloneBox = new QGroupBox(this); cloneBox = new QGroupBox(this);
@ -71,23 +83,24 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
} }
/** Save group box */ /** Save group box */
/*
boxSave = new QGroupBox("Save Image",this); boxSave = new QGroupBox("Save Image",this);
boxSave->setFixedHeight(45); boxSave->setFixedHeight(45);
boxSave->setContentsMargins(0,8,0,0); boxSave->setContentsMargins(0,8,0,0);
layoutSave = new QHBoxLayout; layoutSave = new QHBoxLayout;
boxSave->setLayout(layoutSave); boxSave->setLayout(layoutSave);
/** Label file name*/ * Label file name
lblFName = new QLabel("File Name:",this); lblFName = new QLabel("File Name:",this);
layoutSave->addWidget(lblFName); layoutSave->addWidget(lblFName);
/** To get 0 spacing between the next 2 widgets file name and file format */ * To get 0 spacing between the next 2 widgets file name and file format
hLayoutSave = new QHBoxLayout(); hLayoutSave = new QHBoxLayout();
layoutSave->addLayout(hLayoutSave); layoutSave->addLayout(hLayoutSave);
hLayoutSave->setSpacing(0); hLayoutSave->setSpacing(0);
/** file name */ * file name
dispFName = new QLineEdit(this); dispFName = new QLineEdit(this);
dispFName->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); dispFName->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
hLayoutSave->addWidget(dispFName); hLayoutSave->addWidget(dispFName);
/** file format */ * file format
comboFormat = new QComboBox(this); comboFormat = new QComboBox(this);
comboFormat->setFrame(true); comboFormat->setFrame(true);
comboFormat->addItem(".gif"); comboFormat->addItem(".gif");
@ -100,67 +113,88 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
comboFormat->addItem(".xpm"); comboFormat->addItem(".xpm");
comboFormat->addItem(".C"); comboFormat->addItem(".C");
hLayoutSave->addWidget(comboFormat); hLayoutSave->addWidget(comboFormat);
/** save button */ * save button
btnSave = new QPushButton("Save",this); btnSave = new QPushButton("Save",this);
btnSave->setFocusPolicy(Qt::NoFocus); btnSave->setFocusPolicy(Qt::NoFocus);
layoutSave->addWidget(btnSave); layoutSave->addWidget(btnSave);
/** automatic file name check box */ * automatic file name check box
chkAutoFName = new QCheckBox("Automatic File Name",this); chkAutoFName = new QCheckBox("Automatic File Name",this);
layoutSave->addWidget(chkAutoFName); layoutSave->addWidget(chkAutoFName);
/** automatic save all check box */ * automatic save all check box
chkSaveAll = new QCheckBox("Save All",this); chkSaveAll = new QCheckBox("Save All",this);
layoutSave->addWidget(chkSaveAll); layoutSave->addWidget(chkSaveAll);
*/
/** main window widgets */ /** main window widgets */
mainLayout->addWidget(boxSave,0,0); //mainLayout->addWidget(boxSave,0,0);
mainLayout->addWidget(cloneBox,1,0); mainLayout->addWidget(cloneBox,1,0);
setCentralWidget(centralWidget);
/** Save */ /** Save */
connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot())); connect(actionSave,SIGNAL(triggered()),this,SLOT(SavePlot()));
//connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot()));
setMinimumHeight(300); setMinimumHeight(300);
resize(500,350); resize(500,350);
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[]){ void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[]){
/** for each plot*/ /** for each plot*/
for(int hist_num=0;hist_num<nHists;hist_num++){ for(int hist_num=0;hist_num<nHists;hist_num++){
/** create hists */ /** create hists */
SlsQtH1D* k; SlsQtH1D* k;
if(hist_num+1>cloneplot1D_hists.size()){ if(hist_num+1>cloneplot1D_hists.size()){
cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis[hist_num])); cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis[hist_num]));
k->SetLineColor(hist_num+1); k->SetLineColor(hist_num+1);
}else{ }else{
k=cloneplot1D_hists.at(hist_num); k=cloneplot1D_hists.at(hist_num);
k->SetData(histNBins,histXAxis,histYAxis[hist_num]); k->SetData(histNBins,histXAxis,histYAxis[hist_num]);
}
k->setTitle(histTitle[hist_num].c_str());
k->Attach(cloneplot1D);
} }
k->setTitle(histTitle[hist_num].c_str()); //cloneplot1D->UnZoom();
k->Attach(cloneplot1D);
} }
//cloneplot1D->UnZoom(); //-------------------------------------------------------------------------------------------------------------------------------------------------
char* qCloneWidget::GetCurrentTimeStamp(){
char output[30];
char *result;
//using sys cmds to get output or str
FILE* sysFile = popen("date", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
result = output + 0;
return result;
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SavePlot(){ void qCloneWidget::SavePlot(){
QString fName = QString(filePath.c_str())+'/'+dispFName->text()+comboFormat->currentText(); //QString fName = QString(filePath.c_str())+'/'+dispFName->text()+comboFormat->currentText();
char cID[10];
sprintf(cID,"%d",id);
QString fName = QString(filePath.c_str())+"/Snapshot_"+QString(cID)+".png";
QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32); QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32);
QPainter painter(&img); QPainter painter(&img);
cloneBox->render(&painter); cloneBox->render(&painter);
img.save(fName);
fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),
fName,tr("Images (*.png *.xpm *.jpg)"));
if (!fName.isEmpty())
if(!(img.save(fName)))
qDefs::ErrorMessage("ERROR: Attempt to save snapshot failed","Snapshot: WARNING");
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::closeEvent(QCloseEvent* event){ void qCloneWidget::closeEvent(QCloseEvent* event){
emit CloneClosedSignal(id); emit CloneClosedSignal(id);
event->accept(); event->accept();
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -21,13 +21,13 @@
#include <string> #include <string>
using namespace std; using namespace std;
#define Detector_Index 0
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
int main (int argc, char **argv) { int main (int argc, char **argv) {
QApplication *theApp = new QApplication(argc, argv); QApplication *theApp = new QApplication(argc, argv);
theApp->setWindowIcon(QIcon( ":/icons/images/mountain.png" ));
qDetectorMain *det=new qDetectorMain(argc, argv, theApp,0); qDetectorMain *det=new qDetectorMain(argc, argv, theApp,0);
det->show(); det->show();
//theApp->connect( theApp, SIGNAL(lastWindowClosed()), theApp, SLOT(quit())); //theApp->connect( theApp, SIGNAL(lastWindowClosed()), theApp, SLOT(quit()));
@ -37,24 +37,27 @@ int main (int argc, char **argv) {
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent) : qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent) :
QMainWindow(parent), theApp(app),myPlot(NULL),tabs(NULL),isDeveloper(0){ QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(NULL),tabs(NULL),isDeveloper(0){
myDet = 0;
setupUi(this);
SetUpWidgetWindow();
Initialization();
/**need to use argc and argv to determine which slsdet or multidet to use.*/
/** Getting all the command line arguments */
for(int iarg=1; iarg<argc; iarg++){ for(int iarg=1; iarg<argc; iarg++){
if(!strcasecmp(argv[1],"-developer")) {isDeveloper=1;SetDeveloperMode(true);} if(!strcasecmp(argv[iarg],"-developer")) {isDeveloper=1;}
if(!strcasecmp(argv[iarg],"-id")) {detID=atoi(argv[iarg+1]);}
if(!strcasecmp(argv[1],"-help")){ if(!strcasecmp(argv[iarg],"-help")){
cout<<"Possible Arguments are:"<<endl; cout<<"Possible Arguments are:"<<endl;
cout<<"-help \t\t : \t This help"<<endl; cout<<"-help \t\t : \t This help"<<endl;
cout<<"-developer \t : \t Enables the developer tab"<<endl; cout<<"-developer \t : \t Enables the developer tab"<<endl;
//cout<<"-id i \t : \t Sets the detector to id i (the default is 0). "; cout<<"-id i \t : \t Sets the detector to id i (the default is 0). "
//cout<<"Required only when more than one detector is connected in parallel."<<endl; "Required only when more than one detector is connected in parallel."<<endl;
} }
} }
setupUi(this);
SetUpDetector();
SetUpWidgetWindow();
Initialization();
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -69,9 +72,6 @@ qDetectorMain::~qDetectorMain(){
void qDetectorMain::SetUpWidgetWindow(){ void qDetectorMain::SetUpWidgetWindow(){
SetUpDetector();
/** Layout */ /** Layout */
layoutTabs= new QGridLayout; layoutTabs= new QGridLayout;
centralwidget->setLayout(layoutTabs); centralwidget->setLayout(layoutTabs);
@ -89,7 +89,7 @@ void qDetectorMain::SetUpWidgetWindow(){
tab_dataoutput = new qTabDataOutput (this, myDet); tab_dataoutput = new qTabDataOutput (this, myDet);
tab_plot = new qTabPlot (this, myDet,myPlot); tab_plot = new qTabPlot (this, myDet,myPlot);
tab_actions = new qTabActions (this, myDet); tab_actions = new qTabActions (this, myDet);
tab_settings = new qTabSettings (this, myDet); tab_settings = new qTabSettings (this, myDet, detID);
tab_advanced = new qTabAdvanced (this, myDet); tab_advanced = new qTabAdvanced (this, myDet);
tab_debugging = new qTabDebugging (this, myDet); tab_debugging = new qTabDebugging (this, myDet);
tab_developer = new qTabDeveloper (this, myDet); tab_developer = new qTabDeveloper (this, myDet);
@ -124,6 +124,7 @@ void qDetectorMain::SetUpWidgetWindow(){
SetBeamlineMode(false); SetBeamlineMode(false);
SetExpertMode(false); SetExpertMode(false);
SetDeveloperMode(false); SetDeveloperMode(false);
SetDeveloperMode(isDeveloper);
tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255)); tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255));
@ -136,13 +137,17 @@ void qDetectorMain::SetUpDetector(){
/**instantiate detector and set window title*/ /**instantiate detector and set window title*/
myDet = new multiSlsDetector(Detector_Index); myDet = new multiSlsDetector(detID);
if(!myDet->getHostname(Detector_Index).length()){ if(!myDet->getHostname(detID).length()){
setWindowTitle("SLS Detector GUI : No Detector Connected");
#ifdef VERBOSE #ifdef VERBOSE
cout<<endl<<"No Detector Connected"<<endl; cout<<endl<<"No Detector Connected at id:"<<detID<<endl;
cout<<myDet->getHostname(detID)<<endl;
#endif #endif
myDet = 0; char cIndex[10];
sprintf(cIndex,"%d",detID);
qDefs::ErrorMessage(string("ERROR: No Detector Connected at "
"id : ")+string(cIndex),"Main: ERROR");
exit(-1);
} }
else{ else{
/** Check if type valid. If not, exit*/ /** Check if type valid. If not, exit*/
@ -152,14 +157,18 @@ void qDetectorMain::SetUpDetector(){
case slsDetectorDefs::GOTTHARD: break; case slsDetectorDefs::GOTTHARD: break;
default: default:
string detName = myDet->slsDetectorBase::getDetectorType(myDet->getDetectorsType()); string detName = myDet->slsDetectorBase::getDetectorType(myDet->getDetectorsType());
string hostname = myDet->getHostname(Detector_Index); string hostname = myDet->getHostname(detID);
string errorMess = string("ERROR: ")+hostname+string(" has unknown detector type \"")+detName+string("\". Exiting GUI."); string errorMess = string("ERROR: ")+hostname+string(" has "
"unknown detector type \"")+detName+string("\". Exiting GUI.");
qDefs::ErrorMessage(errorMess,"Main: ERROR"); qDefs::ErrorMessage(errorMess,"Main: ERROR");
exit(-1); exit(-1);
} }
setWindowTitle("SLS Detector GUI : "+QString(slsDetectorBase::getDetectorType(myDet->getDetectorsType()).c_str())+" - "+QString(myDet->getHostname(Detector_Index).c_str())); setWindowTitle("SLS Detector GUI : "+
QString(slsDetectorBase::getDetectorType(myDet->getDetectorsType()).c_str())+
" - "+QString(myDet->getHostname(detID).c_str()));
#ifdef VERBOSE #ifdef VERBOSE
cout<<endl<<"Type : "<<slsDetectorBase::getDetectorType(myDet->getDetectorsType())<<"\t\t\tDetector : "<<myDet->getHostname(Detector_Index)<<endl; cout<<endl<<"Type : "<<slsDetectorBase::getDetectorType(myDet->getDetectorsType())<<"\t\t\tDetector : "
""<<myDet->getHostname(detID)<<endl;
#endif #endif
myDet->setOnline(slsDetectorDefs::ONLINE_FLAG); myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
} }

View File

@ -22,48 +22,13 @@
using namespace std; using namespace std;
#define Detector_Index 0
//-------------------------------------------------------------------------------------------------------------------------------------------------
/** Static Members */
int qDrawPlot::numberOfMeasurements;
int qDrawPlot::currentFrame;
int qDrawPlot::number_of_exposures;
pthread_mutex_t qDrawPlot::last_image_complete_mutex;
unsigned int qDrawPlot::plot_in_scope;
unsigned int qDrawPlot::nPixelsX;
unsigned int qDrawPlot::nPixelsY;
unsigned int qDrawPlot::lastImageNumber;
string qDrawPlot::histTitle[MAX_1DPLOTS];
unsigned int qDrawPlot::nHists;
int qDrawPlot::histNBins;
double* qDrawPlot::histXAxis;
double* qDrawPlot::yvalues[MAX_1DPLOTS];
double* qDrawPlot::histYAxis[MAX_1DPLOTS];
string qDrawPlot::imageTitle;
double* qDrawPlot::lastImageArray;
double* qDrawPlot::image_data;
bool qDrawPlot::gui_acquisition_thread_running;
int qDrawPlot::persistency;
int qDrawPlot::currentPersistency;
int qDrawPlot::progress;
bool qDrawPlot::plotEnable;
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
if(myDet) { SetupWidgetWindow();
SetupWidgetWindow(); Initialization();
Initialization(); StartStopDaqToggle(); //as default
StartStopDaqToggle(); //as default
}
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -85,15 +50,16 @@ void qDrawPlot::SetupWidgetWindow(){
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Setting up plot variables"<<endl; cout<<"Setting up plot variables"<<endl;
#endif #endif
numberOfMeasurements=1; number_of_measurements=1;
currentMeasurement = 0;
stop_signal = 0; stop_signal = 0;
pthread_mutex_init(&last_image_complete_mutex,NULL); pthread_mutex_init(&last_image_complete_mutex,NULL);
gui_acquisition_thread_running = 0; //gui_acquisition_thread_running = 0;
/** Default Plotting*/ /** Default Plotting*/
plot_in_scope = 0; plot_in_scope = 0;
/**2d*/ /**2d*/
lastImageNumber = 0; lastImageNumber = 0;
last_plot_number = 0;
nPixelsX = 1280; nPixelsY = 100; nPixelsX = 1280; nPixelsY = 100;
@ -183,7 +149,21 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
StartDaq(0); StartDaq(0);
running=!running; running=!running;
}else if(!stop_if_running){ //then start }else if(!stop_if_running){ //then start
StartDaq(1);
/**Do the following only once before each n measurements */
/** Reset Current Measurement */
currentMeasurement = 0;
/** Number of Exposures */
number_of_exposures= (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
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;
/** Acquisition Period*/
acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9);
cout<<"\tAcquisition Period:"<<setprecision (10)<<acquisitionPeriod<<endl;
StartDaq(true);
running=!running; running=!running;
} }
} }
@ -193,23 +173,14 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
void qDrawPlot::StartDaq(bool start){ void qDrawPlot::StartDaq(bool start){
if(start){ if(start){
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Start Daq(1) function"<<endl; cout<<"Start Daq(true) function"<<endl;
#endif #endif
number_of_exposures= (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
cout<<"\tNumber of Exposures:"<<number_of_exposures<<endl;
acquisitionTime= ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9);
cout<<"\tAcquisition Time:"<<setprecision (10)<<acquisitionTime<<endl;
framePeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9);
cout<<"\tFrame Period:"<<setprecision (10)<<framePeriod<<endl;
ResetDaqForGui(); ResetDaqForGui();
StartDaqForGui(); StartDaqForGui();
UpdatePlot(); UpdatePlot();
}else{ }else{
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Start Daq(0) function"<<endl; cout<<"Start Daq(false) function"<<endl;
#endif #endif
StopDaqForGui(); StopDaqForGui();
StopUpdatePlot(); StopUpdatePlot();
@ -220,6 +191,7 @@ void qDrawPlot::StartDaq(bool start){
int qDrawPlot::ResetDaqForGui(){ int qDrawPlot::ResetDaqForGui(){
if(!StopDaqForGui()) return 0; if(!StopDaqForGui()) return 0;
cout<<"Resetting image number"<<endl;
lastImageNumber = 0; lastImageNumber = 0;
return 1; return 1;
} }
@ -227,6 +199,7 @@ int qDrawPlot::ResetDaqForGui(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
bool qDrawPlot::StartOrStopThread(bool start){ bool qDrawPlot::StartOrStopThread(bool start){
static bool gui_acquisition_thread_running = 0;
static pthread_t gui_acquisition_thread; static pthread_t gui_acquisition_thread;
static pthread_mutex_t gui_acquisition_start_stop_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t gui_acquisition_start_stop_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -234,8 +207,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){
cout<<"Stopping current acquisition thread ...."<<endl; cout<<"Stopping current acquisition thread ...."<<endl;
stop_signal = 1; stop_signal = 1;//sort of useless
myDet->stopAcquisition();
pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits
gui_acquisition_thread_running = 0; gui_acquisition_thread_running = 0;
} }
@ -243,6 +215,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
//start part //start part
if(start){ if(start){
/** Defaults */ /** Defaults */
progress = 0;
currentFrame = 0; currentFrame = 0;
stop_signal = 0; stop_signal = 0;
histNBins = nPixelsX; histNBins = nPixelsX;
@ -255,14 +228,16 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(plot_in_scope==1) Clear1DPlot(); if(plot_in_scope==1) Clear1DPlot();
cout<<"Starting new acquisition thread ...."<<endl; cout<<"Starting new acquisition threadddd ...."<<endl;
/** Setting the callback function to get data from software client*/ /** Setting the callback function to get data from software client*/
myDet->registerDataCallback(&(GetDataCallBack)); myDet->registerDataCallback(&(GetDataCallBack),this);
/** Start acquiring data from server */ /** Start acquiring data from server */
pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this); pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this);
/** This is later reset to zero when all the plotting is done */ /** This is set here and later reset to zero when all the plotting is done
* This is manually done instead of keeping track of thread because
* this thread returns immediately after executing the acquire command*/
gui_acquisition_thread_running=1; gui_acquisition_thread_running=1;
cout<<"Started acquiring"<<endl; cout<<"Started acquiring threaddd"<<endl;
} }
pthread_mutex_unlock(&gui_acquisition_start_stop_mutex); pthread_mutex_unlock(&gui_acquisition_start_stop_mutex);
return gui_acquisition_thread_running; return gui_acquisition_thread_running;
@ -271,16 +246,26 @@ bool qDrawPlot::StartOrStopThread(bool start){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void* qDrawPlot::DataStartAcquireThread(void *this_pointer){ void* qDrawPlot::DataStartAcquireThread(void *this_pointer){
cout<<"before acquire ...."<<endl;
((qDrawPlot*)this_pointer)->myDet->acquire(1); ((qDrawPlot*)this_pointer)->myDet->acquire(1);
cout<<"after acquire ...."<<endl;
return this_pointer; return this_pointer;
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::GetDataCallBack(detectorData *data){ int qDrawPlot::GetDataCallBack(detectorData *data, void *this_pointer){
#ifdef VERYVERBOSE ((qDrawPlot*)this_pointer)->GetData(data);
cout<<"Entering GetDataCallBack function"<<endl; return 0;
#endif }
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::GetData(detectorData *data){
//#ifdef VERYVERBOSE
cout<<"Entering GetDatafunction"<<endl;
//#endif
progress=(int)data->progressIndex; progress=(int)data->progressIndex;
if(!plotEnable) { if(!plotEnable) {
@ -338,7 +323,7 @@ int qDrawPlot::GetDataCallBack(detectorData *data){
currentFrame++; currentFrame++;
} }
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Exiting GetDataCallBack function"<<endl; cout<<"Exiting GetData function"<<endl;
#endif #endif
return 0; return 0;
} }
@ -346,7 +331,7 @@ int qDrawPlot::GetDataCallBack(detectorData *data){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::setNumMeasurements(int num){ void qDrawPlot::setNumMeasurements(int num){
numberOfMeasurements = num; number_of_measurements = num;
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -380,7 +365,7 @@ void qDrawPlot::Clear1DPlot(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::UpdatePlot(){ void qDrawPlot::UpdatePlot(){
static int last_plot_number = 0; //static int last_plot_number = 0;
plot_update_timer->stop(); plot_update_timer->stop();
if(plotEnable){ if(plotEnable){
@ -425,17 +410,28 @@ void qDrawPlot::UpdatePlot(){
} }
} }
last_plot_number=lastImageNumber; last_plot_number=lastImageNumber;
if(plotEnable) UnlockLastImageArray();
/* if(plot_in_scope==1) SelectPlot(1);
else if(plot_in_scope==2) SelectPlot(2);*/
if(number_of_exposures==last_plot_number){ if(plotEnable) UnlockLastImageArray();
gui_acquisition_thread_running=0;
StartStopDaqToggle(1); /** Measurement not over, continue*/
emit UpdatingPlotFinished(); if(number_of_exposures!=last_plot_number){
}else{
plot_update_timer->start(500); plot_update_timer->start(500);
} }
/** if a measurement is over */
else{
currentMeasurement++;
cout<<"currentMeausremet:"<<currentMeasurement<<endl;
/** if all the measurements are over */
if(currentMeasurement==number_of_measurements){
StartStopDaqToggle(true);
emit UpdatingPlotFinished();
}/** To start the next measurement*/
else{
StopDaqForGui();
//StartDaq(false);
StartDaq(true);
}
}
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -18,16 +18,11 @@
using namespace std; using namespace std;
#define Detector_Index 0
qTabActions::qTabActions(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ qTabActions::qTabActions(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
if(myDet) SetupWidgetWindow();
{ Initialization();
SetupWidgetWindow();
Initialization();
}
} }

View File

@ -14,18 +14,13 @@
using namespace std; using namespace std;
#define Detector_Index 0
qTabAdvanced::qTabAdvanced(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ qTabAdvanced::qTabAdvanced(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
setupUi(this); setupUi(this);
if(myDet) myDetType = (int)myDet->getDetectorsType();
{ SetupWidgetWindow();
myDetType = (int)myDet->getDetectorsType(); Initialization();
SetupWidgetWindow();
Initialization();
}
} }

View File

@ -17,18 +17,13 @@
using namespace std; using namespace std;
#define Detector_Index 0
qTabDataOutput::qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector): qTabDataOutput::qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector):
QWidget(parent),myDet(detector){ QWidget(parent),myDet(detector){
setupUi(this); setupUi(this);
if(myDet) SetupWidgetWindow();
{ Initialization();
SetupWidgetWindow();
Initialization();
}
} }

View File

@ -14,17 +14,12 @@
using namespace std; using namespace std;
#define Detector_Index 0
qTabDebugging::qTabDebugging(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ qTabDebugging::qTabDebugging(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
setupUi(this); setupUi(this);
if(myDet) SetupWidgetWindow();
{ Initialization();
SetupWidgetWindow();
Initialization();
}
} }

View File

@ -14,17 +14,13 @@
using namespace std; using namespace std;
#define Detector_Index 0
qTabDeveloper::qTabDeveloper(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ qTabDeveloper::qTabDeveloper(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
setupUi(this); setupUi(this);
if(myDet) SetupWidgetWindow();
{ Initialization();
SetupWidgetWindow();
Initialization();
}
} }

View File

@ -20,19 +20,17 @@
using namespace std; using namespace std;
#define Detector_Index 0
#define UndefinedSettings 7
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
qTabMeasurement::qTabMeasurement(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot): qTabMeasurement::qTabMeasurement(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot):
QWidget(parent),myDet(detector),myPlot(plot){ QWidget(parent),myDet(detector),myPlot(plot){
setupUi(this); setupUi(this);
if(myDet) SetupWidgetWindow();
{ Initialization();
SetupWidgetWindow();
Initialization();
}
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -49,9 +47,10 @@ void qTabMeasurement::SetupWidgetWindow(){
progressTimer = new QTimer(this); progressTimer = new QTimer(this);
//btnStartStop->setStyleSheet("color:green"); //btnStartStop->setStyleSheet("color:green");
/** Exp Time **/ /** Exp Time **/
float time = (float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)); qDefs::timeUnit unit;
float time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9))));
spinExpTime->setValue(time); spinExpTime->setValue(time);
comboExpUnit->setCurrentIndex(qDefs::SECONDS); comboExpUnit->setCurrentIndex((int)unit);
/** Hide the error message **/ /** Hide the error message **/
lblNote->hide(); lblNote->hide();
/** File Name **/ /** File Name **/
@ -85,7 +84,7 @@ void qTabMeasurement::SetupWidgetWindow(){
item[(int)Gated_Start]->setEnabled(true); item[(int)Gated_Start]->setEnabled(true);
item[(int)Trigger_Window]->setEnabled(false); item[(int)Trigger_Window]->setEnabled(false);
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::EIGER:
item[(int)Trigger_Exp_Series]->setEnabled(true); item[(int)Trigger_Exp_Series]->setEnabled(true);
item[(int)Trigger_Frame]->setEnabled(true); item[(int)Trigger_Frame]->setEnabled(true);
item[(int)Trigger_Readout]->setEnabled(false); item[(int)Trigger_Readout]->setEnabled(false);
@ -93,7 +92,7 @@ void qTabMeasurement::SetupWidgetWindow(){
item[(int)Gated_Start]->setEnabled(false); item[(int)Gated_Start]->setEnabled(false);
item[(int)Trigger_Window]->setEnabled(true); item[(int)Trigger_Window]->setEnabled(true);
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::GOTTHARD:
item[(int)Trigger_Exp_Series]->setEnabled(true); item[(int)Trigger_Exp_Series]->setEnabled(true);
item[(int)Trigger_Frame]->setEnabled(false); item[(int)Trigger_Frame]->setEnabled(false);
item[(int)Trigger_Readout]->setEnabled(false); item[(int)Trigger_Readout]->setEnabled(false);
@ -146,7 +145,7 @@ void qTabMeasurement::SetupWidgetWindow(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMeasurement::Initialization(int timingChange){ void qTabMeasurement::Initialization(int timingChange){
/** These signals are connected only at start up*/ /** These signals are connected only at start up. The others are reinitialized when changing timing mode*/
if(!timingChange){ if(!timingChange){
/** Number of Measurements**/ /** Number of Measurements**/
connect(spinNumMeasurements,SIGNAL(valueChanged(int)), myPlot, SLOT(setNumMeasurements(int))); connect(spinNumMeasurements,SIGNAL(valueChanged(int)), myPlot, SLOT(setNumMeasurements(int)));
@ -242,13 +241,14 @@ void qTabMeasurement::startStopAcquisition(){
btnStartStop->setText("Stop"); btnStartStop->setText("Stop");
Enable(0); Enable(0);
progressBar->setValue(0); progressBar->setValue(0);
progressTimer->start(200); progressTimer->start(100);
emit StartSignal(); emit StartSignal();
}else{ }else{
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Stopping Acquisition"<<endl; cout<<"Stopping Acquisition"<<endl;
#endif #endif
myDet->stopAcquisition();
//btnStartStop->setStyleSheet("color:green"); //btnStartStop->setStyleSheet("color:green");
//btnStartStop->setStyleSheet("background:rgb(239,239,239)"); //btnStartStop->setStyleSheet("background:rgb(239,239,239)");
progressTimer->stop(); progressTimer->stop();
@ -476,6 +476,7 @@ void qTabMeasurement::setTimingMode(int mode){
float time; float time;
int val; int val;
qDefs::timeUnit unit;
/**Number of Frames */ /**Number of Frames */
if(lblNumFrames->isEnabled()){ if(lblNumFrames->isEnabled()){
val = (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1); val = (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
@ -487,22 +488,22 @@ void qTabMeasurement::setTimingMode(int mode){
/**Exposure Time */ /**Exposure Time */
if(lblExpTime->isEnabled()){ if(lblExpTime->isEnabled()){
time = (float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)); time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9))));
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Getting acquisition time : " << time << "s" << endl; cout<<"Getting acquisition time : " << time << "s" << endl;
#endif #endif
spinExpTime->setValue(time); spinExpTime->setValue(time);
comboExpUnit->setCurrentIndex(qDefs::SECONDS); comboExpUnit->setCurrentIndex((int)unit);
} }
/**Frame Period between exposures */ /**Frame Period between exposures */
if(lblPeriod->isEnabled()){ if(lblPeriod->isEnabled()){
time = (float)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)); time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9))));
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Getting frame period between exposures : " << time << "s" << endl; cout<<"Getting frame period between exposures : " << time << "s" << endl;
#endif #endif
spinPeriod->setValue(time); spinPeriod->setValue(time);
comboPeriodUnit->setCurrentIndex(qDefs::SECONDS); comboPeriodUnit->setCurrentIndex((int)unit);
int64_t exptimeNS,acqtimeNS; int64_t exptimeNS,acqtimeNS;
exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value());
@ -534,12 +535,12 @@ void qTabMeasurement::setTimingMode(int mode){
/**Delay After Trigger */ /**Delay After Trigger */
if(lblDelay->isEnabled()){ if(lblDelay->isEnabled()){
time = (float)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)); time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9))));
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Getting delay after trigger : " << time << "s" << endl; cout<<"Getting delay after trigger : " << time << "s" << endl;
#endif #endif
spinDelay->setValue(time); spinDelay->setValue(time);
comboDelayUnit->setCurrentIndex(qDefs::SECONDS); comboDelayUnit->setCurrentIndex((int)unit);
} }
/**Number of Gates */ /**Number of Gates */

View File

@ -17,8 +17,6 @@
using namespace std; using namespace std;
#define Detector_Index 0
QString qTabPlot::defaultPlotTitle("Measurement"); QString qTabPlot::defaultPlotTitle("Measurement");
QString qTabPlot::defaultHistXAxisTitle("Channel Number"); QString qTabPlot::defaultHistXAxisTitle("Channel Number");
@ -30,19 +28,17 @@ QString qTabPlot::defaultImageZAxisTitle("Intensity");
qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot):QWidget(parent),myDet(detector),myPlot(plot){ qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot):QWidget(parent),myDet(detector),myPlot(plot){
setupUi(this); setupUi(this);
if(myDet){ SetupWidgetWindow();
SetupWidgetWindow(); /** Depending on whether the detector is 1d or 2d*/
/** Depending on whether the detector is 1d or 2d*/ switch(myDet->getDetectorsType()){
switch(myDet->getDetectorsType()){ case slsDetectorDefs::MYTHEN: Select1DPlot(true); break;
case slsDetectorDefs::MYTHEN: Select1DPlot(true); break; case slsDetectorDefs::EIGER: Select1DPlot(false);break;
case slsDetectorDefs::EIGER: Select1DPlot(false);break; case slsDetectorDefs::GOTTHARD: Select1DPlot(true);break;
case slsDetectorDefs::GOTTHARD: Select1DPlot(true);break; default:
default: cout<<"ERROR: Detector Type is Generic"<<endl;
cout<<"ERROR: Detector Type is Generic"<<endl; exit(-1);
exit(-1);
}
Initialization();
} }
Initialization();
} }

View File

@ -15,17 +15,13 @@
using namespace std; using namespace std;
#define Detector_Index 0
qTabSettings::qTabSettings(QWidget *parent,slsDetectorUtils*& detector,int detID):
QWidget(parent),myDet(detector),detID(detID){
qTabSettings::qTabSettings(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
setupUi(this); setupUi(this);
if(myDet) SetupWidgetWindow();
{ Initialization();
SetupWidgetWindow();
Initialization();
}
} }
@ -40,7 +36,7 @@ qTabSettings::~qTabSettings(){
void qTabSettings::SetupWidgetWindow(){ void qTabSettings::SetupWidgetWindow(){
/** Settings */ /** Settings */
comboSettings->setCurrentIndex(myDet->getSettings(Detector_Index)); comboSettings->setCurrentIndex(myDet->getSettings(detID));
} }
@ -52,13 +48,8 @@ void qTabSettings::Initialization(){
void qTabSettings::Enable(bool enable){
comboSettings->setEnabled(enable);
}
void qTabSettings::setSettings(int index){ void qTabSettings::setSettings(int index){
slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index,Detector_Index); slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index,detID);
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Settings have been set to "<<myDet->slsDetectorBase::getDetectorSettings(sett)<<endl; cout<<"Settings have been set to "<<myDet->slsDetectorBase::getDetectorSettings(sett)<<endl;
#endif #endif