rxr sls namespace (#457)

* rxr src files and classes (detectordata, ZmqSocket) added to sls namespace

* moving defines inside namespace

* moving defines inside namespace, added helpdacs to namespace

* added namespace to gui

* gui also updated

* removed unnecessary sls:: when already in sls namespace for slsDetectoSoftware, receverSoftware, slsDetectorGui and slsSupportlib
This commit is contained in:
Dhanya Thattil
2022-05-18 11:48:38 +02:00
committed by GitHub
parent fcc7f7aef8
commit 4259363169
88 changed files with 1200 additions and 923 deletions

View File

@ -11,6 +11,8 @@
#include <QPainter>
#include <qwt_text.h>
namespace sls {
int qCloneWidget::NumClones{0};
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
@ -44,7 +46,7 @@ qCloneWidget::~qCloneWidget() {
void qCloneWidget::SetupWidgetWindow(QString title) {
std::string winTitle = std::string("Snapshot:") + std::to_string(id) +
std::string(" - ") + sls::Logger::Timestamp();
std::string(" - ") + Logger::Timestamp();
setWindowTitle(QString(winTitle.c_str()));
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
@ -146,4 +148,6 @@ void qCloneWidget::resizeEvent(QResizeEvent *event) {
qDefs::DATA_GAIN_PLOT_RATIO);
}
event->accept();
}
}
} // namespace sls

View File

@ -3,7 +3,9 @@
#include "qDacWidget.h"
#include "qDefs.h"
qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d,
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);
@ -94,3 +96,5 @@ void qDacWidget::Refresh() {
GetAdc();
}
}
} // namespace sls

View File

