WIP. catching exceptions using macros to ignore socket and shm error

This commit is contained in:
maliakal_d 2019-06-25 17:27:30 +02:00
parent bd3e439d87
commit 61b937e2e0
11 changed files with 789 additions and 872 deletions

View File

@ -30,7 +30,7 @@ void qClient::executeLine(int narg, char *args[]) {
// validate command structure // validate command structure
if (narg < 1) { if (narg < 1) {
throw sls::NonCriticalError("No command parsed. " + printCommands()); throw sls::RuntimeError("No command parsed. " + printCommands());
} }
// help // help
@ -49,7 +49,7 @@ void qClient::executeLine(int narg, char *args[]) {
else if (argument == "stop") else if (argument == "stop")
stopAcquisition(); stopAcquisition();
else { else {
throw sls::NonCriticalError("Could not parse arguments. " + printCommands()); throw sls::RuntimeError("Could not parse arguments. " + printCommands());
} }
} }
retval = getStatus(); retval = getStatus();
@ -67,7 +67,7 @@ void qClient::executeLine(int narg, char *args[]) {
// unrecognized command // unrecognized command
else { else {
throw sls::NonCriticalError("Unrecognized command. " + printCommands()); throw sls::RuntimeError("Unrecognized command. " + printCommands());
} }
// print result // print result

View File

@ -11,6 +11,9 @@
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
#define CATCH_DISPLAY(m, s) catch(...) { qDefs::DisplayExceptions(m, s); }
#define CATCH_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); }
class qDefs : public QWidget { class qDefs : public QWidget {
public: public:
/** /**
@ -18,7 +21,36 @@ class qDefs : public QWidget {
*/ */
qDefs(){}; 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 <class CT> struct NonDeduced { using type = CT; };
template <class S, typename RT, typename... CT>
static void HandleExceptions(const std::string emsg, const std::string src, S* s,
RT (S::*somefunc)(CT...),
typename NonDeduced<CT>::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 */ /** function enums */
enum qFuncNames { enum qFuncNames {

View File

@ -349,9 +349,7 @@ void qDetectorMain::LoadConfigFile(const std::string fName) {
} else { } else {
try { try {
myDet->readConfigurationFile(fName); myDet->readConfigurationFile(fName);
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not load config file.", "qDetectorMain::LoadConfigFile")
qDefs::ExceptionMessage("Could not load config file.", e.what(), "qDetectorMain::LoadConfigFile");
}
} }
} }
@ -562,9 +560,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
} }
} }
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not execute utilities.", "qDetectorMain::ExecuteUtilities")
qDefs::ExceptionMessage("Could not execute utilities.", e.what(), "qDetectorMain::ExecuteUtilities");
}
Refresh(tabs->currentIndex()); Refresh(tabs->currentIndex());
if (refreshTabs) { if (refreshTabs) {
@ -587,13 +583,10 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
"and Moench detectors"; "and Moench detectors";
std::string guiVersion = std::to_string(APIGUI); std::string guiVersion = std::to_string(APIGUI);
std::string clientVersion; std::string clientVersion = "unknown";
try { try {
clientVersion = std::to_string(myDet->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION)); clientVersion = std::to_string(myDet->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION));
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get client version.", "qDetectorMain::ExecuteHelp")
qDefs::ExceptionMessage("Could not get client version.", e.what(), "qDetectorMain::ExecuteHelp");
clientVersion = "unknown";
}
qDefs::Message(qDefs::INFORMATION, qDefs::Message(qDefs::INFORMATION,
"<p style=\"font-family:verdana;\">" "<p style=\"font-family:verdana;\">"

View File

@ -90,7 +90,7 @@ void qServer::ServerThread(bool isControlServer) {
auto socket = (isControlServer ? controlSocket->accept() : stopSocket->accept()); auto socket = (isControlServer ? controlSocket->accept() : stopSocket->accept());
try{ try{
DecodeFunction(socket); DecodeFunction(socket);
} catch(const sls::NonCriticalError &e) { } catch(const sls::RuntimeError &e) {
if (strstr(e.what(), "exit")) { if (strstr(e.what(), "exit")) {
FILE_LOG(logINFO) << "Exiting " << (isControlServer ? "Control" : "Stop") << "Server"; FILE_LOG(logINFO) << "Exiting " << (isControlServer ? "Control" : "Stop") << "Server";
@ -101,7 +101,7 @@ void qServer::ServerThread(bool isControlServer) {
socket.Send(qDefs::FAIL); socket.Send(qDefs::FAIL);
socket.Send(mess); socket.Send(mess);
} }
} catch (const sls::NonCriticalError &e) { } catch (const sls::RuntimeError &e) {
FILE_LOG(logERROR) << "Accept failed"; FILE_LOG(logERROR) << "Accept failed";
} }
@ -130,21 +130,21 @@ void qServer::GetStatus(sls::ServerInterface2 &socket) {
void qServer::StartAcquisition(sls::ServerInterface2 &socket) { void qServer::StartAcquisition(sls::ServerInterface2 &socket) {
if (mainTab->StartStopAcquisitionFromClient(true) == slsDetectorDefs::FAIL) { 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); socket.Send(slsDetectorDefs::OK);
} }
void qServer::StopsAcquisition(sls::ServerInterface2 &socket) { void qServer::StopsAcquisition(sls::ServerInterface2 &socket) {
if (mainTab->StartStopAcquisitionFromClient(false) == slsDetectorDefs::FAIL) { 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); socket.Send(slsDetectorDefs::OK);
} }
void qServer::Acquire(sls::ServerInterface2 &socket) { void qServer::Acquire(sls::ServerInterface2 &socket) {
if (mainTab->StartStopAcquisitionFromClient(true) == slsDetectorDefs::FAIL) { 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 // blocking
usleep(5000); usleep(5000);
@ -155,5 +155,5 @@ void qServer::Acquire(sls::ServerInterface2 &socket) {
} }
void qServer::ExitServer(sls::ServerInterface2 &socket) { void qServer::ExitServer(sls::ServerInterface2 &socket) {
throw sls::NonCriticalError("Server exited"); throw sls::RuntimeError("Server exited");
} }

File diff suppressed because it is too large Load Diff

View File

@ -89,6 +89,7 @@ void qTabDataOutput::PopulateDetectors() {
void qTabDataOutput::EnableBrowse() { void qTabDataOutput::EnableBrowse() {
FILE_LOG(logDEBUG) << "Getting browse enable"; FILE_LOG(logDEBUG) << "Getting browse enable";
try { try {
btnOutputBrowse->setEnabled(false); // exception default
std::string receiverHostname = myDet->getReceiverHostname(comboDetector->currentIndex() - 1); std::string receiverHostname = myDet->getReceiverHostname(comboDetector->currentIndex() - 1);
if (receiverHostname == "localhost") { if (receiverHostname == "localhost") {
btnOutputBrowse->setEnabled(true); btnOutputBrowse->setEnabled(true);
@ -106,15 +107,13 @@ void qTabDataOutput::EnableBrowse() {
btnOutputBrowse->setEnabled(false); btnOutputBrowse->setEnabled(false);
} }
} }
} catch (const sls::RuntimeError &e) { } CATCH_DISPLAY ("Could not get receiver hostname.", "qTabDataOutput::EnableBrowse")
qDefs::ExceptionMessage("Could not get receiver hostname.", e.what(), "qTabDataOutput::EnableBrowse");
btnOutputBrowse->setEnabled(false);
}
} }
void qTabDataOutput::GetFileWrite() { void qTabDataOutput::GetFileWrite() {
FILE_LOG(logDEBUG) << "Getting file write enable"; FILE_LOG(logDEBUG) << "Getting file write enable";
try { try {
boxFileWriteEnabled->setEnabled(true); // exception default
int retval = myDet->getFileWrite(); int retval = myDet->getFileWrite();
if (retval == -1) { if (retval == -1) {
qDefs::Message(qDefs::WARNING, "File write is inconsistent for all detectors.", "qTabDataOutput::GetFileWrite"); qDefs::Message(qDefs::WARNING, "File write is inconsistent for all detectors.", "qTabDataOutput::GetFileWrite");
@ -122,10 +121,7 @@ void qTabDataOutput::GetFileWrite() {
} else { } else {
boxFileWriteEnabled->setEnabled(retval == 0 ? false : true); boxFileWriteEnabled->setEnabled(retval == 0 ? false : true);
} }
} catch (const sls::RuntimeError &e) { } CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite")
qDefs::ExceptionMessage("Could not get file enable.", e.what(), "qTabDataOutput::GetFileWrite");
boxFileWriteEnabled->setEnabled(true);
}
} }
void qTabDataOutput::GetFileName() { void qTabDataOutput::GetFileName() {
@ -133,10 +129,7 @@ void qTabDataOutput::GetFileName() {
try { try {
auto retval = myDet->getFileName(); auto retval = myDet->getFileName();
dispFileName->setText(QString(retval.c_str())); dispFileName->setText(QString(retval.c_str()));
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get file name prefix.", "qTabDataOutput::GetFileName")
qDefs::ExceptionMessage("Could not get file name prefix.", e.what(), "qTabDataOutput::GetFileName");
}
} }
void qTabDataOutput::GetOutputDir() { void qTabDataOutput::GetOutputDir() {
@ -147,9 +140,7 @@ void qTabDataOutput::GetOutputDir() {
try { try {
std::string path = myDet->getFilePath(comboDetector->currentIndex() - 1); std::string path = myDet->getFilePath(comboDetector->currentIndex() - 1);
dispOutputDir->setText(QString(path.c_str())); dispOutputDir->setText(QString(path.c_str()));
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get file path.", "qTabDataOutput::GetOutputDir")
qDefs::ExceptionMessage("Could not get file path.", e.what(), "qTabDataOutput::GetOutputDir");
}
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
} }
@ -180,10 +171,7 @@ void qTabDataOutput::SetOutputDir() {
std::string spath = std::string(path.toAscii().constData()); std::string spath = std::string(path.toAscii().constData());
try { try {
myDet->setFilePath(spath, comboDetector->currentIndex() - 1); myDet->setFilePath(spath, comboDetector->currentIndex() - 1);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set output file path.", "qTabDataOutput::SetOutputDir", this, &qTabDataOutput::GetOutputDir)
qDefs::ExceptionMessage("Could not set output file path.", e.what(), "qTabDataOutput::SetOutputDir");
GetOutputDir();
}
} }
} }
@ -205,9 +193,7 @@ void qTabDataOutput::GetFileFormat() {
qDefs::Message(qDefs::WARNING, std::string("Unknown file format: ") + std::to_string(static_cast<int>(retval)), "qTabDataOutput::GetFileFormat"); qDefs::Message(qDefs::WARNING, std::string("Unknown file format: ") + std::to_string(static_cast<int>(retval)), "qTabDataOutput::GetFileFormat");
break; break;
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat")
qDefs::ExceptionMessage("Could not get file format.", e.what(), "qTabDataOutput::GetFileFormat");
}
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); 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(); FILE_LOG(logINFO) << "Setting File Format to " << comboFileFormat->currentText().toAscii().data();
try { try {
myDet->setFileFormat((slsDetectorDefs::fileFormat)comboFileFormat->currentIndex()); myDet->setFileFormat((slsDetectorDefs::fileFormat)comboFileFormat->currentIndex());
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set file format.", "qTabDataOutput::SetFileFormat", this, &qTabDataOutput::GetFileFormat)
qDefs::ExceptionMessage("Could not set file format.", e.what(), "qTabDataOutput::SetFileFormat");
GetFileFormat();
}
} }
void qTabDataOutput::GetFileOverwrite() { void qTabDataOutput::GetFileOverwrite() {
@ -233,9 +216,7 @@ void qTabDataOutput::GetFileOverwrite() {
} else { } else {
chkOverwriteEnable->setChecked(retval == 0 ? false : true); chkOverwriteEnable->setChecked(retval == 0 ? false : true);
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get file over write enable.", "qTabDataOutput::GetFileOverwrite")
qDefs::ExceptionMessage("Could not get file over write enable.", e.what(), "qTabDataOutput::GetFileOverwrite");
}
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool)));
} }
@ -245,10 +226,7 @@ void qTabDataOutput::SetOverwriteEnable(bool enable) {
try { try {
myDet->setFileOverWrite(enable); myDet->setFileOverWrite(enable);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set file over write enable.", "qTabDataOutput::SetOverwriteEnable", this, &qTabDataOutput::GetFileOverwrite)
qDefs::ExceptionMessage("Could not set file over write enable.", e.what(), "qTabDataOutput::SetOverwriteEnable");
GetFileOverwrite();
}
} }
void qTabDataOutput::GetTenGigaEnable() { void qTabDataOutput::GetTenGigaEnable() {
@ -262,9 +240,7 @@ void qTabDataOutput::GetTenGigaEnable() {
} else { } else {
chkTenGiga->setChecked(retval == 0 ? false : true); chkTenGiga->setChecked(retval == 0 ? false : true);
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get 10GbE enable.", "qTabDataOutput::GetTenGigaEnable")
qDefs::ExceptionMessage("Could not get 10GbE enable.", e.what(), "qTabDataOutput::GetTenGigaEnable");
}
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool))); connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
} }
@ -274,10 +250,7 @@ void qTabDataOutput::SetTenGigaEnable(bool enable) {
try { try {
myDet->enableTenGigabitEthernet(enable); myDet->enableTenGigabitEthernet(enable);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set 10GbE enable.", "qTabDataOutput::SetTenGigaEnable", this, &qTabDataOutput::GetTenGigaEnable)
qDefs::ExceptionMessage("Could not set 10GbE enable.", e.what(), "qTabDataOutput::SetTenGigaEnable");
GetTenGigaEnable();
}
} }
void qTabDataOutput::GetRateCorrection() { void qTabDataOutput::GetRateCorrection() {
@ -296,9 +269,7 @@ void qTabDataOutput::GetRateCorrection() {
if (retval != 0) if (retval != 0)
spinCustomDeadTime->setValue(retval); spinCustomDeadTime->setValue(retval);
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY("Could not get rate correction.", "qTabDataOutput::GetRateCorrection")
qDefs::ExceptionMessage("Could not get rate correction.", e.what(), "qTabDataOutput::GetRateCorrection");
}
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection())); connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection())); connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
@ -315,10 +286,7 @@ void qTabDataOutput::EnableRateCorrection() {
// disable // disable
try { try {
myDet->setRateCorrection(0); myDet->setRateCorrection(0);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not switch off rate correction.", "qTabDataOutput::EnableRateCorrection", this, &qTabDataOutput::GetRateCorrection)
qDefs::ExceptionMessage("Could not switch off rate correction.", e.what(), "qTabDataOutput::EnableRateCorrection");
GetRateCorrection();
}
} }
void qTabDataOutput::SetRateCorrection() { void qTabDataOutput::SetRateCorrection() {
@ -335,10 +303,7 @@ void qTabDataOutput::SetRateCorrection() {
try { try {
myDet->setRateCorrection(deadtime); myDet->setRateCorrection(deadtime);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set rate correction.", "qTabDataOutput::SetRateCorrection", this, &qTabDataOutput::GetRateCorrection)
qDefs::ExceptionMessage("Could not set rate correction.", e.what(), "qTabDataOutput::SetRateCorrection");
GetRateCorrection();
}
} }
void qTabDataOutput::GetSpeed() { void qTabDataOutput::GetSpeed() {
@ -360,9 +325,7 @@ void qTabDataOutput::GetSpeed() {
qDefs::Message(qDefs::WARNING, std::string("Unknown speed: ") + std::to_string(retval), "qTabDataOutput::GetFileFormat"); qDefs::Message(qDefs::WARNING, std::string("Unknown speed: ") + std::to_string(retval), "qTabDataOutput::GetFileFormat");
break; break;
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed")
qDefs::ExceptionMessage("Could not get speed.", e.what(), "qTabDataOutput::GetSpeed");
}
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed())); 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();; FILE_LOG(logINFO) << "Setting Speed to " << comboEigerClkDivider->currentText().toAscii().data();;
try { try {
myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, speed); myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, speed);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set speed.", "qTabDataOutput::SetSpeed", this, &qTabDataOutput::GetSpeed)
qDefs::ExceptionMessage("Could not set speed.", e.what(), "qTabDataOutput::SetSpeed");
GetSpeed();
}
} }
void qTabDataOutput::GetFlags() { 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"); qDefs::Message(qDefs::WARNING, std::string("Unknown flag (Not Parallel or Non Parallel): ") + std::to_string(retval), "qTabDataOutput::GetFlags");
} }
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed")
qDefs::ExceptionMessage("Could not get speed.", e.what(), "qTabDataOutput::GetSpeed");
}
connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
@ -443,10 +401,7 @@ void qTabDataOutput::SetFlags() {
myDet->setReadOutFlags(flag1); myDet->setReadOutFlags(flag1);
FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerFlags2->currentText().toAscii().data(); FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerFlags2->currentText().toAscii().data();
myDet->setReadOutFlags(flag2); myDet->setReadOutFlags(flag2);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set readout flags.", "qTabDataOutput::SetFlags", this, &qTabDataOutput::GetFlags)
qDefs::ExceptionMessage("Could not set readout flags.", e.what(), "qTabDataOutput::SetFlags");
GetFlags();
}
} }

