Guidetector (#54)

* WIP

* dacWidget

* main WIP

* advanced WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* works

* updated gui to chrono

* review fixes

* unitque ptrs in gui
This commit is contained in:
Dhanya Thattil 2019-08-26 19:14:22 +02:00 committed by GitHub
parent 7a4c1161ab
commit aafe049a9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 709 additions and 1138 deletions

View File

@ -219,39 +219,27 @@
<property name="nativeMenuBar"> <property name="nativeMenuBar">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QMenu" name="menuUtilities">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="title">
<string>&amp;Utilities</string>
</property>
<addaction name="actionOpenSetup"/>
<addaction name="actionSaveSetup"/>
<addaction name="separator"/>
<addaction name="actionOpenConfiguration"/>
<addaction name="actionSaveConfiguration"/>
<addaction name="separator"/>
<addaction name="actionLoadTrimbits"/>
<addaction name="actionSaveTrimbits"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuModes">
<property name="title">
<string>&amp;Modes</string>
</property>
<addaction name="actionDebug"/>
<addaction name="actionExpert"/>
<addaction name="actionDockable"/>
</widget>
<widget class="QMenu" name="menuHelp"> <widget class="QMenu" name="menuHelp">
<property name="title"> <property name="title">
<string>&amp;Help</string> <string>&amp;Help</string>
</property> </property>
<addaction name="actionAbout"/> <addaction name="actionAbout"/>
</widget> </widget>
<widget class="QMenu" name="menuUtilities">
<property name="title">
<string>Utilities</string>
</property>
<addaction name="actionConfigurationLoad"/>
<addaction name="actionTrimbitsLoad"/>
</widget>
<widget class="QMenu" name="menuModes">
<property name="title">
<string>Modes</string>
</property>
<addaction name="actionDebug"/>
<addaction name="actionExpert"/>
<addaction name="actionDockable"/>
</widget>
<addaction name="menuUtilities"/> <addaction name="menuUtilities"/>
<addaction name="menuModes"/> <addaction name="menuModes"/>
<addaction name="menuHelp"/> <addaction name="menuHelp"/>
@ -477,40 +465,38 @@ p, li { white-space: pre-wrap; }
<string>&amp;About</string> <string>&amp;About</string>
</property> </property>
</action> </action>
<action name="actionConfigurationLoad">
<property name="text">
<string>Load Configuration</string>
</property>
</action>
<action name="actionTrimbitsLoad">
<property name="text">
<string>Load Trimbits</string>
</property>
</action>
<action name="actionDebug">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Debug</string>
</property>
</action>
<action name="actionExpert">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Expert</string>
</property>
</action>
<action name="actionDockable"> <action name="actionDockable">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>D&amp;ockable Windows</string> <string>Dockable Windows</string>
</property>
</action>
<action name="actionLoadTrimbits">
<property name="text">
<string>&amp;Load &amp;Trimbits</string>
</property>
</action>
<action name="actionSaveTrimbits">
<property name="text">
<string>&amp;Save &amp;Trimbits</string>
</property>
</action>
<action name="actionLoadCalibration">
<property name="text">
<string>&amp;Load C&amp;alibration</string>
</property>
</action>
<action name="actionSaveCalibration">
<property name="text">
<string>&amp;Save C&amp;alibration</string>
</property>
</action>
<action name="actionListenGuiClient">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Listen to Gui Client</string>
</property> </property>
</action> </action>
</widget> </widget>

View File

@ -54,7 +54,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>2</number>
</property> </property>
<property name="elideMode"> <property name="elideMode">
<enum>Qt::ElideLeft</enum> <enum>Qt::ElideLeft</enum>
@ -418,7 +418,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Receiver UDP IP:</string> <string>Destination UDP IP:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -799,7 +799,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Receiver UDP Port:</string> <string>Destination UDP Port:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -942,7 +942,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Readout UDP MAC:</string> <string>Sourceadout UDP MAC:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -987,7 +987,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Receiver UDP MAC:</string> <string>Destination UDP MAC:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -1000,7 +1000,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Readout UDP IP:</string> <string>Source UDP IP:</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -55,6 +55,9 @@
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The file path can be different depending on the Module chosen.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="3">
@ -532,31 +535,21 @@ Compression using Root. Available only for Gotthard in Expert Mode.
<bool>false</bool> <bool>false</bool>
</property> </property>
<layout class="QGridLayout" name="gridEiger"> <layout class="QGridLayout" name="gridEiger">
<item row="1" column="2"> <item row="0" column="1">
<widget class="QComboBox" name="comboEigerFlags1"> <spacer name="horizontalSpacer_4">
<property name="minimumSize"> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size> <size>
<width>0</width> <width>10</width>
<height>25</height> <height>20</height>
</size> </size>
</property> </property>
<property name="maximumSize"> </spacer>
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Continous</string>
</property>
</item>
<item>
<property name="text">
<string>Store in RAM</string>
</property>
</item>
</widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QComboBox" name="comboEigerClkDivider"> <widget class="QComboBox" name="comboEigerClkDivider">
@ -589,7 +582,7 @@ Compression using Root. Available only for Gotthard in Expert Mode.
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="5"> <item row="1" column="4">
<spacer name="horizontalSpacer_6"> <spacer name="horizontalSpacer_6">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -618,8 +611,21 @@ Compression using Root. Available only for Gotthard in Expert Mode.
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="0" column="0">
<widget class="QComboBox" name="comboEigerFlags2"> <widget class="QLabel" name="lblClkDivider">
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Clock Divider:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="comboEigerParallelFlag">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@ -642,56 +648,6 @@ Compression using Root. Available only for Gotthard in Expert Mode.
<string>Non Parallel</string> <string>Non Parallel</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Safe</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblClkDivider">
<property name="maximumSize">
<size>
<width>105</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Clock Divider:</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -730,8 +686,6 @@ Compression using Root. Available only for Gotthard in Expert Mode.
<tabstop>radioCustomDeadtime</tabstop> <tabstop>radioCustomDeadtime</tabstop>
<tabstop>spinCustomDeadTime</tabstop> <tabstop>spinCustomDeadTime</tabstop>
<tabstop>comboEigerClkDivider</tabstop> <tabstop>comboEigerClkDivider</tabstop>
<tabstop>comboEigerFlags1</tabstop>
<tabstop>comboEigerFlags2</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../include/icons.qrc"/> <include location="../include/icons.qrc"/>

View File

@ -2,7 +2,7 @@
#include "ui_form_dac.h" #include "ui_form_dac.h"
class multiSlsDetector; #include "Detector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include <string> #include <string>
@ -11,7 +11,7 @@ class qDacWidget:public QWidget, private Ui::WidgetDacObject {
Q_OBJECT Q_OBJECT
public: public:
qDacWidget(QWidget *parent, multiSlsDetector* detector, bool d, std::string n, slsDetectorDefs::dacIndex i, bool t); qDacWidget(QWidget *parent, sls::Detector* detector, bool d, std::string n, slsDetectorDefs::dacIndex i, bool t);
~qDacWidget(); ~qDacWidget();
void SetDetectorIndex(int id); void SetDetectorIndex(int id);
@ -25,7 +25,7 @@ private:
void GetAdc(); void GetAdc();
void Refresh(); void Refresh();
multiSlsDetector *myDet; sls::Detector *det;
bool isDac{true}; bool isDac{true};
slsDetectorDefs::dacIndex index; slsDetectorDefs::dacIndex index;
bool isMillideg{false}; bool isMillideg{false};

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#include "multiSlsDetector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include <QAbstractButton> #include <QAbstractButton>
@ -10,6 +9,15 @@
#include <ostream> #include <ostream>
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
#include <chrono>
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::nanoseconds;
using std::chrono::microseconds;
using std::chrono::milliseconds;
using std::chrono::seconds;
using std::chrono::minutes;
using std::chrono::hours;
#define CATCH_DISPLAY(m, s) catch(...) { qDefs::DisplayExceptions(m, s); } #define CATCH_DISPLAY(m, s) catch(...) { qDefs::DisplayExceptions(m, s); }
#define CATCH_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); } #define CATCH_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); }
@ -145,98 +153,81 @@ class qDefs : public QWidget {
} }
}; };
/** /** returns the time in a user friendly time unit */
* returns the value in ns to send to server as the static std::pair<double, timeUnit> getUserFriendlyTime(nanoseconds tns) {
* server class slsdetector accepts in ns. if (tns < microseconds(1)) {
* @param unit unit of time return std::make_pair(tns.count(), NANOSECONDS);
* @param value time }
* returns time value in ns if (tns < milliseconds(1)) {
*/ return std::make_pair(
static double getNSTime(timeUnit unit, double value) { duration_cast<duration<double, std::micro>>(tns).count(),
double valueNS = value; MICROSECONDS);
switch (unit) { }
if (tns < seconds(1)) {
return std::make_pair(
duration_cast<duration<double, std::milli>>(tns).count(),
MILLISECONDS);
}
if (tns < minutes(1)) {
return std::make_pair(duration_cast<duration<double>>(tns).count(),
SECONDS);
}
if (tns < hours(1)) {
return std::make_pair(
duration_cast<duration<double, std::ratio<60>>>(tns).count(),
MINUTES);
}
return std::make_pair(
duration_cast<duration<double, std::ratio<3600>>>(tns).count(), HOURS);
}
/** returns the value in ns */
static nanoseconds getNSTime(std::pair<double, timeUnit> time) {
switch (time.second) {
case HOURS: case HOURS:
valueNS *= 60; return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double, std::ratio<3600>>(time.first));
case MINUTES: case MINUTES:
valueNS *= 60; return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double, std::ratio<60>>(time.first));
case SECONDS: case SECONDS:
valueNS *= 1000; return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(time.first));
case MILLISECONDS: case MILLISECONDS:
valueNS *= 1000; return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double, std::milli>(time.first));
case MICROSECONDS: case MICROSECONDS:
valueNS *= 1000; return std::chrono::duration_cast<std::chrono::nanoseconds>(
case NANOSECONDS: std::chrono::duration<double, std::micro>(time.first));
default: default:
break; return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double, std::nano>(time.first));
} }
return valueNS; }
};
/**
* returns the value in ms
* @param unit unit of time
* @param value time
* returns time value in ms
*/
static double getMSTime(timeUnit unit, double value) {
double valueMS = value;
switch (unit) {
case NANOSECONDS:
valueMS /= 1000;
case MICROSECONDS:
valueMS /= 1000;
return valueMS;
/** returns the value in ms */
static milliseconds getMSTime(std::pair<double, timeUnit> time) {
switch (time.second) {
case HOURS: case HOURS:
valueMS *= 60; return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::duration<double, std::ratio<3600>>(time.first));
case MINUTES: case MINUTES:
valueMS *= 60; return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::duration<double, std::ratio<60>>(time.first));
case SECONDS: case SECONDS:
valueMS *= 1000; return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::duration<double>(time.first));
case MILLISECONDS:
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::duration<double, std::milli>(time.first));
case MICROSECONDS:
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::duration<double, std::micro>(time.first));
default: default:
break; return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::duration<double, std::nano>(time.first));
} }
return valueMS; }
};
/**
* returns the time in the appropriate time unit
* @param value time in seconds
* returns the time in an appropriate time and unit
*/
static std::pair<double, timeUnit> getCorrectTime(double value) {
timeUnit unit;
int intUnit = (int)SECONDS;
/**0 ms*/
if (!value) {
unit = MILLISECONDS;
return std::make_pair(value, unit);
}
/** hr, min, sec */
if (value >= 1) {
double newVal = value;
while ((newVal >= 1) && (intUnit >= (int)HOURS)) {
/** value retains the old value */
value = newVal;
newVal = value / (double)60;
intUnit--;
}
/** returning the previous value*/
unit = (timeUnit)(intUnit + 1);
return std::make_pair(value, unit);
}
/** ms, us, ns */
else {
while ((value < 1) && (intUnit < (int)NANOSECONDS)) {
value = value * (double)1000;
intUnit++;
}
unit = (timeUnit)(intUnit);
return std::make_pair(value, unit);
}
};
/** /**
* displays an warning,error,info message * displays an warning,error,info message

View File

@ -13,7 +13,7 @@ class qTabDebugging;
class qTabDeveloper; class qTabDeveloper;
class qTabMessages; class qTabMessages;
class multiSlsDetector; #include "Detector.h"
#include <QTabWidget> #include <QTabWidget>
class QResizeEvent; class QResizeEvent;
@ -70,17 +70,17 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
NumberOfTabs NumberOfTabs
}; };
slsDetectorDefs::detectorType detType; slsDetectorDefs::detectorType detType;
multiSlsDetector* myDet; std::unique_ptr<sls::Detector> det;
qDrawPlot* myPlot; std::unique_ptr<qDrawPlot> plot;
MyTabWidget* tabs; std::unique_ptr<MyTabWidget> tabs;
qTabMeasurement* tabMeasurement; std::unique_ptr<qTabMeasurement> tabMeasurement;
qTabDataOutput* tabDataOutput; std::unique_ptr<qTabDataOutput> tabDataOutput;
qTabPlot* tabPlot; std::unique_ptr<qTabPlot> tabPlot;
qTabSettings* tabSettings; std::unique_ptr<qTabSettings> tabSettings;
qTabAdvanced* tabAdvanced; std::unique_ptr<qTabAdvanced> tabAdvanced;
qTabDebugging* tabDebugging; std::unique_ptr<qTabDebugging> tabDebugging;
qTabDeveloper* tabDeveloper; std::unique_ptr<qTabDeveloper> tabDeveloper;
qTabMessages* tabMessages; std::unique_ptr<qTabMessages> tabMessages;
int isDeveloper; int isDeveloper;
int heightPlotWindow; int heightPlotWindow;
int heightCentralWidget; int heightCentralWidget;

View File

@ -3,20 +3,24 @@
#include "ui_form_plot.h" #include "ui_form_plot.h"
#include "qDefs.h" #include "qDefs.h"
class detectorData;
class SlsQt1DPlot; class SlsQt1DPlot;
class SlsQtH1D; class SlsQtH1D;
class SlsQt2DPlot; class SlsQt2DPlot;
class qCloneWidget; class qCloneWidget;
class QResizeEvent;
class detectorData;
#include "Detector.h"
class QResizeEvent;
#include <QFutureWatcher> #include <QFutureWatcher>
#include <mutex>
class qDrawPlot : public QWidget, private Ui::PlotObject { class qDrawPlot : public QWidget, private Ui::PlotObject {
Q_OBJECT Q_OBJECT
public: public:
qDrawPlot(QWidget *parent, multiSlsDetector *detector); qDrawPlot(QWidget *parent, sls::Detector *detector);
~qDrawPlot(); ~qDrawPlot();
bool GetIsRunning(); bool GetIsRunning();
void SetRunning(bool enable); void SetRunning(bool enable);
@ -88,7 +92,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void Update2dXYRange(); void Update2dXYRange();
static const int NUM_PEDESTAL_FRAMES = 20; static const int NUM_PEDESTAL_FRAMES = 20;
multiSlsDetector *myDet; sls::Detector *det;
slsDetectorDefs::detectorType detType; slsDetectorDefs::detectorType detType;
SlsQt1DPlot *plot1d{nullptr}; SlsQt1DPlot *plot1d{nullptr};

View File

@ -2,20 +2,20 @@
#include "ui_form_tab_advanced.h" #include "ui_form_tab_advanced.h"
class multiSlsDetector; #include "Detector.h"
class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{ class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{
Q_OBJECT Q_OBJECT
public: public:
qTabAdvanced(QWidget *parent, multiSlsDetector* detector); qTabAdvanced(QWidget *parent, sls::Detector* detector);
~qTabAdvanced(); ~qTabAdvanced();
public slots: public slots:
void Refresh(); void Refresh();
private slots: private slots:
void SetDetector(int index); void SetDetector();
void SetControlPort(int port); void SetControlPort(int port);
void SetStopPort(int port); void SetStopPort(int port);
void SetDetectorUDPIP(); void SetDetectorUDPIP();
@ -60,7 +60,7 @@ private:
void GetSubExposureTime(); void GetSubExposureTime();
void GetSubDeadTime(); void GetSubDeadTime();
multiSlsDetector *myDet; sls::Detector *det;
}; };

View File

@ -2,13 +2,13 @@
#include "ui_form_tab_dataoutput.h" #include "ui_form_tab_dataoutput.h"
class multiSlsDetector; #include "Detector.h"
class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{ class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{
Q_OBJECT Q_OBJECT
public: public:
qTabDataOutput(QWidget *parent, multiSlsDetector* detector); qTabDataOutput(QWidget *parent, sls::Detector* detector);
~qTabDataOutput(); ~qTabDataOutput();
void Refresh(); void Refresh();
@ -38,7 +38,7 @@ public:
void GetSpeed(); void GetSpeed();
void GetFlags(); void GetFlags();
multiSlsDetector *myDet; sls::Detector *det;
// Button group for radiobuttons for rate // Button group for radiobuttons for rate
QButtonGroup *btnGroupRate; QButtonGroup *btnGroupRate;
// enum for the Eiger clock divider // enum for the Eiger clock divider
@ -48,12 +48,7 @@ public:
QUARTERSPEED, QUARTERSPEED,
NUMBEROFSPEEDS NUMBEROFSPEEDS
}; };
// enum for the Eiger readout flags1 // enum for the Eiger Parallel flag
enum {
CONTINUOUS,
STOREINRAM
};
// enum for the Eiger readout flags2
enum { enum {
PARALLEL, PARALLEL,
NONPARALLEL NONPARALLEL

View File

@ -2,7 +2,7 @@
#include "ui_form_tab_debugging.h" #include "ui_form_tab_debugging.h"
class multiSlsDetector; #include "Detector.h"
class QTreeWidget; class QTreeWidget;
class QTreeWidgetItem; class QTreeWidgetItem;
@ -11,7 +11,7 @@ class qTabDebugging:public QWidget, private Ui::TabDebuggingObject{
Q_OBJECT Q_OBJECT
public: public:
qTabDebugging(QWidget *parent, multiSlsDetector* detector); qTabDebugging(QWidget *parent, sls::Detector* detector);
~qTabDebugging(); ~qTabDebugging();
void Refresh(); void Refresh();
@ -26,7 +26,7 @@ private:
void Initialization(); void Initialization();
void PopulateDetectors(); void PopulateDetectors();
multiSlsDetector *myDet; sls::Detector *det;
/** Tree Widget displaying the detectors, modules */ /** Tree Widget displaying the detectors, modules */
QTreeWidget *treeDet; QTreeWidget *treeDet;
QLabel *lblDetectorHostname; QLabel *lblDetectorHostname;

View File

@ -3,7 +3,7 @@
#include "ui_form_tab_developer.h" #include "ui_form_tab_developer.h"
class qDacWidget; class qDacWidget;
class multiSlsDetector; #include "Detector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include <string> #include <string>
@ -13,7 +13,7 @@ class qTabDeveloper:public QWidget, private Ui::TabDeveloperObject {
Q_OBJECT Q_OBJECT
public: public:
qTabDeveloper(QWidget *parent, multiSlsDetector* detector); qTabDeveloper(QWidget *parent, sls::Detector* detector);
~qTabDeveloper(); ~qTabDeveloper();
public slots: public slots:
@ -29,7 +29,7 @@ private:
void GetHighVoltage(); void GetHighVoltage();
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, int index); slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, int index);
multiSlsDetector *myDet; sls::Detector *det;
std::vector<qDacWidget*> dacWidgets; std::vector<qDacWidget*> dacWidgets;
std::vector<qDacWidget*> adcWidgets; std::vector<qDacWidget*> adcWidgets;

View File

