diff --git a/slsDetectorGui/client/qClient.cpp b/slsDetectorGui/client/qClient.cpp index f4ceccd9f..b301ba7a4 100755 --- a/slsDetectorGui/client/qClient.cpp +++ b/slsDetectorGui/client/qClient.cpp @@ -30,7 +30,7 @@ void qClient::executeLine(int narg, char *args[]) { // validate command structure if (narg < 1) { - throw sls::NonCriticalError("No command parsed. " + printCommands()); + throw sls::RuntimeError("No command parsed. " + printCommands()); } // help @@ -49,7 +49,7 @@ void qClient::executeLine(int narg, char *args[]) { else if (argument == "stop") stopAcquisition(); else { - throw sls::NonCriticalError("Could not parse arguments. " + printCommands()); + throw sls::RuntimeError("Could not parse arguments. " + printCommands()); } } retval = getStatus(); @@ -67,7 +67,7 @@ void qClient::executeLine(int narg, char *args[]) { // unrecognized command else { - throw sls::NonCriticalError("Unrecognized command. " + printCommands()); + throw sls::RuntimeError("Unrecognized command. " + printCommands()); } // print result diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h index 6633de9f7..c1f50ee85 100755 --- a/slsDetectorGui/include/qDefs.h +++ b/slsDetectorGui/include/qDefs.h @@ -11,6 +11,9 @@ #include #include +#define CATCH_DISPLAY(m, s) catch(...) { qDefs::DisplayExceptions(m, s); } +#define CATCH_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); } + class qDefs : public QWidget { public: /** @@ -18,7 +21,36 @@ class qDefs : public QWidget { */ qDefs(){}; -#define GOODBYE -200 + #define GOODBYE -200 + + static void DisplayExceptions(std::string emsg, std::string src) { + try { + throw; + } catch (sls::SocketError) { + throw; + } catch (sls::SharedMemoryError) { + throw; + } catch (const std::exception &e) { + ExceptionMessage(emsg, e.what(), src); + } + } + + template struct NonDeduced { using type = CT; }; + template + static void HandleExceptions(const std::string emsg, const std::string src, S* s, + RT (S::*somefunc)(CT...), + typename NonDeduced::type... Args) { + try { + throw; + } catch (sls::SocketError) { + throw; + } catch (sls::SharedMemoryError) { + throw; + } catch (const std::exception &e) { + ExceptionMessage(emsg, e.what(), src); + (s->*somefunc)(Args...); + } + } /** function enums */ enum qFuncNames { diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index c11c0eac5..d0926df0d 100755 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -349,9 +349,7 @@ void qDetectorMain::LoadConfigFile(const std::string fName) { } else { try { myDet->readConfigurationFile(fName); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not load config file.", e.what(), "qDetectorMain::LoadConfigFile"); - } + } CATCH_DISPLAY ("Could not load config file.", "qDetectorMain::LoadConfigFile") } } @@ -562,9 +560,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) { } } } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not execute utilities.", e.what(), "qDetectorMain::ExecuteUtilities"); - } + } CATCH_DISPLAY ("Could not execute utilities.", "qDetectorMain::ExecuteUtilities") Refresh(tabs->currentIndex()); if (refreshTabs) { @@ -587,13 +583,10 @@ void qDetectorMain::ExecuteHelp(QAction *action) { "and Moench detectors"; std::string guiVersion = std::to_string(APIGUI); - std::string clientVersion; + std::string clientVersion = "unknown"; try { clientVersion = std::to_string(myDet->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION)); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get client version.", e.what(), "qDetectorMain::ExecuteHelp"); - clientVersion = "unknown"; - } + } CATCH_DISPLAY ("Could not get client version.", "qDetectorMain::ExecuteHelp") qDefs::Message(qDefs::INFORMATION, "

" diff --git a/slsDetectorGui/src/qServer.cpp b/slsDetectorGui/src/qServer.cpp index 8ee37e763..7ff98832a 100755 --- a/slsDetectorGui/src/qServer.cpp +++ b/slsDetectorGui/src/qServer.cpp @@ -90,7 +90,7 @@ void qServer::ServerThread(bool isControlServer) { auto socket = (isControlServer ? controlSocket->accept() : stopSocket->accept()); try{ DecodeFunction(socket); - } catch(const sls::NonCriticalError &e) { + } catch(const sls::RuntimeError &e) { if (strstr(e.what(), "exit")) { FILE_LOG(logINFO) << "Exiting " << (isControlServer ? "Control" : "Stop") << "Server"; @@ -101,7 +101,7 @@ void qServer::ServerThread(bool isControlServer) { socket.Send(qDefs::FAIL); socket.Send(mess); } - } catch (const sls::NonCriticalError &e) { + } catch (const sls::RuntimeError &e) { FILE_LOG(logERROR) << "Accept failed"; } @@ -130,21 +130,21 @@ void qServer::GetStatus(sls::ServerInterface2 &socket) { void qServer::StartAcquisition(sls::ServerInterface2 &socket) { if (mainTab->StartStopAcquisitionFromClient(true) == slsDetectorDefs::FAIL) { - throw sls::NonCriticalError("Could not start acquistion in Gui"); + throw sls::RuntimeError("Could not start acquistion in Gui"); } socket.Send(slsDetectorDefs::OK); } void qServer::StopsAcquisition(sls::ServerInterface2 &socket) { if (mainTab->StartStopAcquisitionFromClient(false) == slsDetectorDefs::FAIL) { - throw sls::NonCriticalError("Could not stop acquistion in Gui"); + throw sls::RuntimeError("Could not stop acquistion in Gui"); } socket.Send(slsDetectorDefs::OK); } void qServer::Acquire(sls::ServerInterface2 &socket) { if (mainTab->StartStopAcquisitionFromClient(true) == slsDetectorDefs::FAIL) { - throw sls::NonCriticalError("Could not start blocking acquistion in Gui"); + throw sls::RuntimeError("Could not start blocking acquistion in Gui"); } // blocking usleep(5000); @@ -155,5 +155,5 @@ void qServer::Acquire(sls::ServerInterface2 &socket) { } void qServer::ExitServer(sls::ServerInterface2 &socket) { - throw sls::NonCriticalError("Server exited"); + throw sls::RuntimeError("Server exited"); } \ No newline at end of file diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index 12c5c4bb3..409910218 100755 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -3,860 +3,896 @@ #include - -qTabAdvanced::qTabAdvanced(QWidget *parent, multiSlsDetector* detector): -QWidget(parent), myDet(detector) { - setupUi(this); - SetupWidgetWindow(); - FILE_LOG(logDEBUG) << "Advanced ready"; +qTabAdvanced::qTabAdvanced(QWidget *parent, multiSlsDetector *detector) + : QWidget(parent), myDet(detector) { + setupUi(this); + SetupWidgetWindow(); + FILE_LOG(logDEBUG) << "Advanced ready"; } -qTabAdvanced::~qTabAdvanced(){ - for (int i = 0; i < lblFromX.size(); ++i) { - delete lblFromX[i]; - delete lblFromY[i]; - delete lblToX[i]; - delete lblToY[i]; - delete spinFromX[i]; - delete spinFromY[i]; - delete spinToX[i]; - delete spinToY[i]; - } +qTabAdvanced::~qTabAdvanced() { + for (size_t i = 0; i < lblFromX.size(); ++i) { + delete lblFromX[i]; + delete lblFromY[i]; + delete lblToX[i]; + delete lblToY[i]; + delete spinFromX[i]; + delete spinFromY[i]; + delete spinToX[i]; + delete spinToY[i]; + } } -void qTabAdvanced::SetupWidgetWindow(){ - // palette - red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - detOnlineTip = dispOnline->toolTip(); - rxrOnlineTip = dispRxrOnline->toolTip(); - errOnlineTip = QString("

It is offline!"); +void qTabAdvanced::SetupWidgetWindow() { + // palette + red = QPalette(); + red.setColor(QPalette::Active, QPalette::WindowText, Qt::red); + detOnlineTip = dispOnline->toolTip(); + rxrOnlineTip = dispRxrOnline->toolTip(); + errOnlineTip = QString( + "

It is offline!"); - // enabling according to det type - switch(myDet->getDetectorTypeAsEnum()) { - case slsDetectorDefs::EIGER: - tab_trimming->setEnabled(true); - lblSubExpTime->setEnabled(true); - spinSubExpTime->setEnabled(true); - comboSubExpTimeUnit->setEnabled(true); - lblSubDeadTime->setEnabled(true); - spinSubDeadTime->setEnabled(true); - comboSubDeadTimeUnit->setEnabled(true); - break; - case slsDetectorDefs::GOTTHARD: - tab_roi->setEnabled(true); - break; - default: - break; - } + // enabling according to det type + switch (myDet->getDetectorTypeAsEnum()) { + case slsDetectorDefs::EIGER: + tab_trimming->setEnabled(true); + lblSubExpTime->setEnabled(true); + spinSubExpTime->setEnabled(true); + comboSubExpTimeUnit->setEnabled(true); + lblSubDeadTime->setEnabled(true); + spinSubDeadTime->setEnabled(true); + comboSubDeadTimeUnit->setEnabled(true); + break; + case slsDetectorDefs::GOTTHARD: + tab_roi->setEnabled(true); + break; + default: + break; + } - // set initially to network tab - tabAdvancedSettings->setCurrentWidget(tab_network); + // set initially to network tab + tabAdvancedSettings->setCurrentWidget(tab_network); - Initialization(); + Initialization(); - PopulateDetectors(); - - Refresh(); + PopulateDetectors(); + + Refresh(); } -void qTabAdvanced::Initialization(){ +void qTabAdvanced::Initialization() { - connect(tabAdvancedSettings, SIGNAL(currentChanged(int)), this, SLOT(Refresh())); + connect(tabAdvancedSettings, SIGNAL(currentChanged(int)), this, + SLOT(Refresh())); - // trimming - if (tab_trimming->isEnabled()) { - // editingFinished to not set trimbits for every character input - connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); - } + // trimming + if (tab_trimming->isEnabled()) { + // editingFinished to not set trimbits for every character input + connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, + SLOT(SetAllTrimbits())); + } - //network - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); - connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPIP())); - connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPMAC())); - connect(spinZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZMQPort(int))); - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); - connect(dispRxrHostname, SIGNAL(editingFinished()), this, SLOT(SetRxrHostname())); - connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); - connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPMAC())); - connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZMQPort(int))); - connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); + // network + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetDetector(int))); + connect(spinControlPort, SIGNAL(valueChanged(int)), this, + SLOT(SetControlPort(int))); + connect(spinStopPort, SIGNAL(valueChanged(int)), this, + SLOT(SetStopPort(int))); + connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, + SLOT(SetDetectorUDPIP())); + connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, + SLOT(SetDetectorUDPMAC())); + connect(spinZMQPort, SIGNAL(valueChanged(int)), this, + SLOT(SetCltZMQPort(int))); + connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); + connect(dispRxrHostname, SIGNAL(editingFinished()), this, + SLOT(SetRxrHostname())); + connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrTCPPort(int))); + connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrUDPPort(int))); + connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); + connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, + SLOT(SetRxrUDPMAC())); + connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrZMQPort(int))); + connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); - // roi - if (gridRoi->isEnabled()) { - connect(btnAddRoi, SIGNAL(clicked()), this, SLOT(AddROISlot())); - connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(SetROI())); - connect(btnGetRoi, SIGNAL(clicked()), this, SLOT(GetROI())); - connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(ClearROI())); - } + // roi + if (gridRoi->isEnabled()) { + connect(btnAddRoi, SIGNAL(clicked()), this, SLOT(AddROISlot())); + connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(SetROI())); + connect(btnGetRoi, SIGNAL(clicked()), this, SLOT(GetROI())); + connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(ClearROI())); + } - // storage cells - if (lblNumStoragecells->isEnabled()) { - connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); - } + // storage cells + if (lblNumStoragecells->isEnabled()) { + connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, + SLOT(SetNumStoragecells(int))); + } - // subexptime, subdeadtime - if (lblSubExpTime->isEnabled()) { - connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); - connect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); - connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubDeadTime())); - } + // subexptime, subdeadtime + if (lblSubExpTime->isEnabled()) { + connect(spinSubExpTime, SIGNAL(valueChanged(double)), this, + SLOT(SetSubExposureTime())); + connect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetSubExposureTime())); + connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this, + SLOT(SetSubDeadTime())); + connect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetSubDeadTime())); + } } -void qTabAdvanced::PopulateDetectors() { - FILE_LOG(logDEBUG) << "Populating detectors"; - disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); +void qTabAdvanced::PopulateDetectors() { + FILE_LOG(logDEBUG) << "Populating detectors"; + disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetDetector(int))); - comboDetector->clear(); - for(int i = 0; i < myDet->getNumberOfDetectors(); ++i) - comboDetector->addItem(QString(myDet->getHostname(i).c_str())); - comboDetector->setCurrentIndex(0); + comboDetector->clear(); + for (int i = 0; i < myDet->getNumberOfDetectors(); ++i) + comboDetector->addItem(QString(myDet->getHostname(i).c_str())); + comboDetector->setCurrentIndex(0); - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetDetector(int))); } void qTabAdvanced::GetOnline() { - FILE_LOG(logDEBUG) << "Getting detector online status"; + FILE_LOG(logDEBUG) << "Getting detector online status"; - int moduleId = comboDetector->currentIndex(); - try { - myDet->checkOnline(moduleId); - - int ret = myDet->getOnlineFlag(moduleId); - switch(ret) { - case 1: - dispOnline->setText("Online"); - lblOnline->setText("Detector Online Status: "); - dispOnline->setToolTip(detOnlineTip); - lblOnline->setToolTip(detOnlineTip); - dispOnline->setPalette(lblHostname->palette()); - lblOnline->setPalette(lblHostname->palette()); - default: - dispOnline->setText("Offline"); - lblOnline->setText("Detector Online Status:* "); - dispOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - dispOnline->setPalette(red); - lblOnline->setPalette(red); - break; - } - } - // ignore if checkonline throws socket exception, else display it - catch (const sls::SocketError &e) { - ;// do nothing as it might just be offline - } - // display any other exception - catch (const std::exception &e) { - qDefs::ExceptionMessage("Could not get detector online status", e.what(), "qTabAdvanced::GetOnline"); - } + int moduleId = comboDetector->currentIndex(); + try { + myDet->checkOnline(moduleId); + + int ret = myDet->getOnlineFlag(moduleId); + switch (ret) { + case 1: + dispOnline->setText("Online"); + lblOnline->setText("Detector Online Status: "); + dispOnline->setToolTip(detOnlineTip); + lblOnline->setToolTip(detOnlineTip); + dispOnline->setPalette(lblHostname->palette()); + lblOnline->setPalette(lblHostname->palette()); + default: + dispOnline->setText("Offline"); + lblOnline->setText("Detector Online Status:* "); + dispOnline->setToolTip(detOnlineTip + errOnlineTip); + lblOnline->setToolTip(detOnlineTip + errOnlineTip); + dispOnline->setPalette(red); + lblOnline->setPalette(red); + break; + } + } + // ignore if checkonline throws socket exception, else display it + catch (const sls::SocketError &e) { + ; // do nothing as it might just be offline + } + // display any other exception + catch (const std::exception &e) { + qDefs::ExceptionMessage("Could not get detector online status", + e.what(), "qTabAdvanced::GetOnline"); + } } void qTabAdvanced::GetControlPort() { - FILE_LOG(logDEBUG) << "Getting control port "; - disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); + FILE_LOG(logDEBUG) << "Getting control port "; + disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, + SLOT(SetControlPort(int))); - try { + try { int retval = myDet->setControlPort(-1, comboDetector->currentIndex()); - spinControlPort->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get detector control port.", e.what(), "qTabAdvanced::GetControlPort"); - } + spinControlPort->setValue(retval); + } CATCH_DISPLAY ("Could not get detector control port.", "qTabAdvanced::GetControlPort") - connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); + connect(spinControlPort, SIGNAL(valueChanged(int)), this, + SLOT(SetControlPort(int))); } void qTabAdvanced::GetStopPort() { - FILE_LOG(logDEBUG) << "Getting stop port"; - disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); + FILE_LOG(logDEBUG) << "Getting stop port"; + disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, + SLOT(SetStopPort(int))); - try { + try { int retval = myDet->setStopPort(-1, comboDetector->currentIndex()); - spinStopPort->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get detector stop port.", e.what(), "qTabAdvanced::GetStopPort"); - } + spinStopPort->setValue(retval); + } CATCH_DISPLAY ("Could not get detector stop port.", "qTabAdvanced::GetStopPort") - connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); + connect(spinStopPort, SIGNAL(valueChanged(int)), this, + SLOT(SetStopPort(int))); } void qTabAdvanced::GetDetectorUDPIP() { - FILE_LOG(logDEBUG) << "Getting Detector UDP IP"; - disconnect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPIP())); + FILE_LOG(logDEBUG) << "Getting Detector UDP IP"; + disconnect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, + SLOT(SetDetectorUDPIP())); - try { + try { auto retval = myDet->getDetectorIP(comboDetector->currentIndex()); - dispDetectorUDPIP->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get detector UDP IP.", e.what(), "qTabAdvanced::GetDetectorUDPIP"); - } + dispDetectorUDPIP->setText(QString(retval.c_str())); + } CATCH_DISPLAY ("Could not get detector UDP IP.", "qTabAdvanced::GetDetectorUDPIP") - connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPIP())); + connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, + SLOT(SetDetectorUDPIP())); } void qTabAdvanced::GetDetectorUDPMAC() { - FILE_LOG(logDEBUG) << "Getting Detector UDP MAC"; - disconnect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPMAC())); + FILE_LOG(logDEBUG) << "Getting Detector UDP MAC"; + disconnect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, + SLOT(SetDetectorUDPMAC())); - try { + try { auto retval = myDet->getDetectorMAC(comboDetector->currentIndex()); - dispDetectorUDPMAC->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get detector UDP MAC.", e.what(), "qTabAdvanced::GetDetectorUDPMAC"); - } + dispDetectorUDPMAC->setText(QString(retval.c_str())); + } CATCH_DISPLAY ("Could not get detector UDP MAC.", "qTabAdvanced::GetDetectorUDPMAC") - connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPMAC())); + connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, + SLOT(SetDetectorUDPMAC())); } void qTabAdvanced::GetCltZMQPort() { - FILE_LOG(logDEBUG) << "Getting Client ZMQ port"; - disconnect(spinZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZMQPort(int))); + FILE_LOG(logDEBUG) << "Getting Client ZMQ port"; + disconnect(spinZMQPort, SIGNAL(valueChanged(int)), this, + SLOT(SetCltZMQPort(int))); - try { - int retval = myDet->getClientStreamingPort(comboDetector->currentIndex()); - spinZMQPort->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get client zmq port.", e.what(), "qTabAdvanced::GetCltZMQPort"); - } + try { + int retval = + myDet->getClientStreamingPort(comboDetector->currentIndex()); + spinZMQPort->setValue(retval); + } CATCH_DISPLAY ("Could not get client zmq port.", "qTabAdvanced::GetCltZMQPort") - connect(spinZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZMQPort(int))); + connect(spinZMQPort, SIGNAL(valueChanged(int)), this, + SLOT(SetCltZMQPort(int))); } void qTabAdvanced::GetCltZMQIP() { - FILE_LOG(logDEBUG) << "Getting Client ZMQ IP"; - disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); + FILE_LOG(logDEBUG) << "Getting Client ZMQ IP"; + disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); - try { - auto retval = myDet->getClientStreamingIP(comboDetector->currentIndex()); - dispZMQIP->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get client zmq ip.", e.what(), "qTabAdvanced::GetCltZMQIP"); - } + try { + auto retval = + myDet->getClientStreamingIP(comboDetector->currentIndex()); + dispZMQIP->setText(QString(retval.c_str())); + } CATCH_DISPLAY ("Could not get client zmq ip.", "qTabAdvanced::GetCltZMQIP") - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); + connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); } void qTabAdvanced::GetRxrHostname() { - FILE_LOG(logDEBUG) << "Getting Receiver Hostname"; - disconnect(dispRxrHostname, SIGNAL(editingFinished()), this, SLOT(SetRxrHostname())); + FILE_LOG(logDEBUG) << "Getting Receiver Hostname"; + disconnect(dispRxrHostname, SIGNAL(editingFinished()), this, + SLOT(SetRxrHostname())); - try { + try { auto retval = myDet->getReceiverHostname(comboDetector->currentIndex()); - dispRxrHostname->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get receiver hostname.", e.what(), "qTabAdvanced::GetRxrHostname"); - } + dispRxrHostname->setText(QString(retval.c_str())); + } CATCH_DISPLAY ("Could not get receiver hostname.", "qTabAdvanced::GetRxrHostname") - connect(dispRxrHostname, SIGNAL(editingFinished()), this, SLOT(SetRxrHostname())); + connect(dispRxrHostname, SIGNAL(editingFinished()), this, + SLOT(SetRxrHostname())); } void qTabAdvanced::GetReceiverOnline() { - FILE_LOG(logDEBUG) << "Getting Receiver online status"; - - int moduleId = comboDetector->currentIndex(); - try { - myDet->checkReceiverOnline(moduleId); - - int ret = myDet->getReceiverOnlineFlag(moduleId); - switch(ret) { - case 1: - dispRxrOnline->setText("Online"); - lblRxrOnline->setText("Receiver Online Status: "); - dispRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip); - dispRxrOnline->setPalette(lblHostname->palette()); - lblRxrOnline->setPalette(lblHostname->palette()); - default: - dispRxrOnline->setText("Offline"); - lblRxrOnline->setText("Receiver Online Status:* "); - dispRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - dispRxrOnline->setPalette(red); - lblRxrOnline->setPalette(red); - break; - } - } - // ignore if checkReceiverOnline throws socket exception - catch (const sls::SocketError &e) { - ; - } - // display any other exception - catch (const std::exception &e) { - qDefs::ExceptionMessage("Could not check receiver online status", e.what(), "qTabAdvanced::GetReceiverOnline"); - } + FILE_LOG(logDEBUG) << "Getting Receiver online status"; + + int moduleId = comboDetector->currentIndex(); + try { + myDet->checkReceiverOnline(moduleId); + + int ret = myDet->getReceiverOnlineFlag(moduleId); + switch (ret) { + case 1: + dispRxrOnline->setText("Online"); + lblRxrOnline->setText("Receiver Online Status: "); + dispRxrOnline->setToolTip(rxrOnlineTip); + lblRxrOnline->setToolTip(rxrOnlineTip); + dispRxrOnline->setPalette(lblHostname->palette()); + lblRxrOnline->setPalette(lblHostname->palette()); + default: + dispRxrOnline->setText("Offline"); + lblRxrOnline->setText("Receiver Online Status:* "); + dispRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); + lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); + dispRxrOnline->setPalette(red); + lblRxrOnline->setPalette(red); + break; + } + } + // ignore if checkReceiverOnline throws socket exception + catch (const sls::SocketError &e) { + ; + } + // display any other exception + catch (const std::exception &e) { + qDefs::ExceptionMessage("Could not check receiver online status", + e.what(), "qTabAdvanced::GetReceiverOnline"); + } } void qTabAdvanced::GetRxrTCPPort() { - FILE_LOG(logDEBUG) << "Getting Receiver TCP port"; - disconnect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); + FILE_LOG(logDEBUG) << "Getting Receiver TCP port"; + disconnect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrTCPPort(int))); - try { + try { int retval = myDet->getReceiverPort(comboDetector->currentIndex()); - spinRxrTCPPort->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get receiver tcp port.", e.what(), "qTabAdvanced::GetRxrTCPPort"); - } + spinRxrTCPPort->setValue(retval); + } CATCH_DISPLAY ("Could not get receiver tcp port.", "qTabAdvanced::GetRxrTCPPort") - connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); + connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrTCPPort(int))); } void qTabAdvanced::GetRxrUDPPort() { - FILE_LOG(logDEBUG) << "Getting Receiver UDP port"; - disconnect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); + FILE_LOG(logDEBUG) << "Getting Receiver UDP port"; + disconnect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrUDPPort(int))); - try { + try { int retval = myDet->getReceiverUDPPort(comboDetector->currentIndex()); - spinRxrUDPPort->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get receiver udp port.", e.what(), "qTabAdvanced::GetRxrUDPPort"); - } + spinRxrUDPPort->setValue(retval); + } CATCH_DISPLAY ("Could not get receiver udp port.", "qTabAdvanced::GetRxrUDPPort") - connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); + connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrUDPPort(int))); } void qTabAdvanced::GetRxrUDPIP() { - FILE_LOG(logDEBUG) << "Getting Receiver UDP IP"; - disconnect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); + FILE_LOG(logDEBUG) << "Getting Receiver UDP IP"; + disconnect(dispRxrUDPIP, SIGNAL(editingFinished()), this, + SLOT(SetRxrUDPIP())); - try { + try { auto retval = myDet->getReceiverUDPIP(comboDetector->currentIndex()); - dispRxrUDPIP->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get receiver udp ip.", e.what(), "qTabAdvanced::GetRxrUDPIP"); - } + dispRxrUDPIP->setText(QString(retval.c_str())); + } CATCH_DISPLAY ("Could not get receiver udp ip.", "qTabAdvanced::GetRxrUDPIP") - connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); + connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); } void qTabAdvanced::GetRxrUDPMAC() { - FILE_LOG(logDEBUG) << "Getting Receiver UDP MAC"; - disconnect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPMAC())); + FILE_LOG(logDEBUG) << "Getting Receiver UDP MAC"; + disconnect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, + SLOT(SetRxrUDPMAC())); - try { + try { auto retval = myDet->getReceiverUDPMAC(comboDetector->currentIndex()); - dispRxrUDPMAC->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get receiver udp mac.", e.what(), "qTabAdvanced::GetRxrUDPMAC"); - } + dispRxrUDPMAC->setText(QString(retval.c_str())); + } CATCH_DISPLAY ("Could not get receiver udp mac.", "qTabAdvanced::GetRxrUDPMAC") - connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPMAC())); + connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, + SLOT(SetRxrUDPMAC())); } void qTabAdvanced::GetRxrZMQPort() { - FILE_LOG(logDEBUG) << "Getting Receiver ZMQ port"; - disconnect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZMQPort(int))); + FILE_LOG(logDEBUG) << "Getting Receiver ZMQ port"; + disconnect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrZMQPort(int))); - try { - int retval = myDet->getReceiverStreamingPort(comboDetector->currentIndex()); - spinRxrZMQPort->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get receiver zmq port.", e.what(), "qTabAdvanced::GetRxrZMQPort"); - } + try { + int retval = + myDet->getReceiverStreamingPort(comboDetector->currentIndex()); + spinRxrZMQPort->setValue(retval); + } CATCH_DISPLAY ("Could not get receiver zmq port.", "qTabAdvanced::GetRxrZMQPort") - connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZMQPort(int))); + connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, + SLOT(SetRxrZMQPort(int))); } void qTabAdvanced::GetRxrZMQIP() { - FILE_LOG(logDEBUG) << "Getting Receiver ZMQ IP"; - disconnect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); + FILE_LOG(logDEBUG) << "Getting Receiver ZMQ IP"; + disconnect(dispRxrZMQIP, SIGNAL(editingFinished()), this, + SLOT(SetRxrZMQIP())); - try { - auto retval = myDet->getReceiverStreamingIP(comboDetector->currentIndex()); - dispRxrZMQIP->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get receiver zmq ip.", e.what(), "qTabAdvanced::GetRxrZMQIP"); - } + try { + auto retval = + myDet->getReceiverStreamingIP(comboDetector->currentIndex()); + dispRxrZMQIP->setText(QString(retval.c_str())); + } CATCH_DISPLAY ("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP") - connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); + connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); } void qTabAdvanced::SetDetector(int index) { - FILE_LOG(logDEBUG) << "Set Detector: " << comboDetector->currentText().toAscii().data(); - - GetOnline(); - GetControlPort(); - GetStopPort(); - GetDetectorUDPIP(); - GetDetectorUDPMAC(); - GetCltZMQPort(); - GetCltZMQIP(); - GetRxrHostname(); - GetReceiverOnline(); - GetRxrTCPPort(); - GetRxrUDPPort(); - GetRxrUDPIP(); - GetRxrUDPMAC(); - GetRxrZMQPort(); - GetRxrZMQIP(); + FILE_LOG(logDEBUG) << "Set Detector: " + << comboDetector->currentText().toAscii().data(); - myDet->printReceiverConfiguration(logDEBUG); + GetOnline(); + GetControlPort(); + GetStopPort(); + GetDetectorUDPIP(); + GetDetectorUDPMAC(); + GetCltZMQPort(); + GetCltZMQIP(); + GetRxrHostname(); + GetReceiverOnline(); + GetRxrTCPPort(); + GetRxrUDPPort(); + GetRxrUDPIP(); + GetRxrUDPMAC(); + GetRxrZMQPort(); + GetRxrZMQIP(); + + myDet->printReceiverConfiguration(logDEBUG); } void qTabAdvanced::SetControlPort(int port) { - FILE_LOG(logINFO) << "Setting Control Port:" << port; + FILE_LOG(logINFO) << "Setting Control Port:" << port; try { myDet->setControlPort(port, comboDetector->currentIndex()); - } catch (const sls::RuntimeError &e) { - qDefs::ExceptionMessage("Could not set control port.", e.what(), "qTabAdvanced::SetControlPort"); - GetControlPort(); - } + } CATCH_HANDLE("Could not set control port.", "qTabAdvanced::SetControlPort", + this, &qTabAdvanced::GetControlPort) } void qTabAdvanced::SetStopPort(int port) { - FILE_LOG(logINFO) << "Setting Stop Port:" << port; + FILE_LOG(logINFO) << "Setting Stop Port:" << port; try { myDet->setStopPort(port, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set stop port.", e.what(), "qTabAdvanced::SetStopPort"); - GetStopPort(); - } + } CATCH_HANDLE ("Could not set stop port.", "qTabAdvanced::SetStopPort", this, + &qTabAdvanced::GetStopPort) } void qTabAdvanced::SetDetectorUDPIP() { - std::string s = dispDetectorUDPIP->text().toAscii().constData(); - FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s; - try { + std::string s = dispDetectorUDPIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s; + try { myDet->setDetectorIP(s, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Detector UDP IP.", e.what(), "qTabAdvanced::SetDetectorUDPIP"); - GetDetectorUDPIP(); - } + } CATCH_HANDLE ("Could not set Detector UDP IP.", + "qTabAdvanced::SetDetectorUDPIP", this, + &qTabAdvanced::GetDetectorUDPIP) } - void qTabAdvanced::SetDetectorUDPMAC() { - std::string s = dispDetectorUDPMAC->text().toAscii().constData(); - FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s; - try { + std::string s = dispDetectorUDPMAC->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s; + try { myDet->setDetectorMAC(s, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Detector UDP MAC.", e.what(), "qTabAdvanced::SetDetectorUDPMAC"); - GetDetectorUDPMAC(); - } + } CATCH_HANDLE ("Could not set Detector UDP MAC.", + "qTabAdvanced::SetDetectorUDPMAC", this, + &qTabAdvanced::GetDetectorUDPMAC) } void qTabAdvanced::SetCltZMQPort(int port) { - FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port; - try { - myDet->setClientDataStreamingInPort(port, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Client ZMQ port.", e.what(), "qTabAdvanced::SetCltZMQPort"); - GetCltZMQPort(); - } + FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port; + try { + myDet->setClientDataStreamingInPort(port, + comboDetector->currentIndex()); + } CATCH_HANDLE ("Could not set Client ZMQ port.", + "qTabAdvanced::SetCltZMQPort", this, + &qTabAdvanced::GetCltZMQPort) } void qTabAdvanced::SetCltZMQIP() { - std::string s = dispZMQIP->text().toAscii().constData(); - FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s; - try { + std::string s = dispZMQIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s; + try { myDet->setClientDataStreamingInIP(s, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Client ZMQ IP.", e.what(), "qTabAdvanced::SetCltZMQIP"); - GetCltZMQIP(); - } + } CATCH_HANDLE ("Could not set Client ZMQ IP.", + "qTabAdvanced::SetCltZMQIP", this, + &qTabAdvanced::GetCltZMQIP) } void qTabAdvanced::SetRxrHostname() { - std::string s = dispZMQIP->text().toAscii().constData(); - FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s; - try { + std::string s = dispZMQIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s; + try { myDet->setReceiverHostname(s, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Client ZMQ IP.", e.what(), "qTabAdvanced::SetRxrHostname"); - GetRxrHostname(); - } + } CATCH_HANDLE ("Could not set Client ZMQ IP.", + "qTabAdvanced::SetRxrHostname", this, + &qTabAdvanced::GetRxrHostname) - // update all network widgets (receiver mainly) - SetDetector(comboDetector->currentIndex()); + // update all network widgets (receiver mainly) + SetDetector(comboDetector->currentIndex()); } void qTabAdvanced::SetRxrTCPPort(int port) { - FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port; - try { + FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port; + try { myDet->setReceiverPort(port, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Receiver TCP port.", e.what(), "qTabAdvanced::SetRxrTCPPort"); - GetRxrTCPPort(); - } + } CATCH_HANDLE ("Could not set Receiver TCP port.", + "qTabAdvanced::SetRxrTCPPort", this, + &qTabAdvanced::GetRxrTCPPort) } - void qTabAdvanced::SetRxrUDPPort(int port) { - FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port; - try { + FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port; + try { myDet->setReceiverUDPPort(port, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Receiver UDP port.", e.what(), "qTabAdvanced::SetRxrUDPPort"); - GetRxrUDPPort(); - } + } CATCH_HANDLE ("Could not set Receiver UDP port.", + "qTabAdvanced::SetRxrUDPPort", this, + &qTabAdvanced::GetRxrUDPPort) } void qTabAdvanced::SetRxrUDPIP() { - std::string s = dispRxrUDPIP->text().toAscii().constData(); - FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s; - try { + std::string s = dispRxrUDPIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s; + try { myDet->setReceiverUDPIP(s, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Receiver UDP IP.", e.what(), "qTabAdvanced::SetRxrUDPIP"); - GetRxrUDPIP(); - } + } CATCH_HANDLE ("Could not set Receiver UDP IP.", + "qTabAdvanced::SetRxrUDPIP", this, + &qTabAdvanced::GetRxrUDPIP) } - void qTabAdvanced::SetRxrUDPMAC() { - std::string s = dispRxrUDPMAC->text().toAscii().constData(); - FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s; - try { + std::string s = dispRxrUDPMAC->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s; + try { myDet->setReceiverUDPMAC(s, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Receiver UDP MAC.", e.what(), "qTabAdvanced::SetRxrUDPMAC"); - GetRxrUDPMAC(); - } + } CATCH_HANDLE ("Could not set Receiver UDP MAC.", + "qTabAdvanced::SetRxrUDPMAC", this, + &qTabAdvanced::GetRxrUDPMAC) } -void qTabAdvanced::SetRxrZMQPort(int port){ - FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port; - try { - myDet->setReceiverDataStreamingOutPort(port, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Receiver ZMQ port.", e.what(), "qTabAdvanced::SetRxrZMQPort"); - GetRxrZMQPort(); - } +void qTabAdvanced::SetRxrZMQPort(int port) { + FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port; + try { + myDet->setReceiverDataStreamingOutPort(port, + comboDetector->currentIndex()); + } CATCH_HANDLE ("Could not set Receiver ZMQ port.", + "qTabAdvanced::SetRxrZMQPort", this, + &qTabAdvanced::GetRxrZMQPort) } -void qTabAdvanced::SetRxrZMQIP(){ - std::string s = dispRxrZMQIP->text().toAscii().constData(); - FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; - try { +void qTabAdvanced::SetRxrZMQIP() { + std::string s = dispRxrZMQIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; + try { myDet->setReceiverDataStreamingOutIP(s, comboDetector->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set Receiver ZMQ IP.", e.what(), "qTabAdvanced::SetRxrZMQIP"); - GetRxrZMQIP(); - } + } CATCH_HANDLE ("Could not set Receiver ZMQ IP.", + "qTabAdvanced::SetRxrZMQIP", this, + &qTabAdvanced::GetRxrZMQIP) } void qTabAdvanced::AddROISlot() { - FILE_LOG(logDEBUG) << "Add ROI Slot"; + FILE_LOG(logDEBUG) << "Add ROI Slot"; - QLabel* lFromX = new QLabel("x min:"); - QLabel* lFromY = new QLabel("y min:"); - QLabel* lToX = new QLabel("x max:"); - QLabel* lToY = new QLabel("y max:"); - QSpinBox* sFromX = new QSpinBox(); - QSpinBox* sFromY = new QSpinBox(); - QSpinBox* sToX = new QSpinBox(); - QSpinBox* sToY = new QSpinBox(); - lFromX->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lFromY->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lToX->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lToY->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - sFromX->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - sFromY->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - sToX->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - sToY->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - lFromX->setFixedWidth(50); - lFromY->setFixedWidth(50); - lToX->setFixedWidth(50); - lToY->setFixedWidth(50); - sFromX->setFixedWidth(80); - sFromY->setFixedWidth(80); - sToX->setFixedWidth(80); - sToY->setFixedWidth(80); - sFromX->setFixedHeight(19); - sFromY->setFixedHeight(19); - sToX->setFixedHeight(19); - sToY->setFixedHeight(19); - sFromX->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X) - 1); - sToX->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X) - 1); - sFromY->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y) - 1); - sToY->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y) - 1); - sFromX->setMinimum(-1); - sToX->setMinimum(-1); - sFromY->setMinimum(-1); - sToY->setMinimum(-1); - sFromX->setValue(-1); - sFromY->setValue(-1); - sToX->setValue(-1); - sToY->setValue(-1); + QLabel *lFromX = new QLabel("x min:"); + QLabel *lFromY = new QLabel("y min:"); + QLabel *lToX = new QLabel("x max:"); + QLabel *lToY = new QLabel("y max:"); + QSpinBox *sFromX = new QSpinBox(); + QSpinBox *sFromY = new QSpinBox(); + QSpinBox *sToX = new QSpinBox(); + QSpinBox *sToY = new QSpinBox(); + lFromX->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + lFromY->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + lToX->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + lToY->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + sFromX->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + sFromY->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + sToX->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + sToY->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + lFromX->setFixedWidth(50); + lFromY->setFixedWidth(50); + lToX->setFixedWidth(50); + lToY->setFixedWidth(50); + sFromX->setFixedWidth(80); + sFromY->setFixedWidth(80); + sToX->setFixedWidth(80); + sToY->setFixedWidth(80); + sFromX->setFixedHeight(19); + sFromY->setFixedHeight(19); + sToX->setFixedHeight(19); + sToY->setFixedHeight(19); + sFromX->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X) - 1); + sToX->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X) - 1); + sFromY->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y) - 1); + sToY->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y) - 1); + sFromX->setMinimum(-1); + sToX->setMinimum(-1); + sFromY->setMinimum(-1); + sToY->setMinimum(-1); + sFromX->setValue(-1); + sFromY->setValue(-1); + sToX->setValue(-1); + sToY->setValue(-1); - lblFromX.push_back(lFromX); - lblFromY.push_back(lFromY); - lblToX.push_back(lToX); - lblToY.push_back(lToY); - spinFromX.push_back(sFromX); - spinFromY.push_back(sFromY); - spinToX.push_back(sToX); - spinToY.push_back(sToY); + lblFromX.push_back(lFromX); + lblFromY.push_back(lFromY); + lblToX.push_back(lToX); + lblToY.push_back(lToY); + spinFromX.push_back(sFromX); + spinFromY.push_back(sFromY); + spinToX.push_back(sToX); + spinToY.push_back(sToY); - int nroi = (int)lblFromX.size(); - gridRoi->addWidget(lblFromX[nroi], nroi,0,Qt::AlignTop); - gridRoi->addWidget(spinFromX[nroi], nroi,1,Qt::AlignTop); - //FIXME: gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), nroi,2,Qt::AlignTop); - gridRoi->addWidget(lblToX[nroi], nroi,3,Qt::AlignTop); - gridRoi->addWidget(spinToX[nroi], nroi,4,Qt::AlignTop); - //FIXME: gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), nroi,5,Qt::AlignTop); - gridRoi->addWidget(lblFromY[nroi], nroi,6,Qt::AlignTop); - gridRoi->addWidget(spinFromY[nroi], nroi,7,Qt::AlignTop); - //FIXME: gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), nroi,8,Qt::AlignTop); - gridRoi->addWidget(lblToY[nroi], nroi,9,Qt::AlignTop); - gridRoi->addWidget(spinToY[nroi], nroi,10,Qt::AlignTop); + int nroi = (int)lblFromX.size(); + gridRoi->addWidget(lblFromX[nroi], nroi, 0, Qt::AlignTop); + gridRoi->addWidget(spinFromX[nroi], nroi, 1, Qt::AlignTop); + // FIXME: gridRoi->addItem(new + // QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), + // nroi,2,Qt::AlignTop); + gridRoi->addWidget(lblToX[nroi], nroi, 3, Qt::AlignTop); + gridRoi->addWidget(spinToX[nroi], nroi, 4, Qt::AlignTop); + // FIXME: gridRoi->addItem(new + // QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), + // nroi,5,Qt::AlignTop); + gridRoi->addWidget(lblFromY[nroi], nroi, 6, Qt::AlignTop); + gridRoi->addWidget(spinFromY[nroi], nroi, 7, Qt::AlignTop); + // FIXME: gridRoi->addItem(new + // QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), + // nroi,8,Qt::AlignTop); + gridRoi->addWidget(lblToY[nroi], nroi, 9, Qt::AlignTop); + gridRoi->addWidget(spinToY[nroi], nroi, 10, Qt::AlignTop); - lblFromX[nroi]->show(); - spinFromX[nroi]->show(); - lblToX[nroi]->show(); - spinToX[nroi]->show(); - lblFromY[nroi]->show(); - spinFromY[nroi]->show(); - lblToY[nroi]->show(); - spinToY[nroi]->show(); + lblFromX[nroi]->show(); + spinFromX[nroi]->show(); + lblToX[nroi]->show(); + spinToX[nroi]->show(); + lblFromY[nroi]->show(); + spinFromY[nroi]->show(); + lblToY[nroi]->show(); + spinToY[nroi]->show(); - FILE_LOG(logDEBUG) << "ROI Inputs added"; + FILE_LOG(logDEBUG) << "ROI Inputs added"; } -void qTabAdvanced::GetROI(){ - FILE_LOG(logDEBUG) << "Getting ROI"; - ClearROIWidgets(); +void qTabAdvanced::GetROI() { + FILE_LOG(logDEBUG) << "Getting ROI"; + ClearROIWidgets(); - try { - int nroi = 0; - const slsDetectorDefs::ROI* roi = myDet->getROI(nroi); - if (roi != nullptr) { - for (int i = 0; i < nroi; ++i) { - AddROISlot(); - spinFromX[i]->setValue(roi[i].xmin); - spinFromY[i]->setValue(roi[i].ymin); - spinToX[i]->setValue(roi[i].xmax); - spinToY[i]->setValue(roi[i].ymax); - } - FILE_LOG(logDEBUG) << "ROIs populated: " << nroi; - } - - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get ROI.", e.what(), "qTabAdvanced::GetROI"); - } + try { + int nroi = 0; + const slsDetectorDefs::ROI *roi = myDet->getROI(nroi); + if (roi != nullptr) { + for (int i = 0; i < nroi; ++i) { + AddROISlot(); + spinFromX[i]->setValue(roi[i].xmin); + spinFromY[i]->setValue(roi[i].ymin); + spinToX[i]->setValue(roi[i].xmax); + spinToY[i]->setValue(roi[i].ymax); + } + FILE_LOG(logDEBUG) << "ROIs populated: " << nroi; + } + + } CATCH_DISPLAY ("Could not get ROI.", "qTabAdvanced::GetROI") } void qTabAdvanced::ClearROIWidgets() { - FILE_LOG(logDEBUG) << "Clear ROI Widgets"; + FILE_LOG(logDEBUG) << "Clear ROI Widgets"; - // hide widgets - QLayoutItem *item; - while((item = gridRoi->takeAt(0))) { - if (item->widget()){ - item->widget()->hide(); - gridRoi->removeWidget(item->widget()); - } - } + // hide widgets + QLayoutItem *item; + while ((item = gridRoi->takeAt(0))) { + if (item->widget()) { + item->widget()->hide(); + gridRoi->removeWidget(item->widget()); + } + } - // delete widgets - for (size_t i = 0; i < lblFromX.size(); ++i) { - delete lblFromX[i]; - delete spinFromX[i]; - delete lblToX[i]; - delete spinToY[i]; - delete lblFromY[i]; - delete spinFromY[i]; - delete lblToY[i]; - delete spinToY[i]; - } - lblFromX.clear(); - spinFromX.clear(); - lblToX.clear(); - spinToY.clear(); - lblFromY.clear(); - spinFromY.clear(); - lblToY.clear(); - spinToY.clear(); + // delete widgets + for (size_t i = 0; i < lblFromX.size(); ++i) { + delete lblFromX[i]; + delete spinFromX[i]; + delete lblToX[i]; + delete spinToY[i]; + delete lblFromY[i]; + delete spinFromY[i]; + delete lblToY[i]; + delete spinToY[i]; + } + lblFromX.clear(); + spinFromX.clear(); + lblToX.clear(); + spinToY.clear(); + lblFromY.clear(); + spinFromY.clear(); + lblToY.clear(); + spinToY.clear(); } void qTabAdvanced::ClearROI() { - FILE_LOG(logINFO) << "Clearing ROI"; - if (QMessageBox::warning(this, "Clear ROI", - "Are you sure you want to clear all the ROI in detector?", - QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes){ + FILE_LOG(logINFO) << "Clearing ROI"; + if (QMessageBox::warning( + this, "Clear ROI", + "Are you sure you want to clear all the ROI in detector?", + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No) == QMessageBox::Yes) { - ClearROIWidgets(); - SetROI(); - FILE_LOG(logDEBUG) << "ROIs cleared"; - } + ClearROIWidgets(); + SetROI(); + FILE_LOG(logDEBUG) << "ROIs cleared"; + } } void qTabAdvanced::SetROI() { - // get roi from widgets - int nroi = (int)lblFromX.size(); - slsDetectorDefs::ROI roi[nroi]; - for (int i = 0; i < nroi; ++i){ - roi[i].xmin = spinFromX[i]->value(); - roi[i].ymin = spinFromY[i]->value(); - roi[i].xmax = spinToX[i]->value(); - roi[i].ymax = spinToY[i]->value(); - } - - // set roi - FILE_LOG(logINFO) << "Setting ROI:" << nroi; - try { - myDet->setROI(nroi, roi, -1); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set these ROIs.", e.what(), "qTabAdvanced::SetROI"); - } + // get roi from widgets + int nroi = (int)lblFromX.size(); + slsDetectorDefs::ROI roi[nroi]; + for (int i = 0; i < nroi; ++i) { + roi[i].xmin = spinFromX[i]->value(); + roi[i].ymin = spinFromY[i]->value(); + roi[i].xmax = spinToX[i]->value(); + roi[i].ymax = spinToY[i]->value(); + } - // update corrected list - GetROI(); + // set roi + FILE_LOG(logINFO) << "Setting ROI:" << nroi; + try { + myDet->setROI(nroi, roi, -1); + } CATCH_DISPLAY ("Could not set these ROIs.", + "qTabAdvanced::SetROI") + + // update corrected list + GetROI(); } void qTabAdvanced::GetAllTrimbits() { - FILE_LOG(logDEBUG) << "Getting all trimbits value"; - disconnect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); + FILE_LOG(logDEBUG) << "Getting all trimbits value"; + disconnect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, + SLOT(SetAllTrimbits())); - try { + try { int retval = myDet->setAllTrimbits(-1); - spinSetAllTrimbits->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get all trimbits.", e.what(), "qTabAdvanced::GetAllTrimbits"); - } + spinSetAllTrimbits->setValue(retval); + } CATCH_DISPLAY ("Could not get all trimbits.", "qTabAdvanced::GetAllTrimbits") - connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); + connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, + SLOT(SetAllTrimbits())); } void qTabAdvanced::SetAllTrimbits() { - int value = spinSetAllTrimbits->value(); - FILE_LOG(logINFO) << "Setting all trimbits:" << value; + int value = spinSetAllTrimbits->value(); + FILE_LOG(logINFO) << "Setting all trimbits:" << value; - try { + try { myDet->setAllTrimbits(value); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set all trimbits.", e.what(), "qTabAdvanced::SetAllTrimbits"); - GetAllTrimbits(); - } + } CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits", + this, &qTabAdvanced::GetAllTrimbits) } void qTabAdvanced::GetNumStoragecells() { - FILE_LOG(logDEBUG) << "Getting number of additional storage cells"; - disconnect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); + FILE_LOG(logDEBUG) << "Getting number of additional storage cells"; + disconnect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, + SLOT(SetNumStoragecells(int))); - try { + try { auto retval = myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER); - spinNumStoragecells->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get number of additional storage cells.", e.what(), "qTabAdvanced::GetNumStoragecells"); - } + spinNumStoragecells->setValue(retval); + } CATCH_DISPLAY ( + "Could not get number of additional storage cells.", + "qTabAdvanced::GetNumStoragecells") - connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); + connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, + SLOT(SetNumStoragecells(int))); } void qTabAdvanced::SetNumStoragecells(int value) { - FILE_LOG(logINFO) << "Setting number of additional stoarge cells: " << value; - try { + FILE_LOG(logINFO) << "Setting number of additional stoarge cells: " + << value; + try { myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, value, -1); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set number of additional storage cells.", e.what(), "qTabAdvanced::SetNumStoragecells"); - GetNumStoragecells(); - } + } CATCH_HANDLE ( + "Could not set number of additional storage cells.", + "qTabAdvanced::SetNumStoragecells", this, + &qTabAdvanced::GetNumStoragecells) } void qTabAdvanced::GetSubExposureTime() { - FILE_LOG(logDEBUG) << "Getting sub exposure time"; - disconnect(spinSubExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); + FILE_LOG(logDEBUG) << "Getting sub exposure time"; + disconnect(spinSubExpTime, SIGNAL(valueChanged(double)), this, + 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(time.second)); - } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get sub exposure time.", e.what(), "qTabSettings::GetSubExposureTime"); - } + 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(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, SLOT(SetSubExposureTime())); + connect(spinSubExpTime, SIGNAL(valueChanged(double)), this, + SLOT(SetSubExposureTime())); + connect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetSubExposureTime())); } void qTabAdvanced::SetSubExposureTime() { - double timeNS = qDefs::getNSTime((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(), spinSubExpTime->value()); - FILE_LOG(logINFO) << "Setting sub frame acquisition time to " << timeNS << " ns" << - "/" << spinSubExpTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()); - try { - myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME, (int64_t)timeNS, -1); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set sub exposure time.", e.what(), "qTabAdvanced::SetSubExposureTime"); - } + double timeNS = + qDefs::getNSTime((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(), + spinSubExpTime->value()); + FILE_LOG(logINFO) + << "Setting sub frame acquisition time to " << timeNS << " ns" + << "/" << spinSubExpTime->value() + << qDefs::getUnitString( + (qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()); + try { + myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME, + (int64_t)timeNS, -1); + } CATCH_DISPLAY ("Could not set sub exposure time.", + "qTabAdvanced::SetSubExposureTime") + GetSubExposureTime(); } void qTabAdvanced::GetSubDeadTime() { - FILE_LOG(logDEBUG) << "Getting sub dead time"; - disconnect(spinSubDeadTime, SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); - disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubDeadTime())); + FILE_LOG(logDEBUG) << "Getting sub dead time"; + disconnect(spinSubDeadTime, SIGNAL(valueChanged(double)), this, + 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(time.second)); - } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get sub dead time.", e.what(), "qTabSettings::GetSubDeadTime"); - } + 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(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, SLOT(SetSubDeadTime())); + connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this, + SLOT(SetSubDeadTime())); + connect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this, + SLOT(SetSubDeadTime())); } void qTabAdvanced::SetSubDeadTime() { - double timeNS = qDefs::getNSTime((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex(), spinSubDeadTime->value()); - FILE_LOG(logINFO) << "Setting sub frame dead time to " << timeNS << " ns" << - "/" << spinSubDeadTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex()); - try { - myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME, (int64_t)timeNS, -1); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set sub dead time.", e.what(), "qTabAdvanced::SetSubDeadTime"); - } + double timeNS = + qDefs::getNSTime((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex(), + spinSubDeadTime->value()); + FILE_LOG(logINFO) + << "Setting sub frame dead time to " << timeNS << " ns" + << "/" << spinSubDeadTime->value() + << qDefs::getUnitString( + (qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex()); + try { + myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME, (int64_t)timeNS, + -1); + } CATCH_DISPLAY ("Could not set sub dead time.", + "qTabAdvanced::SetSubDeadTime") + GetSubDeadTime(); } - -void qTabAdvanced::Refresh(){ - FILE_LOG(logDEBUG) << "**Updating Advanced Tab"; - - // trimming - if (tab_trimming->isEnabled()) { - GetAllTrimbits(); - } +void qTabAdvanced::Refresh() { + FILE_LOG(logDEBUG) << "**Updating Advanced Tab"; - // update all network widgets - SetDetector(comboDetector->currentIndex()); + // trimming + if (tab_trimming->isEnabled()) { + GetAllTrimbits(); + } - // roi - if (gridRoi->isEnabled()) { - GetROI(); - } + // update all network widgets + SetDetector(comboDetector->currentIndex()); - // storage cells - if (lblNumStoragecells->isEnabled()) { - GetNumStoragecells(); - } + // roi + if (gridRoi->isEnabled()) { + GetROI(); + } - // subexptime, subdeadtime - if (lblSubExpTime->isEnabled()) { - GetSubExposureTime(); - GetSubDeadTime(); - } + // storage cells + if (lblNumStoragecells->isEnabled()) { + GetNumStoragecells(); + } - FILE_LOG(logDEBUG) << "**Updated Advanced Tab"; + // subexptime, subdeadtime + if (lblSubExpTime->isEnabled()) { + GetSubExposureTime(); + GetSubDeadTime(); + } + + FILE_LOG(logDEBUG) << "**Updated Advanced Tab"; } diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index 995a90f00..5ac62f241 100755 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -89,6 +89,7 @@ void qTabDataOutput::PopulateDetectors() { void qTabDataOutput::EnableBrowse() { FILE_LOG(logDEBUG) << "Getting browse enable"; try { + btnOutputBrowse->setEnabled(false); // exception default std::string receiverHostname = myDet->getReceiverHostname(comboDetector->currentIndex() - 1); if (receiverHostname == "localhost") { btnOutputBrowse->setEnabled(true); @@ -106,15 +107,13 @@ void qTabDataOutput::EnableBrowse() { btnOutputBrowse->setEnabled(false); } } - } catch (const sls::RuntimeError &e) { - qDefs::ExceptionMessage("Could not get receiver hostname.", e.what(), "qTabDataOutput::EnableBrowse"); - btnOutputBrowse->setEnabled(false); - } + } CATCH_DISPLAY ("Could not get receiver hostname.", "qTabDataOutput::EnableBrowse") } void qTabDataOutput::GetFileWrite() { FILE_LOG(logDEBUG) << "Getting file write enable"; try { + boxFileWriteEnabled->setEnabled(true); // exception default int retval = myDet->getFileWrite(); if (retval == -1) { qDefs::Message(qDefs::WARNING, "File write is inconsistent for all detectors.", "qTabDataOutput::GetFileWrite"); @@ -122,10 +121,7 @@ void qTabDataOutput::GetFileWrite() { } else { boxFileWriteEnabled->setEnabled(retval == 0 ? false : true); } - } catch (const sls::RuntimeError &e) { - qDefs::ExceptionMessage("Could not get file enable.", e.what(), "qTabDataOutput::GetFileWrite"); - boxFileWriteEnabled->setEnabled(true); - } + } CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite") } void qTabDataOutput::GetFileName() { @@ -133,10 +129,7 @@ void qTabDataOutput::GetFileName() { try { auto retval = myDet->getFileName(); dispFileName->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get file name prefix.", e.what(), "qTabDataOutput::GetFileName"); - } - + } CATCH_DISPLAY ("Could not get file name prefix.", "qTabDataOutput::GetFileName") } void qTabDataOutput::GetOutputDir() { @@ -147,9 +140,7 @@ void qTabDataOutput::GetOutputDir() { try { std::string path = myDet->getFilePath(comboDetector->currentIndex() - 1); dispOutputDir->setText(QString(path.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get file path.", e.what(), "qTabDataOutput::GetOutputDir"); - } + } CATCH_DISPLAY ("Could not get file path.", "qTabDataOutput::GetOutputDir") connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); } @@ -180,10 +171,7 @@ void qTabDataOutput::SetOutputDir() { std::string spath = std::string(path.toAscii().constData()); try { myDet->setFilePath(spath, comboDetector->currentIndex() - 1); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set output file path.", e.what(), "qTabDataOutput::SetOutputDir"); - GetOutputDir(); - } + } CATCH_HANDLE ("Could not set output file path.", "qTabDataOutput::SetOutputDir", this, &qTabDataOutput::GetOutputDir) } } @@ -205,9 +193,7 @@ void qTabDataOutput::GetFileFormat() { qDefs::Message(qDefs::WARNING, std::string("Unknown file format: ") + std::to_string(static_cast(retval)), "qTabDataOutput::GetFileFormat"); break; } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get file format.", e.what(), "qTabDataOutput::GetFileFormat"); - } + } CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat") connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); } @@ -216,10 +202,7 @@ void qTabDataOutput::SetFileFormat(int format) { FILE_LOG(logINFO) << "Setting File Format to " << comboFileFormat->currentText().toAscii().data(); try { myDet->setFileFormat((slsDetectorDefs::fileFormat)comboFileFormat->currentIndex()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set file format.", e.what(), "qTabDataOutput::SetFileFormat"); - GetFileFormat(); - } + } CATCH_HANDLE ("Could not set file format.", "qTabDataOutput::SetFileFormat", this, &qTabDataOutput::GetFileFormat) } void qTabDataOutput::GetFileOverwrite() { @@ -233,9 +216,7 @@ void qTabDataOutput::GetFileOverwrite() { } else { chkOverwriteEnable->setChecked(retval == 0 ? false : true); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get file over write enable.", e.what(), "qTabDataOutput::GetFileOverwrite"); - } + } CATCH_DISPLAY ("Could not get file over write enable.", "qTabDataOutput::GetFileOverwrite") connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); } @@ -245,10 +226,7 @@ void qTabDataOutput::SetOverwriteEnable(bool enable) { try { myDet->setFileOverWrite(enable); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set file over write enable.", e.what(), "qTabDataOutput::SetOverwriteEnable"); - GetFileOverwrite(); - } + } CATCH_HANDLE ("Could not set file over write enable.", "qTabDataOutput::SetOverwriteEnable", this, &qTabDataOutput::GetFileOverwrite) } void qTabDataOutput::GetTenGigaEnable() { @@ -262,9 +240,7 @@ void qTabDataOutput::GetTenGigaEnable() { } else { chkTenGiga->setChecked(retval == 0 ? false : true); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get 10GbE enable.", e.what(), "qTabDataOutput::GetTenGigaEnable"); - } + } CATCH_DISPLAY ("Could not get 10GbE enable.", "qTabDataOutput::GetTenGigaEnable") connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool))); } @@ -274,10 +250,7 @@ void qTabDataOutput::SetTenGigaEnable(bool enable) { try { myDet->enableTenGigabitEthernet(enable); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set 10GbE enable.", e.what(), "qTabDataOutput::SetTenGigaEnable"); - GetTenGigaEnable(); - } + } CATCH_HANDLE ("Could not set 10GbE enable.", "qTabDataOutput::SetTenGigaEnable", this, &qTabDataOutput::GetTenGigaEnable) } void qTabDataOutput::GetRateCorrection() { @@ -296,9 +269,7 @@ void qTabDataOutput::GetRateCorrection() { if (retval != 0) spinCustomDeadTime->setValue(retval); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get rate correction.", e.what(), "qTabDataOutput::GetRateCorrection"); - } + } CATCH_DISPLAY("Could not get rate correction.", "qTabDataOutput::GetRateCorrection") connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection())); connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection())); @@ -315,10 +286,7 @@ void qTabDataOutput::EnableRateCorrection() { // disable try { myDet->setRateCorrection(0); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not switch off rate correction.", e.what(), "qTabDataOutput::EnableRateCorrection"); - GetRateCorrection(); - } + } CATCH_HANDLE ("Could not switch off rate correction.", "qTabDataOutput::EnableRateCorrection", this, &qTabDataOutput::GetRateCorrection) } void qTabDataOutput::SetRateCorrection() { @@ -335,10 +303,7 @@ void qTabDataOutput::SetRateCorrection() { try { myDet->setRateCorrection(deadtime); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set rate correction.", e.what(), "qTabDataOutput::SetRateCorrection"); - GetRateCorrection(); - } + } CATCH_HANDLE ("Could not set rate correction.", "qTabDataOutput::SetRateCorrection", this, &qTabDataOutput::GetRateCorrection) } void qTabDataOutput::GetSpeed() { @@ -360,9 +325,7 @@ void qTabDataOutput::GetSpeed() { qDefs::Message(qDefs::WARNING, std::string("Unknown speed: ") + std::to_string(retval), "qTabDataOutput::GetFileFormat"); break; } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get speed.", e.what(), "qTabDataOutput::GetSpeed"); - } + } CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed") connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); } @@ -371,10 +334,7 @@ void qTabDataOutput::SetSpeed(int speed) { FILE_LOG(logINFO) << "Setting Speed to " << comboEigerClkDivider->currentText().toAscii().data();; try { myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, speed); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set speed.", e.what(), "qTabDataOutput::SetSpeed"); - GetSpeed(); - } + } CATCH_HANDLE ("Could not set speed.", "qTabDataOutput::SetSpeed", this, &qTabDataOutput::GetSpeed) } void qTabDataOutput::GetFlags() { @@ -405,9 +365,7 @@ void qTabDataOutput::GetFlags() { qDefs::Message(qDefs::WARNING, std::string("Unknown flag (Not Parallel or Non Parallel): ") + std::to_string(retval), "qTabDataOutput::GetFlags"); } } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get speed.", e.what(), "qTabDataOutput::GetSpeed"); - } + } CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed") connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); @@ -443,10 +401,7 @@ void qTabDataOutput::SetFlags() { myDet->setReadOutFlags(flag1); FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerFlags2->currentText().toAscii().data(); myDet->setReadOutFlags(flag2); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set readout flags.", e.what(), "qTabDataOutput::SetFlags"); - GetFlags(); - } + } CATCH_HANDLE ("Could not set readout flags.", "qTabDataOutput::SetFlags", this, &qTabDataOutput::GetFlags) } diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index ba6d5ba8e..936efcba5 100755 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -66,9 +66,7 @@ void qTabDebugging::GetDetectorStatus() { try { std::string status = slsDetectorDefs::runStatusType(myDet->getRunStatus(comboDetector->currentIndex())); lblStatus->setText(QString(status.c_str()).toUpper()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get detector status.", e.what(), "qTabDebugging::GetDetectorStatus"); - } + } CATCH_DISPLAY ("Could not get detector status.", "qTabDebugging::GetDetectorStatus") } @@ -167,9 +165,7 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) { lblDetectorFirmware->setText(QString(retval.c_str())); retval = std::string("0x") + std::to_string((unsigned long)myDet->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, comboDetector->currentIndex())); lblDetectorSoftware->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get versions.", e.what(), "qTabDebugging::SetParameters"); - } + } CATCH_DISPLAY ("Could not get versions.", "qTabDebugging::SetParameters") } } @@ -210,9 +206,7 @@ void qTabDebugging::TestDetector() { //display message qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(), "qTabDebugging::TestDetector"); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not execute digital test.", e.what(), "qTabDebugging::TestDetector"); - } + } CATCH_DISPLAY ("Could not execute digital test.", "qTabDebugging::TestDetector") } diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index e5497f5ea..09075aa99 100755 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -28,12 +28,12 @@ qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) : } qTabDeveloper::~qTabDeveloper() { - for (int i = 0; i < lblDacs.size(); ++i) { + for (size_t i = 0; i < lblDacs.size(); ++i) { delete lblDacs[i]; delete lblDacsmV[i]; delete spinDacs[i]; } - for (int i = 0; i < lblAdcs.size(); ++i) { + for (size_t i = 0; i < lblAdcs.size(); ++i) { delete lblAdcs[i]; delete spinAdcs[i]; } @@ -288,9 +288,7 @@ void qTabDeveloper::GetDac(int id) { // 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"); - } + } CATCH_DISPLAY("Could not get dac.", "qTabDeveloper::GetDac") connect(spinDacs[id], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int))); } @@ -309,9 +307,8 @@ void qTabDeveloper::SetDac(int id) { try { myDet->setDAC(val, getSLSIndex(id), 0, comboDetector->currentIndex() - 1); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set dac.", e.what(), "qTabDeveloper::SetDac"); - } + } CATCH_DISPLAY ("Could not set dac.", "qTabDeveloper::SetDac") + // update mV anyway GetDac(id); } @@ -331,9 +328,7 @@ void qTabDeveloper::GetAdcs() { } spinAdcs[i]->setText(QString::number(retval, 'f', 2) + 0x00b0 + QString("C")); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get adcs.", e.what(), "qTabDeveloper::GetAdcs"); - } + } CATCH_DISPLAY ("Could not get adcs.", "qTabDeveloper::GetAdcs") } } @@ -390,10 +385,7 @@ void qTabDeveloper::GetHighVoltage() { } } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get high voltage.", e.what(), "qTabDeveloper::GetHighVoltage"); - - } + } CATCH_DISPLAY ("Could not get high voltage.", "qTabDeveloper::GetHighVoltage") if (comboHV == nullptr) { connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage())); @@ -408,10 +400,8 @@ void qTabDeveloper::SetHighVoltage() { try { myDet->setDAC(val, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set high voltage.", e.what(), "qTabDeveloper::SetHighVoltage"); - GetHighVoltage(); - } + } CATCH_HANDLE ("Could not set high voltage.", "qTabDeveloper::SetHighVoltage", + this, &qTabDeveloper::GetHighVoltage) } @@ -467,7 +457,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) { case 22: return slsDetectorDefs::TEMPERATURE_FPGA; default: - throw sls::NonCriticalError(std::string("Unknown dac/adc index") + std::to_string(index)); + throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); } break; case slsDetectorDefs::GOTTHARD: @@ -493,7 +483,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) { case 9: return slsDetectorDefs::TEMPERATURE_FPGA; default: - throw sls::NonCriticalError(std::string("Unknown dac/adc index") + std::to_string(index)); + throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); } break; @@ -504,7 +494,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) { if (index == numDACWidgets) { return slsDetectorDefs::TEMPERATURE_ADC; } else { - throw sls::NonCriticalError(std::string("Unknown dac/adc index") + std::to_string(index)); + throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); } break; @@ -512,7 +502,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) { if (index >= 0 && index < numDACWidgets) { return (slsDetectorDefs::dacIndex)index; } else { - throw sls::NonCriticalError(std::string("Unknown dac/adc index") + std::to_string(index)); + throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); } break; diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index a43ed6ae5..7b88dc7f1 100755 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -222,9 +222,7 @@ void qTabMeasurement::GetTimingMode() { qDefs::Message(qDefs::WARNING, std::string("Unknown timing mode: ")+ std::to_string(retval), "qTabMeasurement::GetTimingMode"); break; } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get timing mode.", e.what(), "qTabMeasurement::GetTimingMode"); - } + } CATCH_DISPLAY("Could not get timing mode.", "qTabMeasurement::GetTimingMode") disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); } @@ -235,10 +233,7 @@ void qTabMeasurement::SetTimingMode(int val) { try { myDet->setExternalCommunicationMode(static_cast(val)); EnableWidgetsforTimingMode(); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set timing mode.", e.what(), "qTabMeasurement::SetTimingMode"); - GetTimingMode(); - } + } CATCH_HANDLE("Could not set timing mode.", "qTabMeasurement::SetTimingMode", this, &qTabMeasurement::GetTimingMode) } void qTabMeasurement::GetNumMeasurements() { @@ -251,9 +246,7 @@ void qTabMeasurement::GetNumMeasurements() { qDefs::Message(qDefs::WARNING, "Number of measurements is inconsistent for all detectors.", "qTabMeasurement::GetNumMeasurements"); } spinNumMeasurements->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get number of measurements.", e.what(), "qTabMeasurement::GetNumMeasurements"); - } + } CATCH_DISPLAY ("Could not get number of measurements.", "qTabMeasurement::GetNumMeasurements") connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(SetNumMeasurements(int))); } @@ -263,10 +256,7 @@ void qTabMeasurement::SetNumMeasurements(int val) { try { myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER, val); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set number of measurements.", e.what(), "qTabMeasurement::SetNumMeasurements"); - GetNumMeasurements(); - } + } CATCH_HANDLE("Could not set number of measurements.", "qTabMeasurement::SetNumMeasurements", this, &qTabMeasurement::GetNumMeasurements) } void qTabMeasurement::GetNumFrames() { @@ -279,9 +269,7 @@ void qTabMeasurement::GetNumFrames() { qDefs::Message(qDefs::WARNING, "Number of frames is inconsistent for all detectors.", "qTabMeasurement::GetNumFrames"); } spinNumFrames->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get number of frames.", e.what(), "qTabMeasurement::GetNumFrames"); - } + } CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumFrames") connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int))); } @@ -291,10 +279,7 @@ void qTabMeasurement::SetNumFrames(int val) { try { myDet->setTimer(slsDetectorDefs::FRAME_NUMBER, val); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set number of frames.", e.what(), "qTabMeasurement::SetNumFrames"); - GetNumFrames(); - } + } CATCH_HANDLE("Could not set number of frames.", "qTabMeasurement::SetNumFrames", this, &qTabMeasurement::GetNumFrames) } void qTabMeasurement::GetNumTriggers() { @@ -307,9 +292,7 @@ void qTabMeasurement::GetNumTriggers() { qDefs::Message(qDefs::WARNING, "Number of triggers is inconsistent for all detectors.", "qTabMeasurement::GetNumTriggers"); } spinNumTriggers->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get number of frames.", e.what(), "qTabMeasurement::GetNumTriggers"); - } + } CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumTriggers") connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int))); } @@ -319,10 +302,7 @@ void qTabMeasurement::SetNumTriggers(int val) { try { myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER, val); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set number of triggers.", e.what(), "qTabMeasurement::SetNumTriggers"); - GetNumTriggers(); - } + } CATCH_HANDLE("Could not set number of triggers.", "qTabMeasurement::SetNumTriggers", this, &qTabMeasurement::GetNumTriggers) } void qTabMeasurement::GetNumSamples() { @@ -339,9 +319,7 @@ void qTabMeasurement::GetNumSamples() { qDefs::Message(qDefs::WARNING, "Number of digital samples is inconsistent for all detectors.", "qTabMeasurement::GetNumSamples"); } spinNumSamples->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get number of samples.", e.what(), "qTabMeasurement::GetNumSamples"); - } + } CATCH_DISPLAY ("Could not get number of samples.", "qTabMeasurement::GetNumSamples") connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); } @@ -352,10 +330,7 @@ void qTabMeasurement::SetNumSamples(int val) { try { myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES, val); myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES, val); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set number of samples.", e.what(), "qTabMeasurement::SetNumSamples"); - GetNumSamples(); - } + } CATCH_HANDLE("Could not set number of samples.", "qTabMeasurement::SetNumSamples", this, &qTabMeasurement::GetNumSamples) } void qTabMeasurement::GetExposureTime() { @@ -375,9 +350,7 @@ void qTabMeasurement::GetExposureTime() { CheckAcqPeriodGreaterThanExp(); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get exposure time.", e.what(), "qTabMeasurement::GetExposureTime"); - } + } CATCH_DISPLAY ("Could not get exposure time.", "qTabMeasurement::GetExposureTime") connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); @@ -392,10 +365,7 @@ void qTabMeasurement::SetExposureTime() { double timeNS = qDefs::getNSTime(unit, val); myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, std::lround(timeNS)); CheckAcqPeriodGreaterThanExp(); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set exposure time.", e.what(), "qTabMeasurement::SetExposureTime"); - GetExposureTime(); - } + } CATCH_HANDLE("Could not set exposure time.", "qTabMeasurement::SetExposureTime", this, &qTabMeasurement::GetExposureTime) } void qTabMeasurement::GetAcquisitionPeriod() { @@ -415,9 +385,7 @@ void qTabMeasurement::GetAcquisitionPeriod() { CheckAcqPeriodGreaterThanExp(); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get acquisition period.", e.what(), "qTabMeasurement::GetAcquisitionPeriod"); - } + } CATCH_DISPLAY ("Could not get acquisition period.", "qTabMeasurement::GetAcquisitionPeriod") connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod())); connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod())); @@ -432,10 +400,7 @@ void qTabMeasurement::SetAcquisitionPeriod() { double timeNS = qDefs::getNSTime(unit, val); myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, std::lround(timeNS)); CheckAcqPeriodGreaterThanExp(); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set acquisition period.", e.what(), "qTabMeasurement::SetAcquisitionPeriod"); - GetAcquisitionPeriod(); - } + } CATCH_HANDLE("Could not set acquisition period.", "qTabMeasurement::SetAcquisitionPeriod", this, &qTabMeasurement::GetAcquisitionPeriod) } void qTabMeasurement::CheckAcqPeriodGreaterThanExp() { @@ -478,9 +443,7 @@ void qTabMeasurement::GetDelay() { CheckAcqPeriodGreaterThanExp(); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get delay.", e.what(), "qTabMeasurement::GetDelay"); - } + } CATCH_DISPLAY ("Could not get delay.", "qTabMeasurement::GetDelay") connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay())); connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay())); @@ -495,10 +458,7 @@ void qTabMeasurement::SetDelay() { double timeNS = qDefs::getNSTime(unit, val); myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER, std::lround(timeNS)); CheckAcqPeriodGreaterThanExp(); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set delay.", e.what(), "qTabMeasurement::SetDelay"); - GetDelay(); - } + } CATCH_HANDLE("Could not set delay.", "qTabMeasurement::SetDelay", this, &qTabMeasurement::GetDelay) } void qTabMeasurement::GetFileWrite() { @@ -506,7 +466,8 @@ void qTabMeasurement::GetFileWrite() { disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); try { - int retval = myDet->getFileWrite(); + dispFileName->setEnabled(true); // default, even when exception + int retval = myDet->getFileWrite(); if (retval == -1) { qDefs::Message(qDefs::WARNING, "File write is inconsistent for all detectors.", "qTabMeasurement::GetFileWrite"); dispFileName->setEnabled(true); @@ -514,10 +475,7 @@ void qTabMeasurement::GetFileWrite() { chkFile->setChecked(retval == 0 ? false : true); dispFileName->setEnabled(chkFile->isChecked()); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get file over write enable.", e.what(), "qTabMeasurement::GetFileWrite"); - dispFileName->setEnabled(true); - } + } CATCH_DISPLAY ("Could not get file over write enable.", "qTabMeasurement::GetFileWrite") connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); } @@ -528,10 +486,7 @@ void qTabMeasurement::SetFileWrite(bool val) { try { myDet->setFileWrite(val); dispFileName->setEnabled(chkFile->isChecked()); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set file write enable.", e.what(), "qTabMeasurement::SetFileWrite"); - GetFileWrite(); - } + } CATCH_HANDLE("Could not set file write enable.", "qTabMeasurement::SetFileWrite", this, &qTabMeasurement::GetFileWrite) } void qTabMeasurement::GetFileName() { @@ -541,9 +496,7 @@ void qTabMeasurement::GetFileName() { try { auto retval = myDet->getFileName(); dispFileName->setText(QString(retval.c_str())); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get file name prefix.", e.what(), "qTabMeasurement::GetFileName"); - } + } CATCH_DISPLAY ("Could not get file name prefix.", "qTabMeasurement::GetFileName") connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName())); } @@ -553,10 +506,7 @@ void qTabMeasurement::SetFileName() { FILE_LOG(logINFO) << "Setting File Name Prefix:" << val; try { myDet->setFileName(val); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set file name prefix.", e.what(), "qTabMeasurement::SetFileName"); - GetFileName(); - } + } CATCH_HANDLE("Could not set file name prefix.", "qTabMeasurement::SetFileName", this, &qTabMeasurement::GetFileName) } void qTabMeasurement::GetRunIndex() { @@ -569,9 +519,7 @@ void qTabMeasurement::GetRunIndex() { qDefs::Message(qDefs::WARNING, "Acquisition File Index is inconsistent for all detectors.", "qTabMeasurement::GetRunIndex"); } spinIndex->setValue(retval); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get acquisition file index.", e.what(), "qTabMeasurement::GetRunIndex"); - } + } CATCH_DISPLAY ("Could not get acquisition file index.", "qTabMeasurement::GetRunIndex") connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int))); } @@ -581,10 +529,7 @@ void qTabMeasurement::SetRunIndex(int val) { try { myDet->setFileIndex(val); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set acquisition file index.", e.what(), "qTabMeasurement::SetRunIndex"); - GetRunIndex(); - } + } CATCH_HANDLE("Could not set acquisition file index.", "qTabMeasurement::SetRunIndex", this, &qTabMeasurement::GetRunIndex) } void qTabMeasurement::SetCurrentMeasurement(int val) { @@ -621,11 +566,10 @@ int qTabMeasurement::VerifyOutputDirectoryError() { myDet->setFilePath(paths[det], det); } } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set path.", e.what(), "qTabMeasurement::VerifyOutputDirectoryError"); - return slsDetectorDefs::FAIL; - } - return slsDetectorDefs::OK; + return slsDetectorDefs::OK; + } CATCH_DISPLAY ("Could not set path.", "qTabMeasurement::VerifyOutputDirectoryError") + + return slsDetectorDefs::FAIL; // for exception } void qTabMeasurement::StartAcquisition() { @@ -660,9 +604,7 @@ void qTabMeasurement::StopAcquisition() { FILE_LOG(logINFORED) << "Stopping Acquisition"; try{ myDet->stopAcquisition(); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not stop acquisition.", e.what(), "qTabMeasurement::StopAcquisition"); - } + } CATCH_DISPLAY("Could not stop acquisition.", "qTabMeasurement::StopAcquisition") } void qTabMeasurement::UpdateFinished() { diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index eca334f25..a858ca773 100755 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -331,9 +331,7 @@ void qTabPlot::GetGapPixels() { } else { chkGapPixels->setChecked(retval == 0 ? false : true); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get gap pixels enable.", e.what(), "qTabPlot::GetGapPixels"); - } + } CATCH_DISPLAY ("Could not get gap pixels enable.", "qTabPlot::GetGapPixels") connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); } @@ -343,10 +341,7 @@ void qTabPlot::SetGapPixels(bool enable) { try { myDet->enableGapPixels(enable); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set gap pixels enable.", e.what(), "qTabPlot::SetGapPixels"); - GetGapPixels(); - } + } CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels", this, &qTabPlot::GetGapPixels) } void qTabPlot::SetTitles() { @@ -643,9 +638,7 @@ void qTabPlot::GetStreamingFrequency() { spinTimeGap->setValue(time.first); comboTimeGapUnit->setCurrentIndex(static_cast(time.second)); } - } catch(const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get streaming timer.", e.what(), "qTabPlot::GetStreamingFrequency"); - } + } CATCH_DISPLAY ("Could not get streaming timer.", "qTabPlot::GetStreamingFrequency") } // every nth frame else { @@ -653,9 +646,7 @@ void qTabPlot::GetStreamingFrequency() { stackedLayout->setCurrentIndex(1); spinNthFrame->setValue(freq); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get streaming frequency.", e.what(), "qTabPlot::GetStreamingFrequency"); - } + } CATCH_DISPLAY ("Could not get streaming frequency.", "qTabPlot::GetStreamingFrequency") connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); @@ -679,10 +670,7 @@ void qTabPlot::SetStreamingFrequency() { double timeMS = qDefs::getMSTime(timeUnit, timeVal); myDet->setReceiverStreamingTimer(timeMS); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set streaming frequency/ timer.", e.what(), "qTabPlot::SetStreamingFrequency"); - GetStreamingFrequency(); - } + } CATCH_HANDLE("Could not set streaming frequency/ timer.", "qTabPlot::SetStreamingFrequency", this, &qTabPlot::GetStreamingFrequency) } void qTabPlot::Refresh() { diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 26a73a902..8664c29ad 100755 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -127,9 +127,7 @@ void qTabSettings::GetSettings() { } break; } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get settings.", e.what(), "qTabSettings::GetSettings"); - } + } CATCH_DISPLAY ("Could not get settings.", "qTabSettings::GetSettings") connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); } @@ -141,10 +139,7 @@ void qTabSettings::SetSettings(int index) { try { myDet->setSettings(val); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set settings.", e.what(), "qTabSettings::SetSettings"); - GetSettings(); - } + } CATCH_HANDLE ("Could not set settings.", "qTabSettings::SetSettings", this, &qTabSettings::GetSettings) // threshold if (spinThreshold->isEnabled()) { @@ -180,9 +175,7 @@ void qTabSettings::GetDynamicRange() { qDefs::Message(qDefs::WARNING, std::string("Unknown dynamic range: ") + std::to_string(retval), "qTabSettings::GetDynamicRange"); break; } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get dynamic range.", e.what(), "qTabSettings::GetDynamicRange"); - } + } CATCH_DISPLAY ("Could not get dynamic range.", "qTabSettings::GetDynamicRange") connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int))); } @@ -207,10 +200,7 @@ void qTabSettings::SetDynamicRange(int index) { qDefs::Message(qDefs::WARNING, std::string("Unknown dynamic range: ") + std::to_string(index), "qTabSettings::SetDynamicRange"); break; } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not set dynamic range.", e.what(), "qTabSettings::SetDynamicRange"); - GetDynamicRange(); - } + } CATCH_HANDLE ("Could not set dynamic range.", "qTabSettings::SetDynamicRange", this, &qTabSettings::GetDynamicRange) } void qTabSettings::GetThresholdEnergy() { @@ -225,9 +215,7 @@ void qTabSettings::GetThresholdEnergy() { } else { spinThreshold->setValue(retval); } - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get threshold energy.", e.what(), "qTabDataOutput::GetThresholdEnergy"); - } + } CATCH_DISPLAY ("Could not get threshold energy.", "qTabDataOutput::GetThresholdEnergy") connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy())); } @@ -236,9 +224,8 @@ void qTabSettings::SetThresholdEnergy(int index) { FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV"; try { myDet->setThresholdEnergy(index); - } catch (const sls::NonCriticalError &e) { - qDefs::ExceptionMessage("Could not get threshold energy.", e.what(), "qTabSettings::SetThresholdEnergy"); - } + } CATCH_DISPLAY ("Could not get threshold energy.", "qTabSettings::SetThresholdEnergy") + // set the right value anyway (due to tolerance) GetThresholdEnergy(); }