mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 10:30:41 +02:00
WIP
This commit is contained in:
parent
111c48e3fa
commit
cb2c39c62f
@ -1,28 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qDefs.h"
|
|
||||||
|
|
||||||
class multiSlsDetector;
|
class multiSlsDetector;
|
||||||
|
|
||||||
#include <QWidget>
|
class QGroupBox;
|
||||||
#include <QGridLayout>
|
class QLabel;
|
||||||
#include <QGroupBox>
|
class QDoubleSpinBox;
|
||||||
#include <QLabel>
|
class MyDoubleSpinBox;
|
||||||
#include <QLineEdit>
|
class QLineEdit;
|
||||||
#include <QComboBox>
|
class QComboBox;
|
||||||
#include <QDoubleSpinBox>
|
class QSpinBox;
|
||||||
#include <QScrollArea>
|
class QGridLayout;
|
||||||
#include <QTimer>
|
class QString;
|
||||||
#include <QString>
|
class QPalette;
|
||||||
#include <QPalette>
|
|
||||||
class qDetectorMain;
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
/**To override the spin box class to have an id and emit it*/
|
/**To override the spin box class to have an id and emit it*/
|
||||||
class MyDoubleSpinBox:public QDoubleSpinBox{
|
class MyDoubleSpinBox: public QDoubleSpinBox{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
int myId;
|
int myId;
|
||||||
@ -38,98 +34,50 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*@short sets up the Developer parameters
|
|
||||||
*/
|
|
||||||
class qTabDeveloper:public QWidget {
|
class qTabDeveloper:public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* The constructor
|
|
||||||
* @param parent is the parent tab widget
|
|
||||||
* @param detector is the detector returned from the detector tab
|
|
||||||
*/
|
|
||||||
qTabDeveloper(QWidget *parent, multiSlsDetector* detector);
|
qTabDeveloper(QWidget *parent, multiSlsDetector* detector);
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
~qTabDeveloper();
|
~qTabDeveloper();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh and update widgets
|
|
||||||
*/
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
void GetAdcs();
|
||||||
* Refreshes the adcs
|
void SetDac(int id);
|
||||||
*/
|
|
||||||
void RefreshAdcs();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Dac values
|
|
||||||
* @param id id of dac
|
|
||||||
*/
|
|
||||||
void SetDacValues(int id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set High Voltage
|
|
||||||
*/
|
|
||||||
void SetHighVoltage();
|
void SetHighVoltage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up the widget
|
|
||||||
*/
|
|
||||||
void SetupWidgetWindow();
|
void SetupWidgetWindow();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up all the slots and signals
|
|
||||||
*/
|
|
||||||
void Initialization();
|
void Initialization();
|
||||||
|
void PopulateDetectors();
|
||||||
/**
|
|
||||||
* Sets up the DAC Widgets
|
|
||||||
*/
|
|
||||||
void CreateDACWidgets();
|
void CreateDACWidgets();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up the ADC Widgets
|
|
||||||
*/
|
|
||||||
void CreateADCWidgets();
|
void CreateADCWidgets();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up HV widget
|
|
||||||
*/
|
|
||||||
void CreateHVWidget();
|
void CreateHVWidget();
|
||||||
|
void GetDac(int id);
|
||||||
/**
|
void GetDacs();
|
||||||
* Gets the sls index to set/get dac/adc
|
void GetHighVoltage();
|
||||||
* @param index is the gui dac/adc index
|
|
||||||
* @returns the sls index
|
|
||||||
*/
|
|
||||||
slsDetectorDefs::dacIndex getSLSIndex(int index);
|
slsDetectorDefs::dacIndex getSLSIndex(int index);
|
||||||
|
|
||||||
/** The sls detector object */
|
|
||||||
multiSlsDetector *myDet;
|
multiSlsDetector *myDet;
|
||||||
/** detector type */
|
|
||||||
slsDetectorDefs::detectorType detType;
|
slsDetectorDefs::detectorType detType;
|
||||||
/**number of dac widgets*/
|
|
||||||
int numDACWidgets;
|
int numDACWidgets;
|
||||||
/**number of adc widgets*/
|
|
||||||
int numADCWidgets;
|
int numADCWidgets;
|
||||||
|
|
||||||
/** list of dac and adc names */
|
|
||||||
std::vector<std::string>dacNames;
|
std::vector<std::string>dacNames;
|
||||||
std::vector<std::string>adcNames;
|
std::vector<std::string>adcNames;
|
||||||
|
|
||||||
|
enum hvVals {
|
||||||
|
HV_0,
|
||||||
|
HV_90,
|
||||||
|
HV_110,
|
||||||
|
HV_120,
|
||||||
|
HV_150,
|
||||||
|
HV_180,
|
||||||
|
HV_200
|
||||||
|
};
|
||||||
|
|
||||||
/**widgets needed*/
|
|
||||||
QGroupBox *boxDacs;
|
QGroupBox *boxDacs;
|
||||||
QGroupBox *boxAdcs;
|
QGroupBox *boxAdcs;
|
||||||
std::vector<QLabel*>lblDacs;
|
std::vector<QLabel*>lblDacs;
|
||||||
@ -141,8 +89,9 @@ private:
|
|||||||
QComboBox *comboHV;
|
QComboBox *comboHV;
|
||||||
QSpinBox *spinHV;
|
QSpinBox *spinHV;
|
||||||
QGridLayout *dacLayout;
|
QGridLayout *dacLayout;
|
||||||
QString tipHV;
|
|
||||||
QPalette red;
|
|
||||||
QComboBox *comboDetector;
|
QComboBox *comboDetector;
|
||||||
|
|
||||||
|
static const int HV_MIN = 60;
|
||||||
|
static const int HV_MAX = 200;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include "qTabDebugging.h"
|
#include "qTabDebugging.h"
|
||||||
#include "qDefs.h"
|
#include "qDefs.h"
|
||||||
|
|
||||||
#include "multiSlsDetector.h"
|
|
||||||
|
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
#include "qTabDeveloper.h"
|
#include "qTabDeveloper.h"
|
||||||
#include "qDetectorMain.h"
|
#include "qDefs.h"
|
||||||
|
|
||||||
#include "multiSlsDetector.h"
|
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QString>
|
||||||
|
#include <QPalette>
|
||||||
#include <QDoubleValidator>
|
#include <QDoubleValidator>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -10,47 +19,22 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) : QWidget(parent),
|
qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) :
|
||||||
myDet(detector),
|
QWidget(parent), myDet(detector), detType(slsDetectorDefs::GENERIC), numDACWidgets(0), numADCWidgets(0),
|
||||||
detType(slsDetectorDefs::GENERIC),
|
boxDacs(nullptr), boxAdcs(nullptr), lblHV(nullptr), comboHV(nullptr), dacLayout(nullptr), comboDetector(nullptr) {
|
||||||
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();
|
SetupWidgetWindow();
|
||||||
Initialization();
|
Initialization();
|
||||||
FILE_LOG(logDEBUG) << "Developer ready";
|
FILE_LOG(logDEBUG) << "Developer ready";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qTabDeveloper::~qTabDeveloper() {}
|
qTabDeveloper::~qTabDeveloper() {}
|
||||||
|
|
||||||
void qTabDeveloper::SetupWidgetWindow() {
|
void qTabDeveloper::SetupWidgetWindow() {
|
||||||
//Detector Type
|
|
||||||
detType = myDet->getDetectorTypeAsEnum();
|
detType = myDet->getDetectorTypeAsEnum();
|
||||||
|
|
||||||
//palette
|
|
||||||
red = QPalette();
|
|
||||||
red.setColor(QPalette::Active, QPalette::WindowText, Qt::red);
|
|
||||||
|
|
||||||
//the number of dacs and adcs
|
|
||||||
switch (detType) {
|
switch (detType) {
|
||||||
case slsDetectorDefs::EIGER:
|
case slsDetectorDefs::EIGER:
|
||||||
numDACWidgets = 17;
|
numDACWidgets = 17;
|
||||||
numADCWidgets = 6;
|
numADCWidgets = 6;
|
||||||
|
|
||||||
dacNames.push_back("v SvP:");
|
dacNames.push_back("v SvP:");
|
||||||
dacNames.push_back("v SvN");
|
dacNames.push_back("v SvN");
|
||||||
dacNames.push_back("v Vrf:");
|
dacNames.push_back("v Vrf:");
|
||||||
@ -68,16 +52,13 @@ void qTabDeveloper::SetupWidgetWindow() {
|
|||||||
dacNames.push_back("v Vcmp_rl:");
|
dacNames.push_back("v Vcmp_rl:");
|
||||||
dacNames.push_back("v Vcmp_rr:");
|
dacNames.push_back("v Vcmp_rr:");
|
||||||
dacNames.push_back("v threshold:");
|
dacNames.push_back("v threshold:");
|
||||||
|
|
||||||
adcNames.push_back("Temperature FPGA Ext:");
|
adcNames.push_back("Temperature FPGA Ext:");
|
||||||
adcNames.push_back("Temperature 10GE:");
|
adcNames.push_back("Temperature 10GE:");
|
||||||
adcNames.push_back("Temperature DCDC:");
|
adcNames.push_back("Temperature DCDC:");
|
||||||
adcNames.push_back("Temperature SODL:");
|
adcNames.push_back("Temperature SODL:");
|
||||||
adcNames.push_back("Temperature SODR:");
|
adcNames.push_back("Temperature SODR:");
|
||||||
adcNames.push_back("Temperature FPGA:");
|
adcNames.push_back("Temperature FPGA:");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case slsDetectorDefs::GOTTHARD:
|
case slsDetectorDefs::GOTTHARD:
|
||||||
numDACWidgets = 8;
|
numDACWidgets = 8;
|
||||||
numADCWidgets = 2;
|
numADCWidgets = 2;
|
||||||
@ -89,12 +70,9 @@ void qTabDeveloper::SetupWidgetWindow() {
|
|||||||
dacNames.push_back("v Comp. Input:");
|
dacNames.push_back("v Comp. Input:");
|
||||||
dacNames.push_back("v Comp. Ref:");
|
dacNames.push_back("v Comp. Ref:");
|
||||||
dacNames.push_back("i Base Test:");
|
dacNames.push_back("i Base Test:");
|
||||||
|
|
||||||
adcNames.push_back("Temperature ADC:");
|
adcNames.push_back("Temperature ADC:");
|
||||||
adcNames.push_back("Temperature FPGA:");
|
adcNames.push_back("Temperature FPGA:");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case slsDetectorDefs::JUNGFRAU:
|
case slsDetectorDefs::JUNGFRAU:
|
||||||
numDACWidgets = 8;
|
numDACWidgets = 8;
|
||||||
numADCWidgets = 1;
|
numADCWidgets = 1;
|
||||||
@ -106,13 +84,9 @@ void qTabDeveloper::SetupWidgetWindow() {
|
|||||||
dacNames.push_back("v vb ds:");
|
dacNames.push_back("v vb ds:");
|
||||||
dacNames.push_back("v vref ds:");
|
dacNames.push_back("v vref ds:");
|
||||||
dacNames.push_back("i vref comp:");
|
dacNames.push_back("i vref comp:");
|
||||||
|
|
||||||
adcNames.push_back("Temperature ADC/FPGA:");
|
adcNames.push_back("Temperature ADC/FPGA:");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case slsDetectorDefs::MOENCH:
|
case slsDetectorDefs::MOENCH:
|
||||||
|
|
||||||
numDACWidgets = 8;
|
numDACWidgets = 8;
|
||||||
numADCWidgets = 0;
|
numADCWidgets = 0;
|
||||||
dacNames.push_back("v Dac 0:");
|
dacNames.push_back("v Dac 0:");
|
||||||
@ -123,73 +97,54 @@ void qTabDeveloper::SetupWidgetWindow() {
|
|||||||
dacNames.push_back("v Dac 5:");
|
dacNames.push_back("v Dac 5:");
|
||||||
dacNames.push_back("v Dac 6:");
|
dacNames.push_back("v Dac 6:");
|
||||||
dacNames.push_back("i Dac 7:");
|
dacNames.push_back("i Dac 7:");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
std::string errorMess =
|
break;
|
||||||
myDet->getHostname() + std::string(" has ") +
|
|
||||||
myDet->getDetectorTypeAsString() + std::string(" detector type (") +
|
|
||||||
std::to_string(detType) + std::string("). Exiting GUI. (Source: qTabDeveloper::SetupWidgetWindow)");
|
|
||||||
throw sls::RuntimeError(errorMess.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//layout
|
|
||||||
setFixedWidth(765);
|
setFixedWidth(765);
|
||||||
setFixedHeight(20 + 50 + (numDACWidgets / 2) * 35);
|
setFixedHeight(20 + 50 + (numDACWidgets / 2) * 35);
|
||||||
|
|
||||||
QScrollArea* scroll = new QScrollArea;
|
QScrollArea* scroll = new QScrollArea;
|
||||||
scroll->setWidget(this);
|
scroll->setWidget(this);
|
||||||
scroll->setWidgetResizable(true);
|
scroll->setWidgetResizable(true);
|
||||||
|
|
||||||
QGridLayout *layout = new QGridLayout(scroll);
|
QGridLayout *layout = new QGridLayout(scroll);
|
||||||
layout->setContentsMargins(20, 10, 10, 5);
|
layout->setContentsMargins(20, 10, 10, 5);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
//readout
|
|
||||||
comboDetector = new QComboBox(this);
|
comboDetector = new QComboBox(this);
|
||||||
comboDetector->addItem("All");
|
PopulateDetectors();
|
||||||
//add detectors
|
|
||||||
for (int i = 1; i < myDet->getNumberOfDetectors() + 1; ++i)
|
|
||||||
comboDetector->addItem(QString(myDet->getHostname(i - 1).c_str()));
|
|
||||||
comboDetector->setCurrentIndex(0);
|
|
||||||
|
|
||||||
//dacs
|
|
||||||
CreateDACWidgets();
|
CreateDACWidgets();
|
||||||
|
|
||||||
// hv for gotthard, jungfrau, moench
|
|
||||||
if ((detType == slsDetectorDefs::GOTTHARD) ||
|
|
||||||
(detType == slsDetectorDefs::JUNGFRAU) ||
|
|
||||||
(detType == slsDetectorDefs::MOENCH)) {
|
|
||||||
CreateHVWidget();
|
CreateHVWidget();
|
||||||
|
|
||||||
}
|
|
||||||
layout->addWidget(comboDetector, 0, 0);
|
layout->addWidget(comboDetector, 0, 0);
|
||||||
layout->addWidget(boxDacs, 1, 0);
|
layout->addWidget(boxDacs, 1, 0);
|
||||||
|
|
||||||
//adcs
|
|
||||||
if (numADCWidgets) {
|
|
||||||
CreateADCWidgets();
|
CreateADCWidgets();
|
||||||
layout->addWidget(boxAdcs, 2, 0);
|
|
||||||
}
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void qTabDeveloper::Initialization() {
|
void qTabDeveloper::Initialization() {
|
||||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh()));
|
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh()));
|
||||||
|
|
||||||
// dacs
|
|
||||||
for (int i = 0; i < numDACWidgets; ++i)
|
for (int i = 0; i < numDACWidgets; ++i)
|
||||||
connect(spinDacs[i], SIGNAL(editingFinished(int)), this, SLOT(SetDacValues(int)));
|
connect(spinDacs[i], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int)));
|
||||||
|
if (comboHV != nullptr) {
|
||||||
// hv
|
|
||||||
if (comboHV) {
|
|
||||||
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||||
} else {
|
} else {
|
||||||
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
|
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qTabDeveloper::PopulateDetectors() {
|
||||||
|
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||||
|
|
||||||
|
comboDetector->clear();
|
||||||
|
comboDetector->addItem("All");
|
||||||
|
if (myDet->getNumberOfDetectors() > 1) {
|
||||||
|
for (int i = 0; i < myDet->getNumberOfDetectors(); ++i)
|
||||||
|
comboDetector->addItem(QString(myDet->getHostname(i).c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void qTabDeveloper::CreateDACWidgets() {
|
void qTabDeveloper::CreateDACWidgets() {
|
||||||
boxDacs = new QGroupBox("Dacs", this);
|
boxDacs = new QGroupBox("Dacs", this);
|
||||||
@ -216,6 +171,9 @@ void qTabDeveloper::CreateDACWidgets() {
|
|||||||
|
|
||||||
|
|
||||||
void qTabDeveloper::CreateADCWidgets() {
|
void qTabDeveloper::CreateADCWidgets() {
|
||||||
|
if (!numADCWidgets)
|
||||||
|
return;
|
||||||
|
|
||||||
int rows = numADCWidgets / 2;
|
int rows = numADCWidgets / 2;
|
||||||
if (numADCWidgets % 2)
|
if (numADCWidgets % 2)
|
||||||
rows++;
|
rows++;
|
||||||
@ -245,9 +203,21 @@ void qTabDeveloper::CreateADCWidgets() {
|
|||||||
setFixedHeight(340);
|
setFixedHeight(340);
|
||||||
layout->setVerticalSpacing(diff / 2);
|
layout->setVerticalSpacing(diff / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
layout->addWidget(boxAdcs, 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qTabDeveloper::CreateHVWidget() {
|
void qTabDeveloper::CreateHVWidget() {
|
||||||
|
|
||||||
|
switch(detType) {
|
||||||
|
case slsDetectorDefs::GOTTHARD:
|
||||||
|
case slsDetectorDefs::JUNGFRAU:
|
||||||
|
case slsDetectorDefs::MOENCH:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boxDacs->setFixedHeight(boxDacs->height() + 35);
|
boxDacs->setFixedHeight(boxDacs->height() + 35);
|
||||||
lblHV = new QLabel("High Voltage", boxDacs);
|
lblHV = new QLabel("High Voltage", boxDacs);
|
||||||
dacLayout->addWidget(lblHV, (int)(numDACWidgets / 2), 1);
|
dacLayout->addWidget(lblHV, (int)(numDACWidgets / 2), 1);
|
||||||
@ -274,7 +244,7 @@ void qTabDeveloper::CreateHVWidget() {
|
|||||||
else {
|
else {
|
||||||
spinHV = new QSpinBox(boxDacs);
|
spinHV = new QSpinBox(boxDacs);
|
||||||
spinDacs[i]->setMinimum(-1);
|
spinDacs[i]->setMinimum(-1);
|
||||||
spinDacs[i]->setMaximum(200);
|
spinDacs[i]->setMaximum(HV_MAX);
|
||||||
tipHV = "<nobr>Set high voltage to 0 or 60 - 200V</nobr>";
|
tipHV = "<nobr>Set high voltage to 0 or 60 - 200V</nobr>";
|
||||||
spinHV->setToolTip(tipHV);
|
spinHV->setToolTip(tipHV);
|
||||||
dacLayout->addWidget(spinHV, (int)(numDACWidgets / 2), 2);
|
dacLayout->addWidget(spinHV, (int)(numDACWidgets / 2), 2);
|
||||||
@ -282,47 +252,139 @@ void qTabDeveloper::CreateHVWidget() {
|
|||||||
lblHV->setToolTip(tipHV);
|
lblHV->setToolTip(tipHV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qTabDeveloper::GetDac(int id) {
|
||||||
|
FILE_LOG(logDEBUG) << "Getting Dac " << id;
|
||||||
|
|
||||||
void qTabDeveloper::SetDacValues(int id) {
|
disconnect(spinDacs[id], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int)));
|
||||||
FILE_LOG(logINFO) << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value();
|
try {
|
||||||
|
// dac units
|
||||||
|
auto retval = myDet->setDAC(-1, getSLSIndex(id), 0, comboDetector->currentIndex() - 1);
|
||||||
|
spinDacs[id]->setValue(retval);
|
||||||
|
// mv
|
||||||
|
retval = myDet->setDAC(-1, getSLSIndex(id), 1, comboDetector->currentIndex() - 1);
|
||||||
|
lblDacsmV[id]->setText(QString("%1mV").arg(retval -10));
|
||||||
|
} catch (const sls::NonCriticalError &e) {
|
||||||
|
qDefs::ExceptionMessage("Could not get dac.", e.what(), "qTabDeveloper::GetDac");
|
||||||
|
}
|
||||||
|
|
||||||
int moduleId = comboDetector->currentIndex() - 1;
|
connect(spinDacs[id], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int)));
|
||||||
|
|
||||||
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::GetDacs() {
|
||||||
|
FILE_LOG(logDEBUG) << "Getting All Dacs";
|
||||||
|
|
||||||
|
for (int i = 0; i < numDACWidgets; ++i) {
|
||||||
|
GetDac(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void qTabDeveloper::SetDac(int id) {
|
||||||
|
int val = spinDacs[id]->value();
|
||||||
|
FILE_LOG(logINFO) << "Setting dac:" << dacNames[id] << " : " << val;
|
||||||
|
|
||||||
|
try {
|
||||||
|
myDet->setDAC(val, etSLSIndex(id), 0, comboDetector->currentIndex() - 1);
|
||||||
|
} catch (const sls::NonCriticalError &e) {
|
||||||
|
qDefs::ExceptionMessage("Could not set dac.", e.what(), "qTabDeveloper::SetDac");
|
||||||
|
}
|
||||||
|
// update mV anyway
|
||||||
|
GetDac(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void qTabDeveloper::GetAdcs() {
|
||||||
|
FILE_LOG(logDEBUG) << "Getting ADCs";
|
||||||
|
|
||||||
|
for (int i = 0; i < numADCWidgets; ++i) {
|
||||||
|
try {
|
||||||
|
auto retval = myDet->getADC(getSLSIndex(id + numDACWidgets), comboDetector->currentIndex() - 1);
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
} catch (const sls::NonCriticalError &e) {
|
||||||
|
qDefs::ExceptionMessage("Could not get adcs.", e.what(), "qTabDeveloper::GetAdcs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void qTabDeveloper::GetHighVoltage() {
|
||||||
|
// not enabled for this detector type
|
||||||
|
if (comboHV == nullptr && spinHV == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FILE_LOG(logDEBUG) << "Getting High Voltage";
|
||||||
|
if (comboHV == nullptr) {
|
||||||
|
disconnect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
|
||||||
|
} else {
|
||||||
|
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// dac units
|
||||||
|
auto retval = myDet->setDAC(-1, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1);
|
||||||
|
if (spinHV != nullptr) {
|
||||||
|
if (retval != 0 && retval != -1 && retval < HV_MIN && ret > HV_MAX) {
|
||||||
|
qDefs::Message(qDefs::WARNING, std::string("Unknown High Voltage: ") + std::to_string(retval), "qTabDeveloper::GetHighVoltage");
|
||||||
|
} else{
|
||||||
|
spinHV->setValue(ret);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (ret) {
|
||||||
|
case -1:
|
||||||
|
qDefs::Message(qDefs::WARNING, "Different values for high voltage.");
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
comboHV->setCurrentIndex(HV_0);
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
comboHV->setCurrentIndex(HV_90);
|
||||||
|
break;
|
||||||
|
case 110:
|
||||||
|
comboHV->setCurrentIndex(HV_110);
|
||||||
|
break;
|
||||||
|
case 120:
|
||||||
|
comboHV->setCurrentIndex(HV_120);
|
||||||
|
break;
|
||||||
|
case 150:
|
||||||
|
comboHV->setCurrentIndex(HV_150);
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
comboHV->setCurrentIndex(HV_180);
|
||||||
|
break;
|
||||||
|
case 200:
|
||||||
|
comboHV->setCurrentIndex(HV_200);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qDefs::Message(qDefs::WARNING, std::string("Unknown High Voltage: ") + std::to_string(retval), "qTabDeveloper::GetHighVoltage");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (const sls::NonCriticalError &e) {
|
||||||
|
qDefs::ExceptionMessage("Could not get high voltage.", e.what(), "qTabDeveloper::GetHighVoltage");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comboHV == nullptr) {
|
||||||
|
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
|
||||||
|
} else {
|
||||||
|
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void qTabDeveloper::SetHighVoltage() {
|
void qTabDeveloper::SetHighVoltage() {
|
||||||
int highvoltage = (comboHV ? comboHV->currentText().toInt() : spinHV->value());
|
int val = (comboHV ? comboHV->currentText().toInt() : spinHV->value());
|
||||||
FILE_LOG(logINFO) << "Setting high voltage:" << highvoltage;
|
FILE_LOG(logINFO) << "Setting high voltage:" << val;
|
||||||
|
|
||||||
auto moduleId = comboDetector->currentIndex() - 1;
|
try {
|
||||||
int ret = det->setDAC(highvoltage,slsDetectorDefs::HIGH_VOLTAGE, 0, moduleId);
|
myDet->setDAC(val, slsDetectorDefs::HIGH_VOLTAGE, 0, comboFileFormat->currentIndex() - 1);
|
||||||
qDefs::checkErrorMessage(myDet, moduleId, "qTabDeveloper::SetHighVoltage");
|
} catch (const sls::NonCriticalError &e) {
|
||||||
|
qDefs::ExceptionMessage("Could not set high voltage.", e.what(), "qTabDeveloper::SetHighVoltage");
|
||||||
//error
|
GetHighVoltage();
|
||||||
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>");
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,9 +441,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
|
|||||||
case 22:
|
case 22:
|
||||||
return slsDetectorDefs::TEMPERATURE_FPGA;
|
return slsDetectorDefs::TEMPERATURE_FPGA;
|
||||||
default:
|
default:
|
||||||
qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex");
|
throw sls:NonCriticalError(std::string(Unknown dac/adc index) + std::to_string(index));
|
||||||
Refresh();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case slsDetectorDefs::GOTTHARD:
|
case slsDetectorDefs::GOTTHARD:
|
||||||
@ -407,165 +467,41 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
|
|||||||
case 9:
|
case 9:
|
||||||
return slsDetectorDefs::TEMPERATURE_FPGA;
|
return slsDetectorDefs::TEMPERATURE_FPGA;
|
||||||
default:
|
default:
|
||||||
qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex");
|
throw sls:NonCriticalError(std::string(Unknown dac/adc index) + std::to_string(index));
|
||||||
Refresh();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case slsDetectorDefs::JUNGFRAU:
|
case slsDetectorDefs::JUNGFRAU:
|
||||||
if (index >= 0 && index <= 7) {
|
if (index >= 0 && index < numDACWidgets) {
|
||||||
return (slsDetectorDefs::dacIndex)index;
|
return (slsDetectorDefs::dacIndex)index;
|
||||||
}
|
}
|
||||||
if (index == 8) {
|
if (index == numDACWidgets) {
|
||||||
return slsDetectorDefs::TEMPERATURE_ADC;
|
return slsDetectorDefs::TEMPERATURE_ADC;
|
||||||
} else {
|
} else {
|
||||||
qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex");
|
throw sls:NonCriticalError(std::string(Unknown dac/adc index) + std::to_string(index));
|
||||||
Refresh();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case slsDetectorDefs::MOENCH:
|
case slsDetectorDefs::MOENCH:
|
||||||
if (index >= 0 && index <= 7) {
|
if (index >= 0 && index < numDACWidgets) {
|
||||||
return (slsDetectorDefs::dacIndex)index;
|
return (slsDetectorDefs::dacIndex)index;
|
||||||
} else {
|
} else {
|
||||||
qDefs::Message(qDefs::CRITICAL, "Unknown DAC/ADC Index. Weird Error Index:" + index, "qTabDeveloper::getSLSIndex");
|
throw sls:NonCriticalError(std::string(Unknown dac/adc index) + std::to_string(index));
|
||||||
Refresh();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (slsDetectorDefs::dacIndex)0;
|
return (slsDetectorDefs::dacIndex)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void qTabDeveloper::RefreshAdcs() {
|
|
||||||
FILE_LOG(logDEBUG) << "Updating ADCs";
|
|
||||||
|
|
||||||
auto moduleId = comboDetector->currentIndex() - 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < numADCWidgets; ++i) {
|
|
||||||
|
|
||||||
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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qDefs::checkErrorMessage(myDet, "qTabDeveloper::RefreshAdcs");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void qTabDeveloper::Refresh() {
|
void qTabDeveloper::Refresh() {
|
||||||
FILE_LOG(logDEBUG) << "**Updating Developer Tab\n";
|
FILE_LOG(logDEBUG) << "**Updating Developer Tab\n";
|
||||||
|
GetDacs();
|
||||||
auto moduleId = comboDetector->currentIndex() - 1;
|
GetAdcs();
|
||||||
|
GetHighVoltage();
|
||||||
// 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 (numADCWidgets)
|
|
||||||
RefreshAdcs();
|
|
||||||
|
|
||||||
//gotthard -high voltage
|
|
||||||
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);
|
|
||||||
if (comboHV)
|
|
||||||
comboHV->setToolTip(tipHV);
|
|
||||||
else
|
|
||||||
spinHV->setToolTip(tipHV);
|
|
||||||
|
|
||||||
//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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE_LOG(logDEBUG) << "**Updated Developer Tab";
|
FILE_LOG(logDEBUG) << "**Updated Developer Tab";
|
||||||
|
|
||||||
qDefs::checkErrorMessage(myDet, "qTabDeveloper::Refresh");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user