mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-20 08:38:00 +02:00

- 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)
101 lines
2.7 KiB
C++
101 lines
2.7 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
#include "qDacWidget.h"
|
|
#include "qDefs.h"
|
|
|
|
namespace sls {
|
|
|
|
qDacWidget::qDacWidget(QWidget *parent, Detector *detector, bool d,
|
|
std::string n, slsDetectorDefs::dacIndex i)
|
|
: QWidget(parent), det(detector), isDac(d), index(i) {
|
|
setupUi(this);
|
|
SetupWidgetWindow(n);
|
|
}
|
|
|
|
qDacWidget::~qDacWidget() {}
|
|
|
|
void qDacWidget::SetupWidgetWindow(std::string name) {
|
|
lblDac->setText(name.c_str());
|
|
if (isDac) {
|
|
spinDac->setDecimals(0);
|
|
} else {
|
|
spinDac->setSuffix(0x00b0 + QString("C"));
|
|
spinDac->setReadOnly(true);
|
|
lblDacmV->setMinimumWidth(0);
|
|
lblDacmV->setMaximumWidth(0);
|
|
}
|
|
Initialization();
|
|
Refresh();
|
|
}
|
|
|
|
void qDacWidget::Initialization() {
|
|
if (isDac) {
|
|
connect(spinDac, SIGNAL(valueChanged(double)), this, SLOT(SetDac()));
|
|
}
|
|
}
|
|
|
|
void qDacWidget::SetDetectorIndex(int id) {
|
|
detectorIndex = id;
|
|
Refresh();
|
|
}
|
|
|
|
void qDacWidget::GetDac() {
|
|
LOG(logDEBUG) << "Getting Dac " << index;
|
|
|
|
disconnect(spinDac, SIGNAL(valueChanged(double)), this, SLOT(SetDac()));
|
|
try {
|
|
// dac units
|
|
auto retval = det->getDAC(index, 0, {detectorIndex}).squash(-1);
|
|
spinDac->setValue(retval);
|
|
// mv
|
|
retval = det->getDAC(index, 1, {detectorIndex}).squash(-1);
|
|
// -6 is the minimum amt of space it occupies, if more needed, its
|
|
// padded with ' ', negative value for left aligned text
|
|
lblDacmV->setText(QString("%1mV").arg(retval, -6));
|
|
}
|
|
CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index),
|
|
"qDacWidget::GetDac")
|
|
|
|
connect(spinDac, SIGNAL(valueChanged(double)), this, SLOT(SetDac()));
|
|
}
|
|
|
|
void qDacWidget::SetDac() {
|
|
int val = (int)spinDac->value();
|
|
LOG(logINFO) << "Setting dac:" << lblDac->text().toLatin1().data() << " : "
|
|
<< val;
|
|
|
|
try {
|
|
det->setDAC(index, val, 0, {detectorIndex});
|
|
}
|
|
CATCH_DISPLAY(std::string("Could not set dac ") + std::to_string(index),
|
|
"qDacWidget::SetDac")
|
|
|
|
// update mV anyway
|
|
GetDac();
|
|
}
|
|
|
|
void qDacWidget::GetAdc() {
|
|
LOG(logDEBUG) << "Getting ADC " << index;
|
|
|
|
try {
|
|
auto retval = det->getTemperature(index, {detectorIndex}).squash(-1);
|
|
if (retval == -1 && detectorIndex == -1) {
|
|
spinDac->setValue(-1);
|
|
} else {
|
|
spinDac->setValue(retval);
|
|
}
|
|
}
|
|
CATCH_DISPLAY(std::string("Could not get adc ") + std::to_string(index),
|
|
"qDacWidget::GetAdc")
|
|
}
|
|
|
|
void qDacWidget::Refresh() {
|
|
if (isDac) {
|
|
GetDac();
|
|
} else {
|
|
GetAdc();
|
|
}
|
|
}
|
|
|
|
} // namespace sls
|