advanced down

This commit is contained in:
2019-05-08 16:44:08 +02:00
parent 2a1c89f712
commit c30485a65b
18 changed files with 1766 additions and 1648 deletions

View File

@ -276,6 +276,25 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
std::string title =
"SLS Detector GUI : " + myDet->getDetectorTypeAsString() + " - " +
myDet->getHostname();
FILE_LOG(logINFO) << title;
setWindowTitle(QString(title.c_str()));
//FIXME: not needed anymore due to client creating socket each time
//myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
//myDet->setReceiverOnline(slsDetectorDefs::ONLINE_FLAG);
}
void qDetectorMain::Initialization() {
// Dockable Plot
connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this,SLOT(ResizeMainWindow(bool)));
// tabs
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*)));
// Measurement tab
connect(tabMeasurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs()));
connect(tabMeasurement, SIGNAL(StopSignal()), myPlot,SLOT(StopAcquisition()));
connect(tabMeasurement, SIGNAL(CheckPlotIntervalSignal()), tabPlot,SLOT(SetFrequency()));
// Plot tab
connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool)));
// Plotting
// When the acquisition is finished, must update the meas tab
connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs()));
@ -328,7 +347,9 @@ void qDetectorMain::LoadConfigFile(const std::string fName) {
"qDetectorMain::LoadConfigFile");
FILE_LOG(logWARNING) << "File not recognized";
} else {
qDefs::IgnoreNonCriticalExceptions(myDet, "qDetectorMain::LoadConfigFile",
qDefs::IgnoreNonCriticalExceptions(myDet,
"Could not load config file.",
"qDetectorMain::LoadConfigFile",
&multiSlsDetector::readConfigurationFile, fName);
}
}
@ -361,11 +382,6 @@ void qDetectorMain::EnableModes(QAction *action) {
enable = actionExpert->isChecked();
tabs->setTabEnabled(ADVANCED, enable);
// moench don't have settings
if (detType != slsDetectorDefs::MOENCH) {
actionLoadTrimbits->setVisible(enable);
actionSaveTrimbits->setVisible(enable);
}
FILE_LOG(logINFO) << "Expert Mode: "
<< slsDetectorDefs::stringEnable(enable);
}
@ -546,8 +562,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
}
}
} catch (const sls::NonCriticalError &e) {
qDefs::Message(qDefs::WARNING, e.what(),
"qDetectorMain::ExecuteUtilities");
qDefs::ExceptionMessage("Could not execute utilities.", e.what(), "qDetectorMain::ExecuteUtilities");
}
Refresh(tabs->currentIndex());
@ -570,22 +585,22 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
FILE_LOG(logINFO) << "About Common GUI for Eiger, Gotthard, Jungfrau "
"and Moench detectors";
char version[200];
long long unsigned int retval = APIGUI;
sprintf(version, "%llx", retval);
std::string thisGUIVersion{version};
sprintf(version, "%lx",
myDet->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION));
std::string thisClientVersion{version};
std::string guiVersion = std::to_string(APIGUI);
std::string clientVersion;
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";
}
qDefs::Message(qDefs::INFORMATION,
"<p style=\"font-family:verdana;\">"
"SLS Detector GUI version:&nbsp;&nbsp;&nbsp;" +
thisGUIVersion +
guiVersion +
"<br>"
"SLS Detector Client version: " +
thisClientVersion +
clientVersion +
"<br><br>"
"Common GUI to control the SLS Detectors: "
"Eiger, Gotthard, Jungfrau and Moench.<br><br>"
@ -701,8 +716,8 @@ void qDetectorMain::EnableTabs() {
// expert
bool expertTab = enable && (actionExpert->isChecked());
tabs->setTabEnabled(ADVANCED, expertTab);
actionLoadTrimbits->setVisible(expertTab);
actionSaveTrimbits->setVisible(expertTab);
actionLoadTrimbits->setVisible(expertTab && detType != slsDetectorDefs::MOENCH);
actionSaveTrimbits->setVisible(expertTab && detType != slsDetectorDefs::MOENCH);
// moved to here, so that its all in order, instead of signals and different
// threads

View File

@ -19,11 +19,11 @@ qServer::qServer(qDetectorMain *t)
qServer::~qServer() {}
void qServer::FunctionTable() {
flist.push_back(qServer::GetStatus);
flist.push_back(qServer::StartAcquisition);
flist.push_back(qServer::StopsAcquisition);
flist.push_back(qServer::Acquire);
flist.push_back(qServer::ExitServer);
sflist.push_back(&qServer::GetStatus);
sflist.push_back(&qServer::StartAcquisition);
sflist.push_back(&qServer::StopsAcquisition);
sflist.push_back(&qServer::Acquire);
sflist.push_back(&qServer::ExitServer);
}
int qServer::DecodeFunction(ServerSocket *sock) {
@ -46,7 +46,7 @@ int qServer::DecodeFunction(ServerSocket *sock) {
// calling function
FILE_LOG(logDEBUG1) << "calling function fnum: " << fnum;
ret = (this->*flist[fnum])();
ret = (this->*sflist[fnum])(sock);
return ret;
}
@ -119,7 +119,7 @@ void qServer::ServerThread(ServerSocket* sock) {
emit ServerStoppedSignal();
}
int qServer::GetStatus(ServerSock* sock) {
int qServer::GetStatus(ServerSocket* sock) {
slsDetectorDefs::runStatus status = slsDetectorDefs::ERROR;
int progress = 0;
if (myMainTab->isPlotRunning())
@ -135,7 +135,7 @@ int qServer::GetStatus(ServerSock* sock) {
return ret;
}
int qServer::StartAcquisition(ServerSock* sock) {
int qServer::StartAcquisition(ServerSocket* sock) {
char mess[MAX_STR_LENGTH] = {};
sls::strcpy_safe(mess, "Could not start acquistion in Gui");
int ret = myMainTab->StartStopAcquisitionFromClient(true);
@ -143,7 +143,7 @@ int qServer::StartAcquisition(ServerSock* sock) {
return ret;
}
int qServer::StopsAcquisition(ServerSock* sock) {
int qServer::StopsAcquisition(ServerSocket* sock) {
char mess[MAX_STR_LENGTH] = {};
sls::strcpy_safe(mess, "Could not stop acquistion in Gui");
int ret = myMainTab->StartStopAcquisitionFromClient(false);
@ -151,7 +151,7 @@ int qServer::StopsAcquisition(ServerSock* sock) {
return ret;
}
int qServer::Acquire(ServerSock* sock) {
int qServer::Acquire(ServerSocket* sock) {
char mess[MAX_STR_LENGTH] = {};
sls::strcpy_safe(mess, "Could not start blocking acquistion in Gui");
int ret = myMainTab->StartStopAcquisitionFromClient(true);
@ -163,7 +163,7 @@ int qServer::Acquire(ServerSock* sock) {
return ret;
}
int qServer::ExitServer(ServerSock* sock) {
int qServer::ExitServer(ServerSocket* sock) {
DestroyServers();
int ret = qDefs::OK;
sock->SendResult(ret, nullptr, 0, mess);

File diff suppressed because it is too large Load Diff

View File

@ -22,9 +22,7 @@ qTabDebugging::qTabDebugging(QWidget *parent, multiSlsDetector *detector) : QWid
FILE_LOG(logDEBUG) << "Debugging ready";
}
qTabDebugging::~qTabDebugging() {
delete myDet;
}
qTabDebugging::~qTabDebugging() {}
void qTabDebugging::SetupWidgetWindow() {

View File

@ -35,10 +35,7 @@ qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) : QWid
}
qTabDeveloper::~qTabDeveloper() {
if (myDet)
delete myDet;
}
qTabDeveloper::~qTabDeveloper() {}
void qTabDeveloper::SetupWidgetWindow() {
//Detector Type
@ -130,10 +127,11 @@ void qTabDeveloper::SetupWidgetWindow() {
break;
default:
FILE_LOG(logERROR) << "Unknown detector type: " + myDet->getDetectorTypeAsString();
qDefs::Message(qDefs::CRITICAL, std::string("Unknown detector type:") + myDet->getDetectorTypeAsString(), "qTabDeveloper::SetupWidgetWindow");
exit(-1);
break;
std::string errorMess =
myDet->getHostname() + std::string(" has ") +
myDet->getDetectorTypeAsString() + std::string(" detector type (") +
std::to_string(detType) + std::string("). Exiting GUI. (Source: qTabDeveloper::SetupWidgetWindow)");
throw sls::RuntimeError(errorMess.c_str());
}
//layout
@ -174,8 +172,6 @@ void qTabDeveloper::SetupWidgetWindow() {
CreateADCWidgets();
layout->addWidget(boxAdcs, 2, 0);
}
qDefs::checkErrorMessage(myDet, "qTabDeveloper::SetupWidgetWindow");
}

View File

@ -8,50 +8,51 @@
#include <iostream>
qTabSettings::qTabSettings(QWidget *parent, multiSlsDetector *detector)
: QWidget(parent), myDet(detector), detType(slsDetectorDefs::GENERIC) {
: QWidget(parent), myDet(detector) {
setupUi(this);
SetupWidgetWindow();
Initialization();
FILE_LOG(logDEBUG) << "Settings ready";
}
qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() {
// Detector Type
detType = myDet->getDetectorTypeAsEnum();
switch(myDet->getDetectorTypeAsEnum()) {
case MOENCH:
lblSettings->setEnabled(false);
comboSettings->setEnabled(false);
break;
case EIGER:
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
break;
default:
break;
}
Initialization();
// Settings
comboSettings->setCurrentIndex(UNINITIALIZED);
if (detType == slsDetectorDefs::MOENCH) {
lblSettings->setEnabled(false);
comboSettings->setEnabled(false);
} else {
if (comboSettings->isEnabled()) {
SetupDetectorSettings();
GetSettings();
}
// Dynamic Range
// Dynamic Range (update it anyway)
GetDynamicRange();
// cannot change dr for other types
if (detType != slsDetectorDefs::EIGER) {
lblDynamicRange->setEnabled(false);
comboDynamicRange->setEnabled(false);
}
// threshold energy
if (detType == slsDetectorDefs::EIGER) {
qDefs::IgnoreNonCriticalExceptions<QSpinBox>(
spinThreshold,
&QSpinBox::setValue,
myDet,
std::string("qTabSettings::SetupWidgetWindow"),
&multiSlsDetector::getThresholdEnergy, -1);
} else {
lblThreshold->setEnabled(false);
spinThreshold->setEnabled(false);
}
// get threshold
spinThreshold->setValue(-1);
if (spinThreshold->isEnabled())
GetThresholdEnergy();
}
void qTabSettings::SetupDetectorSettings() {
@ -139,84 +140,114 @@ void qTabSettings::SetupDetectorSettings() {
void qTabSettings::Initialization() {
// Settings
if (comboSettings->isEnabled())
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
// Dynamic Range
if (comboDynamicRange->isEnabled())
connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
// Threshold
if (spinThreshold->isEnabled())
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetEnergy()));
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
}
void qTabSettings::GetSettings() {
FILE_LOG(logDEBUG) << "Getting settings";
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
int sett = qDefs::IgnoreNonCriticalExceptionsandReturn(
myDet, std::string("qTabSettings::SetupWidgetWindow"),
&multiSlsDetector::getSettings, -1);
FILE_LOG(logDEBUG) << "Settings from Detector:" << sett;
if (sett == -1)
sett = UNDEFINED;
if (sett == slsDetectorDefs::UNDEFINED)
sett = UNDEFINED;
else if (sett == slsDetectorDefs::UNINITIALIZED)
sett = UNINITIALIZED;
comboSettings->setCurrentIndex(sett);
try{
int sett = myDet->getSettings(-1);
FILE_LOG(logDEBUG) << "Settings from Detector:" << sett;
switch (sett) {
case -1:
qDefs::Message(qDefs::WARNING, "Different values for settings.", "qTabSettings::GetSettings");
comboSettings->setCurrentIndex(UNDEFINED);
break;
case slsDetectorDefs::UNDEFINED:
comboSettings->setCurrentIndex(UNDEFINED);
break;
case slsDetectorDefs::UNINITIALIZED:
comboSettings->setCurrentIndex(UNINITIALIZED);
break;
default:
if (sett >= NUMSETTINGS) {
qDefs::Message(qDefs::WARNING, "Unknown settings " + std::to_string(sett) + ".", "qTabSettings::GetSettings");
return;
}
comboSettings->setCurrentIndex(sett);
break;
}
} catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get settings.", e.what(), "qTabSettings::GetSettings");
}
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
}
void qTabSettings::GetDynamicRange() {
FILE_LOG(logDEBUG) << "Getting dynamic range";
disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
try {
int ret = myDet->setDynamicRange(-1);
int ret = qDefs::IgnoreNonCriticalExceptionsandReturn(
myDet, std::string("qTabSettings::GetDynamicRange"),
&multiSlsDetector::setDynamicRange, -1, -1);
// set the final value on gui
switch (ret) {
case 32:
comboDynamicRange->setCurrentIndex(0);
break;
case 16:
comboDynamicRange->setCurrentIndex(1);
break;
case 8:
comboDynamicRange->setCurrentIndex(2);
break;
case 4:
comboDynamicRange->setCurrentIndex(3);
break;
default:
if (ret != -1) {
qDefs::Message(qDefs::WARNING,
"Unknown Dyanmic Range " + std::to_string(ret) + ".",
"qTabSettings::SetupDetectorSettings");
// set the final value on gui
switch (ret) {
case -1:
qDefs::Message(qDefs::WARNING, "Different values for dynamic range.", "qTabSettings::GetDynamicRange");
break;
case 32:
comboDynamicRange->setCurrentIndex(0);
break;
case 16:
comboDynamicRange->setCurrentIndex(1);
break;
case 8:
comboDynamicRange->setCurrentIndex(2);
break;
case 4:
comboDynamicRange->setCurrentIndex(3);
break;
default:
qDefs::Message(qDefs::WARNING, "Unknown Dynamic Range " + std::to_string(ret) + ".", "qTabSettings::GetDynamicRange");
break;
}
break;
} catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get dynamic range.", e.what(), "qTabSettings::GetDynamicRange");
}
connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int)));
}
void qTabSettings::GetThresholdEnergy() {
FILE_LOG(logDEBUG) << "Getting theshold energy";
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
qDefs::IgnoreNonCriticalExceptions<QSpinBox>(
myDet,
"Could not get threshold energy."
"qTabSettings::GetThresholdEnergy",
spinThreshold,
&QSpinBox::setValue,
&multiSlsDetector::getThresholdEnergy, -1);
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
}
void qTabSettings::SetSettings(int index) {
slsDetectorDefs::detectorSettings sett =
// settings
try {
myDet->setSettings((slsDetectorDefs::detectorSettings)index);
FILE_LOG(logINFO) << "Settings set to "
<< myDet->slsDetectorDefs::getDetectorSettings(sett);
FILE_LOG(logINFO) << "Settings set to " << myDet->slsDetectorDefs::getDetectorSettings(sett);
} catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not set settings.", e.what(), "qTabSettings::SetSettings");
GetSettings();
}
// threshold
if (spinThreshold->isEnabled()) {
SetEnergy();
}
qDefs::checkErrorMessage(myDet, "qTabSettings::SetSettings");
}
void qTabSettings::SetDynamicRange(int index) {
int dr;
int dr = -1;
switch (index) {
case 0:
dr = 32;
@ -231,41 +262,36 @@ void qTabSettings::SetDynamicRange(int index) {
dr = 4;
break;
default:
break;
qDefs::Message(qDefs::WARNING, "Unknown dynamic range " + std::to_string(index) + ".", "qTabSettings::SetDynamicRange");
return;
}
int ret = myDet->setDynamicRange(dr);
FILE_LOG(logINFO) << "Setting dynamic range to " << dr;
qDefs::checkErrorMessage(myDet, "qTabSettings::SetDynamicRange");
// check
if (ret != dr) {
qDefs::Message(qDefs::WARNING, "Could not set dynamic range.",
"qTabSettings::SetDynamicRange");
disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
try {
myDet->setDynamicRange(dr);
FILE_LOG(logINFO) << "Setting dynamic range to " << dr;
} catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not set dynamic range.", e.what(), "qTabSettings::SetDynamicRange");
GetDynamicRange();
connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
}
}
void qTabSettings::SetEnergy() {
int index = spinThreshold->value();
FILE_LOG(logINFO) << "Settings threshold energy to " << index;
myDet->setThresholdEnergy(index);
int ret = myDet->getThresholdEnergy();
if ((ret - index) > 200) {
qDefs::Message(qDefs::WARNING,
"Threshold energy could not be set (tolerance 200).",
try {
// set
int index = spinThreshold->value();
int ret = myDet->setThresholdEnergy(index);
FILE_LOG(logINFO) << "Threshold energy set to " << index;
// validate
if ((ret - index) > THRESHOLD_TOLERANCE) {
qDefs::Message(qDefs::WARNING,
"Threshold energy could not be set (tolerance 200 eV).",
"qTabSettings::SetEnergy");
}
} catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not get threshold energy."), e.what(), "qTabSettings::SetEnergy");
}
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetEnergy()));
spinThreshold->setValue(ret);
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy()));
qDefs::checkErrorMessage(myDet, "qTabSettings::SetEnergy");
// set the right value anyway (exception or no)
GetThresholdEnergy();
}
void qTabSettings::Refresh() {
@ -273,32 +299,18 @@ void qTabSettings::Refresh() {
// settings
if (comboSettings->isEnabled()) {
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
GetSettings();
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
}
// threshold
if (spinThreshold->isEnabled()) {
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetEnergy()));
spinThreshold->setValue(myDet->getThresholdEnergy());
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetEnergy()));
GetThresholdEnergy();
}
// Dynamic Range
if (comboDynamicRange->isEnabled()) {
disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
GetDynamicRange();
connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
}
FILE_LOG(logDEBUG) << "**Updated Settings Tab";
qDefs::checkErrorMessage(myDet, "qTabSettings::Refresh");
}