diff --git a/integrationTests/test-integrationDectector.cpp b/integrationTests/test-integrationDectector.cpp index 527558966..eab84b241 100755 --- a/integrationTests/test-integrationDectector.cpp +++ b/integrationTests/test-integrationDectector.cpp @@ -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 diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt index aad448d94..a13a1b3ff 100755 --- a/slsDetectorGui/CMakeLists.txt +++ b/slsDetectorGui/CMakeLists.txt @@ -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 diff --git a/slsDetectorGui/forms/form_tab_advanced.ui b/slsDetectorGui/forms/form_tab_advanced.ui index 4044e0e41..526a372d0 100755 --- a/slsDetectorGui/forms/form_tab_advanced.ui +++ b/slsDetectorGui/forms/form_tab_advanced.ui @@ -36,12 +36,15 @@ :/icons/images/refresh.png:/icons/images/refresh.png + + true + 5 3 761 - 343 + 344 @@ -51,73 +54,60 @@ QTabWidget::North - 4 + 3 Qt::ElideLeft - + + + false + Logs - + + + false + Trimming - - - false - + - 10 + 20 10 - 233 - 66 + 309 + 39 - - Developer Option - - - false - - - false - - - - - 12 - 28 - 94 - 16 - - - - Set All trimbits: - - - - - - 121 - 24 - 86 - 25 - - - - -1 - - - 63 - - + + + + + Set All trimbits: + + + + + + + -1 + + + 63 + + + + - + + + false + Region of Interest @@ -166,7 +156,7 @@ - + 0 @@ -180,16 +170,16 @@ - Get ROI + Add ROI Slot - :/icons/images/download.png:/icons/images/download.png + :/icons/images/add.png:/icons/images/add.png - + Qt::Horizontal @@ -224,6 +214,42 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 150 + 0 + + + + Get ROI + + + + :/icons/images/download.png:/icons/images/download.png + + + @@ -263,432 +289,294 @@ - + Network - - - - 10 - 132 - 736 - 171 - - - - Receiver Parameters - - - - - 420 - 140 - 291 - 29 - - - - Setup Receiver - - - - :/icons/images/setup.png:/icons/images/setup.png - - - - - - 25 - 21 - 686 - 148 - - - - - 6 - - - - - - 0 - 0 - - - - TCP Port: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the Receiver UDP IP -#rx_udpip# - - - none - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 127 - 0 - - - - Sets Receiver UDP Port -#rx_udpport# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - UDP IP: - - - - - - - - 0 - 0 - - - - Hostname / IP: - - - - - - - - 0 - 0 - - - - <nobr>If the receiver is online<br>#r_online#</nobr>< - - - - Offline - - - - - Online - - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the Receiver UDP MAC -#rx_udpmac# - - - none - - - - - - - - 0 - 0 - - - - - 127 - 0 - - - - Sets Receiver TCP Port -#rx_tcpport# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - Online: - - - - - - - - 0 - 0 - - - - UDP Port: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the Receiver Hostname, connects to it and gets the receiver mac address and eth. Sets some receiver parameters like file name, file dir, file index in receiver. -#rx_hostname# - - - none - - - - - - - - 0 - 0 - - - - UDP MAC: - - - - - - - - 0 - 0 - - - - ZMQ Port: - - - - - - - - 0 - 0 - - - - - 127 - 0 - - - - Sets Receiver UDP Port -#rx_udpport# - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - 0 - - - 2000000000 - - - 0 - - - - - - - - 0 - 0 - - - - ZMQ IP: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the Receiver UDP IP -#rx_udpip# - - - - - - - - - - 35 + 19 10 - 686 - 146 + 724 + 300 - + 6 + + + + + 0 + 0 + + + + Receiver TCP Port: + + + + + + + + 0 + 0 + + + + Detector UDP IP: + + + + + + + + 0 + 0 + + + + + 127 + 0 + + + + Sets Receiver TCP Port +#rx_tcpport# + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + + 0 + + + 2000000000 + + + 0 + + + + + + + + 0 + 0 + + + + Receiver UDP IP: + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Sets the detector IP to send packets to receiver +#detectorip# + + + + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Sets the detector MAC to send packets to receiver +#detectormac# + + + + + + + + + + + 0 + 0 + + + + Client ZMQ IP: + + + + + + + + 0 + 0 + + + + Receiver UDP MAC: + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Sets the Receiver Hostname, connects to it and gets the receiver mac address and eth. Sets some receiver parameters like file name, file dir, file index in receiver. +#rx_hostname# + + + none + + + + + + + + 0 + 0 + + + + Detector UDP MAC: + + + + + + + + 0 + 0 + + + + + 127 + 0 + + + + Sets Receiver UDP Port +#rx_udpport# + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + + 0 + + + 2000000000 + + + 0 + + + + + + + + 0 + 0 + + + + Receiver: + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Sets the Receiver UDP IP +#rx_udpip# + + + none + + + @@ -712,42 +600,13 @@ - 40 + 20 20 - - - - - 0 - 0 - - - - - 180 - 0 - - - - <nobr>If the detector is online<br>#online#</nobr>< - - - - Offline - - - - - Online - - - - - + @@ -756,11 +615,11 @@ - Stop Port: + Detector Stop Port: - + @@ -769,85 +628,7 @@ - Control Port: - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the detector IP to send packets to receiver -#detectorip# - - - - - - - - - - - 0 - 0 - - - - - 180 - 0 - - - - Sets the detector MAC to send packets to receiver -#detectormac# - - - - - - - - - - - 0 - 0 - - - - MAC: - - - - - - - - 0 - 0 - - - - - 108 - 0 - - - - Online: + Detector Control Port: @@ -870,20 +651,7 @@ - - - - - 0 - 0 - - - - IP: - - - - + @@ -933,7 +701,7 @@ - + @@ -977,7 +745,7 @@ - + @@ -986,11 +754,11 @@ - ZMQ Port (GUI): + Client ZMQ Port: - + @@ -1034,8 +802,31 @@ - - + + + + + 0 + 0 + + + + + 180 + 0 + + + + Sets the Receiver UDP MAC +#rx_udpmac# + + + none + + + + + 0 @@ -1043,11 +834,100 @@ - Client ZMQ IP: + Receiver Online Status: - + + + + + 0 + 0 + + + + + 108 + 0 + + + + Detector Online Status: + + + + + + + + 0 + 0 + + + + Receiver ZMQ Port: + + + + + + + + 0 + 0 + + + + Receiver UDP Port: + + + + + + + + 0 + 0 + + + + + 127 + 0 + + + + Sets Receiver UDP Port +#rx_udpport# + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + + 0 + + + 2000000000 + + + 0 + + + + @@ -1070,10 +950,98 @@ + + + + + 0 + 0 + + + + + 180 + 0 + + + + Sets the Receiver UDP IP +#rx_udpip# + + + + + + + + + + + 0 + 0 + + + + Receiver ZMQ IP: + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Gets the detector online status +#online# + + + + + + true + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Gets the receiver online status +#r_online# + + + + + + true + + + - + Acquisition @@ -1147,7 +1115,7 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode false - <html><head/><body><p>Number of storage cells. For Jungfrau only. </p><p>Default: 0. </p><p>Number of Images received: #frames * #cycles * (#storagecells+1) </p><p> #storagecells#</p><p><br/></p></body></html> + <html><head/><body><p>Number of additional storage cells. For Jungfrau only. </p><p>Default: 0. </p><p>Number of Images received: #frames * #cycles * (#storagecells+1) </p><p> #storagecells#</p><p><br/></p></body></html> Number of Storage cells: @@ -1239,7 +1207,7 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode - <html><head/><body><p>Number of storage cells. For Jungfrau only. </p><p>Default: 0. </p><p>Number of Images received: #frames * #cycles * (#storagecells+1) </p><p> #storagecells#</p><p><br/></p></body></html> + <html><head/><body><p>Number of additional storage cells. For Jungfrau only. </p><p>Default: 0. </p><p>Number of Images received: #frames * #cycles * (#storagecells+1) </p><p> #storagecells#</p><p><br/></p></body></html> @@ -1391,23 +1359,11 @@ Default value is 0. A value less than the required minimum is ignored. tabAdvancedSettings - btnGetRoi - btnSetRoi btnClearRoi scrollArea comboDetector - comboOnline spinControlPort - dispIP spinStopPort - dispMAC - dispRxrHostname - comboRxrOnline - spinTCPPort - dispUDPIP - spinUDPPort - dispUDPMAC - btnRxr diff --git a/slsDetectorGui/forms/form_tab_settings.ui b/slsDetectorGui/forms/form_tab_settings.ui index c56af8243..9a44089a3 100755 --- a/slsDetectorGui/forms/form_tab_settings.ui +++ b/slsDetectorGui/forms/form_tab_settings.ui @@ -43,6 +43,9 @@ + + false + Dynamic Range: @@ -50,6 +53,9 @@ + + true + 0 @@ -144,6 +150,9 @@ + + false + Threshold: @@ -167,6 +176,9 @@ + + false + 1.67772e+07 @@ -191,6 +203,9 @@ + + true + Settings: @@ -198,6 +213,9 @@ + + false + false diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h index 3a241a4fa..cb71e5f98 100755 --- a/slsDetectorGui/include/qDefs.h +++ b/slsDetectorGui/include/qDefs.h @@ -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 - static void IgnoreNonCriticalExceptions(multiSlsDetector* det, const std::string loc, RT (multiSlsDetector::*somefunc)(CT...), - typename NonDeduced::type... Args) { + static void IgnoreNonCriticalExceptions(multiSlsDetector* det, + const std::string message, const std::string source, + RT (multiSlsDetector::*somefunc)(CT...), + typename NonDeduced::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 - static void IgnoreNonCriticalExceptions(W* wid, - void (W::*someQfunc)(WRT), - multiSlsDetector* det, const std::string loc, - RT (multiSlsDetector::*somefunc)(CT...), - typename NonDeduced::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::type... Args) { try { auto val = ((det->*somefunc)(Args...)); (wid->*someQfunc)(static_cast(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 + /* can easily get out of hand + template 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(-1); } - }; + };*/ }; diff --git a/slsDetectorGui/include/qServer.h b/slsDetectorGui/include/qServer.h index 96f381b14..8ffebe3ab 100755 --- a/slsDetectorGui/include/qServer.h +++ b/slsDetectorGui/include/qServer.h @@ -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 flist; + typedef int (qServer::*some_func_t)(ServerSocket*); + typedef std::vector sflist; /** if the gui server thread is running*/ bool threadRunning; diff --git a/slsDetectorGui/include/qTabAdvanced.h b/slsDetectorGui/include/qTabAdvanced.h index 568b8bcb1..65a1ac432 100755 --- a/slsDetectorGui/include/qTabAdvanced.h +++ b/slsDetectorGui/include/qTabAdvanced.h @@ -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 lblFromX; - std::vector spinFromX; - std::vector lblFromY; - std::vector spinFromY; - std::vector lblToX; - std::vector spinToX; - std::vector lblToY; - std::vector spinToY; - int numRois; - + std::vector lblFromX; + std::vector spinFromX; + std::vector lblFromY; + std::vector spinFromY; + std::vector lblToX; + std::vector spinToX; + std::vector lblToY; + std::vector spinToY; }; diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h index fb2d2f422..52dc24c1e 100755 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -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; }; diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index debfae231..6f5fa2d49 100755 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -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, "