@ -4,7 +4,7 @@
class qDrawPlot; class qDrawPlot;
class multiSlsDetector; #include "Detector.h"
class QStandardItemModel; class QStandardItemModel;
@ -12,7 +12,7 @@ class qTabMeasurement:public QWidget, private Ui::TabMeasurementObject{
Q_OBJECT Q_OBJECT
public: public:
qTabMeasurement(QWidget *parent, multiSlsDetector* detector, qDrawPlot* plot); qTabMeasurement(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
~qTabMeasurement(); ~qTabMeasurement();
void Refresh(); void Refresh();
@ -66,8 +66,8 @@ signals:
void EnableTabsSignal(bool); void EnableTabsSignal(bool);
void FileNameChangedSignal(QString); void FileNameChangedSignal(QString);
private: private:
multiSlsDetector *myDet; sls::Detector *det;
qDrawPlot *myPlot; qDrawPlot *plot;
// enum for the timing mode // enum for the timing mode
enum{ enum{
AUTO, AUTO,

View File

@ -4,7 +4,7 @@
class qDrawPlot; class qDrawPlot;
class multiSlsDetector; #include "Detector.h"
class QButtonGroup; class QButtonGroup;
@ -12,7 +12,7 @@ class qTabPlot:public QWidget, private Ui::TabPlotObject{
Q_OBJECT Q_OBJECT
public: public:
qTabPlot(QWidget *parent,multiSlsDetector* detector, qDrawPlot* plot); qTabPlot(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
~qTabPlot(); ~qTabPlot();
void SetScanArgument(); void SetScanArgument();
void Refresh(); void Refresh();
@ -45,8 +45,8 @@ private:
void SetXYRange(); void SetXYRange();
void MaintainAspectRatio(int dimension); void MaintainAspectRatio(int dimension);
multiSlsDetector *myDet; sls::Detector *det;
qDrawPlot *myPlot; qDrawPlot *plot;
bool is1d; bool is1d;
QButtonGroup *btnGroupPlotType{nullptr}; QButtonGroup *btnGroupPlotType{nullptr};

View File

@ -2,13 +2,13 @@
#include "ui_form_tab_settings.h" #include "ui_form_tab_settings.h"
class multiSlsDetector; #include "Detector.h"
class qTabSettings: public QWidget, private Ui::TabSettingsObject{ class qTabSettings: public QWidget, private Ui::TabSettingsObject{
Q_OBJECT Q_OBJECT
public: public:
qTabSettings(QWidget *parent, multiSlsDetector* detector); qTabSettings(QWidget *parent, sls::Detector* detector);
~qTabSettings(); ~qTabSettings();
void Refresh(); void Refresh();
@ -26,7 +26,7 @@ private:
void GetDynamicRange(); void GetDynamicRange();
void GetThresholdEnergy(); void GetThresholdEnergy();
multiSlsDetector *myDet; sls::Detector *det;
enum { enum {
STANDARD, STANDARD,
FAST, FAST,

View File

@ -3,8 +3,8 @@
#include <iostream> #include <iostream>
qDacWidget::qDacWidget(QWidget *parent, multiSlsDetector *detector, bool d, std::string n, slsDetectorDefs::dacIndex i, bool t) : qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n, slsDetectorDefs::dacIndex i, bool t) :
QWidget(parent), myDet(detector), isDac(d), index(i), isMillideg(t) { QWidget(parent), det(detector), isDac(d), index(i), isMillideg(t) {
setupUi(this); setupUi(this);
SetupWidgetWindow(n); SetupWidgetWindow(n);
} }
@ -43,10 +43,10 @@ void qDacWidget::GetDac() {
disconnect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac())); disconnect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
try { try {
// dac units // dac units
auto retval = myDet->setDAC(-1, index, 0, detectorIndex); auto retval = det->getDAC(index, 0, {detectorIndex}).squash(-1);
spinDac->setValue(retval); spinDac->setValue(retval);
// mv // mv
retval = myDet->setDAC(-1, index, 1, detectorIndex); retval = det->getDAC(index, 1, {detectorIndex}).squash(-1);
lblDacmV->setText(QString("%1mV").arg(retval -10)); lblDacmV->setText(QString("%1mV").arg(retval -10));
} CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index), "qDacWidget::GetDac") } CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index), "qDacWidget::GetDac")
@ -59,7 +59,7 @@ void qDacWidget::SetDac() {
FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data() << " : " << val; FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data() << " : " << val;
try { try {
myDet->setDAC(val, index, 0, detectorIndex); det->setDAC(val, index, 0, {detectorIndex});
} CATCH_DISPLAY (std::string("Could not set dac ") + std::to_string(index), "qDacWidget::SetDac") } CATCH_DISPLAY (std::string("Could not set dac ") + std::to_string(index), "qDacWidget::SetDac")
// update mV anyway // update mV anyway
@ -70,7 +70,7 @@ void qDacWidget::GetAdc() {
FILE_LOG(logDEBUG) << "Getting ADC " << index; FILE_LOG(logDEBUG) << "Getting ADC " << index;
try { try {
auto retval = myDet->getADC(index, detectorIndex); auto retval = det->getTemperature(index, {detectorIndex}).squash(-1);
if (retval == -1 && detectorIndex == -1) { if (retval == -1 && detectorIndex == -1) {
spinDac->setValue(-1); spinDac->setValue(-1);
} else { } else {

View File

@ -115,51 +115,28 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
SetUpWidgetWindow(); SetUpWidgetWindow();
} }
qDetectorMain::~qDetectorMain() { qDetectorMain::~qDetectorMain() {}
if (myDet)
delete myDet;
if (myPlot)
delete myPlot;
if (tabs)
delete tabs;
if (tabMeasurement)
delete tabMeasurement;
if (tabDataOutput)
delete tabDataOutput;
if (tabPlot)
delete tabPlot;
if (tabSettings)
delete tabSettings;
if (tabAdvanced)
delete tabAdvanced;
if (tabDebugging)
delete tabDebugging;
if (tabDeveloper)
delete tabDeveloper;
if (tabMessages)
delete tabMessages;
}
void qDetectorMain::SetUpWidgetWindow() { void qDetectorMain::SetUpWidgetWindow() {
setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
// plot setup // plot setup
myPlot = new qDrawPlot(dockWidgetPlot, myDet); plot = sls::make_unique<qDrawPlot>(dockWidgetPlot, det.get());
FILE_LOG(logDEBUG) << "DockPlot ready"; FILE_LOG(logDEBUG) << "DockPlot ready";
dockWidgetPlot->setWidget(myPlot); dockWidgetPlot->setWidget(plot.get());
// tabs setup // tabs setup
tabs = new MyTabWidget(this); tabs = sls::make_unique<MyTabWidget>(this);
layoutTabs->addWidget(tabs); layoutTabs->addWidget(tabs.get());
// creating all the other tab widgets // creating all the other tab widgets
tabMeasurement = new qTabMeasurement(this, myDet, myPlot); tabMeasurement = sls::make_unique<qTabMeasurement>(this, det.get(), plot.get());
tabDataOutput = new qTabDataOutput(this, myDet); tabDataOutput = sls::make_unique<qTabDataOutput>(this, det.get());
tabPlot = new qTabPlot(this, myDet, myPlot); tabPlot = sls::make_unique<qTabPlot>(this, det.get(), plot.get());
tabSettings = new qTabSettings(this, myDet); tabSettings = sls::make_unique<qTabSettings>(this, det.get());
tabAdvanced = new qTabAdvanced(this, myDet); tabAdvanced = sls::make_unique<qTabAdvanced>(this, det.get());
tabDebugging = new qTabDebugging(this, myDet); tabDebugging = sls::make_unique<qTabDebugging>(this, det.get());
tabDeveloper = new qTabDeveloper(this, myDet); tabDeveloper = sls::make_unique<qTabDeveloper>(this, det.get());
// creating the scroll area widgets for the tabs // creating the scroll area widgets for the tabs
QScrollArea *scroll[NumberOfTabs]; QScrollArea *scroll[NumberOfTabs];
@ -168,13 +145,13 @@ void qDetectorMain::SetUpWidgetWindow() {
scroll[i]->setFrameShape(QFrame::NoFrame); scroll[i]->setFrameShape(QFrame::NoFrame);
} }
// setting the tab widgets to the scrollareas // setting the tab widgets to the scrollareas
scroll[MEASUREMENT]->setWidget(tabMeasurement); scroll[MEASUREMENT]->setWidget(tabMeasurement.get());
scroll[DATAOUTPUT]->setWidget(tabDataOutput); scroll[DATAOUTPUT]->setWidget(tabDataOutput.get());
scroll[PLOT]->setWidget(tabPlot); scroll[PLOT]->setWidget(tabPlot.get());
scroll[SETTINGS]->setWidget(tabSettings); scroll[SETTINGS]->setWidget(tabSettings.get());
scroll[ADVANCED]->setWidget(tabAdvanced); scroll[ADVANCED]->setWidget(tabAdvanced.get());
scroll[DEBUGGING]->setWidget(tabDebugging); scroll[DEBUGGING]->setWidget(tabDebugging.get());
scroll[DEVELOPER]->setWidget(tabDeveloper); scroll[DEVELOPER]->setWidget(tabDeveloper.get());
// inserting all the tabs // inserting all the tabs
tabs->insertTab(MEASUREMENT, scroll[MEASUREMENT], "Measurement"); tabs->insertTab(MEASUREMENT, scroll[MEASUREMENT], "Measurement");
tabs->insertTab(DATAOUTPUT, scroll[DATAOUTPUT], "Data Output"); tabs->insertTab(DATAOUTPUT, scroll[DATAOUTPUT], "Data Output");
@ -184,17 +161,17 @@ void qDetectorMain::SetUpWidgetWindow() {
tabs->insertTab(DEBUGGING, scroll[DEBUGGING], "Debugging"); tabs->insertTab(DEBUGGING, scroll[DEBUGGING], "Debugging");
tabs->insertTab(DEVELOPER, scroll[DEVELOPER], "Developer"); tabs->insertTab(DEVELOPER, scroll[DEVELOPER], "Developer");
// no scroll buttons this way // no scroll buttons this way
tabs->insertTab(MESSAGES, tabMessages, "Terminal"); tabs->insertTab(MESSAGES, tabMessages.get(), "Terminal");
// swap tabs so that messages is last tab // swap tabs so that messages is last tab
tabs->tabBar()->moveTab(tabs->indexOf(tabMeasurement), MEASUREMENT); tabs->tabBar()->moveTab(tabs->indexOf(tabMeasurement.get()), MEASUREMENT);
tabs->tabBar()->moveTab(tabs->indexOf(tabSettings), SETTINGS); tabs->tabBar()->moveTab(tabs->indexOf(tabSettings.get()), SETTINGS);
tabs->tabBar()->moveTab(tabs->indexOf(tabDataOutput), DATAOUTPUT); tabs->tabBar()->moveTab(tabs->indexOf(tabDataOutput.get()), DATAOUTPUT);
tabs->tabBar()->moveTab(tabs->indexOf(tabPlot), PLOT); tabs->tabBar()->moveTab(tabs->indexOf(tabPlot.get()), PLOT);
tabs->tabBar()->moveTab(tabs->indexOf(tabAdvanced), ADVANCED); tabs->tabBar()->moveTab(tabs->indexOf(tabAdvanced.get()), ADVANCED);
tabs->tabBar()->moveTab(tabs->indexOf(tabDebugging), DEBUGGING); tabs->tabBar()->moveTab(tabs->indexOf(tabDebugging.get()), DEBUGGING);
tabs->tabBar()->moveTab(tabs->indexOf(tabDeveloper), DEVELOPER); tabs->tabBar()->moveTab(tabs->indexOf(tabDeveloper.get()), DEVELOPER);
tabs->tabBar()->moveTab(tabs->indexOf(tabMessages), MESSAGES); tabs->tabBar()->moveTab(tabs->indexOf(tabMessages.get()), MESSAGES);
tabs->setCurrentIndex(MEASUREMENT); tabs->setCurrentIndex(MEASUREMENT);
// other tab properties // other tab properties
@ -213,8 +190,7 @@ void qDetectorMain::SetUpWidgetWindow() {
tabs->setTabEnabled(DEBUGGING, false); tabs->setTabEnabled(DEBUGGING, false);
tabs->setTabEnabled(ADVANCED, false); tabs->setTabEnabled(ADVANCED, false);
tabs->setTabEnabled(DEVELOPER, isDeveloper); tabs->setTabEnabled(DEVELOPER, isDeveloper);
actionLoadTrimbits->setVisible(false); actionTrimbitsLoad->setVisible(false);
actionSaveTrimbits->setVisible(false);
dockWidgetPlot->setFloating(false); dockWidgetPlot->setFloating(false);
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
@ -232,40 +208,37 @@ void qDetectorMain::SetUpWidgetWindow() {
void qDetectorMain::SetUpDetector(const std::string fName, int multiID) { void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
// instantiate detector and set window title // instantiate detector and set window title
myDet = new multiSlsDetector(multiID); det = sls::make_unique<sls::Detector>(multiID);
// create messages tab to capture config file loading logs // create messages tab to capture config file loading logs
tabMessages = new qTabMessages(this); tabMessages = sls::make_unique<qTabMessages>(this);
// loads the config file at startup // loads the config file at startup
if (!fName.empty()) if (!fName.empty())
LoadConfigFile(fName); LoadConfigFile(fName);
// validate detector type (for GUI) and update menu // validate detector type (for GUI) and update menu
detType = myDet->getDetectorTypeAsEnum(); detType = det->getDetectorType().tsquash("Different detector type for all modules.");
actionTrimbitsLoad->setEnabled(false);
switch (detType) { switch (detType) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
actionTrimbitsLoad->setEnabled(true);
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
actionLoadTrimbits->setText("Load Settings");
actionSaveTrimbits->setText("Save Settings");
break;
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
actionLoadTrimbits->setEnabled(false); break;
actionSaveTrimbits->setEnabled(false);
break;
default: default:
std::string errorMess = std::string errorMess =
myDet->getHostname() + std::string(" has ") + sls::ToString(det->getHostname(), ',') + " has " +
myDet->getDetectorTypeAsString() + std::string(" detector type (") + slsDetectorDefs::detectorTypeToString(det->getDetectorType().squash()) + " detector type (" +
std::to_string(detType) + std::string("). Exiting GUI."); std::to_string(detType) + "). Exiting GUI.";
throw sls::RuntimeError(errorMess.c_str()); throw sls::RuntimeError(errorMess.c_str());
} }
std::string title = std::string title =
"SLS Detector GUI : " + myDet->getDetectorTypeAsString() + " - " + "SLS Detector GUI : " + slsDetectorDefs::detectorTypeToString(det->getDetectorType().squash()) + " - " +
myDet->getHostname(); sls::ToString(det->getHostname(), ',');
FILE_LOG(logINFO) << title; FILE_LOG(logINFO) << title;
setWindowTitle(QString(title.c_str())); setWindowTitle(QString(title.c_str()));
} }
@ -274,16 +247,16 @@ void qDetectorMain::Initialization() {
// Dockable Plot // Dockable Plot
connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this, SLOT(ResizeMainWindow(bool))); connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this, SLOT(ResizeMainWindow(bool)));
// tabs // tabs
connect(tabs,SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*))); connect(tabs.get(),SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*)));
// Measurement tab // Measurement tab
connect(tabMeasurement, SIGNAL(EnableTabsSignal(bool)), this, SLOT(EnableTabs(bool))); connect(tabMeasurement.get(), SIGNAL(EnableTabsSignal(bool)), this, SLOT(EnableTabs(bool)));
connect(tabMeasurement, SIGNAL(FileNameChangedSignal(QString)), myPlot, SLOT(SetSaveFileName(QString))); connect(tabMeasurement.get(), SIGNAL(FileNameChangedSignal(QString)), plot.get(), SLOT(SetSaveFileName(QString)));
// Plot tab // Plot tab
connect(tabPlot, SIGNAL(DisableZoomSignal(bool)), this, SLOT(SetZoomToolTip(bool))); connect(tabPlot.get(), SIGNAL(DisableZoomSignal(bool)), this, SLOT(SetZoomToolTip(bool)));
// Plotting // Plotting
connect(myPlot, SIGNAL(AcquireFinishedSignal()), tabMeasurement, SLOT(AcquireFinished())); connect(plot.get(), SIGNAL(AcquireFinishedSignal()), tabMeasurement.get(), SLOT(AcquireFinished()));
connect(myPlot, SIGNAL(AbortSignal()), tabMeasurement, SLOT(AbortAcquire())); connect(plot.get(), SIGNAL(AbortSignal()), tabMeasurement.get(), SLOT(AbortAcquire()));
// menubar // menubar
// Modes Menu // Modes Menu
@ -324,7 +297,7 @@ void qDetectorMain::LoadConfigFile(const std::string fName) {
FILE_LOG(logWARNING) << "File not recognized"; FILE_LOG(logWARNING) << "File not recognized";
} else { } else {
try { try {
myDet->readConfigurationFile(fName); det->loadConfig(fName);
} CATCH_DISPLAY ("Could not load config file.", "qDetectorMain::LoadConfigFile") } CATCH_DISPLAY ("Could not load config file.", "qDetectorMain::LoadConfigFile")
} }
} }
@ -346,8 +319,7 @@ void qDetectorMain::EnableModes(QAction *action) {
enable = actionExpert->isChecked(); enable = actionExpert->isChecked();
tabs->setTabEnabled(ADVANCED, enable); tabs->setTabEnabled(ADVANCED, enable);
actionLoadTrimbits->setVisible(enable && detType != slsDetectorDefs::MOENCH); actionTrimbitsLoad->setVisible(enable && detType == slsDetectorDefs::EIGER);
actionSaveTrimbits->setVisible(enable && detType != slsDetectorDefs::MOENCH);
FILE_LOG(logINFO) << "Expert Mode: " FILE_LOG(logINFO) << "Expert Mode: "
<< slsDetectorDefs::stringEnable(enable); << slsDetectorDefs::stringEnable(enable);
} }
@ -369,53 +341,17 @@ void qDetectorMain::EnableModes(QAction *action) {
void qDetectorMain::ExecuteUtilities(QAction *action) { void qDetectorMain::ExecuteUtilities(QAction *action) {
bool refreshTabs = false; bool refreshTabs = false;
try { try {
if (action == actionOpenSetup) {
FILE_LOG(logDEBUG) << "Loading Setup";
QString fName = QString(myDet->getFilePath().c_str());
fName = QFileDialog::getOpenFileName(
this, tr("Load Detector Setup"), fName,
tr("Detector Setup files (*.det);;All Files(*)"));
// Gets called when cancelled as well
if (!fName.isEmpty()) {
refreshTabs = true;
myDet->retrieveDetectorSetup(
std::string(fName.toAscii().constData()));
qDefs::Message(
qDefs::INFORMATION,
"The Setup Parameters have been loaded successfully.",
"qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) << "Setup Parameters loaded successfully";
}
}
else if (action == actionSaveSetup) { if (action == actionConfigurationLoad) {
FILE_LOG(logDEBUG) << "Saving Setup";
QString fName = QString(myDet->getFilePath().c_str());
fName = QFileDialog::getSaveFileName(
this, tr("Save Current Detector Setup"), fName,
tr("Detector Setup files (*.det);;All Files(*) "));
// Gets called when cancelled as well
if (!fName.isEmpty()) {
myDet->dumpDetectorSetup(
std::string(fName.toAscii().constData()));
qDefs::Message(
qDefs::INFORMATION,
"The Setup Parameters have been saved successfully.",
"qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) << "Setup Parameters saved successfully";
}
}
else if (action == actionOpenConfiguration) {
FILE_LOG(logDEBUG) << "Loading Configuration"; FILE_LOG(logDEBUG) << "Loading Configuration";
QString fName = QString(myDet->getFilePath().c_str()); QString fName = QString(det->getFilePath().squash("/tmp/").c_str());
fName = QFileDialog::getOpenFileName( fName = QFileDialog::getOpenFileName(
this, tr("Load Detector Configuration"), fName, this, tr("Load Detector Configuration"), fName,
tr("Configuration files (*.config);;All Files(*)")); tr("Configuration files (*.config);;All Files(*)"));
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()) { if (!fName.isEmpty()) {
refreshTabs = true; refreshTabs = true;
myDet->readConfigurationFile( det->loadConfig(
std::string(fName.toAscii().constData())); std::string(fName.toAscii().constData()));
qDefs::Message(qDefs::INFORMATION, qDefs::Message(qDefs::INFORMATION,
"The Configuration Parameters have been " "The Configuration Parameters have been "
@ -426,107 +362,30 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
} }
} }
else if (action == actionSaveConfiguration) { else if (action == actionTrimbitsLoad) {
FILE_LOG(logDEBUG) << "Saving Configuration"; QString fName = QString((det->getSettingsDir().squash("/tmp/")).c_str());
QString fName = QString(myDet->getFilePath().c_str()); FILE_LOG(logDEBUG) << "Loading Trimbits";
fName = QFileDialog::getSaveFileName( // so that even nonexisting files can be selected
this, tr("Save Current Detector Configuration"), fName, QFileDialog *fileDialog = new QFileDialog(
tr("Configuration files (*.config) ;;All Files(*)")); this, tr("Load Detector Trimbits"), fName,
tr("Trimbit files (*.trim noise.sn*);;All Files(*)"));
fileDialog->setFileMode(QFileDialog::AnyFile);
if (fileDialog->exec() == QDialog::Accepted)
fName = fileDialog->selectedFiles()[0];
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()) { if (!fName.isEmpty()) {
myDet->writeConfigurationFile( det->loadTrimbits(
std::string(fName.toAscii().constData())); std::string(fName.toAscii().constData()));
qDefs::Message(qDefs::INFORMATION, qDefs::Message(
"The Configuration Parameters have been saved " qDefs::INFORMATION,
"successfully.", "The Trimbits have been loaded successfully.",
"qDetectorMain::ExecuteUtilities"); "qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) FILE_LOG(logINFO) << "Trimbits loaded successfully";
<< "Configuration Parameters saved successfully";
} }
} }
else if (action == actionLoadTrimbits) {
QString fName = QString((myDet->getSettingsDir()).c_str());
// gotthard
if (actionLoadTrimbits->text().contains("Settings")) {
FILE_LOG(logDEBUG) << "Loading Settings";
fName = QFileDialog::getOpenFileName(
this, tr("Load Detector Settings"), fName,
tr("Settings files (*.settings settings.sn*);;All "
"Files(*)"));
// Gets called when cancelled as well
if (!fName.isEmpty()) {
myDet->loadSettingsFile(
std::string(fName.toAscii().constData()), -1);
qDefs::Message(
qDefs::INFORMATION,
"The Settings have been loaded successfully.",
"qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) << "Settings loaded successfully";
}
} // mythen and eiger
else {
FILE_LOG(logDEBUG) << "Loading Trimbits";
// so that even nonexisting files can be selected
QFileDialog *fileDialog = new QFileDialog(
this, tr("Load Detector Trimbits"), fName,
tr("Trimbit files (*.trim noise.sn*);;All Files(*)"));
fileDialog->setFileMode(QFileDialog::AnyFile);
if (fileDialog->exec() == QDialog::Accepted)
fName = fileDialog->selectedFiles()[0];
// Gets called when cancelled as well
if (!fName.isEmpty()) {
myDet->loadSettingsFile(
std::string(fName.toAscii().constData()), -1);
qDefs::Message(
qDefs::INFORMATION,
"The Trimbits have been loaded successfully.",
"qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) << "Trimbits loaded successfully";
}
}
}
else if (action == actionSaveTrimbits) {
// gotthard
if (actionLoadTrimbits->text().contains("Settings")) {
FILE_LOG(logDEBUG) << "Saving Settings";
// different output directory so as not to overwrite
QString fName = QString((myDet->getSettingsDir()).c_str());
fName = QFileDialog::getSaveFileName(
this, tr("Save Current Detector Settings"), fName,
tr("Settings files (*.settings settings.sn*);;All "
"Files(*) "));
// Gets called when cancelled as well
if (!fName.isEmpty()) {
myDet->saveSettingsFile(
std::string(fName.toAscii().constData()), -1);
qDefs::Message(qDefs::INFORMATION,
"The Settings have been saved successfully.",
"qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) << "Settings saved successfully";
}
} // mythen and eiger
else {
FILE_LOG(logDEBUG) << "Saving Trimbits";
// different output directory so as not to overwrite
QString fName = QString((myDet->getSettingsDir()).c_str());
fName = QFileDialog::getSaveFileName(
this, tr("Save Current Detector Trimbits"), fName,
tr("Trimbit files (*.trim noise.sn*) ;;All Files(*)"));
// Gets called when cancelled as well
if (!fName.isEmpty()) {
myDet->saveSettingsFile(
std::string(fName.toAscii().constData()), -1);
qDefs::Message(qDefs::INFORMATION,
"The Trimbits have been saved successfully.",
"qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) << "Trimbits saved successfully";
}
}
}
} CATCH_DISPLAY ("Could not execute utilities.", "qDetectorMain::ExecuteUtilities") } CATCH_DISPLAY ("Could not execute utilities.", "qDetectorMain::ExecuteUtilities")
Refresh(tabs->currentIndex()); Refresh(tabs->currentIndex());
@ -552,7 +411,7 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
std::string guiVersion = std::to_string(APIGUI); std::string guiVersion = std::to_string(APIGUI);
std::string clientVersion = "unknown"; std::string clientVersion = "unknown";
try { try {
clientVersion = std::to_string(myDet->getId(slsDetectorDefs::THIS_SOFTWARE_VERSION)); clientVersion = std::to_string(det->getClientVersion());
} CATCH_DISPLAY ("Could not get client version.", "qDetectorMain::ExecuteHelp") } CATCH_DISPLAY ("Could not get client version.", "qDetectorMain::ExecuteHelp")
qDefs::Message(qDefs::INFORMATION, qDefs::Message(qDefs::INFORMATION,
@ -660,10 +519,7 @@ void qDetectorMain::EnableTabs(bool enable) {
tabs->setTabEnabled(MESSAGES, enable); tabs->setTabEnabled(MESSAGES, enable);
// actions check // actions check
actionOpenSetup->setEnabled(enable); actionConfigurationLoad->setEnabled(enable);
actionSaveSetup->setEnabled(enable);
actionOpenConfiguration->setEnabled(enable);
actionSaveConfiguration->setEnabled(enable);
actionDebug->setEnabled(enable); actionDebug->setEnabled(enable);
actionExpert->setEnabled(enable); actionExpert->setEnabled(enable);
@ -673,8 +529,7 @@ void qDetectorMain::EnableTabs(bool enable) {
// expert // expert
bool expertTab = enable && (actionExpert->isChecked()); bool expertTab = enable && (actionExpert->isChecked());
tabs->setTabEnabled(ADVANCED, expertTab); tabs->setTabEnabled(ADVANCED, expertTab);
actionLoadTrimbits->setVisible(expertTab && detType != slsDetectorDefs::MOENCH); actionTrimbitsLoad->setVisible(expertTab && detType == slsDetectorDefs::EIGER);
actionSaveTrimbits->setVisible(expertTab && detType != slsDetectorDefs::MOENCH);
// moved to here, so that its all in order, instead of signals and different // moved to here, so that its all in order, instead of signals and different
// threads // threads
@ -690,7 +545,7 @@ void qDetectorMain::EnableTabs(bool enable) {
tabDeveloper->Refresh(); tabDeveloper->Refresh();
tabPlot->Refresh(); tabPlot->Refresh();
myPlot->StartAcquisition(); plot->StartAcquisition();
} else { // to enable scan box } else { // to enable scan box
tabPlot->Refresh(); tabPlot->Refresh();
// to start adc timer // to start adc timer

View File

@ -5,13 +5,15 @@
#include "detectorData.h" #include "detectorData.h"
#include "qCloneWidget.h" #include "qCloneWidget.h"
#include "detectorData.h"
#include <QFileDialog> #include <QFileDialog>
#include <QPainter> #include <QPainter>
#include <QtConcurrentRun> #include <QtConcurrentRun>
#include <QResizeEvent> #include <QResizeEvent>
qDrawPlot::qDrawPlot(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector) { qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logINFO) << "Plots ready"; FILE_LOG(logINFO) << "Plots ready";
@ -48,12 +50,12 @@ qDrawPlot::~qDrawPlot() {
} }
void qDrawPlot::SetupWidgetWindow() { void qDrawPlot::SetupWidgetWindow() {
detType = myDet->getDetectorTypeAsEnum(); detType = det->getDetectorType().squash();
// save // save
try { try {
std::string temp = myDet->getFilePath(); std::string temp = det->getFilePath().squash("/tmp/");
fileSavePath = QString(temp.c_str()); fileSavePath = QString(temp.c_str());
temp = myDet->getFileName(); temp = det->getFileNamePrefix().squash("xxx");
fileSaveName = QString(temp.c_str()); fileSaveName = QString(temp.c_str());
} catch (const std::exception &e) { } catch (const std::exception &e) {
qDefs::ExceptionMessage("Could not get file path or file name.", e.what(), "qDrawPlot::SetupWidgetWindow"); qDefs::ExceptionMessage("Could not get file path or file name.", e.what(), "qDrawPlot::SetupWidgetWindow");
@ -63,7 +65,7 @@ void qDrawPlot::SetupWidgetWindow() {
SetupPlots(); SetupPlots();
SetDataCallBack(true); SetDataCallBack(true);
myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this); det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this);
// future watcher to watch result of AcquireThread only because it uses signals/slots to handle acquire exception // future watcher to watch result of AcquireThread only because it uses signals/slots to handle acquire exception
acqResultWatcher = new QFutureWatcher<std::string>(); acqResultWatcher = new QFutureWatcher<std::string>();
@ -79,23 +81,27 @@ void qDrawPlot::SetupPlots() {
setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
// default image size // default image size
slsDetectorDefs::xy res = myDet->getNumberOfChannels(); slsDetectorDefs::xy res = det->getDetectorSize();
nPixelsX = res.x; nPixelsX = res.x;
nPixelsY = res.y; nPixelsY = res.y;
switch(detType) { switch(detType) {
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES, -1) * 2)/25;// for moench 03 try{
nPixelsX = npixelsx_jctb; npixelsy_jctb = (det->getNumberOfAnalogSamples().tsquash("Inconsistent values for number of analog samples") * 2)/25;// for moench 03
nPixelsY = npixelsy_jctb; nPixelsX = npixelsx_jctb;
nPixelsY = npixelsy_jctb;
} CATCH_DISPLAY ("Could not get number of analog samples.", "qDrawPlot::SetupPlots")
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
if (myDet->getQuad()) { try{
nPixelsX /= 2; if (det->getQuad().tsquash("Inconsistent values for quad type")) {
nPixelsY *= 2; nPixelsX /= 2;
if (nPixelsX != nPixelsY) { nPixelsY *= 2;
--nPixelsX; if (nPixelsX != nPixelsY) {
--nPixelsX;
}
} }
} } CATCH_DISPLAY ("Could not get quad.", "qDrawPlot::SetupPlots")
break; break;
default: default:
break; break;
@ -310,10 +316,10 @@ void qDrawPlot::SetDataCallBack(bool enable) {
FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable << std::noboolalpha;
if (enable) { if (enable) {
isPlot = true; isPlot = true;
myDet->registerDataCallback(&(GetDataCallBack), this); det->registerDataCallback(&(GetDataCallBack), this);
} else { } else {
isPlot = false; isPlot = false;
myDet->registerDataCallback(nullptr, this); det->registerDataCallback(nullptr, this);
} }
} }
@ -527,25 +533,13 @@ void qDrawPlot::StartAcquisition() {
progress = 0; progress = 0;
currentFrame = 0; currentFrame = 0;
boxPlot->setTitle("Old Plot"); boxPlot->setTitle("Old Plot");
// check acquiring flag (from previous exit) or if running det->clearAcquiringFlag(); // (from previous exit) or if running
try{
if (myDet->getAcquiringFlag()) {
if (myDet->getRunStatus() != slsDetectorDefs::IDLE) {
qDefs::Message(qDefs::WARNING, "Could not start acquisition as it is already in progress.\nClick start when finished.", "qDrawPlot::StartAcquisition");
emit AbortSignal();
return;
} else {
myDet->setAcquiringFlag(false);
}
}
} CATCH_DISPLAY("Could not get detector stats.", "qDrawPlot::StartAcquisition");
// ensure data streaming in receiver (if plot enabled) // ensure data streaming in receiver (if plot enabled)
if (isPlot) { if (isPlot) {
try { try {
if (myDet->enableDataStreamingFromReceiver() != 1) { if (!det->getRxZmqDataStream().squash(false)) {
myDet->enableDataStreamingFromReceiver(1); det->setRxZmqDataStream(true);
} }
} CATCH_DISPLAY("Could not enable data streaming in Receiver.", "qDrawPlot::StartAcquisition"); } CATCH_DISPLAY("Could not enable data streaming in Receiver.", "qDrawPlot::StartAcquisition");
} }
@ -571,8 +565,7 @@ void qDrawPlot::AcquireFinished() {
FILE_LOG(logERROR) << "Acquisition Finished with an exception: " << mess; FILE_LOG(logERROR) << "Acquisition Finished with an exception: " << mess;
qDefs::ExceptionMessage("Acquire unsuccessful.", mess, "qDrawPlot::AcquireFinished"); qDefs::ExceptionMessage("Acquire unsuccessful.", mess, "qDrawPlot::AcquireFinished");
try{ try{
myDet->stopAcquisition(); det->stopAcquisition();
myDet->stopReceiver();
} CATCH_DISPLAY("Could not stop acquisition and receiver.", "qDrawPlot::AcquireFinished"); } CATCH_DISPLAY("Could not stop acquisition and receiver.", "qDrawPlot::AcquireFinished");
emit AbortSignal(); emit AbortSignal();
} }
@ -582,7 +575,7 @@ void qDrawPlot::AcquireFinished() {
std::string qDrawPlot::AcquireThread() { std::string qDrawPlot::AcquireThread() {
FILE_LOG(logDEBUG) << "Acquire Thread"; FILE_LOG(logDEBUG) << "Acquire Thread";
try { try {
myDet->acquire(); det->acquire();
} catch (const std::exception &e) { } catch (const std::exception &e) {
return std::string(e.what()); return std::string(e.what());
} }

View File

@ -1,10 +1,11 @@
#include "qTabAdvanced.h" #include "qTabAdvanced.h"
#include "qDefs.h" #include "qDefs.h"
#include "network_utils.h"
#include <iostream> #include <iostream>
qTabAdvanced::qTabAdvanced(QWidget *parent, multiSlsDetector *detector) qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector)
: QWidget(parent), myDet(detector) { : QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Advanced ready"; FILE_LOG(logDEBUG) << "Advanced ready";
@ -14,7 +15,7 @@ qTabAdvanced::~qTabAdvanced() {}
void qTabAdvanced::SetupWidgetWindow() { void qTabAdvanced::SetupWidgetWindow() {
// enabling according to det type // enabling according to det type
switch (myDet->getDetectorTypeAsEnum()) { switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
tab_trimming->setEnabled(true); tab_trimming->setEnabled(true);
lblSubExpTime->setEnabled(true); lblSubExpTime->setEnabled(true);
@ -55,7 +56,7 @@ void qTabAdvanced::Initialization() {
// network // network
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector(int))); SLOT(SetDetector()));
connect(spinControlPort, SIGNAL(valueChanged(int)), this, connect(spinControlPort, SIGNAL(valueChanged(int)), this,
SLOT(SetControlPort(int))); SLOT(SetControlPort(int)));
connect(spinStopPort, SIGNAL(valueChanged(int)), this, connect(spinStopPort, SIGNAL(valueChanged(int)), this,
@ -109,20 +110,21 @@ void qTabAdvanced::Initialization() {
void qTabAdvanced::PopulateDetectors() { void qTabAdvanced::PopulateDetectors() {
FILE_LOG(logDEBUG) << "Populating detectors"; FILE_LOG(logDEBUG) << "Populating detectors";
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector(int))); SLOT(SetDetector()));
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI())); disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
comboDetector->clear(); comboDetector->clear();
comboReadout->clear(); comboReadout->clear();
for (unsigned int i = 0; i < myDet->size(); ++i) { auto res = det->getHostname();
comboDetector->addItem(QString(myDet->getHostname(i).c_str())); for (auto &it : res) {
comboReadout->addItem(QString(myDet->getHostname(i).c_str())); comboDetector->addItem(QString(it.c_str()));
comboReadout->addItem(QString(it.c_str()));
} }
comboDetector->setCurrentIndex(0); comboDetector->setCurrentIndex(0);
comboReadout->setCurrentIndex(0); comboReadout->setCurrentIndex(0);
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector(int))); SLOT(SetDetector()));
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI())); connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
} }
@ -132,7 +134,7 @@ void qTabAdvanced::GetControlPort() {
SLOT(SetControlPort(int))); SLOT(SetControlPort(int)));
try { try {
int retval = myDet->setControlPort(-1, comboDetector->currentIndex()); int retval = det->getControlPort({comboDetector->currentIndex()})[0];
spinControlPort->setValue(retval); spinControlPort->setValue(retval);
} CATCH_DISPLAY ("Could not get detector control port.", "qTabAdvanced::GetControlPort") } CATCH_DISPLAY ("Could not get detector control port.", "qTabAdvanced::GetControlPort")
@ -146,7 +148,7 @@ void qTabAdvanced::GetStopPort() {
SLOT(SetStopPort(int))); SLOT(SetStopPort(int)));
try { try {
int retval = myDet->setStopPort(-1, comboDetector->currentIndex()); int retval = det->getStopPort({comboDetector->currentIndex()})[0];
spinStopPort->setValue(retval); spinStopPort->setValue(retval);
} CATCH_DISPLAY ("Could not get detector stop port.", "qTabAdvanced::GetStopPort") } CATCH_DISPLAY ("Could not get detector stop port.", "qTabAdvanced::GetStopPort")
@ -160,7 +162,7 @@ void qTabAdvanced::GetDetectorUDPIP() {
SLOT(SetDetectorUDPIP())); SLOT(SetDetectorUDPIP()));
try { try {
auto retval = myDet->getDetectorIP(comboDetector->currentIndex()); auto retval = det->getSourceUDPIP({comboDetector->currentIndex()})[0].str();
dispDetectorUDPIP->setText(QString(retval.c_str())); dispDetectorUDPIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get detector UDP IP.", "qTabAdvanced::GetDetectorUDPIP") } CATCH_DISPLAY ("Could not get detector UDP IP.", "qTabAdvanced::GetDetectorUDPIP")
@ -174,7 +176,7 @@ void qTabAdvanced::GetDetectorUDPMAC() {
SLOT(SetDetectorUDPMAC())); SLOT(SetDetectorUDPMAC()));
try { try {
auto retval = myDet->getDetectorMAC(comboDetector->currentIndex()); auto retval = det->getSourceUDPMAC({comboDetector->currentIndex()})[0].str();
dispDetectorUDPMAC->setText(QString(retval.c_str())); dispDetectorUDPMAC->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get detector UDP MAC.", "qTabAdvanced::GetDetectorUDPMAC") } CATCH_DISPLAY ("Could not get detector UDP MAC.", "qTabAdvanced::GetDetectorUDPMAC")
@ -189,7 +191,7 @@ void qTabAdvanced::GetCltZMQPort() {
try { try {
int retval = int retval =
myDet->getClientStreamingPort(comboDetector->currentIndex()); det->getClientZmqPort({comboDetector->currentIndex()})[0];
spinZMQPort->setValue(retval); spinZMQPort->setValue(retval);
} CATCH_DISPLAY ("Could not get client zmq port.", "qTabAdvanced::GetCltZMQPort") } CATCH_DISPLAY ("Could not get client zmq port.", "qTabAdvanced::GetCltZMQPort")
@ -203,7 +205,7 @@ void qTabAdvanced::GetCltZMQIP() {
try { try {
auto retval = auto retval =
myDet->getClientStreamingIP(comboDetector->currentIndex()); det->getClientZmqIp({comboDetector->currentIndex()})[0];
dispZMQIP->setText(QString(retval.c_str())); dispZMQIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get client zmq ip.", "qTabAdvanced::GetCltZMQIP") } CATCH_DISPLAY ("Could not get client zmq ip.", "qTabAdvanced::GetCltZMQIP")
@ -216,7 +218,7 @@ void qTabAdvanced::GetRxrHostname() {
SLOT(SetRxrHostname())); SLOT(SetRxrHostname()));
try { try {
auto retval = myDet->getReceiverHostname(comboDetector->currentIndex()); auto retval = det->getRxHostname({comboDetector->currentIndex()})[0];
dispRxrHostname->setText(QString(retval.c_str())); dispRxrHostname->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver hostname.", "qTabAdvanced::GetRxrHostname") } CATCH_DISPLAY ("Could not get receiver hostname.", "qTabAdvanced::GetRxrHostname")
@ -230,7 +232,7 @@ void qTabAdvanced::GetRxrTCPPort() {
SLOT(SetRxrTCPPort(int))); SLOT(SetRxrTCPPort(int)));
try { try {
int retval = myDet->getReceiverPort(comboDetector->currentIndex()); int retval = det->getRxPort({comboDetector->currentIndex()})[0];
spinRxrTCPPort->setValue(retval); spinRxrTCPPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver tcp port.", "qTabAdvanced::GetRxrTCPPort") } CATCH_DISPLAY ("Could not get receiver tcp port.", "qTabAdvanced::GetRxrTCPPort")
@ -244,7 +246,7 @@ void qTabAdvanced::GetRxrUDPPort() {
SLOT(SetRxrUDPPort(int))); SLOT(SetRxrUDPPort(int)));
try { try {
int retval = myDet->getReceiverUDPPort(comboDetector->currentIndex()); int retval = det->getDestinationUDPPort({comboDetector->currentIndex()})[0];
spinRxrUDPPort->setValue(retval); spinRxrUDPPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver udp port.", "qTabAdvanced::GetRxrUDPPort") } CATCH_DISPLAY ("Could not get receiver udp port.", "qTabAdvanced::GetRxrUDPPort")
@ -258,7 +260,7 @@ void qTabAdvanced::GetRxrUDPIP() {
SLOT(SetRxrUDPIP())); SLOT(SetRxrUDPIP()));
try { try {
auto retval = myDet->getReceiverUDPIP(comboDetector->currentIndex()); auto retval = det->getDestinationUDPIP({comboDetector->currentIndex()})[0].str();
dispRxrUDPIP->setText(QString(retval.c_str())); dispRxrUDPIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver udp ip.", "qTabAdvanced::GetRxrUDPIP") } CATCH_DISPLAY ("Could not get receiver udp ip.", "qTabAdvanced::GetRxrUDPIP")
@ -271,7 +273,7 @@ void qTabAdvanced::GetRxrUDPMAC() {
SLOT(SetRxrUDPMAC())); SLOT(SetRxrUDPMAC()));
try { try {
auto retval = myDet->getReceiverUDPMAC(comboDetector->currentIndex()); auto retval = det->getDestinationUDPMAC({comboDetector->currentIndex()})[0].str();
dispRxrUDPMAC->setText(QString(retval.c_str())); dispRxrUDPMAC->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver udp mac.", "qTabAdvanced::GetRxrUDPMAC") } CATCH_DISPLAY ("Could not get receiver udp mac.", "qTabAdvanced::GetRxrUDPMAC")
@ -286,7 +288,7 @@ void qTabAdvanced::GetRxrZMQPort() {
try { try {
int retval = int retval =
myDet->getReceiverStreamingPort(comboDetector->currentIndex()); det->getRxZmqPort({comboDetector->currentIndex()})[0];
spinRxrZMQPort->setValue(retval); spinRxrZMQPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver zmq port.", "qTabAdvanced::GetRxrZMQPort") } CATCH_DISPLAY ("Could not get receiver zmq port.", "qTabAdvanced::GetRxrZMQPort")
@ -301,14 +303,14 @@ void qTabAdvanced::GetRxrZMQIP() {
try { try {
auto retval = auto retval =
myDet->getReceiverStreamingIP(comboDetector->currentIndex()); det->getRxZmqIP({comboDetector->currentIndex()})[0];
dispRxrZMQIP->setText(QString(retval.c_str())); dispRxrZMQIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP") } CATCH_DISPLAY ("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP")
connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP()));
} }
void qTabAdvanced::SetDetector(int index) { void qTabAdvanced::SetDetector() {
FILE_LOG(logDEBUG) << "Set Detector: " FILE_LOG(logDEBUG) << "Set Detector: "
<< comboDetector->currentText().toAscii().data(); << comboDetector->currentText().toAscii().data();
@ -326,13 +328,13 @@ void qTabAdvanced::SetDetector(int index) {
GetRxrZMQPort(); GetRxrZMQPort();
GetRxrZMQIP(); GetRxrZMQIP();
FILE_LOG(logDEBUG) << myDet->printReceiverConfiguration(); FILE_LOG(logDEBUG) << det->printRxConfiguration();
} }
void qTabAdvanced::SetControlPort(int port) { void qTabAdvanced::SetControlPort(int port) {
FILE_LOG(logINFO) << "Setting Control Port:" << port; FILE_LOG(logINFO) << "Setting Control Port:" << port;
try { try {
myDet->setControlPort(port, comboDetector->currentIndex()); det->setControlPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE("Could not set control port.", "qTabAdvanced::SetControlPort", } CATCH_HANDLE("Could not set control port.", "qTabAdvanced::SetControlPort",
this, &qTabAdvanced::GetControlPort) this, &qTabAdvanced::GetControlPort)
} }
@ -340,7 +342,7 @@ void qTabAdvanced::SetControlPort(int port) {
void qTabAdvanced::SetStopPort(int port) { void qTabAdvanced::SetStopPort(int port) {
FILE_LOG(logINFO) << "Setting Stop Port:" << port; FILE_LOG(logINFO) << "Setting Stop Port:" << port;
try { try {
myDet->setStopPort(port, comboDetector->currentIndex()); det->setStopPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set stop port.", "qTabAdvanced::SetStopPort", this, } CATCH_HANDLE ("Could not set stop port.", "qTabAdvanced::SetStopPort", this,
&qTabAdvanced::GetStopPort) &qTabAdvanced::GetStopPort)
} }
@ -349,7 +351,7 @@ void qTabAdvanced::SetDetectorUDPIP() {
std::string s = dispDetectorUDPIP->text().toAscii().constData(); std::string s = dispDetectorUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s; FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s;
try { try {
myDet->setDetectorIP(s, comboDetector->currentIndex()); det->setSourceUDPIP(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP IP.", } CATCH_HANDLE ("Could not set Detector UDP IP.",
"qTabAdvanced::SetDetectorUDPIP", this, "qTabAdvanced::SetDetectorUDPIP", this,
&qTabAdvanced::GetDetectorUDPIP) &qTabAdvanced::GetDetectorUDPIP)
@ -359,7 +361,7 @@ void qTabAdvanced::SetDetectorUDPMAC() {
std::string s = dispDetectorUDPMAC->text().toAscii().constData(); std::string s = dispDetectorUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s; FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s;
try { try {
myDet->setDetectorMAC(s, comboDetector->currentIndex()); det->setSourceUDPMAC(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP MAC.", } CATCH_HANDLE ("Could not set Detector UDP MAC.",
"qTabAdvanced::SetDetectorUDPMAC", this, "qTabAdvanced::SetDetectorUDPMAC", this,
&qTabAdvanced::GetDetectorUDPMAC) &qTabAdvanced::GetDetectorUDPMAC)
@ -368,8 +370,7 @@ void qTabAdvanced::SetDetectorUDPMAC() {
void qTabAdvanced::SetCltZMQPort(int port) { void qTabAdvanced::SetCltZMQPort(int port) {
FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port; FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port;
try { try {
myDet->setClientDataStreamingInPort(port, det->setClientZmqPort(port, {comboDetector->currentIndex()});
comboDetector->currentIndex());
} CATCH_HANDLE ("Could not set Client ZMQ port.", } CATCH_HANDLE ("Could not set Client ZMQ port.",
"qTabAdvanced::SetCltZMQPort", this, "qTabAdvanced::SetCltZMQPort", this,
&qTabAdvanced::GetCltZMQPort) &qTabAdvanced::GetCltZMQPort)
@ -379,7 +380,7 @@ void qTabAdvanced::SetCltZMQIP() {
std::string s = dispZMQIP->text().toAscii().constData(); std::string s = dispZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s; FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s;
try { try {
myDet->setClientDataStreamingInIP(s, comboDetector->currentIndex()); det->setClientZmqIp(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.", } CATCH_HANDLE ("Could not set Client ZMQ IP.",
"qTabAdvanced::SetCltZMQIP", this, "qTabAdvanced::SetCltZMQIP", this,
&qTabAdvanced::GetCltZMQIP) &qTabAdvanced::GetCltZMQIP)
@ -389,19 +390,19 @@ void qTabAdvanced::SetRxrHostname() {
std::string s = dispZMQIP->text().toAscii().constData(); std::string s = dispZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s; FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s;
try { try {
myDet->setReceiverHostname(s, comboDetector->currentIndex()); det->setRxHostname(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.", } CATCH_HANDLE ("Could not set Client ZMQ IP.",
"qTabAdvanced::SetRxrHostname", this, "qTabAdvanced::SetRxrHostname", this,
&qTabAdvanced::GetRxrHostname) &qTabAdvanced::GetRxrHostname)
// update all network widgets (receiver mainly) // update all network widgets (receiver mainly)
SetDetector(comboDetector->currentIndex()); SetDetector();
} }
void qTabAdvanced::SetRxrTCPPort(int port) { void qTabAdvanced::SetRxrTCPPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port; FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port;
try { try {
myDet->setReceiverPort(port, comboDetector->currentIndex()); det->setRxPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver TCP port.", } CATCH_HANDLE ("Could not set Receiver TCP port.",
"qTabAdvanced::SetRxrTCPPort", this, "qTabAdvanced::SetRxrTCPPort", this,
&qTabAdvanced::GetRxrTCPPort) &qTabAdvanced::GetRxrTCPPort)
@ -410,7 +411,7 @@ void qTabAdvanced::SetRxrTCPPort(int port) {
void qTabAdvanced::SetRxrUDPPort(int port) { void qTabAdvanced::SetRxrUDPPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port; FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port;
try { try {
myDet->setReceiverUDPPort(port, comboDetector->currentIndex()); det->setRxPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP port.", } CATCH_HANDLE ("Could not set Receiver UDP port.",
"qTabAdvanced::SetRxrUDPPort", this, "qTabAdvanced::SetRxrUDPPort", this,
&qTabAdvanced::GetRxrUDPPort) &qTabAdvanced::GetRxrUDPPort)
@ -420,7 +421,7 @@ void qTabAdvanced::SetRxrUDPIP() {
std::string s = dispRxrUDPIP->text().toAscii().constData(); std::string s = dispRxrUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s; FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s;
try { try {
myDet->setReceiverUDPIP(s, comboDetector->currentIndex()); det->setDestinationUDPIP(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP IP.", } CATCH_HANDLE ("Could not set Receiver UDP IP.",
"qTabAdvanced::SetRxrUDPIP", this, "qTabAdvanced::SetRxrUDPIP", this,
&qTabAdvanced::GetRxrUDPIP) &qTabAdvanced::GetRxrUDPIP)
@ -430,7 +431,7 @@ void qTabAdvanced::SetRxrUDPMAC() {
std::string s = dispRxrUDPMAC->text().toAscii().constData(); std::string s = dispRxrUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s; FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
try { try {
myDet->setReceiverUDPMAC(s, comboDetector->currentIndex()); det->setDestinationUDPMAC(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP MAC.", } CATCH_HANDLE ("Could not set Receiver UDP MAC.",
"qTabAdvanced::SetRxrUDPMAC", this, "qTabAdvanced::SetRxrUDPMAC", this,
&qTabAdvanced::GetRxrUDPMAC) &qTabAdvanced::GetRxrUDPMAC)
@ -439,8 +440,7 @@ void qTabAdvanced::SetRxrUDPMAC() {
void qTabAdvanced::SetRxrZMQPort(int port) { void qTabAdvanced::SetRxrZMQPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port; FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port;
try { try {
myDet->setReceiverDataStreamingOutPort(port, det->setRxZmqPort(port, {comboDetector->currentIndex()});
comboDetector->currentIndex());
} CATCH_HANDLE ("Could not set Receiver ZMQ port.", } CATCH_HANDLE ("Could not set Receiver ZMQ port.",
"qTabAdvanced::SetRxrZMQPort", this, "qTabAdvanced::SetRxrZMQPort", this,
&qTabAdvanced::GetRxrZMQPort) &qTabAdvanced::GetRxrZMQPort)
@ -450,7 +450,7 @@ void qTabAdvanced::SetRxrZMQIP() {
std::string s = dispRxrZMQIP->text().toAscii().constData(); std::string s = dispRxrZMQIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
try { try {
myDet->setReceiverDataStreamingOutIP(s, comboDetector->currentIndex()); det->setRxZmqIP(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ IP.", } CATCH_HANDLE ("Could not set Receiver ZMQ IP.",
"qTabAdvanced::SetRxrZMQIP", this, "qTabAdvanced::SetRxrZMQIP", this,
&qTabAdvanced::GetRxrZMQIP) &qTabAdvanced::GetRxrZMQIP)
@ -459,7 +459,7 @@ void qTabAdvanced::SetRxrZMQIP() {
void qTabAdvanced::GetROI() { void qTabAdvanced::GetROI() {
FILE_LOG(logDEBUG) << "Getting ROI"; FILE_LOG(logDEBUG) << "Getting ROI";
try { try {
slsDetectorDefs::ROI roi = myDet->getROI(comboReadout->currentIndex()); slsDetectorDefs::ROI roi = det->getROI({comboReadout->currentIndex()})[0];
spinXmin->setValue(roi.xmin); spinXmin->setValue(roi.xmin);
spinXmax->setValue(roi.xmax); spinXmax->setValue(roi.xmax);
} CATCH_DISPLAY ("Could not get ROI.", "qTabAdvanced::GetROI") } CATCH_DISPLAY ("Could not get ROI.", "qTabAdvanced::GetROI")
@ -482,7 +482,7 @@ void qTabAdvanced::SetROI() {
// set roi // set roi
FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]"; FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]";
try { try {
myDet->setROI(roi, comboReadout->currentIndex()); det->setROI(roi, {comboReadout->currentIndex()});
} CATCH_DISPLAY ("Could not set these ROIs.", } CATCH_DISPLAY ("Could not set these ROIs.",
"qTabAdvanced::SetROI") "qTabAdvanced::SetROI")
@ -496,7 +496,7 @@ void qTabAdvanced::GetAllTrimbits() {
SLOT(SetAllTrimbits())); SLOT(SetAllTrimbits()));
try { try {
int retval = myDet->setAllTrimbits(-1); int retval = det->getAllTrimbits().squash(-1);
spinSetAllTrimbits->setValue(retval); spinSetAllTrimbits->setValue(retval);
} CATCH_DISPLAY ("Could not get all trimbits.", "qTabAdvanced::GetAllTrimbits") } CATCH_DISPLAY ("Could not get all trimbits.", "qTabAdvanced::GetAllTrimbits")
@ -509,7 +509,7 @@ void qTabAdvanced::SetAllTrimbits() {
FILE_LOG(logINFO) << "Setting all trimbits:" << value; FILE_LOG(logINFO) << "Setting all trimbits:" << value;
try { try {
myDet->setAllTrimbits(value); det->setAllTrimbits(value);
} CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits", } CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits",
this, &qTabAdvanced::GetAllTrimbits) this, &qTabAdvanced::GetAllTrimbits)
} }
@ -520,7 +520,7 @@ void qTabAdvanced::GetNumStoragecells() {
SLOT(SetNumStoragecells(int))); SLOT(SetNumStoragecells(int)));
try { try {
auto retval = myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER); auto retval = det->getNumberOfAdditionalStorageCells().tsquash("Inconsistent values for number of addditional storage cells.");
spinNumStoragecells->setValue(retval); spinNumStoragecells->setValue(retval);
} CATCH_DISPLAY ( } CATCH_DISPLAY (
"Could not get number of additional storage cells.", "Could not get number of additional storage cells.",
@ -534,7 +534,7 @@ void qTabAdvanced::SetNumStoragecells(int value) {
FILE_LOG(logINFO) << "Setting number of additional stoarge cells: " FILE_LOG(logINFO) << "Setting number of additional stoarge cells: "
<< value; << value;
try { try {
myDet->setTimer(slsDetectorDefs::STORAGE_CELL_NUMBER, value, -1); det->setNumberOfAdditionalStorageCells(value);
} CATCH_HANDLE ( } CATCH_HANDLE (
"Could not set number of additional storage cells.", "Could not set number of additional storage cells.",
"qTabAdvanced::SetNumStoragecells", this, "qTabAdvanced::SetNumStoragecells", this,
@ -547,24 +547,14 @@ void qTabAdvanced::GetSubExposureTime() {
SLOT(SetSubExposureTime())); SLOT(SetSubExposureTime()));
disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this, disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSubExposureTime())); SLOT(SetSubExposureTime()));
try { try {
int64_t retval = auto retval =
myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME); det->getSubExptime().tsquash("Subexptime is inconsistent for all detectors.");
if (retval == -1) { auto time = qDefs::getUserFriendlyTime(retval);
qDefs::Message(qDefs::WARNING, spinSubExpTime->setValue(time.first);
"Subexptime is inconsistent for all detectors.", comboSubExpTimeUnit->setCurrentIndex(static_cast<int>(time.second));
"qTabAdvanced::GetSubExposureTime");
spinSubExpTime->setValue(-1);
} else {
double value = (double)(retval * (1E-9));
auto time = qDefs::getCorrectTime(value);
spinSubExpTime->setValue(time.first);
comboSubExpTimeUnit->setCurrentIndex(static_cast<int>(time.second));
}
} CATCH_DISPLAY ("Could not get sub exposure time.", } CATCH_DISPLAY ("Could not get sub exposure time.",
"qTabSettings::GetSubExposureTime") "qTabSettings::GetSubExposureTime")
connect(spinSubExpTime, SIGNAL(valueChanged(double)), this, connect(spinSubExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetSubExposureTime())); SLOT(SetSubExposureTime()));
connect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this, connect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
@ -572,17 +562,14 @@ void qTabAdvanced::GetSubExposureTime() {
} }
void qTabAdvanced::SetSubExposureTime() { void qTabAdvanced::SetSubExposureTime() {
double timeNS = auto timeNS = qDefs::getNSTime(std::make_pair(spinSubExpTime->value(), static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex())));
qDefs::getNSTime((qDefs::timeUnit)comboSubExpTimeUnit->currentIndex(),
spinSubExpTime->value());
FILE_LOG(logINFO) FILE_LOG(logINFO)
<< "Setting sub frame acquisition time to " << timeNS << " ns" << "Setting sub frame acquisition time to " << timeNS.count() << " ns"
<< "/" << spinSubExpTime->value() << "/" << spinSubExpTime->value()
<< qDefs::getUnitString( << qDefs::getUnitString(
(qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()); (qDefs::timeUnit)comboSubExpTimeUnit->currentIndex());
try { try {
myDet->setTimer(slsDetectorDefs::SUBFRAME_ACQUISITION_TIME, det->setSubExptime(timeNS);
(int64_t)timeNS, -1);
} CATCH_DISPLAY ("Could not set sub exposure time.", } CATCH_DISPLAY ("Could not set sub exposure time.",
"qTabAdvanced::SetSubExposureTime") "qTabAdvanced::SetSubExposureTime")
@ -595,24 +582,14 @@ void qTabAdvanced::GetSubDeadTime() {
SLOT(SetSubDeadTime())); SLOT(SetSubDeadTime()));
disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this, disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSubDeadTime())); SLOT(SetSubDeadTime()));
try { try {
int64_t retval = myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME); auto retval = det->getSubDeadTime().tsquash("Sub dead time is inconsistent for all detectors.");
if (retval == -1) { auto time = qDefs::getUserFriendlyTime(retval);
qDefs::Message(qDefs::WARNING, spinSubDeadTime->setValue(time.first);
"Sub dead time is inconsistent for all detectors.", comboSubDeadTimeUnit->setCurrentIndex(
"qTabAdvanced::GetSubDeadTime"); static_cast<int>(time.second));
spinSubDeadTime->setValue(-1);
} else {
double value = (double)(retval * (1E-9));
auto time = qDefs::getCorrectTime(value);
spinSubDeadTime->setValue(time.first);
comboSubDeadTimeUnit->setCurrentIndex(
static_cast<int>(time.second));
}
} CATCH_DISPLAY ("Could not get sub dead time.", } CATCH_DISPLAY ("Could not get sub dead time.",
"qTabSettings::GetSubDeadTime") "qTabSettings::GetSubDeadTime")
connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this, connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this,
SLOT(SetSubDeadTime())); SLOT(SetSubDeadTime()));
connect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this, connect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
@ -620,20 +597,17 @@ void qTabAdvanced::GetSubDeadTime() {
} }
void qTabAdvanced::SetSubDeadTime() { void qTabAdvanced::SetSubDeadTime() {
double timeNS = auto timeNS = qDefs::getNSTime(std::make_pair(spinSubDeadTime->value(), static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex())));
qDefs::getNSTime((qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex(),
spinSubDeadTime->value());
FILE_LOG(logINFO) FILE_LOG(logINFO)
<< "Setting sub frame dead time to " << timeNS << " ns" << "Setting sub frame dead time to " << timeNS.count() << " ns"
<< "/" << spinSubDeadTime->value() << "/" << spinSubDeadTime->value()
<< qDefs::getUnitString( << qDefs::getUnitString(
(qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex()); (qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex());
try { try {
myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME, (int64_t)timeNS, det->setSubDeadTime(timeNS);
-1);
} CATCH_DISPLAY ("Could not set sub dead time.", } CATCH_DISPLAY ("Could not set sub dead time.",
"qTabAdvanced::SetSubDeadTime") "qTabAdvanced::SetSubDeadTime")
GetSubDeadTime(); GetSubDeadTime();
} }
@ -646,7 +620,7 @@ void qTabAdvanced::Refresh() {
} }
// update all network widgets // update all network widgets
SetDetector(comboDetector->currentIndex()); SetDetector();
// roi // roi
if (tab_roi->isEnabled()) { if (tab_roi->isEnabled()) {

View File

@ -10,7 +10,7 @@
#include <string> #include <string>
qTabDataOutput::qTabDataOutput(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector), btnGroupRate(nullptr) { qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector), btnGroupRate(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "DataOutput ready"; FILE_LOG(logDEBUG) << "DataOutput ready";
@ -28,7 +28,7 @@ void qTabDataOutput::SetupWidgetWindow() {
btnGroupRate->addButton(radioCustomDeadtime, 1); btnGroupRate->addButton(radioCustomDeadtime, 1);
// enabling according to det type // enabling according to det type
switch(myDet->getDetectorTypeAsEnum()) { switch(det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
chkTenGiga->setEnabled(true); chkTenGiga->setEnabled(true);
chkRate->setEnabled(true); chkRate->setEnabled(true);
@ -70,8 +70,7 @@ void qTabDataOutput::Initialization() {
// flags, speed // flags, speed
if (widgetEiger->isEnabled()) { if (widgetEiger->isEnabled()) {
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int))); connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
} }
} }
@ -80,9 +79,11 @@ void qTabDataOutput::PopulateDetectors() {
comboDetector->clear(); comboDetector->clear();
comboDetector->addItem("All"); comboDetector->addItem("All");
if (myDet->size() > 1) { if (det->size() > 1) {
for (unsigned int i = 0; i < myDet->size(); ++i) auto res = det->getHostname();
comboDetector->addItem(QString(myDet->getHostname(i).c_str())); for (auto &it : res) {
comboDetector->addItem(QString(it.c_str()));
}
} }
} }
@ -90,8 +91,10 @@ void qTabDataOutput::EnableBrowse() {
FILE_LOG(logDEBUG) << "Getting browse enable"; FILE_LOG(logDEBUG) << "Getting browse enable";
try { try {
btnOutputBrowse->setEnabled(false); // exception default btnOutputBrowse->setEnabled(false); // exception default
std::string receiverHostname = myDet->getReceiverHostname(comboDetector->currentIndex() - 1); std::string rxHostname = det->getRxHostname({comboDetector->currentIndex() - 1}).squash("none");
if (receiverHostname == "localhost") { if (rxHostname == "none") {
btnOutputBrowse->setEnabled(false);
} else if (rxHostname == "localhost") {
btnOutputBrowse->setEnabled(true); btnOutputBrowse->setEnabled(true);
} else { } else {
std::string hostname; std::string hostname;
@ -101,7 +104,7 @@ void qTabDataOutput::EnableBrowse() {
hostname.assign(host); hostname.assign(host);
} }
// client pc (hostname) same as reciever hostname // client pc (hostname) same as reciever hostname
if (hostname == receiverHostname) { if (hostname == rxHostname) {
btnOutputBrowse->setEnabled(true); btnOutputBrowse->setEnabled(true);
} else { } else {
btnOutputBrowse->setEnabled(false); btnOutputBrowse->setEnabled(false);
@ -114,34 +117,26 @@ void qTabDataOutput::GetFileWrite() {
FILE_LOG(logDEBUG) << "Getting file write enable"; FILE_LOG(logDEBUG) << "Getting file write enable";
try { try {
boxFileWriteEnabled->setEnabled(true); // exception default boxFileWriteEnabled->setEnabled(true); // exception default
int retval = myDet->getFileWrite(); auto retval = det->getFileWrite().tsquash("File write is inconsistent for all detectors.");
if (retval == -1) { boxFileWriteEnabled->setEnabled(retval);
qDefs::Message(qDefs::WARNING, "File write is inconsistent for all detectors.", "qTabDataOutput::GetFileWrite");
boxFileWriteEnabled->setEnabled(true);
} else {
boxFileWriteEnabled->setEnabled(retval == 0 ? false : true);
}
} CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite") } CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite")
} }
void qTabDataOutput::GetFileName() { void qTabDataOutput::GetFileName() {
FILE_LOG(logDEBUG) << "Getting file name"; FILE_LOG(logDEBUG) << "Getting file name";
try { try {
auto retval = myDet->getFileName(); auto retval = det->getFileNamePrefix().tsquash("File name is inconsistent for all detectors.");
dispFileName->setText(QString(retval.c_str())); dispFileName->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get file name prefix.", "qTabDataOutput::GetFileName") } CATCH_DISPLAY ("Could not get file name prefix.", "qTabDataOutput::GetFileName")
} }
void qTabDataOutput::GetOutputDir() { void qTabDataOutput::GetOutputDir() {
FILE_LOG(logDEBUG) << "Getting file path"; FILE_LOG(logDEBUG) << "Getting file path";
disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
try { try {
std::string path = myDet->getFilePath(comboDetector->currentIndex() - 1); std::string path = det->getFilePath({comboDetector->currentIndex() - 1}).tsquash("File path is different for all detectors.");
dispOutputDir->setText(QString(path.c_str())); dispOutputDir->setText(QString(path.c_str()));
} CATCH_DISPLAY ("Could not get file path.", "qTabDataOutput::GetOutputDir") } CATCH_DISPLAY ("Could not get file path.", "qTabDataOutput::GetOutputDir")
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
} }
@ -170,7 +165,7 @@ void qTabDataOutput::SetOutputDir() {
} }
std::string spath = std::string(path.toAscii().constData()); std::string spath = std::string(path.toAscii().constData());
try { try {
myDet->setFilePath(spath, comboDetector->currentIndex() - 1); det->setFilePath(spath, {comboDetector->currentIndex() - 1});
} CATCH_HANDLE ("Could not set output file path.", "qTabDataOutput::SetOutputDir", this, &qTabDataOutput::GetOutputDir) } CATCH_HANDLE ("Could not set output file path.", "qTabDataOutput::SetOutputDir", this, &qTabDataOutput::GetOutputDir)
} }
} }
@ -178,44 +173,33 @@ void qTabDataOutput::SetOutputDir() {
void qTabDataOutput::GetFileFormat() { void qTabDataOutput::GetFileFormat() {
FILE_LOG(logDEBUG) << "Getting File Format"; FILE_LOG(logDEBUG) << "Getting File Format";
disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int)));
try { try {
auto retval = myDet->getFileFormat(); auto retval = det->getFileFormat().tsquash("File format is inconsistent for all detectors.");
switch(retval) { switch(retval) {
case slsDetectorDefs::GET_FILE_FORMAT:
qDefs::Message(qDefs::WARNING, "File Format is inconsistent for all detectors.", "qTabDataOutput::GetFileFormat");
break;
case slsDetectorDefs::BINARY: case slsDetectorDefs::BINARY:
case slsDetectorDefs::HDF5: case slsDetectorDefs::HDF5:
comboFileFormat->setCurrentIndex(static_cast<int>(retval)); comboFileFormat->setCurrentIndex(static_cast<int>(retval));
break; break;
default: default:
qDefs::Message(qDefs::WARNING, std::string("Unknown file format: ") + std::to_string(static_cast<int>(retval)), "qTabDataOutput::GetFileFormat"); throw sls::RuntimeError(std::string("Unknown file format: ") + std::to_string(static_cast<int>(retval)));
break;
} }
} CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat") } CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat")
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int)));
} }
void qTabDataOutput::SetFileFormat(int format) { void qTabDataOutput::SetFileFormat(int format) {
FILE_LOG(logINFO) << "Setting File Format to " << comboFileFormat->currentText().toAscii().data(); FILE_LOG(logINFO) << "Setting File Format to " << comboFileFormat->currentText().toAscii().data();
try { try {
myDet->setFileFormat((slsDetectorDefs::fileFormat)comboFileFormat->currentIndex()); det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(comboFileFormat->currentIndex()));
} CATCH_HANDLE ("Could not set file format.", "qTabDataOutput::SetFileFormat", this, &qTabDataOutput::GetFileFormat) } CATCH_HANDLE ("Could not set file format.", "qTabDataOutput::SetFileFormat", this, &qTabDataOutput::GetFileFormat)
} }
void qTabDataOutput::GetFileOverwrite() { void qTabDataOutput::GetFileOverwrite() {
FILE_LOG(logDEBUG) << "Getting File Over Write Enable"; FILE_LOG(logDEBUG) << "Getting File Over Write Enable";
disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool)));
try { try {
int retval = myDet->getFileOverWrite(); auto retval = det->getFileOverWrite().tsquash("File over write is inconsistent for all detectors.");
if (retval == -1) { chkOverwriteEnable->setChecked(retval);
qDefs::Message(qDefs::WARNING, "File over write is inconsistent for all detectors.", "qTabDataOutput::GetFileOverwrite");
} else {
chkOverwriteEnable->setChecked(retval == 0 ? false : true);
}
} CATCH_DISPLAY ("Could not get file over write enable.", "qTabDataOutput::GetFileOverwrite") } CATCH_DISPLAY ("Could not get file over write enable.", "qTabDataOutput::GetFileOverwrite")
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool)));
@ -223,33 +207,25 @@ void qTabDataOutput::GetFileOverwrite() {
void qTabDataOutput::SetOverwriteEnable(bool enable) { void qTabDataOutput::SetOverwriteEnable(bool enable) {
FILE_LOG(logINFO) << "Setting File Over Write Enable to " << enable; FILE_LOG(logINFO) << "Setting File Over Write Enable to " << enable;
try { try {
myDet->setFileOverWrite(enable); det->setFileOverWrite(enable);
} CATCH_HANDLE ("Could not set file over write enable.", "qTabDataOutput::SetOverwriteEnable", this, &qTabDataOutput::GetFileOverwrite) } CATCH_HANDLE ("Could not set file over write enable.", "qTabDataOutput::SetOverwriteEnable", this, &qTabDataOutput::GetFileOverwrite)
} }
void qTabDataOutput::GetTenGigaEnable() { void qTabDataOutput::GetTenGigaEnable() {
FILE_LOG(logDEBUG) << "Getting 10GbE enable"; FILE_LOG(logDEBUG) << "Getting 10GbE enable";
disconnect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool))); disconnect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
try { try {
int retval = myDet->enableTenGigabitEthernet(); auto retval = det->getTenGiga().tsquash("10GbE enable is inconsistent for all detectors.");
if (retval == -1) { chkTenGiga->setChecked(retval);
qDefs::Message(qDefs::WARNING, "10GbE enable is inconsistent for all detectors.", "qTabDataOutput::GetTenGigaEnable");
} else {
chkTenGiga->setChecked(retval == 0 ? false : true);
}
} CATCH_DISPLAY ("Could not get 10GbE enable.", "qTabDataOutput::GetTenGigaEnable") } CATCH_DISPLAY ("Could not get 10GbE enable.", "qTabDataOutput::GetTenGigaEnable")
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool))); connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
} }
void qTabDataOutput::SetTenGigaEnable(bool enable) { void qTabDataOutput::SetTenGigaEnable(bool enable) {
FILE_LOG(logINFO) << "Setting 10GbE to " << enable; FILE_LOG(logINFO) << "Setting 10GbE to " << enable;
try { try {
myDet->enableTenGigabitEthernet(enable); det->setTenGiga(enable);
} CATCH_HANDLE ("Could not set 10GbE enable.", "qTabDataOutput::SetTenGigaEnable", this, &qTabDataOutput::GetTenGigaEnable) } CATCH_HANDLE ("Could not set 10GbE enable.", "qTabDataOutput::SetTenGigaEnable", this, &qTabDataOutput::GetTenGigaEnable)
} }
@ -258,19 +234,13 @@ void qTabDataOutput::GetRateCorrection() {
disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection())); disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection())); disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
disconnect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); disconnect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
try { try {
int64_t retval = myDet->getRateCorrection(); spinCustomDeadTime->setValue(-1);
if (retval == -1) { int64_t retval = det->getRateCorrection().tsquash("Rate correction (enable/tau) is inconsistent for all detectors.").count();
qDefs::Message(qDefs::WARNING, "Rate correction (enable/tau) is inconsistent for all detectors.", "qTabDataOutput::GetRateCorrection"); chkRate->setChecked(retval == 0 ? false : true);
spinCustomDeadTime->setValue(-1); if (retval != 0)
} else { spinCustomDeadTime->setValue(retval);
chkRate->setChecked(retval == 0 ? false : true);
if (retval != 0)
spinCustomDeadTime->setValue(retval);
}
} CATCH_DISPLAY("Could not get rate correction.", "qTabDataOutput::GetRateCorrection") } CATCH_DISPLAY("Could not get rate correction.", "qTabDataOutput::GetRateCorrection")
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection())); connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection())); connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
@ -285,7 +255,7 @@ void qTabDataOutput::EnableRateCorrection() {
FILE_LOG(logINFO) << "Disabling Rate correction"; FILE_LOG(logINFO) << "Disabling Rate correction";
// disable // disable
try { try {
myDet->setRateCorrection(0); det->setRateCorrection(sls::ns(0));
} CATCH_HANDLE ("Could not switch off rate correction.", "qTabDataOutput::EnableRateCorrection", this, &qTabDataOutput::GetRateCorrection) } CATCH_HANDLE ("Could not switch off rate correction.", "qTabDataOutput::EnableRateCorrection", this, &qTabDataOutput::GetRateCorrection)
} }
@ -294,122 +264,69 @@ void qTabDataOutput::SetRateCorrection() {
if (!chkRate->isChecked()) { if (!chkRate->isChecked()) {
return; return;
} }
// get default or custom value
int64_t deadtime = -1;
if (radioCustomDeadtime->isChecked()) {
deadtime = spinCustomDeadTime->value();
}
FILE_LOG(logINFO) << "Setting Rate Correction with dead time: " << deadtime;
try { try {
myDet->setRateCorrection(deadtime); // custom dead time
if (radioCustomDeadtime->isChecked()) {
int64_t deadtime = spinCustomDeadTime->value();
FILE_LOG(logINFO) << "Setting Rate Correction with custom dead time: " << deadtime;
det->setRateCorrection(sls::ns(deadtime));
}
// default dead time
else {
FILE_LOG(logINFO) << "Setting Rate Correction with default dead time";
det->setDefaultRateCorrection();
}
} CATCH_HANDLE ("Could not set rate correction.", "qTabDataOutput::SetRateCorrection", this, &qTabDataOutput::GetRateCorrection) } CATCH_HANDLE ("Could not set rate correction.", "qTabDataOutput::SetRateCorrection", this, &qTabDataOutput::GetRateCorrection)
} }
void qTabDataOutput::GetSpeed() { void qTabDataOutput::GetSpeed() {
FILE_LOG(logDEBUG) << "Getting Speed"; FILE_LOG(logDEBUG) << "Getting Speed";
disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int))); disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
try { try {
int retval = myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER); int retval = det->getSpeed().tsquash("Speed is inconsistent for all detectors.");
switch(retval) { switch(retval) {
case -1:
qDefs::Message(qDefs::WARNING, "Speed is inconsistent for all detectors.", "qTabDataOutput::GetSpeed");
break;
case FULLSPEED: case FULLSPEED:
case HALFSPEED: case HALFSPEED:
case QUARTERSPEED: case QUARTERSPEED:
comboEigerClkDivider->setCurrentIndex(retval); comboEigerClkDivider->setCurrentIndex(retval);
break; break;
default: default:
qDefs::Message(qDefs::WARNING, std::string("Unknown speed: ") + std::to_string(retval), "qTabDataOutput::GetFileFormat"); throw sls::RuntimeError(std::string("Unknown speed: ") + std::to_string(retval));
break;
} }
} CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed") } CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed")
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int))); connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
} }
void qTabDataOutput::SetSpeed(int speed) { void qTabDataOutput::SetSpeed(int speed) {
FILE_LOG(logINFO) << "Setting Speed to " << comboEigerClkDivider->currentText().toAscii().data();; FILE_LOG(logINFO) << "Setting Speed to " << comboEigerClkDivider->currentText().toAscii().data();;
try { try {
myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER, speed); det->setSpeed(speed);
} CATCH_HANDLE ("Could not set speed.", "qTabDataOutput::SetSpeed", this, &qTabDataOutput::GetSpeed) } CATCH_HANDLE ("Could not set speed.", "qTabDataOutput::SetSpeed", this, &qTabDataOutput::GetSpeed)
} }
void qTabDataOutput::GetFlags() { void qTabDataOutput::GetFlags() {
FILE_LOG(logDEBUG) << "Getting readout flags"; FILE_LOG(logDEBUG) << "Getting readout flags";
disconnect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
disconnect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
try { try {
int retval = myDet->setReadOutFlags(slsDetectorDefs::GET_READOUT_FLAGS); auto retval = det->getParallelMode().tsquash("Parallel Flag is inconsistent for all detectors.");
if (retval == -1) { // parallel or non parallel
qDefs::Message(qDefs::WARNING, "Readout flags are inconsistent for all detectors.", "qTabDataOutput::GetFlags"); if (retval)
} else { comboEigerParallelFlag->setCurrentIndex(PARALLEL);
// store in ram or continuous else
if (retval & slsDetectorDefs::STORE_IN_RAM) comboEigerParallelFlag->setCurrentIndex(NONPARALLEL);
comboEigerFlags1->setCurrentIndex(STOREINRAM);
else if (retval & slsDetectorDefs::CONTINOUS_RO)
comboEigerFlags1->setCurrentIndex(CONTINUOUS);
else {
qDefs::Message(qDefs::WARNING, std::string("Unknown flag (Not Store in ram or Continous): ") + std::to_string(retval), "qTabDataOutput::GetFlags");
}
// parallel or non parallel
if (retval & slsDetectorDefs::PARALLEL)
comboEigerFlags2->setCurrentIndex(PARALLEL);
else if (retval & slsDetectorDefs::NONPARALLEL)
comboEigerFlags2->setCurrentIndex(NONPARALLEL);
else {
qDefs::Message(qDefs::WARNING, std::string("Unknown flag (Not Parallel or Non Parallel): ") + std::to_string(retval), "qTabDataOutput::GetFlags");
}
}
} CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed") } CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed")
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
connect(comboEigerFlags1, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
connect(comboEigerFlags2, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
} }
void qTabDataOutput::SetFlags() { void qTabDataOutput::SetFlags() {
auto flag1 = slsDetectorDefs::GET_READOUT_FLAGS; auto mode = comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
auto flag2 = slsDetectorDefs::GET_READOUT_FLAGS;
//set to continous or storeinram
switch (comboEigerFlags1->currentIndex()) {
case STOREINRAM:
flag1 = slsDetectorDefs::STORE_IN_RAM;
break;
default:
flag1 = slsDetectorDefs::CONTINOUS_RO;
break;
}
//set to parallel or nonparallel
switch (comboEigerFlags2->currentIndex()) {
case PARALLEL:
flag2 = slsDetectorDefs::PARALLEL;
break;
default:
flag2 = slsDetectorDefs::NONPARALLEL;
break;
}
try { try {
FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerFlags1->currentText().toAscii().data(); FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerParallelFlag->currentText().toAscii().data();
myDet->setReadOutFlags(flag1); det->setParallelMode(mode);
FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerFlags2->currentText().toAscii().data();
myDet->setReadOutFlags(flag2);
} CATCH_HANDLE ("Could not set readout flags.", "qTabDataOutput::SetFlags", this, &qTabDataOutput::GetFlags) } CATCH_HANDLE ("Could not set readout flags.", "qTabDataOutput::SetFlags", this, &qTabDataOutput::GetFlags)
} }
void qTabDataOutput::Refresh() { void qTabDataOutput::Refresh() {
FILE_LOG(logDEBUG) << "**Updating DataOutput Tab"; FILE_LOG(logDEBUG) << "**Updating DataOutput Tab";

View File

@ -7,8 +7,8 @@
#include <iostream> #include <iostream>
qTabDebugging::qTabDebugging(QWidget *parent, multiSlsDetector *detector) : qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector) :
QWidget(parent), myDet(detector), treeDet(nullptr), lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr), lblDetectorSoftware(nullptr) { QWidget(parent), det(detector), treeDet(nullptr), lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr), lblDetectorSoftware(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Debugging ready"; FILE_LOG(logDEBUG) << "Debugging ready";
@ -28,7 +28,7 @@ qTabDebugging::~qTabDebugging() {
void qTabDebugging::SetupWidgetWindow() { void qTabDebugging::SetupWidgetWindow() {
// enabling according to det type // enabling according to det type
if (myDet->getDetectorTypeAsEnum() == slsDetectorDefs::EIGER) { if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
lblDetector->setText("Half Module:"); lblDetector->setText("Half Module:");
chkDetectorFirmware->setEnabled(false); chkDetectorFirmware->setEnabled(false);
chkDetectorBus->setEnabled(false); chkDetectorBus->setEnabled(false);
@ -55,8 +55,9 @@ void qTabDebugging::PopulateDetectors() {
FILE_LOG(logDEBUG) << "Populating detectors"; FILE_LOG(logDEBUG) << "Populating detectors";
comboDetector->clear(); comboDetector->clear();
for (unsigned int i = 0; i < myDet->size(); ++i) { auto res = det->getHostname();
comboDetector->addItem(QString(myDet->getHostname(i).c_str())); for (auto &it : res) {
comboDetector->addItem(QString(it.c_str()));
} }
} }
@ -64,7 +65,7 @@ void qTabDebugging::GetDetectorStatus() {
FILE_LOG(logDEBUG) << "Getting Status"; FILE_LOG(logDEBUG) << "Getting Status";
try { try {
std::string status = slsDetectorDefs::runStatusType(myDet->getRunStatus(comboDetector->currentIndex())); std::string status = slsDetectorDefs::runStatusType(det->getDetectorStatus({comboDetector->currentIndex()})[0]);
lblStatus->setText(QString(status.c_str()).toUpper()); lblStatus->setText(QString(status.c_str()).toUpper());
} CATCH_DISPLAY ("Could not get detector status.", "qTabDebugging::GetDetectorStatus") } CATCH_DISPLAY ("Could not get detector status.", "qTabDebugging::GetDetectorStatus")
} }
@ -87,9 +88,9 @@ void qTabDebugging::GetInfo() {
//to make sure the size is constant //to make sure the size is constant
lblDetectorFirmware->setFixedWidth(100); lblDetectorFirmware->setFixedWidth(100);
layout->addWidget(dispFrame, 0, 1); layout->addWidget(dispFrame, 0, 1);
QString detName = QString(myDet->getDetectorTypeAsString().c_str()); QString detName = QString(slsDetectorDefs::detectorTypeToString(det->getDetectorType().squash()).c_str());
switch (myDet->getDetectorTypeAsEnum()) { switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
formLayout->addWidget(new QLabel("Half Module:"), 0, 0); formLayout->addWidget(new QLabel("Half Module:"), 0, 0);
@ -148,7 +149,7 @@ void qTabDebugging::GetInfo() {
void qTabDebugging::SetParameters(QTreeWidgetItem *item) { void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
// eiger: if half module clicked, others: true always // eiger: if half module clicked, others: true always
bool ignoreOrHalfModuleClicked = true; bool ignoreOrHalfModuleClicked = true;
if (myDet->getDetectorTypeAsEnum() == slsDetectorDefs::EIGER) { if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
if (!(item->text(0).contains("Half Module"))) { if (!(item->text(0).contains("Half Module"))) {
ignoreOrHalfModuleClicked = false; ignoreOrHalfModuleClicked = false;
} }
@ -161,9 +162,9 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
break; break;
} }
try { try {
auto retval = std::string("0x") + std::to_string((unsigned long)myDet->getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION, comboDetector->currentIndex())); auto retval = std::string("0x") + std::to_string((unsigned long)det->getFirmwareVersion({comboDetector->currentIndex()})[0]);
lblDetectorFirmware->setText(QString(retval.c_str())); lblDetectorFirmware->setText(QString(retval.c_str()));
retval = std::string("0x") + std::to_string((unsigned long)myDet->getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, comboDetector->currentIndex())); retval = std::string("0x") + std::to_string((unsigned long)det->getDetectorServerVersion({comboDetector->currentIndex()})[0]);
lblDetectorSoftware->setText(QString(retval.c_str())); lblDetectorSoftware->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get versions.", "qTabDebugging::SetParameters") } CATCH_DISPLAY ("Could not get versions.", "qTabDebugging::SetParameters")
} }
@ -174,7 +175,7 @@ void qTabDebugging::TestDetector() {
try { try {
QString moduleName = "Module"; QString moduleName = "Module";
if (myDet->getDetectorTypeAsEnum() == slsDetectorDefs::EIGER) { if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
moduleName = "Half Module"; moduleName = "Half Module";
} }
@ -183,7 +184,7 @@ void qTabDebugging::TestDetector() {
//detector firmware //detector firmware
if (chkDetectorFirmware->isChecked()) { if (chkDetectorFirmware->isChecked()) {
auto retval = myDet->digitalTest(slsDetectorDefs::DETECTOR_FIRMWARE_TEST, comboDetector->currentIndex()); auto retval = det->executeFirmwareTest({comboDetector->currentIndex()})[0];
if (retval == slsDetectorDefs::FAIL) { if (retval == slsDetectorDefs::FAIL) {
message.append(QString("<nobr>%1 Firmware: FAIL</nobr><br>").arg(moduleName)); message.append(QString("<nobr>%1 Firmware: FAIL</nobr><br>").arg(moduleName));
FILE_LOG(logERROR) << "Firmware fail"; FILE_LOG(logERROR) << "Firmware fail";
@ -195,7 +196,7 @@ void qTabDebugging::TestDetector() {
//detector CPU-FPGA bus //detector CPU-FPGA bus
if (chkDetectorBus->isChecked()) { if (chkDetectorBus->isChecked()) {
auto retval = myDet->digitalTest(slsDetectorDefs::DETECTOR_BUS_TEST, comboDetector->currentIndex()); auto retval = det->executeBusTest({comboDetector->currentIndex()})[0];
if (retval == slsDetectorDefs::FAIL) { if (retval == slsDetectorDefs::FAIL) {
message.append(QString("<nobr>%1 Bus: &nbsp;&nbsp;&nbsp;&nbsp;FAIL</nobr><br>").arg(moduleName)); message.append(QString("<nobr>%1 Bus: &nbsp;&nbsp;&nbsp;&nbsp;FAIL</nobr><br>").arg(moduleName));
FILE_LOG(logERROR) << "Bus Test fail"; FILE_LOG(logERROR) << "Bus Test fail";

View File

@ -4,7 +4,7 @@
#include <iostream> #include <iostream>
qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector) { qTabDeveloper::qTabDeveloper(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Developer ready"; FILE_LOG(logDEBUG) << "Developer ready";
@ -21,74 +21,74 @@ void qTabDeveloper::SetupWidgetWindow() {
spinHV->hide(); spinHV->hide();
try{ try{
slsDetectorDefs::detectorType detType = myDet->getDetectorTypeAsEnum(); slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
switch (detType) { switch (detType) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v SvP: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v SvP: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v SvN ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v SvN ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vrf: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vrf: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vrs: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vrs: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vtr: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vtr: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vtgstv: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vtgstv: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v cal: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v cal: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcp ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcp ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcn: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcn: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vis: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vis: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v rxb_lb: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v rxb_lb: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v rxb_rb: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v rxb_rb: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcmp_ll: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcmp_ll: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcmp_lr: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcmp_lr: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcmp_rl: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcmp_rl: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcmp_rr: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcmp_rr: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v threshold: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v threshold: ", getSLSIndex(detType, tempid++), false));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature FPGA Ext: ", getSLSIndex(detType, tempid++), true)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature FPGA Ext: ", getSLSIndex(detType, tempid++), true));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature 10GE: ", getSLSIndex(detType, tempid++), true)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature 10GE: ", getSLSIndex(detType, tempid++), true));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature DCDC: ", getSLSIndex(detType, tempid++), true)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature DCDC: ", getSLSIndex(detType, tempid++), true));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature SODL: ", getSLSIndex(detType, tempid++), true)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature SODL: ", getSLSIndex(detType, tempid++), true));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature SODR: ", getSLSIndex(detType, tempid++), true)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature SODR: ", getSLSIndex(detType, tempid++), true));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature FPGA: ", getSLSIndex(detType, tempid++), true)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature FPGA: ", getSLSIndex(detType, tempid++), true));
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
comboHV->show(); comboHV->show();
lblComboHV->show(); lblComboHV->show();
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Reference: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Reference: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Cascode n: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Cascode n: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Cascode p: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Cascode p: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Comp. Output: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Comp. Output: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Cascode out ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Cascode out ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Comp. Input: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Comp. Input: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Comp. Ref: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Comp. Ref: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "i Base Test: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "i Base Test: ", getSLSIndex(detType, tempid++), false));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature ADC: ", getSLSIndex(detType, tempid++), false)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature ADC: ", getSLSIndex(detType, tempid++), false));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature FPGA: ", getSLSIndex(detType, tempid++), false)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature FPGA: ", getSLSIndex(detType, tempid++), false));
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vb comp: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v vb comp: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vdd prot: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v vdd prot: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vin com: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v vin com: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vref prech: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v vref prech: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vb pixbuf: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v vb pixbuf: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vb ds: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v vb ds: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vref ds: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v vref ds: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "i vref comp: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "i vref comp: ", getSLSIndex(detType, tempid++), false));
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature ADC/FPGA: ", getSLSIndex(detType, tempid++), true)); adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature ADC/FPGA: ", getSLSIndex(detType, tempid++), true));
break; break;
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 0: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 0: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 1: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 1: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 2: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 2: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 3: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 3: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 4: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 4: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 5: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 5: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 6: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "v Dac 6: ", getSLSIndex(detType, tempid++), false));
dacWidgets.push_back(new qDacWidget(this, myDet, true, "i Dac 7: ", getSLSIndex(detType, tempid++), false)); dacWidgets.push_back(new qDacWidget(this, det, true, "i Dac 7: ", getSLSIndex(detType, tempid++), false));
break; break;
default: default:
@ -124,9 +124,11 @@ void qTabDeveloper::PopulateDetectors() {
comboDetector->clear(); comboDetector->clear();
comboDetector->addItem("All"); comboDetector->addItem("All");
if (myDet->size() > 1) { auto res = det->getHostname();
for (unsigned int i = 0; i < myDet->size(); ++i) if (det->size() > 1) {
comboDetector->addItem(QString(myDet->getHostname(i).c_str())); for (auto &it : res) {
comboDetector->addItem(QString(it.c_str()));
}
} }
comboDetector->setCurrentIndex(0); comboDetector->setCurrentIndex(0);
} }
@ -135,25 +137,22 @@ void qTabDeveloper::GetHighVoltage() {
// not enabled for eiger // not enabled for eiger
if (!comboHV->isVisible() && !spinHV->isVisible()) if (!comboHV->isVisible() && !spinHV->isVisible())
return; return;
FILE_LOG(logDEBUG) << "Getting High Voltage"; FILE_LOG(logDEBUG) << "Getting High Voltage";
disconnect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage())); disconnect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
try { try {
// dac units // dac units
auto retval = myDet->setDAC(-1, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1); auto retval = det->getHighVoltage({comboDetector->currentIndex() - 1}).tsquash("Inconsistent values for high voltage.");
//spinHV
if (spinHV->isVisible()) { if (spinHV->isVisible()) {
if (retval != 0 && retval != -1 && retval < HV_MIN && retval > HV_MAX) { if (retval != 0 && retval < HV_MIN && retval > HV_MAX) {
qDefs::Message(qDefs::WARNING, std::string("Unknown High Voltage: ") + std::to_string(retval), "qTabDeveloper::GetHighVoltage"); throw sls::RuntimeError(std::string("Unknown High Voltage: ") + std::to_string(retval));
} else{
spinHV->setValue(retval);
} }
} else { spinHV->setValue(retval);
}
// combo HV
else {
switch (retval) { switch (retval) {
case -1:
qDefs::Message(qDefs::WARNING, "Different values for high voltage.", "qTabDeveloper::GetHighVoltage");
break;
case 0: case 0:
comboHV->setCurrentIndex(HV_0); comboHV->setCurrentIndex(HV_0);
break; break;
@ -176,13 +175,10 @@ void qTabDeveloper::GetHighVoltage() {
comboHV->setCurrentIndex(HV_200); comboHV->setCurrentIndex(HV_200);
break; break;
default: default:
qDefs::Message(qDefs::WARNING, std::string("Unknown High Voltage: ") + std::to_string(retval), "qTabDeveloper::GetHighVoltage"); throw sls::RuntimeError(std::string("Unknown High Voltage: ") + std::to_string(retval));
break;
} }
} }
} CATCH_DISPLAY ("Could not get high voltage.", "qTabDeveloper::GetHighVoltage") } CATCH_DISPLAY ("Could not get high voltage.", "qTabDeveloper::GetHighVoltage")
connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage())); connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
} }
@ -192,7 +188,7 @@ void qTabDeveloper::SetHighVoltage() {
FILE_LOG(logINFO) << "Setting high voltage:" << val; FILE_LOG(logINFO) << "Setting high voltage:" << val;
try { try {
myDet->setDAC(val, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1); det->setHighVoltage({comboDetector->currentIndex() - 1});
} CATCH_HANDLE ("Could not set high voltage.", "qTabDeveloper::SetHighVoltage", } CATCH_HANDLE ("Could not set high voltage.", "qTabDeveloper::SetHighVoltage",
this, &qTabDeveloper::GetHighVoltage) this, &qTabDeveloper::GetHighVoltage)
} }

View File

@ -10,7 +10,7 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
qTabMeasurement::qTabMeasurement(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) : QWidget(parent), myDet(detector), myPlot(plot), qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector, qDrawPlot *p) : QWidget(parent), det(detector), plot(p),
progressTimer(nullptr) { progressTimer(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -43,7 +43,7 @@ void qTabMeasurement::SetupWidgetWindow() {
spinDelay->setEnabled(true); spinDelay->setEnabled(true);
comboDelayUnit->setEnabled(true); comboDelayUnit->setEnabled(true);
// enabling according to det type // enabling according to det type
switch(myDet->getDetectorTypeAsEnum()) { switch(det->getDetectorType().squash()) {
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
lblNumSamples->setEnabled(true); lblNumSamples->setEnabled(true);
spinNumSamples->setEnabled(true); spinNumSamples->setEnabled(true);
@ -111,7 +111,7 @@ void qTabMeasurement::SetupTimingMode() {
item[i] = model->itemFromIndex(index[i]); item[i] = model->itemFromIndex(index[i]);
} }
if (myDet->getDetectorTypeAsEnum() != slsDetectorDefs::EIGER) { if (det->getDetectorType().squash() != slsDetectorDefs::EIGER) {
item[(int)GATED]->setEnabled(false); item[(int)GATED]->setEnabled(false);
item[(int)BURST_TRIGGER]->setEnabled(false); item[(int)BURST_TRIGGER]->setEnabled(false);
} }
@ -156,7 +156,7 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
lblExpTime->setEnabled(true); lblExpTime->setEnabled(true);
spinExpTime->setEnabled(true); spinExpTime->setEnabled(true);
comboExpUnit->setEnabled(true); comboExpUnit->setEnabled(true);
if (myDet->getDetectorTypeAsEnum() == slsDetectorDefs::EIGER) { if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
spinNumFrames->setValue(1); spinNumFrames->setValue(1);
} else { } else {
// #frames, period, delay // #frames, period, delay
@ -198,14 +198,10 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
void qTabMeasurement::GetTimingMode() { void qTabMeasurement::GetTimingMode() {
FILE_LOG(logDEBUG) << "Getting timing mode"; FILE_LOG(logDEBUG) << "Getting timing mode";
connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));
try { try {
auto oldMode = comboTimingMode->currentIndex(); auto oldMode = comboTimingMode->currentIndex();
auto retval = myDet->setTimingMode(); auto retval = det->getTimingMode().tsquash("Inconsistent timing mode for all detectors.");
switch(retval) { switch(retval) {
case slsDetectorDefs::GET_TIMING_MODE:
qDefs::Message(qDefs::WARNING, "Timing Mode is inconsistent for all detectors.", "qTabMeasurement::GetTimingMode");
break;
case slsDetectorDefs::AUTO_TIMING: case slsDetectorDefs::AUTO_TIMING:
case slsDetectorDefs::TRIGGER_EXPOSURE: case slsDetectorDefs::TRIGGER_EXPOSURE:
case slsDetectorDefs::GATED: case slsDetectorDefs::GATED:
@ -217,19 +213,16 @@ void qTabMeasurement::GetTimingMode() {
} }
break; break;
default: default:
qDefs::Message(qDefs::WARNING, std::string("Unknown timing mode: ")+ std::to_string(retval), "qTabMeasurement::GetTimingMode"); throw sls::RuntimeError(std::string("Unknown timing mode: ")+ std::to_string(retval));
break;
} }
} CATCH_DISPLAY("Could not get timing mode.", "qTabMeasurement::GetTimingMode") } CATCH_DISPLAY("Could not get timing mode.", "qTabMeasurement::GetTimingMode")
disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));
} }
void qTabMeasurement::SetTimingMode(int val) { void qTabMeasurement::SetTimingMode(int val) {
FILE_LOG(logINFO) << "Setting timing mode:" << comboTimingMode->currentText().toAscii().data(); FILE_LOG(logINFO) << "Setting timing mode:" << comboTimingMode->currentText().toAscii().data();
try { try {
myDet->setTimingMode(static_cast<slsDetectorDefs::timingMode>(val)); det->setTimingMode(static_cast<slsDetectorDefs::timingMode>(val));
EnableWidgetsforTimingMode(); EnableWidgetsforTimingMode();
} CATCH_HANDLE("Could not set timing mode.", "qTabMeasurement::SetTimingMode", this, &qTabMeasurement::GetTimingMode) } CATCH_HANDLE("Could not set timing mode.", "qTabMeasurement::SetTimingMode", this, &qTabMeasurement::GetTimingMode)
} }
@ -242,74 +235,51 @@ void qTabMeasurement::SetNumMeasurements(int val) {
void qTabMeasurement::GetNumFrames() { void qTabMeasurement::GetNumFrames() {
FILE_LOG(logDEBUG) << "Getting number of frames"; FILE_LOG(logDEBUG) << "Getting number of frames";
disconnect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int))); disconnect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int)));
try { try {
auto retval = myDet->setTimer(slsDetectorDefs::FRAME_NUMBER); auto retval = det->getNumberOfFrames().tsquash("Inconsistent number of frames for all detectors.");
if (retval == -1) {
qDefs::Message(qDefs::WARNING, "Number of frames is inconsistent for all detectors.", "qTabMeasurement::GetNumFrames");
}
spinNumFrames->setValue(retval); spinNumFrames->setValue(retval);
} CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumFrames") } CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumFrames")
connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int))); connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int)));
} }
void qTabMeasurement::SetNumFrames(int val) { void qTabMeasurement::SetNumFrames(int val) {
FILE_LOG(logINFO) << "Setting number of frames to " << val; FILE_LOG(logINFO) << "Setting number of frames to " << val;
try { try {
myDet->setTimer(slsDetectorDefs::FRAME_NUMBER, val); det->setNumberOfFrames(val);
} CATCH_HANDLE("Could not set number of frames.", "qTabMeasurement::SetNumFrames", this, &qTabMeasurement::GetNumFrames) } CATCH_HANDLE("Could not set number of frames.", "qTabMeasurement::SetNumFrames", this, &qTabMeasurement::GetNumFrames)
} }
void qTabMeasurement::GetNumTriggers() { void qTabMeasurement::GetNumTriggers() {
FILE_LOG(logDEBUG) << "Getting number of triggers"; FILE_LOG(logDEBUG) << "Getting number of triggers";
disconnect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int))); disconnect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int)));
try { try {
auto retval = myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER); auto retval = det->getNumberOfTriggers().tsquash("Inconsistent number of triggers for all detectors.");
if (retval == -1) {
qDefs::Message(qDefs::WARNING, "Number of triggers is inconsistent for all detectors.", "qTabMeasurement::GetNumTriggers");
}
spinNumTriggers->setValue(retval); spinNumTriggers->setValue(retval);
} CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumTriggers") } CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumTriggers")
connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int))); connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int)));
} }
void qTabMeasurement::SetNumTriggers(int val) { void qTabMeasurement::SetNumTriggers(int val) {
FILE_LOG(logINFO) << "Setting number of triggers to " << val; FILE_LOG(logINFO) << "Setting number of triggers to " << val;
try { try {
myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER, val); det->setNumberOfTriggers(val);
} CATCH_HANDLE("Could not set number of triggers.", "qTabMeasurement::SetNumTriggers", this, &qTabMeasurement::GetNumTriggers) } CATCH_HANDLE("Could not set number of triggers.", "qTabMeasurement::SetNumTriggers", this, &qTabMeasurement::GetNumTriggers)
} }
void qTabMeasurement::GetNumSamples() { void qTabMeasurement::GetNumSamples() {
FILE_LOG(logDEBUG) << "Getting number of samples"; FILE_LOG(logDEBUG) << "Getting number of samples";
disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int)));
try { try {
auto retval = myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES); auto retval = det->getNumberOfAnalogSamples().tsquash("Inconsistent number of analog samples for all detectors.");
if (retval == -1) {
qDefs::Message(qDefs::WARNING, "Number of analog samples is inconsistent for all detectors.", "qTabMeasurement::GetNumSamples");
}
retval = myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES);
if (retval == -1) {
qDefs::Message(qDefs::WARNING, "Number of digital samples is inconsistent for all detectors.", "qTabMeasurement::GetNumSamples");
}
spinNumSamples->setValue(retval); spinNumSamples->setValue(retval);
} CATCH_DISPLAY ("Could not get number of samples.", "qTabMeasurement::GetNumSamples") } CATCH_DISPLAY ("Could not get number of samples.", "qTabMeasurement::GetNumSamples")
connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int)));
} }
void qTabMeasurement::SetNumSamples(int val) { void qTabMeasurement::SetNumSamples(int val) {
FILE_LOG(logINFO) << "Setting number of samples to " << val; FILE_LOG(logINFO) << "Setting number of samples to " << val;
try { try {
myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES, val); det->setNumberOfAnalogSamples(val);
myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES, val);
} CATCH_HANDLE("Could not set number of samples.", "qTabMeasurement::SetNumSamples", this, &qTabMeasurement::GetNumSamples) } CATCH_HANDLE("Could not set number of samples.", "qTabMeasurement::SetNumSamples", this, &qTabMeasurement::GetNumSamples)
} }
@ -317,21 +287,14 @@ void qTabMeasurement::GetExposureTime() {
FILE_LOG(logDEBUG) << "Getting exposure time"; FILE_LOG(logDEBUG) << "Getting exposure time";
disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime()));
disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime()));
try { try {
auto retval = myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME); spinExpTime->setValue(-1);
if (retval == -1) { auto retval = det->getExptime().tsquash("Inconsistent exposure time for all detectors.");
qDefs::Message(qDefs::WARNING, "Exposure Time is inconsistent for all detectors.", "qTabMeasurement::GetExposureTime"); auto time = qDefs::getUserFriendlyTime(retval);
spinExpTime->setValue(-1); spinExpTime->setValue(time.first);
} else { comboExpUnit->setCurrentIndex(static_cast<int>(time.second));
auto time = qDefs::getCorrectTime(static_cast<double>(retval) * (1E-9)); CheckAcqPeriodGreaterThanExp();
spinExpTime->setValue(time.first);
comboExpUnit->setCurrentIndex(static_cast<int>(time.second));
CheckAcqPeriodGreaterThanExp();
}
} CATCH_DISPLAY ("Could not get exposure time.", "qTabMeasurement::GetExposureTime") } CATCH_DISPLAY ("Could not get exposure time.", "qTabMeasurement::GetExposureTime")
connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime()));
connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime()));
} }
@ -340,10 +303,9 @@ void qTabMeasurement::SetExposureTime() {
auto val = spinExpTime->value(); auto val = spinExpTime->value();
auto unit = static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex());
FILE_LOG(logINFO) << "Setting exposure time to " << val << " " << qDefs::getUnitString(unit); FILE_LOG(logINFO) << "Setting exposure time to " << val << " " << qDefs::getUnitString(unit);
try { try {
double timeNS = qDefs::getNSTime(unit, val); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME, std::lround(timeNS)); det->setExptime(timeNS);
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} CATCH_HANDLE("Could not set exposure time.", "qTabMeasurement::SetExposureTime", this, &qTabMeasurement::GetExposureTime) } CATCH_HANDLE("Could not set exposure time.", "qTabMeasurement::SetExposureTime", this, &qTabMeasurement::GetExposureTime)
} }
@ -352,21 +314,14 @@ void qTabMeasurement::GetAcquisitionPeriod() {
FILE_LOG(logDEBUG) << "Getting acquisition period"; FILE_LOG(logDEBUG) << "Getting acquisition period";
disconnect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod())); disconnect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod()));
disconnect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod())); disconnect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod()));
try { try {
auto retval = myDet->setTimer(slsDetectorDefs::FRAME_PERIOD); spinPeriod->setValue(-1);
if (retval == -1) { auto retval = det->getPeriod().tsquash("Inconsistent acquisition period for all detectors.");
qDefs::Message(qDefs::WARNING, "Acquisition Period is inconsistent for all detectors.", "qTabMeasurement::GetAcquisitionPeriod"); auto time = qDefs::getUserFriendlyTime(retval);
spinPeriod->setValue(-1); spinPeriod->setValue(time.first);
} else { comboPeriodUnit->setCurrentIndex(static_cast<int>(time.second));
auto time = qDefs::getCorrectTime(static_cast<double>(retval) * (1E-9)); CheckAcqPeriodGreaterThanExp();
spinPeriod->setValue(time.first);
comboPeriodUnit->setCurrentIndex(static_cast<int>(time.second));
CheckAcqPeriodGreaterThanExp();
}
} CATCH_DISPLAY ("Could not get acquisition period.", "qTabMeasurement::GetAcquisitionPeriod") } CATCH_DISPLAY ("Could not get acquisition period.", "qTabMeasurement::GetAcquisitionPeriod")
connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod())); connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod()));
connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod())); connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod()));
} }
@ -375,10 +330,9 @@ void qTabMeasurement::SetAcquisitionPeriod() {
auto val = spinPeriod->value(); auto val = spinPeriod->value();
auto unit = static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex());
FILE_LOG(logINFO) << "Setting acquisition period to " << val << " " << qDefs::getUnitString(unit); FILE_LOG(logINFO) << "Setting acquisition period to " << val << " " << qDefs::getUnitString(unit);
try { try {
double timeNS = qDefs::getNSTime(unit, val); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
myDet->setTimer(slsDetectorDefs::FRAME_PERIOD, std::lround(timeNS)); det->setPeriod(timeNS);
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} CATCH_HANDLE("Could not set acquisition period.", "qTabMeasurement::SetAcquisitionPeriod", this, &qTabMeasurement::GetAcquisitionPeriod) } CATCH_HANDLE("Could not set acquisition period.", "qTabMeasurement::SetAcquisitionPeriod", this, &qTabMeasurement::GetAcquisitionPeriod)
} }
@ -387,8 +341,8 @@ void qTabMeasurement::CheckAcqPeriodGreaterThanExp() {
FILE_LOG(logDEBUG) << "Checking period >= exptime"; FILE_LOG(logDEBUG) << "Checking period >= exptime";
bool error = false; bool error = false;
if (lblPeriod->isEnabled()) { if (lblPeriod->isEnabled()) {
double exptimeNS = qDefs::getNSTime(static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex()), spinExpTime->value()); auto exptimeNS = qDefs::getNSTime(std::make_pair(spinExpTime->value(), static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex())));
double acqtimeNS = qDefs::getNSTime(static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex()), spinPeriod->value()); auto acqtimeNS = qDefs::getNSTime(std::make_pair(spinPeriod->value(), static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex())));
if (exptimeNS > acqtimeNS) { if (exptimeNS > acqtimeNS) {
error = true; error = true;
spinPeriod->setToolTip(errPeriodTip); spinPeriod->setToolTip(errPeriodTip);
@ -410,21 +364,13 @@ void qTabMeasurement::GetDelay() {
FILE_LOG(logDEBUG) << "Getting delay"; FILE_LOG(logDEBUG) << "Getting delay";
disconnect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay())); disconnect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay()));
disconnect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay())); disconnect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay()));
try { try {
auto retval = myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER); spinDelay->setValue(-1);
if (retval == -1) { auto retval = det->getDelayAfterTrigger().tsquash("Inconsistent delay for all detectors.");
qDefs::Message(qDefs::WARNING, "Delay is inconsistent for all detectors.", "qTabMeasurement::GetDelay"); auto time = qDefs::getUserFriendlyTime(retval);
spinDelay->setValue(-1); spinDelay->setValue(time.first);
} else { comboDelayUnit->setCurrentIndex(static_cast<int>(time.second));
auto time = qDefs::getCorrectTime(static_cast<double>(retval) * (1E-9));
spinDelay->setValue(time.first);
comboDelayUnit->setCurrentIndex(static_cast<int>(time.second));
CheckAcqPeriodGreaterThanExp();
}
} CATCH_DISPLAY ("Could not get delay.", "qTabMeasurement::GetDelay") } CATCH_DISPLAY ("Could not get delay.", "qTabMeasurement::GetDelay")
connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay())); connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay()));
connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay())); connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay()));
} }
@ -433,61 +379,45 @@ void qTabMeasurement::SetDelay() {
auto val = spinDelay->value(); auto val = spinDelay->value();
auto unit = static_cast<qDefs::timeUnit>(comboDelayUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboDelayUnit->currentIndex());
FILE_LOG(logINFO) << "Setting delay to " << val << " " << qDefs::getUnitString(unit); FILE_LOG(logINFO) << "Setting delay to " << val << " " << qDefs::getUnitString(unit);
try { try {
double timeNS = qDefs::getNSTime(unit, val); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER, std::lround(timeNS)); det->setDelayAfterTrigger(timeNS);
CheckAcqPeriodGreaterThanExp();
} CATCH_HANDLE("Could not set delay.", "qTabMeasurement::SetDelay", this, &qTabMeasurement::GetDelay) } CATCH_HANDLE("Could not set delay.", "qTabMeasurement::SetDelay", this, &qTabMeasurement::GetDelay)
} }
void qTabMeasurement::GetFileWrite() { void qTabMeasurement::GetFileWrite() {
FILE_LOG(logDEBUG) << "Getting File Write Enable"; FILE_LOG(logDEBUG) << "Getting File Write Enable";
disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
try { try {
dispFileName->setEnabled(true); // default, even when exception dispFileName->setEnabled(true); // default, even when exception
lblIndex->setEnabled(true); lblIndex->setEnabled(true);
spinIndex->setEnabled(true); spinIndex->setEnabled(true);
int retval = myDet->getFileWrite(); auto retval = det->getFileWrite().tsquash("Inconsistent file write for all detectors.");
if (retval == -1) { chkFile->setChecked(retval);
qDefs::Message(qDefs::WARNING, "File write is inconsistent for all detectors.", "qTabMeasurement::GetFileWrite"); dispFileName->setEnabled(retval);
dispFileName->setEnabled(true); lblIndex->setEnabled(retval);
lblIndex->setEnabled(true); spinIndex->setEnabled(retval);
spinIndex->setEnabled(true);
} else {
bool enable = (retval == 0 ? false : true);
chkFile->setChecked(enable);
dispFileName->setEnabled(enable);
lblIndex->setEnabled(enable);
spinIndex->setEnabled(enable);
}
} CATCH_DISPLAY ("Could not get file over write enable.", "qTabMeasurement::GetFileWrite") } CATCH_DISPLAY ("Could not get file over write enable.", "qTabMeasurement::GetFileWrite")
connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
} }
void qTabMeasurement::SetFileWrite(bool val) { void qTabMeasurement::SetFileWrite(bool val) {
FILE_LOG(logINFO) << "Set File Write to " << val; FILE_LOG(logINFO) << "Set File Write to " << val;
try { try {
myDet->setFileWrite(val); det->setFileWrite(val);
bool enable = chkFile->isChecked(); dispFileName->setEnabled(val);
dispFileName->setEnabled(enable); lblIndex->setEnabled(val);
lblIndex->setEnabled(enable); spinIndex->setEnabled(val);
spinIndex->setEnabled(enable);
} CATCH_HANDLE("Could not set file write enable.", "qTabMeasurement::SetFileWrite", this, &qTabMeasurement::GetFileWrite) } CATCH_HANDLE("Could not set file write enable.", "qTabMeasurement::SetFileWrite", this, &qTabMeasurement::GetFileWrite)
} }
void qTabMeasurement::GetFileName() { void qTabMeasurement::GetFileName() {
FILE_LOG(logDEBUG) << "Getting file name prefix"; FILE_LOG(logDEBUG) << "Getting file name prefix";
disconnect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName())); disconnect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName()));
try { try {
auto retval = myDet->getFileName(); auto retval = det->getFileNamePrefix().tsquash("Inconsistent file name prefix for all detectors.");
dispFileName->setText(QString(retval.c_str())); dispFileName->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get file name prefix.", "qTabMeasurement::GetFileName") } CATCH_DISPLAY ("Could not get file name prefix.", "qTabMeasurement::GetFileName")
connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName())); connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName()));
} }
@ -495,7 +425,7 @@ void qTabMeasurement::SetFileName() {
std::string val = std::string(dispFileName->text().toAscii().constData()); std::string val = std::string(dispFileName->text().toAscii().constData());
FILE_LOG(logINFO) << "Setting File Name Prefix:" << val; FILE_LOG(logINFO) << "Setting File Name Prefix:" << val;
try { try {
myDet->setFileName(val); det->setFileNamePrefix(val);
} CATCH_HANDLE("Could not set file name prefix.", "qTabMeasurement::SetFileName", this, &qTabMeasurement::GetFileName) } CATCH_HANDLE("Could not set file name prefix.", "qTabMeasurement::SetFileName", this, &qTabMeasurement::GetFileName)
emit FileNameChangedSignal(dispFileName->text()); emit FileNameChangedSignal(dispFileName->text());
@ -504,43 +434,34 @@ void qTabMeasurement::SetFileName() {
void qTabMeasurement::GetRunIndex() { void qTabMeasurement::GetRunIndex() {
FILE_LOG(logDEBUG) << "Getting Acquisition File index"; FILE_LOG(logDEBUG) << "Getting Acquisition File index";
disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int))); disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int)));
try { try {
auto retval = myDet->getFileIndex(); auto retval = det->getAcquisitonIndex().tsquash("Inconsistent file index for all detectors.");
if (retval == -1) {
qDefs::Message(qDefs::WARNING, "Acquisition File Index is inconsistent for all detectors.", "qTabMeasurement::GetRunIndex");
}
spinIndex->setValue(retval); spinIndex->setValue(retval);
} CATCH_DISPLAY ("Could not get acquisition file index.", "qTabMeasurement::GetRunIndex") } CATCH_DISPLAY ("Could not get acquisition file index.", "qTabMeasurement::GetRunIndex")
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int))); connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int)));
} }
void qTabMeasurement::SetRunIndex(int val) { void qTabMeasurement::SetRunIndex(int val) {
FILE_LOG(logINFO) << "Setting Acquisition File Index to " << val; FILE_LOG(logINFO) << "Setting Acquisition File Index to " << val;
try { try {
myDet->setFileIndex(val); det->setAcquisitionIndex(val);
} CATCH_HANDLE("Could not set acquisition file index.", "qTabMeasurement::SetRunIndex", this, &qTabMeasurement::GetRunIndex) } CATCH_HANDLE("Could not set acquisition file index.", "qTabMeasurement::SetRunIndex", this, &qTabMeasurement::GetRunIndex)
} }
void qTabMeasurement::GetStartingFrameNumber() { void qTabMeasurement::GetStartingFrameNumber() {
FILE_LOG(logDEBUG) << "Getting Starting Frame Number"; FILE_LOG(logDEBUG) << "Getting Starting Frame Number";
disconnect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this, SLOT(SetStartingFrameNumber(int))); disconnect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this, SLOT(SetStartingFrameNumber(int)));
try { try {
auto retval = myDet->getStartingFrameNumber(); auto retval = det->getStartingFrameNumber().tsquash("Inconsistent starting frame number for all detectors.");
spinStartingFrameNumber->setValue(retval); spinStartingFrameNumber->setValue(retval);
} CATCH_DISPLAY ("Could not get starting frame number.", "qTabMeasurement::GetStartingFrameNumber") } CATCH_DISPLAY ("Could not get starting frame number.", "qTabMeasurement::GetStartingFrameNumber")
connect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this, SLOT(SetStartingFrameNumber(int))); connect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this, SLOT(SetStartingFrameNumber(int)));
} }
void qTabMeasurement::SetStartingFrameNumber(int val) { void qTabMeasurement::SetStartingFrameNumber(int val) {
FILE_LOG(logINFO) << "Setting Starting frame number to " << val; FILE_LOG(logINFO) << "Setting Starting frame number to " << val;
try { try {
myDet->setStartingFrameNumber(val); det->setStartingFrameNumber(val);
} CATCH_HANDLE("Could not set starting frame number.", "qTabMeasurement::SetStartingFrameNumber", this, &qTabMeasurement::GetStartingFrameNumber) } CATCH_HANDLE("Could not set starting frame number.", "qTabMeasurement::SetStartingFrameNumber", this, &qTabMeasurement::GetStartingFrameNumber)
} }
@ -553,28 +474,19 @@ void qTabMeasurement::ResetProgress() {
void qTabMeasurement::UpdateProgress() { void qTabMeasurement::UpdateProgress() {
FILE_LOG(logDEBUG) << "Updating progress"; FILE_LOG(logDEBUG) << "Updating progress";
progressBar->setValue(myPlot->GetProgress()); progressBar->setValue(plot->GetProgress());
lblCurrentFrame->setText(QString::number(myPlot->GetCurrentFrameIndex())); lblCurrentFrame->setText(QString::number(plot->GetCurrentFrameIndex()));
lblCurrentMeasurement->setText(QString::number(currentMeasurement)); lblCurrentMeasurement->setText(QString::number(currentMeasurement));
} }
int qTabMeasurement::VerifyOutputDirectoryError() { int qTabMeasurement::VerifyOutputDirectoryError() {
try { try {
auto retval = myDet->getFilePath(); auto retval = det->getFilePath();
// multi for (auto &it : retval) {
if (retval.find('+') == std::string::npos) { det->setFilePath(it);
myDet->setFilePath(retval);
}
//single
else {
const auto &paths = sls::split(retval, '+');
for (size_t det = 0; det < paths.size(); ++det) {
myDet->setFilePath(paths[det], det);
}
} }
return slsDetectorDefs::OK; return slsDetectorDefs::OK;
} CATCH_DISPLAY ("Could not set path.", "qTabMeasurement::VerifyOutputDirectoryError") } CATCH_DISPLAY ("Could not set path.", "qTabMeasurement::VerifyOutputDirectoryError")
return slsDetectorDefs::FAIL; // for exception return slsDetectorDefs::FAIL; // for exception
} }
@ -597,7 +509,7 @@ void qTabMeasurement::StartAcquisition() {
} }
FILE_LOG(logINFOBLUE) << "Starting Acquisition"; FILE_LOG(logINFOBLUE) << "Starting Acquisition";
myPlot->SetRunning(true); plot->SetRunning(true);
isAcquisitionStopped = false; isAcquisitionStopped = false;
currentMeasurement = 0; currentMeasurement = 0;
ResetProgress(); ResetProgress();
@ -612,7 +524,7 @@ void qTabMeasurement::StopAcquisition() {
FILE_LOG(logINFORED) << "Stopping Acquisition"; FILE_LOG(logINFORED) << "Stopping Acquisition";
try{ try{
isAcquisitionStopped = true; isAcquisitionStopped = true;
myDet->stopAcquisition(); det->stopAcquisition();
} CATCH_DISPLAY("Could not stop acquisition.", "qTabMeasurement::StopAcquisition") } CATCH_DISPLAY("Could not stop acquisition.", "qTabMeasurement::StopAcquisition")
} }
@ -629,13 +541,13 @@ void qTabMeasurement::AcquireFinished() {
// next measurement if acq is not stopped // next measurement if acq is not stopped
if (!isAcquisitionStopped && ((currentMeasurement + 1) < numMeasurements)) { if (!isAcquisitionStopped && ((currentMeasurement + 1) < numMeasurements)) {
++currentMeasurement; ++currentMeasurement;
myPlot->StartAcquisition(); plot->StartAcquisition();
} }
// end of acquisition // end of acquisition
else { else {
progressTimer->stop(); progressTimer->stop();
Enable(1); Enable(1);
myPlot->SetRunning(false); plot->SetRunning(false);
btnStart->setEnabled(true); btnStart->setEnabled(true);
emit EnableTabsSignal(true); emit EnableTabsSignal(true);
} }
@ -659,7 +571,7 @@ void qTabMeasurement::Enable(bool enable) {
void qTabMeasurement::Refresh() { void qTabMeasurement::Refresh() {
FILE_LOG(logDEBUG) << "**Updating Measurement Tab"; FILE_LOG(logDEBUG) << "**Updating Measurement Tab";
if (!myPlot->GetIsRunning()) { if (!plot->GetIsRunning()) {
GetTimingMode(); GetTimingMode();
GetNumFrames(); GetNumFrames();
GetExposureTime(); GetExposureTime();

View File

@ -19,8 +19,8 @@ QString qTabPlot::defaultImageYAxisTitle("Pixel");
QString qTabPlot::defaultImageZAxisTitle("Intensity"); QString qTabPlot::defaultImageZAxisTitle("Intensity");
qTabPlot::qTabPlot(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) : qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p) :
QWidget(parent), myDet(detector), myPlot(plot), is1d(false) { QWidget(parent), det(detector), plot(p), is1d(false) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Plot ready"; FILE_LOG(logDEBUG) << "Plot ready";
@ -57,7 +57,7 @@ void qTabPlot::SetupWidgetWindow() {
// enabling according to det type // enabling according to det type
is1d = false; is1d = false;
switch(myDet->getDetectorTypeAsEnum()) { switch(det->getDetectorType().squash()) {
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
is1d = true; is1d = true;
break; break;
@ -95,27 +95,27 @@ void qTabPlot::Initialization() {
// 1D options // 1D options
connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool))); connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool)));
connect(spinPersistency, SIGNAL(valueChanged(int)), myPlot, SLOT(SetPersistency(int))); connect(spinPersistency, SIGNAL(valueChanged(int)), plot, SLOT(SetPersistency(int)));
connect(chkPoints, SIGNAL(toggled(bool)), myPlot, SLOT(SetMarkers(bool))); connect(chkPoints, SIGNAL(toggled(bool)), plot, SLOT(SetMarkers(bool)));
connect(chkLines, SIGNAL(toggled(bool)), myPlot, SLOT(SetLines(bool))); connect(chkLines, SIGNAL(toggled(bool)), plot, SLOT(SetLines(bool)));
connect(chk1DLog, SIGNAL(toggled(bool)), myPlot, SLOT(Set1dLogY(bool))); connect(chk1DLog, SIGNAL(toggled(bool)), plot, SLOT(Set1dLogY(bool)));
connect(chkStatistics, SIGNAL(toggled(bool)), myPlot, SLOT(DisplayStatistics(bool))); connect(chkStatistics, SIGNAL(toggled(bool)), plot, SLOT(DisplayStatistics(bool)));
// 2D Plot box // 2D Plot box
connect(chkInterpolate, SIGNAL(toggled(bool)), myPlot, SLOT(SetInterpolate(bool))); connect(chkInterpolate, SIGNAL(toggled(bool)), plot, SLOT(SetInterpolate(bool)));
connect(chkContour, SIGNAL(toggled(bool)), myPlot, SLOT(SetContour(bool))); connect(chkContour, SIGNAL(toggled(bool)), plot, SLOT(SetContour(bool)));
connect(chkLogz, SIGNAL(toggled(bool)), myPlot, SLOT(SetLogz(bool))); connect(chkLogz, SIGNAL(toggled(bool)), plot, SLOT(SetLogz(bool)));
connect(chkStatistics_2, SIGNAL(toggled(bool)), myPlot, SLOT(DisplayStatistics(bool))); connect(chkStatistics_2, SIGNAL(toggled(bool)), plot, SLOT(DisplayStatistics(bool)));
//pedstal //pedstal
connect(chkPedestal, SIGNAL(toggled(bool)), myPlot, SLOT(SetPedestal(bool))); connect(chkPedestal, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool)));
connect(btnRecalPedestal, SIGNAL(clicked()), myPlot, SLOT(RecalculatePedestal())); connect(btnRecalPedestal, SIGNAL(clicked()), plot, SLOT(RecalculatePedestal()));
connect(chkPedestal_2, SIGNAL(toggled(bool)), myPlot, SLOT(SetPedestal(bool))); connect(chkPedestal_2, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool)));
connect(btnRecalPedestal_2, SIGNAL(clicked()), myPlot, SLOT(RecalculatePedestal())); connect(btnRecalPedestal_2, SIGNAL(clicked()), plot, SLOT(RecalculatePedestal()));
//accumulate //accumulate
connect(chkAccumulate, SIGNAL(toggled(bool)), myPlot, SLOT(SetAccumulate(bool))); connect(chkAccumulate, SIGNAL(toggled(bool)), plot, SLOT(SetAccumulate(bool)));
connect(btnResetAccumulate, SIGNAL(clicked()), myPlot, SLOT(ResetAccumulate())); connect(btnResetAccumulate, SIGNAL(clicked()), plot, SLOT(ResetAccumulate()));
connect(chkAccumulate_2, SIGNAL(toggled(bool)), myPlot, SLOT(SetAccumulate(bool))); connect(chkAccumulate_2, SIGNAL(toggled(bool)), plot, SLOT(SetAccumulate(bool)));
connect(btnResetAccumulate_2, SIGNAL(clicked()), myPlot, SLOT(ResetAccumulate())); connect(btnResetAccumulate_2, SIGNAL(clicked()), plot, SLOT(ResetAccumulate()));
//binary //binary
connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary()));
connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary()));
@ -125,14 +125,14 @@ void qTabPlot::Initialization() {
connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
//gainplot //gainplot
if (chkGainPlot->isEnabled()) if (chkGainPlot->isEnabled())
connect(chkGainPlot, SIGNAL(toggled(bool)), myPlot, SLOT(EnableGainPlot(bool))); connect(chkGainPlot, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool)));
// gap pixels // gap pixels
if (chkGapPixels->isEnabled()) if (chkGapPixels->isEnabled())
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
// Save, clone // Save, clone
connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot())); connect(btnSave, SIGNAL(clicked()), plot, SLOT(SavePlot()));
connect(btnClone, SIGNAL(clicked()), myPlot, SLOT(ClonePlot())); connect(btnClone, SIGNAL(clicked()), plot, SLOT(ClonePlot()));
// Plot Axis // Plot Axis
connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
@ -171,7 +171,7 @@ void qTabPlot::Select1DPlot(bool enable) {
chkZMax->setEnabled(!enable); chkZMax->setEnabled(!enable);
dispZMin->setEnabled(!enable); dispZMin->setEnabled(!enable);
dispZMax->setEnabled(!enable); dispZMax->setEnabled(!enable);
myPlot->Select1dPlot(enable); plot->Select1dPlot(enable);
SetTitles(); SetTitles();
SetXYRange(); SetXYRange();
if (!is1d) { if (!is1d) {
@ -201,7 +201,7 @@ void qTabPlot::SetPlot() {
} }
} }
myPlot->SetDataCallBack(plotEnable); plot->SetDataCallBack(plotEnable);
} }
void qTabPlot::Set1DPlotOptionsRight() { void qTabPlot::Set1DPlotOptionsRight() {
@ -249,9 +249,9 @@ void qTabPlot::EnablePersistency(bool enable) {
lblPersistency->setEnabled(enable); lblPersistency->setEnabled(enable);
spinPersistency->setEnabled(enable); spinPersistency->setEnabled(enable);
if (enable) if (enable)
myPlot->SetPersistency(spinPersistency->value()); plot->SetPersistency(spinPersistency->value());
else else
myPlot->SetPersistency(0); plot->SetPersistency(0);
} }
void qTabPlot::SetBinary() { void qTabPlot::SetBinary() {
@ -263,38 +263,31 @@ void qTabPlot::SetBinary() {
lblTo->setEnabled(binary1D); lblTo->setEnabled(binary1D);
spinFrom->setEnabled(binary1D); spinFrom->setEnabled(binary1D);
spinTo->setEnabled(binary1D); spinTo->setEnabled(binary1D);
myPlot->SetBinary(binary1D, spinFrom->value(), spinTo->value()); plot->SetBinary(binary1D, spinFrom->value(), spinTo->value());
} else { } else {
FILE_LOG(logINFO) << "Binary Plot " << (binary2D ? "enabled" : "disabled"); FILE_LOG(logINFO) << "Binary Plot " << (binary2D ? "enabled" : "disabled");
lblFrom_2->setEnabled(binary2D); lblFrom_2->setEnabled(binary2D);
lblTo_2->setEnabled(binary2D); lblTo_2->setEnabled(binary2D);
spinFrom_2->setEnabled(binary2D); spinFrom_2->setEnabled(binary2D);
spinTo_2->setEnabled(binary2D); spinTo_2->setEnabled(binary2D);
myPlot->SetBinary(binary2D, spinFrom_2->value(), spinTo_2->value()); plot->SetBinary(binary2D, spinFrom_2->value(), spinTo_2->value());
} }
} }
void qTabPlot::GetGapPixels() { void qTabPlot::GetGapPixels() {
FILE_LOG(logDEBUG) << "Getting gap pixels"; FILE_LOG(logDEBUG) << "Getting gap pixels";
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
try { try {
auto retval = myDet->enableGapPixels(-1); auto retval = det->getRxAddGapPixels().tsquash("Inconsistent gap pixels enabled for all detectors.");
if (retval == -1) { chkGapPixels->setChecked(retval);
qDefs::Message(qDefs::WARNING, "Gap pixels enable is inconsistent for all detectors.", "qTabPlot::GetGapPixels");
} else {
chkGapPixels->setChecked(retval == 0 ? false : true);
}
} CATCH_DISPLAY ("Could not get gap pixels enable.", "qTabPlot::GetGapPixels") } CATCH_DISPLAY ("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
} }
void qTabPlot::SetGapPixels(bool enable) { void qTabPlot::SetGapPixels(bool enable) {
FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable; FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
try { try {
myDet->enableGapPixels(enable); det->setRxAddGapPixels(enable);
} CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels", this, &qTabPlot::GetGapPixels) } CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels", this, &qTabPlot::GetGapPixels)
} }
@ -311,31 +304,31 @@ void qTabPlot::SetTitles() {
// title // title
if (!chkTitle->isChecked() || dispTitle->text().isEmpty()) { if (!chkTitle->isChecked() || dispTitle->text().isEmpty()) {
myPlot->SetPlotTitlePrefix(""); plot->SetPlotTitlePrefix("");
dispTitle->setText(""); dispTitle->setText("");
} else { } else {
myPlot->SetPlotTitlePrefix(dispTitle->text()); plot->SetPlotTitlePrefix(dispTitle->text());
} }
// x // x
if (!chkXAxis->isChecked() || dispXAxis->text().isEmpty()) { if (!chkXAxis->isChecked() || dispXAxis->text().isEmpty()) {
dispXAxis->setText(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle); dispXAxis->setText(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle);
myPlot->SetXAxisTitle(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle); plot->SetXAxisTitle(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle);
} else { } else {
myPlot->SetXAxisTitle(dispXAxis->text()); plot->SetXAxisTitle(dispXAxis->text());
} }
// y // y
if (!chkYAxis->isChecked() || dispYAxis->text().isEmpty()) { if (!chkYAxis->isChecked() || dispYAxis->text().isEmpty()) {
dispYAxis->setText(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle); dispYAxis->setText(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle);
myPlot->SetYAxisTitle(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle); plot->SetYAxisTitle(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle);
} else { } else {
myPlot->SetYAxisTitle(dispYAxis->text()); plot->SetYAxisTitle(dispYAxis->text());
} }
// z // z
if (!chkZAxis->isChecked() || dispZAxis->text().isEmpty()) { if (!chkZAxis->isChecked() || dispZAxis->text().isEmpty()) {
myPlot->SetZAxisTitle(defaultImageZAxisTitle); plot->SetZAxisTitle(defaultImageZAxisTitle);
dispZAxis->setText(defaultImageZAxisTitle); dispZAxis->setText(defaultImageZAxisTitle);
} else { } else {
myPlot->SetZAxisTitle(dispZAxis->text()); plot->SetZAxisTitle(dispZAxis->text());
} }
connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
@ -395,7 +388,7 @@ void qTabPlot::SetXYRange() {
} }
} }
myPlot->SetXYRangeChanged(disablezoom, xyRange, isRange); plot->SetXYRangeChanged(disablezoom, xyRange, isRange);
emit DisableZoomSignal(disablezoom); emit DisableZoomSignal(disablezoom);
} }
@ -417,20 +410,20 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
chkYMin->setChecked(true); chkYMin->setChecked(true);
chkYMax->setChecked(true); chkYMax->setChecked(true);
if (dispXMin->text().isEmpty()) if (dispXMin->text().isEmpty())
dispXMin->setText(QString::number(myPlot->GetXMinimum())); dispXMin->setText(QString::number(plot->GetXMinimum()));
if (dispXMax->text().isEmpty()) if (dispXMax->text().isEmpty())
dispXMax->setText(QString::number(myPlot->GetXMaximum())); dispXMax->setText(QString::number(plot->GetXMaximum()));
if (dispYMin->text().isEmpty()) if (dispYMin->text().isEmpty())
dispYMin->setText(QString::number(myPlot->GetYMinimum())); dispYMin->setText(QString::number(plot->GetYMinimum()));
if (dispYMax->text().isEmpty()) if (dispYMax->text().isEmpty())
dispYMax->setText(QString::number(myPlot->GetYMaximum())); dispYMax->setText(QString::number(plot->GetYMaximum()));
// calculate ideal aspect ratio with previous limits // calculate ideal aspect ratio with previous limits
double ranges[4]; double ranges[4];
ranges[qDefs::XMIN] = myPlot->GetXMinimum(); ranges[qDefs::XMIN] = plot->GetXMinimum();
ranges[qDefs::XMAX] = myPlot->GetXMaximum(); ranges[qDefs::XMAX] = plot->GetXMaximum();
ranges[qDefs::YMIN] = myPlot->GetYMinimum(); ranges[qDefs::YMIN] = plot->GetYMinimum();
ranges[qDefs::YMAX] = myPlot->GetYMaximum(); ranges[qDefs::YMAX] = plot->GetYMaximum();
double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]); double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
FILE_LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio << " for x(" << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN] << " - " << ranges[qDefs::YMAX] << ")"; FILE_LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio << " for x(" << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN] << " - " << ranges[qDefs::YMAX] << ")";
@ -454,7 +447,7 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
double newval = 0; double newval = 0;
if (dimension == static_cast<int>(slsDetectorDefs::X)) { if (dimension == static_cast<int>(slsDetectorDefs::X)) {
newval = idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]) + ranges[qDefs::XMIN]; newval = idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]) + ranges[qDefs::XMIN];
if (newval <= myPlot->GetXMaximum()) { if (newval <= plot->GetXMaximum()) {
ranges[qDefs::XMAX] = newval; ranges[qDefs::XMAX] = newval;
dispXMax->setText(QString::number(newval)); dispXMax->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New XMax: " << newval; FILE_LOG(logDEBUG) << "New XMax: " << newval;
@ -468,7 +461,7 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
// adjust y // adjust y
else { else {
newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio) + ranges[qDefs::YMIN]; newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio) + ranges[qDefs::YMIN];
if (newval <= myPlot->GetYMaximum()) { if (newval <= plot->GetYMaximum()) {
ranges[qDefs::YMAX] = newval; ranges[qDefs::YMAX] = newval;
dispYMax->setText(QString::number(newval)); dispYMax->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New YMax: " << newval; FILE_LOG(logDEBUG) << "New YMax: " << newval;
@ -491,7 +484,7 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange())); connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
bool isRange[4] {true, true, true, true}; bool isRange[4] {true, true, true, true};
myPlot->SetXYRangeChanged(true, ranges, isRange); plot->SetXYRangeChanged(true, ranges, isRange);
emit DisableZoomSignal(true); emit DisableZoomSignal(true);
} }
@ -509,7 +502,7 @@ void qTabPlot::SetZRange() {
FILE_LOG(logDEBUG) << "Setting zmax to " << val; FILE_LOG(logDEBUG) << "Setting zmax to " << val;
zRange[1] = val; zRange[1] = val;
} }
myPlot->SetZRange(zRange, isZRange); plot->SetZRange(zRange, isZRange);
} }
void qTabPlot::GetStreamingFrequency() { void qTabPlot::GetStreamingFrequency() {
@ -518,26 +511,18 @@ void qTabPlot::GetStreamingFrequency() {
disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
try { try {
int freq = myDet->setReceiverStreamingFrequency(-1); int freq = det->getRxZmqFrequency().tsquash("Inconsistent receiver zmq streaming frequency for all detectors.");
if (freq < 0) {
qDefs::Message(qDefs::WARNING, "Streaming frequency is inconsistent for all detectors.", "qTabPlot::GetStreamingFrequency");
}
// time interval // time interval
else if (freq == 0) { if (freq == 0) {
comboFrequency->setCurrentIndex(0); comboFrequency->setCurrentIndex(0);
stackedTimeInterval->setCurrentIndex(0); stackedTimeInterval->setCurrentIndex(0);
try { try {
int timeMs = myDet->setReceiverStreamingTimer(-1); int timeMs = det->getRxZmqTimer().tsquash("Inconsistent receiver zmq streaming timer for all detectors.");
if (freq < 0) { auto timeNS = qDefs::getNSTime(std::make_pair(static_cast<double>(timeMs), qDefs::MILLISECONDS));
qDefs::Message(qDefs::WARNING, "Streaming timer is inconsistent for all detectors.", "qTabPlot::GetStreamingFrequency"); auto time = qDefs::getUserFriendlyTime(timeNS);
} else { spinTimeGap->setValue(time.first);
double timeS = static_cast<double>(timeMs) / 1000.00; comboTimeGapUnit->setCurrentIndex(static_cast<int>(time.second));
auto time = qDefs::getCorrectTime(timeS);
spinTimeGap->setValue(time.first);
comboTimeGapUnit->setCurrentIndex(static_cast<int>(time.second));
}
} CATCH_DISPLAY ("Could not get streaming timer.", "qTabPlot::GetStreamingFrequency") } CATCH_DISPLAY ("Could not get streaming timer.", "qTabPlot::GetStreamingFrequency")
} }
// every nth frame // every nth frame
@ -547,12 +532,10 @@ void qTabPlot::GetStreamingFrequency() {
spinNthFrame->setValue(freq); spinNthFrame->setValue(freq);
} }
} CATCH_DISPLAY ("Could not get streaming frequency.", "qTabPlot::GetStreamingFrequency") } CATCH_DISPLAY ("Could not get streaming frequency.", "qTabPlot::GetStreamingFrequency")
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
} }
void qTabPlot::SetStreamingFrequency() { void qTabPlot::SetStreamingFrequency() {
@ -564,11 +547,11 @@ void qTabPlot::SetStreamingFrequency() {
try { try {
if (frequency) { if (frequency) {
FILE_LOG(logINFO) << "Setting Streaming Frequency to " << freqVal; FILE_LOG(logINFO) << "Setting Streaming Frequency to " << freqVal;
myDet->setReceiverStreamingFrequency(freqVal); det->setRxZmqFrequency(freqVal);
} else { } else {
FILE_LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " " << qDefs::getUnitString(timeUnit); FILE_LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " " << qDefs::getUnitString(timeUnit);
double timeMS = qDefs::getMSTime(timeUnit, timeVal); auto timeMS = qDefs::getMSTime(std::make_pair(timeVal, timeUnit));
myDet->setReceiverStreamingTimer(timeMS); det->setRxZmqTimer(timeMS.count());
} }
} CATCH_HANDLE("Could not set streaming frequency/ timer.", "qTabPlot::SetStreamingFrequency", this, &qTabPlot::GetStreamingFrequency) } CATCH_HANDLE("Could not set streaming frequency/ timer.", "qTabPlot::SetStreamingFrequency", this, &qTabPlot::GetStreamingFrequency)
} }
@ -576,7 +559,7 @@ void qTabPlot::SetStreamingFrequency() {
void qTabPlot::Refresh() { void qTabPlot::Refresh() {
FILE_LOG(logDEBUG) << "**Updating Plot Tab"; FILE_LOG(logDEBUG) << "**Updating Plot Tab";
if (!myPlot->GetIsRunning()) { if (!plot->GetIsRunning()) {
boxPlotType->setEnabled(true); boxPlotType->setEnabled(true);
// streaming frequency // streaming frequency
@ -585,7 +568,7 @@ void qTabPlot::Refresh() {
} }
GetStreamingFrequency(); GetStreamingFrequency();
// gain plot, gap pixels enable // gain plot, gap pixels enable
switch(myDet->getDetectorTypeAsEnum()) { switch(det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
chkGapPixels->setEnabled(true); chkGapPixels->setEnabled(true);
GetGapPixels(); GetGapPixels();

View File

@ -6,7 +6,7 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
qTabSettings::qTabSettings(QWidget *parent, multiSlsDetector *detector): QWidget(parent), myDet(detector) { qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector): QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Settings ready"; FILE_LOG(logDEBUG) << "Settings ready";
@ -17,7 +17,7 @@ qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() { void qTabSettings::SetupWidgetWindow() {
// enabling according to det type // enabling according to det type
switch(myDet->getDetectorTypeAsEnum()) { switch(det->getDetectorType().squash()) {
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
lblSettings->setEnabled(false); lblSettings->setEnabled(false);
comboSettings->setEnabled(false); comboSettings->setEnabled(false);
@ -57,7 +57,7 @@ void qTabSettings::SetupDetectorSettings() {
item[i] = model->itemFromIndex(index[i]); item[i] = model->itemFromIndex(index[i]);
item[i]->setEnabled(false); item[i]->setEnabled(false);
} }
switch (myDet->getDetectorTypeAsEnum()) { switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
item[(int)STANDARD]->setEnabled(true); item[(int)STANDARD]->setEnabled(true);
item[(int)HIGHGAIN]->setEnabled(true); item[(int)HIGHGAIN]->setEnabled(true);
@ -106,13 +106,9 @@ void qTabSettings::Initialization() {
void qTabSettings::GetSettings() { void qTabSettings::GetSettings() {
FILE_LOG(logDEBUG) << "Getting settings"; FILE_LOG(logDEBUG) << "Getting settings";
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
try{ try{
auto retval = myDet->getSettings(-1); auto retval = det->getSettings().tsquash("Inconsistent settings for all detectors.");
switch (retval) { switch (retval) {
case -1:
qDefs::Message(qDefs::WARNING, "Settings are inconsistent for all detectors.", "qTabSettings::GetSettings");
break;
case slsDetectorDefs::UNDEFINED: case slsDetectorDefs::UNDEFINED:
comboSettings->setCurrentIndex(UNDEFINED); comboSettings->setCurrentIndex(UNDEFINED);
break; break;
@ -121,26 +117,22 @@ void qTabSettings::GetSettings() {
break; break;
default: default:
if ((int)retval < -1 || (int)retval >= NUMSETTINGS) { if ((int)retval < -1 || (int)retval >= NUMSETTINGS) {
qDefs::Message(qDefs::WARNING, std::string("Unknown settings: ") + std::to_string(retval), "qTabSettings::GetSettings"); throw sls::RuntimeError(std::string("Unknown settings: ") + std::to_string(retval));
} else {
comboSettings->setCurrentIndex(retval);
} }
comboSettings->setCurrentIndex(retval);
break; break;
} }
} CATCH_DISPLAY ("Could not get settings.", "qTabSettings::GetSettings") } CATCH_DISPLAY ("Could not get settings.", "qTabSettings::GetSettings")
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
} }
void qTabSettings::SetSettings(int index) { void qTabSettings::SetSettings(int index) {
// settings // settings
auto val = static_cast<slsDetectorDefs::detectorSettings>(index); auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
FILE_LOG(logINFO) << "Setting Settings to " << myDet->slsDetectorDefs::getDetectorSettings(val); FILE_LOG(logINFO) << "Setting Settings to " << slsDetectorDefs::getDetectorSettings(val);
try { try {
myDet->setSettings(val); det->setSettings(val);
} CATCH_HANDLE ("Could not set settings.", "qTabSettings::SetSettings", this, &qTabSettings::GetSettings) } CATCH_HANDLE ("Could not set settings.", "qTabSettings::SetSettings", this, &qTabSettings::GetSettings)
// threshold // threshold
if (spinThreshold->isEnabled()) { if (spinThreshold->isEnabled()) {
SetThresholdEnergy(spinThreshold->value()); SetThresholdEnergy(spinThreshold->value());
@ -150,15 +142,10 @@ void qTabSettings::SetSettings(int index) {
void qTabSettings::GetDynamicRange() { void qTabSettings::GetDynamicRange() {
FILE_LOG(logDEBUG) << "Getting dynamic range"; FILE_LOG(logDEBUG) << "Getting dynamic range";
disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
try {
try { auto retval = det->getDynamicRange().tsquash("Inconsistent dynamic range for all detectors.");
auto retval = myDet->setDynamicRange(-1);
// set the final value on gui // set the final value on gui
switch (retval) { switch (retval) {
case -1:
qDefs::Message(qDefs::WARNING, "Dynamic Range is inconsistent for all detectors.", "qTabSettings::GetDynamicRange");
break;
case 32: case 32:
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_32); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_32);
break; break;
@ -172,11 +159,9 @@ void qTabSettings::GetDynamicRange() {
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
break; break;
default: default:
qDefs::Message(qDefs::WARNING, std::string("Unknown dynamic range: ") + std::to_string(retval), "qTabSettings::GetDynamicRange"); throw sls::RuntimeError(std::string("Unknown dynamic range: ") + std::to_string(retval));
break;
} }
} CATCH_DISPLAY ("Could not get dynamic range.", "qTabSettings::GetDynamicRange") } CATCH_DISPLAY ("Could not get dynamic range.", "qTabSettings::GetDynamicRange")
connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int))); connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int)));
} }
@ -185,20 +170,19 @@ void qTabSettings::SetDynamicRange(int index) {
try { try {
switch (index) { switch (index) {
case DYNAMICRANGE_32: case DYNAMICRANGE_32:
myDet->setDynamicRange(32); det->setDynamicRange(32);
break; break;
case DYNAMICRANGE_16: case DYNAMICRANGE_16:
myDet->setDynamicRange(16); det->setDynamicRange(16);
break; break;
case DYNAMICRANGE_8: case DYNAMICRANGE_8:
myDet->setDynamicRange(8); det->setDynamicRange(8);
break; break;
case DYNAMICRANGE_4: case DYNAMICRANGE_4:
myDet->setDynamicRange(4); det->setDynamicRange(4);
break; break;
default: default:
qDefs::Message(qDefs::WARNING, std::string("Unknown dynamic range: ") + std::to_string(index), "qTabSettings::SetDynamicRange"); throw sls::RuntimeError(std::string("Unknown dynamic range: ") + std::to_string(index));
break;
} }
} CATCH_HANDLE ("Could not set dynamic range.", "qTabSettings::SetDynamicRange", this, &qTabSettings::GetDynamicRange) } CATCH_HANDLE ("Could not set dynamic range.", "qTabSettings::SetDynamicRange", this, &qTabSettings::GetDynamicRange)
} }
@ -206,27 +190,18 @@ void qTabSettings::SetDynamicRange(int index) {
void qTabSettings::GetThresholdEnergy() { void qTabSettings::GetThresholdEnergy() {
FILE_LOG(logDEBUG) << "Getting theshold energy"; FILE_LOG(logDEBUG) << "Getting theshold energy";
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int))); disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int)));
try { try {
auto retval = myDet->getThresholdEnergy(); auto retval = det->getThresholdEnergy().tsquash("Inconsistent threhsold energy for all detectors.");
/*if (retval == -1) { commenting out as default is -1, handle this when API changes
qDefs::Message(qDefs::WARNING, "Threshold Energy is inconsistent for all detectors.", "qTabDataOutput::GetThresholdEnergy");
spinThreshold->setValue(-1);
} else {
spinThreshold->setValue(retval);
}*/
spinThreshold->setValue(retval); spinThreshold->setValue(retval);
} CATCH_DISPLAY ("Could not get threshold energy.", "qTabDataOutput::GetThresholdEnergy") } CATCH_DISPLAY ("Could not get threshold energy.", "qTabDataOutput::GetThresholdEnergy")
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int))); connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int)));
} }
void qTabSettings::SetThresholdEnergy(int index) { void qTabSettings::SetThresholdEnergy(int index) {
FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV"; FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
try { try {
myDet->setThresholdEnergy(index); det->setThresholdEnergy(index);
} CATCH_DISPLAY ("Could not get threshold energy.", "qTabSettings::SetThresholdEnergy") } CATCH_DISPLAY ("Could not get threshold energy.", "qTabSettings::SetThresholdEnergy")
// set the right value anyway (due to tolerance) // set the right value anyway (due to tolerance)
GetThresholdEnergy(); GetThresholdEnergy();
} }