View File

@ -66,9 +66,7 @@ void qTabDebugging::GetDetectorStatus() {
try { try {
std::string status = slsDetectorDefs::runStatusType(myDet->getRunStatus(comboDetector->currentIndex())); std::string status = slsDetectorDefs::runStatusType(myDet->getRunStatus(comboDetector->currentIndex()));
lblStatus->setText(QString(status.c_str()).toUpper()); lblStatus->setText(QString(status.c_str()).toUpper());
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get detector status.", "qTabDebugging::GetDetectorStatus")
qDefs::ExceptionMessage("Could not get detector status.", e.what(), "qTabDebugging::GetDetectorStatus");
}
} }
@ -167,9 +165,7 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
lblDetectorFirmware->setText(QString(retval.c_str())); lblDetectorFirmware->setText(QString(retval.c_str()));
retval = std::string("0x") + std::to_string((unsigned long)myDet->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, comboDetector->currentIndex())); retval = std::string("0x") + std::to_string((unsigned long)myDet->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, comboDetector->currentIndex()));
lblDetectorSoftware->setText(QString(retval.c_str())); lblDetectorSoftware->setText(QString(retval.c_str()));
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get versions.", "qTabDebugging::SetParameters")
qDefs::ExceptionMessage("Could not get versions.", e.what(), "qTabDebugging::SetParameters");
}
} }
} }
@ -210,9 +206,7 @@ void qTabDebugging::TestDetector() {
//display message //display message
qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(), "qTabDebugging::TestDetector"); qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(), "qTabDebugging::TestDetector");
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not execute digital test.", "qTabDebugging::TestDetector")
qDefs::ExceptionMessage("Could not execute digital test.", e.what(), "qTabDebugging::TestDetector");
}
} }

