advanced down

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

View File

@ -107,7 +107,7 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
d.setOnline(true);
CHECK(d.getOnlineFlag() == true);
CHECK(d.getReceiverOnline() == false);
CHECK(d.getReceiverOnlineFlag() == false);
CHECK(d.checkDetectorVersionCompatibility() == slsDetectorDefs::OK);
// Setting and reading exposure time

View File

@ -1,14 +1,14 @@
set(CMAKE_AUTOMOC ON)
set(ENV{QMAKESPEC} "/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/mkspecs/linux-g++")
set(ENV{PATH} "/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/bin:$PATH")
#set(ENV{QMAKESPEC} "/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/mkspecs/linux-g++")
#set(ENV{PATH} "/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/bin:$PATH")
link_directories(
/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/lib
/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/qwt-6.0.1/lib
/afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/qwtplot3d/lib
/afs/psi.ch/project/sls_det_software/dhanya_softwareDevelopment/mySoft/slsDetectorPackage/build/bin
)
#link_directories(
# /afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/Qt-4.8.2/lib
# /afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/qwt-6.0.1/lib
# /afs/psi.ch/intranet/Controls/Software/Trolltech/RHEL7-x86_64/qwtplot3d/lib
# /afs/psi.ch/project/sls_det_software/dhanya_softwareDevelopment/mySoft/slsDetectorPackage/build/bin
#)
set(SOURCES
slsDetectorPlotting/src/SlsQt1DPlot.cxx
@ -67,6 +67,7 @@ set(HEADERS
include/qTabMessages.h
../slsSupportLib/include/versionAPI.h
include/qServer.h
../slsDetectorSoftware/include
)
set(RESOURCES
include/icons.qrc

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,9 @@
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="lblDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Dynamic Range:</string>
</property>
@ -50,6 +53,9 @@
</item>
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="comboSettings">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -144,6 +150,9 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Threshold:</string>
</property>
@ -167,6 +176,9 @@
</item>
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="comboDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>1.67772e+07</string>
@ -191,6 +203,9 @@
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblSettings">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Settings:</string>
</property>
@ -198,6 +213,9 @@
</item>
<item row="1" column="2" colspan="2">
<widget class="QSpinBox" name="spinThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>

View File

@ -198,6 +198,15 @@ class qDefs : public QWidget {
return FAIL;
}
/**
* Wrap exception message
*/
static int ExceptionMessage(std::string message,
std::string exceptionMessage,
std::string source) {
return Message(qDefs::WARNING, message + std::string("\nCaught exception:\n") + exceptionMessage, source);
}
/**
* Wrap around to ignore non critical exceptions
*/
@ -205,37 +214,40 @@ class qDefs : public QWidget {
// only executing multiSlsDetector function
template <typename RT, typename... CT>
static void IgnoreNonCriticalExceptions(multiSlsDetector* det, const std::string loc, RT (multiSlsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
static void IgnoreNonCriticalExceptions(multiSlsDetector* det,
const std::string message, const std::string source,
RT (multiSlsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
try {
((det->*somefunc)(Args...));
}
// catch them here as they are not critical
catch (const sls::NonCriticalError &e) {
Message(qDefs::WARNING, e.what(), loc);
ExceptionMessage(message, e.what(), source);
}
};
// executing multiSlsDetector funtion and using return value to set QWidget function
template <class W, typename WRT, typename RT, typename... CT>
static void IgnoreNonCriticalExceptions(W* wid,
void (W::*someQfunc)(WRT),
multiSlsDetector* det, const std::string loc,
RT (multiSlsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
static void IgnoreNonCriticalExceptions(multiSlsDetector* det,
const std::string message, const std::string source,
W* wid, void (W::*someQfunc)(WRT),
RT (multiSlsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
try {
auto val = ((det->*somefunc)(Args...));
(wid->*someQfunc)(static_cast<RT>(val));
}
// catch them here as they are not critical
catch (const sls::NonCriticalError &e) {
Message(qDefs::WARNING, e.what(), loc);
ExceptionMessage(message, e.what(), source);
}
};
// executing multiSlsDetector funtion and returning its value (integers, where value cannot be -1)
template <typename RT, typename... CT>
/* can easily get out of hand
template <typename RT, typename... CT>
static RT IgnoreNonCriticalExceptionsandReturn(
multiSlsDetector* det, const std::string loc,
RT (multiSlsDetector::*somefunc)(CT...),
@ -248,5 +260,5 @@ class qDefs : public QWidget {
Message(qDefs::WARNING, e.what(), loc);
return static_cast<RT>(-1);
}
};
};*/
};

View File

@ -61,43 +61,39 @@ class qServer : public QWidget, public virtual slsDetectorDefs {
*/
void ServerThread(ServerSocket* sock);
/**
* Thread of stop server
*/
void StopServer();
/**
* Get Detector Status
* @returns success of operation
*/
int GetStatus();
int GetStatus(ServerSocket* sock);
/**
* Starts Acquisition
* @returns success of operation
*/
int StartAcquisition();
int StartAcquisition(ServerSocket* sock);
/**
* Stops Acquisition
* @returns success of operation
*/
int StopsAcquisition();
int StopsAcquisition(ServerSocket* sock);
/**
* Acquire - blocking
* @returns success of operation
*/
int Acquire();
int Acquire(ServerSocket* sock);
/**
* Exit Server
* @returns GOODBYE
*/
int ExitServer();
int ExitServer(ServerSocket* sock);
/** function list */
std::vector<int (*)()> flist;
typedef int (qServer::*some_func_t)(ServerSocket*);
typedef std::vector<some_func_t> sflist;
/** if the gui server thread is running*/
bool threadRunning;

View File

@ -37,31 +37,14 @@ public slots:
*/
void Refresh();
private:
/**
* Sets up the widget
*/
void SetupWidgetWindow();
/**
* Sets up all the slots and signals
*/
void Initialization();
/**
* Add ROI Input
* @param num number of inputs to add
*/
void AddROIInput(int num);
/**
* Update the setalltrimbits value from server
*/
void updateAllTrimbitsFromServer();
private slots:
/**
* Select Readout
* @param index position index of readout
*/
void SetDetector(int index);
/**
* Sets control port
* @param port control port
@ -74,6 +57,32 @@ private slots:
*/
void SetStopPort(int port);
/**
* Sets detector udp ip
*/
void SetDetectorUDPIP();
/**
* Sets detector udp mac
*/
void SetDetectorUDPMAC();
/**
* Sets client zmq port
* @param port client zmq port
*/
void SetCltZMQPort(int port);
/**
* Sets client zmq ip to listen to
*/
void SetCltZMQIP();
/**
* Sets the receiver hostname
*/
void SetRxrHostname();
/**
* Sets receiver tcp port
* @param port receiver tcp port
@ -87,88 +96,54 @@ private slots:
void SetRxrUDPPort(int port);
/**
* Sets client zmq receiver port
* @param port client zmq receiver port
* Sets receiver ip
*/
void SetCltZmqPort(int port);
void SetRxrUDPIP();
/**
* Sets receiver zmq transmitting port
* @param port receiver zmq transmitting port
* Sets reciever mac
*/
void SetRxrZmqPort(int port);
void SetRxrUDPMAC();
/**
* Sets receiver online
* @param index 1 for online and 0 for offline
* Sets receiver zmq port
* @param port receiver zmq port
*/
void SetReceiverOnline(int index);
/**
* Sets detector online
* @param index 1 for online and 0 for offline
*/
void SetOnline(int index);
/**
* Sets network parameters like receiver udp ip,
* receiver udp mac, detector ip and detector mac
*/
void SetNetworkParameters();
/**
* Sets client zmq ip to listen to
*/
void SetClientZMQIP();
void SetRxrZMQPort(int port);
/**
* Sets receiver zmq ip to stream from
*/
void SetReceiverZMQIP();
void SetRxrZMQIP();
/**
* Sets the receiver. which also sets the receiver parameters
* Add ROI
*/
void SetReceiver();
/**
* Add ROI Input if the value changed in the last slot
*/
void AddROIInputSlot();
/**
* Clears all the ROI inputs
*/
void clearROI();
void AddROISlot();
/**
* Gets ROIs from detector and updates it
*/
void updateROIList();
/**
* Sets ROI in detector
*/
void setROI();
void GetROI();
/**
* Clears ROI in detector
*/
void clearROIinDetector();
void ClearROI();
/**
* Select Readout
* @param index position index of readout
* Sets ROI in detector
*/
void SetDetector(int index);
void SetROI();
/**
* Set all trimbits to a value
*/
void SetAllTrimbits();
/**
* Set storage cells
* Set number of additional storage cells
* @param value value to set to
*/
void SetNumStoragecells(int value);
@ -186,12 +161,125 @@ private slots:
private:
/**
* Sets up the widget
*/
void SetupWidgetWindow();
/**
* Sets up all the slots and signals
*/
void Initialization();
/**
* Populate detectors
*/
void PopulateDetectors();
/**
* Gets detector online
*/
void GetOnline();
/**
* Gets control port
*/
void GetControlPort();
/**
* Gets stop port
*/
void GetStopPort();
/**
* Gets detector udp ip
*/
void GetDetectorUDPIP();
/**
* Gets detector udp mac
*/
void GetDetectorUDPMAC();
/**
* Gets client zmq receiver port
*/
void GetCltZMQPort();
/**
* Gets client zmq ip to listen to
*/
void GetCltZMQIP();
/**
* Gets receiver hostname
*/
void GetRxrHostname();
/**
* Sets receiver online
*/
void GetReceiverOnline();
/**
* Gets receiver tcp port
*/
void GetRxrTCPPort();
/**
* Gets receiver udp port
*/
void GetRxrUDPPort();
/**
* Gets receiver udp ip
*/
void GetRxrUDPIP();
/**
* Gets receiver udp mac
*/
void GetRxrUDPMAC();
/**
* Gets receiver zmq transmitting port
*/
void GetRxrZMQPort();
/**
* Gets receiver zmq transmitting ip
*/
void GetRxrZMQIP();
/**
* Clears all the ROI widgets
*/
void ClearROIWidgets();
/**
* Get all trimbits
*/
void GetAllTrimbits();
/**
* Get number of additional storage cells
*/
void GetNumStoragecells();
/**
* Get sub frame exposure time
*/
void GetSubExposureTime();
/**
* Get sub frame dead time
*/
void GetSubDeadTime();
/** The multi detector object */
multiSlsDetector *myDet;
/** detector type */
slsDetectorDefs::detectorType detType;
/** Tool Tip */
QString errOnlineTip;
QString detOnlineTip;
@ -199,16 +287,14 @@ private:
QPalette red;
/** ROI */
std::vector <QLabel*> lblFromX;
std::vector <QSpinBox*> spinFromX;
std::vector <QLabel*> lblFromY;
std::vector <QSpinBox*> spinFromY;
std::vector <QLabel*> lblToX;
std::vector <QSpinBox*> spinToX;
std::vector <QLabel*> lblToY;
std::vector <QSpinBox*> spinToY;
int numRois;
std::vector <QLabel*> lblFromX;
std::vector <QSpinBox*> spinFromX;
std::vector <QLabel*> lblFromY;
std::vector <QSpinBox*> spinFromY;
std::vector <QLabel*> lblToX;
std::vector <QSpinBox*> spinToX;
std::vector <QLabel*> lblToY;
std::vector <QSpinBox*> spinToY;
};

View File

@ -77,13 +77,17 @@ private:
*/
void GetDynamicRange();
/**
* Gets the threshold energy and update widget
*/
void GetThresholdEnergy();
/** The sls detector object */
multiSlsDetector *myDet;
/** detector type */
slsDetectorDefs::detectorType detType;
enum{STANDARD, FAST, HIGHGAIN, DYNAMICGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN, LOWNOISE,
DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2, VERLOWGAIN,
UNDEFINED, UNINITIALIZED, NUMSETTINGS};
static const int THRESHOLD_TOLERANCE = 200;
};

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");
}

View File

@ -410,6 +410,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
int setOnline(int value = GET_ONLINE_FLAG, int detPos = -1);
/**
* Get detector online status
* @param detPos -1 for all detectors in list or specific detector position
*/
int getOnlineFlag(int detPos = -1);
/**
* Checks if each of the detectors are online/offline
* @param detPos -1 for all detectors in list or specific detector position
@ -444,9 +450,10 @@ class multiSlsDetector : public virtual slsDetectorDefs {
/**
* Get Receiver port
* @param detPos -1 for all detectors in list or specific detector position
* @returns vector of receiver port
*/
std::vector<int> getReceiverPort() const;
int getReceiverPort(int detPos = -1) const;
/**
* Lock server for this client IP
@ -1613,6 +1620,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
int setReceiverOnline(int value = GET_ONLINE_FLAG, int detPos = -1);
/**
* Get receiver online status
* @param detPos -1 for all detectors in list or specific detector position
*/
int getReceiverOnlineFlag(int detPos = -1);
/**
* Checks if the receiver is really online
* @param detPos -1 for all detectors in list or specific detector position

View File

@ -1519,7 +1519,7 @@ class slsDetector : public virtual slsDetectorDefs{
*/
int setReceiverOnline(int value = GET_ONLINE_FLAG);
int getReceiverOnline() const;
int getReceiverOnlineFlag() const;
/**
* Checks if the receiver is really online

View File

@ -674,6 +674,15 @@ int multiSlsDetector::setOnline(int value, int detPos) {
return multi_shm()->onlineFlag;
}
int multiSlsDetector::getOnlineFlag(int detPos) {
if (detPos >= 0) {
return detectors[detPos]->getOnlineFlag();
}
auto r = serialCall(&slsDetector::getOnlineFlag);
return sls::minusOneIfDifferent(r);
}
std::string multiSlsDetector::checkOnline(int detPos) {
if (detPos >= 0) {
return detectors[detPos]->checkOnline();
@ -710,8 +719,13 @@ int multiSlsDetector::setReceiverPort(int port_number, int detPos) {
return sls::minusOneIfDifferent(r);
}
std::vector<int> multiSlsDetector::getReceiverPort() const {
return parallelCall(&slsDetector::getReceiverPort);
int multiSlsDetector::getReceiverPort(int detPos) const {
if (detPos >= 0) {
return detectors[detPos]->getReceiverPort();
}
auto r = serialCall(&slsDetector::getReceiverPort);
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::lockServer(int p, int detPos) {
@ -2887,6 +2901,17 @@ int multiSlsDetector::setReceiverOnline(int value, int detPos) {
return multi_shm()->receiverOnlineFlag;
}
int multiSlsDetector::getReceiverOnlineFlag(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getReceiverOnlineFlag();
}
// multi
auto r = parallelCall(&slsDetector::getReceiverOnlineFlag);
return sls::minusOneIfDifferent(r);
}
std::string multiSlsDetector::checkReceiverOnline(int detPos) {
// single
if (detPos >= 0) {

View File

@ -3270,7 +3270,7 @@ int slsDetector::setReceiverOnline(int value) {
return shm()->rxOnlineFlag;
}
int slsDetector::getReceiverOnline() const { return shm()->rxOnlineFlag; }
int slsDetector::getReceiverOnlineFlag() const { return shm()->rxOnlineFlag; }
std::string slsDetector::checkReceiverOnline() {
try {