View File

@ -233,7 +233,7 @@ class Detector {
*/ */
void stopAcquisition(); void stopAcquisition();
/** /** TODO: initially was getting acq flag, if set, check if detctor idle, then set, else exception & abort
* Clears the acquiring flag. This has to be done manually * Clears the acquiring flag. This has to be done manually
* after an acquisition was aborted. * after an acquisition was aborted.
*/ */
@ -249,7 +249,7 @@ class Detector {
Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const; Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const;
/** [Eiger][Jungfrau] */ /** [Eiger][Jungfrau] */
void setStartingFrameNumber(uint64_t value, Positions pos); void setStartingFrameNumber(uint64_t value, Positions pos = {});
/** [Eiger] Sends an internal software trigger to the detector */ /** [Eiger] Sends an internal software trigger to the detector */
void sendSoftwareTrigger(Positions pos = {}); void sendSoftwareTrigger(Positions pos = {});
@ -655,10 +655,12 @@ class Detector {
/** [Eiger] deadtime in ns, 0 = disabled */ /** [Eiger] deadtime in ns, 0 = disabled */
Result<ns> getRateCorrection(Positions pos = {}) const; Result<ns> getRateCorrection(Positions pos = {}) const;
/** [Eiger] Sets default rate correction from trimbit file */
void setDefaultRateCorrection(Positions pos = {});
/** //TODO: default, get, set /** //TODO: default, get, set
* [Eiger] Set Rate correction * [Eiger] Set Rate correction
* 0 disable correction, < 0: default dead time from trimbit file, > 0 * 0 disable correction, > 0 custom deadtime, cannot be -1
* custom deadtime (advanced)
*/ */
void setRateCorrection(ns dead_time, Positions pos = {}); void setRateCorrection(ns dead_time, Positions pos = {});

View File

@ -1552,11 +1552,16 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/ */
int setAutoComparatorDisableMode(int ival = -1, int detPos = -1); // int setAutoComparatorDisableMode(int ival = -1, int detPos = -1); //
/**
* Set Default Rate correction from trimbit file ( Eiger)
* @param detPos -1 for all detectors in list or specific detector position
*/
void setDefaultRateCorrection(int detPos = -1); //
/** /**
* Set Rate correction ( Eiger) * Set Rate correction ( Eiger)
* @param t dead time in ns - if 0 disable correction, * @param t dead time in ns - if 0 disable correction,
* if >0 set dead time to t, if < 0 set deadtime to default dead time * if >0 set dead time to t, cannot be < 0
* for current settings
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
*/ */
void setRateCorrection(int64_t t = 0, int detPos = -1); // void setRateCorrection(int64_t t = 0, int detPos = -1); //

View File

@ -1280,10 +1280,15 @@ class slsDetector : public virtual slsDetectorDefs {
*/ */
sls_detector_module getModule(); sls_detector_module getModule();
/**
* Set Default Rate correction from trimbit file(Eiger)
*/
void setDefaultRateCorrection();
/** /**
* Set Rate correction (Eiger) * Set Rate correction (Eiger)
* @param t dead time in ns - if 0 disable correction, * @param t dead time in ns - if 0 disable correction,
* if >0 set dead time to t, if < 0 set deadtime to default dead time * if >0 set dead time to t, cannot be < 0
* for current settings * for current settings
*/ */
void setRateCorrection(int64_t t = 0); void setRateCorrection(int64_t t = 0);

View File

@ -250,14 +250,14 @@ void Detector::setTimingMode(defs::timingMode value, Positions pos) {
void Detector::acquire() { pimpl->acquire(); } void Detector::acquire() { pimpl->acquire(); }
void Detector::startAcquisition() { void Detector::startAcquisition() {
if (getUseReceiverFlag({}).squash()) if (getUseReceiverFlag().squash(true))
pimpl->Parallel(&slsDetector::startReceiver, {}); pimpl->Parallel(&slsDetector::startReceiver, {});
pimpl->Parallel(&slsDetector::startAcquisition, {}); pimpl->Parallel(&slsDetector::startAcquisition, {});
} }
void Detector::stopAcquisition() { void Detector::stopAcquisition() {
pimpl->Parallel(&slsDetector::stopAcquisition, {}); pimpl->Parallel(&slsDetector::stopAcquisition, {});
if (getUseReceiverFlag({}).squash()) // TODO: problem for acquire() if (getUseReceiverFlag().squash(true))
pimpl->Parallel(&slsDetector::stopReceiver, {}); pimpl->Parallel(&slsDetector::stopReceiver, {});
} }
@ -768,9 +768,9 @@ void Detector::setRxAddGapPixels(bool enable) {
Result<bool> Detector::getParallelMode(Positions pos) const { Result<bool> Detector::getParallelMode(Positions pos) const {
auto res = pimpl->Parallel(&slsDetector::setReadOutFlags, pos, auto res = pimpl->Parallel(&slsDetector::setReadOutFlags, pos,
defs::GET_READOUT_FLAGS); defs::GET_READOUT_FLAGS);
Result<bool> booleanRes; Result<bool> booleanRes(res.size());
for (unsigned int i = 0; i < res.size(); ++i) { for (size_t i = 0; i < res.size(); ++i) {
booleanRes[i] = (res[i] & defs::PARALLEL) ? true : false; booleanRes[i] = res[i] & defs::PARALLEL;
} }
return booleanRes; return booleanRes;
} }
@ -783,9 +783,9 @@ void Detector::setParallelMode(bool value, Positions pos) {
Result<bool> Detector::getOverFlowMode(Positions pos) const { Result<bool> Detector::getOverFlowMode(Positions pos) const {
auto res = pimpl->Parallel(&slsDetector::setReadOutFlags, pos, auto res = pimpl->Parallel(&slsDetector::setReadOutFlags, pos,
defs::GET_READOUT_FLAGS); defs::GET_READOUT_FLAGS);
Result<bool> booleanRes; Result<bool> booleanRes(res.size());
for (unsigned int i = 0; i < res.size(); ++i) { for (size_t i = 0; i < res.size(); ++i) {
booleanRes[i] = (res[i] & defs::SHOW_OVERFLOW) ? true : false; booleanRes[i] = res[i] & defs::SHOW_OVERFLOW;
} }
return booleanRes; return booleanRes;
} }
@ -824,6 +824,10 @@ Result<ns> Detector::getRateCorrection(Positions pos) const {
return pimpl->Parallel(&slsDetector::getRateCorrection, pos); return pimpl->Parallel(&slsDetector::getRateCorrection, pos);
} }
void Detector::setDefaultRateCorrection(Positions pos) {
pimpl->Parallel(&slsDetector::setDefaultRateCorrection, pos);
}
void Detector::setRateCorrection(ns dead_time, Positions pos) { void Detector::setRateCorrection(ns dead_time, Positions pos) {
pimpl->Parallel(&slsDetector::setRateCorrection, pos, dead_time.count()); pimpl->Parallel(&slsDetector::setRateCorrection, pos, dead_time.count());
} }

View File

@ -2358,7 +2358,20 @@ int multiSlsDetector::setAutoComparatorDisableMode(int ival, int detPos) {
return sls::minusOneIfDifferent(r); return sls::minusOneIfDifferent(r);
} }
void multiSlsDetector::setDefaultRateCorrection(int detPos) {
// single
if (detPos >= 0) {
detectors[detPos]->setDefaultRateCorrection();
}
// multi
parallelCall(&slsDetector::setDefaultRateCorrection);
}
void multiSlsDetector::setRateCorrection(int64_t t, int detPos) { void multiSlsDetector::setRateCorrection(int64_t t, int detPos) {
if (t < 0) {
throw sls::RuntimeError("Dead time has to be greater or equal to 0");
}
// single // single
if (detPos >= 0) { if (detPos >= 0) {
detectors[detPos]->setRateCorrection(t); detectors[detPos]->setRateCorrection(t);

View File

@ -2719,6 +2719,13 @@ sls_detector_module slsDetector::getModule() {
return myMod; return myMod;
} }
void slsDetector::setDefaultRateCorrection() {
FILE_LOG(logDEBUG1) << "Setting Default Rate Correction";
int64_t arg = -1;
sendToDetector(F_SET_RATE_CORRECT, arg, nullptr);
shm()->deadTime = -1;
}
void slsDetector::setRateCorrection(int64_t t) { void slsDetector::setRateCorrection(int64_t t) {
FILE_LOG(logDEBUG1) << "Setting Rate Correction to " << t; FILE_LOG(logDEBUG1) << "Setting Rate Correction to " << t;
sendToDetector(F_SET_RATE_CORRECT, t, nullptr); sendToDetector(F_SET_RATE_CORRECT, t, nullptr);

View File

@ -7,7 +7,6 @@
#define APICTB 0x190821 #define APICTB 0x190821
#define APIGOTTHARD 0x190821 #define APIGOTTHARD 0x190821
#define APIJUNGFRAU 0x190821 #define APIJUNGFRAU 0x190821
#define APIEIGER 0x190821
#define APIMYTHEN3 0x190822 #define APIMYTHEN3 0x190822
#define APIEIGER 0x190823
#define APIGOTTHARD2 0x190826 #define APIGOTTHARD2 0x190826