@ -59,7 +59,7 @@ int main(int argc, char **argv) {
case 'f':
fname = optarg;
LOG(logDEBUG) << long_options[option_index].name << " " << optarg;
LOG(sls::logDEBUG) << long_options[option_index].name << " " << optarg;
break;
case 'd':
@ -72,7 +72,7 @@ int main(int argc, char **argv) {
case 'v':
tempval = APIGUI;
LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
LOG(sls::logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
<< std::hex << tempval << ")";
return 0;
@ -88,7 +88,7 @@ int main(int argc, char **argv) {
"i. Default: 0. Required \n" +
"\t only when more than one multi "
"detector object is needed.\n\n";
LOG(logERROR) << help_message;
LOG(sls::logERROR) << help_message;
return -1;
}
}
@ -96,16 +96,18 @@ int main(int argc, char **argv) {
QApplication app(argc, argv);
app.setStyle(new QPlastiqueStyle); // style is deleted by QApplication
try {
qDetectorMain det(multiId, fname, isDeveloper);
sls::qDetectorMain det(multiId, fname, isDeveloper);
det.show();
app.exec();
} catch (const std::exception &e) {
qDefs::Message(qDefs::CRITICAL,
sls::qDefs::Message(sls::qDefs::CRITICAL,
std::string(e.what()) + "\nExiting Gui :'( ", "main");
}
return 0;
}
namespace sls {
qDetectorMain::qDetectorMain(int multiId, const std::string &fname,
bool isDevel)
: QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC),
@ -212,7 +214,7 @@ void qDetectorMain::SetUpWidgetWindow() {
void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
// instantiate detector and set window title
det = sls::make_unique<sls::Detector>(multiID);
det = make_unique<Detector>(multiID);
// create messages tab to capture config file loading logs
tabMessages = new qTabMessages(this);
@ -238,15 +240,15 @@ void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
default:
std::ostringstream os;
os << det->getHostname() << " has "
<< sls::ToString(det->getDetectorType().squash())
<< ToString(det->getDetectorType().squash())
<< " detector type (" << std::to_string(detType)
<< "). Exiting GUI.";
std::string errorMess = os.str();
throw sls::RuntimeError(errorMess.c_str());
throw RuntimeError(errorMess.c_str());
}
std::ostringstream os;
os << "SLS Detector GUI : "
<< sls::ToString(det->getDetectorType().squash()) << " - "
<< ToString(det->getDetectorType().squash()) << " - "
<< det->getHostname();
std::string title = os.str();
LOG(logINFO) << title;
@ -441,10 +443,10 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
"Gotthard, Gotthard2 and Moench detectors";
std::string guiVersion = sls::ToStringHex(APIGUI);
std::string guiVersion = ToStringHex(APIGUI);
std::string clientVersion = "unknown";
try {
clientVersion = sls::ToStringHex(det->getClientVersion());
clientVersion = ToStringHex(det->getClientVersion());
}
CATCH_DISPLAY("Could not get client version.",
"qDetectorMain::ExecuteHelp")
@ -609,3 +611,5 @@ void qDetectorMain::SetZoomToolTip(bool disable) {
else
dockWidgetPlot->setToolTip(zoomToolTip);
}
} // namespace sls

View File

@ -14,7 +14,9 @@
#include <QResizeEvent>
#include <QtConcurrentRun>
qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector)
namespace sls {
qDrawPlot::qDrawPlot(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector) {
setupUi(this);
SetupWidgetWindow();
@ -728,7 +730,7 @@ void qDrawPlot::AcquisitionFinished(double currentProgress,
int detectorStatus) {
progress = currentProgress;
std::string status =
sls::ToString(static_cast<slsDetectorDefs::runStatus>(detectorStatus));
ToString(static_cast<slsDetectorDefs::runStatus>(detectorStatus));
if (detectorStatus == slsDetectorDefs::ERROR) {
qDefs::Message(qDefs::WARNING,
@ -761,7 +763,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
<< " \t dynamic range: " << data->dynamicRange << std::endl
<< " \t file index: " << data->fileIndex << std::endl
<< " \t complete image: " << data->completeImage << std::endl
<< " \t rx Roi: " << sls::ToString(data->rxRoi) << std::endl
<< " \t rx Roi: " << ToString(data->rxRoi) << std::endl
<< " ]";
progress = data->progressIndex;
@ -780,9 +782,9 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
rxRoi.xmax += ((rxRoi.xmax/1024) * 6 + (rxRoi.xmax/256) * 2);
rxRoi.ymin += ((rxRoi.ymin/512) * 34 + (rxRoi.ymin/256) * 2);
rxRoi.ymax += ((rxRoi.ymax/512) * 34 + (rxRoi.ymax/256) * 2);
LOG(logINFO) << "Rx_roi recalculated with gap pixels: " << sls::ToString(rxRoi);
LOG(logINFO) << "Rx_roi recalculated with gap pixels: " << ToString(rxRoi);
}
LOG(logDEBUG) << "Rx_roi: " << sls::ToString(rxRoi);
LOG(logDEBUG) << "Rx_roi: " << ToString(rxRoi);
}
@ -1272,3 +1274,5 @@ void qDrawPlot::UpdatePlot() {
LOG(logDEBUG) << "End of Update Plot";
}
} // namespace sls

View File

@ -5,7 +5,9 @@
#include "qDrawPlot.h"
#include "sls/network_utils.h"
qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector,
namespace sls {
qTabAdvanced::qTabAdvanced(QWidget *parent, Detector *detector,
qDrawPlot *p)
: QWidget(parent), det(detector), plot(p) {
setupUi(this);
@ -443,7 +445,7 @@ void qTabAdvanced::SetDetectorUDPIP(bool force) {
std::string s = dispDetectorUDPIP->text().toAscii().constData();
LOG(logINFO) << "Setting Detector UDP IP:" << s;
try {
det->setSourceUDPIP(sls::IpAddr{s},
det->setSourceUDPIP(IpAddr{s},
{comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Detector UDP IP.",
@ -461,7 +463,7 @@ void qTabAdvanced::SetDetectorUDPMAC(bool force) {
std::string s = dispDetectorUDPMAC->text().toAscii().constData();
LOG(logINFO) << "Setting Detector UDP MAC:" << s;
try {
det->setSourceUDPMAC(sls::MacAddr{s},
det->setSourceUDPMAC(MacAddr{s},
{comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Detector UDP MAC.",
@ -489,7 +491,7 @@ void qTabAdvanced::SetCltZMQIP(bool force) {
std::string s = dispZMQIP->text().toAscii().constData();
LOG(logINFO) << "Setting Client ZMQ IP:" << s;
try {
det->setClientZmqIp(sls::IpAddr{s},
det->setClientZmqIp(IpAddr{s},
{comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Client ZMQ IP.",
@ -547,7 +549,7 @@ void qTabAdvanced::SetRxrUDPIP(bool force) {
std::string s = dispRxrUDPIP->text().toAscii().constData();
LOG(logINFO) << "Setting Receiver UDP IP:" << s;
try {
det->setDestinationUDPIP(sls::IpAddr{s},
det->setDestinationUDPIP(IpAddr{s},
{comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Receiver UDP IP.",
@ -565,7 +567,7 @@ void qTabAdvanced::SetRxrUDPMAC(bool force) {
std::string s = dispRxrUDPMAC->text().toAscii().constData();
LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
try {
det->setDestinationUDPMAC(sls::MacAddr{s},
det->setDestinationUDPMAC(MacAddr{s},
{comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Receiver UDP MAC.",
@ -593,7 +595,7 @@ void qTabAdvanced::SetRxrZMQIP(bool force) {
std::string s = dispRxrZMQIP->text().toAscii().constData();
LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
try {
det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
det->setRxZmqIP(IpAddr{s}, {comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Receiver ZMQ IP.",
"qTabAdvanced::SetRxrZMQIP", this,
@ -891,3 +893,5 @@ void qTabAdvanced::Refresh() {
}
LOG(logDEBUG) << "**Updated Advanced Tab";
}
} // namespace sls

View File

@ -11,7 +11,9 @@
#include <unistd.h>
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector)
namespace sls {
qTabDataOutput::qTabDataOutput(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector), btnGroupRate(nullptr) {
setupUi(this);
SetupWidgetWindow();
@ -232,7 +234,7 @@ void qTabDataOutput::GetFileFormat() {
comboFileFormat->setCurrentIndex(static_cast<int>(retval));
break;
default:
throw sls::RuntimeError(std::string("Unknown file format: ") +
throw RuntimeError(std::string("Unknown file format: ") +
std::to_string(static_cast<int>(retval)));
}
}
@ -339,7 +341,7 @@ void qTabDataOutput::EnableRateCorrection() {
LOG(logINFO) << "Disabling Rate correction";
// disable
try {
det->setRateCorrection(sls::ns(0));
det->setRateCorrection(ns(0));
}
CATCH_HANDLE("Could not switch off rate correction.",
"qTabDataOutput::EnableRateCorrection", this,
@ -357,7 +359,7 @@ void qTabDataOutput::SetRateCorrection() {
int64_t deadtime = spinCustomDeadTime->value();
LOG(logINFO) << "Setting Rate Correction with custom dead time: "
<< deadtime;
det->setRateCorrection(sls::ns(deadtime));
det->setRateCorrection(ns(deadtime));
}
// default dead time
else {
@ -442,3 +444,5 @@ void qTabDataOutput::Refresh() {
LOG(logDEBUG) << "**Updated DataOutput Tab";
}
} // namespace sls

View File

@ -7,7 +7,9 @@
#include <QGridLayout>
#include <QTreeWidget>
qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector)
namespace sls {
qTabDebugging::qTabDebugging(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector), treeDet(nullptr),
lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr),
lblDetectorSoftware(nullptr) {
@ -62,7 +64,7 @@ void qTabDebugging::GetDetectorStatus() {
LOG(logDEBUG) << "Getting Status";
try {
std::string status = sls::ToString(
std::string status = ToString(
det->getDetectorStatus({comboDetector->currentIndex()})[0]);
lblStatus->setText(QString(status.c_str()).toUpper());
}
@ -88,7 +90,7 @@ void qTabDebugging::GetInfo() {
lblDetectorFirmware->setFixedWidth(100);
layout->addWidget(dispFrame, 0, 1);
QString detName =
QString(sls::ToString(det->getDetectorType().squash()).c_str());
QString(ToString(det->getDetectorType().squash()).c_str());
switch (det->getDetectorType().squash()) {
@ -241,3 +243,5 @@ void qTabDebugging::Refresh() {
GetDetectorStatus();
LOG(logDEBUG) << "**Updated Debugging Tab";
}
} // namespace sls

View File

@ -4,7 +4,9 @@
#include "qDacWidget.h"
#include "qDefs.h"
qTabDeveloper::qTabDeveloper(QWidget *parent, sls::Detector *detector)
namespace sls {
qTabDeveloper::qTabDeveloper(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector) {
setupUi(this);
SetupWidgetWindow();
@ -324,7 +326,7 @@ void qTabDeveloper::GetHighVoltage() {
// spinHV
if (spinHV->isVisible()) {
if (retval != 0 && retval < hvmin && retval > HV_MAX) {
throw sls::RuntimeError(std::string("Unknown High Voltage: ") +
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
spinHV->setValue(retval);
@ -354,7 +356,7 @@ void qTabDeveloper::GetHighVoltage() {
comboHV->setCurrentIndex(HV_200);
break;
default:
throw sls::RuntimeError(std::string("Unknown High Voltage: ") +
throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
}
}
@ -431,7 +433,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 22:
return slsDetectorDefs::TEMPERATURE_FPGA;
default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
}
break;
@ -458,7 +460,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 9:
return slsDetectorDefs::TEMPERATURE_FPGA;
default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
}
break;
@ -484,7 +486,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 8:
return slsDetectorDefs::TEMPERATURE_ADC;
default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
}
break;
@ -508,7 +510,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 7:
return slsDetectorDefs::IBIAS_SFP;
default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
}
break;
@ -550,7 +552,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 16:
return slsDetectorDefs::VTHRESHOLD;
default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
}
break;
@ -586,13 +588,13 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
case 13:
return slsDetectorDefs::VCOM_ADC2;
default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
}
break;
default:
throw sls::RuntimeError(std::string("Unknown detector type"));
throw RuntimeError(std::string("Unknown detector type"));
}
}
@ -607,3 +609,5 @@ void qTabDeveloper::Refresh() {
GetHighVoltage();
LOG(logDEBUG) << "**Updated Developer Tab";
}
} // namespace sls

View File

@ -7,7 +7,9 @@
#include <QStandardItemModel>
#include <QTimer>
qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector,
namespace sls {
qTabMeasurement::qTabMeasurement(QWidget *parent, Detector *detector,
qDrawPlot *p)
: QWidget(parent), det(detector), plot(p), progressTimer(nullptr) {
setupUi(this);
@ -343,7 +345,7 @@ void qTabMeasurement::GetTimingMode() {
if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
auto retvals = det->getTimingMode();
auto is_master = det->getMaster();
sls::Result<slsDetectorDefs::timingMode> masterRetvals;
Result<slsDetectorDefs::timingMode> masterRetvals;
for (size_t i = 0; i != is_master.size(); ++i) {
if (is_master[i]) {
masterRetvals.push_back(retvals[i]);
@ -370,7 +372,7 @@ void qTabMeasurement::GetTimingMode() {
}
break;
default:
throw sls::RuntimeError(std::string("Unknown timing mode: ") +
throw RuntimeError(std::string("Unknown timing mode: ") +
std::to_string(retval));
}
}
@ -407,7 +409,7 @@ void qTabMeasurement::GetBurstMode() {
ShowTriggerDelay();
break;
default:
throw sls::RuntimeError(std::string("Unknown burst mode: ") +
throw RuntimeError(std::string("Unknown burst mode: ") +
std::to_string(retval));
}
}
@ -1017,3 +1019,5 @@ void qTabMeasurement::Refresh() {
LOG(logDEBUG) << "**Updated Measurement Tab";
}
} // namespace sls

View File

@ -11,6 +11,8 @@
#include <QTextStream>
#include <string>
namespace sls {
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
setupUi(this);
SetupWidgetWindow();
@ -142,3 +144,5 @@ void qTabMessages::Refresh() {
dispCommand->clear();
dispCommand->setFocus();
}
} // namespace sls

View File

@ -6,6 +6,8 @@
#include <QStackedLayout>
#include <QStandardItemModel>
namespace sls {
QString qTabPlot::defaultPlotTitle("");
QString qTabPlot::defaultHistXAxisTitle("Channel Number");
QString qTabPlot::defaultHistYAxisTitle("Counts");
@ -13,7 +15,7 @@ QString qTabPlot::defaultImageXAxisTitle("Pixel");
QString qTabPlot::defaultImageYAxisTitle("Pixel");
QString qTabPlot::defaultImageZAxisTitle("Intensity");
qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p)
qTabPlot::qTabPlot(QWidget *parent, Detector *detector, qDrawPlot *p)
: QWidget(parent), det(detector), plot(p), is1d(false) {
setupUi(this);
SetupWidgetWindow();
@ -797,3 +799,5 @@ void qTabPlot::Refresh() {
LOG(logDEBUG) << "**Updated Plot Tab";
}
} // namespace sls

View File

@ -6,7 +6,9 @@
#include "sls/bit_utils.h"
#include <QStandardItemModel>
qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector)
namespace sls {
qTabSettings::qTabSettings(QWidget *parent, Detector *detector)
: QWidget(parent), det(detector) {
setupUi(this);
SetupWidgetWindow();
@ -215,7 +217,7 @@ void qTabSettings::GetSettings() {
break;
default:
if ((int)retval < -1 || (int)retval >= comboSettings->count()) {
throw sls::RuntimeError(std::string("Unknown settings: ") +
throw RuntimeError(std::string("Unknown settings: ") +
std::to_string(retval));
}
comboSettings->setCurrentIndex(retval);
@ -231,7 +233,7 @@ void qTabSettings::SetSettings(int index) {
// settings
auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
try {
LOG(logINFO) << "Setting Settings to " << sls::ToString(val);
LOG(logINFO) << "Setting Settings to " << ToString(val);
det->setSettings(val);
}
CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this,
@ -250,7 +252,7 @@ void qTabSettings::GetGainMode() {
auto retval = det->getGainMode().tsquash(
"Inconsistent gain mode for all detectors.");
if ((int)retval < 0 || (int)retval >= comboGainMode->count()) {
throw sls::RuntimeError(std::string("Unknown gain mode: ") +
throw RuntimeError(std::string("Unknown gain mode: ") +
std::to_string(retval));
}
// warning when using fix_g0 and not in export mode
@ -321,7 +323,7 @@ void qTabSettings::GetDynamicRange() {
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
break;
default:
throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
throw RuntimeError(std::string("Unknown dynamic range: ") +
std::to_string(retval));
}
}
@ -352,7 +354,7 @@ void qTabSettings::SetDynamicRange(int index) {
det->setDynamicRange(4);
break;
default:
throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
throw RuntimeError(std::string("Unknown dynamic range: ") +
std::to_string(index));
}
}
@ -399,7 +401,7 @@ void qTabSettings::SetThresholdEnergies() {
slsDetectorDefs::detectorSettings sett =
static_cast<slsDetectorDefs::detectorSettings>(
comboSettings->currentIndex());
LOG(logINFO) << "Setting Threshold Energies to " << sls::ToString(eV)
LOG(logINFO) << "Setting Threshold Energies to " << ToString(eV)
<< " (eV)";
try {
det->setThresholdEnergy(eV, sett);
@ -430,7 +432,7 @@ void qTabSettings::GetCounterMask() {
disconnect(chkCounter3, SIGNAL(toggled(bool)), this,
SLOT(SetCounterMask()));
try {
auto retval = sls::getSetBits(det->getCounterMask().tsquash(
auto retval = getSetBits(det->getCounterMask().tsquash(
"Counter mask is inconsistent for all detectors."));
// default to unchecked
for (auto p : counters) {
@ -439,7 +441,7 @@ void qTabSettings::GetCounterMask() {
// if retval[i] = 2, chkCounter2 is checked
for (auto i : retval) {
if (i > 3) {
throw sls::RuntimeError(
throw RuntimeError(
std::string("Unknown counter index : ") +
std::to_string(static_cast<int>(i)));
}
@ -496,3 +498,5 @@ void qTabSettings::Refresh() {
LOG(logDEBUG) << "**Updated Settings Tab";
}
} // namespace sls