diff --git a/slsDetectorGui/images/mountain.png b/slsDetectorGui/images/mountain.png
new file mode 100644
index 000000000..3962d0fbc
Binary files /dev/null and b/slsDetectorGui/images/mountain.png differ
diff --git a/slsDetectorGui/include/icons.qrc b/slsDetectorGui/include/icons.qrc
new file mode 100644
index 000000000..7ae9757eb
--- /dev/null
+++ b/slsDetectorGui/include/icons.qrc
@@ -0,0 +1,5 @@
+
+
+ ../images/mountain.png
+
+
diff --git a/slsDetectorGui/include/qCloneWidget.h b/slsDetectorGui/include/qCloneWidget.h
index 4cf22c26f..0fe0def05 100644
--- a/slsDetectorGui/include/qCloneWidget.h
+++ b/slsDetectorGui/include/qCloneWidget.h
@@ -13,7 +13,10 @@ class SlsQtH1D;
class SlsQt1DPlot;
class SlsQt2DPlotLayout;
/** Qt Include Headers */
-#include
+#include
+#include
+#include
+#include
#include
#include
#include
@@ -31,7 +34,7 @@ using namespace std;
/**
*@short Sets up the clone plot widget
*/
-class qCloneWidget:public QFrame{
+class qCloneWidget:public QMainWindow{
Q_OBJECT
public:
@@ -77,6 +80,10 @@ private:
QVector cloneplot1D_hists;
+ QMenuBar *menubar;
+ // QMenu *menuFile;
+ QAction *actionSave;
+
QGridLayout *mainLayout;
QGroupBox *cloneBox;
QGridLayout *gridClone;
@@ -90,6 +97,8 @@ private:
QCheckBox *chkAutoFName;
QCheckBox *chkSaveAll;
+ /** Gets the current time stamp for the window title*/
+ char* GetCurrentTimeStamp();
private slots:
diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h
index 955cb344d..f75af62a2 100644
--- a/slsDetectorGui/include/qDefs.h
+++ b/slsDetectorGui/include/qDefs.h
@@ -54,6 +54,40 @@ public:
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
diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h
index a09558036..c7ac27275 100644
--- a/slsDetectorGui/include/qDetectorMain.h
+++ b/slsDetectorGui/include/qDetectorMain.h
@@ -62,6 +62,8 @@ private:
QApplication *theApp;
/** The sls detector object */
slsDetectorUtils *myDet;
+ /** sls detector id */
+ int detID;
/** The Plot widget */
qDrawPlot *myPlot;
/**Tab Widget */
@@ -74,6 +76,7 @@ private:
int heightCentralWidget;
/** The default zooming tool tip */
QString zoomToolTip;
+
/** The default tab heading color */
QColor defaultTabColor;
/** enumeration of the tabs */
@@ -97,6 +100,7 @@ private:
/**Developer tab */
qTabDeveloper *tab_developer;
/**if the developer tab should be enabled,known from command line */
+
int isDeveloper;
/**Sets up the layout of the widget
*/
diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h
index 5bdaa7c78..57bfe31b6 100644
--- a/slsDetectorGui/include/qDrawPlot.h
+++ b/slsDetectorGui/include/qDrawPlot.h
@@ -108,22 +108,24 @@ private:
/** Number of Measurements */
- static int numberOfMeasurements;
+ int number_of_measurements;
+ /** Current Measurement */
+ int currentMeasurement;
/** currentFrame */
- static int currentFrame;
+ int currentFrame;
/** Number of Exposures */
- static int number_of_exposures;
+ int number_of_exposures;
/** Duration between Exposures */
- double framePeriod;
+ double acquisitionPeriod;
/** Acquisition Time */
- double acquisitionTime;
+ double exposureTime;
/**variables for threads */
/** */
volatile bool stop_signal;
/** */
- static pthread_mutex_t last_image_complete_mutex;
+ pthread_mutex_t last_image_complete_mutex;
/**variables for histograms */
/** X Axis Title in 2D */
@@ -137,37 +139,38 @@ private:
/** Y Axis Title in 1D */
QString histYAxisTitle;
/** Title for all the graphs in 1D */
- static std::string histTitle[MAX_1DPLOTS];
+ std::string histTitle[MAX_1DPLOTS];
/** Title in 2D */
- static std::string imageTitle;
+ std::string imageTitle;
/** 1D or 2D */
- static unsigned int plot_in_scope;
+ unsigned int plot_in_scope;
/** Number of Pixels in X Axis */
- static unsigned int nPixelsX;
+ unsigned int nPixelsX;
/** Number of Pixels in Y Axis */
- static unsigned int nPixelsY;
+ unsigned int nPixelsY;
/** Current Image Number */
- static unsigned int lastImageNumber;
+ unsigned int lastImageNumber;
+ int last_plot_number;
/** Number of graphs in 1D */
- static unsigned int nHists;
+ unsigned int nHists;
/** Total Number of X axis values/channels in 1D */
- static int histNBins;
+ int histNBins;
/** X Axis value in 1D */
- static double* histXAxis;
+ double* histXAxis;
/** Y Axis value in 1D */
- static double* histYAxis[MAX_1DPLOTS];
+ double* histYAxis[MAX_1DPLOTS];
/** Current Image Values in 2D */
- static double* lastImageArray;
+ double* lastImageArray;
/** temporary Y Axis value in 1D */
- static double* yvalues[MAX_1DPLOTS];
+ double* yvalues[MAX_1DPLOTS];
/** temporary Image Values in 2D */
- static double* image_data;
- static bool gui_acquisition_thread_running;
- static int persistency;
- static int currentPersistency;
- static int progress;
- static bool plotEnable;
+ double* image_data;
+ //bool gui_acquisition_thread_running;
+ int persistency;
+ int currentPersistency;
+ int progress;
+ bool plotEnable;
/** Initializes all its members and the thread */
void Initialization();
@@ -197,8 +200,10 @@ private:
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 copt the data it jus acquired */
- static int GetDataCallBack(detectorData *data);
+ /** 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);
public slots:
diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h
index c83c77b1b..23c5ecd6b 100644
--- a/slsDetectorGui/include/qTabSettings.h
+++ b/slsDetectorGui/include/qTabSettings.h
@@ -23,8 +23,9 @@ public:
/** \short The constructor
* @param parent is the parent tab widget
* @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
*/
@@ -35,6 +36,10 @@ private:
/** The sls detector object */
slsDetectorUtils *myDet;
+ /** sls detector id */
+ int detID;
+
+
/** Sets up the widget
*/
void SetupWidgetWindow();
@@ -43,9 +48,6 @@ private:
*/
void Initialization();
- /** Enables/Disables all the widgets
- */
- void Enable(bool enable);
private slots:
diff --git a/slsDetectorGui/slsDetectorGui.pro b/slsDetectorGui/slsDetectorGui.pro
index 9ec0c8f12..6046b23e6 100644
--- a/slsDetectorGui/slsDetectorGui.pro
+++ b/slsDetectorGui/slsDetectorGui.pro
@@ -3,6 +3,9 @@ MOC_DIR = mocs
OBJECTS_DIR = objs
UI_HEADERS_DIR = forms/include
+RESOURCES += icons.qrc
+
+
DEFINES += VERBOSE
diff --git a/slsDetectorGui/src/qActionsWidget.cpp b/slsDetectorGui/src/qActionsWidget.cpp
index 7b3e0514a..1004150c8 100644
--- a/slsDetectorGui/src/qActionsWidget.cpp
+++ b/slsDetectorGui/src/qActionsWidget.cpp
@@ -24,7 +24,6 @@
using namespace std;
-#define Detector_Index 0
ActionsWidget::ActionsWidget(QWidget *parent, int scanType): QFrame(parent){
diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp
index 941aa9b39..ae8d385a8 100644
--- a/slsDetectorGui/src/qCloneWidget.cpp
+++ b/slsDetectorGui/src/qCloneWidget.cpp
@@ -7,30 +7,33 @@
/** Qt Project Class Headers */
#include "qCloneWidget.h"
+#include "qDefs.h"
#include "SlsQt1DPlot.h"
#include "SlsQt2DPlotLayout.h"
/** Qt Include Headers */
#include
#include
+#include
/** C++ Include Headers */
#include
using namespace std;
+//-------------------------------------------------------------------------------------------------------------------------------------------------
-
-
-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){
+qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath):
+ QMainWindow(parent),id(id),filePath(FilePath){
/** Window title*/
- char winTitle[100];
- sprintf(winTitle,"SLS Detector GUI Clone %d",id);
+ char winTitle[300],currTime[50];
+ strcpy(currTime,GetCurrentTimeStamp());
+ sprintf(winTitle,"Snapshot:%d - %s",id,currTime);
setWindowTitle(QString(winTitle));
/** Set up widget*/
SetupWidgetWindow(title,numDim,plot1D,plot2D);
-
}
+//-------------------------------------------------------------------------------------------------------------------------------------------------
qCloneWidget::~qCloneWidget(){
delete cloneplot1D;
@@ -39,13 +42,22 @@ qCloneWidget::~qCloneWidget(){
delete boxSave;
}
-
+//-------------------------------------------------------------------------------------------------------------------------------------------------
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 */
- mainLayout = new QGridLayout(this);
- setLayout(mainLayout);
+ QWidget *centralWidget = new QWidget(this);
+ mainLayout = new QGridLayout(centralWidget);
+ centralWidget->setLayout(mainLayout);
/** plot group box*/
cloneBox = new QGroupBox(this);
@@ -71,23 +83,24 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
}
/** Save group box */
+/*
boxSave = new QGroupBox("Save Image",this);
boxSave->setFixedHeight(45);
boxSave->setContentsMargins(0,8,0,0);
layoutSave = new QHBoxLayout;
boxSave->setLayout(layoutSave);
- /** Label file name*/
+ * Label file name
lblFName = new QLabel("File Name:",this);
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();
layoutSave->addLayout(hLayoutSave);
hLayoutSave->setSpacing(0);
- /** file name */
+ * file name
dispFName = new QLineEdit(this);
dispFName->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
hLayoutSave->addWidget(dispFName);
- /** file format */
+ * file format
comboFormat = new QComboBox(this);
comboFormat->setFrame(true);
comboFormat->addItem(".gif");
@@ -100,67 +113,88 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
comboFormat->addItem(".xpm");
comboFormat->addItem(".C");
hLayoutSave->addWidget(comboFormat);
- /** save button */
+ * save button
btnSave = new QPushButton("Save",this);
btnSave->setFocusPolicy(Qt::NoFocus);
layoutSave->addWidget(btnSave);
- /** automatic file name check box */
+ * automatic file name check box
chkAutoFName = new QCheckBox("Automatic File Name",this);
layoutSave->addWidget(chkAutoFName);
- /** automatic save all check box */
+ * automatic save all check box
chkSaveAll = new QCheckBox("Save All",this);
layoutSave->addWidget(chkSaveAll);
+*/
/** main window widgets */
- mainLayout->addWidget(boxSave,0,0);
+ //mainLayout->addWidget(boxSave,0,0);
mainLayout->addWidget(cloneBox,1,0);
+ setCentralWidget(centralWidget);
/** Save */
- connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot()));
+ connect(actionSave,SIGNAL(triggered()),this,SLOT(SavePlot()));
+ //connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot()));
setMinimumHeight(300);
resize(500,350);
-
}
-
-
+//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[]){
-/** for each plot*/
-for(int hist_num=0;hist_numcloneplot1D_hists.size()){
- cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis[hist_num]));
- k->SetLineColor(hist_num+1);
- }else{
- k=cloneplot1D_hists.at(hist_num);
- k->SetData(histNBins,histXAxis,histYAxis[hist_num]);
+ /** for each plot*/
+ for(int hist_num=0;hist_numcloneplot1D_hists.size()){
+ cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis[hist_num]));
+ k->SetLineColor(hist_num+1);
+ }else{
+ k=cloneplot1D_hists.at(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());
- k->Attach(cloneplot1D);
+ //cloneplot1D->UnZoom();
}
-//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(){
- 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);
QPainter painter(&img);
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){
emit CloneClosedSignal(id);
event->accept();
}
+
+//-------------------------------------------------------------------------------------------------------------------------------------------------
diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp
index 59947cf64..718281802 100644
--- a/slsDetectorGui/src/qDetectorMain.cpp
+++ b/slsDetectorGui/src/qDetectorMain.cpp
@@ -21,13 +21,13 @@
#include
using namespace std;
-#define Detector_Index 0
//-------------------------------------------------------------------------------------------------------------------------------------------------
int main (int argc, char **argv) {
QApplication *theApp = new QApplication(argc, argv);
+ theApp->setWindowIcon(QIcon( ":/icons/images/mountain.png" ));
qDetectorMain *det=new qDetectorMain(argc, argv, theApp,0);
det->show();
//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) :
- QMainWindow(parent), theApp(app),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.*/
+ QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(NULL),tabs(NULL),isDeveloper(0){
+ /** Getting all the command line arguments */
for(int iarg=1; iargsetLayout(layoutTabs);
@@ -89,7 +89,7 @@ void qDetectorMain::SetUpWidgetWindow(){
tab_dataoutput = new qTabDataOutput (this, myDet);
tab_plot = new qTabPlot (this, myDet,myPlot);
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_debugging = new qTabDebugging (this, myDet);
tab_developer = new qTabDeveloper (this, myDet);
@@ -124,6 +124,7 @@ void qDetectorMain::SetUpWidgetWindow(){
SetBeamlineMode(false);
SetExpertMode(false);
SetDeveloperMode(false);
+ SetDeveloperMode(isDeveloper);
tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255));
@@ -136,13 +137,17 @@ void qDetectorMain::SetUpDetector(){
/**instantiate detector and set window title*/
- myDet = new multiSlsDetector(Detector_Index);
- if(!myDet->getHostname(Detector_Index).length()){
- setWindowTitle("SLS Detector GUI : No Detector Connected");
+ myDet = new multiSlsDetector(detID);
+ if(!myDet->getHostname(detID).length()){
#ifdef VERBOSE
- cout<getHostname(detID)<slsDetectorBase::getDetectorType(myDet->getDetectorsType());
- string hostname = myDet->getHostname(Detector_Index);
- string errorMess = string("ERROR: ")+hostname+string(" has unknown detector type \"")+detName+string("\". Exiting GUI.");
+ string hostname = myDet->getHostname(detID);
+ string errorMess = string("ERROR: ")+hostname+string(" has "
+ "unknown detector type \"")+detName+string("\". Exiting GUI.");
qDefs::ErrorMessage(errorMess,"Main: ERROR");
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
- cout<getDetectorsType())<<"\t\t\tDetector : "<getHostname(Detector_Index)<getDetectorsType())<<"\t\t\tDetector : "
+ ""<getHostname(detID)<setOnline(slsDetectorDefs::ONLINE_FLAG);
}
diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp
index 516029096..537c8b986 100644
--- a/slsDetectorGui/src/qDrawPlot.cpp
+++ b/slsDetectorGui/src/qDrawPlot.cpp
@@ -22,48 +22,13 @@
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){
- if(myDet) {
- SetupWidgetWindow();
- Initialization();
- StartStopDaqToggle(); //as default
- }
+ SetupWidgetWindow();
+ Initialization();
+ StartStopDaqToggle(); //as default
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@@ -85,15 +50,16 @@ void qDrawPlot::SetupWidgetWindow(){
#ifdef VERBOSE
cout<<"Setting up plot variables"<setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
+ cout<<"\tNumber of Exposures:"<setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9);
+ cout<<"\tExposure Time:"<setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9);
+ cout<<"\tAcquisition Period:"<setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
- cout<<"\tNumber of Exposures:"<setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9);
- cout<<"\tAcquisition Time:"<setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9);
- cout<<"\tFrame Period:"<stopAcquisition();
+ stop_signal = 1;//sort of useless
pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits
gui_acquisition_thread_running = 0;
}
@@ -243,6 +215,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
//start part
if(start){
/** Defaults */
+ progress = 0;
currentFrame = 0;
stop_signal = 0;
histNBins = nPixelsX;
@@ -255,14 +228,16 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(plot_in_scope==1) Clear1DPlot();
- cout<<"Starting new acquisition thread ...."<registerDataCallback(&(GetDataCallBack));
+ myDet->registerDataCallback(&(GetDataCallBack),this);
/** Start acquiring data from server */
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;
- cout<<"Started acquiring"<myDet->acquire(1);
+ cout<<"after acquire ...."<GetData(data);
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------------------------------------
+
+int qDrawPlot::GetData(detectorData *data){
+//#ifdef VERYVERBOSE
+ cout<<"Entering GetDatafunction"<progressIndex;
if(!plotEnable) {
@@ -338,7 +323,7 @@ int qDrawPlot::GetDataCallBack(detectorData *data){
currentFrame++;
}
#ifdef VERYVERBOSE
- cout<<"Exiting GetDataCallBack function"<stop();
if(plotEnable){
@@ -425,17 +410,28 @@ void qDrawPlot::UpdatePlot(){
}
}
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){
- gui_acquisition_thread_running=0;
- StartStopDaqToggle(1);
- emit UpdatingPlotFinished();
- }else{
+ if(plotEnable) UnlockLastImageArray();
+
+ /** Measurement not over, continue*/
+ if(number_of_exposures!=last_plot_number){
plot_update_timer->start(500);
}
+ /** if a measurement is over */
+ else{
+ currentMeasurement++;
+ cout<<"currentMeausremet:"<getDetectorsType();
- SetupWidgetWindow();
- Initialization();
- }
+ myDetType = (int)myDet->getDetectorsType();
+ SetupWidgetWindow();
+ Initialization();
}
diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp
index 778f3f908..b51904a23 100644
--- a/slsDetectorGui/src/qTabDataOutput.cpp
+++ b/slsDetectorGui/src/qTabDataOutput.cpp
@@ -17,18 +17,13 @@
using namespace std;
-#define Detector_Index 0
-
qTabDataOutput::qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector):
QWidget(parent),myDet(detector){
setupUi(this);
- if(myDet)
- {
- SetupWidgetWindow();
- Initialization();
- }
+ SetupWidgetWindow();
+ Initialization();
}
diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp
index 4fcf040bb..8c797b30b 100644
--- a/slsDetectorGui/src/qTabDebugging.cpp
+++ b/slsDetectorGui/src/qTabDebugging.cpp
@@ -14,17 +14,12 @@
using namespace std;
-#define Detector_Index 0
-
qTabDebugging::qTabDebugging(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
setupUi(this);
- if(myDet)
- {
- SetupWidgetWindow();
- Initialization();
- }
+ SetupWidgetWindow();
+ Initialization();
}
diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp
index 777a76c7f..b987fff82 100644
--- a/slsDetectorGui/src/qTabDeveloper.cpp
+++ b/slsDetectorGui/src/qTabDeveloper.cpp
@@ -14,17 +14,13 @@
using namespace std;
-#define Detector_Index 0
-
qTabDeveloper::qTabDeveloper(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
setupUi(this);
- if(myDet)
- {
- SetupWidgetWindow();
- Initialization();
- }
+ SetupWidgetWindow();
+ Initialization();
+
}
diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp
index 91266a84d..23e597325 100644
--- a/slsDetectorGui/src/qTabMeasurement.cpp
+++ b/slsDetectorGui/src/qTabMeasurement.cpp
@@ -20,19 +20,17 @@
using namespace std;
-#define Detector_Index 0
-#define UndefinedSettings 7
+
+
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabMeasurement::qTabMeasurement(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot):
QWidget(parent),myDet(detector),myPlot(plot){
setupUi(this);
- if(myDet)
- {
- SetupWidgetWindow();
- Initialization();
- }
+ SetupWidgetWindow();
+ Initialization();
+
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@@ -49,9 +47,10 @@ void qTabMeasurement::SetupWidgetWindow(){
progressTimer = new QTimer(this);
//btnStartStop->setStyleSheet("color:green");
/** 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);
- comboExpUnit->setCurrentIndex(qDefs::SECONDS);
+ comboExpUnit->setCurrentIndex((int)unit);
/** Hide the error message **/
lblNote->hide();
/** File Name **/
@@ -85,7 +84,7 @@ void qTabMeasurement::SetupWidgetWindow(){
item[(int)Gated_Start]->setEnabled(true);
item[(int)Trigger_Window]->setEnabled(false);
break;
- case slsDetectorDefs::GOTTHARD:
+ case slsDetectorDefs::EIGER:
item[(int)Trigger_Exp_Series]->setEnabled(true);
item[(int)Trigger_Frame]->setEnabled(true);
item[(int)Trigger_Readout]->setEnabled(false);
@@ -93,7 +92,7 @@ void qTabMeasurement::SetupWidgetWindow(){
item[(int)Gated_Start]->setEnabled(false);
item[(int)Trigger_Window]->setEnabled(true);
break;
- case slsDetectorDefs::EIGER:
+ case slsDetectorDefs::GOTTHARD:
item[(int)Trigger_Exp_Series]->setEnabled(true);
item[(int)Trigger_Frame]->setEnabled(false);
item[(int)Trigger_Readout]->setEnabled(false);
@@ -146,7 +145,7 @@ void qTabMeasurement::SetupWidgetWindow(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
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){
/** Number of Measurements**/
connect(spinNumMeasurements,SIGNAL(valueChanged(int)), myPlot, SLOT(setNumMeasurements(int)));
@@ -242,13 +241,14 @@ void qTabMeasurement::startStopAcquisition(){
btnStartStop->setText("Stop");
Enable(0);
progressBar->setValue(0);
- progressTimer->start(200);
+ progressTimer->start(100);
emit StartSignal();
}else{
#ifdef VERBOSE
cout<<"Stopping Acquisition"<stopAcquisition();
//btnStartStop->setStyleSheet("color:green");
//btnStartStop->setStyleSheet("background:rgb(239,239,239)");
progressTimer->stop();
@@ -476,6 +476,7 @@ void qTabMeasurement::setTimingMode(int mode){
float time;
int val;
+ qDefs::timeUnit unit;
/**Number of Frames */
if(lblNumFrames->isEnabled()){
val = (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
@@ -487,22 +488,22 @@ void qTabMeasurement::setTimingMode(int mode){
/**Exposure Time */
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
cout<<"Getting acquisition time : " << time << "s" << endl;
#endif
spinExpTime->setValue(time);
- comboExpUnit->setCurrentIndex(qDefs::SECONDS);
+ comboExpUnit->setCurrentIndex((int)unit);
}
/**Frame Period between exposures */
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
cout<<"Getting frame period between exposures : " << time << "s" << endl;
#endif
spinPeriod->setValue(time);
- comboPeriodUnit->setCurrentIndex(qDefs::SECONDS);
+ comboPeriodUnit->setCurrentIndex((int)unit);
int64_t exptimeNS,acqtimeNS;
exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value());
@@ -534,12 +535,12 @@ void qTabMeasurement::setTimingMode(int mode){
/**Delay After Trigger */
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
cout<<"Getting delay after trigger : " << time << "s" << endl;
#endif
spinDelay->setValue(time);
- comboDelayUnit->setCurrentIndex(qDefs::SECONDS);
+ comboDelayUnit->setCurrentIndex((int)unit);
}
/**Number of Gates */
diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp
index 9ab78a281..2f3be9d58 100644
--- a/slsDetectorGui/src/qTabPlot.cpp
+++ b/slsDetectorGui/src/qTabPlot.cpp
@@ -17,8 +17,6 @@
using namespace std;
-#define Detector_Index 0
-
QString qTabPlot::defaultPlotTitle("Measurement");
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){
setupUi(this);
- if(myDet){
- SetupWidgetWindow();
- /** Depending on whether the detector is 1d or 2d*/
- switch(myDet->getDetectorsType()){
- case slsDetectorDefs::MYTHEN: Select1DPlot(true); break;
- case slsDetectorDefs::EIGER: Select1DPlot(false);break;
- case slsDetectorDefs::GOTTHARD: Select1DPlot(true);break;
- default:
- cout<<"ERROR: Detector Type is Generic"<getDetectorsType()){
+ case slsDetectorDefs::MYTHEN: Select1DPlot(true); break;
+ case slsDetectorDefs::EIGER: Select1DPlot(false);break;
+ case slsDetectorDefs::GOTTHARD: Select1DPlot(true);break;
+ default:
+ cout<<"ERROR: Detector Type is Generic"<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){
- slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index,Detector_Index);
+ slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index,detID);
#ifdef VERBOSE
cout<<"Settings have been set to "<slsDetectorBase::getDetectorSettings(sett)<