merging refactor (replacing)

This commit is contained in:
2019-04-12 10:53:09 +02:00
parent 0bb800cc8a
commit 89a06f099c
1176 changed files with 82698 additions and 159058 deletions

View File

@@ -1,219 +0,0 @@
/*
* qActionsWidget.cpp
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
// Project Class Headers
#include "slsDetector.h"
#include "multiSlsDetector.h"
// Qt Project Class Headers
#include "qActionsWidget.h"
// Qt Include Headers
#include <QFileDialog>
// C++ Include Headers
#include<iostream>
using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qActionsWidget::NUM_ACTION_WIDGETS(0);
//-------------------------------------------------------------------------------------------------------------------------------------------------
qActionsWidget::qActionsWidget(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector){
setupUi(this);
SetupWidgetWindow();
Initialization();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
qActionsWidget::~qActionsWidget(){
delete myDet;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qActionsWidget::SetupWidgetWindow(){
id = NUM_ACTION_WIDGETS;
NUM_ACTION_WIDGETS++;
setFixedHeight(25);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qActionsWidget::Initialization(){
//mode
connect(comboScript, SIGNAL(currentIndexChanged(int)), this,SLOT(SetMode(int)));
//file
connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
connect(btnBrowse, SIGNAL(clicked()), this, SLOT(BrowsePath()));
//parameter
connect(dispParameter, SIGNAL(editingFinished()), this, SLOT(SetParameter()));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qActionsWidget::SetMode(int mode){
#ifdef VERBOSE
cout << "Setting\taction:" << id << "\tmode:" << mode << endl;
#endif
//enabling/disabling
dispScript->setEnabled(mode);
btnBrowse->setEnabled(mode);
lblParameter->setEnabled(mode);
dispParameter->setEnabled(mode);
QString fName = dispScript->text();
//set the mode
if(mode) myDet->setActionScript(id,fName.toAscii().constData());
else myDet->setActionScript(id,"");
//mode is not set when fname is blank
if(!fName.isEmpty()){
//check if mode didnt get set
if(mode!=myDet->getActionMode(id)){
qDefs::Message(qDefs::WARNING,"The mode could not be changed.","qActionsWidget::SetMode");
comboScript->setCurrentIndex(myDet->getActionMode(id));
}//if mode got set and its custom script
else if(mode){
//when the file name did not get set correctly
if(fName.compare(QString(myDet->getActionScript(id).c_str()))){
qDefs::Message(qDefs::WARNING,"The file path could not be set.","qActionsWidget::SetMode");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
SetScriptFile();
}
}
}
qDefs::checkErrorMessage(myDet,"qActionsWidget::SetMode");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qActionsWidget::BrowsePath(){
#ifdef VERBOSE
cout << "Browsing Script File Path" << endl;
#endif
QString fName = dispScript->text();
QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep);
if(dir.isEmpty()) dir = "/home";
//dialog
fName = QFileDialog::getOpenFileName(this,
tr("Load Script File"),dir,
tr("Script Files(*.awk);;All Files(*)"));
//if empty, set the file name and it calls setscriptfile, else ignore
if (!fName.isEmpty()){
dispScript->setText(fName);
SetScriptFile();
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qActionsWidget::SetScriptFile(){
QString fName = dispScript->text();
#ifdef VERBOSE
cout << "Setting\taction:" << id << "\tscript:" << fName.toAscii().constData() << endl;
#endif
bool set = false;
struct stat st_buf;
//blank
if(fName.isEmpty())
set = true;
else if(!fName.compare("none"))
set = true;
//not blank
else{
//path doesnt exist
if(stat(fName.toAscii().constData(),&st_buf)){
qDefs::Message(qDefs::WARNING,"The script file entered does not exist","qActionsWidget::SetScriptFile");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
//if its not a file
else if (!S_ISREG (st_buf.st_mode)) {
qDefs::Message(qDefs::WARNING,"The script file path entered is not a file","qActionsWidget::SetScriptFile");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
else
set=true;
}
//if blank or valid file
if(set){
//scan and positions wouldnt get here
myDet->setActionScript(id,fName.toAscii().constData());
if(fName.compare(QString(myDet->getActionScript(id).c_str()))){
//did not get set, write what is was before
if(!fName.isEmpty())
qDefs::Message(qDefs::WARNING,"The script file could not be set. Reverting to previous file.","qActionsWidget::SetScriptFile");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
}
//dont display if theres a none
if(!dispScript->text().compare("none")) dispScript->setText("");
qDefs::checkErrorMessage(myDet,"qActionsWidget::SetScriptFile");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qActionsWidget::SetParameter(){
QString parameter = dispParameter->text();
#ifdef VERBOSE
cout << "Setting\taction:" << id << "\tparameter:" << parameter.toAscii().constData() << endl;
#endif
myDet->setActionParameter(id,parameter.toAscii().constData());
//dont display if theres a none
if(!dispParameter->text().compare("none")) dispParameter->setText("");
qDefs::checkErrorMessage(myDet,"qActionsWidget::SetParameter");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qActionsWidget::Refresh(){
int mode = (myDet->getActionMode(id)>0?1:0);
string script = myDet->getActionScript(id);
string parameter = myDet->getActionParameter(id);
//settings values and checking for none
if(QString(script.c_str()).compare("none"))
dispScript->setText(QString(script.c_str()));
if(mode)SetScriptFile();
dispParameter->setText(QString(parameter.c_str()));
SetParameter();
//set mode which also checks everything
comboScript->setCurrentIndex(mode);
#ifdef VERBOSE
cout << "Updated\taction:" << id << "\t"
"mode:"<<mode<<"\t"
"script:" << script << "\t"
"parameter:" << parameter << "\t***" << endl;
#endif
qDefs::checkErrorMessage(myDet,"qActionsWidget::Refresh");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

622
slsDetectorGui/src/qCloneWidget.cpp Normal file → Executable file
View File

@@ -1,359 +1,341 @@
/*
* qCloneWidget.cpp
*
* Created on: May 18, 2012
* Author: l_maliakal_d
*/
/** Qt Project Class Headers */
#include "qCloneWidget.h"
/** Qt Include Headers */
#include "qDefs.h"
#include "qwt_symbol.h"
#include <QFileDialog>
#include <QImage>
#include <QPainter>
#include <QFileDialog>
#include "qwt_symbol.h"
/** C++ Include Headers */
qCloneWidget::qCloneWidget(QWidget *parent, int id, QString title, QString xTitle, QString yTitle, QString zTitle,
int numDim, std::string FilePath, bool displayStats, QString min, QString max, QString sum) : QMainWindow(parent), id(id), filePath(FilePath), cloneplot1D(0), cloneplot2D(0) {
// Window title
char winTitle[300], currTime[50];
strcpy(currTime, GetCurrentTimeStamp());
sprintf(winTitle, "Snapshot:%d - %s", id, currTime);
setWindowTitle(QString(winTitle));
marker = new QwtSymbol();
nomarker = new QwtSymbol();
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5, 5);
//-------------------------------------------------------------------------------------------------------------------------------------------------
qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,QString xTitle, QString yTitle, QString zTitle,
int numDim,string FilePath,bool displayStats, QString min, QString max, QString sum):
QMainWindow(parent),id(id),filePath(FilePath),cloneplot1D(0),cloneplot2D(0)
{
// Window title
char winTitle[300],currTime[50];
strcpy(currTime,GetCurrentTimeStamp());
sprintf(winTitle,"Snapshot:%d - %s",id,currTime);
setWindowTitle(QString(winTitle));
marker = new QwtSymbol();
nomarker = new QwtSymbol();
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5,5);
// Set up widget
SetupWidgetWindow(title,xTitle, yTitle, zTitle, numDim);
DisplayStats(displayStats,min,max,sum);
// Set up widget
SetupWidgetWindow(title, xTitle, yTitle, zTitle, numDim);
DisplayStats(displayStats, min, max, sum);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
qCloneWidget::~qCloneWidget(){
delete cloneplot1D;
delete cloneplot2D;
delete cloneBox;
qCloneWidget::~qCloneWidget() {
delete cloneplot1D;
delete cloneplot2D;
delete cloneBox;
cloneplot1D_hists.clear();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim){
menubar = new QMenuBar(this);
actionSave = new QAction("&Save",this);
menubar->addAction(actionSave);
setMenuBar(menubar);
//Main Window Layout
QWidget *centralWidget = new QWidget(this);
mainLayout = new QGridLayout(centralWidget);
centralWidget->setLayout(mainLayout);
//plot group box
cloneBox = new QGroupBox(this);
gridClone = new QGridLayout(cloneBox);
cloneBox->setLayout(gridClone);
cloneBox->setContentsMargins(0,0,0,0);
cloneBox->setAlignment(Qt::AlignHCenter);
cloneBox->setFont(QFont("Sans Serif",11,QFont::Normal));
cloneBox->setTitle(title);
// According to dimensions, create appropriate 1D or 2Dplot
if(numDim==1){
cloneplot1D = new SlsQt1DPlot(cloneBox);
cloneplot1D->setFont(QFont("Sans Serif",9,QFont::Normal));
cloneplot1D->SetXTitle(xTitle.toAscii().constData());
cloneplot1D->SetYTitle(yTitle.toAscii().constData());
cloneBox->setFlat(false);
cloneBox->setContentsMargins(0,30,0,0);
gridClone->addWidget(cloneplot1D,0,0);
lblHistTitle = new QLabel("");
mainLayout->addWidget(lblHistTitle,0,0);
}else{
cloneplot2D = new SlsQt2DPlotLayout(cloneBox);
cloneplot2D->setFont(QFont("Sans Serif",9,QFont::Normal));
cloneplot2D->SetXTitle(xTitle);
cloneplot2D->SetYTitle(yTitle);
cloneplot2D->SetZTitle(zTitle);
cloneplot2D->setAlignment(Qt::AlignLeft);
cloneBox->setFlat(true);
cloneBox->setContentsMargins(0,20,0,0);
gridClone->addWidget(cloneplot2D,0,0);
}
// main window widgets
mainLayout->addWidget(cloneBox,1,0);
setCentralWidget(centralWidget);
// Save
connect(actionSave,SIGNAL(triggered()),this,SLOT(SavePlot()));
setMinimumHeight(300);
resize(500,350);
SlsQt1DPlot* qCloneWidget::Get1dPlot() {
return cloneplot1D;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[],bool lines,bool markers){
//for each plot, create hists
for(int hist_num=0;hist_num<nHists;hist_num++){
SlsQtH1D* k;
if(hist_num+1>cloneplot1D_hists.size()){
cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis[hist_num]));
k->SetLineColor(0);
}else{
k=cloneplot1D_hists.at(hist_num);
k->SetData(histNBins,histXAxis,histYAxis[hist_num]);
}
void qCloneWidget::SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim) {
QMenuBar* menubar = new QMenuBar(this);
QAction* actionSave = new QAction("&Save", this);
menubar->addAction(actionSave);
setMenuBar(menubar);
//Main Window Layout
QWidget *centralWidget = new QWidget(this);
mainLayout = new QGridLayout(centralWidget);
centralWidget->setLayout(mainLayout);
//plot group box
cloneBox = new QGroupBox(this);
QGridLayout* gridClone = new QGridLayout(cloneBox);
cloneBox->setLayout(gridClone);
cloneBox->setContentsMargins(0, 0, 0, 0);
cloneBox->setAlignment(Qt::AlignHCenter);
cloneBox->setFont(QFont("Sans Serif", 11, QFont::Normal));
cloneBox->setTitle(title);
// According to dimensions, create appropriate 1D or 2Dplot
if (numDim == 1) {
cloneplot1D = new SlsQt1DPlot(cloneBox);
cloneplot1D->setFont(QFont("Sans Serif", 9, QFont::Normal));
cloneplot1D->SetXTitle(xTitle.toAscii().constData());
cloneplot1D->SetYTitle(yTitle.toAscii().constData());
cloneBox->setFlat(false);
cloneBox->setContentsMargins(0, 30, 0, 0);
gridClone->addWidget(cloneplot1D, 0, 0);
lblHistTitle = new QLabel("");
mainLayout->addWidget(lblHistTitle, 0, 0);
} else {
cloneplot2D = new SlsQt2DPlotLayout(cloneBox);
cloneplot2D->setFont(QFont("Sans Serif", 9, QFont::Normal));
cloneplot2D->SetXTitle(xTitle);
cloneplot2D->SetYTitle(yTitle);
cloneplot2D->SetZTitle(zTitle);
cloneplot2D->setAlignment(Qt::AlignLeft);
cloneBox->setFlat(true);
cloneBox->setContentsMargins(0, 20, 0, 0);
gridClone->addWidget(cloneplot2D, 0, 0);
}
// main window widgets
mainLayout->addWidget(cloneBox, 1, 0);
setCentralWidget(centralWidget);
// Save
connect(actionSave, SIGNAL(triggered()), this, SLOT(SavePlot()));
setMinimumHeight(300);
resize(500, 350);
}
//style of plot
if(lines) k->setStyle(QwtPlotCurve::Lines);
else k->setStyle(QwtPlotCurve::Dots);
#if QWT_VERSION<0x060000
if(markers) k->setSymbol(*marker);
else k->setSymbol(*nomarker);
void qCloneWidget::SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis[], std::string histTitle[], bool lines, bool markers) {
//for each plot, create hists
for (int hist_num = 0; hist_num < nHists; ++hist_num) {
SlsQtH1D *k;
if (hist_num + 1 > cloneplot1D_hists.size()) {
cloneplot1D_hists.append(k = new SlsQtH1D("1d plot", histNBins, histXAxis, histYAxis[hist_num]));
k->SetLineColor(0);
} else {
k = cloneplot1D_hists.at(hist_num);
k->SetData(histNBins, histXAxis, histYAxis[hist_num]);
}
//style of plot
if (lines)
k->setStyle(QwtPlotCurve::Lines);
else
k->setStyle(QwtPlotCurve::Dots);
#if QWT_VERSION < 0x060000
if (markers)
k->setSymbol(*marker);
else
k->setSymbol(*nomarker);
#else
if(markers) k->setSymbol(marker);
else k->setSymbol(nomarker);
if (markers)
k->setSymbol(marker);
else
k->setSymbol(nomarker);
#endif
//set title and attach plot
lblHistTitle->setText(QString(histTitle[0].c_str()));
//set title and attach plot
lblHistTitle->setText(QString(histTitle[0].c_str()));
k->Attach(cloneplot1D);
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis,string histTitle[],bool lines,bool markers){
// for each plot create hists
for(int hist_num=0;hist_num<nHists;hist_num++){
SlsQtH1D* k;
if(hist_num+1>cloneplot1D_hists.size()){
cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis));
k->SetLineColor(hist_num+1);
}else{
k=cloneplot1D_hists.at(hist_num);
k->SetData(histNBins,histXAxis,histYAxis);
}
//style of plot
if(lines) k->setStyle(QwtPlotCurve::Lines);
else k->setStyle(QwtPlotCurve::Dots);
if(markers) {
QwtSymbol *marker = new QwtSymbol();
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5,5);
#if QWT_VERSION<0x060000
k->setSymbol(*marker);
#else
k->setSymbol(marker);
#endif
}else {
QwtSymbol *noMarker = new QwtSymbol();
#if QWT_VERSION<0x060000
k->setSymbol(*noMarker);
#else
k->setSymbol(noMarker);
#endif
}
//set title and attach plot
lblHistTitle->setText(QString(histTitle[0].c_str()));
k->Attach(cloneplot1D);
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetCloneHists2D(int nbinsx,double xmin,double xmax,int nbinsy, double ymin, double ymax, double *d){
cloneplot2D->GetPlot()->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d);
cloneplot2D->UpdateNKeepSetRangeIfSet();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetRange(bool IsXYRange[],double XYRangeValues[]){
double XYCloneRangeValues[4];
if(!IsXYRange[qDefs::XMINIMUM]){
if(cloneplot1D) XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot1D->GetXMinimum();
else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetXMinimum();
}else XYCloneRangeValues[qDefs::XMINIMUM]= XYRangeValues[qDefs::XMINIMUM];
if(!IsXYRange[qDefs::XMAXIMUM]){
if(cloneplot1D) XYCloneRangeValues[qDefs::XMAXIMUM]= cloneplot1D->GetXMaximum();
else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetXMaximum();
}else XYCloneRangeValues[qDefs::XMAXIMUM]= XYRangeValues[qDefs::XMAXIMUM];
if(!IsXYRange[qDefs::YMINIMUM]){
if(cloneplot1D) XYCloneRangeValues[qDefs::YMINIMUM]= cloneplot1D->GetYMinimum();
else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetYMinimum();
}else XYCloneRangeValues[qDefs::YMINIMUM]= XYRangeValues[qDefs::YMINIMUM];
if(!IsXYRange[qDefs::YMAXIMUM]){
if(cloneplot1D) XYCloneRangeValues[qDefs::YMAXIMUM]= cloneplot1D->GetYMaximum();
else XYCloneRangeValues[qDefs::XMINIMUM]= cloneplot2D->GetPlot()->GetYMaximum();
}else XYCloneRangeValues[qDefs::YMAXIMUM]= XYRangeValues[qDefs::YMAXIMUM];
if(cloneplot1D){
cloneplot1D->SetXMinMax(XYCloneRangeValues[qDefs::XMINIMUM],XYCloneRangeValues[qDefs::XMAXIMUM]);
cloneplot1D->SetYMinMax(XYCloneRangeValues[qDefs::YMINIMUM],XYCloneRangeValues[qDefs::YMAXIMUM]);
}else{
cloneplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]);
cloneplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
cloneplot2D->GetPlot()->Update();
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
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(){
char cID[10];
sprintf(cID,"%d",id);
//title
QString fName = QString(filePath.c_str());
if(cloneBox->title().contains('.')){
fName.append(QString('/')+cloneBox->title());
fName.replace(".dat",".png");
fName.replace(".raw",".png");
}else fName.append(QString("/Snapshot_unknown_title.png"));
//save
QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32);
QPainter painter(&img);
cloneBox->render(&painter);
fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),fName,tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"),0,QFileDialog::ShowDirsOnly);
if (!fName.isEmpty()) {
if((img.save(fName)))
qDefs::Message(qDefs::INFORMATION,"The SnapShot has been successfully saved","qCloneWidget::SavePlot");
else
qDefs::Message(qDefs::WARNING,"Attempt to save snapshot failed.\n"
"Formats: .png, .jpg, .xpm.","qCloneWidget::SavePlot");
k->Attach(cloneplot1D);
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qCloneWidget::SavePlotAutomatic(){
char cID[10];
sprintf(cID,"%d",id);
//title
QString fName = QString(filePath.c_str());
if(cloneBox->title().contains('.')){
fName.append(QString('/')+cloneBox->title());
fName.replace(".dat",".png");
fName.replace(".raw",".png");
}else fName.append(QString("/Snapshot_unknown_title.png"));
cout<<"fname:"<<fName.toAscii().constData()<<endl;
//save
QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32);
QPainter painter(&img);
cloneBox->render(&painter);
if(img.save(fName))
return 0;
else return -1;
void qCloneWidget::SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis, std::string histTitle[], bool lines, bool markers) {
// for each plot create hists
for (int hist_num = 0; hist_num < nHists; ++hist_num) {
SlsQtH1D *k;
if (hist_num + 1 > cloneplot1D_hists.size()) {
cloneplot1D_hists.append(k = new SlsQtH1D("1d plot", histNBins, histXAxis, histYAxis));
k->SetLineColor(hist_num + 1);
} else {
k = cloneplot1D_hists.at(hist_num);
k->SetData(histNBins, histXAxis, histYAxis);
}
//style of plot
if (lines)
k->setStyle(QwtPlotCurve::Lines);
else
k->setStyle(QwtPlotCurve::Dots);
if (markers) {
QwtSymbol *marker = new QwtSymbol();
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5, 5);
#if QWT_VERSION < 0x060000
k->setSymbol(*marker);
#else
k->setSymbol(marker);
#endif
} else {
QwtSymbol *noMarker = new QwtSymbol();
#if QWT_VERSION < 0x060000
k->setSymbol(*noMarker);
#else
k->setSymbol(noMarker);
#endif
}
//set title and attach plot
lblHistTitle->setText(QString(histTitle[0].c_str()));
k->Attach(cloneplot1D);
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::closeEvent(QCloseEvent* event){
emit CloneClosedSignal(id);
event->accept();
void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d) {
cloneplot2D->GetPlot()->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d);
cloneplot2D->UpdateNKeepSetRangeIfSet();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SetRange(bool IsXYRange[], double XYRangeValues[]) {
double XYCloneRangeValues[4];
if (!IsXYRange[qDefs::XMINIMUM]) {
if (cloneplot1D)
XYCloneRangeValues[qDefs::XMINIMUM] = cloneplot1D->GetXMinimum();
else
XYCloneRangeValues[qDefs::XMINIMUM] = cloneplot2D->GetPlot()->GetXMinimum();
} else
XYCloneRangeValues[qDefs::XMINIMUM] = XYRangeValues[qDefs::XMINIMUM];
void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum){
if(enable){
QWidget *widgetStatistics = new QWidget(this);
widgetStatistics->setFixedHeight(15);
QHBoxLayout *hl1 = new QHBoxLayout;
hl1->setSpacing(0);
hl1->setContentsMargins(0, 0, 0, 0);
QLabel *lblMin = new QLabel("Min: ");
lblMin->setFixedWidth(40);
lblMin->setAlignment(Qt::AlignRight);
QLabel *lblMax = new QLabel("Max: ");
lblMax->setFixedWidth(40);
lblMax->setAlignment(Qt::AlignRight);
QLabel *lblSum = new QLabel("Sum: ");
lblSum->setFixedWidth(40);
lblSum->setAlignment(Qt::AlignRight);
QLabel *lblMinDisp = new QLabel(min);
lblMinDisp->setAlignment(Qt::AlignLeft);
QLabel *lblMaxDisp = new QLabel(max);
lblMaxDisp->setAlignment(Qt::AlignLeft);
QLabel *lblSumDisp = new QLabel(sum);
lblSumDisp->setAlignment(Qt::AlignLeft);
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
hl1->addWidget(lblMin);
hl1->addWidget(lblMinDisp);
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed));
hl1->addWidget(lblMax);
hl1->addWidget(lblMaxDisp);
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed));
hl1->addWidget(lblSum);
hl1->addWidget(lblSumDisp);
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
widgetStatistics->setLayout(hl1);
mainLayout->addWidget(widgetStatistics,2,0);
widgetStatistics->show();
if (!IsXYRange[qDefs::XMAXIMUM]) {
if (cloneplot1D)
XYCloneRangeValues[qDefs::XMAXIMUM] = cloneplot1D->GetXMaximum();
else
XYCloneRangeValues[qDefs::XMAXIMUM] = cloneplot2D->GetPlot()->GetXMaximum();
} else
XYCloneRangeValues[qDefs::XMAXIMUM] = XYRangeValues[qDefs::XMAXIMUM];
}
if (!IsXYRange[qDefs::YMINIMUM]) {
if (cloneplot1D)
XYCloneRangeValues[qDefs::YMINIMUM] = cloneplot1D->GetYMinimum();
else
XYCloneRangeValues[qDefs::YMINIMUM] = cloneplot2D->GetPlot()->GetYMinimum();
} else
XYCloneRangeValues[qDefs::YMINIMUM] = XYRangeValues[qDefs::YMINIMUM];
if (!IsXYRange[qDefs::YMAXIMUM]) {
if (cloneplot1D)
XYCloneRangeValues[qDefs::YMAXIMUM] = cloneplot1D->GetYMaximum();
else
XYCloneRangeValues[qDefs::YMAXIMUM] = cloneplot2D->GetPlot()->GetYMaximum();
} else
XYCloneRangeValues[qDefs::YMAXIMUM] = XYRangeValues[qDefs::YMAXIMUM];
if (cloneplot1D) {
cloneplot1D->SetXMinMax(XYCloneRangeValues[qDefs::XMINIMUM], XYCloneRangeValues[qDefs::XMAXIMUM]);
cloneplot1D->SetYMinMax(XYCloneRangeValues[qDefs::YMINIMUM], XYCloneRangeValues[qDefs::YMAXIMUM]);
} else {
cloneplot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM], XYRangeValues[qDefs::XMAXIMUM]);
cloneplot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM], XYRangeValues[qDefs::YMAXIMUM]);
cloneplot2D->GetPlot()->Update();
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::SavePlot() {
char cID[10];
sprintf(cID, "%d", id);
//title
QString fName = QString(filePath.c_str());
if (cloneBox->title().contains('.')) {
fName.append(QString('/') + cloneBox->title());
fName.replace(".dat", ".png");
fName.replace(".raw", ".png");
} else
fName.append(QString("/Snapshot_unknown_title.png"));
//save
QImage img(cloneBox->size().width(), cloneBox->size().height(), QImage::Format_RGB32);
QPainter painter(&img);
cloneBox->render(&painter);
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "), fName, tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0, QFileDialog::ShowDirsOnly);
if (!fName.isEmpty()) {
if ((img.save(fName))) {
qDefs::Message(qDefs::INFORMATION, "The SnapShot has been successfully saved", "qCloneWidget::SavePlot");
FILE_LOG(logINFO) << "The SnapShot has been successfully saved";
} else {
qDefs::Message(qDefs::WARNING, "Attempt to save snapshot failed.\n"
"Formats: .png, .jpg, .xpm.",
"qCloneWidget::SavePlot");
FILE_LOG(logWARNING) << "Attempt to save snapshot failed";
}
}
}
int qCloneWidget::SavePlotAutomatic() {
char cID[10];
sprintf(cID, "%d", id);
//title
QString fName = QString(filePath.c_str());
if (cloneBox->title().contains('.')) {
fName.append(QString('/') + cloneBox->title());
fName.replace(".dat", ".png");
fName.replace(".raw", ".png");
} else
fName.append(QString("/Snapshot_unknown_title.png"));
FILE_LOG(logDEBUG) << "fname:" << fName.toAscii().constData();
//save
QImage img(cloneBox->size().width(), cloneBox->size().height(), QImage::Format_RGB32);
QPainter painter(&img);
cloneBox->render(&painter);
if (img.save(fName))
return 0;
else
return -1;
}
void qCloneWidget::closeEvent(QCloseEvent *event) {
emit CloneClosedSignal(id);
event->accept();
}
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::DisplayStats(bool enable, QString min, QString max, QString sum) {
if (enable) {
QWidget *widgetStatistics = new QWidget(this);
widgetStatistics->setFixedHeight(15);
QHBoxLayout *hl1 = new QHBoxLayout;
hl1->setSpacing(0);
hl1->setContentsMargins(0, 0, 0, 0);
QLabel *lblMin = new QLabel("Min: ");
lblMin->setFixedWidth(40);
lblMin->setAlignment(Qt::AlignRight);
QLabel *lblMax = new QLabel("Max: ");
lblMax->setFixedWidth(40);
lblMax->setAlignment(Qt::AlignRight);
QLabel *lblSum = new QLabel("Sum: ");
lblSum->setFixedWidth(40);
lblSum->setAlignment(Qt::AlignRight);
QLabel *lblMinDisp = new QLabel(min);
lblMinDisp->setAlignment(Qt::AlignLeft);
QLabel *lblMaxDisp = new QLabel(max);
lblMaxDisp->setAlignment(Qt::AlignLeft);
QLabel *lblSumDisp = new QLabel(sum);
lblSumDisp->setAlignment(Qt::AlignLeft);
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed));
hl1->addWidget(lblMin);
hl1->addWidget(lblMinDisp);
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));
hl1->addWidget(lblMax);
hl1->addWidget(lblMaxDisp);
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));
hl1->addWidget(lblSum);
hl1->addWidget(lblSumDisp);
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed));
widgetStatistics->setLayout(hl1);
mainLayout->addWidget(widgetStatistics, 2, 0);
widgetStatistics->show();
}
}