" "SLS Detector GUI version:   " + - thisGUIVersion + + guiVersion + "
" "SLS Detector Client version: " + - thisClientVersion + + clientVersion + "

" "Common GUI to control the SLS Detectors: " "Eiger, Gotthard, Jungfrau and Moench.

" @@ -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 diff --git a/slsDetectorGui/src/qServer.cpp b/slsDetectorGui/src/qServer.cpp index e8ae77581..e8c13747d 100755 --- a/slsDetectorGui/src/qServer.cpp +++ b/slsDetectorGui/src/qServer.cpp @@ -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); diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index d808196e0..3f67fedae 100755 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -3,874 +3,860 @@ #include "multiSlsDetector.h" -#include +#include qTabAdvanced::qTabAdvanced(QWidget *parent, multiSlsDetector* detector): -QWidget(parent), myDet(detector),detType(slsDetectorDefs::GENERIC), -lblFromX(0), -spinFromX(0), -lblFromY(0), -spinFromY(0), -lblToX(0), -spinToX(0), -lblToY(0), -spinToY(0), -numRois(0){ +QWidget(parent), myDet(detector) { setupUi(this); SetupWidgetWindow(); FILE_LOG(logDEBUG) << "Advanced ready"; } - -qTabAdvanced::~qTabAdvanced(){ - delete myDet; -} - +qTabAdvanced::~qTabAdvanced(){} void qTabAdvanced::SetupWidgetWindow(){ red = QPalette(); red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - detOnlineTip = comboOnline->toolTip(); - rxrOnlineTip = comboRxrOnline->toolTip(); + detOnlineTip = dispOnline->toolTip(); + rxrOnlineTip = dispRxrOnline->toolTip(); errOnlineTip = QString("

