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 SlsQt2DPlotLayout;
/** Qt Include Headers */
#include <QFrame>
#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QGridLayout>
#include <QCloseEvent>
#include <QGroupBox>
@ -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<SlsQtH1D*> 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:

View File

@ -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

View File

@ -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
*/

View File

@ -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:

View File

@ -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:

View File

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

View File

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

View File

@ -7,30 +7,33 @@
/** Qt Project Class Headers */
#include "qCloneWidget.h"
#include "qDefs.h"
#include "SlsQt1DPlot.h"
#include "SlsQt2DPlotLayout.h"
/** Qt Include Headers */
#include <QImage>
#include <QPainter>
#include <QFileDialog>
/** C++ Include Headers */
#include <iostream>
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,35 +113,36 @@ 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_num<nHists;hist_num++){
/** for each plot*/
for(int hist_num=0;hist_num<nHists;hist_num++){
/** create hists */
SlsQtH1D* k;
if(hist_num+1>cloneplot1D_hists.size()){
@ -140,27 +154,47 @@ for(int hist_num=0;hist_num<nHists;hist_num++){
}
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();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -21,13 +21,13 @@
#include <string>
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; 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<<"-help \t\t : \t This help"<<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<<"Required only when more than one detector is connected in parallel."<<endl;
cout<<"-id i \t : \t Sets the detector to id i (the default is 0). "
"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(){
SetUpDetector();
/** Layout */
layoutTabs= new QGridLayout;
centralwidget->setLayout(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<<endl<<"No Detector Connected"<<endl;
cout<<endl<<"No Detector Connected at id:"<<detID<<endl;
cout<<myDet->getHostname(detID)<<endl;
#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{
/** Check if type valid. If not, exit*/
@ -152,14 +157,18 @@ void qDetectorMain::SetUpDetector(){
case slsDetectorDefs::GOTTHARD: break;
default:
string detName = myDet->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<<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
myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
}

View File

@ -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
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -85,15 +50,16 @@ void qDrawPlot::SetupWidgetWindow(){
#ifdef VERBOSE
cout<<"Setting up plot variables"<<endl;
#endif
numberOfMeasurements=1;
number_of_measurements=1;
currentMeasurement = 0;
stop_signal = 0;
pthread_mutex_init(&last_image_complete_mutex,NULL);
gui_acquisition_thread_running = 0;
//gui_acquisition_thread_running = 0;
/** Default Plotting*/
plot_in_scope = 0;
/**2d*/
lastImageNumber = 0;
last_plot_number = 0;
nPixelsX = 1280; nPixelsY = 100;
@ -183,7 +149,21 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
StartDaq(0);
running=!running;
}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;
}
}
@ -193,23 +173,14 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
void qDrawPlot::StartDaq(bool start){
if(start){
#ifdef VERBOSE
cout<<"Start Daq(1) function"<<endl;
cout<<"Start Daq(true) function"<<endl;
#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();
StartDaqForGui();
UpdatePlot();
}else{
#ifdef VERBOSE
cout<<"Start Daq(0) function"<<endl;
cout<<"Start Daq(false) function"<<endl;
#endif
StopDaqForGui();
StopUpdatePlot();
@ -220,6 +191,7 @@ void qDrawPlot::StartDaq(bool start){
int qDrawPlot::ResetDaqForGui(){
if(!StopDaqForGui()) return 0;
cout<<"Resetting image number"<<endl;
lastImageNumber = 0;
return 1;
}
@ -227,6 +199,7 @@ int qDrawPlot::ResetDaqForGui(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
bool qDrawPlot::StartOrStopThread(bool start){
static bool gui_acquisition_thread_running = 0;
static pthread_t gui_acquisition_thread;
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
if(gui_acquisition_thread_running){
cout<<"Stopping current acquisition thread ...."<<endl;
stop_signal = 1;
myDet->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 ...."<<endl;
cout<<"Starting new acquisition threadddd ...."<<endl;
/** Setting the callback function to get data from software client*/
myDet->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"<<endl;
cout<<"Started acquiring threaddd"<<endl;
}
pthread_mutex_unlock(&gui_acquisition_start_stop_mutex);
return gui_acquisition_thread_running;
@ -271,16 +246,26 @@ bool qDrawPlot::StartOrStopThread(bool start){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void* qDrawPlot::DataStartAcquireThread(void *this_pointer){
cout<<"before acquire ...."<<endl;
((qDrawPlot*)this_pointer)->myDet->acquire(1);
cout<<"after acquire ...."<<endl;
return this_pointer;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::GetDataCallBack(detectorData *data){
#ifdef VERYVERBOSE
cout<<"Entering GetDataCallBack function"<<endl;
#endif
int qDrawPlot::GetDataCallBack(detectorData *data, void *this_pointer){
((qDrawPlot*)this_pointer)->GetData(data);
return 0;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::GetData(detectorData *data){
//#ifdef VERYVERBOSE
cout<<"Entering GetDatafunction"<<endl;
//#endif
progress=(int)data->progressIndex;
if(!plotEnable) {
@ -338,7 +323,7 @@ int qDrawPlot::GetDataCallBack(detectorData *data){
currentFrame++;
}
#ifdef VERYVERBOSE
cout<<"Exiting GetDataCallBack function"<<endl;
cout<<"Exiting GetData function"<<endl;
#endif
return 0;
}
@ -346,7 +331,7 @@ int qDrawPlot::GetDataCallBack(detectorData *data){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::setNumMeasurements(int num){
numberOfMeasurements = num;
number_of_measurements = num;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -380,7 +365,7 @@ void qDrawPlot::Clear1DPlot(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::UpdatePlot(){
static int last_plot_number = 0;
//static int last_plot_number = 0;
plot_update_timer->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:"<<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;
#define Detector_Index 0
qTabActions::qTabActions(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
if(myDet)
{
SetupWidgetWindow();
Initialization();
}
}

View File

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

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -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"<<endl;
#endif
myDet->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 */

View File

@ -17,8 +17,6 @@
using namespace std;
#define Detector_Index 0
QString qTabPlot::defaultPlotTitle("Measurement");
QString qTabPlot::defaultHistXAxisTitle("Channel Number");
@ -30,7 +28,6 @@ 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()){
@ -42,7 +39,6 @@ qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot
exit(-1);
}
Initialization();
}
}

View File

@ -15,17 +15,13 @@
using namespace std;
#define Detector_Index 0
qTabSettings::qTabSettings(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
qTabSettings::qTabSettings(QWidget *parent,slsDetectorUtils*& detector,int detID):
QWidget(parent),myDet(detector),detID(detID){
setupUi(this);
if(myDet)
{
SetupWidgetWindow();
Initialization();
}
}
@ -40,7 +36,7 @@ qTabSettings::~qTabSettings(){
void qTabSettings::SetupWidgetWindow(){
/** 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){
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 "<<myDet->slsDetectorBase::getDetectorSettings(sett)<<endl;
#endif