View File

@ -28,12 +28,12 @@ qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) :
} }
qTabDeveloper::~qTabDeveloper() { qTabDeveloper::~qTabDeveloper() {
for (int i = 0; i < lblDacs.size(); ++i) { for (size_t i = 0; i < lblDacs.size(); ++i) {
delete lblDacs[i]; delete lblDacs[i];
delete lblDacsmV[i]; delete lblDacsmV[i];
delete spinDacs[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 lblAdcs[i];
delete spinAdcs[i]; delete spinAdcs[i];
} }
@ -288,9 +288,7 @@ void qTabDeveloper::GetDac(int id) {
// mv // mv
retval = myDet->setDAC(-1, getSLSIndex(id), 1, comboDetector->currentIndex() - 1); retval = myDet->setDAC(-1, getSLSIndex(id), 1, comboDetector->currentIndex() - 1);
lblDacsmV[id]->setText(QString("%1mV").arg(retval -10)); lblDacsmV[id]->setText(QString("%1mV").arg(retval -10));
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY("Could not get dac.", "qTabDeveloper::GetDac")
qDefs::ExceptionMessage("Could not get dac.", e.what(), "qTabDeveloper::GetDac");
}
connect(spinDacs[id], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int))); connect(spinDacs[id], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int)));
} }
@ -309,9 +307,8 @@ void qTabDeveloper::SetDac(int id) {
try { try {
myDet->setDAC(val, getSLSIndex(id), 0, comboDetector->currentIndex() - 1); myDet->setDAC(val, getSLSIndex(id), 0, comboDetector->currentIndex() - 1);
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not set dac.", "qTabDeveloper::SetDac")
qDefs::ExceptionMessage("Could not set dac.", e.what(), "qTabDeveloper::SetDac");
}
// update mV anyway // update mV anyway
GetDac(id); GetDac(id);
} }
@ -331,9 +328,7 @@ void qTabDeveloper::GetAdcs() {
} }
spinAdcs[i]->setText(QString::number(retval, 'f', 2) + 0x00b0 + QString("C")); spinAdcs[i]->setText(QString::number(retval, 'f', 2) + 0x00b0 + QString("C"));
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get adcs.", "qTabDeveloper::GetAdcs")
qDefs::ExceptionMessage("Could not get adcs.", e.what(), "qTabDeveloper::GetAdcs");
}
} }
} }
@ -390,10 +385,7 @@ void qTabDeveloper::GetHighVoltage() {
} }
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get high voltage.", "qTabDeveloper::GetHighVoltage")
qDefs::ExceptionMessage("Could not get high voltage.", e.what(), "qTabDeveloper::GetHighVoltage");
}
if (comboHV == nullptr) { if (comboHV == nullptr) {
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage())); connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
@ -408,10 +400,8 @@ void qTabDeveloper::SetHighVoltage() {
try { try {
myDet->setDAC(val, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1); myDet->setDAC(val, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set high voltage.", "qTabDeveloper::SetHighVoltage",
qDefs::ExceptionMessage("Could not set high voltage.", e.what(), "qTabDeveloper::SetHighVoltage"); this, &qTabDeveloper::GetHighVoltage)
GetHighVoltage();
}
} }
@ -467,7 +457,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
case 22: case 22:
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: 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; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
@ -493,7 +483,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
case 9: case 9:
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: 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; break;
@ -504,7 +494,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
if (index == numDACWidgets) { if (index == numDACWidgets) {
return slsDetectorDefs::TEMPERATURE_ADC; return slsDetectorDefs::TEMPERATURE_ADC;
} else { } 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; break;
@ -512,7 +502,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
if (index >= 0 && index < numDACWidgets) { if (index >= 0 && index < numDACWidgets) {
return (slsDetectorDefs::dacIndex)index; return (slsDetectorDefs::dacIndex)index;
} else { } 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; break;

View File

@ -222,9 +222,7 @@ void qTabMeasurement::GetTimingMode() {
qDefs::Message(qDefs::WARNING, std::string("Unknown timing mode: ")+ std::to_string(retval), "qTabMeasurement::GetTimingMode"); qDefs::Message(qDefs::WARNING, std::string("Unknown timing mode: ")+ std::to_string(retval), "qTabMeasurement::GetTimingMode");
break; break;
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY("Could not get timing mode.", "qTabMeasurement::GetTimingMode")
qDefs::ExceptionMessage("Could not get timing mode.", e.what(), "qTabMeasurement::GetTimingMode");
}
disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));
} }
@ -235,10 +233,7 @@ void qTabMeasurement::SetTimingMode(int val) {
try { try {
myDet->setExternalCommunicationMode(static_cast<slsDetectorDefs::externalCommunicationMode>(val)); myDet->setExternalCommunicationMode(static_cast<slsDetectorDefs::externalCommunicationMode>(val));
EnableWidgetsforTimingMode(); EnableWidgetsforTimingMode();
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set timing mode.", "qTabMeasurement::SetTimingMode", this, &qTabMeasurement::GetTimingMode)
qDefs::ExceptionMessage("Could not set timing mode.", e.what(), "qTabMeasurement::SetTimingMode");
GetTimingMode();
}
} }
void qTabMeasurement::GetNumMeasurements() { void qTabMeasurement::GetNumMeasurements() {
@ -251,9 +246,7 @@ void qTabMeasurement::GetNumMeasurements() {
qDefs::Message(qDefs::WARNING, "Number of measurements is inconsistent for all detectors.", "qTabMeasurement::GetNumMeasurements"); qDefs::Message(qDefs::WARNING, "Number of measurements is inconsistent for all detectors.", "qTabMeasurement::GetNumMeasurements");
} }
spinNumMeasurements->setValue(retval); spinNumMeasurements->setValue(retval);
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get number of measurements.", "qTabMeasurement::GetNumMeasurements")
qDefs::ExceptionMessage("Could not get number of measurements.", e.what(), "qTabMeasurement::GetNumMeasurements");
}
connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(SetNumMeasurements(int))); connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(SetNumMeasurements(int)));
} }
@ -263,10 +256,7 @@ void qTabMeasurement::SetNumMeasurements(int val) {
try { try {
myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER, val); myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER, val);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set number of measurements.", "qTabMeasurement::SetNumMeasurements", this, &qTabMeasurement::GetNumMeasurements)
qDefs::ExceptionMessage("Could not set number of measurements.", e.what(), "qTabMeasurement::SetNumMeasurements");
GetNumMeasurements();
}
} }
void qTabMeasurement::GetNumFrames() { void qTabMeasurement::GetNumFrames() {
@ -279,9 +269,7 @@ void qTabMeasurement::GetNumFrames() {
qDefs::Message(qDefs::WARNING, "Number of frames is inconsistent for all detectors.", "qTabMeasurement::GetNumFrames"); qDefs::Message(qDefs::WARNING, "Number of frames is inconsistent for all detectors.", "qTabMeasurement::GetNumFrames");
} }
spinNumFrames->setValue(retval); spinNumFrames->setValue(retval);
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumFrames")
qDefs::ExceptionMessage("Could not get number of frames.", e.what(), "qTabMeasurement::GetNumFrames");
}
connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int))); connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int)));
} }
@ -291,10 +279,7 @@ void qTabMeasurement::SetNumFrames(int val) {
try { try {
myDet->setTimer(slsDetectorDefs::FRAME_NUMBER, val); myDet->setTimer(slsDetectorDefs::FRAME_NUMBER, val);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set number of frames.", "qTabMeasurement::SetNumFrames", this, &qTabMeasurement::GetNumFrames)
qDefs::ExceptionMessage("Could not set number of frames.", e.what(), "qTabMeasurement::SetNumFrames");
GetNumFrames();
}
} }
void qTabMeasurement::GetNumTriggers() { void qTabMeasurement::GetNumTriggers() {
@ -307,9 +292,7 @@ void qTabMeasurement::GetNumTriggers() {
qDefs::Message(qDefs::WARNING, "Number of triggers is inconsistent for all detectors.", "qTabMeasurement::GetNumTriggers"); qDefs::Message(qDefs::WARNING, "Number of triggers is inconsistent for all detectors.", "qTabMeasurement::GetNumTriggers");
} }
spinNumTriggers->setValue(retval); spinNumTriggers->setValue(retval);
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumTriggers")
qDefs::ExceptionMessage("Could not get number of frames.", e.what(), "qTabMeasurement::GetNumTriggers");
}
connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int))); connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int)));
} }
@ -319,10 +302,7 @@ void qTabMeasurement::SetNumTriggers(int val) {
try { try {
myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER, val); myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER, val);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set number of triggers.", "qTabMeasurement::SetNumTriggers", this, &qTabMeasurement::GetNumTriggers)
qDefs::ExceptionMessage("Could not set number of triggers.", e.what(), "qTabMeasurement::SetNumTriggers");
GetNumTriggers();
}
} }
void qTabMeasurement::GetNumSamples() { 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"); qDefs::Message(qDefs::WARNING, "Number of digital samples is inconsistent for all detectors.", "qTabMeasurement::GetNumSamples");
} }
spinNumSamples->setValue(retval); spinNumSamples->setValue(retval);
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get number of samples.", "qTabMeasurement::GetNumSamples")
qDefs::ExceptionMessage("Could not get number of samples.", e.what(), "qTabMeasurement::GetNumSamples");
}
connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int)));
} }
@ -352,10 +330,7 @@ void qTabMeasurement::SetNumSamples(int val) {
try { try {
myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES, val); myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES, val);
myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES, val); myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES, val);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set number of samples.", "qTabMeasurement::SetNumSamples", this, &qTabMeasurement::GetNumSamples)
qDefs::ExceptionMessage("Could not set number of samples.", e.what(), "qTabMeasurement::SetNumSamples");
GetNumSamples();
}
} }
void qTabMeasurement::GetExposureTime() { void qTabMeasurement::GetExposureTime() {
@ -375,9 +350,7 @@ void qTabMeasurement::GetExposureTime() {
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get exposure time.", "qTabMeasurement::GetExposureTime")
qDefs::ExceptionMessage("Could not get exposure time.", e.what(), "qTabMeasurement::GetExposureTime");
}
connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime()));
connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime()));
@ -392,10 +365,7 @@ void qTabMeasurement::SetExposureTime() {
double timeNS = qDefs::getNSTime(unit, val); double timeNS = qDefs::getNSTime(unit, val);
myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, std::lround(timeNS)); myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, std::lround(timeNS));
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set exposure time.", "qTabMeasurement::SetExposureTime", this, &qTabMeasurement::GetExposureTime)
qDefs::ExceptionMessage("Could not set exposure time.", e.what(), "qTabMeasurement::SetExposureTime");
GetExposureTime();
}
} }
void qTabMeasurement::GetAcquisitionPeriod() { void qTabMeasurement::GetAcquisitionPeriod() {
@ -415,9 +385,7 @@ void qTabMeasurement::GetAcquisitionPeriod() {
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get acquisition period.", "qTabMeasurement::GetAcquisitionPeriod")
qDefs::ExceptionMessage("Could not get acquisition period.", e.what(), "qTabMeasurement::GetAcquisitionPeriod");
}
connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod())); connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod()));
connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod())); connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod()));
@ -432,10 +400,7 @@ void qTabMeasurement::SetAcquisitionPeriod() {
double timeNS = qDefs::getNSTime(unit, val); double timeNS = qDefs::getNSTime(unit, val);
myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, std::lround(timeNS)); myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, std::lround(timeNS));
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set acquisition period.", "qTabMeasurement::SetAcquisitionPeriod", this, &qTabMeasurement::GetAcquisitionPeriod)
qDefs::ExceptionMessage("Could not set acquisition period.", e.what(), "qTabMeasurement::SetAcquisitionPeriod");
GetAcquisitionPeriod();
}
} }
void qTabMeasurement::CheckAcqPeriodGreaterThanExp() { void qTabMeasurement::CheckAcqPeriodGreaterThanExp() {
@ -478,9 +443,7 @@ void qTabMeasurement::GetDelay() {
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get delay.", "qTabMeasurement::GetDelay")
qDefs::ExceptionMessage("Could not get delay.", e.what(), "qTabMeasurement::GetDelay");
}
connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay())); connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay()));
connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay())); connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay()));
@ -495,10 +458,7 @@ void qTabMeasurement::SetDelay() {
double timeNS = qDefs::getNSTime(unit, val); double timeNS = qDefs::getNSTime(unit, val);
myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER, std::lround(timeNS)); myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER, std::lround(timeNS));
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set delay.", "qTabMeasurement::SetDelay", this, &qTabMeasurement::GetDelay)
qDefs::ExceptionMessage("Could not set delay.", e.what(), "qTabMeasurement::SetDelay");
GetDelay();
}
} }
void qTabMeasurement::GetFileWrite() { void qTabMeasurement::GetFileWrite() {
@ -506,7 +466,8 @@ void qTabMeasurement::GetFileWrite() {
disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
try { try {
int retval = myDet->getFileWrite(); dispFileName->setEnabled(true); // default, even when exception
int retval = myDet->getFileWrite();
if (retval == -1) { if (retval == -1) {
qDefs::Message(qDefs::WARNING, "File write is inconsistent for all detectors.", "qTabMeasurement::GetFileWrite"); qDefs::Message(qDefs::WARNING, "File write is inconsistent for all detectors.", "qTabMeasurement::GetFileWrite");
dispFileName->setEnabled(true); dispFileName->setEnabled(true);
@ -514,10 +475,7 @@ void qTabMeasurement::GetFileWrite() {
chkFile->setChecked(retval == 0 ? false : true); chkFile->setChecked(retval == 0 ? false : true);
dispFileName->setEnabled(chkFile->isChecked()); dispFileName->setEnabled(chkFile->isChecked());
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get file over write enable.", "qTabMeasurement::GetFileWrite")
qDefs::ExceptionMessage("Could not get file over write enable.", e.what(), "qTabMeasurement::GetFileWrite");
dispFileName->setEnabled(true);
}
connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
} }
@ -528,10 +486,7 @@ void qTabMeasurement::SetFileWrite(bool val) {
try { try {
myDet->setFileWrite(val); myDet->setFileWrite(val);
dispFileName->setEnabled(chkFile->isChecked()); dispFileName->setEnabled(chkFile->isChecked());
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set file write enable.", "qTabMeasurement::SetFileWrite", this, &qTabMeasurement::GetFileWrite)
qDefs::ExceptionMessage("Could not set file write enable.", e.what(), "qTabMeasurement::SetFileWrite");
GetFileWrite();
}
} }
void qTabMeasurement::GetFileName() { void qTabMeasurement::GetFileName() {
@ -541,9 +496,7 @@ void qTabMeasurement::GetFileName() {
try { try {
auto retval = myDet->getFileName(); auto retval = myDet->getFileName();
dispFileName->setText(QString(retval.c_str())); dispFileName->setText(QString(retval.c_str()));
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get file name prefix.", "qTabMeasurement::GetFileName")
qDefs::ExceptionMessage("Could not get file name prefix.", e.what(), "qTabMeasurement::GetFileName");
}
connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName())); connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName()));
} }
@ -553,10 +506,7 @@ void qTabMeasurement::SetFileName() {
FILE_LOG(logINFO) << "Setting File Name Prefix:" << val; FILE_LOG(logINFO) << "Setting File Name Prefix:" << val;
try { try {
myDet->setFileName(val); myDet->setFileName(val);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set file name prefix.", "qTabMeasurement::SetFileName", this, &qTabMeasurement::GetFileName)
qDefs::ExceptionMessage("Could not set file name prefix.", e.what(), "qTabMeasurement::SetFileName");
GetFileName();
}
} }
void qTabMeasurement::GetRunIndex() { void qTabMeasurement::GetRunIndex() {
@ -569,9 +519,7 @@ void qTabMeasurement::GetRunIndex() {
qDefs::Message(qDefs::WARNING, "Acquisition File Index is inconsistent for all detectors.", "qTabMeasurement::GetRunIndex"); qDefs::Message(qDefs::WARNING, "Acquisition File Index is inconsistent for all detectors.", "qTabMeasurement::GetRunIndex");
} }
spinIndex->setValue(retval); spinIndex->setValue(retval);
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get acquisition file index.", "qTabMeasurement::GetRunIndex")
qDefs::ExceptionMessage("Could not get acquisition file index.", e.what(), "qTabMeasurement::GetRunIndex");
}
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int))); connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int)));
} }
@ -581,10 +529,7 @@ void qTabMeasurement::SetRunIndex(int val) {
try { try {
myDet->setFileIndex(val); myDet->setFileIndex(val);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set acquisition file index.", "qTabMeasurement::SetRunIndex", this, &qTabMeasurement::GetRunIndex)
qDefs::ExceptionMessage("Could not set acquisition file index.", e.what(), "qTabMeasurement::SetRunIndex");
GetRunIndex();
}
} }
void qTabMeasurement::SetCurrentMeasurement(int val) { void qTabMeasurement::SetCurrentMeasurement(int val) {
@ -621,11 +566,10 @@ int qTabMeasurement::VerifyOutputDirectoryError() {
myDet->setFilePath(paths[det], det); myDet->setFilePath(paths[det], det);
} }
} }
} catch (const sls::NonCriticalError &e) { return slsDetectorDefs::OK;
qDefs::ExceptionMessage("Could not set path.", e.what(), "qTabMeasurement::VerifyOutputDirectoryError"); } CATCH_DISPLAY ("Could not set path.", "qTabMeasurement::VerifyOutputDirectoryError")
return slsDetectorDefs::FAIL;
} return slsDetectorDefs::FAIL; // for exception
return slsDetectorDefs::OK;
} }
void qTabMeasurement::StartAcquisition() { void qTabMeasurement::StartAcquisition() {
@ -660,9 +604,7 @@ void qTabMeasurement::StopAcquisition() {
FILE_LOG(logINFORED) << "Stopping Acquisition"; FILE_LOG(logINFORED) << "Stopping Acquisition";
try{ try{
myDet->stopAcquisition(); myDet->stopAcquisition();
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY("Could not stop acquisition.", "qTabMeasurement::StopAcquisition")
qDefs::ExceptionMessage("Could not stop acquisition.", e.what(), "qTabMeasurement::StopAcquisition");
}
} }
void qTabMeasurement::UpdateFinished() { void qTabMeasurement::UpdateFinished() {

View File

@ -331,9 +331,7 @@ void qTabPlot::GetGapPixels() {
} else { } else {
chkGapPixels->setChecked(retval == 0 ? false : true); chkGapPixels->setChecked(retval == 0 ? false : true);
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
qDefs::ExceptionMessage("Could not get gap pixels enable.", e.what(), "qTabPlot::GetGapPixels");
}
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
} }
@ -343,10 +341,7 @@ void qTabPlot::SetGapPixels(bool enable) {
try { try {
myDet->enableGapPixels(enable); myDet->enableGapPixels(enable);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels", this, &qTabPlot::GetGapPixels)
qDefs::ExceptionMessage("Could not set gap pixels enable.", e.what(), "qTabPlot::SetGapPixels");
GetGapPixels();
}
} }
void qTabPlot::SetTitles() { void qTabPlot::SetTitles() {
@ -643,9 +638,7 @@ void qTabPlot::GetStreamingFrequency() {
spinTimeGap->setValue(time.first); spinTimeGap->setValue(time.first);
comboTimeGapUnit->setCurrentIndex(static_cast<int>(time.second)); comboTimeGapUnit->setCurrentIndex(static_cast<int>(time.second));
} }
} catch(const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get streaming timer.", "qTabPlot::GetStreamingFrequency")
qDefs::ExceptionMessage("Could not get streaming timer.", e.what(), "qTabPlot::GetStreamingFrequency");
}
} }
// every nth frame // every nth frame
else { else {
@ -653,9 +646,7 @@ void qTabPlot::GetStreamingFrequency() {
stackedLayout->setCurrentIndex(1); stackedLayout->setCurrentIndex(1);
spinNthFrame->setValue(freq); spinNthFrame->setValue(freq);
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get streaming frequency.", "qTabPlot::GetStreamingFrequency")
qDefs::ExceptionMessage("Could not get streaming frequency.", e.what(), "qTabPlot::GetStreamingFrequency");
}
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
connect(comboTimeGapUnit, 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); double timeMS = qDefs::getMSTime(timeUnit, timeVal);
myDet->setReceiverStreamingTimer(timeMS); myDet->setReceiverStreamingTimer(timeMS);
} }
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE("Could not set streaming frequency/ timer.", "qTabPlot::SetStreamingFrequency", this, &qTabPlot::GetStreamingFrequency)
qDefs::ExceptionMessage("Could not set streaming frequency/ timer.", e.what(), "qTabPlot::SetStreamingFrequency");
GetStreamingFrequency();
}
} }
void qTabPlot::Refresh() { void qTabPlot::Refresh() {

View File

@ -127,9 +127,7 @@ void qTabSettings::GetSettings() {
} }
break; break;
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get settings.", "qTabSettings::GetSettings")
qDefs::ExceptionMessage("Could not get settings.", e.what(), "qTabSettings::GetSettings");
}
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
} }
@ -141,10 +139,7 @@ void qTabSettings::SetSettings(int index) {
try { try {
myDet->setSettings(val); myDet->setSettings(val);
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set settings.", "qTabSettings::SetSettings", this, &qTabSettings::GetSettings)
qDefs::ExceptionMessage("Could not set settings.", e.what(), "qTabSettings::SetSettings");
GetSettings();
}
// threshold // threshold
if (spinThreshold->isEnabled()) { 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"); qDefs::Message(qDefs::WARNING, std::string("Unknown dynamic range: ") + std::to_string(retval), "qTabSettings::GetDynamicRange");
break; break;
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get dynamic range.", "qTabSettings::GetDynamicRange")
qDefs::ExceptionMessage("Could not get dynamic range.", e.what(), "qTabSettings::GetDynamicRange");
}
connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int))); 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"); qDefs::Message(qDefs::WARNING, std::string("Unknown dynamic range: ") + std::to_string(index), "qTabSettings::SetDynamicRange");
break; break;
} }
} catch (const sls::NonCriticalError &e) { } CATCH_HANDLE ("Could not set dynamic range.", "qTabSettings::SetDynamicRange", this, &qTabSettings::GetDynamicRange)
qDefs::ExceptionMessage("Could not set dynamic range.", e.what(), "qTabSettings::SetDynamicRange");
GetDynamicRange();
}
} }
void qTabSettings::GetThresholdEnergy() { void qTabSettings::GetThresholdEnergy() {
@ -225,9 +215,7 @@ void qTabSettings::GetThresholdEnergy() {
} else { } else {
spinThreshold->setValue(retval); spinThreshold->setValue(retval);
} }
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get threshold energy.", "qTabDataOutput::GetThresholdEnergy")
qDefs::ExceptionMessage("Could not get threshold energy.", e.what(), "qTabDataOutput::GetThresholdEnergy");
}
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy())); 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"; FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
try { try {
myDet->setThresholdEnergy(index); myDet->setThresholdEnergy(index);
} catch (const sls::NonCriticalError &e) { } CATCH_DISPLAY ("Could not get threshold energy.", "qTabSettings::SetThresholdEnergy")
qDefs::ExceptionMessage("Could not get threshold energy.", e.what(), "qTabSettings::SetThresholdEnergy");
}
// set the right value anyway (due to tolerance) // set the right value anyway (due to tolerance)
GetThresholdEnergy(); GetThresholdEnergy();
} }