mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-28 12:20:48 +02:00
Qt5 built in qwt (#570)
- qt4->qt5 - in built qt5 6.1.5 because rhel7 is not upto date with qt5, removed findqwt.cmake - made a fix in qwt lib (qwt_plot_layout.h) to work with 5.15 and lower versions for qrect constr. - qt5 forms fixed, qt4 many hard coding forms switched to forms including qtabwidget, scrolls etc, fonts moved to forms - docking option enabled by default, removed option to disable docking feature from "Mode" - added qVersionResolve utility functions to handle compatibility before and after qt5.12 - qtplots (ian's code) takes in gain mode enable to set some settings within the class, with proper gain plot ticks - ensure gain plots have no zooming of z axis in 2d and y axis in 1d - removed placeholder text in qpalette in main window form as its not supportd until 5.12 (so using qt5.9 designer insted of qt5.15 to cope) - tab order Servers: - fixed some error messages that were empty for fail in funcs (mostly minor as if this error, major issues)
This commit is contained in:
@ -3,49 +3,36 @@
|
||||
#include "qTabDebugging.h"
|
||||
#include "qDefs.h"
|
||||
#include "sls/ToString.h"
|
||||
#include <QDesktopWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QTreeWidget>
|
||||
|
||||
namespace sls {
|
||||
|
||||
qTabDebugging::qTabDebugging(QWidget *parent, Detector *detector)
|
||||
: QWidget(parent), det(detector), treeDet(nullptr),
|
||||
lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr),
|
||||
lblDetectorSoftware(nullptr) {
|
||||
: QWidget(parent), det(detector) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
LOG(logDEBUG) << "Debugging ready";
|
||||
}
|
||||
|
||||
qTabDebugging::~qTabDebugging() {
|
||||
delete treeDet;
|
||||
delete lblDetectorHostname;
|
||||
delete lblDetectorFirmware;
|
||||
delete lblDetectorSoftware;
|
||||
}
|
||||
qTabDebugging::~qTabDebugging() {}
|
||||
|
||||
void qTabDebugging::SetupWidgetWindow() {
|
||||
// enabling according to det type
|
||||
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
|
||||
lblDetector->setText("Half Module:");
|
||||
chkDetectorFirmware->setEnabled(false);
|
||||
chkDetectorBus->setEnabled(false);
|
||||
btnTest->setEnabled(false);
|
||||
groupTest->setEnabled(false);
|
||||
} else {
|
||||
EnableTest();
|
||||
}
|
||||
|
||||
PopulateDetectors();
|
||||
|
||||
Initialization();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void qTabDebugging::Initialization() {
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(GetDetectorStatus()));
|
||||
connect(btnGetInfo, SIGNAL(clicked()), this, SLOT(GetInfo()));
|
||||
if (btnTest->isEnabled()) {
|
||||
SLOT(GetInfo()));
|
||||
connect(chkDetectorFirmware, SIGNAL(toggled(bool)), this,
|
||||
SLOT(EnableTest()));
|
||||
connect(chkDetectorBus, SIGNAL(toggled(bool)), this, SLOT(EnableTest()));
|
||||
if (groupTest->isEnabled()) {
|
||||
connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector()));
|
||||
}
|
||||
}
|
||||
@ -53,20 +40,73 @@ void qTabDebugging::Initialization() {
|
||||
void qTabDebugging::PopulateDetectors() {
|
||||
LOG(logDEBUG) << "Populating detectors";
|
||||
|
||||
comboDetector->clear();
|
||||
auto res = det->getHostname();
|
||||
for (auto &it : res) {
|
||||
comboDetector->addItem(QString(it.c_str()));
|
||||
try {
|
||||
comboDetector->clear();
|
||||
comboDetector->addItem("All");
|
||||
auto res = det->getHostname();
|
||||
if (det->size() > 1) {
|
||||
for (auto &it : res) {
|
||||
comboDetector->addItem(QString(it.c_str()));
|
||||
}
|
||||
}
|
||||
comboDetector->setCurrentIndex(0);
|
||||
}
|
||||
CATCH_DISPLAY("Could not populate readouts for debugging",
|
||||
"qTabDebugging::PopulateDetectors")
|
||||
}
|
||||
|
||||
void qTabDebugging::GetFirmwareVersion() {
|
||||
LOG(logDEBUG) << "Firmware Version";
|
||||
try {
|
||||
auto retval =
|
||||
det->getFirmwareVersion({comboDetector->currentIndex() - 1})
|
||||
.squash(-1);
|
||||
std::string s = "inconsistent";
|
||||
if (retval != -1) {
|
||||
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
|
||||
s = ToString(retval);
|
||||
} else {
|
||||
s = ToStringHex(retval);
|
||||
}
|
||||
}
|
||||
dispFirmwareVersion->setText(s.c_str());
|
||||
}
|
||||
CATCH_DISPLAY("Could not get firmware version.",
|
||||
"qTabDebugging::GetFirmwareVersion")
|
||||
}
|
||||
|
||||
void qTabDebugging::GetServerSoftwareVersion() {
|
||||
LOG(logDEBUG) << "Server Software Version";
|
||||
try {
|
||||
std::string s =
|
||||
det->getDetectorServerVersion({comboDetector->currentIndex() - 1})
|
||||
.squash("inconsistent");
|
||||
dispSoftwareVersion->setText(s.c_str());
|
||||
}
|
||||
CATCH_DISPLAY("Could not get on-board software version.",
|
||||
"qTabDebugging::GetServerSoftwareVersion")
|
||||
}
|
||||
|
||||
void qTabDebugging::GetReceiverVersion() {
|
||||
LOG(logDEBUG) << "Server Receiver Version";
|
||||
try {
|
||||
std::string s =
|
||||
det->getReceiverVersion({comboDetector->currentIndex() - 1})
|
||||
.squash("inconsistent");
|
||||
dispReceiverVersion->setText(s.c_str());
|
||||
}
|
||||
CATCH_DISPLAY("Could not receiver version.",
|
||||
"qTabDebugging::GetReceiverVersion")
|
||||
}
|
||||
|
||||
void qTabDebugging::GetDetectorStatus() {
|
||||
LOG(logDEBUG) << "Getting Status";
|
||||
|
||||
try {
|
||||
std::string status = ToString(
|
||||
det->getDetectorStatus({comboDetector->currentIndex()})[0]);
|
||||
lblStatus->setText(QString(status.c_str()).toUpper());
|
||||
std::string s =
|
||||
ToString(det->getDetectorStatus({comboDetector->currentIndex() - 1})
|
||||
.squash(defs::runStatus::ERROR));
|
||||
lblStatus->setText(QString(s.c_str()).toUpper());
|
||||
}
|
||||
CATCH_DISPLAY("Could not get detector status.",
|
||||
"qTabDebugging::GetDetectorStatus")
|
||||
@ -74,172 +114,53 @@ void qTabDebugging::GetDetectorStatus() {
|
||||
|
||||
void qTabDebugging::GetInfo() {
|
||||
LOG(logDEBUG) << "Getting Readout Info";
|
||||
|
||||
// open info in a new popup
|
||||
QFrame *popup1 = new QFrame(this, Qt::Popup | Qt::SubWindow);
|
||||
QList<QTreeWidgetItem *> items;
|
||||
QGridLayout *layout = new QGridLayout(popup1);
|
||||
treeDet = new QTreeWidget(popup1);
|
||||
layout->addWidget(treeDet, 0, 0);
|
||||
QFrame *dispFrame = new QFrame(popup1);
|
||||
QGridLayout *formLayout = new QGridLayout(dispFrame);
|
||||
lblDetectorHostname = new QLabel("");
|
||||
lblDetectorFirmware = new QLabel("");
|
||||
lblDetectorSoftware = new QLabel("");
|
||||
// to make sure the size is constant
|
||||
lblDetectorFirmware->setFixedWidth(100);
|
||||
layout->addWidget(dispFrame, 0, 1);
|
||||
QString detName =
|
||||
QString(ToString(det->getDetectorType().squash()).c_str());
|
||||
|
||||
switch (det->getDetectorType().squash()) {
|
||||
|
||||
case slsDetectorDefs::EIGER:
|
||||
formLayout->addWidget(new QLabel("Half Module:"), 0, 0);
|
||||
formLayout->addItem(
|
||||
new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0,
|
||||
1);
|
||||
formLayout->addWidget(lblDetectorHostname, 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);
|
||||
treeDet->setHeaderLabel("Eiger Detector");
|
||||
// get num modules
|
||||
for (int i = 0; i < comboDetector->count() / 2; ++i)
|
||||
items.append(
|
||||
new QTreeWidgetItem((QTreeWidget *)nullptr,
|
||||
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 *)nullptr,
|
||||
QStringList(QString("Half Module (%1)")
|
||||
.arg(comboDetector->itemText(i)))));
|
||||
treeDet->topLevelItem(i * 2)->insertChildren(0, childItems);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
formLayout->addWidget(new QLabel("Module:"), 0, 0);
|
||||
formLayout->addItem(
|
||||
new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0,
|
||||
1);
|
||||
formLayout->addWidget(lblDetectorHostname, 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);
|
||||
treeDet->setHeaderLabel(QString(detName + " Detector"));
|
||||
// gets det names
|
||||
for (int i = 0; i < comboDetector->count(); ++i)
|
||||
items.append(new QTreeWidgetItem(
|
||||
(QTreeWidget *)nullptr,
|
||||
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));
|
||||
|
||||
// connect to slots
|
||||
connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this,
|
||||
SLOT(SetParameters(QTreeWidgetItem *)));
|
||||
GetFirmwareVersion();
|
||||
GetServerSoftwareVersion();
|
||||
GetReceiverVersion();
|
||||
GetDetectorStatus();
|
||||
}
|
||||
|
||||
void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
|
||||
// eiger: if half module clicked, others: true always
|
||||
bool ignoreOrHalfModuleClicked = true;
|
||||
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
|
||||
if (!(item->text(0).contains("Half Module"))) {
|
||||
ignoreOrHalfModuleClicked = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreOrHalfModuleClicked) {
|
||||
// find index
|
||||
for (int i = 0; i < comboDetector->count(); ++i) {
|
||||
if (item == treeDet->topLevelItem(i))
|
||||
break;
|
||||
}
|
||||
try {
|
||||
auto retval = std::string("0x") +
|
||||
std::to_string((unsigned long)det->getFirmwareVersion(
|
||||
{comboDetector->currentIndex()})[0]);
|
||||
lblDetectorFirmware->setText(QString(retval.c_str()));
|
||||
retval = det->getDetectorServerVersion(
|
||||
{comboDetector->currentIndex()})[0];
|
||||
lblDetectorSoftware->setText(QString(retval.c_str()));
|
||||
}
|
||||
CATCH_DISPLAY("Could not get versions.", "qTabDebugging::SetParameters")
|
||||
}
|
||||
void qTabDebugging::EnableTest() {
|
||||
btnTest->setEnabled(chkDetectorFirmware->isChecked() ||
|
||||
chkDetectorBus->isChecked());
|
||||
lblBusTestOk->hide();
|
||||
lblBusTestFail->hide();
|
||||
lblFwTestOk->hide();
|
||||
lblFwTestFail->hide();
|
||||
}
|
||||
|
||||
void qTabDebugging::TestDetector() {
|
||||
LOG(logINFO) << "Testing Readout";
|
||||
|
||||
try {
|
||||
QString moduleName = "Module";
|
||||
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
|
||||
moduleName = "Half Module";
|
||||
// hide results if clicking button again
|
||||
EnableTest();
|
||||
|
||||
// detector firmware
|
||||
if (chkDetectorFirmware->isChecked()) {
|
||||
try {
|
||||
det->executeFirmwareTest({comboDetector->currentIndex() - 1});
|
||||
LOG(logINFO) << "Detector Firmware Test: Pass";
|
||||
lblFwTestOk->show();
|
||||
} catch (std::exception &e) {
|
||||
LOG(logWARNING)
|
||||
<< "Detector Firmware Test: Fail (" << e.what() << ")";
|
||||
lblFwTestFail->show();
|
||||
}
|
||||
}
|
||||
|
||||
// detector CPU-FPGA bus
|
||||
if (chkDetectorBus->isChecked()) {
|
||||
try {
|
||||
det->executeBusTest({comboDetector->currentIndex() - 1});
|
||||
LOG(logINFO) << "Detector Bus Test: Pass";
|
||||
lblBusTestOk->show();
|
||||
} catch (std::exception &e) {
|
||||
LOG(logWARNING) << "Detector Bus Test: Fail (" << e.what() << ")";
|
||||
lblBusTestFail->show();
|
||||
}
|
||||
|
||||
// construct message
|
||||
QString message = QString("<nobr>Test Results for %1:</nobr><br><br>")
|
||||
.arg(comboDetector->currentText());
|
||||
|
||||
// detector firmware
|
||||
if (chkDetectorFirmware->isChecked()) {
|
||||
try {
|
||||
det->executeFirmwareTest({comboDetector->currentIndex()});
|
||||
message.append(QString("<nobr>%1 Firmware: PASS</nobr><br>")
|
||||
.arg(moduleName));
|
||||
LOG(logINFO) << "Detector Firmware Test: Pass";
|
||||
}
|
||||
CATCH_DISPLAY("Firmware test failed.",
|
||||
"qTabDebugging::TestDetector")
|
||||
}
|
||||
|
||||
// detector CPU-FPGA bus
|
||||
if (chkDetectorBus->isChecked()) {
|
||||
try {
|
||||
det->executeBusTest({comboDetector->currentIndex()});
|
||||
message.append(
|
||||
QString("<nobr>%1 Bus: PASS</nobr><br>").arg(moduleName));
|
||||
LOG(logINFO) << "Detector Bus Test: Pass";
|
||||
}
|
||||
CATCH_DISPLAY("Bus test failed.", "qTabDebugging::TestDetector")
|
||||
}
|
||||
|
||||
// display message
|
||||
qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(),
|
||||
"qTabDebugging::TestDetector");
|
||||
}
|
||||
CATCH_DISPLAY("Could not execute digital test.",
|
||||
"qTabDebugging::TestDetector")
|
||||
}
|
||||
|
||||
void qTabDebugging::Refresh() {
|
||||
LOG(logDEBUG) << "**Updating Debugging Tab";
|
||||
GetDetectorStatus();
|
||||
LOG(logDEBUG) << "**Updated Debugging Tab";
|
||||
}
|
||||
void qTabDebugging::Refresh() { GetInfo(); }
|
||||
|
||||
} // namespace sls
|
||||
|
Reference in New Issue
Block a user