It is offline!"); - detType = myDet->getDetectorTypeAsEnum(); - if (detType == slsDetectorDefs::EIGER ) { - boxSetAllTrimbits->setEnabled(true); - lblSubExpTime->setEnabled(true); - spinSubExpTime->setEnabled(true); - comboSubExpTimeUnit->setEnabled(true); - lblSubDeadTime->setEnabled(true); - spinSubDeadTime->setEnabled(true); - comboSubDeadTimeUnit->setEnabled(true); + + switch((int)myDet->getDetectorTypeAsEnum()) { + case slsDetectorDefs::EIGER: + // trimming + tab_trimming->setEnabled(true); + lblSubExpTime->setEnabled(true); + // subexptime + spinSubExpTime->setEnabled(true); + comboSubExpTimeUnit->setEnabled(true); + // subdeadtime + lblSubDeadTime->setEnabled(true); + spinSubDeadTime->setEnabled(true); + comboSubDeadTimeUnit->setEnabled(true); + break; + case slsDetectorDefs::GOTTHARD: + // roi + tab_roi->setEnabled(true); + break; + } + // set initially to network tab + tabAdvancedSettings->setCurrentWidget(tab_network); - //network - - //add detectors - for(int i=0;igetNumberOfDetectors(); ++i) - comboDetector->addItem(QString(myDet->getHostname(i).c_str())); - - comboDetector->setCurrentIndex(0); - int moduleId = comboDetector->currentIndex(); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetupWidgetWindow"); - FILE_LOG(logDEBUG) << "Getting ports"; - spinControlPort->setValue(myDet->setControlPort(-1, moduleId)); - spinStopPort->setValue(myDet->setStopPort(-1, moduleId)); - spinTCPPort->setValue(myDet->setReceiverPort(-1, moduleId)); - spinUDPPort->setValue(myDet->getReceiverUDPPort(moduleId)); - spinZmqPort->setValue(myDet->getClientStreamingPort(moduleId)); - spinZmqPort2->setValue(myDet->getReceiverStreamingPort(moduleId)); - - FILE_LOG(logDEBUG) << "Getting network information"; - dispIP->setText(myDet->getDetectorIP(moduleId).c_str()); - dispMAC->setText(myDet->getDetectorMAC(moduleId).c_str()); - dispRxrHostname->setText(myDet->getReceiverHostname(moduleId).c_str()); - dispUDPIP->setText(myDet->getReceiverUDPIP(moduleId).c_str()); - dispUDPMAC->setText(myDet->getReceiverUDPMAC(moduleId).c_str()); - dispZMQIP->setText(myDet->getClientStreamingIP(moduleId).c_str()); - dispZMQIP2->setText(myDet->getReceiverStreamingIP(moduleId).c_str()); - - //check if its online and set it to red if offline - FILE_LOG(logDEBUG) << "Getting online status"; - if(myDet->setOnline(moduleId)==slsDetectorDefs::ONLINE_FLAG) - myDet->checkOnline(moduleId); - if(myDet->setReceiverOnline(moduleId)==slsDetectorDefs::ONLINE_FLAG) - myDet->checkReceiverOnline(moduleId); - comboOnline->setCurrentIndex(myDet->setOnline(moduleId)); - comboRxrOnline->setCurrentIndex(myDet->setReceiverOnline(moduleId)); - if(!comboOnline->currentIndex()){ - comboOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setPalette(red); - lblOnline->setText("Online:*"); - } - if((comboRxrOnline->isEnabled())&&(!comboRxrOnline->currentIndex())){ - comboRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setPalette(red); - lblRxrOnline->setText("Online:*"); - } - - - //updates roi - FILE_LOG(logDEBUG) << "Getting ROI"; - if (detType == slsDetectorDefs::GOTTHARD) - updateROIList(); - myDet->printReceiverConfiguration(logDEBUG); - - // jungfrau - if (detType == slsDetectorDefs::JUNGFRAU) { - lblNumStoragecells->setEnabled(true); - spinNumStoragecells->setEnabled(true); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); - } else if (detType == slsDetectorDefs::EIGER) { - //subexptime - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,-1)*(1E-9)))); - spinSubExpTime->setValue(time); - comboSubExpTimeUnit->setCurrentIndex((int)unit); - //period - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); - spinSubDeadTime->setValue(time); - comboSubDeadTimeUnit->setCurrentIndex((int)unit); - - } Initialization(); - qDefs::checkErrorMessage(myDet, moduleId,"qTabAdvanced::SetupWidgetWindow"); - + // udpate detector list in network + PopulateDetectors(); + + Refresh(); } void qTabAdvanced::Initialization(){ connect(tabAdvancedSettings,SIGNAL(currentChanged(int)), this, SLOT(Refresh())); - //network - connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); - connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - - //network - connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - - connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - - connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - - - if (detType == slsDetectorDefs::GOTTHARD) { - // roi - connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(clearROIinDetector())); - connect(btnGetRoi, SIGNAL(clicked()), this, SLOT(updateROIList())); - connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(setROI())); + // trimming + if (tab_trimming->isEnabled()) { + // editingFinished to not set trimbits for every character input + connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); } - else if(detType == slsDetectorDefs::JUNGFRAU) { - // storage cells + //network + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); + connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); + connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); + connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPIP())); + connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPMAC())); + connect(spinZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZMQPort(int))); + connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); + connect(dispRxrHostname, SIGNAL(editingFinished()), this, SLOT(SetRxrHostname())); + connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); + connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); + connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); + connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPMAC())); + connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZMQPort(int))); + connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); + + // roi + if (gridRoi->isEnabled()) { + connect(btnAddRoi, SIGNAL(clicked()), this, SLOT(AddROISlot())); + connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(SetROI())); + connect(btnGetRoi, SIGNAL(clicked()), this, SLOT(GetROI())); + connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(ClearROI())); + } + + // storage cells + if (lblNumStoragecells->isEnabled()) { connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); } - else if (detType == slsDetectorDefs::EIGER) { - // all trimbits - connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); - - //Exposure Time + // subexptime, subdeadtime + if (lblSubExpTime->isEnabled()) { connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); - - //Frame Period between exposures connect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); - connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); - + connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubDeadTime())); } } +void qTabAdvanced::PopulateDetectors() { + FILE_LOG(logDEBUG) << "Populating detectors"; + disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); -void qTabAdvanced::SetControlPort(int port){ + for(int i = 0; i < myDet->getNumberOfDetectors(); ++i) + comboDetector->addItem(QString(myDet->getHostname(i).c_str())); + comboDetector->setCurrentIndex(0); + + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDetector(int))); +} + +void qTabAdvanced::GetOnline() { + FILE_LOG(logDEBUG) << "Getting detector online status"; + + int moduleId = comboDetector->currentIndex(); + try { + myDet->checkOnline(moduleId); + + int ret = myDet->getOnlineFlag(moduleId); + switch(ret) { + case 1: + dispOnline->setText("Online"); + lblOnline->setText("Detector Online Status: "); + dispOnline->setToolTip(detOnlineTip); + lblOnline->setToolTip(detOnlineTip); + dispOnline->setPalette(lblHostname->palette()); + lblOnline->setPalette(lblHostname->palette()); + default: + dispOnline->setText("Offline"); + lblOnline->setText("Detector Online Status:* "); + dispOnline->setToolTip(detOnlineTip + errOnlineTip); + lblOnline->setToolTip(detOnlineTip + errOnlineTip); + dispOnline->setPalette(red); + lblOnline->setPalette(red); + break; + } + } + // ignore if checkonline throws socket exception, else display it + catch (const sls::SocketError &e) { + ;// do nothing as it might just be offline + } + // display any other exception + catch (const std::exception &e) { + qDefs::ExceptionMessage("Could not check detector online status", e.what(), "qTabAdvanced::GetOnline"); + } +} + +void qTabAdvanced::GetControlPort() { + FILE_LOG(logDEBUG) << "Getting control port "; + disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get detector control port." + "qTabAdvanced::GetControlPort", + spinControlPort, + &QSpinBox::setValue, + &multiSlsDetector::setControlPort, -1, comboDetector->currentIndex()); + + connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); +} + +void qTabAdvanced::GetStopPort() { + FILE_LOG(logDEBUG) << "Getting stop port"; + disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get detector stop port." + "qTabAdvanced::GetStopPort", + spinStopPort, + &QSpinBox::setValue, + &multiSlsDetector::setStopPort, -1, comboDetector->currentIndex()); + + connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); +} + +void qTabAdvanced::GetDetectorUDPIP() { + FILE_LOG(logDEBUG) << "Getting Detector UDP IP"; + disconnect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPIP())); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get detector UDP IP." + "qTabAdvanced::GetDetectorUDPIP", + dispDetectorUDPIP, + &QLineEdit::setText, + &multiSlsDetector::getDetectorIP, comboDetector->currentIndex()); + + connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPIP())); +} + +void qTabAdvanced::GetDetectorUDPMAC() { + FILE_LOG(logDEBUG) << "Getting Detector UDP MAC"; + disconnect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPMAC())); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get detector UDP MAC." + "qTabAdvanced::GetDetectorUDPMAC", + dispDetectorUDPMAC, + &QLineEdit::setText, + &multiSlsDetector::getDetectorMAC, comboDetector->currentIndex()); + + connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetDetectorUDPMAC())); +} + +void qTabAdvanced::GetCltZMQPort() { + FILE_LOG(logDEBUG) << "Getting Client ZMQ port"; + disconnect(spinZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZMQPort(int))); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get client zmq port." + "qTabAdvanced::GetCltZMQPort", + spinZMQPort, + &QSpinBox::setValue, + &multiSlsDetector::getClientStreamingPort, comboDetector->currentIndex()); + + connect(spinZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZMQPort(int))); +} + +void qTabAdvanced::GetCltZMQIP() { + FILE_LOG(logDEBUG) << "Getting Client ZMQ IP"; + disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get client zmq ip." + "qTabAdvanced::GetCltZMQIP", + dispZMQIP, + &QLineEdit::setText, + &multiSlsDetector::getClientStreamingIP, comboDetector->currentIndex()); + + connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); +} + +void qTabAdvanced::GetRxrHostname() { + FILE_LOG(logDEBUG) << "Getting Receiver Hostname"; + disconnect(dispRxrHostname, SIGNAL(editingFinished()), this, SLOT(SetRxrHostname())); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get receiver hostname." + "qTabAdvanced::GetRxrHostname", + dispRxrHostname, + &QLineEdit::setText, + &multiSlsDetector::getReceiverHostname, comboDetector->currentIndex()); + + connect(dispRxrHostname, SIGNAL(editingFinished()), this, SLOT(SetRxrHostname())); +} + +void qTabAdvanced::GetReceiverOnline() { + FILE_LOG(logDEBUG) << "Getting Receiver online status"; + + int moduleId = comboDetector->currentIndex(); + try { + myDet->checkReceiverOnline(moduleId); + + int ret = myDet->getReceiverOnlineFlag(moduleId); + switch(ret) { + case 1: + dispRxrOnline->setText("Online"); + lblRxrOnline->setText("Receiver Online Status: "); + dispRxrOnline->setToolTip(rxrOnlineTip); + lblRxrOnline->setToolTip(rxrOnlineTip); + dispRxrOnline->setPalette(lblHostname->palette()); + lblRxrOnline->setPalette(lblHostname->palette()); + default: + dispRxrOnline->setText("Offline"); + lblRxrOnline->setText("Receiver Online Status:* "); + dispRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); + lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); + dispRxrOnline->setPalette(red); + lblRxrOnline->setPalette(red); + break; + } + } + // ignore if checkReceiverOnline throws socket exception + catch (const sls::SocketError &e) { + ; + } + // display any other exception + catch (const exception &e) { + qDefs::ExceptionMessage("Could not check receiver online status", e.what(), "qTabAdvanced::GetReceiverOnline"); + } +} + +void qTabAdvanced::GetRxrTCPPort() { + FILE_LOG(logDEBUG) << "Getting Receiver TCP port"; + disconnect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get receiver tcp port." + "qTabAdvanced::GetRxrTCPPort", + spinRxrTCPPort, + &QSpinBox::setValue, + &multiSlsDetector::getReceiverPort, comboDetector->currentIndex()); + + connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); +} + +void qTabAdvanced::GetRxrUDPPort() { + FILE_LOG(logDEBUG) << "Getting Receiver UDP port"; + disconnect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get receiver udp port." + "qTabAdvanced::GetRxrUDPPort", + spinRxrUDPPort, + &QSpinBox::setValue, + &multiSlsDetector::getReceiverUDPPort, comboDetector->currentIndex()); + + connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); +} + +void qTabAdvanced::GetRxrUDPIP() { + FILE_LOG(logDEBUG) << "Getting Receiver UDP IP"; + disconnect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get receiver udp ip." + "qTabAdvanced::GetRxrUDPIP", + dispRxrUDPIP, + &QLineEdit::setText, + &multiSlsDetector::getReceiverUDPIP, comboDetector->currentIndex()); + + connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); +} + +void qTabAdvanced::GetRxrUDPMAC() { + FILE_LOG(logDEBUG) << "Getting Receiver UDP MAC"; + disconnect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPMAC())); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get receiver udp mac." + "qTabAdvanced::GetRxrUDPMAC", + dispRxrUDPMAC, + &QLineEdit::setText, + &multiSlsDetector::getReceiverUDPMAC, comboDetector->currentIndex()); + + connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPMAC())); +} + +void qTabAdvanced::GetRxrZMQPort() { + FILE_LOG(logDEBUG) << "Getting Receiver ZMQ port"; + disconnect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZMQPort(int))); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get receiver zmq port." + "qTabAdvanced::GetRxrZMQPort", + spinRxrZMQPort, + &QSpinBox::setValue, + &multiSlsDetector::getReceiverStreamingPort, comboDetector->currentIndex()); + + connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZMQPort(int))); +} + +void qTabAdvanced::GetRxrZMQIP() { + FILE_LOG(logDEBUG) << "Getting Receiver ZMQ IP"; + disconnect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); + + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get receiver zmq ip." + "qTabAdvanced::GetRxrZMQIP", + dispRxrZMQIP, + &QLineEdit::setText, + &multiSlsDetector::getReceiverStreamingIP, comboDetector->currentIndex()); + + connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); +} + +void qTabAdvanced::SetDetector(int index) { + FILE_LOG(logDEBUG) << "Set Detector: " << index; + + GetOnline(); + GetControlPort(); + GetStopPort(); + GetDetectorUDPIP(); + GetDetectorUDPMAC(); + GetCltZMQPort(); + GetCltZMQIP(); + GetRxrHostname(); + GetReceiverOnline(); + GetRxrTCPPort(); + GetRxrUDPPort(); + GetRxrUDPIP(); + GetRxrUDPMAC(); + GetRxrZMQPort(); + GetRxrZMQIP(); + + myDet->printReceiverConfiguration(logDEBUG); +} + +void qTabAdvanced::SetControlPort(int port) { FILE_LOG(logINFO) << "Setting Control Port:" << port; - disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - spinControlPort->setValue(myDet->setControlPort(port, comboDetector->currentIndex())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetControlPort"); - connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); + try { + myDet->setControlPort(port, comboDetector->currentIndex()); + } catch (const sls::RuntimeError &e) { + qDefs::ExceptionMessage("Could not set control port.", e.what(), "qTabAdvanced::SetControlPort"); + GetControlPort(); + } } - -void qTabAdvanced::SetStopPort(int port){ +void qTabAdvanced::SetStopPort(int port) { FILE_LOG(logINFO) << "Setting Stop Port:" << port; - disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - spinStopPort->setValue(myDet->setStopPort(port, comboDetector->currentIndex())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetStopPort"); - connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); + try { + myDet->setStopPort(port, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set stop port.", e.what(), "qTabAdvanced::SetStopPort"); + GetStopPort(); + } +} +void qTabAdvanced::SetDetectorUDPIP() { + std::string s = dispDetectorUDPIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s; + try { + myDet->setDetectorIP(s, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Detector UDP IP.", e.what(), "qTabAdvanced::SetDetectorUDPIP"); + GetDetectorUDPIP(); + } } -void qTabAdvanced::SetRxrTCPPort(int port){ +void qTabAdvanced::SetDetectorUDPMAC() { + std::string s = dispDetectorUDPMAC->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s; + try { + myDet->setDetectorMAC(s, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Detector UDP MAC.", e.what(), "qTabAdvanced::SetDetectorUDPMAC"); + GetDetectorUDPMAC(); + } +} + +void qTabAdvanced::SetCltZMQPort(int port) { + FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port; + try { + myDet->setClientDataStreamingInPort(port, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Client ZMQ port.", e.what(), "qTabAdvanced::SetCltZMQPort"); + GetCltZMQPort(); + } +} + +void qTabAdvanced::SetCltZMQIP() { + std::string s = dispZMQIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s; + try { + myDet->setClientDataStreamingInIP(s, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Client ZMQ IP.", e.what(), "qTabAdvanced::SetCltZMQIP"); + GetCltZMQIP(); + } +} + +void qTabAdvanced::SetRxrHostname() { + std::string s = dispZMQIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s; + try { + myDet->setReceiverHostname(s, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Client ZMQ IP.", e.what(), "qTabAdvanced::SetRxrHostname"); + GetRxrHostname(); + } + + // update all network widgets (receiver mainly) + SetDetector(comboDetector->currentIndex()); +} + +void qTabAdvanced::SetRxrTCPPort(int port) { FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port; - disconnect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - spinTCPPort->setValue(myDet->setReceiverPort(port, comboDetector->currentIndex())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetRxrTCPPort"); - connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); + try { + myDet->setReceiverPort(port, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Receiver TCP port.", e.what(), "qTabAdvanced::SetRxrTCPPort"); + GetRxrTCPPort(); + } } -void qTabAdvanced::SetRxrUDPPort(int port){ +void qTabAdvanced::SetRxrUDPPort(int port) { FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port; + try { + myDet->setReceiverUDPPort(port, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Receiver UDP port.", e.what(), "qTabAdvanced::SetRxrUDPPort"); + GetRxrUDPPort(); + } +} - disconnect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - spinUDPPort->setValue(myDet->setReceiverUDPPort(port, comboDetector->currentIndex())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetRxrUDPPort"); - connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); +void qTabAdvanced::SetRxrUDPIP() { + std::string s = dispRxrUDPIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s; + try { + myDet->setReceiverUDPIP(s, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Receiver UDP IP.", e.what(), "qTabAdvanced::SetRxrUDPIP"); + GetRxrUDPIP(); + } } -void qTabAdvanced::SetCltZmqPort(int port){ - FILE_LOG(logINFO) << "Setting Client UDP Port:" << port; - std::ostringstream ss; ss << port; std::string sport = ss.str(); - - disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - myDet->setClientDataStreamingInPort(port, comboDetector->currentIndex()); - spinZmqPort->setValue(myDet->getClientStreamingPort(comboDetector->currentIndex())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetCltZmqPort"); - myDet->enableDataStreamingToClient(false); - myDet->enableDataStreamingToClient(true); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetCltZmqPort"); - connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); +void qTabAdvanced::SetRxrUDPMAC() { + std::string s = dispRxrUDPMAC->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s; + try { + myDet->setReceiverUDPMAC(s, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Receiver UDP MAC.", e.what(), "qTabAdvanced::SetRxrUDPMAC"); + GetRxrUDPMAC(); + } } - -void qTabAdvanced::SetRxrZmqPort(int port){ - FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port; - std::ostringstream ss; ss << port; std::string sport = ss.str(); - - disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - myDet->setReceiverDataStreamingOutPort(port, comboDetector->currentIndex()); - spinZmqPort2->setValue(myDet->getReceiverStreamingPort(comboDetector->currentIndex())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetRxrZmqPort"); - myDet->enableDataStreamingFromReceiver(false); - myDet->enableDataStreamingFromReceiver(true); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetRxrZmqPort"); - connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); +void qTabAdvanced::SetRxrZMQPort(int port){ + FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port; + try { + myDet->setReceiverDataStreamingOutPort(port, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Receiver ZMQ port.", e.what(), "qTabAdvanced::SetRxrZMQPort"); + GetRxrZMQPort(); + } } - -void qTabAdvanced::SetReceiverOnline(int index){ - FILE_LOG(logINFO) << "Setting Reciever Online to :" << index; - disconnect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - if(index){ - SetReceiver(); - }else{ - comboRxrOnline->setCurrentIndex(myDet->setReceiverOnline(index, comboDetector->currentIndex())); - } - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetReceiverOnline"); - connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - //highlight in red if offline - if(!comboRxrOnline->currentIndex()){ - comboRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setPalette(red); - lblRxrOnline->setText("Online:*"); - }else{ - comboRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setPalette(lblHostname->palette()); - lblRxrOnline->setText("Online:"); - } +void qTabAdvanced::SetRxrZMQIP(){ + std::string s = dispRxrZMQIP->text().toAscii().constData(); + FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; + try { + myDet->setReceiverDataStreamingOutIP(s, comboDetector->currentIndex()); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set Receiver ZMQ IP.", e.what(), "qTabAdvanced::SetRxrZMQIP"); + GetRxrZMQIP(); + } } +void qTabAdvanced::AddROISlot() { + FILE_LOG(logDEBUG) << "Add ROI Slot"; -void qTabAdvanced::SetOnline(int index){ - FILE_LOG(logINFO) << "Setting Detector Online to " << index; - disconnect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - comboOnline->setCurrentIndex(myDet->setOnline(index, comboDetector->currentIndex())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetOnline"); - connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - //highlight in red if offline - if(!comboOnline->currentIndex()){ - comboOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setPalette(red); - lblOnline->setText("Online:*"); - }else{ - comboOnline->setToolTip(detOnlineTip); - lblOnline->setToolTip(detOnlineTip); - lblOnline->setPalette(lblHostname->palette()); - lblOnline->setText("Online:"); - } + QLabel* lFromX = new QLabel("x min:"); + QLabel* lFromY = new QLabel("y min:"); + QLabel* lToX = new QLabel("x max:"); + QLabel* lToY = new QLabel("y max:"); + QLabel* sFromX = new QSpinBox(); + QLabel* sFromY = new QSpinBox(); + QLabel* sToX = new QSpinBox(); + QLabel* sToY = new QSpinBox(); + lFromX->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + lFromY->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + lToX->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + lToY->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + sFromX->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + sFromY->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + sToX->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + sToY->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + lFromX->setFixedWidth(50); + lFromY->setFixedWidth(50); + lToX->setFixedWidth(50); + lToY->setFixedWidth(50); + sFromX->setFixedWidth(80); + sFromY->setFixedWidth(80); + sToX->setFixedWidth(80); + sToY->setFixedWidth(80); + sFromX->setFixedHeight(19); + sFromY->setFixedHeight(19); + sToX->setFixedHeight(19); + sToY->setFixedHeight(19); + sFromX->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X) - 1); + sToX->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X) - 1); + sFromY->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y) - 1); + sToY->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y) - 1); + sFromX->setMinimum(-1); + sToX->setMinimum(-1); + sFromY->setMinimum(-1); + sToY->setMinimum(-1); + sFromX->setValue(-1); + sFromY->setValue(-1); + sToX->setValue(-1); + sToY->setValue(-1); + lblFromX.push_back(lFromX); + lblFromY.push_back(lFromY); + lblToX.push_back(lToX); + lblToY.push_back(lToY); + spinFromX.push_back(sFromX); + spinFromY.push_back(sFromY); + spinToX.push_back(sToX); + spinToY.push_back(sToY); + + int nroi = (int)lblFromX.size(); + gridRoi->addWidget(lblFromX[nroi], i,0,Qt::AlignTop); + gridRoi->addWidget(spinFromX[nroi], i,1,Qt::AlignTop); + //FIXME: gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,2,Qt::AlignTop); + gridRoi->addWidget(lblToX[nroi], i,3,Qt::AlignTop); + gridRoi->addWidget(spinToX[nroi], i,4,Qt::AlignTop); + //FIXME: gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,5,Qt::AlignTop); + gridRoi->addWidget(lblFromY[nroi], i,6,Qt::AlignTop); + gridRoi->addWidget(spinFromY[nroi], i,7,Qt::AlignTop); + //FIXME: gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,8,Qt::AlignTop); + gridRoi->addWidget(lblToY[nroi], i,9,Qt::AlignTop); + gridRoi->addWidget(spinToY[nroi], i,10,Qt::AlignTop); + + lblFromX[nroi]->show(); + spinFromX[nroi]->show(); + lblToX[nroi]->show(); + spinToX[nroi]->show(); + lblFromY[nroi]->show(); + spinFromY[nroi]->show(); + lblToY[nroi]->show(); + spinToY[nroi]->show(); + + FILE_LOG(logDEBUG) << "ROI Inputs added"; } +void qTabAdvanced::GetROI(){ + FILE_LOG(logDEBUG) << "Getting ROI"; + ClearROIWidgets(); -void qTabAdvanced::SetNetworkParameters(){ - FILE_LOG(logINFO) << "Setting Network Parametrs"; - disconnect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - - auto moduleId = comboDetector->currentIndex(); - dispIP->setText(QString(myDet->setDetectorIP(dispIP->text().toAscii().constData(), moduleId).c_str())); - dispMAC->setText(QString(myDet->setDetectorMAC(dispMAC->text().toAscii().constData(), moduleId).c_str())); - dispUDPIP->setText(QString(myDet->setReceiverUDPIP(dispUDPIP->text().toAscii().constData(), moduleId).c_str())); - dispUDPMAC->setText(QString(myDet->setReceiverUDPMAC(dispUDPMAC->text().toAscii().constData(), moduleId).c_str())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetNetworkParameters"); - - connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); -} - - -void qTabAdvanced::SetClientZMQIP(){ - FILE_LOG(logINFO) << "Setting Client ZMQ IP"; - disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - - auto moduleId = comboDetector->currentIndex(); - myDet->setClientDataStreamingInIP(dispZMQIP->text().toAscii().constData(), moduleId); - dispZMQIP->setText(QString(myDet->getClientStreamingIP(moduleId).c_str())); - myDet->enableDataStreamingToClient(false); - myDet->enableDataStreamingToClient(true); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetClientZMQIP"); - - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); -} - - -void qTabAdvanced::SetReceiverZMQIP(){ - FILE_LOG(logINFO) << "Setting Receiver ZMQ IP"; - disconnect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - - auto moduleId = comboDetector->currentIndex(); - myDet->setReceiverDataStreamingOutIP(dispZMQIP2->text().toAscii().constData(), moduleId); - dispZMQIP2->setText(QString(myDet->getReceiverStreamingIP(moduleId).c_str())); - myDet->enableDataStreamingFromReceiver(false); - myDet->enableDataStreamingFromReceiver(true); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(),"qTabAdvanced::SetReceiverZMQIP"); - - connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); -} - - -void qTabAdvanced::SetReceiver(){ - FILE_LOG(logINFO) << "Setting Receiver"; - auto outdir = myDet->getFilePath(); - auto moduleId = comboDetector->currentIndex(); - dispRxrHostname->setText(QString(myDet->setReceiverHostname(dispRxrHostname->text().toAscii().constData(), moduleId).c_str())); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetReceiver"); - myDet->setFilePath(outdir, moduleId); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetReceiver"); - Refresh(); -} - - -void qTabAdvanced::AddROIInputSlot(){ - AddROIInput(1); -} - - -void qTabAdvanced::updateROIList(){ - FILE_LOG(logDEBUG) << "Updating ROIList"; - clearROI(); - - int n,i; - slsDetectorDefs::ROI* temp = myDet->getROI(n); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::updateROIList"); - - if((temp!=NULL)&&(n>0)){ - //assign into array, else it loses values cuz of memory - slsDetectorDefs::ROI allroi[n]; - for(i=0;isetValue(allroi[i].xmin); - spinFromY[i]->setValue(allroi[i].ymin); - spinToX[i]->setValue(allroi[i].xmax); - spinToY[i]->setValue(allroi[i].ymax); + try { + int nroi = 0; + slsDetectorDefs::ROI* roi = myDet->getROI(nroi); + if (roi != nullptr) { + for (int i = 0; i < nroi; ++i) { + AddROISlot(); + spinFromX[i]->setValue(roi[i].xmin); + spinFromY[i]->setValue(roi[i].ymin); + spinToX[i]->setValue(roi[i].xmax); + spinToY[i]->setValue(roi[i].ymax); + } + FILE_LOG(logDEBUG) << "ROIs populated: " << nroi; } - FILE_LOG(logDEBUG) << "ROIs populated: " << n; - } - - + + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not get ROI.", e.what(), "qTabAdvanced::GetROI"); + } } +void qTabAdvanced::ClearROIWidgets() { + FILE_LOG(logDEBUG) << "Clear ROI Widgets"; -void qTabAdvanced::AddROIInput(int num){ - FILE_LOG(logDEBUG) << "Add ROI Input " << num; - if((int)lblFromX.size()){ - disconnect(spinFromX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinFromY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinToX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinToY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - } - - int exists = numRois+1; - int total = exists+num; - //if cleared, addding just one - if ((num==0) && (numRois==0)){ - exists = 0; - total = 1; - }/*else{ - gridRoi->removeWidget - }*/ - - for (int i=exists;i= ((int)lblFromX.size())){ - lblFromX.resize(i+1); spinFromX.resize(i+1); - lblFromY.resize(i+1); spinFromY.resize(i+1); - lblToX.resize(i+1); spinToX.resize(i+1); - lblToY.resize(i+1); spinToY.resize(i+1); - - lblFromX[i] = new QLabel("x min:"); - lblFromY[i] = new QLabel("y min:"); - lblToX[i] = new QLabel("x max:"); - lblToY[i] = new QLabel("y max:"); - spinFromX[i] = new QSpinBox(); - spinFromY[i] = new QSpinBox(); - spinToX[i] = new QSpinBox(); - spinToY[i] = new QSpinBox(); - - - lblFromX[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblFromX[i]->setFixedWidth(50); - lblFromY[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblFromY[i]->setFixedWidth(50); - lblToX[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblToX[i]->setFixedWidth(50); - lblToY[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblToY[i]->setFixedWidth(50); - spinFromX[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); spinFromX[i]->setFixedWidth(80); - spinFromY[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); spinFromY[i]->setFixedWidth(80); - spinToX[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); spinToX[i]->setFixedWidth(80); - spinToY[i]->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); spinToY[i]->setFixedWidth(80); - spinFromX[i]->setFixedHeight(19); - spinFromY[i]->setFixedHeight(19); - spinToX[i]->setFixedHeight(19); - spinToY[i]->setFixedHeight(19); - - spinFromX[i]->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X)-1); - spinToX[i]->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::X)-1); - spinFromY[i]->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y)-1); - spinToY[i]->setMaximum(myDet->getTotalNumberOfChannels(slsDetectorDefs::Y)-1); - spinFromX[i]->setMinimum(-1); - spinToX[i]->setMinimum(-1); - spinFromY[i]->setMinimum(-1); - spinToY[i]->setMinimum(-1); - spinFromX[i]->setValue(-1); - spinFromY[i]->setValue(-1); - spinToX[i]->setValue(-1); - spinToY[i]->setValue(-1); - } - - gridRoi->addWidget(lblFromX[i], i,0,Qt::AlignTop); - gridRoi->addWidget(spinFromX[i],i,1,Qt::AlignTop); - gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,2,Qt::AlignTop); - gridRoi->addWidget(lblToX[i], i,3,Qt::AlignTop); - gridRoi->addWidget(spinToX[i], i,4,Qt::AlignTop); - gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,5,Qt::AlignTop); - gridRoi->addWidget(lblFromY[i], i,6,Qt::AlignTop); - gridRoi->addWidget(spinFromY[i],i,7,Qt::AlignTop); - gridRoi->addItem(new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed), i,8,Qt::AlignTop); - gridRoi->addWidget(lblToY[i], i,9,Qt::AlignTop); - gridRoi->addWidget(spinToY[i], i,10,Qt::AlignTop); - - lblFromX[i]->show(); - spinFromX[i]->show(); - lblToX[i]->show(); - spinToX[i]->show(); - lblFromY[i]->show(); - spinFromY[i]->show(); - lblToY[i]->show(); - spinToY[i]->show(); - } - - numRois += num; - - connect(spinFromX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - connect(spinFromY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - connect(spinToX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - connect(spinToY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - - FILE_LOG(logDEBUG) << "ROI Inputs added " << num; - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::AddROIInput"); -} - - -void qTabAdvanced::clearROI(){ - FILE_LOG(logDEBUG) << "in clearROI() "; - if((int)lblFromX.size()){ - disconnect(spinFromX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinFromY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinToX[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - disconnect(spinToY[numRois], SIGNAL(valueChanged(int)), this, SLOT(AddROIInputSlot())); - } - - for (int i=0;isetValue(-1); - spinFromY[i]->setValue(-1); - spinToX[i]->setValue(-1); - spinToY[i]->setValue(-1); - } - - - //hide widget because they are still visible even when removed and layout deleted + // hide widgets QLayoutItem *item; while((item = gridRoi->takeAt(0))) { if (item->widget()){ item->widget()->hide(); gridRoi->removeWidget(item->widget()); } - //if (item->spacerItem()) } - numRois = 0; - AddROIInput(0); - -} - - -void qTabAdvanced::setROI(){ - FILE_LOG(logINFO) << "Setting ROI"; - - slsDetectorDefs::ROI allroi[MAX_ROIS]; - - for (int i=0;ivalue(); - allroi[i].ymin = spinFromY[i]->value(); - allroi[i].xmax = spinToX[i]->value(); - allroi[i].ymax = spinToY[i]->value(); + // delete widgets + for (int i = 0; i < lblFromX.size(); ++i) { + delete lblFromX[i]; + delete spinFromX[i]; + delete lblToX[i]; + delete spinToY[i]; + delete lblFromY[i]; + delete spinFromY[i]; + delete lblToY[i]; + delete spinToY[i]; } - - myDet->setROI(numRois,allroi); - //qDefs::checkErrorMessage(myDet); - FILE_LOG(logDEBUG) << "ROIs set"; - //get the correct list back - updateROIList(); - //configuremac - myDet->configureMAC(); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::setROI"); + lblFromX.clear(); + spinFromX.clear(); + lblToX.clear(); + spinToY.clear(); + lblFromY.clear(); + spinFromY.clear(); + lblToY.clear(); + spinToY.clear(); } - -void qTabAdvanced::clearROIinDetector(){ +void qTabAdvanced::ClearROI() { FILE_LOG(logINFO) << "Clearing ROI"; - if (QMessageBox::warning(this, "Clear ROI", "Are you sure you want to clear all the ROI in detector?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes){ - clearROI(); - setROI(); + ClearROIWidgets(); + SetROI(); FILE_LOG(logDEBUG) << "ROIs cleared"; } } - -void qTabAdvanced::SetDetector(int index){ - FILE_LOG(logINFO) << "in SetDetector: " << index; - // det = myDet->getSlsDetector(comboDetector->currentIndex()); - auto moduleId = comboDetector->currentIndex(); - - spinControlPort->setValue(myDet->setControlPort(-1, moduleId)); - spinStopPort->setValue(myDet->setStopPort(-1, moduleId)); - spinTCPPort->setValue(myDet->setReceiverPort(-1, moduleId)); - spinUDPPort->setValue(myDet->getReceiverUDPPort(moduleId)); - spinZmqPort->setValue(myDet->getClientStreamingPort(moduleId)); - spinZmqPort2->setValue(myDet->getReceiverStreamingPort(moduleId)); - - dispIP->setText(myDet->getDetectorIP(moduleId).c_str()); - dispMAC->setText(myDet->getDetectorMAC(moduleId).c_str()); - dispRxrHostname->setText(myDet->getReceiverHostname(moduleId).c_str()); - dispUDPIP->setText(myDet->getReceiverUDPIP(moduleId).c_str()); - dispUDPMAC->setText(myDet->getReceiverUDPMAC(moduleId).c_str()); - dispZMQIP->setText(myDet->getClientStreamingIP(moduleId).c_str()); - dispZMQIP2->setText(myDet->getReceiverStreamingIP(moduleId).c_str()); - - - //check if its online and set it to red if offline - if(myDet->getOnline(moduleId) == slsDetectorDefs::ONLINE_FLAG) - myDet->checkOnline(moduleId); - if(myDet->getReceiverOnline(moduleId)==slsDetectorDefs::ONLINE_FLAG) - myDet->checkReceiverOnline(moduleId); - comboOnline->setCurrentIndex(myDet->getOnline(moduleId)); - comboRxrOnline->setCurrentIndex(myDet->getReceiverOnline(moduleId)); - //highlight in red if detector or receiver is offline - if(!comboOnline->currentIndex()){ - comboOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setPalette(red); - lblOnline->setText("Online:*"); - }else{ - comboOnline->setToolTip(detOnlineTip); - lblOnline->setToolTip(detOnlineTip); - lblOnline->setPalette(lblHostname->palette()); - lblOnline->setText("Online:"); - } - if(comboRxrOnline->isEnabled()){ - if(!comboRxrOnline->currentIndex()){ - comboRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setPalette(red); - lblRxrOnline->setText("Online:*"); - }else{ - comboRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setPalette(lblHostname->palette()); - lblRxrOnline->setText("Online:"); - } +void qTabAdvanced::SetROI() { + // get roi from widgets + int nroi = (int)lblFromX.size(); + slsDetectorDefs::ROI roi[nroi]; + for (int i = 0; i < nroi; ++i){ + roi[i].xmin = spinFromX[i]->value(); + roi[i].ymin = spinFromY[i]->value(); + roi[i].xmax = spinToX[i]->value(); + roi[i].ymax = spinToY[i]->value(); } + + // set roi + FILE_LOG(logINFO) << "Setting ROI:" << nroi; + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not set these ROIs." + "qTabAdvanced::SetROI", + &multiSlsDetector::setROI, nroi, roi, -1); - qDefs::checkErrorMessage(myDet, comboDetector->currentIndex(), "qTabAdvanced::SetDetector"); + // update corrected list + GetROI(); } - -void qTabAdvanced::SetAllTrimbits(){ - FILE_LOG(logINFO) << "Set all trimbits to " << spinSetAllTrimbits->value(); - myDet->setAllTrimbits(spinSetAllTrimbits->value()); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetAllTrimbits"); - updateAllTrimbitsFromServer(); - -} - - -void qTabAdvanced::updateAllTrimbitsFromServer(){ +void qTabAdvanced::GetAllTrimbits() { FILE_LOG(logDEBUG) << "Getting all trimbits value"; disconnect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); - int ret = myDet->setAllTrimbits(-1); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::updateAllTrimbitsFromServer"); - spinSetAllTrimbits->setValue(ret); + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get all trimbits value." + "qTabAdvanced::GetAllTrimbits", + spinSetAllTrimbits, + &QSpinBox::setValue, + &multiSlsDetector::setAllTrimbits, -1, -1); connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, SLOT(SetAllTrimbits())); } - -void qTabAdvanced::SetNumStoragecells(int value) { - FILE_LOG(logINFO) << "Setting number of stoarge cells to " << value; - myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,value); - - disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); - connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetNumStoragecells"); +void qTabAdvanced::SetAllTrimbits() { + int value = spinSetAllTrimbits->value(); + FILE_LOG(logINFO) << "Setting all trimbits:" << value; + try { + myDet->setAllTrimbits(value, -1); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set all trimbits.", e.what(), "qTabAdvanced::SetAllTrimbits"); + GetAllTrimbits(); + } } +void qTabAdvanced::GetNumStoragecells() { + FILE_LOG(logDEBUG) << "Getting number of additional storage cells"; + disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); -void qTabAdvanced::SetSubExposureTime() { + qDefs::IgnoreNonCriticalExceptions( + myDet, + "Could not get number of additional storage cells." + "qTabAdvanced::GetNumStoragecells", + spinNumStoragecells, + &QSpinBox::setValue, + &multiSlsDetector::setTimer, slsDetectorDefs::STORAGE_CELL_NUMBER, -1, -1); + + connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); +} + +void qTabAdvanced::SetNumStoragecells(int value) { + FILE_LOG(logINFO) << "Setting number of additional stoarge cells: " << value; + try { + myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, value, -1); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set number of additional storage cells.", e.what(), "qTabAdvanced::SetNumStoragecells"); + GetNumStoragecells(); + } +} + +void qTabAdvanced::GetSubExposureTime() { + FILE_LOG(logDEBUG) << "Getting sub exposure time"; disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime())); - //Get the value of timer in ns - double timeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(), - spinSubExpTime->value()); - - // set value - FILE_LOG(logINFO) << "Setting sub frame acquisition time to " << timeNS << " clocks" << - "/" << spinSubExpTime->value() << - qDefs::getUnitString((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()); - myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,(int64_t)timeNS); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubExposureTime"); - - // update value in gui - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)( - myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,-1)*(1E-9)))); - spinSubExpTime->setValue(time); - comboSubExpTimeUnit->setCurrentIndex((int)unit); - + try { + double value = (double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,-1) * (1E-9)); + qDefs::timeUnit unit; + double time = qDefs::getCorrectTime(unit, value); + spinSubExpTime->setValue(time); + comboSubExpTimeUnit->setCurrentIndex((int)unit); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not get sub exposure time.", e.what(), "qTabSettings::GetSubExposureTime"); + } connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); - - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubExposureTime"); } +void qTabAdvanced::SetSubExposureTime() { + double timeNS = qDefs::getNSTime((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(), spinSubExpTime->value()); + FILE_LOG(logINFO) << "Setting sub frame acquisition time to " << timeNS << " clocks" << + "/" << spinSubExpTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()); + try { + myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME, (int64_t)timeNS, -1); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set sub exposure time.", e.what(), "qTabAdvanced::SetSubExposureTime"); + } + GetSubExposureTime(); +} -void qTabAdvanced::SetSubDeadTime() { - disconnect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); +void qTabAdvanced::GetSubDeadTime() { + FILE_LOG(logDEBUG) << "Getting sub dead time"; + disconnect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); disconnect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); - //Get the value of timer in ns - double timeNS = qDefs::getNSTime( - (qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex(), - spinSubDeadTime->value()); - - // set value - FILE_LOG(logINFO) << "Setting sub dead time to " << timeNS << " clocks" << - "/" << spinSubDeadTime->value() << - qDefs::getUnitString((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex()); - myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,(int64_t)timeNS); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubDeadTime"); - - // update value in gui - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)( - myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); - spinSubDeadTime->setValue(time); - comboSubDeadTimeUnit->setCurrentIndex((int)unit); - - connect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); - connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); - - qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubDeadTime"); -} - - -void qTabAdvanced::Refresh(){ - - - FILE_LOG(logDEBUG) << endl << "**Updating Advanced Tab"; - - //network - auto moduleId = comboDetector->currentIndex(); - qDefs::checkErrorMessage(myDet,"qTabAdvanced::Refresh"); - - - - FILE_LOG(logDEBUG) << "Getting Detector Ports"; - //disconnect - disconnect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - disconnect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - disconnect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - - //so that updated status - if(myDet->getOnline(moduleId)==slsDetectorDefs::ONLINE_FLAG) - myDet->checkOnline(moduleId); - comboOnline->setCurrentIndex(myDet->getOnline(moduleId)); - spinControlPort->setValue(myDet->setControlPort(-1, moduleId)); - spinStopPort->setValue(myDet->setStopPort(-1, moduleId)); - - //connect - connect(spinControlPort, SIGNAL(valueChanged(int)), this, SLOT(SetControlPort(int))); - connect(spinStopPort, SIGNAL(valueChanged(int)), this, SLOT(SetStopPort(int))); - connect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); - - - FILE_LOG(logDEBUG) << "Getting Receiver Network Information"; - //disconnect - disconnect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - disconnect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - disconnect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - disconnect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - disconnect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - - dispIP->setText(myDet->getDetectorIP(moduleId).c_str()); - dispMAC->setText(myDet->getDetectorMAC(moduleId).c_str()); - - //so that updated status - if(myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG, moduleId)==slsDetectorDefs::ONLINE_FLAG) - myDet->checkReceiverOnline(moduleId); - comboRxrOnline->setCurrentIndex(myDet->setReceiverOnline(slsDetectorDefs::GET_ONLINE_FLAG, moduleId)); - - dispRxrHostname->setText(myDet->getReceiverHostname(moduleId).c_str()); - spinTCPPort->setValue(myDet->setReceiverPort(-1, moduleId)); - spinUDPPort->setValue(myDet->getReceiverUDPPort(moduleId)); - spinZmqPort->setValue(myDet->getClientStreamingPort(moduleId)); - spinZmqPort2->setValue(myDet->getReceiverStreamingPort(moduleId)); - - dispUDPIP->setText(myDet->getReceiverUDPIP(moduleId).c_str()); - dispUDPMAC->setText(myDet->getReceiverUDPMAC(moduleId).c_str()); - - //connect - connect(spinTCPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrTCPPort(int))); - connect(spinUDPPort, SIGNAL(valueChanged(int)), this, SLOT(SetRxrUDPPort(int))); - connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); - connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); - connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - connect(dispIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPIP, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); - connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); - - // zmq parameters - disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - dispZMQIP->setText(myDet->getClientStreamingIP(moduleId).c_str()); - connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetClientZMQIP())); - - disconnect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - dispZMQIP2->setText(myDet->getReceiverStreamingIP(moduleId).c_str()); - connect(dispZMQIP2, SIGNAL(editingFinished()), this, SLOT(SetReceiverZMQIP())); - - //highlight in red if detector or receiver is offline - if(!comboOnline->currentIndex()){ - comboOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setToolTip(detOnlineTip + errOnlineTip); - lblOnline->setPalette(red); - lblOnline->setText("Online:*"); - }else{ - comboOnline->setToolTip(detOnlineTip); - lblOnline->setToolTip(detOnlineTip); - lblOnline->setPalette(lblHostname->palette()); - lblOnline->setText("Online:"); - } - if(comboRxrOnline->isEnabled()){ - if(!comboRxrOnline->currentIndex()){ - comboRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip + errOnlineTip); - lblRxrOnline->setPalette(red); - lblRxrOnline->setText("Online:*"); - }else{ - comboRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setToolTip(rxrOnlineTip); - lblRxrOnline->setPalette(lblHostname->palette()); - lblRxrOnline->setText("Online:"); - } - } - - //roi - FILE_LOG(logDEBUG) << "Getting ROI"; - if (detType == slsDetectorDefs::GOTTHARD) - updateROIList(); - - //update alltirmbits from server - if(boxSetAllTrimbits->isEnabled()) - updateAllTrimbitsFromServer(); - - // storage cells - if (detType == slsDetectorDefs::JUNGFRAU) { - disconnect(spinNumStoragecells,SIGNAL(valueChanged(int)),this, SLOT(SetNumStoragecells(int))); - spinNumStoragecells->setValue((int)myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER,-1)); - connect(spinNumStoragecells,SIGNAL(valueChanged(int)), this, SLOT(SetNumStoragecells(int))); - } - - // sub exptime and sub dead time - else if (detType == slsDetectorDefs::EIGER) { - disconnect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - disconnect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubExposureTime())); - disconnect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); - disconnect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); - - FILE_LOG(logDEBUG) << "Getting Sub Exposure time and Sub Dead Time"; - // subexptime + try { + double value = (double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1) * (1E-9)); qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)( - myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME,-1)*(1E-9)))); - spinSubExpTime->setValue(time); - comboSubExpTimeUnit->setCurrentIndex((int)unit); - - // subdeadtime - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9)))); + double time = qDefs::getCorrectTime(unit, value); spinSubDeadTime->setValue(time); comboSubDeadTimeUnit->setCurrentIndex((int)unit); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not get sub dead time.", e.what(), "qTabSettings::GetSubDeadTime"); + } + connect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); + connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); +} - connect(spinSubExpTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubExposureTime())); - connect(comboSubExpTimeUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetSubExposureTime())); - connect(spinSubDeadTime,SIGNAL(valueChanged(double)), this, SLOT(SetSubDeadTime())); - connect(comboSubDeadTimeUnit,SIGNAL(currentIndexChanged(int)),this, SLOT(SetSubDeadTime())); +void qTabAdvanced::SetSubDeadTime() { + double timeNS = qDefs::getNSTime((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex(), spinSubDeadTime->value()); + FILE_LOG(logINFO) << "Setting sub frame dead time to " << timeNS << " clocks" << + "/" << spinSubDeadTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex()); + try { + myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME, (int64_t)timeNS, -1); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set sub dead time.", e.what(), "qTabAdvanced::SetSubDeadTime"); + } + GetSubDeadTime(); +} + + +void qTabAdvanced::Refresh(){ + FILE_LOG(logDEBUG) << endl << "**Updating Advanced Tab"; + + // trimming + if (tab_trimming->isEnabled()) { + GetAllTrimbits(); + } + + // update all network widgets + SetDetector(comboDetector->currentIndex()); + + // roi + if (gridRoi->isEnabled()) { + GetROI(); + } + + // storage cells + if (lblNumStoragecells->isEnabled()) { + GetNumStoragecells(); + } + + // subexptime, subdeadtime + if (lblSubExpTime->isEnabled()) { + GetSubExposureTime(); + GetSubDeadTime(); } FILE_LOG(logDEBUG) << "**Updated Advanced Tab"; - - qDefs::checkErrorMessage(myDet, moduleId, "qTabAdvanced::Refresh"); } diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index f0cc36e14..a51603b97 100755 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -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() { diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index 291625c36..3c800f8de 100755 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -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"); } diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index b1d48f867..a76cccdd6 100755 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -8,50 +8,51 @@ #include 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( - 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( + 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"); } diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 613034514..8ffe183ca 100755 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -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 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 diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index d4264abfb..95321eeed 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -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 diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index 231151328..dd1b56422 100755 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -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 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) { diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index 606d0e772..362dabd57 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -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 {