Guidetector (#54)

* WIP

* dacWidget

* main WIP

* advanced WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* works

* updated gui to chrono

* review fixes

* unitque ptrs in gui
This commit is contained in:
Dhanya Thattil
2019-08-26 19:14:22 +02:00
committed by GitHub
parent 7a4c1161ab
commit aafe049a9b
31 changed files with 709 additions and 1138 deletions

View File

@@ -1,10 +1,11 @@
#include "qTabAdvanced.h"
#include "qDefs.h"
#include "network_utils.h"
#include <iostream>
qTabAdvanced::qTabAdvanced(QWidget *parent, multiSlsDetector *detector)
: QWidget(parent), myDet(detector) {
qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector)
: QWidget(parent), det(detector) {
setupUi(this);
SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Advanced ready";
@@ -14,7 +15,7 @@ qTabAdvanced::~qTabAdvanced() {}
void qTabAdvanced::SetupWidgetWindow() {
// enabling according to det type
switch (myDet->getDetectorTypeAsEnum()) {
switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER:
tab_trimming->setEnabled(true);
lblSubExpTime->setEnabled(true);
@@ -55,7 +56,7 @@ void qTabAdvanced::Initialization() {
// network
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector(int)));
SLOT(SetDetector()));
connect(spinControlPort, SIGNAL(valueChanged(int)), this,
SLOT(SetControlPort(int)));
connect(spinStopPort, SIGNAL(valueChanged(int)), this,
@@ -109,20 +110,21 @@ void qTabAdvanced::Initialization() {
void qTabAdvanced::PopulateDetectors() {
FILE_LOG(logDEBUG) << "Populating detectors";
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector(int)));
SLOT(SetDetector()));
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
comboDetector->clear();
comboReadout->clear();
for (unsigned int i = 0; i < myDet->size(); ++i) {
comboDetector->addItem(QString(myDet->getHostname(i).c_str()));
comboReadout->addItem(QString(myDet->getHostname(i).c_str()));
auto res = det->getHostname();
for (auto &it : res) {
comboDetector->addItem(QString(it.c_str()));
comboReadout->addItem(QString(it.c_str()));
}
comboDetector->setCurrentIndex(0);
comboReadout->setCurrentIndex(0);
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector(int)));
SLOT(SetDetector()));
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
}
@@ -132,7 +134,7 @@ void qTabAdvanced::GetControlPort() {
SLOT(SetControlPort(int)));
try {
int retval = myDet->setControlPort(-1, comboDetector->currentIndex());
int retval = det->getControlPort({comboDetector->currentIndex()})[0];
spinControlPort->setValue(retval);
} CATCH_DISPLAY ("Could not get detector control port.", "qTabAdvanced::GetControlPort")
@@ -146,7 +148,7 @@ void qTabAdvanced::GetStopPort() {
SLOT(SetStopPort(int)));
try {
int retval = myDet->setStopPort(-1, comboDetector->currentIndex());
int retval = det->getStopPort({comboDetector->currentIndex()})[0];
spinStopPort->setValue(retval);
} CATCH_DISPLAY ("Could not get detector stop port.", "qTabAdvanced::GetStopPort")
@@ -160,7 +162,7 @@ void qTabAdvanced::GetDetectorUDPIP() {
SLOT(SetDetectorUDPIP()));
try {
auto retval = myDet->getDetectorIP(comboDetector->currentIndex());
auto retval = det->getSourceUDPIP({comboDetector->currentIndex()})[0].str();
dispDetectorUDPIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get detector UDP IP.", "qTabAdvanced::GetDetectorUDPIP")
@@ -174,7 +176,7 @@ void qTabAdvanced::GetDetectorUDPMAC() {
SLOT(SetDetectorUDPMAC()));
try {
auto retval = myDet->getDetectorMAC(comboDetector->currentIndex());
auto retval = det->getSourceUDPMAC({comboDetector->currentIndex()})[0].str();
dispDetectorUDPMAC->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get detector UDP MAC.", "qTabAdvanced::GetDetectorUDPMAC")
@@ -189,7 +191,7 @@ void qTabAdvanced::GetCltZMQPort() {
try {
int retval =
myDet->getClientStreamingPort(comboDetector->currentIndex());
det->getClientZmqPort({comboDetector->currentIndex()})[0];
spinZMQPort->setValue(retval);
} CATCH_DISPLAY ("Could not get client zmq port.", "qTabAdvanced::GetCltZMQPort")
@@ -203,7 +205,7 @@ void qTabAdvanced::GetCltZMQIP() {
try {
auto retval =
myDet->getClientStreamingIP(comboDetector->currentIndex());
det->getClientZmqIp({comboDetector->currentIndex()})[0];
dispZMQIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get client zmq ip.", "qTabAdvanced::GetCltZMQIP")
@@ -216,7 +218,7 @@ void qTabAdvanced::GetRxrHostname() {
SLOT(SetRxrHostname()));
try {
auto retval = myDet->getReceiverHostname(comboDetector->currentIndex());
auto retval = det->getRxHostname({comboDetector->currentIndex()})[0];
dispRxrHostname->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver hostname.", "qTabAdvanced::GetRxrHostname")
@@ -230,7 +232,7 @@ void qTabAdvanced::GetRxrTCPPort() {
SLOT(SetRxrTCPPort(int)));
try {
int retval = myDet->getReceiverPort(comboDetector->currentIndex());
int retval = det->getRxPort({comboDetector->currentIndex()})[0];
spinRxrTCPPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver tcp port.", "qTabAdvanced::GetRxrTCPPort")
@@ -244,7 +246,7 @@ void qTabAdvanced::GetRxrUDPPort() {
SLOT(SetRxrUDPPort(int)));
try {
int retval = myDet->getReceiverUDPPort(comboDetector->currentIndex());
int retval = det->getDestinationUDPPort({comboDetector->currentIndex()})[0];
spinRxrUDPPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver udp port.", "qTabAdvanced::GetRxrUDPPort")
@@ -258,7 +260,7 @@ void qTabAdvanced::GetRxrUDPIP() {
SLOT(SetRxrUDPIP()));
try {
auto retval = myDet->getReceiverUDPIP(comboDetector->currentIndex());
auto retval = det->getDestinationUDPIP({comboDetector->currentIndex()})[0].str();
dispRxrUDPIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver udp ip.", "qTabAdvanced::GetRxrUDPIP")
@@ -271,7 +273,7 @@ void qTabAdvanced::GetRxrUDPMAC() {
SLOT(SetRxrUDPMAC()));
try {
auto retval = myDet->getReceiverUDPMAC(comboDetector->currentIndex());
auto retval = det->getDestinationUDPMAC({comboDetector->currentIndex()})[0].str();
dispRxrUDPMAC->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver udp mac.", "qTabAdvanced::GetRxrUDPMAC")
@@ -286,7 +288,7 @@ void qTabAdvanced::GetRxrZMQPort() {
try {
int retval =
myDet->getReceiverStreamingPort(comboDetector->currentIndex());
det->getRxZmqPort({comboDetector->currentIndex()})[0];
spinRxrZMQPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver zmq port.", "qTabAdvanced::GetRxrZMQPort")
@@ -301,14 +303,14 @@ void qTabAdvanced::GetRxrZMQIP() {
try {
auto retval =
myDet->getReceiverStreamingIP(comboDetector->currentIndex());
det->getRxZmqIP({comboDetector->currentIndex()})[0];
dispRxrZMQIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP")
connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP()));
}
void qTabAdvanced::SetDetector(int index) {
void qTabAdvanced::SetDetector() {
FILE_LOG(logDEBUG) << "Set Detector: "
<< comboDetector->currentText().toAscii().data();
@@ -326,13 +328,13 @@ void qTabAdvanced::SetDetector(int index) {
GetRxrZMQPort();
GetRxrZMQIP();
FILE_LOG(logDEBUG) << myDet->printReceiverConfiguration();
FILE_LOG(logDEBUG) << det->printRxConfiguration();
}
void qTabAdvanced::SetControlPort(int port) {
FILE_LOG(logINFO) << "Setting Control Port:" << port;
try {
myDet->setControlPort(port, comboDetector->currentIndex());
det->setControlPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE("Could not set control port.", "qTabAdvanced::SetControlPort",
this, &qTabAdvanced::GetControlPort)
}
@@ -340,7 +342,7 @@ void qTabAdvanced::SetControlPort(int port) {
void qTabAdvanced::SetStopPort(int port) {
FILE_LOG(logINFO) << "Setting Stop Port:" << port;
try {
myDet->setStopPort(port, comboDetector->currentIndex());
det->setStopPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set stop port.", "qTabAdvanced::SetStopPort", this,
&qTabAdvanced::GetStopPort)
}
@@ -349,7 +351,7 @@ void qTabAdvanced::SetDetectorUDPIP() {
std::string s = dispDetectorUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s;
try {
myDet->setDetectorIP(s, comboDetector->currentIndex());
det->setSourceUDPIP(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP IP.",
"qTabAdvanced::SetDetectorUDPIP", this,
&qTabAdvanced::GetDetectorUDPIP)
@@ -359,7 +361,7 @@ void qTabAdvanced::SetDetectorUDPMAC() {
std::string s = dispDetectorUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s;
try {
myDet->setDetectorMAC(s, comboDetector->currentIndex());
det->setSourceUDPMAC(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP MAC.",
"qTabAdvanced::SetDetectorUDPMAC", this,
&qTabAdvanced::GetDetectorUDPMAC)
@@ -368,8 +370,7 @@ void qTabAdvanced::SetDetectorUDPMAC() {
void qTabAdvanced::SetCltZMQPort(int port) {
FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port;
try {
myDet->setClientDataStreamingInPort(port,
comboDetector->currentIndex());
det->setClientZmqPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ port.",
"qTabAdvanced::SetCltZMQPort", this,
&qTabAdvanced::GetCltZMQPort)
@@ -379,7 +380,7 @@ void qTabAdvanced::SetCltZMQIP() {
std::string s = dispZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s;
try {
myDet->setClientDataStreamingInIP(s, comboDetector->currentIndex());
det->setClientZmqIp(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.",
"qTabAdvanced::SetCltZMQIP", this,
&qTabAdvanced::GetCltZMQIP)
@@ -389,19 +390,19 @@ void qTabAdvanced::SetRxrHostname() {
std::string s = dispZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s;
try {
myDet->setReceiverHostname(s, comboDetector->currentIndex());
det->setRxHostname(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.",
"qTabAdvanced::SetRxrHostname", this,
&qTabAdvanced::GetRxrHostname)
// update all network widgets (receiver mainly)
SetDetector(comboDetector->currentIndex());
SetDetector();
}
void qTabAdvanced::SetRxrTCPPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port;
try {
myDet->setReceiverPort(port, comboDetector->currentIndex());
det->setRxPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver TCP port.",
"qTabAdvanced::SetRxrTCPPort", this,
&qTabAdvanced::GetRxrTCPPort)
@@ -410,7 +411,7 @@ void qTabAdvanced::SetRxrTCPPort(int port) {
void qTabAdvanced::SetRxrUDPPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port;
try {
myDet->setReceiverUDPPort(port, comboDetector->currentIndex());
det->setRxPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP port.",
"qTabAdvanced::SetRxrUDPPort", this,
&qTabAdvanced::GetRxrUDPPort)
@@ -420,7 +421,7 @@ void qTabAdvanced::SetRxrUDPIP() {
std::string s = dispRxrUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s;
try {
myDet->setReceiverUDPIP(s, comboDetector->currentIndex());
det->setDestinationUDPIP(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP IP.",
"qTabAdvanced::SetRxrUDPIP", this,
&qTabAdvanced::GetRxrUDPIP)
@@ -430,7 +431,7 @@ void qTabAdvanced::SetRxrUDPMAC() {
std::string s = dispRxrUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
try {
myDet->setReceiverUDPMAC(s, comboDetector->currentIndex());
det->setDestinationUDPMAC(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP MAC.",
"qTabAdvanced::SetRxrUDPMAC", this,
&qTabAdvanced::GetRxrUDPMAC)
@@ -439,8 +440,7 @@ void qTabAdvanced::SetRxrUDPMAC() {
void qTabAdvanced::SetRxrZMQPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port;
try {
myDet->setReceiverDataStreamingOutPort(port,
comboDetector->currentIndex());
det->setRxZmqPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ port.",
"qTabAdvanced::SetRxrZMQPort", this,
&qTabAdvanced::GetRxrZMQPort)
@@ -450,7 +450,7 @@ void qTabAdvanced::SetRxrZMQIP() {
std::string s = dispRxrZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
try {
myDet->setReceiverDataStreamingOutIP(s, comboDetector->currentIndex());
det->setRxZmqIP(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ IP.",
"qTabAdvanced::SetRxrZMQIP", this,
&qTabAdvanced::GetRxrZMQIP)
@@ -459,7 +459,7 @@ void qTabAdvanced::SetRxrZMQIP() {
void qTabAdvanced::GetROI() {
FILE_LOG(logDEBUG) << "Getting ROI";
try {
slsDetectorDefs::ROI roi = myDet->getROI(comboReadout->currentIndex());
slsDetectorDefs::ROI roi = det->getROI({comboReadout->currentIndex()})[0];
spinXmin->setValue(roi.xmin);
spinXmax->setValue(roi.xmax);
} CATCH_DISPLAY ("Could not get ROI.", "qTabAdvanced::GetROI")
@@ -482,7 +482,7 @@ void qTabAdvanced::SetROI() {
// set roi
FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]";
try {
myDet->setROI(roi, comboReadout->currentIndex());
det->setROI(roi, {comboReadout->currentIndex()});
} CATCH_DISPLAY ("Could not set these ROIs.",
"qTabAdvanced::SetROI")
@@ -496,7 +496,7 @@ void qTabAdvanced::GetAllTrimbits() {
SLOT(SetAllTrimbits()));
try {
int retval = myDet->setAllTrimbits(-1);
int retval = det->getAllTrimbits().squash(-1);
spinSetAllTrimbits->setValue(retval);
} CATCH_DISPLAY ("Could not get all trimbits.", "qTabAdvanced::GetAllTrimbits")
@@ -509,7 +509,7 @@ void qTabAdvanced::SetAllTrimbits() {
FILE_LOG(logINFO) << "Setting all trimbits:" << value;
try {
myDet->setAllTrimbits(value);
det->setAllTrimbits(value);
} CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits",
this, &qTabAdvanced::GetAllTrimbits)
}
@@ -520,7 +520,7 @@ void qTabAdvanced::GetNumStoragecells() {
SLOT(SetNumStoragecells(int)));
try {
auto retval = myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER);
auto retval = det->getNumberOfAdditionalStorageCells().tsquash("Inconsistent values for number of addditional storage cells.");
spinNumStoragecells->setValue(retval);
} CATCH_DISPLAY (
"Could not get number of additional storage cells.",
@@ -534,7 +534,7 @@ void qTabAdvanced::SetNumStoragecells(int value) {
FILE_LOG(logINFO) << "Setting number of additional stoarge cells: "
<< value;
try {
myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, value, -1);
det->setNumberOfAdditionalStorageCells(value);
} CATCH_HANDLE (
"Could not set number of additional storage cells.",
"qTabAdvanced::SetNumStoragecells", this,
@@ -547,24 +547,14 @@ void qTabAdvanced::GetSubExposureTime() {
SLOT(SetSubExposureTime()));
disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSubExposureTime()));
try {
int64_t retval =
myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME);
if (retval == -1) {
qDefs::Message(qDefs::WARNING,
"Subexptime is inconsistent for all detectors.",
"qTabAdvanced::GetSubExposureTime");
spinSubExpTime->setValue(-1);
} else {
double value = (double)(retval * (1E-9));
auto time = qDefs::getCorrectTime(value);
spinSubExpTime->setValue(time.first);
comboSubExpTimeUnit->setCurrentIndex(static_cast<int>(time.second));
}
auto retval =
det->getSubExptime().tsquash("Subexptime is inconsistent for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval);
spinSubExpTime->setValue(time.first);
comboSubExpTimeUnit->setCurrentIndex(static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get sub exposure time.",
"qTabSettings::GetSubExposureTime")
connect(spinSubExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetSubExposureTime()));
connect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
@@ -572,17 +562,14 @@ void qTabAdvanced::GetSubExposureTime() {
}
void qTabAdvanced::SetSubExposureTime() {
double timeNS =
qDefs::getNSTime((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(),
spinSubExpTime->value());
auto timeNS = qDefs::getNSTime(std::make_pair(spinSubExpTime->value(), static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex())));
FILE_LOG(logINFO)
<< "Setting sub frame acquisition time to " << timeNS << " ns"
<< "Setting sub frame acquisition time to " << timeNS.count() << " ns"
<< "/" << spinSubExpTime->value()
<< qDefs::getUnitString(
(qDefs::timeUnit)comboSubExpTimeUnit->currentIndex());
try {
myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,
(int64_t)timeNS, -1);
det->setSubExptime(timeNS);
} CATCH_DISPLAY ("Could not set sub exposure time.",
"qTabAdvanced::SetSubExposureTime")
@@ -595,24 +582,14 @@ void qTabAdvanced::GetSubDeadTime() {
SLOT(SetSubDeadTime()));
disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSubDeadTime()));
try {
int64_t retval = myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME);
if (retval == -1) {
qDefs::Message(qDefs::WARNING,
"Sub dead time is inconsistent for all detectors.",
"qTabAdvanced::GetSubDeadTime");
spinSubDeadTime->setValue(-1);
} else {
double value = (double)(retval * (1E-9));
auto time = qDefs::getCorrectTime(value);
spinSubDeadTime->setValue(time.first);
comboSubDeadTimeUnit->setCurrentIndex(
static_cast<int>(time.second));
}
auto retval = det->getSubDeadTime().tsquash("Sub dead time is inconsistent for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval);
spinSubDeadTime->setValue(time.first);
comboSubDeadTimeUnit->setCurrentIndex(
static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get sub dead time.",
"qTabSettings::GetSubDeadTime")
connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this,
SLOT(SetSubDeadTime()));
connect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
@@ -620,20 +597,17 @@ void qTabAdvanced::GetSubDeadTime() {
}
void qTabAdvanced::SetSubDeadTime() {
double timeNS =
qDefs::getNSTime((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex(),
spinSubDeadTime->value());
auto timeNS = qDefs::getNSTime(std::make_pair(spinSubDeadTime->value(), static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex())));
FILE_LOG(logINFO)
<< "Setting sub frame dead time to " << timeNS << " ns"
<< "Setting sub frame dead time to " << timeNS.count() << " ns"
<< "/" << spinSubDeadTime->value()
<< qDefs::getUnitString(
(qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex());
try {
myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME, (int64_t)timeNS,
-1);
det->setSubDeadTime(timeNS);
} CATCH_DISPLAY ("Could not set sub dead time.",
"qTabAdvanced::SetSubDeadTime")
GetSubDeadTime();
}
@@ -646,7 +620,7 @@ void qTabAdvanced::Refresh() {
}
// update all network widgets
SetDetector(comboDetector->currentIndex());
SetDetector();
// roi
if (tab_roi->isEnabled()) {