1456
slsDetectorGui/src/qDetectorMain.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

3446
slsDetectorGui/src/qDrawPlot.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

530
slsDetectorGui/src/qServer.cpp Normal file → Executable file
View File

@@ -1,431 +1,171 @@
/*
* qServer.cpp
*
* Created on: Feb 27, 2013
* Author: Dhanya Maliakal
*/
// Qt Project Class Headers
#include "qServer.h"
#include "qDetectorMain.h"
// Project Class Headers
#include "slsDetector.h"
#include "ServerSocket.h"
#include "multiSlsDetector.h"
#include "MySocketTCP.h"
// C++ Include Headers
#include "string_utils.h"
#include <iostream>
#include <string>
using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qServer::gui_server_thread_running(0);
//-------------------------------------------------------------------------------------------------------------------------------------------------
qServer::qServer(qDetectorMain *t):
myMainTab(t), mySocket(0),myStopSocket(0),port_no(DEFAULT_GUI_PORTNO),lockStatus(0),checkStarted(0),checkStopStarted(0){
strcpy(mess,"");
FunctionTable();
#include <future>
qServer::qServer(qDetectorMain *t)
: threadRunning(false), threadStarted(false), mainTab(t),
controlPort(DEFAULT_GUI_PORTNO), stopPort(DEFAULT_GUI_PORTNO + 1),
controlSocket(nullptr), stopSocket(nullptr) {
FILE_LOG(logDEBUG) << "Client Server ready";
}
qServer::~qServer() {}
//-------------------------------------------------------------------------------------------------------------------------------------------------
qServer::~qServer(){
delete myMainTab;
if(mySocket) delete mySocket;
if(myStopSocket) delete myStopSocket;
void qServer::FunctionTable() {
flist.push_back(qServer::GetStatus);
flist.push_back(qServer::StartAcquisition);
flist.push_back(qServer::StopsAcquisition);
flist.push_back(qServer::Acquire);
flist.push_back(qServer::ExitServer);
}
int qServer::DecodeFunction(ServerSocket *sock) {
int ret = qDefs::FAIL;
int fnum = 0;
int n = sock->ReceiveDataOnly(&fnum, sizeof(fnum));
if (n <= 0) {
FILE_LOG(logDEBUG3) << "Received " << n << " bytes";
throw sls::RuntimeError("Could not read socket");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
// unrecognized function
if (fnum < 0 && fnum >= qDefs::NUM_GUI_FUNCS) {
ret = qDefs::FAIL;
char mess[MAX_STR_LENGTH] = {};
sls::strcpy_safe(mess, "Unrecognized function");
// will throw an exception
sock->SendResult(ret, nullptr, 0, mess);
}
// calling function
FILE_LOG(logDEBUG1) << "calling function fnum: " << fnum;
ret = (this->*flist[fnum])();
int qServer::FunctionTable(){
flist[F_GET_RUN_STATUS] = &qServer::GetStatus;
flist[F_START_ACQUISITION] = &qServer::StartAcquisition;
flist[F_STOP_ACQUISITION] = &qServer::StopsAcquisition;
flist[F_START_AND_READ_ALL] = &qServer::Acquire;
flist[F_EXIT_SERVER] = &qServer::ExitServer;
return qDefs::OK;
return ret;
}
//------------------------------------------------------------------------------------------------------------------------------------------
int qServer::DecodeFunction(MySocketTCP* sock){
int ret = qDefs::FAIL;
int n,fnum;
#ifdef VERYVERBOSE
cout << "receive data" << endl;
#endif
n = sock->ReceiveDataOnly(&fnum,sizeof(fnum));
if (n <= 0) {
#ifdef VERYVERBOSE
cout << "ERROR reading from socket " << n << ", " << fnum << endl;
#endif
return qDefs::FAIL;
}
#ifdef VERYVERBOSE
else
cout << "size of data received " << n <<endl;
#endif
#ifdef VERYVERBOSE
cout << "calling function fnum = "<< fnum << hex << ":"<< flist[fnum] << endl;
#endif
if (((sock == myStopSocket) && ((fnum == F_GET_RUN_STATUS) || (fnum == F_STOP_ACQUISITION) || (fnum == F_EXIT_SERVER))) ||
((sock == mySocket) && ((fnum == F_START_ACQUISITION) || (fnum == F_START_AND_READ_ALL))))
;
//unrecognized functions exit guis
else{
ret = qDefs::FAIL;
sprintf(mess,"Unrecognized Function\n");
cout << mess << endl;
if (mySocket)
mySocket->ShutDownSocket();
myStopSocket->SendDataOnly(&ret,sizeof(ret));
myStopSocket->SendDataOnly(mess,sizeof(mess));
return GOODBYE;
}
//calling function
ret = (this->*flist[fnum])();
if (ret==qDefs::FAIL)
cout << "Error executing the function = " << fnum << endl;
return ret;
void qServer::ShutDownSockets() {
threadRunning = false;
if (controlSocket) {
controlSocket->shutDownSocket();
delete controlSocket;
controlSocket = nullptr;
}
if (stopSocket) {
stopSocket->shutDownSocket();
delete stopSocket;
stopSocket = nullptr;
}
}
//------------------------------------------------------------------------------------------------------------------------------------------
int qServer::ExitServer(){
int ret = OK;
strcpy(mess," Gui Server closed successfully\n");
if(mySocket)
mySocket->ShutDownSocket();
myStopSocket->SendDataOnly(&ret,sizeof(ret));
myStopSocket->SendDataOnly(mess,sizeof(mess));
cout << mess << endl;
return GOODBYE;
void qServer::CreateServers() {
if (!threadRunning) {
FILE_LOG(logINFO) << "Starting Gui Servers";
threadRunning = true;
try {
// start control server
controlSocket = new ServerSocket(controlPort);
std::async(std::launch::async, ServerThread, controlSocket);
FILE_LOG(logDEBUG)
<< "Gui control server thread created successfully.";
// start stop server
stopSocket = new ServerSocket(stopPort);
std::async(std::launch::async, ServerThread, stopSocket);
FILE_LOG(logDEBUG)
<< "Gui stop server thread created successfully.";
} catch (...) {
ShutDownSockets();
std::string message = "Can't create gui control server thread";
FILE_LOG(logERROR) << message;
qDefs::Message(qDefs::WARNING, message, "qServer::CreateServers");
}
}
}
//------------------------------------------------------------------------------------------------------------------------------------------
int qServer::StartStopServer(int start){
//start server
if(start){
#ifdef VERBOSE
cout << endl << "Starting Gui Server" << endl;
#endif
if(!gui_server_thread_running){
gui_server_thread_running=1;
//error creating thread
checkStarted=1;
if (pthread_create(&gui_server_thread, NULL,StartServerThread, (void*) this)){
gui_server_thread_running=0;
qDefs::Message(qDefs::WARNING,"Can't create gui server thread", "qServer::StartStopServer");
cout << "ERROR: Can't create gui server thread" << endl;
return FAIL;
}
while(checkStarted);
checkStarted = 0;
#ifdef VERBOSE
if(gui_server_thread_running)
cout << "Server thread created successfully." << endl;
#endif
//error creating thread
checkStopStarted=1;
if (pthread_create(&gui_stop_server_thread, NULL,StopServerThread, (void*) this)){
gui_server_thread_running=0;
qDefs::Message(qDefs::WARNING,"Can't create gui stop server thread", "qServer::StartStopServer");
cout << "ERROR: Can't create gui stop server thread" << endl;
return FAIL;
}
while(checkStopStarted);
checkStopStarted=0;
#ifdef VERBOSE
if(gui_server_thread_running)
cout << "Server Stop thread created successfully." << endl;
#endif
}
}
//stop server
else{
#ifdef VERBOSE
cout << "Stopping Gui Server" << endl;
#endif
if(gui_server_thread_running){
gui_server_thread_running=0;
if(mySocket)
mySocket->ShutDownSocket();
pthread_join(gui_server_thread,NULL);
if(mySocket){
delete mySocket;
mySocket = 0;
}
if(myStopSocket)
myStopSocket->ShutDownSocket();
pthread_join(gui_stop_server_thread,NULL);
if(myStopSocket){
delete myStopSocket;
myStopSocket = 0;
}
}
#ifdef VERBOSE
cout << "Server threads stopped successfully." << endl;
#endif
}
return gui_server_thread_running;
void qServer::DestroyServers() {
if (threadRunning) {
FILE_LOG(logINFO) << "Stopping Gui Servers";
ShutDownSockets();
FILE_LOG(logDEBUG) << "Server threads stopped successfully.";
}
}
void qServer::ServerThread(ServerSocket* sock) {
FILE_LOG(logDEBUG) << "Starting Gui Server at port " << sock->getPort();
//-------------------------------------------------------------------------------------------------------------------------------------------------
while (threadRunning)) {
try{
sock->accept();
if (DecodeFunction(sock) == GOODBYE) {
threadRunning = false;
}
sock->close();
}
// any fails will throw an exception, which will be displayed at client side. Ignore here
catch (...) {}
}
FILE_LOG(logDEBUG) << "Stopped gui server thread";
void* qServer::StopServerThread(void* this_pointer){
((qServer*)this_pointer)->StopServer();
return this_pointer;
// stop port is closed last
if (sock->getPort() == stopPort)
emit ServerStoppedSignal();
}
int qServer::GetStatus(ServerSock* sock) {
slsDetectorDefs::runStatus status = slsDetectorDefs::ERROR;
int progress = 0;
if (myMainTab->isPlotRunning())
status = slsDetectorDefs::RUNNING;
else
status = slsDetectorDefs::IDLE;
//-------------------------------------------------------------------------------------------------------------------------------------------------
progress = myMainTab->GetProgress();
int qServer::StopServer(){
#ifdef VERYVERBOSE
cout << "In StopServer()" << endl;
#endif
int ret = qDefs::OK;
try {
MySocketTCP* s = new MySocketTCP(port_no+1);
myStopSocket = s;
} catch(...) {
gui_server_thread_running = 0;
qDefs::Message(qDefs::WARNING,"Could not start gui stop server socket","qServer::StopServer");
}
checkStopStarted = 0;
while ((gui_server_thread_running) && (ret!=GOODBYE)) {
#ifdef VERBOSE
cout<< endl;
#endif
#ifdef VERYVERBOSE
cout << "Waiting for client call" << endl;
#endif
if(myStopSocket->Connect()>=0){
#ifdef VERYVERBOSE
cout << "Conenction accepted" << endl;
#endif
ret = DecodeFunction(myStopSocket);
#ifdef VERYVERBOSE
cout << "function executed" << endl;
#endif
myStopSocket->Disconnect();
#ifdef VERYVERBOSE
cout << "connection closed" << endl;
#endif
}
}
#ifdef VERBOSE
cout << "Stopped gui stop server thread" << endl;
#endif
gui_server_thread_running = 0;
//delete socket(via exit server)
if(myStopSocket){
delete myStopSocket;
myStopSocket = 0;
}
if(!gui_server_thread_running)
emit ServerStoppedSignal();
return qDefs::OK;
int ret = qDefs::OK
int retvals[2] = {static_cast<int>(retval), progress};
sock->SendResult(ret, retvals, sizeof(retvals), nullptr);
return ret;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void* qServer::StartServerThread(void* this_pointer){
((qServer*)this_pointer)->StartServer();
return this_pointer;
int qServer::StartAcquisition(ServerSock* sock) {
char mess[MAX_STR_LENGTH] = {};
sls::strcpy_safe(mess, "Could not start acquistion in Gui");
int ret = myMainTab->StartStopAcquisitionFromClient(true);
sock->SendResult(ret, nullptr, 0, mess);
return ret;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qServer::StartServer(){
#ifdef VERYVERBOSE
cout << "In StartServer()" << endl;
#endif
int ret = qDefs::OK;
try {
MySocketTCP* s = new MySocketTCP(port_no);
mySocket = s;
} catch(...) {
gui_server_thread_running = 0;
qDefs::Message(qDefs::WARNING,"Could not start gui server socket","qServer::StartServer");
}
checkStarted = 0;
while ((gui_server_thread_running) && (ret!=GOODBYE)) {
#ifdef VERBOSE
cout<< endl;
#endif
#ifdef VERYVERBOSE
cout << "Waiting for client call" << endl;
#endif
if(mySocket->Connect()>=0){
#ifdef VERYVERBOSE
cout << "Conenction accepted" << endl;
#endif
ret = DecodeFunction(mySocket);
#ifdef VERYVERBOSE
cout << "function executed" << endl;
#endif
mySocket->Disconnect();
#ifdef VERYVERBOSE
cout << "connection closed" << endl;
#endif
}
}
#ifdef VERBOSE
cout << "Stopped gui server thread" << endl;
#endif
gui_server_thread_running = 0;
//delete socket(via exit server)
if(mySocket){
delete mySocket;
mySocket = 0;
}
if(!gui_server_thread_running)
emit ServerStoppedSignal();
return qDefs::OK;
int qServer::StopsAcquisition(ServerSock* sock) {
char mess[MAX_STR_LENGTH] = {};
sls::strcpy_safe(mess, "Could not stop acquistion in Gui");
int ret = myMainTab->StartStopAcquisitionFromClient(false);
sock->SendResult(ret, nullptr, 0, mess);
return ret;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qServer::GetStatus(){
int ret = qDefs::OK;
enum slsDetectorDefs::runStatus retval;
int progress = 0;
// execute action if the arguments correctly arrived
if(myMainTab->isPlotRunning())
retval = slsDetectorDefs::RUNNING;
else
retval = slsDetectorDefs::IDLE;
progress = myMainTab->GetProgress();
// send answer
myStopSocket->SendDataOnly(&ret,sizeof(ret));
myStopSocket->SendDataOnly(&retval,sizeof(retval));
myStopSocket->SendDataOnly(&progress,sizeof(progress));
//return ok/fail
return ret;
int qServer::Acquire(ServerSock* sock) {
char mess[MAX_STR_LENGTH] = {};
sls::strcpy_safe(mess, "Could not start blocking acquistion in Gui");
int ret = myMainTab->StartStopAcquisitionFromClient(true);
// blocking
usleep(5000);
while (myMainTab->isPlotRunning())
;
sock->SendResult(ret, nullptr, 0, mess);
return ret;
}
//------------------------------------------------------------------------------------------------------------------------------------------
int qServer::StartAcquisition(){
strcpy(mess,"Could not start acquisition in gui. \n");
int ret = myMainTab->StartStopAcquisitionFromClient(true);
mySocket->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL)
mySocket->SendDataOnly(mess,sizeof(mess));
return ret;
}
//------------------------------------------------------------------------------------------------------------------------------------------
int qServer::StopsAcquisition(){
strcpy(mess,"Could not stop acquisition in gui. \n");
int ret = myMainTab->StartStopAcquisitionFromClient(false);
myStopSocket->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL)
myStopSocket->SendDataOnly(mess,sizeof(mess));
return ret;
}
//------------------------------------------------------------------------------------------------------------------------------------------
int qServer::Acquire(){
strcpy(mess,"Could not start blocking acquisition in gui. \n");
int ret = myMainTab->StartStopAcquisitionFromClient(true);
usleep(5000);
while(myMainTab->isPlotRunning());
mySocket->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL)
mySocket->SendDataOnly(mess,sizeof(mess));
return ret;
}
//------------------------------------------------------------------------------------------------------------------------------------------
int qServer::ExitServer(ServerSock* sock) {
DestroyServers();
int ret = qDefs::OK;
sock->SendResult(ret, nullptr, 0, mess);
return GOODBYE;
}

View File

@@ -1,585 +0,0 @@
/*
* qTabActions.cpp
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
// Qt Project Class Headers
#include "qTabActions.h"
// Project Class Headers
#include "slsDetector.h"
#include "multiSlsDetector.h"
// Qt Include Headers
#include <QButtonGroup>
// C++ Include Headers
#include<iostream>
using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabActions::qTabActions(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector),
positionWidget(0),
lblNumPos(0),
lblPosList(0),
spinNumPos(0),
comboPos(0),
btnDelete(0),
chkInvert(0),
chkSeparate(0),
chkReturn(0),
positions(0),
iconPlus(0),
iconMinus(0){
for(int i=0;i<6;i++)
actionWidget[i]=0;
for(int i=0;i<2;i++)
scanWidget[i]=0;
for(int i=0;i<NumTotalActions;i++){
btnExpand[i]=0;
lblName[i]=0;
}
SetupWidgetWindow();
Initialization();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabActions::~qTabActions(){
delete myDet;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::SetupWidgetWindow(){
// Window Settings
setFixedHeight(350);
//setFixedSize(710,350);
setContentsMargins(0,0,0,0);
// Scroll Area Settings
QScrollArea *scroll = new QScrollArea;
scroll->setWidget(this);
scroll->setWidgetResizable(true);
// Layout Settings
gridLayout = new QGridLayout(scroll);
setLayout(gridLayout);
gridLayout->setContentsMargins(10,5,0,0);
gridLayout->setVerticalSpacing(2);
// Buttongroup to know which +/- button was clicked
group = new QButtonGroup(this);
group->setExclusive(false);
palette = new QPalette();
QPalette p;
p.setColor(QPalette::Shadow,QColor(0,0,0,0));
p.setColor(QPalette::Button,QColor(0,0,0,0));
/*get rid of this vector*/
char names[NumTotalActions][200] = {
"Action at Start",
"Scan Level 0",
"Scan Level 1",
"Action before each Frame",
"Positions",
"Header before Frame",
"Header after Frame",
"Action after each Frame",
"Action at Stop"
};
//creating the icons for the buttons
iconPlus = new QIcon(":/icons/images/add.png");
iconMinus = new QIcon(":/icons/images/remove.png");
QString tip = "<nobr>Click on the \"+\" to Expand or \"-\" to Collapse.</nobr>";
int hIndent=0, vIndent=0, colspan=6, posVal=0;
QLabel *lblReal;
// For each level of Actions
for(int i=0;i<NumTotalActions;i++){
//common widgets
lblName[i] = new QLabel(QString(names[i]));
btnExpand[i] = new QPushButton();
lblName[i]->setToolTip(tip);
btnExpand[i]->setCheckable(true);
btnExpand[i]->setChecked(false);
btnExpand[i]->setFixedSize(16,16);
btnExpand[i]->setToolTip(tip);
btnExpand[i]->setIcon(*iconPlus);
btnExpand[i]->setFocusPolicy(Qt::NoFocus);
btnExpand[i]->setFlat(true);
btnExpand[i]->setIconSize(QSize(16,16));
btnExpand[i]->setPalette(p);
group->addButton(btnExpand[i],i);
//add label and button to expand or collapse
gridLayout->addWidget(btnExpand[i],vIndent,hIndent,1,1);
gridLayout->addWidget(lblName[i],vIndent,hIndent+1,1,colspan);
//creating the action/scan/position widgets and adding them
switch(i){
case NumPositions:
CreatePositionsWidget();
gridLayout->addWidget(positionWidget,vIndent+1,hIndent+1,1,colspan);
positionWidget->hide();
break;
case Scan0:
case Scan1:
posVal = qScanWidget::NUM_SCAN_WIDGETS;
scanWidget[posVal] = new qScanWidget(this,myDet);
gridLayout->addWidget(scanWidget[posVal],vIndent+1,hIndent+1,1,colspan);
scanWidget[posVal]->hide();
break;
default:
posVal = qActionsWidget::NUM_ACTION_WIDGETS;
actionWidget[posVal] = new qActionsWidget(this,myDet);
gridLayout->addWidget(actionWidget[posVal],vIndent+1,hIndent+1,1,colspan);
actionWidget[posVal]->hide();
break;
}
//incrementing the vertical and horizontal indent
vIndent+=2;
switch(i){
case HeaderBefore:
//real time acquisition
palette->setColor(QPalette::Active,QPalette::WindowText,QColor(0,0,200,255));
lblReal = new QLabel(" <b>Real Time Acquisition</b>");
lblReal->setFixedHeight(25);
//lblReal->setPalette(*palette);
gridLayout->addWidget(lblReal,vIndent,hIndent+1,1,colspan);
vIndent++;
break;
case HeaderAfter:
hIndent-=2;
colspan+=2;
break;
case ActionAfter:
hIndent=0;
colspan=6;
break;
default:
hIndent++;
colspan--;
break;
}
}
//Number of positions is only for mythen or gotthard
detType = myDet->getDetectorsType();
if((detType == slsDetectorDefs::EIGER) ||
(detType == slsDetectorDefs::AGIPD) ||
(detType == slsDetectorDefs::PROPIX) ||
(detType == slsDetectorDefs::JUNGFRAU) ||
(detType == slsDetectorDefs::JUNGFRAUCTB) ||
(detType == slsDetectorDefs::MOENCH)) {
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}else{
//disable positions if angular conversion is enabled
int ang;
if(!myDet->getAngularConversion(ang)){
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}
}
//load positions
if(lblName[NumPositions]->isEnabled()){
//delete existing positions
if (positions) {delete [] positions; positions = NULL;}
//get number of positions
int numPos=myDet->getPositions();
comboPos->setMaxCount(numPos);
//set the number of positions in the gui
spinNumPos->setValue(numPos);
positions=new double[numPos];
//load the positions
myDet->getPositions(positions);
//delete the combolist and reload it
comboPos->setEnabled(numPos);
lblPosList->setEnabled(numPos);
btnDelete->setEnabled(numPos);
lblPosList->setText("List of Positions: ");
lblPosList->setPalette(normal);
for(int i=0;i<comboPos->count();i++) comboPos->removeItem(i);
for(int i=0;i<numPos;i++) comboPos->insertItem(i,QString("%1").arg(positions[i]));
}
qDefs::checkErrorMessage(myDet,"qTabActions::SetupWidgetWindow");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::CreatePositionsWidget(){
positionWidget = new QWidget;
positionWidget->setFixedHeight(25);
positionWidget->setFixedWidth(680);
QGridLayout *layout = new QGridLayout(positionWidget);
layout->setContentsMargins(0,0,0,0);
layout->setHorizontalSpacing(0);
layout->setVerticalSpacing(5);
lblNumPos = new QLabel("Number of Positions: ");
lblNumPos->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layout->addWidget(lblNumPos,0,0);
layout->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
spinNumPos = new QSpinBox(this);
layout->addWidget(spinNumPos,0,2);
layout->addItem(new QSpacerItem(80,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,3);
lblPosList = new QLabel("List of Positions: ");
lblPosList->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
lblPosList->setFixedWidth(108);
lblPosList->setEnabled(false);
lblPosList->setToolTip("<nobr>Enter the positions at which the detector should be moved.</nobr><br>"
"<nobr>Number of entries is restricted to <b>Number of Positions</b> field.</tnobr>");
layout->addWidget(lblPosList,0,4);
comboPos = new QComboBox(this);
comboPos->setEditable(true);
// comboPos->setCompleter(false);
comboPos->setCompleter(NULL);
normal = comboPos->palette();
comboPos->setEnabled(false);
QDoubleValidator *validate = new QDoubleValidator(comboPos);
comboPos->setValidator(validate);
layout->addWidget(comboPos,0,5);
layout->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,6);
btnDelete = new QPushButton("Delete ");
btnDelete->setEnabled(false);
btnDelete->setIcon(QIcon( ":/icons/images/close.png" ));
btnDelete->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layout->addWidget(btnDelete,0,7);
//might be included at some point
/* QGroupBox *w = new QGroupBox;
layout->addWidget(w,1,0,1,9);
QHBoxLayout *l1 = new QHBoxLayout(w);
l1->setContentsMargins(0,0,0,0);
l1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
chkInvert = new QCheckBox("Invert Angles");
l1->addWidget(chkInvert);
chkSeparate = new QCheckBox("Separate Two Halves");
l1->addWidget(chkSeparate);
chkReturn = new QCheckBox("Return to Start Position");
chkReturn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
l1->addWidget(chkReturn);
l1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
w->setLayout(l1);*/
positionWidget->setLayout(layout);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::Initialization(){
//expand
connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
//enable scan box in plot tab
for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++)
connect(scanWidget[i], SIGNAL(EnableScanBox()), this,SIGNAL(EnableScanBox()));
//positions
connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
connect(btnDelete, SIGNAL(clicked()), this, SLOT(DeletePosition()));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::Expand(QAbstractButton *button ){
int index = group->id(button);
// Collapse
if(!button->isChecked()){
palette->setColor(QPalette::Active,QPalette::WindowText,Qt::black);
lblName[index]->setPalette(*palette);
button->setIcon(*iconPlus);
if(index==NumPositions) {
positionWidget->hide();
setFixedHeight(height()-30);//-80 if the checkboxes are included
if(myDet->getPositions()) {
palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen);
lblName[index]->setPalette(*palette);
}
}
else if((index==Scan0)||(index==Scan1)) {
scanWidget[GetActualIndex(index)]->hide();
setFixedHeight(height()-130);
if(myDet->getScanMode(GetActualIndex(index))){
palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen);
lblName[index]->setPalette(*palette);
}
}
else {
actionWidget[GetActualIndex(index)]->hide();
setFixedHeight(height()-30);
if(myDet->getActionMode(GetActualIndex(index))){
palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen);
lblName[index]->setPalette(*palette);
}
}
}else{
// Expand
//always set title color to blue for expan\d
palette->setColor(QPalette::Active,QPalette::WindowText,QColor(0,0,200,255));
lblName[index]->setPalette(*palette);
button->setIcon(*iconMinus);
if(index==NumPositions){
positionWidget->show();
setFixedHeight(height()+30);//+80 if the checkboxes are included
}
else if((index==Scan0)||(index==Scan1)){
scanWidget[GetActualIndex(index)]->show();
setFixedHeight(height()+130);
}
else{
actionWidget[GetActualIndex(index)]->show();
setFixedHeight(height()+30);
}
}
qDefs::checkErrorMessage(myDet,"qTabActions::Expand");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::SetPosition(){
#ifdef VERBOSE
cout << "Entering SetPosition\tnum Pos:" << spinNumPos->value() << "\tlist count:" << comboPos->count() << endl;
#endif
//get number of positions
int numPos = spinNumPos->value();
comboPos->setMaxCount(numPos);
comboPos->setEnabled(numPos);
lblPosList->setEnabled(numPos);
btnDelete->setEnabled(numPos);
//deleting too many or not entering enough
if(numPos>comboPos->count()){
QPalette red = QPalette();
red.setColor(QPalette::Active,QPalette::WindowText,Qt::red);
lblPosList->setPalette(red);
QString tip = QString("<nobr>Enter the positions at which the detector should be moved.</nobr><br>"
"<nobr>Number of entries is restricted to <b>Number of Positions</b> field.</nobr><br><br>")+
QString("<font color=\"red\"><nobr>Add ")+
(QString("%1").arg(((numPos)-(comboPos->count()))))+
QString(" more positions to the list to match <b>Number of Positions</b>.</nobr><br>"
"<nobr><nobr>Or reduce <b>Number of Positions</b>.</nobr></font>");
lblPosList->setToolTip(tip);
lblPosList->setText("List of Positions:*");
}else{
lblPosList->setText("List of Positions: ");
lblPosList->setPalette(normal);
lblPosList->setToolTip("<nobr>Enter the positions at which the detector should be moved.</nobr><br>"
"<nobr>Number of entries is restricted to <b>Number of Positions</b> field.</nobr>");
}
//delete existing positions
if (positions) {delete [] positions; positions = NULL;}
positions=new double[comboPos->count()];
//copying the list
for(int i=0;i<comboPos->count();i++)
positions[i] = comboPos->itemText(i).toDouble();
//setting the list and catching error
if(myDet->setPositions(comboPos->count(),positions)!=comboPos->count())
qDefs::Message(qDefs::WARNING,"The positions list was not set for some reason.","qTabActions::SetPosition");
qDefs::checkErrorMessage(myDet,"qTabActions::SetPosition");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::DeletePosition(){
QString pos = comboPos->currentText();
bool found = false;
//loops through to find the index and to make sure its in the list
for(int i=0;i<comboPos->count();i++){
if(!comboPos->itemText(i).compare(pos)){
found = true;
comboPos->removeItem(i);
break;
}
}
if(found){
#ifdef VERBOSE
cout << "Deleting Position " << endl;
#endif
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::EnablePositions(bool enable){
#ifdef VERBOSE
cout << "Enable Positions: " << enable << endl;
#endif
if(enable){
lblName[NumPositions]->setEnabled(true);
btnExpand[NumPositions]->setEnabled(true);
}else{
//deletes all positions
for(int i=0;i<comboPos->count();i++)
comboPos->removeItem(i);
cout<<"Number of Positions set to :"<<myDet->getPositions()<<endl;
//to collapse if it was expanded
if(btnExpand[NumPositions]->isChecked()){
disconnect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
btnExpand[NumPositions]->setChecked(false);
connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
Expand(group->button(NumPositions));
}
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}
qDefs::checkErrorMessage(myDet,"qTabActions::EnablePositions");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::Refresh(){
#ifdef VERBOSE
cout << endl <<"**Updating all action widgets: " << endl;
#endif
if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::GOTTHARD)){
//positions is enabled only if angular conversion is enabled
int ang; if(!myDet->getAngularConversion(ang)) EnablePositions(false);
if(lblName[NumPositions]->isEnabled()){
//delete existing positions
if (positions) {delete [] positions; positions = NULL;}
//get number of positions
int numPos=myDet->getPositions();
comboPos->setMaxCount(numPos);
//set the number of positions in the gui
disconnect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
spinNumPos->setValue(numPos);
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
positions=new double[numPos];
//load the positions
myDet->getPositions(positions);
//delete the combolist and reload it
disconnect(comboPos,SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
comboPos->setEnabled(numPos);
lblPosList->setEnabled(numPos);
btnDelete->setEnabled(numPos);
lblPosList->setText("List of Positions: ");
lblPosList->setPalette(normal);
for(int i=0;i<comboPos->count();i++)
comboPos->removeItem(i);
for(int i=0;i<numPos;i++)
comboPos->insertItem(i,QString("%1").arg(positions[i]));
connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
#ifdef VERBOSE
cout << "Updated position widget\tnum:" << numPos << "\t***" << endl;
#endif
}
}
for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++)
scanWidget[i]->Refresh();
for(int i=0;i<qActionsWidget::NUM_ACTION_WIDGETS;i++)
actionWidget[i]->Refresh();
UpdateCollapseColors();
#ifdef VERBOSE
cout << "**Updated all action widgets: " << endl << endl;
#endif
qDefs::checkErrorMessage(myDet,"qTabActions::Refresh");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qTabActions::GetActualIndex(int index){
switch(index){
case 0: return slsDetectorDefs::startScript;
case Scan0: return 0;
case Scan1: return 1;
case 3: return slsDetectorDefs::scriptBefore;
case 5: return slsDetectorDefs::headerBefore;
case 6: return slsDetectorDefs::headerAfter;
case 7: return slsDetectorDefs::scriptAfter;
case 8: return slsDetectorDefs::stopScript;
default: return -1;
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::UpdateCollapseColors(){
#ifdef VERYVERBOSE
cout << "Updating Collapse Colors" << endl;
#endif
for(int i=0;i<NumTotalActions;i++){
//num positions
if(i==NumPositions){
if(myDet->getPositions()) palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen);
else palette->setColor(QPalette::Active,QPalette::WindowText,Qt::black);
lblName[i]->setPalette(*palette);
}
//scans
else if((i==Scan0)||(i==Scan1)){
if(myDet->getScanMode(GetActualIndex(i))) palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen);
else palette->setColor(QPalette::Active,QPalette::WindowText,Qt::black);
lblName[i]->setPalette(*palette);
}
//actions
else{
if(myDet->getActionMode(GetActualIndex(i))) palette->setColor(QPalette::Active,QPalette::WindowText,Qt::darkGreen);
else palette->setColor(QPalette::Active,QPalette::WindowText,Qt::black);
lblName[i]->setPalette(*palette);
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

1291
slsDetectorGui/src/qTabAdvanced.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

1222
slsDetectorGui/src/qTabDataOutput.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

779
slsDetectorGui/src/qTabDebugging.cpp Normal file → Executable file
View File

@@ -1,619 +1,272 @@
/*
* qTabDebugging.cpp
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#include "qTabDebugging.h"
// Project Class Headers
#include "slsDetector.h"
#include "multiSlsDetector.h"
// Qt Include Headers
#include <QDesktopWidget>
#include <QGridLayout>
// C++ Include Headers
#include<iostream>
using namespace std;
#include <iostream>
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabDebugging::qTabDebugging(QWidget *parent, multiSlsDetector *detector) : QWidget(parent),
myDet(detector),
detType(slsDetectorDefs::GENERIC),
treeDet(0),
lblDetectorId(0),
lblDetectorFirmware(0),
lblDetectorSoftware(0) {
setupUi(this);
SetupWidgetWindow();
Initialization();
FILE_LOG(logDEBUG) << "Debugging ready";
}
qTabDebugging::qTabDebugging(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),
myDet(detector),
det(0),
treeDet(0),
dispFrame(0),
lblDetectorId(0),
lblDetectorSerial(0),
lblDetectorFirmware(0),
lblDetectorSoftware(0),
lblModuleId(0),
lblModuleFirmware(0),
lblModuleSerial(0){
setupUi(this);
SetupWidgetWindow();
Initialization();
qTabDebugging::~qTabDebugging() {
delete myDet;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDebugging::SetupWidgetWindow() {
blue = new QPalette();
blue->setColor(QPalette::Active, QPalette::WindowText, Qt::darkBlue);
qTabDebugging::~qTabDebugging(){
delete myDet;
if(det) delete det;
// Detector Type
detType = myDet->getDetectorTypeAsEnum();
// rename label and disable tests
if (detType == slsDetectorDefs::EIGER) {
lblDetector->setText("Half Module:");
chkDetectorFirmware->setEnabled(false);
chkDetectorBus->setEnabled(false);
btnTest->setEnabled(false);
}
//add detectors
for (int i = 0; i < myDet->getNumberOfDetectors(); ++i) {
comboDetector->addItem(QString(myDet->getHostname(i).c_str()));
}
UpdateStatus();
qDefs::checkErrorMessage(myDet, "qTabDebugging::SetupWidgetWindow");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDebugging::Initialization() {
void qTabDebugging::SetupWidgetWindow(){
blue = new QPalette();
blue->setColor(QPalette::Active,QPalette::WindowText,Qt::darkBlue);
// Detector Type
detType=myDet->getDetectorsType();
///change module label
switch(detType){
case slsDetectorDefs::EIGER:
lblDetector->setText("Half Module:");
chkDetectorFirmware->setText("Half Module Firmware:");
chkDetectorSoftware->setText("Half Module Software:");
chkDetectorMemory->setText("Half Module Memory:");
chkDetectorBus->setText("Half Module Bus:");
lblModule->hide();
comboModule->hide();
chkModuleFirmware->hide();
chkChip->setEnabled(false);
chkModuleFirmware->setEnabled(false);
break;
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::JUNGFRAUCTB:
case slsDetectorDefs::PROPIX:
case slsDetectorDefs::GOTTHARD:
lblDetector->setText("Module:");
chkDetectorFirmware->setText("Module Firmware:");
chkDetectorSoftware->setText("Module Software:");
chkDetectorMemory->setText("Module Memory:");
chkDetectorBus->setText("Module Bus:");
lblModule->hide();
comboModule->hide();
chkModuleFirmware->hide();
chkChip->setEnabled(false);
chkModuleFirmware->setEnabled(false);
break;
case slsDetectorDefs::MOENCH:
lblDetector->setText("Module:");
chkDetectorFirmware->setText("Module Firmware:");
chkDetectorSoftware->setText("Module Software:");
chkDetectorMemory->setText("Module Memory:");
chkDetectorBus->setText("Module Bus:");
lblModule->hide();
comboModule->hide();
chkModuleFirmware->hide();
chkChip->setEnabled(false);
chkModuleFirmware->setEnabled(false);
break;
case slsDetectorDefs::MYTHEN:
break;
default:
//leave everything as it is(mythen is default)
break;
}
//add detectors
for(int i=0;i<myDet->getNumberOfDetectors();i++){
comboDetector->addItem(QString(myDet->getHostname(i).c_str()));
}
//add modules and status for current detector
if(detType==slsDetectorDefs::MYTHEN) UpdateModuleList();
UpdateStatus();
qDefs::checkErrorMessage(myDet,"qTabDebugging::SetupWidgetWindow");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDebugging::Initialization(){
if(detType==slsDetectorDefs::MYTHEN)
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateModuleList()));
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateStatus()));
connect(btnGetInfo, SIGNAL(clicked()), this, SLOT(GetInfo()));
connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector()));
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateStatus()));
connect(btnGetInfo, SIGNAL(clicked()), this, SLOT(GetInfo()));
if (btnTest ->isEnabled())
connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector()));
}
void qTabDebugging::UpdateStatus() {
FILE_LOG(logDEBUG) << "Getting Status";
//-------------------------------------------------------------------------------------------------------------------------------------------------
auto moduleId = comboDetector->currentIndex();
int detStatus = (int)myDet->getRunStatus(moduleId);
std::string status = slsDetectorDefs::runStatusType(slsDetectorDefs::runStatus(detStatus));
lblStatus->setText(QString(status.c_str()).toUpper());
void qTabDebugging::UpdateModuleList(){
#ifdef VERBOSE
cout << "Getting Module List" << endl;
#endif
det = myDet->getSlsDetector(comboDetector->currentIndex());
qDefs::checkErrorMessage(myDet,"qTabDebugging::UpdateModuleList");
//deletes all modules except "all modules"
for(int i=0;i<comboModule->count()-1;i++)
comboModule->removeItem(i);
for(int i=0;i<det->getNMods();i++){
comboModule->addItem(QString("Module %1").arg(i));
}
qDefs::checkErrorMessage(det,"qTabDebugging::UpdateModuleList");
qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabDebugging::UpdateStatus");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDebugging::GetInfo() {
FILE_LOG(logDEBUG) << "Getting Readout Info";
//window
QFrame *popup1 = new QFrame(this, Qt::Popup | Qt::SubWindow);
QList<QTreeWidgetItem *> items;
//layout
QGridLayout *layout = new QGridLayout(popup1);
//treewidget
treeDet = new QTreeWidget(popup1);
layout->addWidget(treeDet, 0, 0);
//display the details
QFrame *dispFrame = new QFrame(popup1);
QGridLayout *formLayout = new QGridLayout(dispFrame);
// hostname
lblDetectorId = new QLabel("");
lblDetectorId->setPalette(*blue);
// firmware version
lblDetectorFirmware = new QLabel("");
lblDetectorFirmware->setPalette(*blue);
// software version
lblDetectorSoftware = new QLabel("");
lblDetectorSoftware->setPalette(*blue);
//to make sure the size is constant
lblDetectorFirmware->setFixedWidth(100);
layout->addWidget(dispFrame, 0, 1);
QString detName = QString(myDet->getDetectorTypeAsString().c_str());
switch (detType) {
void qTabDebugging::UpdateStatus(){
#ifdef VERBOSE
cout << "Getting Status" << endl;
#endif
det = myDet->getSlsDetector(comboDetector->currentIndex());
qDefs::checkErrorMessage(myDet,"qTabDebugging::UpdateStatus");
int detStatus = (int)det->getRunStatus();
string status = slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detStatus));
lblStatus->setText(QString(status.c_str()).toUpper());
case slsDetectorDefs::EIGER:
//display widget
formLayout->addWidget(new QLabel("Half Module:"), 0, 0);
formLayout->addItem(new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 1);
formLayout->addWidget(lblDetectorId, 0, 2);
formLayout->addWidget(new QLabel("Half Module Firmware Version:"), 1, 0);
formLayout->addWidget(lblDetectorFirmware, 1, 2);
formLayout->addWidget(new QLabel("Half Module Software Version:"), 2, 0);
formLayout->addWidget(lblDetectorSoftware, 2, 2);
qDefs::checkErrorMessage(det,"qTabDebugging::UpdateStatus");
//tree widget
treeDet->setHeaderLabel("Eiger Detector");
//get num modules
for (int i = 0; i < comboDetector->count() / 2; ++i)
items.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Module %1").arg(i))));
treeDet->insertTopLevelItems(0, items);
//gets det names
for (int i = 0; i < comboDetector->count(); ++i) {
QList<QTreeWidgetItem *> childItems;
childItems.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Half Module (%1)").arg(comboDetector->itemText(i)))));
treeDet->topLevelItem(i * 2)->insertChildren(0, childItems);
}
break;
default:
//display widget
formLayout->addWidget(new QLabel("Module:"), 0, 0);
formLayout->addItem(new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 1);
formLayout->addWidget(lblDetectorId, 0, 2);
formLayout->addWidget(new QLabel("Module Firmware Version:"), 1, 0);
formLayout->addWidget(lblDetectorFirmware, 1, 2);
formLayout->addWidget(new QLabel("Module Software Version:"), 2, 0);
formLayout->addWidget(lblDetectorSoftware, 2, 2);
//tree widget
treeDet->setHeaderLabel(QString(detName + " Detector"));
//gets det names
for (int i = 0; i < comboDetector->count(); ++i)
items.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i)))));
treeDet->insertTopLevelItems(0, items);
break;
}
//show and center widget
int x = ((parentWidget()->width()) - (popup1->frameGeometry().width())) / 2;
int y = ((parentWidget()->height()) - (popup1->frameGeometry().height())) / 2;
QDesktopWidget *desktop = QApplication::desktop();
int screen = desktop->screenNumber(this);
popup1->setWindowModality(Qt::WindowModal);
popup1->move((desktop->screenGeometry(screen).x()) + x, (desktop->screenGeometry(screen).y()) + y);
popup1->show();
//put the first parameters
SetParameters(treeDet->topLevelItem(0));
//initializations
connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(SetParameters(QTreeWidgetItem *)));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
char value[200];
int i;
auto moduleId = comboDetector->currentIndex();
switch (detType) {
void qTabDebugging::GetInfo(){
#ifdef VERBOSE
cout << "Getting Info" << endl;
#endif
//window
QFrame* popup1 = new QFrame(this, Qt::Popup | Qt::SubWindow );
QList<QTreeWidgetItem *> items;
case slsDetectorDefs::EIGER:
//only if half module clicked
if (item->text(0).contains("Half Module")) {
//find index
for (i = 0; i < comboDetector->count(); ++i)
if (item == treeDet->topLevelItem(i))
break;
sprintf(value, "%lx", (long long unsigned int)myDet->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION, moduleId));
lblDetectorFirmware->setText(QString(value));
sprintf(value, "%lx", (long long unsigned int)myDet->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, moduleId));
lblDetectorSoftware->setText(QString(value));
qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabDebugging::SetParameters");
}
break;
//layout
QGridLayout *layout = new QGridLayout(popup1);
//treewidget
treeDet = new QTreeWidget(popup1);
layout->addWidget(treeDet,0,0);
//display the details
dispFrame = new QFrame(popup1);
QGridLayout *formLayout = new QGridLayout(dispFrame);
lblDetectorId = new QLabel(""); lblDetectorId->setPalette(*blue);
lblDetectorSerial = new QLabel(""); lblDetectorSerial->setPalette(*blue);
lblDetectorFirmware = new QLabel(""); lblDetectorFirmware->setPalette(*blue);
lblDetectorSoftware = new QLabel(""); lblDetectorSoftware->setPalette(*blue);
lblModuleId = new QLabel(""); lblModuleId->setPalette(*blue);
lblModuleSerial = new QLabel(""); lblModuleSerial->setPalette(*blue);
lblModuleFirmware = new QLabel(""); lblModuleFirmware->setPalette(*blue);
//to make sure the size is constant
lblDetectorFirmware->setFixedWidth(100);
layout->addWidget(dispFrame,0,1);
default:
//find index
for (i = 0; i < comboDetector->count(); ++i)
if (item == treeDet->topLevelItem(i))
break;
switch(detType){
sprintf(value, "%lx", (long long unsigned int)myDet->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION, moduleId));
lblDetectorFirmware->setText(QString(value));
sprintf(value, "%lx", (long long unsigned int)myDet->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, moduleId));
lblDetectorSoftware->setText(QString(value));
case slsDetectorDefs::MYTHEN:
//display widget
formLayout->addWidget(new QLabel("Readout:"),0,0);
formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
formLayout->addWidget(lblDetectorId,0,2);
formLayout->addWidget(new QLabel("Readout MAC Address:"),1,0);
formLayout->addWidget(lblDetectorSerial,1,2);
formLayout->addWidget(new QLabel("Readout Firmware Version:"),2,0);
formLayout->addWidget(lblDetectorFirmware,2,2);
formLayout->addWidget(new QLabel("Readout Software Version:"),3,0);
formLayout->addWidget(lblDetectorSoftware,3,2);
formLayout->addWidget(new QLabel("Module:"),4,0);
formLayout->addWidget(lblModuleId,4,2);
formLayout->addWidget(new QLabel("Module Serial Number:"),5,0);
formLayout->addWidget(lblModuleSerial,5,2);
formLayout->addWidget(new QLabel("Module Firmware Version:"),6,0);
formLayout->addWidget(lblModuleFirmware,6,2);
//tree widget
treeDet->setHeaderLabel("Mythen Detector");
//gets det names
for (int i=0;i<comboDetector->count();i++)
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Readout (%1)").arg(comboDetector->itemText(i)))));
treeDet->insertTopLevelItems(0, items);
//gets module names
for (int i=0;i<comboDetector->count();i++){
QList<QTreeWidgetItem *> childItems;
det = myDet->getSlsDetector(i);
qDefs::checkErrorMessage(myDet,"qTabDebugging::GetInfo");
for(int j=0;j<det->getNMods();j++)
childItems.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module %1").arg(j))));
treeDet->topLevelItem(i)->insertChildren(0,childItems);
qDefs::checkErrorMessage(det,"qTabDebugging::GetInfo");
}
break;
case slsDetectorDefs::EIGER:
//display widget
formLayout->addWidget(new QLabel("Half Module:"),0,0);
formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
formLayout->addWidget(lblDetectorId,0,2);
formLayout->addWidget(new QLabel("Half Module MAC Address:"),1,0);
formLayout->addWidget(lblDetectorSerial,1,2);
formLayout->addWidget(new QLabel("Half Module Firmware Version:"),2,0);
formLayout->addWidget(lblDetectorFirmware,2,2);
formLayout->addWidget(new QLabel("Half Module Software Version:"),3,0);
formLayout->addWidget(lblDetectorSoftware,3,2);
//tree widget
treeDet->setHeaderLabel("Eiger Detector");
//get num modules
for (int i=0;i<comboDetector->count()/2;i++)
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module %1").arg(i))));
treeDet->insertTopLevelItems(0, items);
//gets det names
for (int i=0;i<comboDetector->count();i++){
QList<QTreeWidgetItem *> childItems;
childItems.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Half Module (%1)").arg(comboDetector->itemText(i)))));
treeDet->topLevelItem(i*2)->insertChildren(0,childItems);
}
break;
case slsDetectorDefs::MOENCH:
//display widget
formLayout->addWidget(new QLabel("Module:"),0,0);
formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
formLayout->addWidget(lblDetectorId,0,2);
formLayout->addWidget(new QLabel("Module MAC Address:"),1,0);
formLayout->addWidget(lblDetectorSerial,1,2);
formLayout->addWidget(new QLabel("Module Firmware Version:"),2,0);
formLayout->addWidget(lblDetectorFirmware,2,2);
formLayout->addWidget(new QLabel("Module Software Version:"),3,0);
formLayout->addWidget(lblDetectorSoftware,3,2);
//tree widget
treeDet->setHeaderLabel("Moench Detector");
//gets det names
for (int i=0;i<comboDetector->count();i++)
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i)))));
treeDet->insertTopLevelItems(0, items);
break;
case slsDetectorDefs::PROPIX:
//display widget
formLayout->addWidget(new QLabel("Module:"),0,0);
formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
formLayout->addWidget(lblDetectorId,0,2);
formLayout->addWidget(new QLabel("Module MAC Address:"),1,0);
formLayout->addWidget(lblDetectorSerial,1,2);
formLayout->addWidget(new QLabel("Module Firmware Version:"),2,0);
formLayout->addWidget(lblDetectorFirmware,2,2);
formLayout->addWidget(new QLabel("Module Software Version:"),3,0);
formLayout->addWidget(lblDetectorSoftware,3,2);
//tree widget
treeDet->setHeaderLabel("Propix Detector");
//gets det names
for (int i=0;i<comboDetector->count();i++)
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i)))));
treeDet->insertTopLevelItems(0, items);
break;
case slsDetectorDefs::GOTTHARD:
//display widget
formLayout->addWidget(new QLabel("Module:"),0,0);
formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
formLayout->addWidget(lblDetectorId,0,2);
formLayout->addWidget(new QLabel("Module MAC Address:"),1,0);
formLayout->addWidget(lblDetectorSerial,1,2);
formLayout->addWidget(new QLabel("Module Firmware Version:"),2,0);
formLayout->addWidget(lblDetectorFirmware,2,2);
formLayout->addWidget(new QLabel("Module Software Version:"),3,0);
formLayout->addWidget(lblDetectorSoftware,3,2);
//tree widget
treeDet->setHeaderLabel("Gotthard Detector");
//gets det names
for (int i=0;i<comboDetector->count();i++)
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i)))));
treeDet->insertTopLevelItems(0, items);
break;
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::JUNGFRAUCTB:
//display widget
formLayout->addWidget(new QLabel("Module:"),0,0);
formLayout->addItem(new QSpacerItem(15,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
formLayout->addWidget(lblDetectorId,0,2);
formLayout->addWidget(new QLabel("Module MAC Address:"),1,0);
formLayout->addWidget(lblDetectorSerial,1,2);
formLayout->addWidget(new QLabel("Module Firmware Version:"),2,0);
formLayout->addWidget(lblDetectorFirmware,2,2);
formLayout->addWidget(new QLabel("Module Software Version:"),3,0);
formLayout->addWidget(lblDetectorSoftware,3,2);
//tree widget
if (detType == slsDetectorDefs::JUNGFRAU)
treeDet->setHeaderLabel("JungFrau Detector");
else
treeDet->setHeaderLabel("JungFrauCTB Detector");
//gets det names
for (int i=0;i<comboDetector->count();i++)
items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i)))));
treeDet->insertTopLevelItems(0, items);
break;
default:
break;
}
//show and center widget
int x = ((parentWidget()->width()) - (popup1->frameGeometry().width())) / 2;
int y = ((parentWidget()->height()) - (popup1->frameGeometry().height())) / 2;
QDesktopWidget *desktop = QApplication::desktop();
int screen = desktop->screenNumber(this);
popup1->setWindowModality(Qt::WindowModal);
popup1->move( (desktop->screenGeometry(screen).x())+x, (desktop->screenGeometry(screen).y())+y );
popup1->show();
//put the first parameters
SetParameters(treeDet->topLevelItem(0));
//initializations
connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *,int)) , this, SLOT(SetParameters(QTreeWidgetItem *)));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDebugging::SetParameters(QTreeWidgetItem *item){
char value[200];
int i;
switch(detType){
case slsDetectorDefs::MYTHEN:
if(item->text(0).contains("Readout")){
//find index
for(i=0;i<comboDetector->count();i++)
if(item== treeDet->topLevelItem(i))
break;
det = myDet->getSlsDetector(i);
qDefs::checkErrorMessage(myDet,"qTabDebugging::SetParameters");
lblDetectorId->setText(comboDetector->itemText(i));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER));
lblDetectorSerial->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION));
lblDetectorFirmware ->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION));
lblDetectorSoftware->setText(QString(value));
qDefs::checkErrorMessage(det,"qTabDebugging::SetParameters");
lblModuleId->setText("");
lblModuleSerial->setText("");
lblModuleFirmware->setText("");
}else{
//find index
for(i=0;i<comboDetector->count();i++)
if(item->parent() == treeDet->topLevelItem(i))
break;
int im = item->parent()->indexOfChild(item);
det = myDet->getSlsDetector(i);
qDefs::checkErrorMessage(myDet,"qTabDebugging::SetParameters");
lblDetectorId->setText(comboDetector->itemText(i));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER));
lblDetectorSerial->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION));
lblDetectorFirmware ->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION));
lblDetectorSoftware->setText(QString(value));
lblModuleId->setText(QString("%1").arg(im));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::MODULE_SERIAL_NUMBER,im));
lblModuleSerial->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::MODULE_FIRMWARE_VERSION,im));
lblModuleFirmware->setText(QString(value));
qDefs::checkErrorMessage(det,"qTabDebugging::SetParameters");
}
break;
case slsDetectorDefs::EIGER:
//only if half module clicked
if(item->text(0).contains("Half Module")){
//find index
for(i=0;i<comboDetector->count();i++)
if(item== treeDet->topLevelItem(i))
break;
det = myDet->getSlsDetector(i);
qDefs::checkErrorMessage(myDet,"qTabDebugging::SetParameters");
lblDetectorId->setText(comboDetector->itemText(i));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER));
lblDetectorSerial->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION));
lblDetectorFirmware ->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION));
lblDetectorSoftware->setText(QString(value));
qDefs::checkErrorMessage(det,"qTabDebugging::SetParameters");
}
break;
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::JUNGFRAUCTB:
case slsDetectorDefs::PROPIX:
case slsDetectorDefs::MOENCH:
case slsDetectorDefs::GOTTHARD:
//find index
for(i=0;i<comboDetector->count();i++)
if(item== treeDet->topLevelItem(i))
break;
det = myDet->getSlsDetector(i);
qDefs::checkErrorMessage(myDet,"qTabDebugging::SetParameters");
lblDetectorId->setText(comboDetector->itemText(i));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SERIAL_NUMBER));
lblDetectorSerial->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION));
lblDetectorFirmware ->setText(QString(value));
sprintf(value,"%llx",(long long unsigned int)det->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION));
lblDetectorSoftware->setText(QString(value));
qDefs::checkErrorMessage(det,"qTabDebugging::SetParameters");
break;
default:
break;
}
qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabDebugging::SetParameters");
break;
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDebugging::TestDetector() {
FILE_LOG(logINFO) << "Testing Readout";
void qTabDebugging::TestDetector(){
#ifdef VERBOSE
cout << "Testing" << endl;
#endif
int retval = slsDetectorDefs::FAIL;
QString message;
QString Detector = "Detector";
int retval=slsDetectorDefs::FAIL;
QString message;
QString Detector = "Detector";
//main messagebox title
switch (detType) {
case slsDetectorDefs::EIGER:
Detector = "Half Module";
break;
default:
Detector = "Module";
break;
}
//main messagebox title
switch(detType){
case slsDetectorDefs::MYTHEN:
message = QString("<nobr>Test Results for %1 and %2:</nobr><br><br>").arg(comboDetector->currentText(),comboModule->currentText());
break;
case slsDetectorDefs::EIGER: Detector = "Half Module"; break;
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::JUNGFRAUCTB:
case slsDetectorDefs::MOENCH:
case slsDetectorDefs::PROPIX:
case slsDetectorDefs::GOTTHARD: Detector = "Module"; break;
default: break;
}
// construct message
message = QString("<nobr>Test Results for %1:</nobr><br><br>").arg(comboDetector->currentText());
auto moduleId = comboDetector->currentIndex();
if(detType==slsDetectorDefs::MYTHEN)
message = QString("<nobr>Test Results for %1 and %2:</nobr><br><br>").arg(comboDetector->currentText(),comboModule->currentText());
else message = QString("<nobr>Test Results for %1:</nobr><br><br>").arg(comboDetector->currentText());
//detector firmware
if (chkDetectorFirmware->isChecked()) {
retval = myDet->digitalTest(slsDetectorDefs::DETECTOR_FIRMWARE_TEST, moduleId);
if (retval == slsDetectorDefs::FAIL) {
message.append(QString("<nobr>%1 Firmware: FAIL</nobr><br>").arg(Detector));
FILE_LOG(logERROR) << "Firmware fail";
}
else
message.append(QString("<nobr>%1 Firmware: %2</nobr><br>").arg(Detector, QString::number(retval)));
FILE_LOG(logINFO) << "Detector Firmware Test: " << retval;
}
//get sls det object
det = myDet->getSlsDetector(comboDetector->currentIndex());
qDefs::checkErrorMessage(myDet,"qTabDebugging::TestDetector");
//detector CPU-FPGA bus
if (chkDetectorBus->isChecked()) {
retval = myDet->digitalTest(slsDetectorDefs::DETECTOR_BUS_TEST, moduleId);
if (retval == slsDetectorDefs::FAIL) {
message.append(QString("<nobr>%1 Bus: &nbsp;&nbsp;&nbsp;&nbsp;FAIL</nobr><br>").arg(Detector));
FILE_LOG(logERROR) << "Bus Test fail";
} else
message.append(QString("<nobr>%1 Bus: &nbsp;&nbsp;&nbsp;&nbsp;%2</nobr><br>").arg(Detector, QString::number(retval)));
FILE_LOG(logINFO) << "Detector Bus Test: " << retval;
}
//detector firmware
if(chkDetectorFirmware->isChecked()){
retval = det->digitalTest(slsDetectorDefs::DETECTOR_FIRMWARE_TEST);
if(retval== slsDetectorDefs::FAIL) message.append(QString("<nobr>%1 Firmware: FAIL</nobr><br>").arg(Detector));
else message.append(QString("<nobr>%1 Firmware: %2</nobr><br>").arg(Detector,QString::number(retval)));
#ifdef VERBOSE
cout<<"Detector Firmware: "<<retval<<endl;
#endif
}
//detector software
if(chkDetectorSoftware->isChecked()){
retval = det->digitalTest(slsDetectorDefs::DETECTOR_SOFTWARE_TEST);
if(retval== slsDetectorDefs::FAIL) message.append(QString("<nobr>%1 Software: FAIL</nobr><br>").arg(Detector));
else message.append(QString("<nobr>%1 Software: %2</nobr><br>").arg(Detector,QString::number(retval)));
#ifdef VERBOSE
cout<<"Detector Software: "<<retval<<endl;
#endif
}
//detector CPU-FPGA bus
if(chkDetectorBus->isChecked()){
retval = det->digitalTest(slsDetectorDefs::DETECTOR_BUS_TEST);
if(retval== slsDetectorDefs::FAIL) message.append(QString("<nobr>%1 Bus: &nbsp;&nbsp;&nbsp;&nbsp;FAIL</nobr><br>").arg(Detector));
else message.append(QString("<nobr>%1 Bus: &nbsp;&nbsp;&nbsp;&nbsp;%2</nobr><br>").arg(Detector,QString::number(retval)));
#ifdef VERBOSE
cout<<"Detector Bus: "<<retval<<endl;
#endif
}
//detector Memory
if(chkDetectorMemory->isChecked()){
retval = det->digitalTest(slsDetectorDefs::DETECTOR_MEMORY_TEST);
if(retval== slsDetectorDefs::FAIL) message.append(QString("<nobr>%1 Memory: &nbsp;FAIL</nobr><br>").arg(Detector));
else message.append(QString("<nobr>%1 Memory: &nbsp;%2</nobr><br>").arg(Detector,QString::number(retval)));
#ifdef VERBOSE
cout<<"Detector Memory: "<<retval<<endl;
#endif
}
//chip
if(chkChip->isChecked()){
retval = det->digitalTest(slsDetectorDefs::CHIP_TEST,comboModule->currentIndex());
if(retval== slsDetectorDefs::FAIL) message.append("<br><nobr>Chip: FAIL</nobr><br>");
else message.append(QString("<nobr>Chip: %1</nobr><br>").arg(retval));
#ifdef VERBOSE
cout<<"Chip: "<<retval<<endl;
#endif
}
//module firmware
if(chkModuleFirmware->isChecked()){
retval = det->digitalTest(slsDetectorDefs::MODULE_FIRMWARE_TEST,comboModule->currentIndex());
if(retval== slsDetectorDefs::FAIL) message.append("<nobr>Module Firmware: FAIL</nobr><br>");
else message.append(QString("<nobr>Module Firmware: %1</nobr><br>").arg(retval));
#ifdef VERBOSE
cout<<"Module Firmware: "<<retval<<endl;
#endif
}
//display message
qDefs::Message(qDefs::INFORMATION,message.toAscii().constData(),"qTabDebugging::TestDetector");
//display message
qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(), "qTabDebugging::TestDetector");
qDefs::checkErrorMessage(det,"qTabDebugging::TestDetector");
qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabDebugging::TestDetector");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDebugging::Refresh(){
#ifdef VERBOSE
cout << endl << "**Updating Debugging Tab" << endl;
#endif
UpdateStatus();
#ifdef VERBOSE
cout << "**Updated Debugging Tab" << endl << endl;
#endif
void qTabDebugging::Refresh() {
FILE_LOG(logDEBUG) << "\n**Updating Debugging Tab";
UpdateStatus();
FILE_LOG(logDEBUG) << "**Updated Debugging Tab";
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

848
slsDetectorGui/src/qTabDeveloper.cpp Normal file → Executable file
View File

@@ -1,90 +1,58 @@
/*
* qTabDeveloper.cpp
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#include "qTabDeveloper.h"
#include "qDetectorMain.h"
//Project Class Headers
#include "slsDetector.h"
#include "multiSlsDetector.h"
//Qt Include Headers
#include <QDoubleValidator>
#include <QSpacerItem>
#include <QString>
#include <QDoubleValidator>
//C++ Include Headers
#include<iostream>
using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qTabDeveloper::NUM_DAC_WIDGETS(0);
int qTabDeveloper::NUM_ADC_WIDGETS(0);
//-------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>
qTabDeveloper::qTabDeveloper(qDetectorMain *parent,multiSlsDetector*& detector):
thisParent(parent),
myDet(detector),
det(0),
boxDacs(0),
boxAdcs(0),
lblHV(0),
comboHV(0),
adcTimer(0),
dacLayout(0){
for(int i=0;i<20;i++) {
lblDacs[i]=0;
lblAdcs[i]=0;
spinDacs[i]=0;
spinAdcs[i]=0;
lblDacsmV[i]=0;
}
qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) : QWidget(parent),
myDet(detector),
detType(slsDetectorDefs::GENERIC),
numDACWidgets(0),
numADCWidgets(0),
boxDacs(0),
boxAdcs(0),
lblHV(0),
comboHV(0),
dacLayout(0),
comboDetector(0) {
lblDacs.clear();
lblAdcs.clear();
spinDacs.clear();
spinAdcs.clear();
lblDacsmV.clear();
SetupWidgetWindow();
Initialization();
FILE_LOG(logDEBUG) << "Developer ready";
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabDeveloper::~qTabDeveloper() {
delete myDet;
if(det) delete det;
if(thisParent) delete thisParent;
if (myDet)
delete myDet;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDeveloper::SetupWidgetWindow() {
//Detector Type
detType=myDet->getDetectorsType();
detType = myDet->getDetectorTypeAsEnum();
//palette
red = QPalette();
red.setColor(QPalette::Active,QPalette::WindowText,Qt::red);
red.setColor(QPalette::Active, QPalette::WindowText, Qt::red);
//the number of dacs and adcs
switch(detType){
case slsDetectorDefs::MYTHEN:
NUM_DAC_WIDGETS = 6;
NUM_ADC_WIDGETS = 0;
dacNames.push_back("v Trimbit:");
dacNames.push_back("v Threshold:");
dacNames.push_back("v Shaper1:");
dacNames.push_back("v Shaper2:");
dacNames.push_back("v Calibration:");
dacNames.push_back("v Preamp:");
break;
switch (detType) {
case slsDetectorDefs::EIGER:
NUM_DAC_WIDGETS = 17;
NUM_ADC_WIDGETS = 6;
numDACWidgets = 17;
numADCWidgets = 6;
dacNames.push_back("v SvP:");
dacNames.push_back("v SvN");
@@ -112,10 +80,10 @@ void qTabDeveloper::SetupWidgetWindow() {
adcNames.push_back("Temperature FPGA:");
break;
case slsDetectorDefs::PROPIX:
case slsDetectorDefs::GOTTHARD:
NUM_DAC_WIDGETS = 8;
NUM_ADC_WIDGETS = 2;
numDACWidgets = 8;
numADCWidgets = 2;
dacNames.push_back("v Reference:");
dacNames.push_back("v Cascode n:");
dacNames.push_back("v Cascode p:");
@@ -129,28 +97,10 @@ void qTabDeveloper::SetupWidgetWindow() {
adcNames.push_back("Temperature FPGA:");
break;
case slsDetectorDefs::MOENCH:
NUM_DAC_WIDGETS = 8;
NUM_ADC_WIDGETS = 2;
dacNames.push_back("v Dac 0:");
dacNames.push_back("v Dac 1:");
dacNames.push_back("v Dac 2:");
dacNames.push_back("v Dac 3:");
dacNames.push_back("v Dac 4:");
dacNames.push_back("v Dac 5:");
dacNames.push_back("v Dac 6:");
dacNames.push_back("i Dac 7:");
adcNames.push_back("Temperature ADC:");
adcNames.push_back("Temperature FPGA:");
break;
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::JUNGFRAUCTB:
NUM_DAC_WIDGETS = 8;
NUM_ADC_WIDGETS = 1;
numDACWidgets = 8;
numADCWidgets = 1;
dacNames.push_back("v vb comp:");
dacNames.push_back("v vdd prot:");
dacNames.push_back("v vin com:");
@@ -164,51 +114,154 @@ void qTabDeveloper::SetupWidgetWindow() {
break;
case slsDetectorDefs::MOENCH:
numDACWidgets = 8;
numADCWidgets = 0;
dacNames.push_back("v Dac 0:");
dacNames.push_back("v Dac 1:");
dacNames.push_back("v Dac 2:");
dacNames.push_back("v Dac 3:");
dacNames.push_back("v Dac 4:");
dacNames.push_back("v Dac 5:");
dacNames.push_back("v Dac 6:");
dacNames.push_back("i Dac 7:");
break;
default:
cout << "ERROR: Unknown detector type: " + myDet->slsDetectorBase::getDetectorType(detType) << endl;
qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorBase::getDetectorType(detType),"qTabDeveloper::SetupWidgetWindow");
FILE_LOG(logERROR) << "Unknown detector type: " + myDet->getDetectorTypeAsString();
qDefs::Message(qDefs::CRITICAL, std::string("Unknown detector type:") + myDet->getDetectorTypeAsString(), "qTabDeveloper::SetupWidgetWindow");
exit(-1);
break;
}
//layout
setFixedWidth(765);
setFixedHeight(20+50+(NUM_DAC_WIDGETS/2)*35);
//setHeight(340);
setFixedHeight(20 + 50 + (numDACWidgets / 2) * 35);
scroll = new QScrollArea;
//scroll->setFrameShape(QFrame::NoFrame);
QScrollArea* scroll = new QScrollArea;
scroll->setWidget(this);
scroll->setWidgetResizable(true);
layout = new QGridLayout(scroll);
layout->setContentsMargins(20,10,10,5);
QGridLayout *layout = new QGridLayout(scroll);
layout->setContentsMargins(20, 10, 10, 5);
setLayout(layout);
//readout
comboDetector = new QComboBox(this);
//comboDetector->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
comboDetector->addItem("All");
//add detectors
for(int i=1;i<myDet->getNumberOfDetectors()+1;i++)
comboDetector->addItem(QString(myDet->getHostname(i-1).c_str()));
for (int i = 1; i < myDet->getNumberOfDetectors() + 1; ++i)
comboDetector->addItem(QString(myDet->getHostname(i - 1).c_str()));
comboDetector->setCurrentIndex(0);
//dacs
boxDacs = new QGroupBox("Dacs",this);
boxDacs->setFixedHeight(25+(NUM_DAC_WIDGETS/2)*35);
CreateDACWidgets();
//HV for gotthard
if ((detType==slsDetectorDefs::GOTTHARD) ||
(detType==slsDetectorDefs::PROPIX) ||
(detType==slsDetectorDefs::MOENCH)){
boxDacs->setFixedHeight(boxDacs->height()+35);
// hv for gotthard, jungfrau, moench
if ((detType == slsDetectorDefs::GOTTHARD) ||
(detType == slsDetectorDefs::JUNGFRAU) ||
(detType == slsDetectorDefs::MOENCH)) {
CreateHVWidget();
lblHV = new QLabel("High Voltage",boxDacs);
comboHV = new QComboBox(boxDacs);
}
layout->addWidget(comboDetector, 0, 0);
layout->addWidget(boxDacs, 1, 0);
//adcs
if (numADCWidgets) {
CreateADCWidgets();
layout->addWidget(boxAdcs, 2, 0);
}
qDefs::checkErrorMessage(myDet, "qTabDeveloper::SetupWidgetWindow");
}
void qTabDeveloper::Initialization() {
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh()));
// dacs
for (int i = 0; i < numDACWidgets; ++i)
connect(spinDacs[i], SIGNAL(editingFinished(int)), this, SLOT(SetDacValues(int)));
// hv
if (comboHV) {
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
} else {
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
}
}
void qTabDeveloper::CreateDACWidgets() {
boxDacs = new QGroupBox("Dacs", this);
boxDacs->setFixedHeight(25 + (numDACWidgets / 2) * 35);
dacLayout = new QGridLayout(boxDacs);
for (int i = 0; i < numDACWidgets; ++i) {
lblDacs[i] = new QLabel(QString(dacNames[i].c_str()), boxDacs);
spinDacs[i] = new MyDoubleSpinBox(i, boxDacs);
spinDacs[i]->setMinimum(-1);
spinDacs[i]->setMaximum(10000);
lblDacsmV[i] = new QLabel("", boxDacs);
dacLayout->addWidget(lblDacs[i], (int)(i / 2), ((i % 2) == 0) ? 1 : 5);
dacLayout->addWidget(spinDacs[i], (int)(i / 2), ((i % 2) == 0) ? 2 : 6);
dacLayout->addWidget(lblDacsmV[i], (int)(i / 2), ((i % 2) == 0) ? 3 : 7);
if (!(i % 2)) {
dacLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 0);
dacLayout->addItem(new QSpacerItem(60, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 4);
dacLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 8);
}
}
}
void qTabDeveloper::CreateADCWidgets() {
int rows = numADCWidgets / 2;
if (numADCWidgets % 2)
rows++;
setFixedHeight(20 + (50 + (numDACWidgets / 2) * 35) + (50 + rows * 35));
boxAdcs = new QGroupBox("ADCs", this);
boxAdcs->setFixedHeight(25 + rows * 35);
QGridLayout *adcLayout = new QGridLayout(boxAdcs);
for (int i = 0; i < numADCWidgets; ++i) {
lblAdcs[i] = new QLabel(QString(adcNames[i].c_str()), boxAdcs);
spinAdcs[i] = new QLineEdit(boxAdcs);
spinAdcs[i]->setReadOnly(true);
adcLayout->addWidget(lblAdcs[i], (int)(i / 2), ((i % 2) == 0) ? 1 : 4);
adcLayout->addWidget(spinAdcs[i], (int)(i / 2), ((i % 2) == 0) ? 2 : 5);
if (!(i % 2)) {
adcLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 0);
adcLayout->addItem(new QSpacerItem(60, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 3);
adcLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 6);
}
}
//to make the adcs at the bottom most
if (detType != slsDetectorDefs::EIGER) {
int diff = 340 - height();
setFixedHeight(340);
layout->setVerticalSpacing(diff / 2);
}
}
void qTabDeveloper::CreateHVWidget() {
boxDacs->setFixedHeight(boxDacs->height() + 35);
lblHV = new QLabel("High Voltage", boxDacs);
dacLayout->addWidget(lblHV, (int)(numDACWidgets / 2), 1);
comboHV = nullptr;
spinHV = nullptr;
// drop down with specific values
if (detType == slsDetectorDefs::GOTTHARD) {
comboHV = new QComboBox(boxDacs);
comboHV->addItem("0");
comboHV->addItem("90");
comboHV->addItem("110");
@@ -217,415 +270,306 @@ void qTabDeveloper::SetupWidgetWindow() {
comboHV->addItem("180");
comboHV->addItem("200");
tipHV = "<nobr>Set high voltage to 0, 90, 110, 120, 150 or 200V.</nobr>";
lblHV->setToolTip(tipHV);
comboHV->setToolTip(tipHV);
dacLayout->addWidget(lblHV,(int)(NUM_DAC_WIDGETS/2),1);
dacLayout->addWidget(comboHV,(int)(NUM_DAC_WIDGETS/2),2);
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
}
layout->addWidget(comboDetector,0,0);
layout->addWidget(boxDacs,1,0);
//adcs
if(NUM_ADC_WIDGETS) {
int rows = NUM_ADC_WIDGETS/2;
if (NUM_ADC_WIDGETS%2)rows++;
setFixedHeight(20+(50+(NUM_DAC_WIDGETS/2)*35)+(50+rows*35));
boxAdcs = new QGroupBox("ADCs",this);
boxAdcs->setFixedHeight(25+rows*35);
layout->addWidget(boxAdcs,2,0);
CreateADCWidgets();
//to make the adcs at the bottom most
if (detType!=slsDetectorDefs::EIGER) {
int diff = 340-height();
setFixedHeight(340);
layout->setVerticalSpacing(diff/2);
}
//timer to check adcs
/*adcTimer = new QTimer(this); adc timer disabled, display adcs only when refreshing developer tab */
dacLayout->addWidget(comboHV, (int)(numDACWidgets / 2), 2);
}
qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetupWidgetWindow");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDeveloper::Initialization(){
/*if(NUM_ADC_WIDGETS) connect(adcTimer, SIGNAL(timeout()), this, SLOT(RefreshAdcs()));*/
for(int i=0;i<NUM_DAC_WIDGETS;i++)
connect(spinDacs[i], SIGNAL(editingFinished(int)), this, SLOT(SetDacValues(int)));
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh()));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDeveloper::CreateDACWidgets(){
dacLayout = new QGridLayout(boxDacs);
for(int i=0;i<NUM_DAC_WIDGETS;i++){
lblDacs[i] = new QLabel(QString(dacNames[i].c_str()),boxDacs);
spinDacs[i] = new MyDoubleSpinBox(i,boxDacs);
// jungfrau, moench (range of values)
else {
spinHV = new QSpinBox(boxDacs);
spinDacs[i]->setMinimum(-1);
spinDacs[i]->setMaximum(10000);
lblDacsmV[i]= new QLabel("",boxDacs);
dacLayout->addWidget(lblDacs[i],(int)(i/2),((i%2)==0)?1:5);
dacLayout->addWidget(spinDacs[i],(int)(i/2),((i%2)==0)?2:6);
dacLayout->addWidget(lblDacsmV[i],(int)(i/2),((i%2)==0)?3:7);
if(!(i%2)){
dacLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),0);
dacLayout->addItem(new QSpacerItem(60,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),4);
dacLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),8);
}
spinDacs[i]->setMaximum(200);
tipHV = "<nobr>Set high voltage to 0 or 60 - 200V</nobr>";
spinHV->setToolTip(tipHV);
dacLayout->addWidget(spinHV, (int)(numDACWidgets / 2), 2);
}
lblHV->setToolTip(tipHV);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDeveloper::SetDacValues(int id) {
FILE_LOG(logINFO) << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value();
int moduleId = comboDetector->currentIndex() - 1;
void qTabDeveloper::CreateADCWidgets(){
QGridLayout *adcLayout = new QGridLayout(boxAdcs);
for(int i=0;i<NUM_ADC_WIDGETS;i++){
lblAdcs[i] = new QLabel(QString(adcNames[i].c_str()),boxAdcs);
spinAdcs[i] = new QLineEdit(boxAdcs);
spinAdcs[i]->setReadOnly(true);
adcLayout->addWidget(lblAdcs[i],(int)(i/2),((i%2)==0)?1:4);
adcLayout->addWidget(spinAdcs[i],(int)(i/2),((i%2)==0)?2:5);
if(!(i%2)){
adcLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),0);
adcLayout->addItem(new QSpacerItem(60,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),3);
adcLayout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),(int)(i/2),6);
}
}
myDet->setDAC(spinDacs[id]->value(),getSLSIndex(id), 0, moduleId);
lblDacsmV[id]->setText(QString("%1mV").arg(myDet->setDAC(-1, getSLSIndex(id), 1, moduleId),-10));
qDefs::checkErrorMessage(myDet, moduleId, "qTabDeveloper::SetDacValues");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDeveloper::SetDacValues(int id){
#ifdef VERBOSE
cout << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value() << endl;
#endif
int detid = comboDetector->currentIndex();
if(detid)
det = myDet->getSlsDetector(detid-1);
//all detectors
if(!detid){
myDet->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0);
lblDacsmV[id]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(id),1),-10));
qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetDacValues");
}
//specific detector
else{
det->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0);
lblDacsmV[id]->setText(QString("%1mV").arg(det->setDAC(-1,getSLSIndex(id),1),-10));
qDefs::checkErrorMessage(det,"qTabDeveloper::SetDacValues");
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDeveloper::SetHighVoltage(){
#ifdef VERBOSE
cout << "Setting high voltage:" << comboHV->currentText().toAscii().constData() << endl;
#endif
int detid = comboDetector->currentIndex();
if(detid)
det = myDet->getSlsDetector(detid-1);
int highvoltage = comboHV->currentText().toInt();
int ret;
//all detectors
if(!detid){
ret = myDet->setDAC(highvoltage,slsDetectorDefs::HV_POT,0);
qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetHighVoltage");
}
//specific detector
else{
ret = det->setDAC(highvoltage,slsDetectorDefs::HV_POT,0);
qDefs::checkErrorMessage(det,"qTabDeveloper::SetHighVoltage");
}
void qTabDeveloper::SetHighVoltage() {
int highvoltage = (comboHV ? comboHV->currentText().toInt() : spinHV->value());
FILE_LOG(logINFO) << "Setting high voltage:" << highvoltage;
auto moduleId = comboDetector->currentIndex() - 1;
int ret = det->setDAC(highvoltage,slsDetectorDefs::HIGH_VOLTAGE, 0, moduleId);
qDefs::checkErrorMessage(myDet, moduleId, "qTabDeveloper::SetHighVoltage");
//error
if(ret != highvoltage){
qDefs::Message(qDefs::CRITICAL,"High Voltage could not be set to this value.","qTabDeveloper::SetHighVoltage");
if (ret != highvoltage && highvoltage != -1) {
qDefs::Message(qDefs::CRITICAL, "High Voltage could not be set to this value.", "qTabDeveloper::SetHighVoltage");
FILE_LOG(logERROR) << "Could not set High voltage";
lblHV->setPalette(red);
lblHV->setText("High Voltage:*");
QString errTip = tipHV+QString("<br><br><font color=\"red\"><nobr>High Voltage could not be set. The return value is ")+
QString::number(ret)+ QString("</nobr></font>");
QString errTip = tipHV + QString("<br><br><font color=\"red\"><nobr>High Voltage could not be set. The return value is ") +
QString::number(ret) + QString("</nobr></font>");
lblHV->setToolTip(errTip);
comboHV->setToolTip(errTip);
}else{
if (comboHV)
comboHV->setToolTip(errTip);
else
spinHV->setToolTip(errTip);
} else {
lblHV->setPalette(lblDacs[0]->palette());
lblHV->setText("High Voltage:");
lblHV->setToolTip(tipHV);
comboHV->setToolTip(tipHV);
if (comboHV)
comboHV->setToolTip(tipHV);
else
spinHV->setToolTip(errTip);
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
switch (detType) {
slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index){
switch(detType){
case slsDetectorDefs::MYTHEN:
switch(index){
case 0: return slsDetectorDefs::TRIMBIT_SIZE;
case 1: return slsDetectorDefs::THRESHOLD;
case 2: return slsDetectorDefs::SHAPER1;
case 3: return slsDetectorDefs::SHAPER2;
case 4: return slsDetectorDefs::CALIBRATION_PULSE;
case 5: return slsDetectorDefs::PREAMP;
case slsDetectorDefs::EIGER:
switch (index) {
case 0:
return slsDetectorDefs::E_SvP;
case 1:
return slsDetectorDefs::E_SvN;
case 2:
return slsDetectorDefs::E_Vrf;
case 3:
return slsDetectorDefs::E_Vrs;
case 4:
return slsDetectorDefs::E_Vtr;
case 5:
return slsDetectorDefs::E_Vtgstv;
case 6:
return slsDetectorDefs::E_cal;
case 7:
return slsDetectorDefs::E_Vcp;
case 8:
return slsDetectorDefs::E_Vcn;
case 9:
return slsDetectorDefs::E_Vis;
case 10:
return slsDetectorDefs::E_rxb_lb;
case 11:
return slsDetectorDefs::E_rxb_rb;
case 12:
return slsDetectorDefs::E_Vcmp_ll;
case 13:
return slsDetectorDefs::E_Vcmp_lr;
case 14:
return slsDetectorDefs::E_Vcmp_rl;
case 15:
return slsDetectorDefs::E_Vcmp_rr;
case 16:
return slsDetectorDefs::THRESHOLD;
case 17:
return slsDetectorDefs::TEMPERATURE_FPGAEXT;
case 18:
return slsDetectorDefs::TEMPERATURE_10GE;
case 19:
return slsDetectorDefs::TEMPERATURE_DCDC;
case 20:
return slsDetectorDefs::TEMPERATURE_SODL;
case 21:
return slsDetectorDefs::TEMPERATURE_SODR;
case 22:
return slsDetectorDefs::TEMPERATURE_FPGA;
default:
qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error Index:"+ index,"qTabDeveloper::getSLSIndex");
qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex");
Refresh();
break;
}
break;
case slsDetectorDefs::EIGER:
switch(index){
case 0: return slsDetectorDefs::E_SvP;
case 1: return slsDetectorDefs::E_SvN;
case 2: return slsDetectorDefs::E_Vrf;
case 3: return slsDetectorDefs::E_Vrs;
case 4: return slsDetectorDefs::E_Vtr;
case 5: return slsDetectorDefs::E_Vtgstv;
case 6: return slsDetectorDefs::E_cal;
case 7: return slsDetectorDefs::E_Vcp;
case 8: return slsDetectorDefs::E_Vcn;
case 9: return slsDetectorDefs::E_Vis;
case 10:return slsDetectorDefs::E_rxb_lb;
case 11:return slsDetectorDefs::E_rxb_rb;
case 12:return slsDetectorDefs::E_Vcmp_ll;
case 13:return slsDetectorDefs::E_Vcmp_lr;
case 14:return slsDetectorDefs::E_Vcmp_rl;
case 15:return slsDetectorDefs::E_Vcmp_rr;
case 16:return slsDetectorDefs::THRESHOLD;
case 17:return slsDetectorDefs::TEMPERATURE_FPGAEXT;
case 18:return slsDetectorDefs::TEMPERATURE_10GE;
case 19:return slsDetectorDefs::TEMPERATURE_DCDC;
case 20:return slsDetectorDefs::TEMPERATURE_SODL;
case 21:return slsDetectorDefs::TEMPERATURE_SODR;
case 22:return slsDetectorDefs::TEMPERATURE_FPGA;
default:
qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error Index:"+ index,"qTabDeveloper::getSLSIndex");
Refresh();
break;
}
case slsDetectorDefs::GOTTHARD:
switch (index) {
case 0:
return slsDetectorDefs::G_VREF_DS;
case 1:
return slsDetectorDefs::G_VCASCN_PB;
case 2:
return slsDetectorDefs::G_VCASCP_PB;
case 3:
return slsDetectorDefs::G_VOUT_CM;
case 4:
return slsDetectorDefs::G_VCASC_OUT;
case 5:
return slsDetectorDefs::G_VIN_CM;
case 6:
return slsDetectorDefs::G_VREF_COMP;
case 7:
return slsDetectorDefs::G_IB_TESTC;
case 8:
return slsDetectorDefs::TEMPERATURE_ADC;
case 9:
return slsDetectorDefs::TEMPERATURE_FPGA;
default:
qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex");
Refresh();
break;
case slsDetectorDefs::MOENCH:
switch(index){
case 0: return slsDetectorDefs::V_DAC0;
case 1: return slsDetectorDefs::V_DAC1;
case 2: return slsDetectorDefs::V_DAC2;
case 3: return slsDetectorDefs::V_DAC3;
case 4: return slsDetectorDefs::V_DAC4;
case 5: return slsDetectorDefs::V_DAC5;
case 6: return slsDetectorDefs::V_DAC6;
case 7: return slsDetectorDefs::V_DAC7;
case 8: return slsDetectorDefs::TEMPERATURE_ADC;
case 9:return slsDetectorDefs::TEMPERATURE_FPGA;
}
break;
default:
qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error. Index:"+ index,"qTabDeveloper::getSLSIndex");
Refresh();
break;
}
break;
case slsDetectorDefs::PROPIX:
case slsDetectorDefs::GOTTHARD:
switch(index){
case 0: return slsDetectorDefs::G_VREF_DS;
case 1: return slsDetectorDefs::G_VCASCN_PB;
case 2: return slsDetectorDefs::G_VCASCP_PB;
case 3: return slsDetectorDefs::G_VOUT_CM;
case 4: return slsDetectorDefs::G_VCASC_OUT;
case 5: return slsDetectorDefs::G_VIN_CM;
case 6: return slsDetectorDefs::G_VREF_COMP;
case 7: return slsDetectorDefs::G_IB_TESTC;
case 8: return slsDetectorDefs::TEMPERATURE_ADC;
case 9:return slsDetectorDefs::TEMPERATURE_FPGA;
default:
qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error Index:"+ index,"qTabDeveloper::getSLSIndex");
Refresh();
break;
}
break;
case slsDetectorDefs::JUNGFRAU:
case slsDetectorDefs::JUNGFRAUCTB:
case slsDetectorDefs::JUNGFRAU:
if (index >= 0 && index <= 7) {
return (slsDetectorDefs::dacIndex)index;
}
if (index == 8) {
return slsDetectorDefs::TEMPERATURE_ADC;
} else {
qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex");
Refresh();
}
break;
case slsDetectorDefs::MOENCH:
if (index >= 0 && index <= 7) {
return (slsDetectorDefs::dacIndex)index;
} else {
qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex");
Refresh();
}
break;
switch(index){
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
return (slsDetectorDefs::dacIndex)index;
break;
case 8: return slsDetectorDefs::TEMPERATURE_ADC;
default:
qDefs::Message(qDefs::CRITICAL,"Unknown DAC/ADC Index. Weird Error Index:"+ index,"qTabDeveloper::getSLSIndex");
Refresh();
break;
}
break;
default:
cout << "Unknown detector type:" + myDet->slsDetectorBase::getDetectorType(detType) << endl;
qDefs::Message(qDefs::CRITICAL,string("Unknown detector type:")+myDet->slsDetectorBase::getDetectorType(detType),"qTabDeveloper::getSLSIndex");
qDefs::checkErrorMessage(myDet,"qTabDeveloper::getSLSIndex");
exit(-1);
break;
default:
FILE_LOG(logERROR) << "Unknown detector type:" + myDet->getDetectorTypeAsString();
qDefs::Message(qDefs::CRITICAL, std::string("Unknown detector type:") + myDet->getDetectorTypeAsString(), "qTabDeveloper::getSLSIndex");
qDefs::checkErrorMessage(myDet, "qTabDeveloper::getSLSIndex");
exit(-1);
break;
}
return slsDetectorDefs::HUMIDITY;
return (slsDetectorDefs::dacIndex)0;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDeveloper::RefreshAdcs() {
FILE_LOG(logDEBUG) << "Updating ADCs";
auto moduleId = comboDetector->currentIndex() - 1;
void qTabDeveloper::RefreshAdcs(){
if(!thisParent->isCurrentlyTabDeveloper())
return;
for (int i = 0; i < numADCWidgets; ++i) {
#ifdef VERYVERBOSE
cout << "Updating ADCs" <<endl;
#endif
/*adcTimer->stop();*/
int detid = comboDetector->currentIndex();
if(detid)
det = myDet->getSlsDetector(detid-1);
for(int i=0;i<NUM_ADC_WIDGETS;i++){
//all detectors
if(!detid){
double value = (double)myDet->getADC(getSLSIndex(i+NUM_DAC_WIDGETS),-1);
if(value == -1)
spinAdcs[i]->setText(QString("Different values"));
else {
if(detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU || detType == slsDetectorDefs::JUNGFRAUCTB)
value/=1000.00;
spinAdcs[i]->setText(QString::number(value,'f',2)+0x00b0+QString("C"));
}
}
//specific detector
else{
double value = (double)det->getADC(getSLSIndex(i+NUM_DAC_WIDGETS));
if(detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU || detType == slsDetectorDefs::JUNGFRAUCTB)
value/=1000.00;
spinAdcs[i]->setText(QString::number(value,'f',2)+0x00b0+QString("C"));
double value = (double)myDet->getADC(getSLSIndex(i + numDACWidgets), moduleId);
if (value == -1 && moduleId == -1) {
spinAdcs[i]->setText(QString("Different values"));
} else {
if (detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU)
value /= 1000.00;
spinAdcs[i]->setText(QString::number(value, 'f', 2) + 0x00b0 + QString("C"));
}
}
/*adcTimer->start(ADC_TIMEOUT);*/
qDefs::checkErrorMessage(myDet,"qTabDeveloper::RefreshAdcs");
qDefs::checkErrorMessage(myDet, "qTabDeveloper::RefreshAdcs");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDeveloper::Refresh() {
FILE_LOG(logDEBUG) << "**Updating Developer Tab\n";
auto moduleId = comboDetector->currentIndex() - 1;
void qTabDeveloper::Refresh(){
#ifdef VERBOSE
cout << endl << "**Updating Developer Tab" << endl;
#endif
int detid = comboDetector->currentIndex();
if(detid)
det = myDet->getSlsDetector(detid-1);
//dacs
#ifdef VERBOSE
cout << "Getting DACs" << NUM_DAC_WIDGETS <<endl;
#endif
for(int i=0;i<NUM_DAC_WIDGETS;i++){
//all detectors
if(!detid){
spinDacs[i]->setValue((double)myDet->setDAC(-1,getSLSIndex(i),0));
lblDacsmV[i]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(i),1),-10));
}
//specific detector
else{
spinDacs[i]->setValue((double)det->setDAC(-1,getSLSIndex(i),0));
lblDacsmV[i]->setText(QString("%1mV").arg(det->setDAC(-1,getSLSIndex(i),1),-10));
}
// dacs
FILE_LOG(logDEBUG) << "Getting DACs";
for (int i = 0; i < numDACWidgets; ++i) {
spinDacs[i]->setValue(myDet->setDAC(-1, getSLSIndex(i), 0, moduleId));
lblDacsmV[i]->setText(QString("%1mV").arg(myDet->setDAC(-1, getSLSIndex(i), 1, moduleId), -10));
}
//adcs
if(NUM_ADC_WIDGETS) RefreshAdcs();
if (numADCWidgets)
RefreshAdcs();
//gotthard -high voltage
if((detType == slsDetectorDefs::GOTTHARD) ||
(detType == slsDetectorDefs::PROPIX) ||
(detType == slsDetectorDefs::MOENCH)){
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
if ((detType == slsDetectorDefs::GOTTHARD) ||
(detType == slsDetectorDefs::JUNGFRAU) ||
(detType == slsDetectorDefs::MOENCH)) {
if (comboHV)
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
else
disconnect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
//default should be correct
lblHV->setPalette(lblDacs[0]->palette());
lblHV->setText("High Voltage:");
lblHV->setToolTip(tipHV);
comboHV->setToolTip(tipHV);
//getting hv value
int ret;
if(!detid) ret = (int)myDet->setDAC(-1,slsDetectorDefs::HV_POT,0);
else ret = (int)det->setDAC(-1,slsDetectorDefs::HV_POT,0);
if (comboHV)
comboHV->setToolTip(tipHV);
else
spinHV->setToolTip(tipHV);
switch(ret){
case 0: comboHV->setCurrentIndex(0);break;
case 90: comboHV->setCurrentIndex(1);break;
case 110: comboHV->setCurrentIndex(2);break;
case 120: comboHV->setCurrentIndex(3);break;
case 150: comboHV->setCurrentIndex(4);break;
case 180: comboHV->setCurrentIndex(5);break;
case 200: comboHV->setCurrentIndex(6);break;
default: comboHV->setCurrentIndex(0);//error
lblHV->setPalette(red);
lblHV->setText("High Voltage:*");
QString errTip = tipHV+QString("<br><br><font color=\"red\"><nobr>High Voltage could not be set. The return value is ")+
QString::number(ret)+ QString("</nobr></font>");
lblHV->setToolTip(errTip);
comboHV->setToolTip(errTip);
break;
//getting hv value
int ret = myDet->setDAC(-1, slsDetectorDefs::HIGH_VOLTAGE, 0, moduleId);
bool error = false;
if (spinHV) {
if (ret != 0 && ret < 60 && ret > 200)
error = true;
else
spinHV->setValue(ret);
} else {
switch (ret) {
case 0:
comboHV->setCurrentIndex(0);
break;
case 90:
comboHV->setCurrentIndex(1);
break;
case 110:
comboHV->setCurrentIndex(2);
break;
case 120:
comboHV->setCurrentIndex(3);
break;
case 150:
comboHV->setCurrentIndex(4);
break;
case 180:
comboHV->setCurrentIndex(5);
break;
case 200:
comboHV->setCurrentIndex(6);
break;
default:
comboHV->setCurrentIndex(0); //error
error = true;
break;
}
}
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
if (error) {
lblHV->setPalette(red);
lblHV->setText("High Voltage:*");
QString errTip = tipHV + QString("<br><br><font color=\"red\"><nobr>High Voltage could not be set. The return value is ") +
QString::number(ret) + QString("</nobr></font>");
lblHV->setToolTip(errTip);
if (comboHV)
comboHV->setToolTip(errTip);
else
spinHV->setToolTip(errTip);
} else {
lblHV->setPalette(lblDacs[0]->palette());
lblHV->setText("High Voltage:");
lblHV->setToolTip(tipHV);
if (comboHV)
comboHV->setToolTip(tipHV);
else
spinHV->setToolTip(errTip);
}
if (comboHV)
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
else
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
}
#ifdef VERBOSE
cout << "**Updated Developer Tab" << endl << endl;
#endif
FILE_LOG(logDEBUG) << "**Updated Developer Tab";
qDefs::checkErrorMessage(myDet,"qTabDeveloper::Refresh");
qDefs::checkErrorMessage(myDet, "qTabDeveloper::Refresh");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

1263
slsDetectorGui/src/qTabMeasurement.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

145
slsDetectorGui/src/qTabMessages.cpp Normal file → Executable file
View File

@@ -1,122 +1,95 @@
/*
* qTabMessages.cpp
*
* Created on: Jun 26, 2012
* Author: l_maliakal_d
*/
/** Qt Project Class Headers */
#include "qTabMessages.h"
#include "qDetectorMain.h"
/** Project Class Headers */
/** Qt Include Headers */
#include <QGridLayout>
#include <QFile>
#include <QTextStream>
#include <QFileDialog>
#include <QGridLayout>
#include <QTextStream>
/** C++ Include Headers */
#include <iostream>
#include <string>
using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabMessages::qTabMessages(qDetectorMain* m):myMainTab(m),qout(0),qerr(0){
SetupWidgetWindow();
Initialization();
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
SetupWidgetWindow();
Initialization();
FILE_LOG(logDEBUG) << "Messages ready";
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabMessages::~qTabMessages(){
delete myMainTab;
delete dispLog;
delete qout;
delete qerr;
qTabMessages::~qTabMessages() {
delete dispLog;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMessages::SetupWidgetWindow(){
/** Layout */
QGridLayout *gridLayout = new QGridLayout(this);
void qTabMessages::SetupWidgetWindow() {
/** Layout */
QGridLayout *gridLayout = new QGridLayout(this);
dispLog = new QTextEdit(this);
dispLog->setReadOnly(true);
dispLog->setFocusPolicy(Qt::NoFocus);
dispLog->setTextColor(Qt::darkBlue);
dispLog = new QTextEdit(this);
dispLog->setReadOnly(true);
dispLog->setFocusPolicy(Qt::NoFocus);
dispLog->setTextColor(Qt::darkBlue);
btnSave = new QPushButton("Save Log ", this);
btnSave->setFocusPolicy(Qt::NoFocus);
btnSave->setFixedWidth(100);
btnSave->setIcon(QIcon(":/icons/images/save.png"));
btnSave = new QPushButton("Save Log ",this);
btnSave->setFocusPolicy(Qt::NoFocus);
btnSave->setFixedWidth(100);
btnSave->setIcon(QIcon( ":/icons/images/save.png" ));
btnClear = new QPushButton("Clear ", this);
btnClear->setFocusPolicy(Qt::NoFocus);
btnClear->setFixedWidth(100);
btnClear->setIcon(QIcon(":/icons/images/erase.png"));
btnClear = new QPushButton("Clear ",this);
btnClear->setFocusPolicy(Qt::NoFocus);
btnClear->setFixedWidth(100);
btnClear->setIcon(QIcon( ":/icons/images/erase.png" ));
gridLayout->addItem(new QSpacerItem(15,10,QSizePolicy::Fixed,QSizePolicy::Fixed),0,0);
gridLayout->addWidget(btnSave,1,0,1,1);
gridLayout->addWidget(btnClear,1,4,1,1);
gridLayout->addItem(new QSpacerItem(15,10,QSizePolicy::Fixed,QSizePolicy::Fixed),2,0);
gridLayout->addWidget(dispLog,3,0,1,5);
errMsg = "<nobr> Please check Messages Tab. Following message was caught:</nobr><br><br><nobr><font color=\"darkBlue\">";
qout=new qDebugStream(std::cout,this);
qerr=new qDebugStream(std::cerr,this);
gridLayout->addItem(new QSpacerItem(15, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 0);
gridLayout->addWidget(btnSave, 1, 0, 1, 1);
gridLayout->addWidget(btnClear, 1, 4, 1, 1);
gridLayout->addItem(new QSpacerItem(15, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 2, 0);
gridLayout->addWidget(dispLog, 3, 0, 1, 5);
qDebugStream *qout = new qDebugStream(std::cout, this);
qDebugStream *qerr = new qDebugStream(std::cerr, this);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMessages::Initialization(){
connect(btnSave,SIGNAL(clicked()),this,SLOT(SaveLog()));
connect(btnClear,SIGNAL(clicked()),this,SLOT(ClearLog()));
void qTabMessages::Initialization() {
connect(btnSave, SIGNAL(clicked()), this, SLOT(SaveLog()));
connect(btnClear, SIGNAL(clicked()), this, SLOT(ClearLog()));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMessages::customEvent(QEvent *e) {
if (e->type() == (STREAMEVENT)){
QString temp = ((qStreamEvent*)e)->getString();
dispLog->append(temp);
}
if (e->type() == (STREAMEVENT)) {
QString temp = ((qStreamEvent *)e)->getString();
dispLog->append(temp);
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMessages::SaveLog() {
QString fName = QString(myMainTab->GetFilePath());
fName = fName+"/LogFile.txt";
fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),
fName,tr("Text files (*.txt);;All Files(*)"));
if (!fName.isEmpty()){
QFile outfile;
outfile.setFileName(fName);
if(outfile.open(QIODevice::WriteOnly | QIODevice::Text)){//Append
QTextStream out(&outfile);
out<<dispLog->toPlainText() << endl;
qDefs::Message(qDefs::INFORMATION,string("The Log has been successfully saved to "
"")+fName.toAscii().constData(),"qTabMessages::SaveLog");
}
else qDefs::Message(qDefs::WARNING,"Attempt to save log file failed.","qTabMessages::SaveLog");
}
QString fName = QString(""); //FIXME:current directory?
fName = fName + "/LogFile.txt";
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "),
fName, tr("Text files (*.txt);;All Files(*)"));
if (!fName.isEmpty()) {
QFile outfile;
outfile.setFileName(fName);
if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) { //Append
QTextStream out(&outfile);
out << dispLog->toPlainText() << endl;
qDefs::Message(qDefs::INFORMATION, std::string("The Log has been successfully saved to "
"") +
fName.toAscii().constData(),
"qTabMessages::SaveLog");
} else {
FILE_LOG(logWARNING) << "Attempt to save log file failed.";
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.", "qTabMessages::SaveLog");
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMessages::ClearLog() {
dispLog->clear();
#ifdef VERBOSE
cout<<"Log Cleared"<<endl;
#endif
dispLog->clear();
FILE_LOG(logINFO) << "Log Cleared";
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

2381
slsDetectorGui/src/qTabPlot.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

595
slsDetectorGui/src/qTabSettings.cpp Normal file → Executable file
View File

@@ -1,385 +1,304 @@
/*
* qTabSettings.cpp
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#include "qTabSettings.h"
// Project Class Headers
#include "slsDetector.h"
#include "multiSlsDetector.h"
// C++ Include Headers
#include<iostream>
#include <QStandardItemModel>
#include <cmath>
using namespace std;
#include <iostream>
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabSettings::qTabSettings(QWidget *parent, multiSlsDetector *detector)
: QWidget(parent), myDet(detector), detType(slsDetectorDefs::GENERIC) {
qTabSettings::qTabSettings(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector),expertMode(false){
for(int i=0;i<NumSettings;i++)
item[i]=0;
setupUi(this);
SetupWidgetWindow();
setupUi(this);
SetupWidgetWindow();
Initialization();
FILE_LOG(logDEBUG) << "Settings ready";
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabSettings::~qTabSettings() {}
qTabSettings::~qTabSettings(){
delete myDet;
void qTabSettings::SetupWidgetWindow() {
// Detector Type
detType = myDet->getDetectorTypeAsEnum();
// Settings
comboSettings->setCurrentIndex(UNINITIALIZED);
if (detType == slsDetectorDefs::MOENCH) {
lblSettings->setEnabled(false);
comboSettings->setEnabled(false);
} else {
SetupDetectorSettings();
GetSettings();
}
// Dynamic Range
GetDynamicRange();
// cannot change dr for other types
if (detType != slsDetectorDefs::EIGER) {
lblDynamicRange->setEnabled(false);
comboDynamicRange->setEnabled(false);
}
// threshold energy
if (detType == slsDetectorDefs::EIGER) {
qDefs::IgnoreNonCriticalExceptions<QSpinBox>(
spinThreshold,
&QSpinBox::setValue,
myDet,
std::string("qTabSettings::SetupWidgetWindow"),
&multiSlsDetector::getThresholdEnergy, -1);
} else {
lblThreshold->setEnabled(false);
spinThreshold->setEnabled(false);
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabSettings::SetupDetectorSettings() {
void qTabSettings::SetupWidgetWindow(){
// Detector Type
detType=myDet->getDetectorsType();
// To be able to index items on a combo box
QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboSettings->model());
if (model) {
QModelIndex index[NUMSETTINGS];
QStandardItem *item[NUMSETTINGS];
for (int i = 0; i < NUMSETTINGS; ++i) {
index[i] = model->index(i, comboSettings->modelColumn(),
comboSettings->rootModelIndex());
item[i] = model->itemFromIndex(index[i]);
}
// Settings
if (detType != slsReceiverDefs::JUNGFRAUCTB) {
SetupDetectorSettings();
} else
comboSettings->setEnabled(false);
item[(int)UNDEFINED]->setEnabled(false);
item[(int)UNINITIALIZED]->setEnabled(false);
//threshold
if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::EIGER))
spinThreshold->setValue(myDet->getThresholdEnergy());
switch (detType) {
case slsDetectorDefs::EIGER:
item[(int)STANDARD]->setEnabled(true);
item[(int)HIGHGAIN]->setEnabled(true);
item[(int)LOWGAIN]->setEnabled(true);
item[(int)VERYHIGHGAIN]->setEnabled(true);
item[(int)VERLOWGAIN]->setEnabled(true);
//expert mode is not enabled initially
lblThreshold->setEnabled(false);
spinThreshold->setEnabled(false);
item[(int)FAST]->setEnabled(false);
item[(int)DYNAMICGAIN]->setEnabled(false);
item[(int)MEDIUMGAIN]->setEnabled(false);
item[(int)LOWNOISE]->setEnabled(false);
item[(int)DYNAMICHG0]->setEnabled(false);
item[(int)FIXGAIN1]->setEnabled(false);
item[(int)FIXGAIN2]->setEnabled(false);
item[(int)FORCESWITCHG1]->setEnabled(false);
item[(int)FORCESWITCHG2]->setEnabled(false);
break;
// Number of Modules
spinNumModules->setMaximum(myDet->getMaxNumberOfModules());
spinNumModules->setValue(myDet->setNumberOfModules());
case slsDetectorDefs::GOTTHARD:
item[(int)HIGHGAIN]->setEnabled(true);
item[(int)DYNAMICGAIN]->setEnabled(true);
item[(int)LOWGAIN]->setEnabled(true);
item[(int)MEDIUMGAIN]->setEnabled(true);
item[(int)VERYHIGHGAIN]->setEnabled(true);
Initialization();
item[(int)STANDARD]->setEnabled(false);
item[(int)FAST]->setEnabled(false);
item[(int)LOWNOISE]->setEnabled(false);
item[(int)DYNAMICHG0]->setEnabled(false);
item[(int)FIXGAIN1]->setEnabled(false);
item[(int)FIXGAIN2]->setEnabled(false);
item[(int)FORCESWITCHG1]->setEnabled(false);
item[(int)FORCESWITCHG2]->setEnabled(false);
item[(int)VERLOWGAIN]->setEnabled(false);
break;
// Dynamic Range
GetDynamicRange();
case slsDetectorDefs::JUNGFRAU:
item[(int)DYNAMICGAIN]->setEnabled(true);
item[(int)DYNAMICHG0]->setEnabled(true);
item[(int)FIXGAIN1]->setEnabled(true);
item[(int)FIXGAIN2]->setEnabled(true);
item[(int)FORCESWITCHG1]->setEnabled(true);
item[(int)FORCESWITCHG2]->setEnabled(true);
qDefs::checkErrorMessage(myDet,"qTabSettings::SetupWidgetWindow");
item[(int)STANDARD]->setEnabled(false);
item[(int)FAST]->setEnabled(false);
item[(int)HIGHGAIN]->setEnabled(false);
item[(int)LOWGAIN]->setEnabled(false);
item[(int)MEDIUMGAIN]->setEnabled(false);
item[(int)VERYHIGHGAIN]->setEnabled(false);
item[(int)LOWNOISE]->setEnabled(false);
item[(int)VERLOWGAIN]->setEnabled(false);
break;
default:
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
qDefs::Message(qDefs::CRITICAL,
"Unknown detector type. Exiting GUI.",
"qTabSettings::SetupDetectorSettings");
exit(-1);
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabSettings::GetDynamicRange(int setvalue){
#ifdef VERBOSE
cout << "Getting dynamic range" << endl;
#endif
int ret = myDet->setDynamicRange(-1);
if(detType == slsDetectorDefs::MYTHEN) {
if(ret==24)
ret=32;
else if(ret==24)
cout<<"ret:"<<ret<<endl;
}
//check if the set value is equal to return value
if((setvalue!=-1) && (setvalue!=ret)){
qDefs::Message(qDefs::WARNING,"Dynamic Range cannot be set to this value.","qTabSettings::SetDynamicRange");
#ifdef VERBOSE
cout << "ERROR: Setting dynamic range to "<< ret << endl;
#endif
}
//set the final value on gui
disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
switch(ret){
case 32: comboDynamicRange->setCurrentIndex(0); break;
case 16: comboDynamicRange->setCurrentIndex(1); break;
case 8: comboDynamicRange->setCurrentIndex(2); break;
case 4: comboDynamicRange->setCurrentIndex(3); break;
default: comboDynamicRange->setCurrentIndex(0); break;
}
connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
void qTabSettings::Initialization() {
// Settings
if (comboSettings->isEnabled())
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
// Dynamic Range
if (comboDynamicRange->isEnabled())
connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
// Threshold
if (spinThreshold->isEnabled())
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetEnergy()));
}
void qTabSettings::GetSettings() {
FILE_LOG(logDEBUG) << "Getting settings";
//-------------------------------------------------------------------------------------------------------------------------------------------------
int sett = qDefs::IgnoreNonCriticalExceptionsandReturn(
myDet, std::string("qTabSettings::SetupWidgetWindow"),
&multiSlsDetector::getSettings, -1);
FILE_LOG(logDEBUG) << "Settings from Detector:" << sett;
void qTabSettings::SetupDetectorSettings(){
// Get detector settings from detector
int sett = (int)myDet->getSettings();cout<<"sett:"<<sett<<endl;
qDefs::checkErrorMessage(myDet,"qTabSettings::SetupDetectorSettings");
if(sett==-1) sett = Undefined;
if(sett == slsDetectorDefs::UNDEFINED) sett = Undefined;
else if(sett == slsDetectorDefs::UNINITIALIZED) sett = Uninitialized;
// To be able to index items on a combo box
model = qobject_cast<QStandardItemModel*>(comboSettings->model());
if (model) {
for(int i=0;i<NumSettings;i++){
index[i] = model->index(i, comboSettings->modelColumn(), comboSettings->rootModelIndex());
item[i] = model->itemFromIndex(index[i]);
}
if (sett == -1)
sett = UNDEFINED;
if (sett == slsDetectorDefs::UNDEFINED)
sett = UNDEFINED;
else if (sett == slsDetectorDefs::UNINITIALIZED)
sett = UNINITIALIZED;
switch(detType){
case slsDetectorDefs::MYTHEN:
item[(int)Standard]->setEnabled(true);
item[(int)Fast]->setEnabled(true);
item[(int)HighGain]->setEnabled(true);
item[(int)DynamicGain]->setEnabled(false);
item[(int)LowGain]->setEnabled(false);
item[(int)MediumGain]->setEnabled(false);
item[(int)VeryHighGain]->setEnabled(false);
item[(int)LowNoise]->setEnabled(false);
item[(int)DynamicHG0]->setEnabled(false);
item[(int)FixGain1]->setEnabled(false);
item[(int)FixGain2]->setEnabled(false);
item[(int)ForceSwitchG1]->setEnabled(false);
item[(int)ForceSwitchG2]->setEnabled(false);
item[(int)VeryLowGain]->setEnabled(false);
break;
case slsDetectorDefs::EIGER:
item[(int)Standard]->setEnabled(true);
item[(int)Fast]->setEnabled(false);
item[(int)HighGain]->setEnabled(true);
item[(int)DynamicGain]->setEnabled(false);
item[(int)LowGain]->setEnabled(true);
item[(int)MediumGain]->setEnabled(false);
item[(int)VeryHighGain]->setEnabled(true);
item[(int)LowNoise]->setEnabled(false);
item[(int)DynamicHG0]->setEnabled(false);
item[(int)FixGain1]->setEnabled(false);
item[(int)FixGain2]->setEnabled(false);
item[(int)ForceSwitchG1]->setEnabled(false);
item[(int)ForceSwitchG2]->setEnabled(false);
item[(int)VeryLowGain]->setEnabled(true);
break;
case slsDetectorDefs::MOENCH:
case slsDetectorDefs::PROPIX:
case slsDetectorDefs::GOTTHARD:
item[(int)Standard]->setEnabled(false);
item[(int)Fast]->setEnabled(false);
item[(int)HighGain]->setEnabled(true);
item[(int)DynamicGain]->setEnabled(true);
item[(int)LowGain]->setEnabled(true);
item[(int)MediumGain]->setEnabled(true);
item[(int)VeryHighGain]->setEnabled(true);
item[(int)LowNoise]->setEnabled(false);
item[(int)DynamicHG0]->setEnabled(false);
item[(int)FixGain1]->setEnabled(false);
item[(int)FixGain2]->setEnabled(false);
item[(int)ForceSwitchG1]->setEnabled(false);
item[(int)ForceSwitchG2]->setEnabled(false);
item[(int)VeryLowGain]->setEnabled(false);
break;
case slsDetectorDefs::JUNGFRAU:
item[(int)Standard]->setEnabled(false);
item[(int)Fast]->setEnabled(false);
item[(int)HighGain]->setEnabled(false);
item[(int)DynamicGain]->setEnabled(true);
item[(int)LowGain]->setEnabled(false);
item[(int)MediumGain]->setEnabled(false);
item[(int)VeryHighGain]->setEnabled(false);
item[(int)LowNoise]->setEnabled(false);
item[(int)DynamicHG0]->setEnabled(true);
item[(int)FixGain1]->setEnabled(true);
item[(int)FixGain2]->setEnabled(true);
item[(int)ForceSwitchG1]->setEnabled(true);
item[(int)ForceSwitchG2]->setEnabled(true);
item[(int)VeryLowGain]->setEnabled(false);
break;
default:
cout << "Unknown detector type. Exiting GUI." << endl;
qDefs::Message(qDefs::CRITICAL,"Unknown detector type. Exiting GUI.","qTabSettings::SetupDetectorSettings");
exit(-1);
break;
}
// detector settings selected NOT ENABLED.
// This should not happen -only if the server and gui has a mismatch
// on which all modes are allowed in detectors
if(!(item[sett]->isEnabled())){
qDefs::Message(qDefs::CRITICAL,"Unknown Detector Settings retrieved from detector. Exiting GUI.","qTabSettings::SetupDetectorSettings");
#ifdef VERBOSE
cout << "ERROR: Unknown Detector Settings retrieved from detector." << endl;
#endif
sett= Undefined;
// exit(-1);
}
// Setting the detector settings
else comboSettings->setCurrentIndex(sett);
}
comboSettings->setCurrentIndex(sett);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabSettings::GetDynamicRange() {
FILE_LOG(logDEBUG) << "Getting dynamic range";
void qTabSettings::Initialization(){
// Settings
if (detType != slsReceiverDefs::JUNGFRAUCTB)
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
// Number of Modules
connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int)));
// Dynamic Range
connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
// Threshold
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
int ret = qDefs::IgnoreNonCriticalExceptionsandReturn(
myDet, std::string("qTabSettings::GetDynamicRange"),
&multiSlsDetector::setDynamicRange, -1, -1);
// set the final value on gui
switch (ret) {
case 32:
comboDynamicRange->setCurrentIndex(0);
break;
case 16:
comboDynamicRange->setCurrentIndex(1);
break;
case 8:
comboDynamicRange->setCurrentIndex(2);
break;
case 4:
comboDynamicRange->setCurrentIndex(3);
break;
default:
if (ret != -1) {
qDefs::Message(qDefs::WARNING,
"Unknown Dyanmic Range " + std::to_string(ret) + ".",
"qTabSettings::SetupDetectorSettings");
}
break;
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabSettings::SetSettings(int index) {
slsDetectorDefs::detectorSettings sett =
myDet->setSettings((slsDetectorDefs::detectorSettings)index);
FILE_LOG(logINFO) << "Settings set to "
<< myDet->slsDetectorDefs::getDetectorSettings(sett);
void qTabSettings::setSettings(int index){
//dont set it if settings is set to undefined or uninitialized
if((index==Undefined)||(index==Uninitialized)){
qDefs::Message(qDefs::WARNING,"Cannot change settings to Undefined or Uninitialized.","qTabSettings::setSettings");
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
int sett = (int)myDet->getSettings();
if(sett==-1) sett = Undefined;
if(sett == slsDetectorDefs::UNDEFINED) sett = Undefined;
else if(sett == slsDetectorDefs::UNINITIALIZED) sett = Uninitialized;
comboSettings->setCurrentIndex(sett);
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
}
// threshold
if (spinThreshold->isEnabled()) {
SetEnergy();
}
else{
slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index);
#ifdef VERBOSE
cout << endl << "Settings have been set to " << myDet->slsDetectorBase::getDetectorSettings(sett) << endl;
#endif
//threshold
if((detType==slsDetectorDefs::MYTHEN)||(detType==slsDetectorDefs::EIGER)){
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
SetEnergy();
//also update trimbits plot
if(expertMode) emit UpdateTrimbitSignal(0);
}
}
qDefs::checkErrorMessage(myDet,"qTabSettings::setSettings");
qDefs::checkErrorMessage(myDet, "qTabSettings::SetSettings");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabSettings::SetDynamicRange(int index) {
int dr;
switch (index) {
case 0:
dr = 32;
break;
case 1:
dr = 16;
break;
case 2:
dr = 8;
break;
case 3:
dr = 4;
break;
default:
break;
}
int ret = myDet->setDynamicRange(dr);
FILE_LOG(logINFO) << "Setting dynamic range to " << dr;
qDefs::checkErrorMessage(myDet, "qTabSettings::SetDynamicRange");
void qTabSettings::SetNumberOfModules(int index){
#ifdef VERBOSE
cout << "Setting number of modules to "<< index << endl;
#endif
int i = myDet->setNumberOfModules(index);
if(index!=i)
qDefs::Message(qDefs::WARNING,"Number of modules cannot be set for this value.","qTabSettings::SetNumberOfModules");
#ifdef VERBOSE
cout << "ERROR: Setting number of modules to "<< i << endl;
#endif
spinNumModules->setValue(i);
qDefs::checkErrorMessage(myDet,"qTabSettings::SetNumberOfModules");
// check
if (ret != dr) {
qDefs::Message(qDefs::WARNING, "Could not set dynamic range.",
"qTabSettings::SetDynamicRange");
disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
GetDynamicRange();
connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabSettings::SetEnergy() {
int index = spinThreshold->value();
FILE_LOG(logINFO) << "Settings threshold energy to " << index;
myDet->setThresholdEnergy(index);
int ret = myDet->getThresholdEnergy();
if ((ret - index) > 200) {
qDefs::Message(qDefs::WARNING,
"Threshold energy could not be set (tolerance 200).",
"qTabSettings::SetEnergy");
}
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetEnergy()));
spinThreshold->setValue(ret);
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
void qTabSettings::SetDynamicRange(int index){
int dr;
switch (index) {
case 0: dr=32; break;
case 1: dr=16; break;
case 2: dr=8; break;
case 3: dr=4; break;
default: dr=32; break;
}
myDet->setDynamicRange(dr);
#ifdef VERBOSE
cout << "Setting dynamic range to "<< dr << endl;
#endif
//check
GetDynamicRange(dr);
qDefs::checkErrorMessage(myDet,"qTabSettings::SetDynamicRange");
qDefs::checkErrorMessage(myDet, "qTabSettings::SetEnergy");
}
void qTabSettings::Refresh() {
FILE_LOG(logDEBUG) << "\n**Updating Settings Tab";
//-------------------------------------------------------------------------------------------------------------------------------------------------
// settings
if (comboSettings->isEnabled()) {
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
GetSettings();
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
}
// threshold
if (spinThreshold->isEnabled()) {
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetEnergy()));
spinThreshold->setValue(myDet->getThresholdEnergy());
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetEnergy()));
}
void qTabSettings::SetEnergy(){
int index = spinThreshold->value();
#ifdef VERBOSE
cout << "Settings threshold energy to "<< index << endl;
#endif
myDet->setThresholdEnergy(index);
int ret = (int)myDet->getThresholdEnergy();
if((ret-index)>200){
qDefs::Message(qDefs::WARNING,"Threshold energy could not be set. The difference is greater than 200.","qTabSettings::SetEnergy");
}
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
spinThreshold->setValue(ret);
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
// Dynamic Range
if (comboDynamicRange->isEnabled()) {
disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
GetDynamicRange();
connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
}
qDefs::checkErrorMessage(myDet,"qTabSettings::SetEnergy");
FILE_LOG(logDEBUG) << "**Updated Settings Tab";
qDefs::checkErrorMessage(myDet, "qTabSettings::Refresh");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabSettings::Refresh(){
#ifdef VERBOSE
cout << endl << "**Updating Settings Tab" << endl;
#endif
if (detType != slsReceiverDefs::JUNGFRAUCTB)
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
disconnect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int)));
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
// Number of Modules
#ifdef VERBOSE
cout << "Getting number of modules:" ;
#endif
int numMod = myDet->setNumberOfModules();
#ifdef VERBOSE
cout << numMod << endl;
#endif
spinNumModules->setValue(numMod);
// Dynamic Range
GetDynamicRange();
// Settings
if (detType != slsReceiverDefs::JUNGFRAUCTB) {
#ifdef VERBOSE
cout << "Getting settings" << endl;
#endif
int sett = (int)myDet->getSettings();
if(sett==-1) sett = Undefined;//slsDetectorDefs::UNDEFINED;
if(sett == slsDetectorDefs::UNDEFINED) sett = Undefined;
else if(sett == slsDetectorDefs::UNINITIALIZED) sett = Uninitialized;
comboSettings->setCurrentIndex(sett);
//threshold
sett = comboSettings->currentIndex();
if((detType==slsDetectorDefs::MYTHEN)||(detType==slsDetectorDefs::EIGER)){
if((sett==Undefined)||(sett==Uninitialized)){
lblThreshold->setEnabled(false);
spinThreshold->setEnabled(false);
}else{
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
#ifdef VERBOSE
cout << "Getting threshold energy" << endl;
#endif
spinThreshold->setValue(myDet->getThresholdEnergy());
}
}
}
if (detType != slsReceiverDefs::JUNGFRAUCTB)
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));
connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int)));
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
#ifdef VERBOSE
cout << "**Updated Settings Tab" << endl << endl;
#endif
qDefs::checkErrorMessage(myDet,"qTabSettings::Refresh");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------