mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 07:47:12 +02:00
rxr sls namespace (#457)
* rxr src files and classes (detectordata, ZmqSocket) added to sls namespace * moving defines inside namespace * moving defines inside namespace, added helpdacs to namespace * added namespace to gui * gui also updated * removed unnecessary sls:: when already in sls namespace for slsDetectoSoftware, receverSoftware, slsDetectorGui and slsSupportlib
This commit is contained in:
@ -72,6 +72,7 @@ This document describes the differences between v7.0.0 and v6.x.x
|
|||||||
- m3 (settings dac check disabled temporarily?)
|
- m3 (settings dac check disabled temporarily?)
|
||||||
- m3 virtual server sends the right pacets now
|
- m3 virtual server sends the right pacets now
|
||||||
- gap pixels in gui enabled by default
|
- gap pixels in gui enabled by default
|
||||||
|
- rxr src files and classes (detectordata, ZmqSocket, helpDacs) added to sls namespace, and macros (namely from logger (logINFO etc)), slsDetectorGui
|
||||||
|
|
||||||
2. Resolved Issues
|
2. Resolved Issues
|
||||||
==================
|
==================
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class SlsQtH1D;
|
class SlsQtH1D;
|
||||||
class SlsQt1DPlot;
|
class SlsQt1DPlot;
|
||||||
class SlsQt2DPlot;
|
class SlsQt2DPlot;
|
||||||
@ -43,3 +45,5 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
|
|||||||
|
|
||||||
static int NumClones;
|
static int NumClones;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,11 +6,13 @@
|
|||||||
#include "ui_form_dac.h"
|
#include "ui_form_dac.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qDacWidget : public QWidget, private Ui::WidgetDacObject {
|
class qDacWidget : public QWidget, private Ui::WidgetDacObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n,
|
qDacWidget(QWidget *parent, Detector *detector, bool d, std::string n,
|
||||||
slsDetectorDefs::dacIndex i);
|
slsDetectorDefs::dacIndex i);
|
||||||
~qDacWidget();
|
~qDacWidget();
|
||||||
void SetDetectorIndex(int id);
|
void SetDetectorIndex(int id);
|
||||||
@ -25,8 +27,10 @@ class qDacWidget : public QWidget, private Ui::WidgetDacObject {
|
|||||||
void GetAdc();
|
void GetAdc();
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
bool isDac{true};
|
bool isDac{true};
|
||||||
slsDetectorDefs::dacIndex index;
|
slsDetectorDefs::dacIndex index;
|
||||||
int detectorIndex{-1};
|
int detectorIndex{-1};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
using std::chrono::duration;
|
using std::chrono::duration;
|
||||||
using std::chrono::duration_cast;
|
using std::chrono::duration_cast;
|
||||||
using std::chrono::hours;
|
using std::chrono::hours;
|
||||||
@ -47,9 +49,9 @@ class qDefs : public QWidget {
|
|||||||
static void DisplayExceptions(std::string emsg, std::string src) {
|
static void DisplayExceptions(std::string emsg, std::string src) {
|
||||||
try {
|
try {
|
||||||
throw;
|
throw;
|
||||||
} catch (const sls::SocketError &e) {
|
} catch (const SocketError &e) {
|
||||||
throw;
|
throw;
|
||||||
} catch (const sls::SharedMemoryError &e) {
|
} catch (const SharedMemoryError &e) {
|
||||||
throw;
|
throw;
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
ExceptionMessage(emsg, e.what(), src);
|
ExceptionMessage(emsg, e.what(), src);
|
||||||
@ -63,9 +65,9 @@ class qDefs : public QWidget {
|
|||||||
typename NonDeduced<CT>::type... Args) {
|
typename NonDeduced<CT>::type... Args) {
|
||||||
try {
|
try {
|
||||||
throw;
|
throw;
|
||||||
} catch (const sls::SocketError &e) {
|
} catch (const SocketError &e) {
|
||||||
throw;
|
throw;
|
||||||
} catch (const sls::SharedMemoryError &e) {
|
} catch (const SharedMemoryError &e) {
|
||||||
throw;
|
throw;
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
ExceptionMessage(emsg, e.what(), src);
|
ExceptionMessage(emsg, e.what(), src);
|
||||||
@ -329,3 +331,5 @@ class qDefs : public QWidget {
|
|||||||
source);
|
source);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
#include "ui_form_detectormain.h"
|
#include "ui_form_detectormain.h"
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
|
|
||||||
|
class QScrollArea;
|
||||||
|
class QResizeEvent;
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qDrawPlot;
|
class qDrawPlot;
|
||||||
class qTabMeasurement;
|
class qTabMeasurement;
|
||||||
class qTabDataOutput;
|
class qTabDataOutput;
|
||||||
@ -15,8 +20,6 @@ class qTabSettings;
|
|||||||
class qTabDebugging;
|
class qTabDebugging;
|
||||||
class qTabDeveloper;
|
class qTabDeveloper;
|
||||||
class qTabMessages;
|
class qTabMessages;
|
||||||
class QScrollArea;
|
|
||||||
class QResizeEvent;
|
|
||||||
|
|
||||||
/** To Over-ride the QTabWidget class to get the tabBar protected
|
/** To Over-ride the QTabWidget class to get the tabBar protected
|
||||||
* methodTabWidget */
|
* methodTabWidget */
|
||||||
@ -70,7 +73,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
|
|||||||
NumberOfTabs
|
NumberOfTabs
|
||||||
};
|
};
|
||||||
slsDetectorDefs::detectorType detType;
|
slsDetectorDefs::detectorType detType;
|
||||||
std::unique_ptr<sls::Detector> det;
|
std::unique_ptr<Detector> det;
|
||||||
qDrawPlot *plot;
|
qDrawPlot *plot;
|
||||||
MyTabWidget *tabs;
|
MyTabWidget *tabs;
|
||||||
QScrollArea *scroll[NumberOfTabs];
|
QScrollArea *scroll[NumberOfTabs];
|
||||||
@ -88,3 +91,5 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
|
|||||||
QString zoomToolTip;
|
QString zoomToolTip;
|
||||||
QColor defaultTabColor;
|
QColor defaultTabColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,18 +6,21 @@
|
|||||||
#include "ui_form_plot.h"
|
#include "ui_form_plot.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
class QResizeEvent;
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class SlsQt1DPlot;
|
class SlsQt1DPlot;
|
||||||
class SlsQtH1D;
|
class SlsQtH1D;
|
||||||
class SlsQt2DPlot;
|
class SlsQt2DPlot;
|
||||||
class qCloneWidget;
|
class qCloneWidget;
|
||||||
class detectorData;
|
class detectorData;
|
||||||
class QResizeEvent;
|
|
||||||
|
|
||||||
class qDrawPlot : public QWidget, private Ui::PlotObject {
|
class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qDrawPlot(QWidget *parent, sls::Detector *detector);
|
qDrawPlot(QWidget *parent, Detector *detector);
|
||||||
~qDrawPlot();
|
~qDrawPlot();
|
||||||
bool GetIsRunning();
|
bool GetIsRunning();
|
||||||
void SetRunning(bool enable);
|
void SetRunning(bool enable);
|
||||||
@ -96,7 +99,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
|||||||
|
|
||||||
static const int NUM_PEDESTAL_FRAMES = 20;
|
static const int NUM_PEDESTAL_FRAMES = 20;
|
||||||
static const int NUM_GOTTHARD25_CHANS = 1280;
|
static const int NUM_GOTTHARD25_CHANS = 1280;
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
slsDetectorDefs::detectorType detType;
|
slsDetectorDefs::detectorType detType;
|
||||||
|
|
||||||
SlsQt1DPlot *plot1d{nullptr};
|
SlsQt1DPlot *plot1d{nullptr};
|
||||||
@ -172,3 +175,5 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
|||||||
int gainOffset{0};
|
int gainOffset{0};
|
||||||
bool gotthard25;
|
bool gotthard25;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -4,13 +4,15 @@
|
|||||||
#include "sls/Detector.h"
|
#include "sls/Detector.h"
|
||||||
#include "ui_form_tab_advanced.h"
|
#include "ui_form_tab_advanced.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qDrawPlot;
|
class qDrawPlot;
|
||||||
|
|
||||||
class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
|
class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qTabAdvanced(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
|
qTabAdvanced(QWidget *parent, Detector *detector, qDrawPlot *p);
|
||||||
~qTabAdvanced();
|
~qTabAdvanced();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -74,6 +76,8 @@ class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
|
|||||||
void GetExposureTime();
|
void GetExposureTime();
|
||||||
void GetGateDelay();
|
void GetGateDelay();
|
||||||
|
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
qDrawPlot *plot;
|
qDrawPlot *plot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
#include "sls/Detector.h"
|
#include "sls/Detector.h"
|
||||||
#include "ui_form_tab_dataoutput.h"
|
#include "ui_form_tab_dataoutput.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
|
class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qTabDataOutput(QWidget *parent, sls::Detector *detector);
|
qTabDataOutput(QWidget *parent, Detector *detector);
|
||||||
~qTabDataOutput();
|
~qTabDataOutput();
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
|
||||||
@ -39,7 +41,9 @@ class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
|
|||||||
void GetSpeed();
|
void GetSpeed();
|
||||||
void GetParallel();
|
void GetParallel();
|
||||||
|
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
// Button group for radiobuttons for rate
|
// Button group for radiobuttons for rate
|
||||||
QButtonGroup *btnGroupRate;
|
QButtonGroup *btnGroupRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -7,11 +7,13 @@
|
|||||||
class QTreeWidget;
|
class QTreeWidget;
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qTabDebugging : public QWidget, private Ui::TabDebuggingObject {
|
class qTabDebugging : public QWidget, private Ui::TabDebuggingObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qTabDebugging(QWidget *parent, sls::Detector *detector);
|
qTabDebugging(QWidget *parent, Detector *detector);
|
||||||
~qTabDebugging();
|
~qTabDebugging();
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
|
||||||
@ -26,10 +28,12 @@ class qTabDebugging : public QWidget, private Ui::TabDebuggingObject {
|
|||||||
void Initialization();
|
void Initialization();
|
||||||
void PopulateDetectors();
|
void PopulateDetectors();
|
||||||
|
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
/** Tree Widget displaying the detectors, modules */
|
/** Tree Widget displaying the detectors, modules */
|
||||||
QTreeWidget *treeDet;
|
QTreeWidget *treeDet;
|
||||||
QLabel *lblDetectorHostname;
|
QLabel *lblDetectorHostname;
|
||||||
QLabel *lblDetectorFirmware;
|
QLabel *lblDetectorFirmware;
|
||||||
QLabel *lblDetectorSoftware;
|
QLabel *lblDetectorSoftware;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,13 +6,15 @@
|
|||||||
#include "ui_form_tab_developer.h"
|
#include "ui_form_tab_developer.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qDacWidget;
|
class qDacWidget;
|
||||||
|
|
||||||
class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
|
class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qTabDeveloper(QWidget *parent, sls::Detector *detector);
|
qTabDeveloper(QWidget *parent, Detector *detector);
|
||||||
~qTabDeveloper();
|
~qTabDeveloper();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -29,7 +31,7 @@ class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
|
|||||||
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType,
|
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType,
|
||||||
int index);
|
int index);
|
||||||
|
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
std::vector<qDacWidget *> dacWidgets;
|
std::vector<qDacWidget *> dacWidgets;
|
||||||
std::vector<qDacWidget *> adcWidgets;
|
std::vector<qDacWidget *> adcWidgets;
|
||||||
|
|
||||||
@ -38,3 +40,5 @@ class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
|
|||||||
static const int HV_MIN = 60;
|
static const int HV_MIN = 60;
|
||||||
static const int HV_MAX = 200;
|
static const int HV_MAX = 200;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -4,14 +4,17 @@
|
|||||||
#include "sls/Detector.h"
|
#include "sls/Detector.h"
|
||||||
#include "ui_form_tab_measurement.h"
|
#include "ui_form_tab_measurement.h"
|
||||||
|
|
||||||
class qDrawPlot;
|
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
class qDrawPlot;
|
||||||
|
|
||||||
class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
|
class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qTabMeasurement(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
|
qTabMeasurement(QWidget *parent, Detector *detector, qDrawPlot *p);
|
||||||
~qTabMeasurement();
|
~qTabMeasurement();
|
||||||
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
@ -81,7 +84,7 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
|
|||||||
void FileNameChangedSignal(QString);
|
void FileNameChangedSignal(QString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
qDrawPlot *plot;
|
qDrawPlot *plot;
|
||||||
// enum for the timing mode
|
// enum for the timing mode
|
||||||
enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, TRIGGER_GATED, NUMTIMINGMODES };
|
enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, TRIGGER_GATED, NUMTIMINGMODES };
|
||||||
@ -98,3 +101,5 @@ class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
|
|||||||
int numMeasurements{1};
|
int numMeasurements{1};
|
||||||
int currentMeasurement{0};
|
int currentMeasurement{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
class QProcess;
|
class QProcess;
|
||||||
class QKeyEvent;
|
class QKeyEvent;
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qTabMessages : public QWidget, private Ui::TabMessagesObject {
|
class qTabMessages : public QWidget, private Ui::TabMessagesObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -34,3 +36,5 @@ class qTabMessages : public QWidget, private Ui::TabMessagesObject {
|
|||||||
QProcess *process;
|
QProcess *process;
|
||||||
QStringList lastCommand;
|
QStringList lastCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -4,13 +4,15 @@
|
|||||||
#include "sls/Detector.h"
|
#include "sls/Detector.h"
|
||||||
#include "ui_form_tab_plot.h"
|
#include "ui_form_tab_plot.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qDrawPlot;
|
class qDrawPlot;
|
||||||
|
|
||||||
class qTabPlot : public QWidget, private Ui::TabPlotObject {
|
class qTabPlot : public QWidget, private Ui::TabPlotObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
|
qTabPlot(QWidget *parent, Detector *detector, qDrawPlot *p);
|
||||||
~qTabPlot();
|
~qTabPlot();
|
||||||
void SetScanArgument();
|
void SetScanArgument();
|
||||||
void Refresh();
|
void Refresh();
|
||||||
@ -53,7 +55,7 @@ class qTabPlot : public QWidget, private Ui::TabPlotObject {
|
|||||||
void SetXYRange();
|
void SetXYRange();
|
||||||
void MaintainAspectRatio(int dimension);
|
void MaintainAspectRatio(int dimension);
|
||||||
|
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
qDrawPlot *plot;
|
qDrawPlot *plot;
|
||||||
bool is1d;
|
bool is1d;
|
||||||
|
|
||||||
@ -65,3 +67,5 @@ class qTabPlot : public QWidget, private Ui::TabPlotObject {
|
|||||||
static QString defaultImageYAxisTitle;
|
static QString defaultImageYAxisTitle;
|
||||||
static QString defaultImageZAxisTitle;
|
static QString defaultImageZAxisTitle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
#include "ui_form_tab_settings.h"
|
#include "ui_form_tab_settings.h"
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qTabSettings(QWidget *parent, sls::Detector *detector);
|
qTabSettings(QWidget *parent, Detector *detector);
|
||||||
~qTabSettings();
|
~qTabSettings();
|
||||||
void Refresh();
|
void Refresh();
|
||||||
public slots:
|
public slots:
|
||||||
@ -37,7 +39,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
|||||||
void GetThresholdEnergies();
|
void GetThresholdEnergies();
|
||||||
void GetCounterMask();
|
void GetCounterMask();
|
||||||
|
|
||||||
sls::Detector *det;
|
Detector *det;
|
||||||
std::vector<QCheckBox *> counters;
|
std::vector<QCheckBox *> counters;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -77,3 +79,5 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
|||||||
DYNAMICRANGE_4
|
DYNAMICRANGE_4
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -12,9 +12,12 @@
|
|||||||
#include <qwt_plot_shapeitem.h>
|
#include <qwt_plot_shapeitem.h>
|
||||||
|
|
||||||
class QPen;
|
class QPen;
|
||||||
class SlsQt1DPlot;
|
|
||||||
class QwtSymbol;
|
class QwtSymbol;
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
class SlsQt1DPlot;
|
||||||
|
|
||||||
class SlsQtH1D : public QwtPlotCurve {
|
class SlsQtH1D : public QwtPlotCurve {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -170,4 +173,8 @@ class SlsQt1DPlot : public QwtPlot {
|
|||||||
void Update();
|
void Update();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <qwt_plot_panner.h>
|
#include <qwt_plot_panner.h>
|
||||||
#include <qwt_plot_zoomer.h>
|
#include <qwt_plot_zoomer.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class SlsQtH1D;
|
class SlsQtH1D;
|
||||||
|
|
||||||
class SlsQt1DZoomer : public QwtPlotZoomer {
|
class SlsQt1DZoomer : public QwtPlotZoomer {
|
||||||
@ -51,4 +53,6 @@ class SlsQt1DZoomer : public QwtPlotZoomer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <qwt_scale_draw.h>
|
#include <qwt_scale_draw.h>
|
||||||
#include <qwt_scale_widget.h>
|
#include <qwt_scale_widget.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class SlsQt2DHist : public QwtRasterData {
|
class SlsQt2DHist : public QwtRasterData {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -125,4 +127,6 @@ class SlsQt2DHist : public QwtRasterData {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,6 +12,8 @@ class QwtPlotPanner;
|
|||||||
class QwtScaleWidget;
|
class QwtScaleWidget;
|
||||||
class QwtLinearColorMap;
|
class QwtLinearColorMap;
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class SlsQt2DPlot : public QwtPlot {
|
class SlsQt2DPlot : public QwtPlot {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -91,3 +93,5 @@ class SlsQt2DPlot : public QwtPlot {
|
|||||||
int isLog;
|
int isLog;
|
||||||
QwtPlotShapeItem *roiBox{nullptr};
|
QwtPlotShapeItem *roiBox{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <qwt_plot_panner.h>
|
#include <qwt_plot_panner.h>
|
||||||
#include <qwt_plot_zoomer.h>
|
#include <qwt_plot_zoomer.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class SlsQt2DZoomer : public QwtPlotZoomer {
|
class SlsQt2DZoomer : public QwtPlotZoomer {
|
||||||
private:
|
private:
|
||||||
SlsQt2DHist *hist;
|
SlsQt2DHist *hist;
|
||||||
@ -40,4 +42,6 @@ class SlsQt2DZoomer : public QwtPlotZoomer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include <qwt_symbol.h>
|
#include <qwt_symbol.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm
|
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm
|
||||||
|
|
||||||
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data)
|
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data)
|
||||||
@ -602,3 +604,5 @@ void SlsQt1DPlot::DisableZoom(bool disable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <qwt_plot.h>
|
#include <qwt_plot.h>
|
||||||
#include <qwt_scale_div.h>
|
#include <qwt_scale_div.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
void SlsQt1DZoomer::ResetZoomBase() {
|
void SlsQt1DZoomer::ResetZoomBase() {
|
||||||
SetZoomBase(x0, y0, x1 - x0,
|
SetZoomBase(x0, y0, x1 - x0,
|
||||||
y1 - y0); // for going between log and nonlog plots
|
y1 - y0); // for going between log and nonlog plots
|
||||||
@ -93,3 +95,5 @@ void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D *h) {
|
|||||||
|
|
||||||
ResetZoomBase();
|
ResetZoomBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy,
|
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy,
|
||||||
double ymin, double ymax, double *d, double zmin,
|
double ymin, double ymax, double *d, double zmin,
|
||||||
double zmax)
|
double zmax)
|
||||||
@ -143,3 +145,5 @@ double SlsQt2DHist::SetMinimumToFirstGreaterThanZero() {
|
|||||||
|
|
||||||
return z_min;
|
return z_min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
|
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||||
isLog = 0;
|
isLog = 0;
|
||||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
|
||||||
@ -312,3 +314,4 @@ void SlsQt2DPlot::DisableRoiBox() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <qwt_text.h>
|
#include <qwt_text.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
int qCloneWidget::NumClones{0};
|
int qCloneWidget::NumClones{0};
|
||||||
|
|
||||||
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
|
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
|
||||||
@ -44,7 +46,7 @@ qCloneWidget::~qCloneWidget() {
|
|||||||
void qCloneWidget::SetupWidgetWindow(QString title) {
|
void qCloneWidget::SetupWidgetWindow(QString title) {
|
||||||
|
|
||||||
std::string winTitle = std::string("Snapshot:") + std::to_string(id) +
|
std::string winTitle = std::string("Snapshot:") + std::to_string(id) +
|
||||||
std::string(" - ") + sls::Logger::Timestamp();
|
std::string(" - ") + Logger::Timestamp();
|
||||||
setWindowTitle(QString(winTitle.c_str()));
|
setWindowTitle(QString(winTitle.c_str()));
|
||||||
|
|
||||||
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||||
@ -147,3 +149,5 @@ void qCloneWidget::resizeEvent(QResizeEvent *event) {
|
|||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
#include "qDacWidget.h"
|
#include "qDacWidget.h"
|
||||||
#include "qDefs.h"
|
#include "qDefs.h"
|
||||||
|
|
||||||
qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d,
|
namespace sls {
|
||||||
|
|
||||||
|
qDacWidget::qDacWidget(QWidget *parent, Detector *detector, bool d,
|
||||||
std::string n, slsDetectorDefs::dacIndex i)
|
std::string n, slsDetectorDefs::dacIndex i)
|
||||||
: QWidget(parent), det(detector), isDac(d), index(i) {
|
: QWidget(parent), det(detector), isDac(d), index(i) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -94,3 +96,5 @@ void qDacWidget::Refresh() {
|
|||||||
GetAdc();
|
GetAdc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -59,7 +59,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
fname = optarg;
|
fname = optarg;
|
||||||
LOG(logDEBUG) << long_options[option_index].name << " " << optarg;
|
LOG(sls::logDEBUG) << long_options[option_index].name << " " << optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
@ -72,7 +72,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
tempval = APIGUI;
|
tempval = APIGUI;
|
||||||
LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
|
LOG(sls::logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
|
||||||
<< std::hex << tempval << ")";
|
<< std::hex << tempval << ")";
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ int main(int argc, char **argv) {
|
|||||||
"i. Default: 0. Required \n" +
|
"i. Default: 0. Required \n" +
|
||||||
"\t only when more than one multi "
|
"\t only when more than one multi "
|
||||||
"detector object is needed.\n\n";
|
"detector object is needed.\n\n";
|
||||||
LOG(logERROR) << help_message;
|
LOG(sls::logERROR) << help_message;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,16 +96,18 @@ int main(int argc, char **argv) {
|
|||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
app.setStyle(new QPlastiqueStyle); // style is deleted by QApplication
|
app.setStyle(new QPlastiqueStyle); // style is deleted by QApplication
|
||||||
try {
|
try {
|
||||||
qDetectorMain det(multiId, fname, isDeveloper);
|
sls::qDetectorMain det(multiId, fname, isDeveloper);
|
||||||
det.show();
|
det.show();
|
||||||
app.exec();
|
app.exec();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
qDefs::Message(qDefs::CRITICAL,
|
sls::qDefs::Message(sls::qDefs::CRITICAL,
|
||||||
std::string(e.what()) + "\nExiting Gui :'( ", "main");
|
std::string(e.what()) + "\nExiting Gui :'( ", "main");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
qDetectorMain::qDetectorMain(int multiId, const std::string &fname,
|
qDetectorMain::qDetectorMain(int multiId, const std::string &fname,
|
||||||
bool isDevel)
|
bool isDevel)
|
||||||
: QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC),
|
: QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC),
|
||||||
@ -212,7 +214,7 @@ void qDetectorMain::SetUpWidgetWindow() {
|
|||||||
void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
|
void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
|
||||||
|
|
||||||
// instantiate detector and set window title
|
// instantiate detector and set window title
|
||||||
det = sls::make_unique<sls::Detector>(multiID);
|
det = make_unique<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 = new qTabMessages(this);
|
||||||
@ -238,15 +240,15 @@ void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
|
|||||||
default:
|
default:
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << det->getHostname() << " has "
|
os << det->getHostname() << " has "
|
||||||
<< sls::ToString(det->getDetectorType().squash())
|
<< ToString(det->getDetectorType().squash())
|
||||||
<< " detector type (" << std::to_string(detType)
|
<< " detector type (" << std::to_string(detType)
|
||||||
<< "). Exiting GUI.";
|
<< "). Exiting GUI.";
|
||||||
std::string errorMess = os.str();
|
std::string errorMess = os.str();
|
||||||
throw sls::RuntimeError(errorMess.c_str());
|
throw RuntimeError(errorMess.c_str());
|
||||||
}
|
}
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "SLS Detector GUI : "
|
os << "SLS Detector GUI : "
|
||||||
<< sls::ToString(det->getDetectorType().squash()) << " - "
|
<< ToString(det->getDetectorType().squash()) << " - "
|
||||||
<< det->getHostname();
|
<< det->getHostname();
|
||||||
std::string title = os.str();
|
std::string title = os.str();
|
||||||
LOG(logINFO) << title;
|
LOG(logINFO) << title;
|
||||||
@ -441,10 +443,10 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
|
|||||||
LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
|
LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
|
||||||
"Gotthard, Gotthard2 and Moench detectors";
|
"Gotthard, Gotthard2 and Moench detectors";
|
||||||
|
|
||||||
std::string guiVersion = sls::ToStringHex(APIGUI);
|
std::string guiVersion = ToStringHex(APIGUI);
|
||||||
std::string clientVersion = "unknown";
|
std::string clientVersion = "unknown";
|
||||||
try {
|
try {
|
||||||
clientVersion = sls::ToStringHex(det->getClientVersion());
|
clientVersion = ToStringHex(det->getClientVersion());
|
||||||
}
|
}
|
||||||
CATCH_DISPLAY("Could not get client version.",
|
CATCH_DISPLAY("Could not get client version.",
|
||||||
"qDetectorMain::ExecuteHelp")
|
"qDetectorMain::ExecuteHelp")
|
||||||
@ -609,3 +611,5 @@ void qDetectorMain::SetZoomToolTip(bool disable) {
|
|||||||
else
|
else
|
||||||
dockWidgetPlot->setToolTip(zoomToolTip);
|
dockWidgetPlot->setToolTip(zoomToolTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
|
|
||||||
qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector)
|
namespace sls {
|
||||||
|
|
||||||
|
qDrawPlot::qDrawPlot(QWidget *parent, Detector *detector)
|
||||||
: QWidget(parent), det(detector) {
|
: QWidget(parent), det(detector) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
SetupWidgetWindow();
|
SetupWidgetWindow();
|
||||||
@ -728,7 +730,7 @@ void qDrawPlot::AcquisitionFinished(double currentProgress,
|
|||||||
int detectorStatus) {
|
int detectorStatus) {
|
||||||
progress = currentProgress;
|
progress = currentProgress;
|
||||||
std::string status =
|
std::string status =
|
||||||
sls::ToString(static_cast<slsDetectorDefs::runStatus>(detectorStatus));
|
ToString(static_cast<slsDetectorDefs::runStatus>(detectorStatus));
|
||||||
|
|
||||||
if (detectorStatus == slsDetectorDefs::ERROR) {
|
if (detectorStatus == slsDetectorDefs::ERROR) {
|
||||||
qDefs::Message(qDefs::WARNING,
|
qDefs::Message(qDefs::WARNING,
|
||||||
@ -761,7 +763,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
|||||||
<< " \t dynamic range: " << data->dynamicRange << std::endl
|
<< " \t dynamic range: " << data->dynamicRange << std::endl
|
||||||
<< " \t file index: " << data->fileIndex << std::endl
|
<< " \t file index: " << data->fileIndex << std::endl
|
||||||
<< " \t complete image: " << data->completeImage << std::endl
|
<< " \t complete image: " << data->completeImage << std::endl
|
||||||
<< " \t rx Roi: " << sls::ToString(data->rxRoi) << std::endl
|
<< " \t rx Roi: " << ToString(data->rxRoi) << std::endl
|
||||||
<< " ]";
|
<< " ]";
|
||||||
|
|
||||||
progress = data->progressIndex;
|
progress = data->progressIndex;
|
||||||
@ -780,9 +782,9 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
|||||||
rxRoi.xmax += ((rxRoi.xmax/1024) * 6 + (rxRoi.xmax/256) * 2);
|
rxRoi.xmax += ((rxRoi.xmax/1024) * 6 + (rxRoi.xmax/256) * 2);
|
||||||
rxRoi.ymin += ((rxRoi.ymin/512) * 34 + (rxRoi.ymin/256) * 2);
|
rxRoi.ymin += ((rxRoi.ymin/512) * 34 + (rxRoi.ymin/256) * 2);
|
||||||
rxRoi.ymax += ((rxRoi.ymax/512) * 34 + (rxRoi.ymax/256) * 2);
|
rxRoi.ymax += ((rxRoi.ymax/512) * 34 + (rxRoi.ymax/256) * 2);
|
||||||
LOG(logINFO) << "Rx_roi recalculated with gap pixels: " << sls::ToString(rxRoi);
|
LOG(logINFO) << "Rx_roi recalculated with gap pixels: " << ToString(rxRoi);
|
||||||
}
|
}
|
||||||
LOG(logDEBUG) << "Rx_roi: " << sls::ToString(rxRoi);
|
LOG(logDEBUG) << "Rx_roi: " << ToString(rxRoi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1272,3 +1274,5 @@ void qDrawPlot::UpdatePlot() {
|
|||||||
|
|
||||||
LOG(logDEBUG) << "End of Update Plot";
|
LOG(logDEBUG) << "End of Update Plot";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
#include "qDrawPlot.h"
|
#include "qDrawPlot.h"
|
||||||
#include "sls/network_utils.h"
|
#include "sls/network_utils.h"
|
||||||
|
|
||||||
qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector,
|
namespace sls {
|
||||||
|
|
||||||
|
qTabAdvanced::qTabAdvanced(QWidget *parent, Detector *detector,
|
||||||
qDrawPlot *p)
|
qDrawPlot *p)
|
||||||
: QWidget(parent), det(detector), plot(p) {
|
: QWidget(parent), det(detector), plot(p) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -443,7 +445,7 @@ void qTabAdvanced::SetDetectorUDPIP(bool force) {
|
|||||||
std::string s = dispDetectorUDPIP->text().toAscii().constData();
|
std::string s = dispDetectorUDPIP->text().toAscii().constData();
|
||||||
LOG(logINFO) << "Setting Detector UDP IP:" << s;
|
LOG(logINFO) << "Setting Detector UDP IP:" << s;
|
||||||
try {
|
try {
|
||||||
det->setSourceUDPIP(sls::IpAddr{s},
|
det->setSourceUDPIP(IpAddr{s},
|
||||||
{comboDetector->currentIndex()});
|
{comboDetector->currentIndex()});
|
||||||
}
|
}
|
||||||
CATCH_HANDLE("Could not set Detector UDP IP.",
|
CATCH_HANDLE("Could not set Detector UDP IP.",
|
||||||
@ -461,7 +463,7 @@ void qTabAdvanced::SetDetectorUDPMAC(bool force) {
|
|||||||
std::string s = dispDetectorUDPMAC->text().toAscii().constData();
|
std::string s = dispDetectorUDPMAC->text().toAscii().constData();
|
||||||
LOG(logINFO) << "Setting Detector UDP MAC:" << s;
|
LOG(logINFO) << "Setting Detector UDP MAC:" << s;
|
||||||
try {
|
try {
|
||||||
det->setSourceUDPMAC(sls::MacAddr{s},
|
det->setSourceUDPMAC(MacAddr{s},
|
||||||
{comboDetector->currentIndex()});
|
{comboDetector->currentIndex()});
|
||||||
}
|
}
|
||||||
CATCH_HANDLE("Could not set Detector UDP MAC.",
|
CATCH_HANDLE("Could not set Detector UDP MAC.",
|
||||||
@ -489,7 +491,7 @@ void qTabAdvanced::SetCltZMQIP(bool force) {
|
|||||||
std::string s = dispZMQIP->text().toAscii().constData();
|
std::string s = dispZMQIP->text().toAscii().constData();
|
||||||
LOG(logINFO) << "Setting Client ZMQ IP:" << s;
|
LOG(logINFO) << "Setting Client ZMQ IP:" << s;
|
||||||
try {
|
try {
|
||||||
det->setClientZmqIp(sls::IpAddr{s},
|
det->setClientZmqIp(IpAddr{s},
|
||||||
{comboDetector->currentIndex()});
|
{comboDetector->currentIndex()});
|
||||||
}
|
}
|
||||||
CATCH_HANDLE("Could not set Client ZMQ IP.",
|
CATCH_HANDLE("Could not set Client ZMQ IP.",
|
||||||
@ -547,7 +549,7 @@ void qTabAdvanced::SetRxrUDPIP(bool force) {
|
|||||||
std::string s = dispRxrUDPIP->text().toAscii().constData();
|
std::string s = dispRxrUDPIP->text().toAscii().constData();
|
||||||
LOG(logINFO) << "Setting Receiver UDP IP:" << s;
|
LOG(logINFO) << "Setting Receiver UDP IP:" << s;
|
||||||
try {
|
try {
|
||||||
det->setDestinationUDPIP(sls::IpAddr{s},
|
det->setDestinationUDPIP(IpAddr{s},
|
||||||
{comboDetector->currentIndex()});
|
{comboDetector->currentIndex()});
|
||||||
}
|
}
|
||||||
CATCH_HANDLE("Could not set Receiver UDP IP.",
|
CATCH_HANDLE("Could not set Receiver UDP IP.",
|
||||||
@ -565,7 +567,7 @@ void qTabAdvanced::SetRxrUDPMAC(bool force) {
|
|||||||
std::string s = dispRxrUDPMAC->text().toAscii().constData();
|
std::string s = dispRxrUDPMAC->text().toAscii().constData();
|
||||||
LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
|
LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
|
||||||
try {
|
try {
|
||||||
det->setDestinationUDPMAC(sls::MacAddr{s},
|
det->setDestinationUDPMAC(MacAddr{s},
|
||||||
{comboDetector->currentIndex()});
|
{comboDetector->currentIndex()});
|
||||||
}
|
}
|
||||||
CATCH_HANDLE("Could not set Receiver UDP MAC.",
|
CATCH_HANDLE("Could not set Receiver UDP MAC.",
|
||||||
@ -593,7 +595,7 @@ void qTabAdvanced::SetRxrZMQIP(bool force) {
|
|||||||
std::string s = dispRxrZMQIP->text().toAscii().constData();
|
std::string s = dispRxrZMQIP->text().toAscii().constData();
|
||||||
LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
|
LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
|
||||||
try {
|
try {
|
||||||
det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
|
det->setRxZmqIP(IpAddr{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,
|
||||||
@ -891,3 +893,5 @@ void qTabAdvanced::Refresh() {
|
|||||||
}
|
}
|
||||||
LOG(logDEBUG) << "**Updated Advanced Tab";
|
LOG(logDEBUG) << "**Updated Advanced Tab";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector)
|
namespace sls {
|
||||||
|
|
||||||
|
qTabDataOutput::qTabDataOutput(QWidget *parent, Detector *detector)
|
||||||
: QWidget(parent), det(detector), btnGroupRate(nullptr) {
|
: QWidget(parent), det(detector), btnGroupRate(nullptr) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
SetupWidgetWindow();
|
SetupWidgetWindow();
|
||||||
@ -232,7 +234,7 @@ void qTabDataOutput::GetFileFormat() {
|
|||||||
comboFileFormat->setCurrentIndex(static_cast<int>(retval));
|
comboFileFormat->setCurrentIndex(static_cast<int>(retval));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown file format: ") +
|
throw RuntimeError(std::string("Unknown file format: ") +
|
||||||
std::to_string(static_cast<int>(retval)));
|
std::to_string(static_cast<int>(retval)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,7 +341,7 @@ void qTabDataOutput::EnableRateCorrection() {
|
|||||||
LOG(logINFO) << "Disabling Rate correction";
|
LOG(logINFO) << "Disabling Rate correction";
|
||||||
// disable
|
// disable
|
||||||
try {
|
try {
|
||||||
det->setRateCorrection(sls::ns(0));
|
det->setRateCorrection(ns(0));
|
||||||
}
|
}
|
||||||
CATCH_HANDLE("Could not switch off rate correction.",
|
CATCH_HANDLE("Could not switch off rate correction.",
|
||||||
"qTabDataOutput::EnableRateCorrection", this,
|
"qTabDataOutput::EnableRateCorrection", this,
|
||||||
@ -357,7 +359,7 @@ void qTabDataOutput::SetRateCorrection() {
|
|||||||
int64_t deadtime = spinCustomDeadTime->value();
|
int64_t deadtime = spinCustomDeadTime->value();
|
||||||
LOG(logINFO) << "Setting Rate Correction with custom dead time: "
|
LOG(logINFO) << "Setting Rate Correction with custom dead time: "
|
||||||
<< deadtime;
|
<< deadtime;
|
||||||
det->setRateCorrection(sls::ns(deadtime));
|
det->setRateCorrection(ns(deadtime));
|
||||||
}
|
}
|
||||||
// default dead time
|
// default dead time
|
||||||
else {
|
else {
|
||||||
@ -442,3 +444,5 @@ void qTabDataOutput::Refresh() {
|
|||||||
|
|
||||||
LOG(logDEBUG) << "**Updated DataOutput Tab";
|
LOG(logDEBUG) << "**Updated DataOutput Tab";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector)
|
namespace sls {
|
||||||
|
|
||||||
|
qTabDebugging::qTabDebugging(QWidget *parent, Detector *detector)
|
||||||
: QWidget(parent), det(detector), treeDet(nullptr),
|
: QWidget(parent), det(detector), treeDet(nullptr),
|
||||||
lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr),
|
lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr),
|
||||||
lblDetectorSoftware(nullptr) {
|
lblDetectorSoftware(nullptr) {
|
||||||
@ -62,7 +64,7 @@ void qTabDebugging::GetDetectorStatus() {
|
|||||||
LOG(logDEBUG) << "Getting Status";
|
LOG(logDEBUG) << "Getting Status";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::string status = sls::ToString(
|
std::string status = ToString(
|
||||||
det->getDetectorStatus({comboDetector->currentIndex()})[0]);
|
det->getDetectorStatus({comboDetector->currentIndex()})[0]);
|
||||||
lblStatus->setText(QString(status.c_str()).toUpper());
|
lblStatus->setText(QString(status.c_str()).toUpper());
|
||||||
}
|
}
|
||||||
@ -88,7 +90,7 @@ void qTabDebugging::GetInfo() {
|
|||||||
lblDetectorFirmware->setFixedWidth(100);
|
lblDetectorFirmware->setFixedWidth(100);
|
||||||
layout->addWidget(dispFrame, 0, 1);
|
layout->addWidget(dispFrame, 0, 1);
|
||||||
QString detName =
|
QString detName =
|
||||||
QString(sls::ToString(det->getDetectorType().squash()).c_str());
|
QString(ToString(det->getDetectorType().squash()).c_str());
|
||||||
|
|
||||||
switch (det->getDetectorType().squash()) {
|
switch (det->getDetectorType().squash()) {
|
||||||
|
|
||||||
@ -241,3 +243,5 @@ void qTabDebugging::Refresh() {
|
|||||||
GetDetectorStatus();
|
GetDetectorStatus();
|
||||||
LOG(logDEBUG) << "**Updated Debugging Tab";
|
LOG(logDEBUG) << "**Updated Debugging Tab";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
#include "qDacWidget.h"
|
#include "qDacWidget.h"
|
||||||
#include "qDefs.h"
|
#include "qDefs.h"
|
||||||
|
|
||||||
qTabDeveloper::qTabDeveloper(QWidget *parent, sls::Detector *detector)
|
namespace sls {
|
||||||
|
|
||||||
|
qTabDeveloper::qTabDeveloper(QWidget *parent, Detector *detector)
|
||||||
: QWidget(parent), det(detector) {
|
: QWidget(parent), det(detector) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
SetupWidgetWindow();
|
SetupWidgetWindow();
|
||||||
@ -324,7 +326,7 @@ void qTabDeveloper::GetHighVoltage() {
|
|||||||
// spinHV
|
// spinHV
|
||||||
if (spinHV->isVisible()) {
|
if (spinHV->isVisible()) {
|
||||||
if (retval != 0 && retval < hvmin && retval > HV_MAX) {
|
if (retval != 0 && retval < hvmin && retval > HV_MAX) {
|
||||||
throw sls::RuntimeError(std::string("Unknown High Voltage: ") +
|
throw RuntimeError(std::string("Unknown High Voltage: ") +
|
||||||
std::to_string(retval));
|
std::to_string(retval));
|
||||||
}
|
}
|
||||||
spinHV->setValue(retval);
|
spinHV->setValue(retval);
|
||||||
@ -354,7 +356,7 @@ void qTabDeveloper::GetHighVoltage() {
|
|||||||
comboHV->setCurrentIndex(HV_200);
|
comboHV->setCurrentIndex(HV_200);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown High Voltage: ") +
|
throw RuntimeError(std::string("Unknown High Voltage: ") +
|
||||||
std::to_string(retval));
|
std::to_string(retval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,7 +433,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
|||||||
case 22:
|
case 22:
|
||||||
return slsDetectorDefs::TEMPERATURE_FPGA;
|
return slsDetectorDefs::TEMPERATURE_FPGA;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
|
throw RuntimeError(std::string("Unknown dac/adc index") +
|
||||||
std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -458,7 +460,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
|||||||
case 9:
|
case 9:
|
||||||
return slsDetectorDefs::TEMPERATURE_FPGA;
|
return slsDetectorDefs::TEMPERATURE_FPGA;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
|
throw RuntimeError(std::string("Unknown dac/adc index") +
|
||||||
std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -484,7 +486,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
|||||||
case 8:
|
case 8:
|
||||||
return slsDetectorDefs::TEMPERATURE_ADC;
|
return slsDetectorDefs::TEMPERATURE_ADC;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
|
throw RuntimeError(std::string("Unknown dac/adc index") +
|
||||||
std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -508,7 +510,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
|||||||
case 7:
|
case 7:
|
||||||
return slsDetectorDefs::IBIAS_SFP;
|
return slsDetectorDefs::IBIAS_SFP;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
|
throw RuntimeError(std::string("Unknown dac/adc index") +
|
||||||
std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -550,7 +552,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
|||||||
case 16:
|
case 16:
|
||||||
return slsDetectorDefs::VTHRESHOLD;
|
return slsDetectorDefs::VTHRESHOLD;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
|
throw RuntimeError(std::string("Unknown dac/adc index") +
|
||||||
std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -586,13 +588,13 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
|||||||
case 13:
|
case 13:
|
||||||
return slsDetectorDefs::VCOM_ADC2;
|
return slsDetectorDefs::VCOM_ADC2;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") +
|
throw RuntimeError(std::string("Unknown dac/adc index") +
|
||||||
std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown detector type"));
|
throw RuntimeError(std::string("Unknown detector type"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,3 +609,5 @@ void qTabDeveloper::Refresh() {
|
|||||||
GetHighVoltage();
|
GetHighVoltage();
|
||||||
LOG(logDEBUG) << "**Updated Developer Tab";
|
LOG(logDEBUG) << "**Updated Developer Tab";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector,
|
namespace sls {
|
||||||
|
|
||||||
|
qTabMeasurement::qTabMeasurement(QWidget *parent, Detector *detector,
|
||||||
qDrawPlot *p)
|
qDrawPlot *p)
|
||||||
: QWidget(parent), det(detector), plot(p), progressTimer(nullptr) {
|
: QWidget(parent), det(detector), plot(p), progressTimer(nullptr) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -343,7 +345,7 @@ void qTabMeasurement::GetTimingMode() {
|
|||||||
if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
|
if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
|
||||||
auto retvals = det->getTimingMode();
|
auto retvals = det->getTimingMode();
|
||||||
auto is_master = det->getMaster();
|
auto is_master = det->getMaster();
|
||||||
sls::Result<slsDetectorDefs::timingMode> masterRetvals;
|
Result<slsDetectorDefs::timingMode> masterRetvals;
|
||||||
for (size_t i = 0; i != is_master.size(); ++i) {
|
for (size_t i = 0; i != is_master.size(); ++i) {
|
||||||
if (is_master[i]) {
|
if (is_master[i]) {
|
||||||
masterRetvals.push_back(retvals[i]);
|
masterRetvals.push_back(retvals[i]);
|
||||||
@ -370,7 +372,7 @@ void qTabMeasurement::GetTimingMode() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown timing mode: ") +
|
throw RuntimeError(std::string("Unknown timing mode: ") +
|
||||||
std::to_string(retval));
|
std::to_string(retval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,7 +409,7 @@ void qTabMeasurement::GetBurstMode() {
|
|||||||
ShowTriggerDelay();
|
ShowTriggerDelay();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown burst mode: ") +
|
throw RuntimeError(std::string("Unknown burst mode: ") +
|
||||||
std::to_string(retval));
|
std::to_string(retval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1017,3 +1019,5 @@ void qTabMeasurement::Refresh() {
|
|||||||
|
|
||||||
LOG(logDEBUG) << "**Updated Measurement Tab";
|
LOG(logDEBUG) << "**Updated Measurement Tab";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
|
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
SetupWidgetWindow();
|
SetupWidgetWindow();
|
||||||
@ -142,3 +144,5 @@ void qTabMessages::Refresh() {
|
|||||||
dispCommand->clear();
|
dispCommand->clear();
|
||||||
dispCommand->setFocus();
|
dispCommand->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
QString qTabPlot::defaultPlotTitle("");
|
QString qTabPlot::defaultPlotTitle("");
|
||||||
QString qTabPlot::defaultHistXAxisTitle("Channel Number");
|
QString qTabPlot::defaultHistXAxisTitle("Channel Number");
|
||||||
QString qTabPlot::defaultHistYAxisTitle("Counts");
|
QString qTabPlot::defaultHistYAxisTitle("Counts");
|
||||||
@ -13,7 +15,7 @@ QString qTabPlot::defaultImageXAxisTitle("Pixel");
|
|||||||
QString qTabPlot::defaultImageYAxisTitle("Pixel");
|
QString qTabPlot::defaultImageYAxisTitle("Pixel");
|
||||||
QString qTabPlot::defaultImageZAxisTitle("Intensity");
|
QString qTabPlot::defaultImageZAxisTitle("Intensity");
|
||||||
|
|
||||||
qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p)
|
qTabPlot::qTabPlot(QWidget *parent, Detector *detector, qDrawPlot *p)
|
||||||
: QWidget(parent), det(detector), plot(p), is1d(false) {
|
: QWidget(parent), det(detector), plot(p), is1d(false) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
SetupWidgetWindow();
|
SetupWidgetWindow();
|
||||||
@ -797,3 +799,5 @@ void qTabPlot::Refresh() {
|
|||||||
|
|
||||||
LOG(logDEBUG) << "**Updated Plot Tab";
|
LOG(logDEBUG) << "**Updated Plot Tab";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
#include "sls/bit_utils.h"
|
#include "sls/bit_utils.h"
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector)
|
namespace sls {
|
||||||
|
|
||||||
|
qTabSettings::qTabSettings(QWidget *parent, Detector *detector)
|
||||||
: QWidget(parent), det(detector) {
|
: QWidget(parent), det(detector) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
SetupWidgetWindow();
|
SetupWidgetWindow();
|
||||||
@ -215,7 +217,7 @@ void qTabSettings::GetSettings() {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ((int)retval < -1 || (int)retval >= comboSettings->count()) {
|
if ((int)retval < -1 || (int)retval >= comboSettings->count()) {
|
||||||
throw sls::RuntimeError(std::string("Unknown settings: ") +
|
throw RuntimeError(std::string("Unknown settings: ") +
|
||||||
std::to_string(retval));
|
std::to_string(retval));
|
||||||
}
|
}
|
||||||
comboSettings->setCurrentIndex(retval);
|
comboSettings->setCurrentIndex(retval);
|
||||||
@ -231,7 +233,7 @@ void qTabSettings::SetSettings(int index) {
|
|||||||
// settings
|
// settings
|
||||||
auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
|
auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
|
||||||
try {
|
try {
|
||||||
LOG(logINFO) << "Setting Settings to " << sls::ToString(val);
|
LOG(logINFO) << "Setting Settings to " << ToString(val);
|
||||||
det->setSettings(val);
|
det->setSettings(val);
|
||||||
}
|
}
|
||||||
CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this,
|
CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this,
|
||||||
@ -250,7 +252,7 @@ void qTabSettings::GetGainMode() {
|
|||||||
auto retval = det->getGainMode().tsquash(
|
auto retval = det->getGainMode().tsquash(
|
||||||
"Inconsistent gain mode for all detectors.");
|
"Inconsistent gain mode for all detectors.");
|
||||||
if ((int)retval < 0 || (int)retval >= comboGainMode->count()) {
|
if ((int)retval < 0 || (int)retval >= comboGainMode->count()) {
|
||||||
throw sls::RuntimeError(std::string("Unknown gain mode: ") +
|
throw RuntimeError(std::string("Unknown gain mode: ") +
|
||||||
std::to_string(retval));
|
std::to_string(retval));
|
||||||
}
|
}
|
||||||
// warning when using fix_g0 and not in export mode
|
// warning when using fix_g0 and not in export mode
|
||||||
@ -321,7 +323,7 @@ void qTabSettings::GetDynamicRange() {
|
|||||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
|
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
|
throw RuntimeError(std::string("Unknown dynamic range: ") +
|
||||||
std::to_string(retval));
|
std::to_string(retval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +354,7 @@ void qTabSettings::SetDynamicRange(int index) {
|
|||||||
det->setDynamicRange(4);
|
det->setDynamicRange(4);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
|
throw RuntimeError(std::string("Unknown dynamic range: ") +
|
||||||
std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,7 +401,7 @@ void qTabSettings::SetThresholdEnergies() {
|
|||||||
slsDetectorDefs::detectorSettings sett =
|
slsDetectorDefs::detectorSettings sett =
|
||||||
static_cast<slsDetectorDefs::detectorSettings>(
|
static_cast<slsDetectorDefs::detectorSettings>(
|
||||||
comboSettings->currentIndex());
|
comboSettings->currentIndex());
|
||||||
LOG(logINFO) << "Setting Threshold Energies to " << sls::ToString(eV)
|
LOG(logINFO) << "Setting Threshold Energies to " << ToString(eV)
|
||||||
<< " (eV)";
|
<< " (eV)";
|
||||||
try {
|
try {
|
||||||
det->setThresholdEnergy(eV, sett);
|
det->setThresholdEnergy(eV, sett);
|
||||||
@ -430,7 +432,7 @@ void qTabSettings::GetCounterMask() {
|
|||||||
disconnect(chkCounter3, SIGNAL(toggled(bool)), this,
|
disconnect(chkCounter3, SIGNAL(toggled(bool)), this,
|
||||||
SLOT(SetCounterMask()));
|
SLOT(SetCounterMask()));
|
||||||
try {
|
try {
|
||||||
auto retval = sls::getSetBits(det->getCounterMask().tsquash(
|
auto retval = getSetBits(det->getCounterMask().tsquash(
|
||||||
"Counter mask is inconsistent for all detectors."));
|
"Counter mask is inconsistent for all detectors."));
|
||||||
// default to unchecked
|
// default to unchecked
|
||||||
for (auto p : counters) {
|
for (auto p : counters) {
|
||||||
@ -439,7 +441,7 @@ void qTabSettings::GetCounterMask() {
|
|||||||
// if retval[i] = 2, chkCounter2 is checked
|
// if retval[i] = 2, chkCounter2 is checked
|
||||||
for (auto i : retval) {
|
for (auto i : retval) {
|
||||||
if (i > 3) {
|
if (i > 3) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
std::string("Unknown counter index : ") +
|
std::string("Unknown counter index : ") +
|
||||||
std::to_string(static_cast<int>(i)));
|
std::to_string(static_cast<int>(i)));
|
||||||
}
|
}
|
||||||
@ -496,3 +498,5 @@ void qTabSettings::Refresh() {
|
|||||||
|
|
||||||
LOG(logDEBUG) << "**Updated Settings Tab";
|
LOG(logDEBUG) << "**Updated Settings Tab";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class detectorData;
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
using ns = std::chrono::nanoseconds;
|
using ns = std::chrono::nanoseconds;
|
||||||
|
class detectorData;
|
||||||
class DetectorImpl;
|
class DetectorImpl;
|
||||||
class MacAddr;
|
class MacAddr;
|
||||||
class IpAddr;
|
class IpAddr;
|
||||||
@ -884,7 +884,7 @@ class Detector {
|
|||||||
void setRxLock(bool value, Positions pos = {});
|
void setRxLock(bool value, Positions pos = {});
|
||||||
|
|
||||||
/** Client IP Address that last communicated with the receiver */
|
/** Client IP Address that last communicated with the receiver */
|
||||||
Result<sls::IpAddr> getRxLastClientIP(Positions pos = {}) const;
|
Result<IpAddr> getRxLastClientIP(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Get thread ids from the receiver in order of [parent, tcp, listener 0,
|
/** Get thread ids from the receiver in order of [parent, tcp, listener 0,
|
||||||
* processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. If
|
* processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. If
|
||||||
@ -1919,7 +1919,7 @@ class Detector {
|
|||||||
void setDetectorLock(bool lock, Positions pos = {});
|
void setDetectorLock(bool lock, Positions pos = {});
|
||||||
|
|
||||||
/** Client IP Address that last communicated with the detector */
|
/** Client IP Address that last communicated with the detector */
|
||||||
Result<sls::IpAddr> getLastClientIP(Positions pos = {}) const;
|
Result<IpAddr> getLastClientIP(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Execute a command on the detector server console */
|
/** Execute a command on the detector server console */
|
||||||
Result<std::string> executeCommand(const std::string &value,
|
Result<std::string> executeCommand(const std::string &value,
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@short data structure to hold the detector data after postprocessing
|
@short data structure to hold the detector data after postprocessing
|
||||||
*/
|
*/
|
||||||
@ -51,3 +53,5 @@ class detectorData {
|
|||||||
bool completeImage;
|
bool completeImage;
|
||||||
std::array<int,4> rxRoi{{-1, -1, -1, -1}};
|
std::array<int,4> rxRoi{{-1, -1, -1, -1}};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
/** Macro to make an integer command.
|
/** Macro to make an integer command.
|
||||||
* CMDNAME name of the function that does the command
|
* CMDNAME name of the function that does the command
|
||||||
* GETFCN Detector function to get
|
* GETFCN Detector function to get
|
||||||
@ -53,7 +55,7 @@
|
|||||||
os << args[0] << '\n'; \
|
os << args[0] << '\n'; \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -75,9 +77,9 @@
|
|||||||
WrongNumberOfParameters(1); \
|
WrongNumberOfParameters(1); \
|
||||||
} \
|
} \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
throw sls::RuntimeError("cannot put"); \
|
throw RuntimeError("cannot put"); \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -102,7 +104,7 @@
|
|||||||
det->SETFCN(args[0], std::vector<int>{det_id}); \
|
det->SETFCN(args[0], std::vector<int>{det_id}); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -128,7 +130,7 @@
|
|||||||
det->SETFCN(val, std::vector<int>{det_id}); \
|
det->SETFCN(val, std::vector<int>{det_id}); \
|
||||||
os << ToStringHex(val, 16) << '\n'; \
|
os << ToStringHex(val, 16) << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -154,7 +156,7 @@
|
|||||||
det->SETFCN(val, std::vector<int>{det_id}); \
|
det->SETFCN(val, std::vector<int>{det_id}); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -180,7 +182,7 @@
|
|||||||
det->SETFCN(val, std::vector<int>{det_id}); \
|
det->SETFCN(val, std::vector<int>{det_id}); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -206,7 +208,7 @@
|
|||||||
det->SETFCN(val, det_id); \
|
det->SETFCN(val, det_id); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -232,7 +234,7 @@
|
|||||||
det->SETFCN(val, det_id); \
|
det->SETFCN(val, det_id); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -252,7 +254,7 @@
|
|||||||
os << OutString(t) << '\n'; \
|
os << OutString(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (det_id != -1) { \
|
if (det_id != -1) { \
|
||||||
throw sls::RuntimeError( \
|
throw RuntimeError( \
|
||||||
"Cannot execute this at module level"); \
|
"Cannot execute this at module level"); \
|
||||||
} \
|
} \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
@ -262,7 +264,7 @@
|
|||||||
det->SETFCN(val); \
|
det->SETFCN(val); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -273,7 +275,7 @@
|
|||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
os << cmd << ' '; \
|
os << cmd << ' '; \
|
||||||
if (det_id != -1) { \
|
if (det_id != -1) { \
|
||||||
throw sls::RuntimeError("Cannot execute this at module level"); \
|
throw RuntimeError("Cannot execute this at module level"); \
|
||||||
} \
|
} \
|
||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
@ -291,7 +293,7 @@
|
|||||||
det->SETFCN(val); \
|
det->SETFCN(val); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -317,7 +319,7 @@
|
|||||||
det->SETFCN(INDEX, val, std::vector<int>{det_id}); \
|
det->SETFCN(INDEX, val, std::vector<int>{det_id}); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -345,7 +347,7 @@
|
|||||||
std::vector<int>{det_id}); \
|
std::vector<int>{det_id}); \
|
||||||
os << args[0] << ' ' << args[1] << '\n'; \
|
os << args[0] << ' ' << args[1] << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -356,12 +358,12 @@
|
|||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
os << cmd << ' '; \
|
os << cmd << ' '; \
|
||||||
if (det_id != -1) { \
|
if (det_id != -1) { \
|
||||||
throw sls::RuntimeError("Cannot execute this at module level"); \
|
throw RuntimeError("Cannot execute this at module level"); \
|
||||||
} \
|
} \
|
||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot get"); \
|
throw RuntimeError("Cannot get"); \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (!args.empty()) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
@ -369,7 +371,7 @@
|
|||||||
det->SETFCN(); \
|
det->SETFCN(); \
|
||||||
os << "successful\n"; \
|
os << "successful\n"; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -382,7 +384,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot get"); \
|
throw RuntimeError("Cannot get"); \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (!args.empty()) { \
|
if (!args.empty()) { \
|
||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
@ -390,7 +392,7 @@
|
|||||||
det->SETFCN(std::vector<int>{det_id}); \
|
det->SETFCN(std::vector<int>{det_id}); \
|
||||||
os << "successful\n"; \
|
os << "successful\n"; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -401,12 +403,12 @@
|
|||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
os << cmd << ' '; \
|
os << cmd << ' '; \
|
||||||
if (det_id != -1) { \
|
if (det_id != -1) { \
|
||||||
throw sls::RuntimeError("Cannot execute this at module level"); \
|
throw RuntimeError("Cannot execute this at module level"); \
|
||||||
} \
|
} \
|
||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot get"); \
|
throw RuntimeError("Cannot get"); \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
WrongNumberOfParameters(1); \
|
WrongNumberOfParameters(1); \
|
||||||
@ -414,7 +416,7 @@
|
|||||||
det->SETFCN(args[0]); \
|
det->SETFCN(args[0]); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -427,7 +429,7 @@
|
|||||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||||
os << HLPSTR << '\n'; \
|
os << HLPSTR << '\n'; \
|
||||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot get"); \
|
throw RuntimeError("Cannot get"); \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
WrongNumberOfParameters(1); \
|
WrongNumberOfParameters(1); \
|
||||||
@ -435,7 +437,7 @@
|
|||||||
det->SETFCN(args[0], std::vector<int>{det_id}); \
|
det->SETFCN(args[0], std::vector<int>{det_id}); \
|
||||||
os << args.front() << '\n'; \
|
os << args.front() << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -454,9 +456,9 @@
|
|||||||
auto t = det->GETFCN(std::vector<int>{det_id}); \
|
auto t = det->GETFCN(std::vector<int>{det_id}); \
|
||||||
os << OutString(t) << '\n'; \
|
os << OutString(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot put"); \
|
throw RuntimeError("Cannot put"); \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -473,11 +475,11 @@
|
|||||||
WrongNumberOfParameters(0); \
|
WrongNumberOfParameters(0); \
|
||||||
} \
|
} \
|
||||||
auto t = det->GETFCN(); \
|
auto t = det->GETFCN(); \
|
||||||
os << sls::ToString(t) << '\n'; \
|
os << ToString(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot put"); \
|
throw RuntimeError("Cannot put"); \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -496,9 +498,9 @@
|
|||||||
auto t = det->GETFCN(std::vector<int>{det_id}); \
|
auto t = det->GETFCN(std::vector<int>{det_id}); \
|
||||||
os << OutStringHex(t) << '\n'; \
|
os << OutStringHex(t) << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot put"); \
|
throw RuntimeError("Cannot put"); \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
@ -516,15 +518,13 @@
|
|||||||
auto t = det->GETFCN(VAL, std::vector<int>{det_id}); \
|
auto t = det->GETFCN(VAL, std::vector<int>{det_id}); \
|
||||||
os << OutString(t) << APPEND << '\n'; \
|
os << OutString(t) << APPEND << '\n'; \
|
||||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||||
throw sls::RuntimeError("Cannot put"); \
|
throw RuntimeError("Cannot put"); \
|
||||||
} else { \
|
} else { \
|
||||||
throw sls::RuntimeError("Unknown action"); \
|
throw RuntimeError("Unknown action"); \
|
||||||
} \
|
} \
|
||||||
return os.str(); \
|
return os.str(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace sls {
|
|
||||||
|
|
||||||
class CmdProxy {
|
class CmdProxy {
|
||||||
public:
|
public:
|
||||||
explicit CmdProxy(Detector *ptr) : det(ptr) {}
|
explicit CmdProxy(Detector *ptr) : det(ptr) {}
|
||||||
@ -558,7 +558,7 @@ class CmdProxy {
|
|||||||
return ToStringHex(value, width);
|
return ToStringHex(value, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename V> std::string OutString(const sls::Result<V> &value) {
|
template <typename V> std::string OutString(const Result<V> &value) {
|
||||||
if (value.equal())
|
if (value.equal())
|
||||||
return ToString(value.front());
|
return ToString(value.front());
|
||||||
return ToString(value);
|
return ToString(value);
|
||||||
@ -1251,7 +1251,7 @@ class CmdProxy {
|
|||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
settings, getSettings, setSettings,
|
settings, getSettings, setSettings,
|
||||||
sls::StringTo<slsDetectorDefs::detectorSettings>,
|
StringTo<slsDetectorDefs::detectorSettings>,
|
||||||
"[standard, fast, highgain, dynamicgain, lowgain, "
|
"[standard, fast, highgain, dynamicgain, lowgain, "
|
||||||
"mediumgain, veryhighgain, highgain0, "
|
"mediumgain, veryhighgain, highgain0, "
|
||||||
"fixgain1, fixgain2, forceswitchg1, forceswitchg2, "
|
"fixgain1, fixgain2, forceswitchg1, forceswitchg2, "
|
||||||
@ -1354,7 +1354,7 @@ class CmdProxy {
|
|||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
timing, getTimingMode, setTimingMode,
|
timing, getTimingMode, setTimingMode,
|
||||||
sls::StringTo<slsDetectorDefs::timingMode>,
|
StringTo<slsDetectorDefs::timingMode>,
|
||||||
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of "
|
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of "
|
||||||
"detector.\n\t[Jungfrau][Gotthard][Ctb][Moench][Gotthard2] "
|
"detector.\n\t[Jungfrau][Gotthard][Ctb][Moench][Gotthard2] "
|
||||||
"[auto|trigger]\n\t[Mythen3] "
|
"[auto|trigger]\n\t[Mythen3] "
|
||||||
@ -1726,7 +1726,7 @@ class CmdProxy {
|
|||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
rx_discardpolicy, getRxFrameDiscardPolicy, setRxFrameDiscardPolicy,
|
rx_discardpolicy, getRxFrameDiscardPolicy, setRxFrameDiscardPolicy,
|
||||||
sls::StringTo<slsDetectorDefs::frameDiscardPolicy>,
|
StringTo<slsDetectorDefs::frameDiscardPolicy>,
|
||||||
"[nodiscard (default)|discardempty|discardpartial(fastest)]\n\tFrame "
|
"[nodiscard (default)|discardempty|discardpartial(fastest)]\n\tFrame "
|
||||||
"discard policy of receiver. nodiscard does not discard frames, "
|
"discard policy of receiver. nodiscard does not discard frames, "
|
||||||
"discardempty discards empty frames, discardpartial discards partial "
|
"discardempty discards empty frames, discardpartial discards partial "
|
||||||
@ -1776,7 +1776,7 @@ class CmdProxy {
|
|||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
fformat, getFileFormat, setFileFormat,
|
fformat, getFileFormat, setFileFormat,
|
||||||
sls::StringTo<slsDetectorDefs::fileFormat>,
|
StringTo<slsDetectorDefs::fileFormat>,
|
||||||
"[binary|hdf5]\n\tFile format of data file. For HDF5, package must be "
|
"[binary|hdf5]\n\tFile format of data file. For HDF5, package must be "
|
||||||
"compiled with HDF5 flags. Default is binary.");
|
"compiled with HDF5 flags. Default is binary.");
|
||||||
|
|
||||||
@ -1992,13 +1992,13 @@ class CmdProxy {
|
|||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
gainmode, getGainMode, setGainMode,
|
gainmode, getGainMode, setGainMode,
|
||||||
sls::StringTo<slsDetectorDefs::gainMode>,
|
StringTo<slsDetectorDefs::gainMode>,
|
||||||
"[dynamicgain|forceswitchg1|forceswitchg2|fixg1|fixg2|fixg0]\n\t["
|
"[dynamicgain|forceswitchg1|forceswitchg2|fixg1|fixg2|fixg0]\n\t["
|
||||||
"Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 without caution, "
|
"Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 without caution, "
|
||||||
"you can damage the detector!!!");
|
"you can damage the detector!!!");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(filtercells, getNumberOfFilterCells,
|
INTEGER_COMMAND_VEC_ID(filtercells, getNumberOfFilterCells,
|
||||||
setNumberOfFilterCells, sls::StringTo<int>,
|
setNumberOfFilterCells, StringTo<int>,
|
||||||
"[0-12]\n\t[Jungfrau] Set Filter Cell. Only for "
|
"[0-12]\n\t[Jungfrau] Set Filter Cell. Only for "
|
||||||
"chipv1.1. Advanced user Command");
|
"chipv1.1. Advanced user Command");
|
||||||
|
|
||||||
@ -2034,7 +2034,7 @@ class CmdProxy {
|
|||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
timingsource, getTimingSource, setTimingSource,
|
timingsource, getTimingSource, setTimingSource,
|
||||||
sls::StringTo<slsDetectorDefs::timingSourceType>,
|
StringTo<slsDetectorDefs::timingSourceType>,
|
||||||
"[internal|external]\n\t[Gotthard2] Timing source. Internal is crystal "
|
"[internal|external]\n\t[Gotthard2] Timing source. Internal is crystal "
|
||||||
"and external is system timing. Default is internal.");
|
"and external is system timing. Default is internal.");
|
||||||
|
|
||||||
@ -2121,7 +2121,7 @@ class CmdProxy {
|
|||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
romode, getReadoutMode, setReadoutMode,
|
romode, getReadoutMode, setReadoutMode,
|
||||||
sls::StringTo<slsDetectorDefs::readoutMode>,
|
StringTo<slsDetectorDefs::readoutMode>,
|
||||||
"[analog|digital|analog_digital]\n\t[CTB] Readout mode. "
|
"[analog|digital|analog_digital]\n\t[CTB] Readout mode. "
|
||||||
"Default is analog.");
|
"Default is analog.");
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
|
|||||||
using defs = slsDetectorDefs;
|
using defs = slsDetectorDefs;
|
||||||
|
|
||||||
Detector::Detector(int shm_id)
|
Detector::Detector(int shm_id)
|
||||||
: pimpl(sls::make_unique<DetectorImpl>(shm_id)) {}
|
: pimpl(make_unique<DetectorImpl>(shm_id)) {}
|
||||||
|
|
||||||
Detector::~Detector() = default;
|
Detector::~Detector() = default;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ void Detector::freeSharedMemory() { pimpl->freeSharedMemory(); }
|
|||||||
void Detector::loadConfig(const std::string &fname) {
|
void Detector::loadConfig(const std::string &fname) {
|
||||||
int shm_id = getShmId();
|
int shm_id = getShmId();
|
||||||
freeSharedMemory();
|
freeSharedMemory();
|
||||||
pimpl = sls::make_unique<DetectorImpl>(shm_id);
|
pimpl = make_unique<DetectorImpl>(shm_id);
|
||||||
LOG(logINFO) << "Loading configuration file: " << fname;
|
LOG(logINFO) << "Loading configuration file: " << fname;
|
||||||
loadParameters(fname);
|
loadParameters(fname);
|
||||||
}
|
}
|
||||||
@ -871,7 +871,7 @@ Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
|
|||||||
|
|
||||||
void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
|
void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
|
||||||
if (getDetectorType().squash() != defs::JUNGFRAU) {
|
if (getDetectorType().squash() != defs::JUNGFRAU) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Cannot set number of udp interfaces for this detector.");
|
"Cannot set number of udp interfaces for this detector.");
|
||||||
}
|
}
|
||||||
// also called by vetostream (for gotthard2)
|
// also called by vetostream (for gotthard2)
|
||||||
@ -951,7 +951,7 @@ Result<UdpDestination> Detector::getDestinationUDPList(const uint32_t entry,
|
|||||||
void Detector::setDestinationUDPList(const UdpDestination dest,
|
void Detector::setDestinationUDPList(const UdpDestination dest,
|
||||||
const int module_id) {
|
const int module_id) {
|
||||||
if (module_id == -1 && size() > 1) {
|
if (module_id == -1 && size() > 1) {
|
||||||
throw sls::RuntimeError("Cannot set this parameter at detector level.");
|
throw RuntimeError("Cannot set this parameter at detector level.");
|
||||||
}
|
}
|
||||||
pimpl->Parallel(&Module::setDestinationUDPList, {module_id}, dest);
|
pimpl->Parallel(&Module::setDestinationUDPList, {module_id}, dest);
|
||||||
}
|
}
|
||||||
@ -1194,7 +1194,7 @@ void Detector::setRxLock(bool value, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setReceiverLock, pos, value);
|
pimpl->Parallel(&Module::setReceiverLock, pos, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<sls::IpAddr> Detector::getRxLastClientIP(Positions pos) const {
|
Result<IpAddr> Detector::getRxLastClientIP(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getReceiverLastClientIP, pos);
|
return pimpl->Parallel(&Module::getReceiverLastClientIP, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2278,7 +2278,7 @@ void Detector::resetFPGA(Positions pos) {
|
|||||||
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
||||||
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
||||||
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
|
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
|
||||||
std::string filename = sls::getFileNameFromFilePath(fname);
|
std::string filename = getFileNameFromFilePath(fname);
|
||||||
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
||||||
if (getDetectorType().squash() != defs::EIGER) {
|
if (getDetectorType().squash() != defs::EIGER) {
|
||||||
rebootController(pos);
|
rebootController(pos);
|
||||||
@ -2287,7 +2287,7 @@ void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
|
|||||||
|
|
||||||
void Detector::updateKernel(const std::string &fname, Positions pos) {
|
void Detector::updateKernel(const std::string &fname, Positions pos) {
|
||||||
LOG(logINFO) << "Updating Kernel...";
|
LOG(logINFO) << "Updating Kernel...";
|
||||||
std::vector<char> buffer = sls::readBinaryFile(fname, "Update Kernel");
|
std::vector<char> buffer = readBinaryFile(fname, "Update Kernel");
|
||||||
pimpl->Parallel(&Module::updateKernel, pos, buffer);
|
pimpl->Parallel(&Module::updateKernel, pos, buffer);
|
||||||
rebootController(pos);
|
rebootController(pos);
|
||||||
}
|
}
|
||||||
@ -2302,7 +2302,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
|
|||||||
LOG(logINFO) << "Updating Firmware and Detector Server (no tftp)...";
|
LOG(logINFO) << "Updating Firmware and Detector Server (no tftp)...";
|
||||||
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
LOG(logINFO) << "Updating Detector Server (no tftp)...";
|
||||||
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
|
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
|
||||||
std::string filename = sls::getFileNameFromFilePath(sname);
|
std::string filename = getFileNameFromFilePath(sname);
|
||||||
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
||||||
programFPGA(fname, false, pos);
|
programFPGA(fname, false, pos);
|
||||||
}
|
}
|
||||||
@ -2390,7 +2390,7 @@ void Detector::setDetectorLock(bool lock, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setLockDetector, pos, lock);
|
pimpl->Parallel(&Module::setLockDetector, pos, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<sls::IpAddr> Detector::getLastClientIP(Positions pos) const {
|
Result<IpAddr> Detector::getLastClientIP(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getLastClientIP, pos);
|
return pimpl->Parallel(&Module::getLastClientIP, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ void DetectorImpl::initializeMembers(bool verify) {
|
|||||||
for (int i = 0; i < shm()->totalNumberOfModules; i++) {
|
for (int i = 0; i < shm()->totalNumberOfModules; i++) {
|
||||||
try {
|
try {
|
||||||
modules.push_back(
|
modules.push_back(
|
||||||
sls::make_unique<Module>(detectorIndex, i, verify));
|
make_unique<Module>(detectorIndex, i, verify));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
modules.clear();
|
modules.clear();
|
||||||
throw;
|
throw;
|
||||||
@ -199,11 +199,11 @@ void DetectorImpl::updateUserdetails() {
|
|||||||
memset(shm()->lastUser, 0, sizeof(shm()->lastUser));
|
memset(shm()->lastUser, 0, sizeof(shm()->lastUser));
|
||||||
memset(shm()->lastDate, 0, sizeof(shm()->lastDate));
|
memset(shm()->lastDate, 0, sizeof(shm()->lastDate));
|
||||||
try {
|
try {
|
||||||
sls::strcpy_safe(shm()->lastUser, exec("whoami").c_str());
|
strcpy_safe(shm()->lastUser, exec("whoami").c_str());
|
||||||
sls::strcpy_safe(shm()->lastDate, exec("date").c_str());
|
strcpy_safe(shm()->lastDate, exec("date").c_str());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
sls::strcpy_safe(shm()->lastUser, "errorreading");
|
strcpy_safe(shm()->lastUser, "errorreading");
|
||||||
sls::strcpy_safe(shm()->lastDate, "errorreading");
|
strcpy_safe(shm()->lastDate, "errorreading");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ void DetectorImpl::addModule(const std::string &hostname) {
|
|||||||
|
|
||||||
int port = DEFAULT_PORTNO;
|
int port = DEFAULT_PORTNO;
|
||||||
std::string host = hostname;
|
std::string host = hostname;
|
||||||
auto res = sls::split(hostname, ':');
|
auto res = split(hostname, ':');
|
||||||
if (res.size() > 1) {
|
if (res.size() > 1) {
|
||||||
host = res[0];
|
host = res[0];
|
||||||
port = StringTo<int>(res[1]);
|
port = StringTo<int>(res[1]);
|
||||||
@ -303,12 +303,12 @@ void DetectorImpl::addModule(const std::string &hostname) {
|
|||||||
// gotthard cannot have more than 2 modules (50um=1, 25um=2
|
// gotthard cannot have more than 2 modules (50um=1, 25um=2
|
||||||
if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) {
|
if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) {
|
||||||
freeSharedMemory();
|
freeSharedMemory();
|
||||||
throw sls::RuntimeError("Gotthard cannot have more than 2 modules");
|
throw RuntimeError("Gotthard cannot have more than 2 modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pos = modules.size();
|
auto pos = modules.size();
|
||||||
modules.emplace_back(
|
modules.emplace_back(
|
||||||
sls::make_unique<Module>(type, detectorIndex, pos, false));
|
make_unique<Module>(type, detectorIndex, pos, false));
|
||||||
shm()->totalNumberOfModules = modules.size();
|
shm()->totalNumberOfModules = modules.size();
|
||||||
modules[pos]->setControlPort(port);
|
modules[pos]->setControlPort(port);
|
||||||
modules[pos]->setStopPort(port + 1);
|
modules[pos]->setStopPort(port + 1);
|
||||||
@ -334,7 +334,7 @@ void DetectorImpl::updateDetectorSize() {
|
|||||||
|
|
||||||
const slsDetectorDefs::xy modSize = modules[0]->getNumberOfChannels();
|
const slsDetectorDefs::xy modSize = modules[0]->getNumberOfChannels();
|
||||||
if (modSize.x == 0 || modSize.y == 0) {
|
if (modSize.x == 0 || modSize.y == 0) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Module size for x or y dimensions is 0. Unable to proceed in "
|
"Module size for x or y dimensions is 0. Unable to proceed in "
|
||||||
"updating detector size. ");
|
"updating detector size. ");
|
||||||
}
|
}
|
||||||
@ -458,7 +458,7 @@ int DetectorImpl::createReceivingDataSockets() {
|
|||||||
portnum += (iSocket % numUDPInterfaces);
|
portnum += (iSocket % numUDPInterfaces);
|
||||||
try {
|
try {
|
||||||
zmqSocket.push_back(
|
zmqSocket.push_back(
|
||||||
sls::make_unique<ZmqSocket>(modules[iSocket / numUDPInterfaces]
|
make_unique<ZmqSocket>(modules[iSocket / numUDPInterfaces]
|
||||||
->getClientStreamingIP()
|
->getClientStreamingIP()
|
||||||
.str()
|
.str()
|
||||||
.c_str(),
|
.c_str(),
|
||||||
@ -468,7 +468,7 @@ int DetectorImpl::createReceivingDataSockets() {
|
|||||||
if (hwm >= 0) {
|
if (hwm >= 0) {
|
||||||
zmqSocket[iSocket]->SetReceiveHighWaterMark(hwm);
|
zmqSocket[iSocket]->SetReceiveHighWaterMark(hwm);
|
||||||
if (zmqSocket[iSocket]->GetReceiveHighWaterMark() != hwm) {
|
if (zmqSocket[iSocket]->GetReceiveHighWaterMark() != hwm) {
|
||||||
throw sls::ZmqSocketError("Could not set zmq rcv hwm to " +
|
throw ZmqSocketError("Could not set zmq rcv hwm to " +
|
||||||
std::to_string(hwm));
|
std::to_string(hwm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -566,8 +566,8 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
// allocate
|
// allocate
|
||||||
size = zHeader.imageSize;
|
size = zHeader.imageSize;
|
||||||
multisize = size * zmqSocket.size();
|
multisize = size * zmqSocket.size();
|
||||||
image = sls::make_unique<char[]>(size);
|
image = make_unique<char[]>(size);
|
||||||
multiframe = sls::make_unique<char[]>(multisize);
|
multiframe = make_unique<char[]>(multisize);
|
||||||
memset(multiframe.get(), 0xFF, multisize);
|
memset(multiframe.get(), 0xFF, multisize);
|
||||||
// dynamic range
|
// dynamic range
|
||||||
dynamicRange = zHeader.dynamicRange;
|
dynamicRange = zHeader.dynamicRange;
|
||||||
@ -1037,7 +1037,7 @@ int DetectorImpl::getClientStreamingHwm() const {
|
|||||||
return shm()->zmqHwm;
|
return shm()->zmqHwm;
|
||||||
}
|
}
|
||||||
// enabled
|
// enabled
|
||||||
sls::Result<int> result;
|
Result<int> result;
|
||||||
result.reserve(zmqSocket.size());
|
result.reserve(zmqSocket.size());
|
||||||
for (auto &it : zmqSocket) {
|
for (auto &it : zmqSocket) {
|
||||||
result.push_back(it->GetReceiveHighWaterMark());
|
result.push_back(it->GetReceiveHighWaterMark());
|
||||||
@ -1048,7 +1048,7 @@ int DetectorImpl::getClientStreamingHwm() const {
|
|||||||
|
|
||||||
void DetectorImpl::setClientStreamingHwm(const int limit) {
|
void DetectorImpl::setClientStreamingHwm(const int limit) {
|
||||||
if (limit < -1) {
|
if (limit < -1) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Cannot set hwm to less than -1 (-1 is lib default).");
|
"Cannot set hwm to less than -1 (-1 is lib default).");
|
||||||
}
|
}
|
||||||
// update shm
|
// update shm
|
||||||
@ -1062,7 +1062,7 @@ void DetectorImpl::setClientStreamingHwm(const int limit) {
|
|||||||
it->SetReceiveHighWaterMark(limit);
|
it->SetReceiveHighWaterMark(limit);
|
||||||
if (it->GetReceiveHighWaterMark() != limit) {
|
if (it->GetReceiveHighWaterMark() != limit) {
|
||||||
shm()->zmqHwm = -1;
|
shm()->zmqHwm = -1;
|
||||||
throw sls::ZmqSocketError("Could not set zmq rcv hwm to " +
|
throw ZmqSocketError("Could not set zmq rcv hwm to " +
|
||||||
std::to_string(limit));
|
std::to_string(limit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1336,7 +1336,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get srcSize to print progress
|
// get srcSize to print progress
|
||||||
ssize_t srcSize = sls::getFileSize(src, "Program FPGA");
|
ssize_t srcSize = getFileSize(src, "Program FPGA");
|
||||||
|
|
||||||
// create temp destination file
|
// create temp destination file
|
||||||
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
|
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
|
||||||
@ -1417,7 +1417,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index,
|
Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index,
|
||||||
defs::detectorSettings sett,
|
defs::detectorSettings sett,
|
||||||
Positions pos) {
|
Positions pos) {
|
||||||
return Parallel(&Module::getDefaultDac, pos, index, sett);
|
return Parallel(&Module::getDefaultDac, pos, index, sett);
|
||||||
|
@ -6,10 +6,7 @@
|
|||||||
#include "sls/Result.h"
|
#include "sls/Result.h"
|
||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
#include "CtbConfig.h"
|
#include "CtbConfig.h"
|
||||||
class ZmqSocket;
|
|
||||||
class detectorData;
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -17,18 +14,19 @@ class detectorData;
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define DETECTOR_SHMAPIVERSION 0x190809
|
|
||||||
#define DETECTOR_SHMVERSION 0x220505
|
|
||||||
#define SHORT_STRING_LENGTH 50
|
|
||||||
|
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
class ZmqSocket;
|
||||||
|
class detectorData;
|
||||||
class Module;
|
class Module;
|
||||||
|
|
||||||
|
#define DETECTOR_SHMAPIVERSION 0x190809
|
||||||
|
#define DETECTOR_SHMVERSION 0x220505
|
||||||
|
#define SHORT_STRING_LENGTH 50
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short structure allocated in shared memory to store detector settings
|
* @short structure allocated in shared memory to store detector settings
|
||||||
* for IPC and cache
|
* for IPC and cache
|
||||||
@ -88,12 +86,12 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
|
|
||||||
template <class CT> struct NonDeduced { using type = CT; };
|
template <class CT> struct NonDeduced { using type = CT; };
|
||||||
template <typename RT, typename... CT>
|
template <typename RT, typename... CT>
|
||||||
sls::Result<RT> Parallel(RT (sls::Module::*somefunc)(CT...),
|
Result<RT> Parallel(RT (Module::*somefunc)(CT...),
|
||||||
std::vector<int> positions,
|
std::vector<int> positions,
|
||||||
typename NonDeduced<CT>::type... Args) {
|
typename NonDeduced<CT>::type... Args) {
|
||||||
|
|
||||||
if (modules.empty())
|
if (modules.empty())
|
||||||
throw sls::RuntimeError("No modules added");
|
throw RuntimeError("No modules added");
|
||||||
if (positions.empty() ||
|
if (positions.empty() ||
|
||||||
(positions.size() == 1 && positions[0] == -1)) {
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
positions.resize(modules.size());
|
positions.resize(modules.size());
|
||||||
@ -103,11 +101,11 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
futures.reserve(positions.size());
|
futures.reserve(positions.size());
|
||||||
for (size_t i : positions) {
|
for (size_t i : positions) {
|
||||||
if (i >= modules.size())
|
if (i >= modules.size())
|
||||||
throw sls::RuntimeError("Module out of range");
|
throw RuntimeError("Module out of range");
|
||||||
futures.push_back(std::async(std::launch::async, somefunc,
|
futures.push_back(std::async(std::launch::async, somefunc,
|
||||||
modules[i].get(), Args...));
|
modules[i].get(), Args...));
|
||||||
}
|
}
|
||||||
sls::Result<RT> result;
|
Result<RT> result;
|
||||||
result.reserve(positions.size());
|
result.reserve(positions.size());
|
||||||
for (auto &i : futures) {
|
for (auto &i : futures) {
|
||||||
result.push_back(i.get());
|
result.push_back(i.get());
|
||||||
@ -116,12 +114,12 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename RT, typename... CT>
|
template <typename RT, typename... CT>
|
||||||
sls::Result<RT> Parallel(RT (sls::Module::*somefunc)(CT...) const,
|
Result<RT> Parallel(RT (Module::*somefunc)(CT...) const,
|
||||||
std::vector<int> positions,
|
std::vector<int> positions,
|
||||||
typename NonDeduced<CT>::type... Args) const {
|
typename NonDeduced<CT>::type... Args) const {
|
||||||
|
|
||||||
if (modules.empty())
|
if (modules.empty())
|
||||||
throw sls::RuntimeError("No modules added");
|
throw RuntimeError("No modules added");
|
||||||
if (positions.empty() ||
|
if (positions.empty() ||
|
||||||
(positions.size() == 1 && positions[0] == -1)) {
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
positions.resize(modules.size());
|
positions.resize(modules.size());
|
||||||
@ -131,11 +129,11 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
futures.reserve(positions.size());
|
futures.reserve(positions.size());
|
||||||
for (size_t i : positions) {
|
for (size_t i : positions) {
|
||||||
if (i >= modules.size())
|
if (i >= modules.size())
|
||||||
throw sls::RuntimeError("Module out of range");
|
throw RuntimeError("Module out of range");
|
||||||
futures.push_back(std::async(std::launch::async, somefunc,
|
futures.push_back(std::async(std::launch::async, somefunc,
|
||||||
modules[i].get(), Args...));
|
modules[i].get(), Args...));
|
||||||
}
|
}
|
||||||
sls::Result<RT> result;
|
Result<RT> result;
|
||||||
result.reserve(positions.size());
|
result.reserve(positions.size());
|
||||||
for (auto &i : futures) {
|
for (auto &i : futures) {
|
||||||
result.push_back(i.get());
|
result.push_back(i.get());
|
||||||
@ -144,12 +142,12 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename... CT>
|
template <typename... CT>
|
||||||
void Parallel(void (sls::Module::*somefunc)(CT...),
|
void Parallel(void (Module::*somefunc)(CT...),
|
||||||
std::vector<int> positions,
|
std::vector<int> positions,
|
||||||
typename NonDeduced<CT>::type... Args) {
|
typename NonDeduced<CT>::type... Args) {
|
||||||
|
|
||||||
if (modules.empty())
|
if (modules.empty())
|
||||||
throw sls::RuntimeError("No modules added");
|
throw RuntimeError("No modules added");
|
||||||
if (positions.empty() ||
|
if (positions.empty() ||
|
||||||
(positions.size() == 1 && positions[0] == -1)) {
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
positions.resize(modules.size());
|
positions.resize(modules.size());
|
||||||
@ -159,7 +157,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
futures.reserve(positions.size());
|
futures.reserve(positions.size());
|
||||||
for (size_t i : positions) {
|
for (size_t i : positions) {
|
||||||
if (i >= modules.size())
|
if (i >= modules.size())
|
||||||
throw sls::RuntimeError("Module out of range");
|
throw RuntimeError("Module out of range");
|
||||||
futures.push_back(std::async(std::launch::async, somefunc,
|
futures.push_back(std::async(std::launch::async, somefunc,
|
||||||
modules[i].get(), Args...));
|
modules[i].get(), Args...));
|
||||||
}
|
}
|
||||||
@ -169,12 +167,12 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename... CT>
|
template <typename... CT>
|
||||||
void Parallel(void (sls::Module::*somefunc)(CT...) const,
|
void Parallel(void (Module::*somefunc)(CT...) const,
|
||||||
std::vector<int> positions,
|
std::vector<int> positions,
|
||||||
typename NonDeduced<CT>::type... Args) const {
|
typename NonDeduced<CT>::type... Args) const {
|
||||||
|
|
||||||
if (modules.empty())
|
if (modules.empty())
|
||||||
throw sls::RuntimeError("No modules added");
|
throw RuntimeError("No modules added");
|
||||||
if (positions.empty() ||
|
if (positions.empty() ||
|
||||||
(positions.size() == 1 && positions[0] == -1)) {
|
(positions.size() == 1 && positions[0] == -1)) {
|
||||||
positions.resize(modules.size());
|
positions.resize(modules.size());
|
||||||
@ -184,7 +182,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
futures.reserve(positions.size());
|
futures.reserve(positions.size());
|
||||||
for (size_t i : positions) {
|
for (size_t i : positions) {
|
||||||
if (i >= modules.size())
|
if (i >= modules.size())
|
||||||
throw sls::RuntimeError("Module out of range");
|
throw RuntimeError("Module out of range");
|
||||||
futures.push_back(std::async(std::launch::async, somefunc,
|
futures.push_back(std::async(std::launch::async, somefunc,
|
||||||
modules[i].get(), Args...));
|
modules[i].get(), Args...));
|
||||||
}
|
}
|
||||||
@ -298,7 +296,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
std::vector<char> readProgrammingFile(const std::string &fname);
|
std::vector<char> readProgrammingFile(const std::string &fname);
|
||||||
|
|
||||||
void setNumberofUDPInterfaces(int n, Positions pos);
|
void setNumberofUDPInterfaces(int n, Positions pos);
|
||||||
sls::Result<int> getDefaultDac(defs::dacIndex index,
|
Result<int> getDefaultDac(defs::dacIndex index,
|
||||||
defs::detectorSettings sett,
|
defs::detectorSettings sett,
|
||||||
Positions pos = {});
|
Positions pos = {});
|
||||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
@ -396,9 +394,9 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
defs::xy calculatePosition(int moduleIndex, defs::xy geometry) const;
|
defs::xy calculatePosition(int moduleIndex, defs::xy geometry) const;
|
||||||
|
|
||||||
const int detectorIndex{0};
|
const int detectorIndex{0};
|
||||||
sls::SharedMemory<sharedDetector> shm{0, -1};
|
SharedMemory<sharedDetector> shm{0, -1};
|
||||||
sls::SharedMemory<CtbConfig> ctb_shm{0, -1, CtbConfig::shm_tag()};
|
SharedMemory<CtbConfig> ctb_shm{0, -1, CtbConfig::shm_tag()};
|
||||||
std::vector<std::unique_ptr<sls::Module>> modules;
|
std::vector<std::unique_ptr<Module>> modules;
|
||||||
|
|
||||||
/** data streaming (down stream) enabled in client (zmq sckets created) */
|
/** data streaming (down stream) enabled in client (zmq sckets created) */
|
||||||
bool client_downstream{false};
|
bool client_downstream{false};
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#include "sls/string_utils.h"
|
#include "sls/string_utils.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
std::string GetHelpDac(std::string dac) {
|
std::string GetHelpDac(std::string dac) {
|
||||||
if (sls::is_int(dac)) {
|
if (sls::is_int(dac)) {
|
||||||
return std::string("[dac name] [dac or mV value] [(optional unit) mV] "
|
return std::string("[dac name] [dac or mV value] [(optional unit) mV] "
|
||||||
@ -304,3 +306,5 @@ std::string GetHelpDac(std::string dac) {
|
|||||||
|
|
||||||
throw sls::RuntimeError("Unknown dac command");
|
throw sls::RuntimeError("Unknown dac command");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -68,7 +68,7 @@ std::string Module::getHostname() const { return shm()->hostname; }
|
|||||||
|
|
||||||
void Module::setHostname(const std::string &hostname,
|
void Module::setHostname(const std::string &hostname,
|
||||||
const bool initialChecks) {
|
const bool initialChecks) {
|
||||||
sls::strcpy_safe(shm()->hostname, hostname.c_str());
|
strcpy_safe(shm()->hostname, hostname.c_str());
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.close();
|
client.close();
|
||||||
try {
|
try {
|
||||||
@ -117,7 +117,7 @@ int64_t Module::getReceiverSoftwareVersion() const {
|
|||||||
slsDetectorDefs::detectorType
|
slsDetectorDefs::detectorType
|
||||||
Module::getTypeFromDetector(const std::string &hostname, int cport) {
|
Module::getTypeFromDetector(const std::string &hostname, int cport) {
|
||||||
LOG(logDEBUG1) << "Getting Module type ";
|
LOG(logDEBUG1) << "Getting Module type ";
|
||||||
sls::ClientSocket socket("Detector", hostname, cport);
|
ClientSocket socket("Detector", hostname, cport);
|
||||||
socket.Send(F_GET_DETECTOR_TYPE);
|
socket.Send(F_GET_DETECTOR_TYPE);
|
||||||
socket.Receive<int>(); // TODO! Should we look at this OK/FAIL?
|
socket.Receive<int>(); // TODO! Should we look at this OK/FAIL?
|
||||||
auto retval = socket.Receive<detectorType>();
|
auto retval = socket.Receive<detectorType>();
|
||||||
@ -443,7 +443,7 @@ std::string Module::getSettingsDir() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Module::setSettingsDir(const std::string &dir) {
|
std::string Module::setSettingsDir(const std::string &dir) {
|
||||||
sls::strcpy_safe(shm()->settingsDir, dir.c_str());
|
strcpy_safe(shm()->settingsDir, dir.c_str());
|
||||||
return shm()->settingsDir;
|
return shm()->settingsDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -894,7 +894,7 @@ std::vector<int64_t> Module::getFramesCaughtByReceiver() const {
|
|||||||
std::vector<int64_t> retval(nports);
|
std::vector<int64_t> retval(nports);
|
||||||
client.Receive(retval);
|
client.Receive(retval);
|
||||||
LOG(logDEBUG1) << "Frames caught of Receiver" << moduleIndex << ": "
|
LOG(logDEBUG1) << "Frames caught of Receiver" << moduleIndex << ": "
|
||||||
<< sls::ToString(retval);
|
<< ToString(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -916,7 +916,7 @@ std::vector<int64_t> Module::getNumMissingPackets() const {
|
|||||||
std::vector<int64_t> retval(nports);
|
std::vector<int64_t> retval(nports);
|
||||||
client.Receive(retval);
|
client.Receive(retval);
|
||||||
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex
|
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex
|
||||||
<< ": " << sls::ToString(retval);
|
<< ": " << ToString(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -938,7 +938,7 @@ std::vector<int64_t> Module::getReceiverCurrentFrameIndex() const {
|
|||||||
std::vector<int64_t> retval(nports);
|
std::vector<int64_t> retval(nports);
|
||||||
client.Receive(retval);
|
client.Receive(retval);
|
||||||
LOG(logDEBUG1) << "Frame index of Receiver" << moduleIndex << ": "
|
LOG(logDEBUG1) << "Frame index of Receiver" << moduleIndex << ": "
|
||||||
<< sls::ToString(retval);
|
<< ToString(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1002,8 +1002,8 @@ void Module::selectUDPInterface(int n) {
|
|||||||
sendToDetector(F_SET_INTERFACE_SEL, n, nullptr);
|
sendToDetector(F_SET_INTERFACE_SEL, n, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::IpAddr Module::getSourceUDPIP() const {
|
IpAddr Module::getSourceUDPIP() const {
|
||||||
return sendToDetector<sls::IpAddr>(F_GET_SOURCE_UDP_IP);
|
return sendToDetector<IpAddr>(F_GET_SOURCE_UDP_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setSourceUDPIP(const IpAddr ip) {
|
void Module::setSourceUDPIP(const IpAddr ip) {
|
||||||
@ -1013,8 +1013,8 @@ void Module::setSourceUDPIP(const IpAddr ip) {
|
|||||||
sendToDetector(F_SET_SOURCE_UDP_IP, ip, nullptr);
|
sendToDetector(F_SET_SOURCE_UDP_IP, ip, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::IpAddr Module::getSourceUDPIP2() const {
|
IpAddr Module::getSourceUDPIP2() const {
|
||||||
return sendToDetector<sls::IpAddr>(F_GET_SOURCE_UDP_IP2);
|
return sendToDetector<IpAddr>(F_GET_SOURCE_UDP_IP2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setSourceUDPIP2(const IpAddr ip) {
|
void Module::setSourceUDPIP2(const IpAddr ip) {
|
||||||
@ -1024,33 +1024,33 @@ void Module::setSourceUDPIP2(const IpAddr ip) {
|
|||||||
sendToDetector(F_SET_SOURCE_UDP_IP2, ip, nullptr);
|
sendToDetector(F_SET_SOURCE_UDP_IP2, ip, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::MacAddr Module::getSourceUDPMAC() const {
|
MacAddr Module::getSourceUDPMAC() const {
|
||||||
return sendToDetector<sls::MacAddr>(F_GET_SOURCE_UDP_MAC);
|
return sendToDetector<MacAddr>(F_GET_SOURCE_UDP_MAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setSourceUDPMAC(const sls::MacAddr mac) {
|
void Module::setSourceUDPMAC(const MacAddr mac) {
|
||||||
if (mac == 0) {
|
if (mac == 0) {
|
||||||
throw RuntimeError("Invalid source udp mac address");
|
throw RuntimeError("Invalid source udp mac address");
|
||||||
}
|
}
|
||||||
sendToDetector(F_SET_SOURCE_UDP_MAC, mac, nullptr);
|
sendToDetector(F_SET_SOURCE_UDP_MAC, mac, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::MacAddr Module::getSourceUDPMAC2() const {
|
MacAddr Module::getSourceUDPMAC2() const {
|
||||||
return sendToDetector<sls::MacAddr>(F_GET_SOURCE_UDP_MAC2);
|
return sendToDetector<MacAddr>(F_GET_SOURCE_UDP_MAC2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
|
void Module::setSourceUDPMAC2(const MacAddr mac) {
|
||||||
if (mac == 0) {
|
if (mac == 0) {
|
||||||
throw RuntimeError("Invalid source udp mac address2");
|
throw RuntimeError("Invalid source udp mac address2");
|
||||||
}
|
}
|
||||||
sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
|
sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
|
UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
|
||||||
return sendToDetector<sls::UdpDestination>(F_GET_DEST_UDP_LIST, entry);
|
return sendToDetector<UdpDestination>(F_GET_DEST_UDP_LIST, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDestinationUDPList(const sls::UdpDestination dest) {
|
void Module::setDestinationUDPList(const UdpDestination dest) {
|
||||||
// set them in the default way so the receivers are also set up
|
// set them in the default way so the receivers are also set up
|
||||||
if (dest.entry == 0) {
|
if (dest.entry == 0) {
|
||||||
if (dest.port != 0) {
|
if (dest.port != 0) {
|
||||||
@ -1090,8 +1090,8 @@ void Module::setFirstUDPDestination(const int value) {
|
|||||||
sendToDetector(F_SET_UDP_FIRST_DEST, value, nullptr);
|
sendToDetector(F_SET_UDP_FIRST_DEST, value, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::IpAddr Module::getDestinationUDPIP() const {
|
IpAddr Module::getDestinationUDPIP() const {
|
||||||
return sendToDetector<sls::IpAddr>(F_GET_DEST_UDP_IP);
|
return sendToDetector<IpAddr>(F_GET_DEST_UDP_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDestinationUDPIP(const IpAddr ip) {
|
void Module::setDestinationUDPIP(const IpAddr ip) {
|
||||||
@ -1104,7 +1104,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
|
|||||||
}
|
}
|
||||||
sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr);
|
sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr);
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sls::MacAddr retval(0LU);
|
MacAddr retval(0LU);
|
||||||
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
|
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
|
||||||
LOG(logINFO) << "Setting destination udp mac of Module " << moduleIndex
|
LOG(logINFO) << "Setting destination udp mac of Module " << moduleIndex
|
||||||
<< " to " << retval;
|
<< " to " << retval;
|
||||||
@ -1112,8 +1112,8 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::IpAddr Module::getDestinationUDPIP2() const {
|
IpAddr Module::getDestinationUDPIP2() const {
|
||||||
return sendToDetector<sls::IpAddr>(F_GET_DEST_UDP_IP2);
|
return sendToDetector<IpAddr>(F_GET_DEST_UDP_IP2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDestinationUDPIP2(const IpAddr ip) {
|
void Module::setDestinationUDPIP2(const IpAddr ip) {
|
||||||
@ -1127,7 +1127,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
|
|||||||
}
|
}
|
||||||
sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr);
|
sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr);
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sls::MacAddr retval(0LU);
|
MacAddr retval(0LU);
|
||||||
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
|
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
|
||||||
LOG(logINFO) << "Setting destination udp mac2 of Module " << moduleIndex
|
LOG(logINFO) << "Setting destination udp mac2 of Module " << moduleIndex
|
||||||
<< " to " << retval;
|
<< " to " << retval;
|
||||||
@ -1135,8 +1135,8 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::MacAddr Module::getDestinationUDPMAC() const {
|
MacAddr Module::getDestinationUDPMAC() const {
|
||||||
return sendToDetector<sls::MacAddr>(F_GET_DEST_UDP_MAC);
|
return sendToDetector<MacAddr>(F_GET_DEST_UDP_MAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDestinationUDPMAC(const MacAddr mac) {
|
void Module::setDestinationUDPMAC(const MacAddr mac) {
|
||||||
@ -1146,8 +1146,8 @@ void Module::setDestinationUDPMAC(const MacAddr mac) {
|
|||||||
sendToDetector(F_SET_DEST_UDP_MAC, mac, nullptr);
|
sendToDetector(F_SET_DEST_UDP_MAC, mac, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::MacAddr Module::getDestinationUDPMAC2() const {
|
MacAddr Module::getDestinationUDPMAC2() const {
|
||||||
return sendToDetector<sls::MacAddr>(F_GET_DEST_UDP_MAC2);
|
return sendToDetector<MacAddr>(F_GET_DEST_UDP_MAC2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDestinationUDPMAC2(const MacAddr mac) {
|
void Module::setDestinationUDPMAC2(const MacAddr mac) {
|
||||||
@ -1279,19 +1279,19 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
|
|||||||
|
|
||||||
if (receiverIP == "none") {
|
if (receiverIP == "none") {
|
||||||
memset(shm()->rxHostname, 0, MAX_STR_LENGTH);
|
memset(shm()->rxHostname, 0, MAX_STR_LENGTH);
|
||||||
sls::strcpy_safe(shm()->rxHostname, "none");
|
strcpy_safe(shm()->rxHostname, "none");
|
||||||
shm()->useReceiverFlag = false;
|
shm()->useReceiverFlag = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start updating
|
// start updating
|
||||||
std::string host = receiverIP;
|
std::string host = receiverIP;
|
||||||
auto res = sls::split(host, ':');
|
auto res = split(host, ':');
|
||||||
if (res.size() > 1) {
|
if (res.size() > 1) {
|
||||||
host = res[0];
|
host = res[0];
|
||||||
shm()->rxTCPPort = std::stoi(res[1]);
|
shm()->rxTCPPort = std::stoi(res[1]);
|
||||||
}
|
}
|
||||||
sls::strcpy_safe(shm()->rxHostname, host.c_str());
|
strcpy_safe(shm()->rxHostname, host.c_str());
|
||||||
shm()->useReceiverFlag = true;
|
shm()->useReceiverFlag = true;
|
||||||
checkReceiverVersionCompatibility();
|
checkReceiverVersionCompatibility();
|
||||||
|
|
||||||
@ -1307,7 +1307,7 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
|
|||||||
memset(retval.hostname, 0, sizeof(retval.hostname));
|
memset(retval.hostname, 0, sizeof(retval.hostname));
|
||||||
strcpy_safe(retval.hostname, shm()->hostname);
|
strcpy_safe(retval.hostname, shm()->hostname);
|
||||||
|
|
||||||
sls::MacAddr retvals[2];
|
MacAddr retvals[2];
|
||||||
sendToReceiver(F_SETUP_RECEIVER, retval, retvals);
|
sendToReceiver(F_SETUP_RECEIVER, retval, retvals);
|
||||||
// update Modules with dest mac
|
// update Modules with dest mac
|
||||||
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
|
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
|
||||||
@ -1393,8 +1393,8 @@ void Module::setReceiverLock(bool lock) {
|
|||||||
sendToReceiver<int>(F_LOCK_RECEIVER, static_cast<int>(lock));
|
sendToReceiver<int>(F_LOCK_RECEIVER, static_cast<int>(lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::IpAddr Module::getReceiverLastClientIP() const {
|
IpAddr Module::getReceiverLastClientIP() const {
|
||||||
return sendToReceiver<sls::IpAddr>(F_GET_LAST_RECEIVER_CLIENT_IP);
|
return sendToReceiver<IpAddr>(F_GET_LAST_RECEIVER_CLIENT_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<pid_t, NUM_RX_THREAD_IDS> Module::getReceiverThreadIds() const {
|
std::array<pid_t, NUM_RX_THREAD_IDS> Module::getReceiverThreadIds() const {
|
||||||
@ -1443,7 +1443,7 @@ void Module::setFilePath(const std::string &path) {
|
|||||||
throw RuntimeError("Cannot set empty file path");
|
throw RuntimeError("Cannot set empty file path");
|
||||||
}
|
}
|
||||||
char args[MAX_STR_LENGTH]{};
|
char args[MAX_STR_LENGTH]{};
|
||||||
sls::strcpy_safe(args, path.c_str());
|
strcpy_safe(args, path.c_str());
|
||||||
sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, nullptr);
|
sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1458,7 +1458,7 @@ void Module::setFileName(const std::string &fname) {
|
|||||||
throw RuntimeError("Cannot set empty file name prefix");
|
throw RuntimeError("Cannot set empty file name prefix");
|
||||||
}
|
}
|
||||||
char args[MAX_STR_LENGTH]{};
|
char args[MAX_STR_LENGTH]{};
|
||||||
sls::strcpy_safe(args, fname.c_str());
|
strcpy_safe(args, fname.c_str());
|
||||||
sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, nullptr);
|
sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1555,11 +1555,11 @@ void Module::setReceiverStreamingPort(int port) {
|
|||||||
sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::IpAddr Module::getReceiverStreamingIP() const {
|
IpAddr Module::getReceiverStreamingIP() const {
|
||||||
return sendToReceiver<sls::IpAddr>(F_GET_RECEIVER_STREAMING_SRC_IP);
|
return sendToReceiver<IpAddr>(F_GET_RECEIVER_STREAMING_SRC_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setReceiverStreamingIP(const sls::IpAddr ip) {
|
void Module::setReceiverStreamingIP(const IpAddr ip) {
|
||||||
if (ip == 0) {
|
if (ip == 0) {
|
||||||
throw RuntimeError("Invalid receiver zmq ip address");
|
throw RuntimeError("Invalid receiver zmq ip address");
|
||||||
}
|
}
|
||||||
@ -1574,9 +1574,9 @@ int Module::getClientStreamingPort() const { return shm()->zmqport; }
|
|||||||
|
|
||||||
void Module::setClientStreamingPort(int port) { shm()->zmqport = port; }
|
void Module::setClientStreamingPort(int port) { shm()->zmqport = port; }
|
||||||
|
|
||||||
sls::IpAddr Module::getClientStreamingIP() const { return shm()->zmqip; }
|
IpAddr Module::getClientStreamingIP() const { return shm()->zmqip; }
|
||||||
|
|
||||||
void Module::setClientStreamingIP(const sls::IpAddr ip) {
|
void Module::setClientStreamingIP(const IpAddr ip) {
|
||||||
if (ip == 0) {
|
if (ip == 0) {
|
||||||
throw RuntimeError("Invalid client zmq ip address");
|
throw RuntimeError("Invalid client zmq ip address");
|
||||||
}
|
}
|
||||||
@ -2420,18 +2420,18 @@ void Module::setExternalSampling(bool value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> Module::getReceiverDbitList() const {
|
std::vector<int> Module::getReceiverDbitList() const {
|
||||||
return sendToReceiver<sls::StaticVector<int, MAX_RX_DBIT>>(
|
return sendToReceiver<StaticVector<int, MAX_RX_DBIT>>(
|
||||||
F_GET_RECEIVER_DBIT_LIST);
|
F_GET_RECEIVER_DBIT_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setReceiverDbitList(std::vector<int> list) {
|
void Module::setReceiverDbitList(std::vector<int> list) {
|
||||||
LOG(logDEBUG1) << "Setting Receiver Dbit List";
|
LOG(logDEBUG1) << "Setting Receiver Dbit List";
|
||||||
if (list.size() > 64) {
|
if (list.size() > 64) {
|
||||||
throw sls::RuntimeError("Dbit list size cannot be greater than 64\n");
|
throw RuntimeError("Dbit list size cannot be greater than 64\n");
|
||||||
}
|
}
|
||||||
for (auto &it : list) {
|
for (auto &it : list) {
|
||||||
if (it < 0 || it > 63) {
|
if (it < 0 || it > 63) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Dbit list value must be between 0 and 63\n");
|
"Dbit list value must be between 0 and 63\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2439,7 +2439,7 @@ void Module::setReceiverDbitList(std::vector<int> list) {
|
|||||||
auto last = std::unique(begin(list), end(list));
|
auto last = std::unique(begin(list), end(list));
|
||||||
list.erase(last, list.end());
|
list.erase(last, list.end());
|
||||||
|
|
||||||
sls::StaticVector<int, MAX_RX_DBIT> arg = list;
|
StaticVector<int, MAX_RX_DBIT> arg = list;
|
||||||
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2628,7 +2628,7 @@ void Module::setAdditionalJsonHeader(
|
|||||||
|
|
||||||
std::string Module::getAdditionalJsonParameter(const std::string &key) const {
|
std::string Module::getAdditionalJsonParameter(const std::string &key) const {
|
||||||
char arg[SHORT_STR_LENGTH]{};
|
char arg[SHORT_STR_LENGTH]{};
|
||||||
sls::strcpy_safe(arg, key.c_str());
|
strcpy_safe(arg, key.c_str());
|
||||||
char retval[SHORT_STR_LENGTH]{};
|
char retval[SHORT_STR_LENGTH]{};
|
||||||
sendToReceiver(F_GET_ADDITIONAL_JSON_PARAMETER, arg, retval);
|
sendToReceiver(F_GET_ADDITIONAL_JSON_PARAMETER, arg, retval);
|
||||||
return retval;
|
return retval;
|
||||||
@ -2644,8 +2644,8 @@ void Module::setAdditionalJsonParameter(const std::string &key,
|
|||||||
"Key cannot be empty. Both can have max 2 characters");
|
"Key cannot be empty. Both can have max 2 characters");
|
||||||
}
|
}
|
||||||
char args[2][SHORT_STR_LENGTH]{};
|
char args[2][SHORT_STR_LENGTH]{};
|
||||||
sls::strcpy_safe(args[0], key.c_str());
|
strcpy_safe(args[0], key.c_str());
|
||||||
sls::strcpy_safe(args[1], value.c_str());
|
strcpy_safe(args[1], value.c_str());
|
||||||
sendToReceiver(F_SET_ADDITIONAL_JSON_PARAMETER, args, nullptr);
|
sendToReceiver(F_SET_ADDITIONAL_JSON_PARAMETER, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2797,14 +2797,14 @@ void Module::setLockDetector(bool lock) {
|
|||||||
sendToDetector<int>(F_LOCK_SERVER, static_cast<int>(lock));
|
sendToDetector<int>(F_LOCK_SERVER, static_cast<int>(lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::IpAddr Module::getLastClientIP() const {
|
IpAddr Module::getLastClientIP() const {
|
||||||
return sendToDetector<sls::IpAddr>(F_GET_LAST_CLIENT_IP);
|
return sendToDetector<IpAddr>(F_GET_LAST_CLIENT_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Module::executeCommand(const std::string &cmd) {
|
std::string Module::executeCommand(const std::string &cmd) {
|
||||||
char arg[MAX_STR_LENGTH]{};
|
char arg[MAX_STR_LENGTH]{};
|
||||||
char retval[MAX_STR_LENGTH]{};
|
char retval[MAX_STR_LENGTH]{};
|
||||||
sls::strcpy_safe(arg, cmd.c_str());
|
strcpy_safe(arg, cmd.c_str());
|
||||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||||
<< "): Sending command " << cmd;
|
<< "): Sending command " << cmd;
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
@ -3254,8 +3254,8 @@ void Module::initializeModuleStructure(detectorType type) {
|
|||||||
shm()->numberOfModule.y = 0;
|
shm()->numberOfModule.y = 0;
|
||||||
shm()->controlPort = DEFAULT_PORTNO;
|
shm()->controlPort = DEFAULT_PORTNO;
|
||||||
shm()->stopPort = DEFAULT_PORTNO + 1;
|
shm()->stopPort = DEFAULT_PORTNO + 1;
|
||||||
sls::strcpy_safe(shm()->settingsDir, getenv("HOME"));
|
strcpy_safe(shm()->settingsDir, getenv("HOME"));
|
||||||
sls::strcpy_safe(shm()->rxHostname, "none");
|
strcpy_safe(shm()->rxHostname, "none");
|
||||||
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
|
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
|
||||||
shm()->useReceiverFlag = false;
|
shm()->useReceiverFlag = false;
|
||||||
shm()->numUDPInterfaces = 1;
|
shm()->numUDPInterfaces = 1;
|
||||||
@ -3310,7 +3310,7 @@ void Module::checkReceiverVersionCompatibility() {
|
|||||||
sendToReceiver(F_RECEIVER_CHECK_VERSION, int64_t(APIRECEIVER), nullptr);
|
sendToReceiver(F_RECEIVER_CHECK_VERSION, int64_t(APIRECEIVER), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Module::sendModule(sls_detector_module *myMod, sls::ClientSocket &client) {
|
int Module::sendModule(sls_detector_module *myMod, ClientSocket &client) {
|
||||||
constexpr TLogLevel level = logDEBUG1;
|
constexpr TLogLevel level = logDEBUG1;
|
||||||
LOG(level) << "Sending Module";
|
LOG(level) << "Sending Module";
|
||||||
int ts = 0;
|
int ts = 0;
|
||||||
@ -3381,7 +3381,7 @@ void Module::updateReceiverStreamingIP() {
|
|||||||
auto ip = getReceiverStreamingIP();
|
auto ip = getReceiverStreamingIP();
|
||||||
if (ip == 0) {
|
if (ip == 0) {
|
||||||
// Hostname could be ip try to decode otherwise look up the hostname
|
// Hostname could be ip try to decode otherwise look up the hostname
|
||||||
ip = sls::IpAddr{shm()->rxHostname};
|
ip = IpAddr{shm()->rxHostname};
|
||||||
if (ip == 0) {
|
if (ip == 0) {
|
||||||
ip = HostnameToIp(shm()->rxHostname);
|
ip = HostnameToIp(shm()->rxHostname);
|
||||||
}
|
}
|
||||||
@ -3634,7 +3634,7 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
|||||||
client.Send(filesize);
|
client.Send(filesize);
|
||||||
|
|
||||||
// send checksum
|
// send checksum
|
||||||
std::string checksum = sls::md5_calculate_checksum(buffer.data(), filesize);
|
std::string checksum = md5_calculate_checksum(buffer.data(), filesize);
|
||||||
LOG(logDEBUG1) << "Checksum:" << checksum;
|
LOG(logDEBUG1) << "Checksum:" << checksum;
|
||||||
char cChecksum[MAX_STR_LENGTH] = {0};
|
char cChecksum[MAX_STR_LENGTH] = {0};
|
||||||
strcpy(cChecksum, checksum.c_str());
|
strcpy(cChecksum, checksum.c_str());
|
||||||
|
@ -14,13 +14,13 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class ServerInterface;
|
class ServerInterface;
|
||||||
|
|
||||||
#define MODULE_SHMAPIVERSION 0x190726
|
#define MODULE_SHMAPIVERSION 0x190726
|
||||||
#define MODULE_SHMVERSION 0x200402
|
#define MODULE_SHMVERSION 0x200402
|
||||||
|
|
||||||
namespace sls {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short structure allocated in shared memory to store Module settings for
|
* @short structure allocated in shared memory to store Module settings for
|
||||||
* IPC and cache
|
* IPC and cache
|
||||||
@ -40,7 +40,7 @@ struct sharedModule {
|
|||||||
int stopPort;
|
int stopPort;
|
||||||
char settingsDir[MAX_STR_LENGTH];
|
char settingsDir[MAX_STR_LENGTH];
|
||||||
/** list of the energies at which the Module has been trimmed */
|
/** list of the energies at which the Module has been trimmed */
|
||||||
sls::StaticVector<int, MAX_TRIMEN> trimEnergies;
|
StaticVector<int, MAX_TRIMEN> trimEnergies;
|
||||||
/** number of channels per chip */
|
/** number of channels per chip */
|
||||||
slsDetectorDefs::xy nChan;
|
slsDetectorDefs::xy nChan;
|
||||||
slsDetectorDefs::xy nChip;
|
slsDetectorDefs::xy nChip;
|
||||||
@ -52,7 +52,7 @@ struct sharedModule {
|
|||||||
/** Listening tcp port from gui (only data) */
|
/** Listening tcp port from gui (only data) */
|
||||||
int zmqport;
|
int zmqport;
|
||||||
/** Listening tcp ip address from gui (only data) **/
|
/** Listening tcp ip address from gui (only data) **/
|
||||||
sls::IpAddr zmqip;
|
IpAddr zmqip;
|
||||||
int numUDPInterfaces;
|
int numUDPInterfaces;
|
||||||
/** to inform rxr when stopping rxr */
|
/** to inform rxr when stopping rxr */
|
||||||
bool stoppedFlag;
|
bool stoppedFlag;
|
||||||
@ -223,28 +223,28 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setNumberofUDPInterfaces(int n);
|
void setNumberofUDPInterfaces(int n);
|
||||||
int getSelectedUDPInterface() const;
|
int getSelectedUDPInterface() const;
|
||||||
void selectUDPInterface(int n);
|
void selectUDPInterface(int n);
|
||||||
sls::IpAddr getSourceUDPIP() const;
|
IpAddr getSourceUDPIP() const;
|
||||||
void setSourceUDPIP(const sls::IpAddr ip);
|
void setSourceUDPIP(const IpAddr ip);
|
||||||
sls::IpAddr getSourceUDPIP2() const;
|
IpAddr getSourceUDPIP2() const;
|
||||||
void setSourceUDPIP2(const sls::IpAddr ip);
|
void setSourceUDPIP2(const IpAddr ip);
|
||||||
sls::MacAddr getSourceUDPMAC() const;
|
MacAddr getSourceUDPMAC() const;
|
||||||
void setSourceUDPMAC(const sls::MacAddr mac);
|
void setSourceUDPMAC(const MacAddr mac);
|
||||||
sls::MacAddr getSourceUDPMAC2() const;
|
MacAddr getSourceUDPMAC2() const;
|
||||||
void setSourceUDPMAC2(const sls::MacAddr mac);
|
void setSourceUDPMAC2(const MacAddr mac);
|
||||||
sls::UdpDestination getDestinationUDPList(const uint32_t entry) const;
|
UdpDestination getDestinationUDPList(const uint32_t entry) const;
|
||||||
void setDestinationUDPList(const sls::UdpDestination dest);
|
void setDestinationUDPList(const UdpDestination dest);
|
||||||
int getNumberofUDPDestinations() const;
|
int getNumberofUDPDestinations() const;
|
||||||
void clearUDPDestinations();
|
void clearUDPDestinations();
|
||||||
int getFirstUDPDestination() const;
|
int getFirstUDPDestination() const;
|
||||||
void setFirstUDPDestination(const int value);
|
void setFirstUDPDestination(const int value);
|
||||||
sls::IpAddr getDestinationUDPIP() const;
|
IpAddr getDestinationUDPIP() const;
|
||||||
void setDestinationUDPIP(const sls::IpAddr ip);
|
void setDestinationUDPIP(const IpAddr ip);
|
||||||
sls::IpAddr getDestinationUDPIP2() const;
|
IpAddr getDestinationUDPIP2() const;
|
||||||
void setDestinationUDPIP2(const sls::IpAddr ip);
|
void setDestinationUDPIP2(const IpAddr ip);
|
||||||
sls::MacAddr getDestinationUDPMAC() const;
|
MacAddr getDestinationUDPMAC() const;
|
||||||
void setDestinationUDPMAC(const sls::MacAddr mac);
|
void setDestinationUDPMAC(const MacAddr mac);
|
||||||
sls::MacAddr getDestinationUDPMAC2() const;
|
MacAddr getDestinationUDPMAC2() const;
|
||||||
void setDestinationUDPMAC2(const sls::MacAddr mac);
|
void setDestinationUDPMAC2(const MacAddr mac);
|
||||||
int getDestinationUDPPort() const;
|
int getDestinationUDPPort() const;
|
||||||
void setDestinationUDPPort(int udpport);
|
void setDestinationUDPPort(int udpport);
|
||||||
int getDestinationUDPPort2() const;
|
int getDestinationUDPPort2() const;
|
||||||
@ -286,7 +286,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setReceiverUDPSocketBufferSize(int udpsockbufsize);
|
void setReceiverUDPSocketBufferSize(int udpsockbufsize);
|
||||||
bool getReceiverLock() const;
|
bool getReceiverLock() const;
|
||||||
void setReceiverLock(bool lock);
|
void setReceiverLock(bool lock);
|
||||||
sls::IpAddr getReceiverLastClientIP() const;
|
IpAddr getReceiverLastClientIP() const;
|
||||||
std::array<pid_t, NUM_RX_THREAD_IDS> getReceiverThreadIds() const;
|
std::array<pid_t, NUM_RX_THREAD_IDS> getReceiverThreadIds() const;
|
||||||
bool getRxArping() const;
|
bool getRxArping() const;
|
||||||
void setRxArping(bool enable);
|
void setRxArping(bool enable);
|
||||||
@ -334,12 +334,12 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setReceiverStreamingStartingFrame(int fnum);
|
void setReceiverStreamingStartingFrame(int fnum);
|
||||||
int getReceiverStreamingPort() const;
|
int getReceiverStreamingPort() const;
|
||||||
void setReceiverStreamingPort(int port);
|
void setReceiverStreamingPort(int port);
|
||||||
sls::IpAddr getReceiverStreamingIP() const;
|
IpAddr getReceiverStreamingIP() const;
|
||||||
void setReceiverStreamingIP(const sls::IpAddr ip);
|
void setReceiverStreamingIP(const IpAddr ip);
|
||||||
int getClientStreamingPort() const;
|
int getClientStreamingPort() const;
|
||||||
void setClientStreamingPort(int port);
|
void setClientStreamingPort(int port);
|
||||||
sls::IpAddr getClientStreamingIP() const;
|
IpAddr getClientStreamingIP() const;
|
||||||
void setClientStreamingIP(const sls::IpAddr ip);
|
void setClientStreamingIP(const IpAddr ip);
|
||||||
int getReceiverStreamingHwm() const;
|
int getReceiverStreamingHwm() const;
|
||||||
void setReceiverStreamingHwm(const int limit);
|
void setReceiverStreamingHwm(const int limit);
|
||||||
|
|
||||||
@ -589,7 +589,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setStopPort(int port_number);
|
void setStopPort(int port_number);
|
||||||
bool getLockDetector() const;
|
bool getLockDetector() const;
|
||||||
void setLockDetector(bool lock);
|
void setLockDetector(bool lock);
|
||||||
sls::IpAddr getLastClientIP() const;
|
IpAddr getLastClientIP() const;
|
||||||
std::string executeCommand(const std::string &cmd);
|
std::string executeCommand(const std::string &cmd);
|
||||||
int64_t getNumberOfFramesFromStart() const;
|
int64_t getNumberOfFramesFromStart() const;
|
||||||
int64_t getActualTime() const;
|
int64_t getActualTime() const;
|
||||||
@ -736,7 +736,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void checkDetectorVersionCompatibility();
|
void checkDetectorVersionCompatibility();
|
||||||
void checkReceiverVersionCompatibility();
|
void checkReceiverVersionCompatibility();
|
||||||
void setModule(sls_detector_module &module, bool trimbits = true);
|
void setModule(sls_detector_module &module, bool trimbits = true);
|
||||||
int sendModule(sls_detector_module *myMod, sls::ClientSocket &client);
|
int sendModule(sls_detector_module *myMod, ClientSocket &client);
|
||||||
void updateReceiverStreamingIP();
|
void updateReceiverStreamingIP();
|
||||||
|
|
||||||
void updateRateCorrection();
|
void updateRateCorrection();
|
||||||
@ -778,7 +778,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
const int timeRequired);
|
const int timeRequired);
|
||||||
|
|
||||||
const int moduleIndex;
|
const int moduleIndex;
|
||||||
mutable sls::SharedMemory<sharedModule> shm{0, 0};
|
mutable SharedMemory<sharedModule> shm{0, 0};
|
||||||
static const int BLACKFIN_ERASE_FLASH_TIME = 65;
|
static const int BLACKFIN_ERASE_FLASH_TIME = 65;
|
||||||
static const int BLACKFIN_WRITE_TO_FLASH_TIME = 30;
|
static const int BLACKFIN_WRITE_TO_FLASH_TIME = 30;
|
||||||
static const int NIOS_ERASE_FLASH_TIME_FPGA = 10;
|
static const int NIOS_ERASE_FLASH_TIME_FPGA = 10;
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_exceptions.h"
|
#include "sls/sls_detector_exceptions.h"
|
||||||
|
|
||||||
// #include "stdlib.h"
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cerrno> // errno
|
#include <cerrno> // errno
|
||||||
#include <cstring> // strerror
|
#include <cstring> // strerror
|
||||||
@ -23,16 +22,15 @@
|
|||||||
#include <sys/mman.h> // shared memory
|
#include <sys/mman.h> // shared memory
|
||||||
#include <sys/stat.h> // fstat
|
#include <sys/stat.h> // fstat
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_"
|
|
||||||
#define SHM_MODULE_PREFIX "_module_"
|
|
||||||
#define SHM_ENV_NAME "SLSDETNAME"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
#define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_"
|
||||||
|
#define SHM_MODULE_PREFIX "_module_"
|
||||||
|
#define SHM_ENV_NAME "SLSDETNAME"
|
||||||
|
|
||||||
template <typename T> class SharedMemory {
|
template <typename T> class SharedMemory {
|
||||||
static constexpr int NAME_MAX_LENGTH = 255;
|
static constexpr int NAME_MAX_LENGTH = 255;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class ClientInterface;
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
class ClientInterface;
|
||||||
|
|
||||||
class Receiver : private virtual slsDetectorDefs {
|
class Receiver : private virtual slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
// gettid added in glibc 2.30
|
// gettid added in glibc 2.30
|
||||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
@ -16,7 +18,7 @@ void Arping::SetInterfacesAndIps(const int index, const std::string &interface,
|
|||||||
const std::string &ip) {
|
const std::string &ip) {
|
||||||
|
|
||||||
if (interface.empty() || ip.empty()) {
|
if (interface.empty() || ip.empty()) {
|
||||||
throw sls::RuntimeError("Could not arping. Interface name and ip not "
|
throw RuntimeError("Could not arping. Interface name and ip not "
|
||||||
"set up for interface " +
|
"set up for interface " +
|
||||||
std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
@ -38,7 +40,7 @@ void Arping::StartThread() {
|
|||||||
try {
|
try {
|
||||||
t = std::thread(&Arping::ThreadExecution, this);
|
t = std::thread(&Arping::ThreadExecution, this);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw sls::RuntimeError("Could not start arping thread");
|
throw RuntimeError("Could not start arping thread");
|
||||||
}
|
}
|
||||||
runningFlag = true;
|
runningFlag = true;
|
||||||
}
|
}
|
||||||
@ -74,13 +76,13 @@ void Arping::ThreadExecution() {
|
|||||||
void Arping::TestCommands() {
|
void Arping::TestCommands() {
|
||||||
// atleast one interface must be set up
|
// atleast one interface must be set up
|
||||||
if (commands[0].empty()) {
|
if (commands[0].empty()) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not arping. Interface not set up in apring thread");
|
"Could not arping. Interface not set up in apring thread");
|
||||||
}
|
}
|
||||||
// test if arping commands throw an error
|
// test if arping commands throw an error
|
||||||
std::string error = ExecuteCommands();
|
std::string error = ExecuteCommands();
|
||||||
if (!error.empty()) {
|
if (!error.empty()) {
|
||||||
throw sls::RuntimeError(error);
|
throw RuntimeError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,3 +120,5 @@ std::string Arping::ExecuteCommands() {
|
|||||||
|
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -12,6 +12,8 @@ is listening to.
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class Arping {
|
class Arping {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -33,3 +35,6 @@ class Arping {
|
|||||||
std::thread t;
|
std::thread t;
|
||||||
std::atomic<pid_t> threadId{0};
|
std::atomic<pid_t> threadId{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#include "BinaryDataFile.h"
|
#include "BinaryDataFile.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
BinaryDataFile::BinaryDataFile(const int index) : File(BINARY), index_(index) {}
|
BinaryDataFile::BinaryDataFile(const int index) : File(BINARY), index_(index) {}
|
||||||
|
|
||||||
BinaryDataFile::~BinaryDataFile() { CloseFile(); }
|
BinaryDataFile::~BinaryDataFile() { CloseFile(); }
|
||||||
@ -47,12 +49,12 @@ void BinaryDataFile::CreateFile() {
|
|||||||
if (!overWriteEnable_) {
|
if (!overWriteEnable_) {
|
||||||
if (nullptr == (fd_ = fopen((const char *)fileName_.c_str(), "wx"))) {
|
if (nullptr == (fd_ = fopen((const char *)fileName_.c_str(), "wx"))) {
|
||||||
fd_ = nullptr;
|
fd_ = nullptr;
|
||||||
throw sls::RuntimeError("Could not create/overwrite file " +
|
throw RuntimeError("Could not create/overwrite file " +
|
||||||
fileName_);
|
fileName_);
|
||||||
}
|
}
|
||||||
} else if (nullptr == (fd_ = fopen((const char *)fileName_.c_str(), "w"))) {
|
} else if (nullptr == (fd_ = fopen((const char *)fileName_.c_str(), "w"))) {
|
||||||
fd_ = nullptr;
|
fd_ = nullptr;
|
||||||
throw sls::RuntimeError("Could not create file " + fileName_);
|
throw RuntimeError("Could not create file " + fileName_);
|
||||||
}
|
}
|
||||||
// setting to no file buffering
|
// setting to no file buffering
|
||||||
setvbuf(fd_, nullptr, _IONBF, 0);
|
setvbuf(fd_, nullptr, _IONBF, 0);
|
||||||
@ -103,8 +105,10 @@ void BinaryDataFile::WriteToFile(char *buffer, const int buffersize,
|
|||||||
|
|
||||||
// if write error
|
// if write error
|
||||||
if (ret != buffersize) {
|
if (ret != buffersize) {
|
||||||
throw sls::RuntimeError(std::to_string(index_) +
|
throw RuntimeError(std::to_string(index_) +
|
||||||
" : Write to file failed for image number " +
|
" : Write to file failed for image number " +
|
||||||
std::to_string(currentFrameNumber));
|
std::to_string(currentFrameNumber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class BinaryDataFile : private virtual slsDetectorDefs, public File {
|
class BinaryDataFile : private virtual slsDetectorDefs, public File {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -43,3 +45,5 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File {
|
|||||||
uint32_t udpPortNumber_{0};
|
uint32_t udpPortNumber_{0};
|
||||||
uint32_t maxFramesPerFile_{0};
|
uint32_t maxFramesPerFile_{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -22,10 +22,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
using ns = std::chrono::nanoseconds;
|
using ns = std::chrono::nanoseconds;
|
||||||
using sls::RuntimeError;
|
using Interface = ServerInterface;
|
||||||
using sls::SocketError;
|
|
||||||
using Interface = sls::ServerInterface;
|
|
||||||
|
|
||||||
// gettid added in glibc 2.30
|
// gettid added in glibc 2.30
|
||||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||||
@ -33,6 +34,7 @@ using Interface = sls::ServerInterface;
|
|||||||
#define gettid() syscall(SYS_gettid)
|
#define gettid() syscall(SYS_gettid)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ClientInterface::~ClientInterface() {
|
ClientInterface::~ClientInterface() {
|
||||||
killTcpThread = true;
|
killTcpThread = true;
|
||||||
LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
||||||
@ -48,7 +50,7 @@ ClientInterface::ClientInterface(int portNumber)
|
|||||||
functionTable();
|
functionTable();
|
||||||
parentThreadId = gettid();
|
parentThreadId = gettid();
|
||||||
tcpThread =
|
tcpThread =
|
||||||
sls::make_unique<std::thread>(&ClientInterface::startTCPServer, this);
|
make_unique<std::thread>(&ClientInterface::startTCPServer, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ClientInterface::getReceiverVersion() { return APIRECEIVER; }
|
int64_t ClientInterface::getReceiverVersion() { return APIRECEIVER; }
|
||||||
@ -98,7 +100,7 @@ void ClientInterface::startTCPServer() {
|
|||||||
} catch (const RuntimeError &e) {
|
} catch (const RuntimeError &e) {
|
||||||
// We had an error needs to be sent to client
|
// We had an error needs to be sent to client
|
||||||
char mess[MAX_STR_LENGTH]{};
|
char mess[MAX_STR_LENGTH]{};
|
||||||
sls::strcpy_safe(mess, e.what());
|
strcpy_safe(mess, e.what());
|
||||||
socket.Send(FAIL);
|
socket.Send(FAIL);
|
||||||
socket.Send(mess);
|
socket.Send(mess);
|
||||||
}
|
}
|
||||||
@ -277,7 +279,7 @@ void ClientInterface::validate(T arg, T retval, const std::string &modename,
|
|||||||
|
|
||||||
void ClientInterface::verifyLock() {
|
void ClientInterface::verifyLock() {
|
||||||
if (lockedByClient && server.getThisClient() != server.getLockedBy()) {
|
if (lockedByClient && server.getThisClient() != server.getLockedBy()) {
|
||||||
throw sls::SocketError("Receiver locked\n");
|
throw SocketError("Receiver locked\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +289,7 @@ void ClientInterface::verifyIdle(Interface &socket) {
|
|||||||
oss << "Can not execute "
|
oss << "Can not execute "
|
||||||
<< getFunctionNameFromEnum((enum detFuncs)fnum)
|
<< getFunctionNameFromEnum((enum detFuncs)fnum)
|
||||||
<< " when receiver is not idle";
|
<< " when receiver is not idle";
|
||||||
throw sls::SocketError(oss.str());
|
throw SocketError(oss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +301,7 @@ int ClientInterface::lock_receiver(Interface &socket) {
|
|||||||
(server.getLockedBy() == server.getThisClient())) {
|
(server.getLockedBy() == server.getThisClient())) {
|
||||||
lockedByClient = lock;
|
lockedByClient = lock;
|
||||||
lock ? server.setLockedBy(server.getThisClient())
|
lock ? server.setLockedBy(server.getThisClient())
|
||||||
: server.setLockedBy(sls::IpAddr{});
|
: server.setLockedBy(IpAddr{});
|
||||||
} else {
|
} else {
|
||||||
throw RuntimeError("Receiver locked\n");
|
throw RuntimeError("Receiver locked\n");
|
||||||
}
|
}
|
||||||
@ -317,7 +319,7 @@ int ClientInterface::get_version(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::setup_receiver(Interface &socket) {
|
int ClientInterface::setup_receiver(Interface &socket) {
|
||||||
auto arg = socket.Receive<rxParameters>();
|
auto arg = socket.Receive<rxParameters>();
|
||||||
LOG(logDEBUG) << sls::ToString(arg);
|
LOG(logDEBUG) << ToString(arg);
|
||||||
|
|
||||||
// if object exists, verify unlocked and idle, else only verify lock
|
// if object exists, verify unlocked and idle, else only verify lock
|
||||||
// (connecting first time)
|
// (connecting first time)
|
||||||
@ -333,17 +335,17 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
|||||||
|
|
||||||
// udp setup
|
// udp setup
|
||||||
// update retvals only if detmac is not the same as in detector
|
// update retvals only if detmac is not the same as in detector
|
||||||
sls::MacAddr retvals[2];
|
MacAddr retvals[2];
|
||||||
if (arg.udp_dstip != 0) {
|
if (arg.udp_dstip != 0) {
|
||||||
sls::MacAddr r = setUdpIp(sls::IpAddr(arg.udp_dstip));
|
MacAddr r = setUdpIp(IpAddr(arg.udp_dstip));
|
||||||
sls::MacAddr detMac{arg.udp_dstmac};
|
MacAddr detMac{arg.udp_dstmac};
|
||||||
if (detMac != r) {
|
if (detMac != r) {
|
||||||
retvals[0] = r;
|
retvals[0] = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (arg.udp_dstip2 != 0) {
|
if (arg.udp_dstip2 != 0) {
|
||||||
sls::MacAddr r = setUdpIp2(sls::IpAddr(arg.udp_dstip2));
|
MacAddr r = setUdpIp2(IpAddr(arg.udp_dstip2));
|
||||||
sls::MacAddr detMac{arg.udp_dstmac2};
|
MacAddr detMac{arg.udp_dstmac2};
|
||||||
if (detMac != r) {
|
if (detMac != r) {
|
||||||
retvals[1] = r;
|
retvals[1] = r;
|
||||||
}
|
}
|
||||||
@ -499,7 +501,7 @@ void ClientInterface::setDetectorType(detectorType arg) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
detType = GENERIC;
|
detType = GENERIC;
|
||||||
receiver = sls::make_unique<Implementation>(arg);
|
receiver = make_unique<Implementation>(arg);
|
||||||
detType = arg;
|
detType = arg;
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
@ -527,7 +529,7 @@ void ClientInterface::setDetectorType(detectorType arg) {
|
|||||||
|
|
||||||
int ClientInterface::set_detector_roi(Interface &socket) {
|
int ClientInterface::set_detector_roi(Interface &socket) {
|
||||||
auto arg = socket.Receive<ROI>();
|
auto arg = socket.Receive<ROI>();
|
||||||
LOG(logDEBUG1) << "Set Detector ROI: " << sls::ToString(arg);
|
LOG(logDEBUG1) << "Set Detector ROI: " << ToString(arg);
|
||||||
|
|
||||||
if (detType != GOTTHARD)
|
if (detType != GOTTHARD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
@ -644,7 +646,7 @@ int ClientInterface::set_exptime(Interface &socket) {
|
|||||||
socket.Receive(args);
|
socket.Receive(args);
|
||||||
int gateIndex = static_cast<int>(args[0]);
|
int gateIndex = static_cast<int>(args[0]);
|
||||||
ns value = std::chrono::nanoseconds(args[1]);
|
ns value = std::chrono::nanoseconds(args[1]);
|
||||||
LOG(logDEBUG1) << "Setting exptime to " << sls::ToString(value)
|
LOG(logDEBUG1) << "Setting exptime to " << ToString(value)
|
||||||
<< " (gateIndex: " << gateIndex << ")";
|
<< " (gateIndex: " << gateIndex << ")";
|
||||||
switch (gateIndex) {
|
switch (gateIndex) {
|
||||||
case -1:
|
case -1:
|
||||||
@ -683,14 +685,14 @@ int ClientInterface::set_exptime(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::set_period(Interface &socket) {
|
int ClientInterface::set_period(Interface &socket) {
|
||||||
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
|
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
|
||||||
LOG(logDEBUG1) << "Setting period to " << sls::ToString(value);
|
LOG(logDEBUG1) << "Setting period to " << ToString(value);
|
||||||
impl()->setAcquisitionPeriod(value);
|
impl()->setAcquisitionPeriod(value);
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_subexptime(Interface &socket) {
|
int ClientInterface::set_subexptime(Interface &socket) {
|
||||||
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
|
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
|
||||||
LOG(logDEBUG1) << "Setting period to " << sls::ToString(value);
|
LOG(logDEBUG1) << "Setting period to " << ToString(value);
|
||||||
ns subdeadtime = impl()->getSubPeriod() - impl()->getSubExpTime();
|
ns subdeadtime = impl()->getSubPeriod() - impl()->getSubExpTime();
|
||||||
impl()->setSubExpTime(value);
|
impl()->setSubExpTime(value);
|
||||||
impl()->setSubPeriod(impl()->getSubExpTime() + subdeadtime);
|
impl()->setSubPeriod(impl()->getSubExpTime() + subdeadtime);
|
||||||
@ -699,10 +701,10 @@ int ClientInterface::set_subexptime(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::set_subdeadtime(Interface &socket) {
|
int ClientInterface::set_subdeadtime(Interface &socket) {
|
||||||
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
|
auto value = std::chrono::nanoseconds(socket.Receive<int64_t>());
|
||||||
LOG(logDEBUG1) << "Setting sub deadtime to " << sls::ToString(value);
|
LOG(logDEBUG1) << "Setting sub deadtime to " << ToString(value);
|
||||||
impl()->setSubPeriod(value + impl()->getSubExpTime());
|
impl()->setSubPeriod(value + impl()->getSubExpTime());
|
||||||
LOG(logDEBUG1) << "Setting sub period to "
|
LOG(logDEBUG1) << "Setting sub period to "
|
||||||
<< sls::ToString(impl()->getSubPeriod());
|
<< ToString(impl()->getSubPeriod());
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,7 +775,7 @@ int ClientInterface::get_streaming_frequency(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::get_status(Interface &socket) {
|
int ClientInterface::get_status(Interface &socket) {
|
||||||
auto retval = impl()->getStatus();
|
auto retval = impl()->getStatus();
|
||||||
LOG(logDEBUG1) << "Status:" << sls::ToString(retval);
|
LOG(logDEBUG1) << "Status:" << ToString(retval);
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,7 +797,7 @@ int ClientInterface::stop_receiver(Interface &socket) {
|
|||||||
auto s = impl()->getStatus();
|
auto s = impl()->getStatus();
|
||||||
if (s != IDLE)
|
if (s != IDLE)
|
||||||
throw RuntimeError("Could not stop receiver. It as it is: " +
|
throw RuntimeError("Could not stop receiver. It as it is: " +
|
||||||
sls::ToString(s));
|
ToString(s));
|
||||||
|
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
@ -856,7 +858,7 @@ int ClientInterface::get_file_index(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::get_frame_index(Interface &socket) {
|
int ClientInterface::get_frame_index(Interface &socket) {
|
||||||
auto retval = impl()->getCurrentFrameIndex();
|
auto retval = impl()->getCurrentFrameIndex();
|
||||||
LOG(logDEBUG1) << "frames index:" << sls::ToString(retval);
|
LOG(logDEBUG1) << "frames index:" << ToString(retval);
|
||||||
auto size = static_cast<int>(retval.size());
|
auto size = static_cast<int>(retval.size());
|
||||||
socket.Send(OK);
|
socket.Send(OK);
|
||||||
socket.Send(size);
|
socket.Send(size);
|
||||||
@ -866,7 +868,7 @@ int ClientInterface::get_frame_index(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::get_missing_packets(Interface &socket) {
|
int ClientInterface::get_missing_packets(Interface &socket) {
|
||||||
auto missing_packets = impl()->getNumMissingPackets();
|
auto missing_packets = impl()->getNumMissingPackets();
|
||||||
LOG(logDEBUG1) << "missing packets:" << sls::ToString(missing_packets);
|
LOG(logDEBUG1) << "missing packets:" << ToString(missing_packets);
|
||||||
auto size = static_cast<int>(missing_packets.size());
|
auto size = static_cast<int>(missing_packets.size());
|
||||||
socket.Send(OK);
|
socket.Send(OK);
|
||||||
socket.Send(size);
|
socket.Send(size);
|
||||||
@ -876,7 +878,7 @@ int ClientInterface::get_missing_packets(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::get_frames_caught(Interface &socket) {
|
int ClientInterface::get_frames_caught(Interface &socket) {
|
||||||
auto retval = impl()->getFramesCaught();
|
auto retval = impl()->getFramesCaught();
|
||||||
LOG(logDEBUG1) << "frames caught:" << sls::ToString(retval);
|
LOG(logDEBUG1) << "frames caught:" << ToString(retval);
|
||||||
auto size = static_cast<int>(retval.size());
|
auto size = static_cast<int>(retval.size());
|
||||||
socket.Send(OK);
|
socket.Send(OK);
|
||||||
socket.Send(size);
|
socket.Send(size);
|
||||||
@ -1094,7 +1096,7 @@ int ClientInterface::get_streaming_port(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_streaming_source_ip(Interface &socket) {
|
int ClientInterface::set_streaming_source_ip(Interface &socket) {
|
||||||
auto ip = socket.Receive<sls::IpAddr>();
|
auto ip = socket.Receive<IpAddr>();
|
||||||
if (ip == 0)
|
if (ip == 0)
|
||||||
throw RuntimeError("Invalid zmq ip " + ip.str());
|
throw RuntimeError("Invalid zmq ip " + ip.str());
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
@ -1103,7 +1105,7 @@ int ClientInterface::set_streaming_source_ip(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::get_streaming_source_ip(Interface &socket) {
|
int ClientInterface::get_streaming_source_ip(Interface &socket) {
|
||||||
sls::IpAddr retval = impl()->getStreamingSourceIP();
|
IpAddr retval = impl()->getStreamingSourceIP();
|
||||||
LOG(logDEBUG1) << "streaming IP:" << retval;
|
LOG(logDEBUG1) << "streaming IP:" << retval;
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
@ -1151,14 +1153,14 @@ int ClientInterface::set_additional_json_header(Interface &socket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// verifyIdle(socket); allowing it to be set on the fly
|
// verifyIdle(socket); allowing it to be set on the fly
|
||||||
LOG(logDEBUG1) << "Setting additional json header: " << sls::ToString(json);
|
LOG(logDEBUG1) << "Setting additional json header: " << ToString(json);
|
||||||
impl()->setAdditionalJsonHeader(json);
|
impl()->setAdditionalJsonHeader(json);
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::get_additional_json_header(Interface &socket) {
|
int ClientInterface::get_additional_json_header(Interface &socket) {
|
||||||
std::map<std::string, std::string> json = impl()->getAdditionalJsonHeader();
|
std::map<std::string, std::string> json = impl()->getAdditionalJsonHeader();
|
||||||
LOG(logDEBUG1) << "additional json header:" << sls::ToString(json);
|
LOG(logDEBUG1) << "additional json header:" << ToString(json);
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
for (auto &it : json) {
|
for (auto &it : json) {
|
||||||
oss << it.first << ' ' << it.second << ' ';
|
oss << it.first << ' ' << it.second << ' ';
|
||||||
@ -1323,7 +1325,7 @@ int ClientInterface::set_adc_mask(Interface &socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_dbit_list(Interface &socket) {
|
int ClientInterface::set_dbit_list(Interface &socket) {
|
||||||
sls::StaticVector<int, MAX_RX_DBIT> args;
|
StaticVector<int, MAX_RX_DBIT> args;
|
||||||
socket.Receive(args);
|
socket.Receive(args);
|
||||||
if (detType != CHIPTESTBOARD)
|
if (detType != CHIPTESTBOARD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
@ -1340,7 +1342,7 @@ int ClientInterface::set_dbit_list(Interface &socket) {
|
|||||||
int ClientInterface::get_dbit_list(Interface &socket) {
|
int ClientInterface::get_dbit_list(Interface &socket) {
|
||||||
if (detType != CHIPTESTBOARD)
|
if (detType != CHIPTESTBOARD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
sls::StaticVector<int, MAX_RX_DBIT> retval;
|
StaticVector<int, MAX_RX_DBIT> retval;
|
||||||
retval = impl()->getDbitList();
|
retval = impl()->getDbitList();
|
||||||
LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
|
LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
@ -1403,10 +1405,10 @@ int ClientInterface::set_read_n_rows(Interface &socket) {
|
|||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) {
|
MacAddr ClientInterface::setUdpIp(IpAddr arg) {
|
||||||
LOG(logINFO) << "Received UDP IP: " << arg;
|
LOG(logINFO) << "Received UDP IP: " << arg;
|
||||||
// getting eth
|
// getting eth
|
||||||
std::string eth = sls::IpToInterfaceName(arg.str());
|
std::string eth = IpToInterfaceName(arg.str());
|
||||||
if (eth == "none") {
|
if (eth == "none") {
|
||||||
throw RuntimeError("Failed to get udp ethernet interface from IP " +
|
throw RuntimeError("Failed to get udp ethernet interface from IP " +
|
||||||
arg.str());
|
arg.str());
|
||||||
@ -1425,7 +1427,7 @@ sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) {
|
|||||||
udpips[0] = arg.str();
|
udpips[0] = arg.str();
|
||||||
|
|
||||||
// get mac address
|
// get mac address
|
||||||
auto retval = sls::InterfaceNameToMac(eth);
|
auto retval = InterfaceNameToMac(eth);
|
||||||
if (retval == 0 && arg.str() != LOCALHOST_IP) {
|
if (retval == 0 && arg.str() != LOCALHOST_IP) {
|
||||||
throw RuntimeError("Failed to get udp mac adddress to listen to (eth:" +
|
throw RuntimeError("Failed to get udp mac adddress to listen to (eth:" +
|
||||||
eth + ", ip:" + arg.str() + ")\n");
|
eth + ", ip:" + arg.str() + ")\n");
|
||||||
@ -1435,16 +1437,16 @@ sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_udp_ip(Interface &socket) {
|
int ClientInterface::set_udp_ip(Interface &socket) {
|
||||||
auto arg = socket.Receive<sls::IpAddr>();
|
auto arg = socket.Receive<IpAddr>();
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
auto retval = setUdpIp(arg);
|
auto retval = setUdpIp(arg);
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) {
|
MacAddr ClientInterface::setUdpIp2(IpAddr arg) {
|
||||||
LOG(logINFO) << "Received UDP IP2: " << arg;
|
LOG(logINFO) << "Received UDP IP2: " << arg;
|
||||||
// getting eth
|
// getting eth
|
||||||
std::string eth = sls::IpToInterfaceName(arg.str());
|
std::string eth = IpToInterfaceName(arg.str());
|
||||||
if (eth == "none") {
|
if (eth == "none") {
|
||||||
throw RuntimeError("Failed to get udp ethernet interface2 from IP " +
|
throw RuntimeError("Failed to get udp ethernet interface2 from IP " +
|
||||||
arg.str());
|
arg.str());
|
||||||
@ -1460,7 +1462,7 @@ sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) {
|
|||||||
udpips[1] = arg.str();
|
udpips[1] = arg.str();
|
||||||
|
|
||||||
// get mac address
|
// get mac address
|
||||||
auto retval = sls::InterfaceNameToMac(eth);
|
auto retval = InterfaceNameToMac(eth);
|
||||||
if (retval == 0 && arg.str() != LOCALHOST_IP) {
|
if (retval == 0 && arg.str() != LOCALHOST_IP) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Failed to get udp mac adddress2 to listen to (eth:" + eth +
|
"Failed to get udp mac adddress2 to listen to (eth:" + eth +
|
||||||
@ -1471,7 +1473,7 @@ sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ClientInterface::set_udp_ip2(Interface &socket) {
|
int ClientInterface::set_udp_ip2(Interface &socket) {
|
||||||
auto arg = socket.Receive<sls::IpAddr>();
|
auto arg = socket.Receive<IpAddr>();
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
if (detType != JUNGFRAU && detType != GOTTHARD2) {
|
if (detType != JUNGFRAU && detType != GOTTHARD2) {
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
@ -1595,7 +1597,7 @@ int ClientInterface::set_gate_delay(Interface &socket) {
|
|||||||
socket.Receive(args);
|
socket.Receive(args);
|
||||||
int gateIndex = static_cast<int>(args[0]);
|
int gateIndex = static_cast<int>(args[0]);
|
||||||
auto value = std::chrono::nanoseconds(args[1]);
|
auto value = std::chrono::nanoseconds(args[1]);
|
||||||
LOG(logDEBUG1) << "Setting gate delay to " << sls::ToString(value)
|
LOG(logDEBUG1) << "Setting gate delay to " << ToString(value)
|
||||||
<< " (gateIndex: " << gateIndex << ")";
|
<< " (gateIndex: " << gateIndex << ")";
|
||||||
if (detType != MYTHEN3) {
|
if (detType != MYTHEN3) {
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
@ -1624,7 +1626,7 @@ int ClientInterface::set_gate_delay(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::get_thread_ids(Interface &socket) {
|
int ClientInterface::get_thread_ids(Interface &socket) {
|
||||||
auto retval = impl()->getThreadIds();
|
auto retval = impl()->getThreadIds();
|
||||||
LOG(logDEBUG1) << "thread ids retval: " << sls::ToString(retval);
|
LOG(logDEBUG1) << "thread ids retval: " << ToString(retval);
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1663,7 +1665,7 @@ int ClientInterface::set_rate_correct(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::set_scan(Interface &socket) {
|
int ClientInterface::set_scan(Interface &socket) {
|
||||||
auto arg = socket.Receive<scanParameters>();
|
auto arg = socket.Receive<scanParameters>();
|
||||||
LOG(logDEBUG) << "Scan Mode: " << sls::ToString(arg);
|
LOG(logDEBUG) << "Scan Mode: " << ToString(arg);
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
impl()->setScan(arg);
|
impl()->setScan(arg);
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
@ -1698,7 +1700,7 @@ int ClientInterface::set_streaming_hwm(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::set_all_threshold(Interface &socket) {
|
int ClientInterface::set_all_threshold(Interface &socket) {
|
||||||
auto eVs = socket.Receive<std::array<int, 3>>();
|
auto eVs = socket.Receive<std::array<int, 3>>();
|
||||||
LOG(logDEBUG) << "Threshold:" << sls::ToString(eVs);
|
LOG(logDEBUG) << "Threshold:" << ToString(eVs);
|
||||||
if (detType != MYTHEN3)
|
if (detType != MYTHEN3)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
@ -1718,8 +1720,8 @@ int ClientInterface::set_detector_datastream(Interface &socket) {
|
|||||||
throw RuntimeError("Invalid port type");
|
throw RuntimeError("Invalid port type");
|
||||||
}
|
}
|
||||||
bool enable = static_cast<int>(args[1]);
|
bool enable = static_cast<int>(args[1]);
|
||||||
LOG(logDEBUG1) << "Setting datastream (" << sls::ToString(port) << ") to "
|
LOG(logDEBUG1) << "Setting datastream (" << ToString(port) << ") to "
|
||||||
<< sls::ToString(enable);
|
<< ToString(enable);
|
||||||
if (detType != EIGER)
|
if (detType != EIGER)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
@ -1746,7 +1748,7 @@ int ClientInterface::set_arping(Interface &socket) {
|
|||||||
|
|
||||||
int ClientInterface::get_receiver_roi(Interface &socket) {
|
int ClientInterface::get_receiver_roi(Interface &socket) {
|
||||||
auto retval = impl()->getReceiverROI();
|
auto retval = impl()->getReceiverROI();
|
||||||
LOG(logDEBUG1) << "Receiver roi retval:" << sls::ToString(retval);
|
LOG(logDEBUG1) << "Receiver roi retval:" << ToString(retval);
|
||||||
return socket.sendResult(retval);
|
return socket.sendResult(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1754,7 +1756,7 @@ int ClientInterface::set_receiver_roi(Interface &socket) {
|
|||||||
auto arg = socket.Receive<ROI>();
|
auto arg = socket.Receive<ROI>();
|
||||||
if (detType == CHIPTESTBOARD || detType == MOENCH)
|
if (detType == CHIPTESTBOARD || detType == MOENCH)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
LOG(logDEBUG1) << "Set Receiver ROI: " << sls::ToString(arg);
|
LOG(logDEBUG1) << "Set Receiver ROI: " << ToString(arg);
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
try {
|
try {
|
||||||
impl()->setReceiverROI(arg);
|
impl()->setReceiverROI(arg);
|
||||||
@ -1768,7 +1770,7 @@ int ClientInterface::set_receiver_roi_metadata(Interface &socket) {
|
|||||||
auto arg = socket.Receive<ROI>();
|
auto arg = socket.Receive<ROI>();
|
||||||
if (detType == CHIPTESTBOARD || detType == MOENCH)
|
if (detType == CHIPTESTBOARD || detType == MOENCH)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
LOG(logDEBUG1) << "Set Receiver ROI Metadata: " << sls::ToString(arg);
|
LOG(logDEBUG1) << "Set Receiver ROI Metadata: " << ToString(arg);
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
try {
|
try {
|
||||||
impl()->setReceiverROIMetadata(arg);
|
impl()->setReceiverROIMetadata(arg);
|
||||||
@ -1777,3 +1779,5 @@ int ClientInterface::set_receiver_roi_metadata(Interface &socket) {
|
|||||||
}
|
}
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,16 +6,19 @@
|
|||||||
#include "sls/ServerSocket.h"
|
#include "sls/ServerSocket.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
#include "sls/sls_detector_funcs.h"
|
#include "sls/sls_detector_funcs.h"
|
||||||
class ServerInterface;
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <future>
|
#include <future>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
class ServerInterface;
|
||||||
|
|
||||||
class ClientInterface : private virtual slsDetectorDefs {
|
class ClientInterface : private virtual slsDetectorDefs {
|
||||||
enum numberMode { DEC, HEX };
|
enum numberMode { DEC, HEX };
|
||||||
detectorType detType;
|
detectorType detType;
|
||||||
int portNumber{0};
|
int portNumber{0};
|
||||||
sls::ServerSocket server;
|
ServerSocket server;
|
||||||
std::unique_ptr<Implementation> receiver;
|
std::unique_ptr<Implementation> receiver;
|
||||||
std::unique_ptr<std::thread> tcpThread;
|
std::unique_ptr<std::thread> tcpThread;
|
||||||
int ret{OK};
|
int ret{OK};
|
||||||
@ -53,132 +56,132 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
private:
|
private:
|
||||||
void startTCPServer();
|
void startTCPServer();
|
||||||
int functionTable();
|
int functionTable();
|
||||||
int decodeFunction(sls::ServerInterface &socket);
|
int decodeFunction(ServerInterface &socket);
|
||||||
void functionNotImplemented();
|
void functionNotImplemented();
|
||||||
void modeNotImplemented(const std::string &modename, int mode);
|
void modeNotImplemented(const std::string &modename, int mode);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void validate(T arg, T retval, const std::string &modename, numberMode hex);
|
void validate(T arg, T retval, const std::string &modename, numberMode hex);
|
||||||
void verifyLock();
|
void verifyLock();
|
||||||
void verifyIdle(sls::ServerInterface &socket);
|
void verifyIdle(ServerInterface &socket);
|
||||||
|
|
||||||
int lock_receiver(sls::ServerInterface &socket);
|
int lock_receiver(ServerInterface &socket);
|
||||||
int get_last_client_ip(sls::ServerInterface &socket);
|
int get_last_client_ip(ServerInterface &socket);
|
||||||
int get_version(sls::ServerInterface &socket);
|
int get_version(ServerInterface &socket);
|
||||||
int setup_receiver(sls::ServerInterface &socket);
|
int setup_receiver(ServerInterface &socket);
|
||||||
void setDetectorType(detectorType arg);
|
void setDetectorType(detectorType arg);
|
||||||
int set_detector_roi(sls::ServerInterface &socket);
|
int set_detector_roi(ServerInterface &socket);
|
||||||
int set_num_frames(sls::ServerInterface &socket);
|
int set_num_frames(ServerInterface &socket);
|
||||||
int set_num_triggers(sls::ServerInterface &socket);
|
int set_num_triggers(ServerInterface &socket);
|
||||||
int set_num_bursts(sls::ServerInterface &socket);
|
int set_num_bursts(ServerInterface &socket);
|
||||||
int set_num_add_storage_cells(sls::ServerInterface &socket);
|
int set_num_add_storage_cells(ServerInterface &socket);
|
||||||
int set_timing_mode(sls::ServerInterface &socket);
|
int set_timing_mode(ServerInterface &socket);
|
||||||
int set_burst_mode(sls::ServerInterface &socket);
|
int set_burst_mode(ServerInterface &socket);
|
||||||
int set_num_analog_samples(sls::ServerInterface &socket);
|
int set_num_analog_samples(ServerInterface &socket);
|
||||||
int set_num_digital_samples(sls::ServerInterface &socket);
|
int set_num_digital_samples(ServerInterface &socket);
|
||||||
int set_exptime(sls::ServerInterface &socket);
|
int set_exptime(ServerInterface &socket);
|
||||||
int set_period(sls::ServerInterface &socket);
|
int set_period(ServerInterface &socket);
|
||||||
int set_subexptime(sls::ServerInterface &socket);
|
int set_subexptime(ServerInterface &socket);
|
||||||
int set_subdeadtime(sls::ServerInterface &socket);
|
int set_subdeadtime(ServerInterface &socket);
|
||||||
int set_dynamic_range(sls::ServerInterface &socket);
|
int set_dynamic_range(ServerInterface &socket);
|
||||||
int set_streaming_frequency(sls::ServerInterface &socket);
|
int set_streaming_frequency(ServerInterface &socket);
|
||||||
int get_streaming_frequency(sls::ServerInterface &socket);
|
int get_streaming_frequency(ServerInterface &socket);
|
||||||
int get_status(sls::ServerInterface &socket);
|
int get_status(ServerInterface &socket);
|
||||||
int start_receiver(sls::ServerInterface &socket);
|
int start_receiver(ServerInterface &socket);
|
||||||
int stop_receiver(sls::ServerInterface &socket);
|
int stop_receiver(ServerInterface &socket);
|
||||||
int set_file_dir(sls::ServerInterface &socket);
|
int set_file_dir(ServerInterface &socket);
|
||||||
int get_file_dir(sls::ServerInterface &socket);
|
int get_file_dir(ServerInterface &socket);
|
||||||
int set_file_name(sls::ServerInterface &socket);
|
int set_file_name(ServerInterface &socket);
|
||||||
int get_file_name(sls::ServerInterface &socket);
|
int get_file_name(ServerInterface &socket);
|
||||||
int set_file_index(sls::ServerInterface &socket);
|
int set_file_index(ServerInterface &socket);
|
||||||
int get_file_index(sls::ServerInterface &socket);
|
int get_file_index(ServerInterface &socket);
|
||||||
int get_frame_index(sls::ServerInterface &socket);
|
int get_frame_index(ServerInterface &socket);
|
||||||
int get_missing_packets(sls::ServerInterface &socket);
|
int get_missing_packets(ServerInterface &socket);
|
||||||
int get_frames_caught(sls::ServerInterface &socket);
|
int get_frames_caught(ServerInterface &socket);
|
||||||
int set_file_write(sls::ServerInterface &socket);
|
int set_file_write(ServerInterface &socket);
|
||||||
int get_file_write(sls::ServerInterface &socket);
|
int get_file_write(ServerInterface &socket);
|
||||||
int set_master_file_write(sls::ServerInterface &socket);
|
int set_master_file_write(ServerInterface &socket);
|
||||||
int get_master_file_write(sls::ServerInterface &socket);
|
int get_master_file_write(ServerInterface &socket);
|
||||||
int enable_compression(sls::ServerInterface &socket);
|
int enable_compression(ServerInterface &socket);
|
||||||
int set_overwrite(sls::ServerInterface &socket);
|
int set_overwrite(ServerInterface &socket);
|
||||||
int get_overwrite(sls::ServerInterface &socket);
|
int get_overwrite(ServerInterface &socket);
|
||||||
int enable_tengiga(sls::ServerInterface &socket);
|
int enable_tengiga(ServerInterface &socket);
|
||||||
int set_fifo_depth(sls::ServerInterface &socket);
|
int set_fifo_depth(ServerInterface &socket);
|
||||||
int set_activate(sls::ServerInterface &socket);
|
int set_activate(ServerInterface &socket);
|
||||||
int set_streaming(sls::ServerInterface &socket);
|
int set_streaming(ServerInterface &socket);
|
||||||
int get_streaming(sls::ServerInterface &socket);
|
int get_streaming(ServerInterface &socket);
|
||||||
int set_streaming_timer(sls::ServerInterface &socket);
|
int set_streaming_timer(ServerInterface &socket);
|
||||||
int get_flip_rows(sls::ServerInterface &socket);
|
int get_flip_rows(ServerInterface &socket);
|
||||||
int set_flip_rows(sls::ServerInterface &socket);
|
int set_flip_rows(ServerInterface &socket);
|
||||||
int set_file_format(sls::ServerInterface &socket);
|
int set_file_format(ServerInterface &socket);
|
||||||
int get_file_format(sls::ServerInterface &socket);
|
int get_file_format(ServerInterface &socket);
|
||||||
int set_streaming_port(sls::ServerInterface &socket);
|
int set_streaming_port(ServerInterface &socket);
|
||||||
int get_streaming_port(sls::ServerInterface &socket);
|
int get_streaming_port(ServerInterface &socket);
|
||||||
int set_streaming_source_ip(sls::ServerInterface &socket);
|
int set_streaming_source_ip(ServerInterface &socket);
|
||||||
int get_streaming_source_ip(sls::ServerInterface &socket);
|
int get_streaming_source_ip(ServerInterface &socket);
|
||||||
int set_silent_mode(sls::ServerInterface &socket);
|
int set_silent_mode(ServerInterface &socket);
|
||||||
int get_silent_mode(sls::ServerInterface &socket);
|
int get_silent_mode(ServerInterface &socket);
|
||||||
int restream_stop(sls::ServerInterface &socket);
|
int restream_stop(ServerInterface &socket);
|
||||||
int set_additional_json_header(sls::ServerInterface &socket);
|
int set_additional_json_header(ServerInterface &socket);
|
||||||
int get_additional_json_header(sls::ServerInterface &socket);
|
int get_additional_json_header(ServerInterface &socket);
|
||||||
int set_udp_socket_buffer_size(sls::ServerInterface &socket);
|
int set_udp_socket_buffer_size(ServerInterface &socket);
|
||||||
int get_real_udp_socket_buffer_size(sls::ServerInterface &socket);
|
int get_real_udp_socket_buffer_size(ServerInterface &socket);
|
||||||
int set_frames_per_file(sls::ServerInterface &socket);
|
int set_frames_per_file(ServerInterface &socket);
|
||||||
int get_frames_per_file(sls::ServerInterface &socket);
|
int get_frames_per_file(ServerInterface &socket);
|
||||||
int check_version_compatibility(sls::ServerInterface &socket);
|
int check_version_compatibility(ServerInterface &socket);
|
||||||
int set_discard_policy(sls::ServerInterface &socket);
|
int set_discard_policy(ServerInterface &socket);
|
||||||
int get_discard_policy(sls::ServerInterface &socket);
|
int get_discard_policy(ServerInterface &socket);
|
||||||
int set_padding_enable(sls::ServerInterface &socket);
|
int set_padding_enable(ServerInterface &socket);
|
||||||
int get_padding_enable(sls::ServerInterface &socket);
|
int get_padding_enable(ServerInterface &socket);
|
||||||
int set_readout_mode(sls::ServerInterface &socket);
|
int set_readout_mode(ServerInterface &socket);
|
||||||
int set_adc_mask(sls::ServerInterface &socket);
|
int set_adc_mask(ServerInterface &socket);
|
||||||
int set_dbit_list(sls::ServerInterface &socket);
|
int set_dbit_list(ServerInterface &socket);
|
||||||
int get_dbit_list(sls::ServerInterface &socket);
|
int get_dbit_list(ServerInterface &socket);
|
||||||
int set_dbit_offset(sls::ServerInterface &socket);
|
int set_dbit_offset(ServerInterface &socket);
|
||||||
int get_dbit_offset(sls::ServerInterface &socket);
|
int get_dbit_offset(ServerInterface &socket);
|
||||||
int set_quad_type(sls::ServerInterface &socket);
|
int set_quad_type(ServerInterface &socket);
|
||||||
int set_read_n_rows(sls::ServerInterface &socket);
|
int set_read_n_rows(ServerInterface &socket);
|
||||||
sls::MacAddr setUdpIp(sls::IpAddr arg);
|
MacAddr setUdpIp(IpAddr arg);
|
||||||
int set_udp_ip(sls::ServerInterface &socket);
|
int set_udp_ip(ServerInterface &socket);
|
||||||
sls::MacAddr setUdpIp2(sls::IpAddr arg);
|
MacAddr setUdpIp2(IpAddr arg);
|
||||||
int set_udp_ip2(sls::ServerInterface &socket);
|
int set_udp_ip2(ServerInterface &socket);
|
||||||
int set_udp_port(sls::ServerInterface &socket);
|
int set_udp_port(ServerInterface &socket);
|
||||||
int set_udp_port2(sls::ServerInterface &socket);
|
int set_udp_port2(ServerInterface &socket);
|
||||||
int set_num_interfaces(sls::ServerInterface &socket);
|
int set_num_interfaces(ServerInterface &socket);
|
||||||
int set_adc_mask_10g(sls::ServerInterface &socket);
|
int set_adc_mask_10g(ServerInterface &socket);
|
||||||
int set_counter_mask(sls::ServerInterface &socket);
|
int set_counter_mask(ServerInterface &socket);
|
||||||
int increment_file_index(sls::ServerInterface &socket);
|
int increment_file_index(ServerInterface &socket);
|
||||||
int set_additional_json_parameter(sls::ServerInterface &socket);
|
int set_additional_json_parameter(ServerInterface &socket);
|
||||||
int get_additional_json_parameter(sls::ServerInterface &socket);
|
int get_additional_json_parameter(ServerInterface &socket);
|
||||||
int get_progress(sls::ServerInterface &socket);
|
int get_progress(ServerInterface &socket);
|
||||||
int set_num_gates(sls::ServerInterface &socket);
|
int set_num_gates(ServerInterface &socket);
|
||||||
int set_gate_delay(sls::ServerInterface &socket);
|
int set_gate_delay(ServerInterface &socket);
|
||||||
int get_thread_ids(sls::ServerInterface &socket);
|
int get_thread_ids(ServerInterface &socket);
|
||||||
int get_streaming_start_fnum(sls::ServerInterface &socket);
|
int get_streaming_start_fnum(ServerInterface &socket);
|
||||||
int set_streaming_start_fnum(sls::ServerInterface &socket);
|
int set_streaming_start_fnum(ServerInterface &socket);
|
||||||
int set_rate_correct(sls::ServerInterface &socket);
|
int set_rate_correct(ServerInterface &socket);
|
||||||
int set_scan(sls::ServerInterface &socket);
|
int set_scan(ServerInterface &socket);
|
||||||
int set_threshold(sls::ServerInterface &socket);
|
int set_threshold(ServerInterface &socket);
|
||||||
int get_streaming_hwm(sls::ServerInterface &socket);
|
int get_streaming_hwm(ServerInterface &socket);
|
||||||
int set_streaming_hwm(sls::ServerInterface &socket);
|
int set_streaming_hwm(ServerInterface &socket);
|
||||||
int set_all_threshold(sls::ServerInterface &socket);
|
int set_all_threshold(ServerInterface &socket);
|
||||||
int set_detector_datastream(sls::ServerInterface &socket);
|
int set_detector_datastream(ServerInterface &socket);
|
||||||
int get_arping(sls::ServerInterface &socket);
|
int get_arping(ServerInterface &socket);
|
||||||
int set_arping(sls::ServerInterface &socket);
|
int set_arping(ServerInterface &socket);
|
||||||
int get_receiver_roi(sls::ServerInterface &socket);
|
int get_receiver_roi(ServerInterface &socket);
|
||||||
int set_receiver_roi(sls::ServerInterface &socket);
|
int set_receiver_roi(ServerInterface &socket);
|
||||||
int set_receiver_roi_metadata(sls::ServerInterface &socket);
|
int set_receiver_roi_metadata(ServerInterface &socket);
|
||||||
|
|
||||||
Implementation *impl() {
|
Implementation *impl() {
|
||||||
if (receiver != nullptr) {
|
if (receiver != nullptr) {
|
||||||
return receiver.get();
|
return receiver.get();
|
||||||
} else {
|
} else {
|
||||||
throw sls::SocketError(
|
throw SocketError(
|
||||||
"Receiver not set up. Please use rx_hostname first.\n");
|
"Receiver not set up. Please use rx_hostname first.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int (ClientInterface::*flist[NUM_REC_FUNCTIONS])(
|
int (ClientInterface::*flist[NUM_REC_FUNCTIONS])(
|
||||||
sls::ServerInterface &socket);
|
ServerInterface &socket);
|
||||||
|
|
||||||
//***callback parameters***
|
//***callback parameters***
|
||||||
|
|
||||||
@ -198,3 +201,5 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
std::vector<std::string> udpips =
|
std::vector<std::string> udpips =
|
||||||
std::vector<std::string>(MAX_NUMBER_OF_LISTENING_THREADS);
|
std::vector<std::string>(MAX_NUMBER_OF_LISTENING_THREADS);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
const std::string DataProcessor::typeName_ = "DataProcessor";
|
const std::string DataProcessor::typeName_ = "DataProcessor";
|
||||||
|
|
||||||
DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
|
DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
|
||||||
@ -65,7 +67,7 @@ void DataProcessor::ResetParametersforNewAcquisition() {
|
|||||||
currentFrameIndex_ = 0;
|
currentFrameIndex_ = 0;
|
||||||
firstStreamerFrame_ = true;
|
firstStreamerFrame_ = true;
|
||||||
streamCurrentFrame_ = false;
|
streamCurrentFrame_ = false;
|
||||||
completeImageToStreamBeforeCropping = sls::make_unique<char[]>(generalData_->imageSize);
|
completeImageToStreamBeforeCropping = make_unique<char[]>(generalData_->imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
||||||
@ -105,7 +107,7 @@ void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
|||||||
dataFile_ = new BinaryDataFile(index);
|
dataFile_ = new BinaryDataFile(index);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Unknown file format (compile with hdf5 flags");
|
"Unknown file format (compile with hdf5 flags");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +121,7 @@ void DataProcessor::CreateFirstFiles(
|
|||||||
const uint64_t numImages, const uint32_t dynamicRange,
|
const uint64_t numImages, const uint32_t dynamicRange,
|
||||||
const bool detectorDataStream) {
|
const bool detectorDataStream) {
|
||||||
if (dataFile_ == nullptr) {
|
if (dataFile_ == nullptr) {
|
||||||
throw sls::RuntimeError("file object not contstructed");
|
throw RuntimeError("file object not contstructed");
|
||||||
}
|
}
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
|
|
||||||
@ -154,14 +156,14 @@ void DataProcessor::CreateFirstFiles(
|
|||||||
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile);
|
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError("Unknown file format (compile with hdf5 flags");
|
throw RuntimeError("Unknown file format (compile with hdf5 flags");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
uint32_t DataProcessor::GetFilesInAcquisition() const {
|
uint32_t DataProcessor::GetFilesInAcquisition() const {
|
||||||
if (dataFile_ == nullptr) {
|
if (dataFile_ == nullptr) {
|
||||||
throw sls::RuntimeError("No data file object created to get number of "
|
throw RuntimeError("No data file object created to get number of "
|
||||||
"files in acquiistion");
|
"files in acquiistion");
|
||||||
}
|
}
|
||||||
return dataFile_->GetFilesInAcquisition();
|
return dataFile_->GetFilesInAcquisition();
|
||||||
@ -243,7 +245,7 @@ std::string DataProcessor::CreateMasterFile(
|
|||||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
attr);
|
attr);
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError("Unknown file format (compile with hdf5 flags");
|
throw RuntimeError("Unknown file format (compile with hdf5 flags");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +375,7 @@ void DataProcessor::ProcessAnImage(char *buf) {
|
|||||||
(*((uint32_t *)buf)) = revsize;
|
(*((uint32_t *)buf)) = revsize;
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
throw sls::RuntimeError("Get Data Callback Error: " +
|
throw RuntimeError("Get Data Callback Error: " +
|
||||||
std::string(e.what()));
|
std::string(e.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +388,7 @@ void DataProcessor::ProcessAnImage(char *buf) {
|
|||||||
(uint32_t)(*((uint32_t *)buf)), //+ size of data (resizable
|
(uint32_t)(*((uint32_t *)buf)), //+ size of data (resizable
|
||||||
// from previous call back
|
// from previous call back
|
||||||
fnum - firstIndex_, nump);
|
fnum - firstIndex_, nump);
|
||||||
} catch (const sls::RuntimeError &e) {
|
} catch (const RuntimeError &e) {
|
||||||
; // ignore write exception for now (TODO: send error message
|
; // ignore write exception for now (TODO: send error message
|
||||||
// via stopReceiver tcp)
|
// via stopReceiver tcp)
|
||||||
}
|
}
|
||||||
@ -559,7 +561,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::CropImage(char *buf) {
|
void DataProcessor::CropImage(char *buf) {
|
||||||
LOG(logDEBUG) << "Cropping Image to ROI " << sls::ToString(receiverRoi_);
|
LOG(logDEBUG) << "Cropping Image to ROI " << ToString(receiverRoi_);
|
||||||
int nPixelsX = generalData_->nPixelsX;
|
int nPixelsX = generalData_->nPixelsX;
|
||||||
int xmin = receiverRoi_.xmin;
|
int xmin = receiverRoi_.xmin;
|
||||||
int xmax = receiverRoi_.xmax;
|
int xmax = receiverRoi_.xmax;
|
||||||
@ -598,3 +600,5 @@ void DataProcessor::CropImage(char *buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -14,16 +14,18 @@
|
|||||||
#include "ThreadObject.h"
|
#include "ThreadObject.h"
|
||||||
#include "receiver_defs.h"
|
#include "receiver_defs.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class GeneralData;
|
class GeneralData;
|
||||||
class Fifo;
|
class Fifo;
|
||||||
class File;
|
class File;
|
||||||
class DataStreamer;
|
class DataStreamer;
|
||||||
struct MasterAttributes;
|
struct MasterAttributes;
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <mutex>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -206,3 +208,5 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
|
|
||||||
void *pRawDataReady{nullptr};
|
void *pRawDataReady{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
const std::string DataStreamer::TypeName = "DataStreamer";
|
const std::string DataStreamer::TypeName = "DataStreamer";
|
||||||
|
|
||||||
DataStreamer::DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi,
|
DataStreamer::DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi,
|
||||||
@ -74,7 +76,7 @@ void DataStreamer::SetAdditionalJsonHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::CreateZmqSockets(int *nunits, uint32_t port,
|
void DataStreamer::CreateZmqSockets(int *nunits, uint32_t port,
|
||||||
const sls::IpAddr ip, int hwm) {
|
const IpAddr ip, int hwm) {
|
||||||
uint32_t portnum = port + index;
|
uint32_t portnum = port + index;
|
||||||
std::string sip = ip.str();
|
std::string sip = ip.str();
|
||||||
try {
|
try {
|
||||||
@ -83,7 +85,7 @@ void DataStreamer::CreateZmqSockets(int *nunits, uint32_t port,
|
|||||||
if (hwm >= 0) {
|
if (hwm >= 0) {
|
||||||
zmqSocket->SetSendHighWaterMark(hwm);
|
zmqSocket->SetSendHighWaterMark(hwm);
|
||||||
if (zmqSocket->GetSendHighWaterMark() != hwm) {
|
if (zmqSocket->GetSendHighWaterMark() != hwm) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not set zmq send high water mark to " +
|
"Could not set zmq send high water mark to " +
|
||||||
std::to_string(hwm));
|
std::to_string(hwm));
|
||||||
}
|
}
|
||||||
@ -262,8 +264,10 @@ void DataStreamer::RestreamStop() {
|
|||||||
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
||||||
int ret = zmqSocket->SendHeader(index, zHeader);
|
int ret = zmqSocket->SendHeader(index, zHeader);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not restream Dummy Header via ZMQ for port " +
|
"Could not restream Dummy Header via ZMQ for port " +
|
||||||
std::to_string(zmqSocket->GetPortNumber()));
|
std::to_string(zmqSocket->GetPortNumber()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -12,14 +12,16 @@
|
|||||||
#include "ThreadObject.h"
|
#include "ThreadObject.h"
|
||||||
#include "sls/network_utils.h"
|
#include "sls/network_utils.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class GeneralData;
|
class GeneralData;
|
||||||
class Fifo;
|
class Fifo;
|
||||||
class DataStreamer;
|
class DataStreamer;
|
||||||
class ZmqSocket;
|
class ZmqSocket;
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -62,7 +64,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param ip streaming source ip
|
* @param ip streaming source ip
|
||||||
* @param hwm streaming high water mark
|
* @param hwm streaming high water mark
|
||||||
*/
|
*/
|
||||||
void CreateZmqSockets(int *nunits, uint32_t port, const sls::IpAddr ip,
|
void CreateZmqSockets(int *nunits, uint32_t port, const IpAddr ip,
|
||||||
int hwm);
|
int hwm);
|
||||||
void CloseZmqSocket();
|
void CloseZmqSocket();
|
||||||
void RestreamStop();
|
void RestreamStop();
|
||||||
@ -131,3 +133,5 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
bool *quadEnable;
|
bool *quadEnable;
|
||||||
uint64_t *totalNumFrames;
|
uint64_t *totalNumFrames;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth)
|
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth)
|
||||||
: index(ind), memory(nullptr), fifoBound(nullptr), fifoFree(nullptr),
|
: index(ind), memory(nullptr), fifoBound(nullptr), fifoFree(nullptr),
|
||||||
fifoStream(nullptr), fifoDepth(depth), status_fifoBound(0),
|
fifoStream(nullptr), fifoDepth(depth), status_fifoBound(0),
|
||||||
@ -35,14 +37,14 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
|||||||
DestroyFifos();
|
DestroyFifos();
|
||||||
|
|
||||||
// create fifos
|
// create fifos
|
||||||
fifoBound = new sls::CircularFifo<char>(fifoDepth);
|
fifoBound = new CircularFifo<char>(fifoDepth);
|
||||||
fifoFree = new sls::CircularFifo<char>(fifoDepth);
|
fifoFree = new CircularFifo<char>(fifoDepth);
|
||||||
fifoStream = new sls::CircularFifo<char>(fifoDepth);
|
fifoStream = new CircularFifo<char>(fifoDepth);
|
||||||
// allocate memory
|
// allocate memory
|
||||||
size_t mem_len = (size_t)fifoItemSize * (size_t)fifoDepth * sizeof(char);
|
size_t mem_len = (size_t)fifoItemSize * (size_t)fifoDepth * sizeof(char);
|
||||||
memory = (char *)malloc(mem_len);
|
memory = (char *)malloc(mem_len);
|
||||||
if (memory == nullptr) {
|
if (memory == nullptr) {
|
||||||
throw sls::RuntimeError("Could not allocate memory for fifos");
|
throw RuntimeError("Could not allocate memory for fifos");
|
||||||
}
|
}
|
||||||
memset(memory, 0, mem_len);
|
memset(memory, 0, mem_len);
|
||||||
int pagesize = getpagesize();
|
int pagesize = getpagesize();
|
||||||
@ -116,3 +118,5 @@ int Fifo::GetMinLevelForFifoFree() {
|
|||||||
status_fifoFree = fifoDepth;
|
status_fifoFree = fifoDepth;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "sls/CircularFifo.h"
|
#include "sls/CircularFifo.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class Fifo : private virtual slsDetectorDefs {
|
class Fifo : private virtual slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -94,13 +96,13 @@ class Fifo : private virtual slsDetectorDefs {
|
|||||||
char *memory;
|
char *memory;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of bound data in memory */
|
/** Circular Fifo pointing to addresses of bound data in memory */
|
||||||
sls::CircularFifo<char> *fifoBound;
|
CircularFifo<char> *fifoBound;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of freed data in memory */
|
/** Circular Fifo pointing to addresses of freed data in memory */
|
||||||
sls::CircularFifo<char> *fifoFree;
|
CircularFifo<char> *fifoFree;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of to be streamed data in memory */
|
/** Circular Fifo pointing to addresses of to be streamed data in memory */
|
||||||
sls::CircularFifo<char> *fifoStream;
|
CircularFifo<char> *fifoStream;
|
||||||
|
|
||||||
/** Fifo depth set */
|
/** Fifo depth set */
|
||||||
int fifoDepth;
|
int fifoDepth;
|
||||||
@ -108,3 +110,6 @@ class Fifo : private virtual slsDetectorDefs {
|
|||||||
volatile int status_fifoBound;
|
volatile int status_fifoBound;
|
||||||
volatile int status_fifoFree;
|
volatile int status_fifoFree;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
|
||||||
|
@ -4,8 +4,12 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
File::File(const slsDetectorDefs::fileFormat format) : format_(format) {}
|
File::File(const slsDetectorDefs::fileFormat format) : format_(format) {}
|
||||||
|
|
||||||
File::~File() {}
|
File::~File() {}
|
||||||
|
|
||||||
slsDetectorDefs::fileFormat File::GetFileFormat() const { return format_; }
|
slsDetectorDefs::fileFormat File::GetFileFormat() const { return format_; }
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
struct MasterAttributes;
|
#include <array>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
#include "H5Cpp.h"
|
#include "H5Cpp.h"
|
||||||
@ -14,7 +16,7 @@ using namespace H5;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <array>
|
struct MasterAttributes;
|
||||||
|
|
||||||
class File : private virtual slsDetectorDefs {
|
class File : private virtual slsDetectorDefs {
|
||||||
|
|
||||||
@ -89,3 +91,5 @@ class File : private virtual slsDetectorDefs {
|
|||||||
protected:
|
protected:
|
||||||
slsDetectorDefs::fileFormat format_;
|
slsDetectorDefs::fileFormat format_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include <cmath> //ceil
|
#include <cmath> //ceil
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class GeneralData {
|
class GeneralData {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -71,7 +73,7 @@ class GeneralData {
|
|||||||
float GetPixelDepth() { return float(dynamicRange) / 8; }
|
float GetPixelDepth() { return float(dynamicRange) / 8; }
|
||||||
|
|
||||||
void ThrowGenericError(std::string msg) const {
|
void ThrowGenericError(std::string msg) const {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
msg + std::string("This is a generic function that should be "
|
msg + std::string("This is a generic function that should be "
|
||||||
"overloaded by a derived class"));
|
"overloaded by a derived class"));
|
||||||
}
|
}
|
||||||
@ -393,7 +395,7 @@ class Mythen3Data : public GeneralData {
|
|||||||
virtual void SetCounterMask(const int mask) {
|
virtual void SetCounterMask(const int mask) {
|
||||||
int n = __builtin_popcount(mask);
|
int n = __builtin_popcount(mask);
|
||||||
if (n < 1 || n > 3) {
|
if (n < 1 || n > 3) {
|
||||||
throw sls::RuntimeError("Invalid number of counters " +
|
throw RuntimeError("Invalid number of counters " +
|
||||||
std::to_string(n) + ". Expected 1-3.");
|
std::to_string(n) + ". Expected 1-3.");
|
||||||
}
|
}
|
||||||
counterMask = mask;
|
counterMask = mask;
|
||||||
@ -642,3 +644,5 @@ class MoenchData : public GeneralData {
|
|||||||
LOG(logDEBUG) << "Databytes: " << imageSize;
|
LOG(logDEBUG) << "Databytes: " << imageSize;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
|
HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
|
||||||
: File(HDF5), index_(index), hdf5Lib_(hdf5Lib) {
|
: File(HDF5), index_(index), hdf5Lib_(hdf5Lib) {
|
||||||
|
|
||||||
@ -218,7 +220,7 @@ void HDF5DataFile::CreateFile() {
|
|||||||
} catch (const Exception &error) {
|
} catch (const Exception &error) {
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
CloseFile();
|
CloseFile();
|
||||||
throw sls::RuntimeError("Could not create HDF5 handles in object " +
|
throw RuntimeError("Could not create HDF5 handles in object " +
|
||||||
index_);
|
index_);
|
||||||
}
|
}
|
||||||
if (!silentMode_) {
|
if (!silentMode_) {
|
||||||
@ -266,7 +268,7 @@ void HDF5DataFile::WriteDataFile(const uint64_t currentFrameNumber,
|
|||||||
if (dynamicRange_ == 12) {
|
if (dynamicRange_ == 12) {
|
||||||
revBuffer = (char *)malloc(EIGER_16_BIT_IMAGE_SIZE);
|
revBuffer = (char *)malloc(EIGER_16_BIT_IMAGE_SIZE);
|
||||||
if (revBuffer == nullptr) {
|
if (revBuffer == nullptr) {
|
||||||
throw sls::RuntimeError("Could not allocate memory for 12 bit to "
|
throw RuntimeError("Could not allocate memory for 12 bit to "
|
||||||
"16 bit conversion in object " +
|
"16 bit conversion in object " +
|
||||||
std::to_string(index_));
|
std::to_string(index_));
|
||||||
}
|
}
|
||||||
@ -300,7 +302,7 @@ void HDF5DataFile::WriteDataFile(const uint64_t currentFrameNumber,
|
|||||||
}
|
}
|
||||||
LOG(logERROR) << "Could not write to file in object " << index_;
|
LOG(logERROR) << "Could not write to file in object " << index_;
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
throw sls::RuntimeError("Could not write to file in object " +
|
throw RuntimeError("Could not write to file in object " +
|
||||||
std::to_string(index_));
|
std::to_string(index_));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +385,7 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
|
|||||||
i = 14;
|
i = 14;
|
||||||
} catch (const Exception &error) {
|
} catch (const Exception &error) {
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not write parameters (index:" + std::to_string(i) +
|
"Could not write parameters (index:" + std::to_string(i) +
|
||||||
") to file in object " + std::to_string(index_));
|
") to file in object " + std::to_string(index_));
|
||||||
}
|
}
|
||||||
@ -413,7 +415,7 @@ void HDF5DataFile::ExtendDataset() {
|
|||||||
|
|
||||||
} catch (const Exception &error) {
|
} catch (const Exception &error) {
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
throw sls::RuntimeError("Could not extend dataset in object " +
|
throw RuntimeError("Could not extend dataset in object " +
|
||||||
std::to_string(index_));
|
std::to_string(index_));
|
||||||
}
|
}
|
||||||
if (!silentMode_) {
|
if (!silentMode_) {
|
||||||
@ -422,3 +424,5 @@ void HDF5DataFile::ExtendDataset() {
|
|||||||
}
|
}
|
||||||
extNumImages_ += numImages_;
|
extNumImages_ += numImages_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -77,3 +79,5 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
|||||||
static const int EIGER_NUM_PIXELS{256 * 2 * 256};
|
static const int EIGER_NUM_PIXELS{256 * 2 * 256};
|
||||||
static const int EIGER_16_BIT_IMAGE_SIZE{EIGER_NUM_PIXELS * 2};
|
static const int EIGER_16_BIT_IMAGE_SIZE{EIGER_NUM_PIXELS * 2};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
/** cosntructor & destructor */
|
/** cosntructor & destructor */
|
||||||
|
|
||||||
Implementation::Implementation(const detectorType d) { setDetectorType(d); }
|
Implementation::Implementation(const detectorType d) { setDetectorType(d); }
|
||||||
@ -73,12 +75,12 @@ void Implementation::SetupFifoStructure() {
|
|||||||
|
|
||||||
// create fifo structure
|
// create fifo structure
|
||||||
try {
|
try {
|
||||||
fifo.push_back(sls::make_unique<Fifo>(
|
fifo.push_back(make_unique<Fifo>(
|
||||||
i, datasize + (generalData->fifoBufferHeaderSize), fifoDepth));
|
i, datasize + (generalData->fifoBufferHeaderSize), fifoDepth));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
fifoDepth = 0;
|
fifoDepth = 0;
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not allocate memory for fifo structure " +
|
"Could not allocate memory for fifo structure " +
|
||||||
std::to_string(i) + ". FifoDepth is now 0.");
|
std::to_string(i) + ". FifoDepth is now 0.");
|
||||||
}
|
}
|
||||||
@ -117,10 +119,10 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
case MOENCH:
|
case MOENCH:
|
||||||
case MYTHEN3:
|
case MYTHEN3:
|
||||||
case GOTTHARD2:
|
case GOTTHARD2:
|
||||||
LOG(logINFO) << " ***** " << sls::ToString(d) << " Receiver *****";
|
LOG(logINFO) << " ***** " << ToString(d) << " Receiver *****";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError("This is an unknown receiver type " +
|
throw RuntimeError("This is an unknown receiver type " +
|
||||||
std::to_string(static_cast<int>(d)));
|
std::to_string(static_cast<int>(d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +178,7 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
auto fifo_ptr = fifo[i].get();
|
auto fifo_ptr = fifo[i].get();
|
||||||
listener.push_back(sls::make_unique<Listener>(
|
listener.push_back(make_unique<Listener>(
|
||||||
i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i],
|
i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i],
|
||||||
&udpSocketBufferSize, &actualUDPSocketBufferSize,
|
&udpSocketBufferSize, &actualUDPSocketBufferSize,
|
||||||
&framesPerFile, &frameDiscardMode, &detectorDataStream[i],
|
&framesPerFile, &frameDiscardMode, &detectorDataStream[i],
|
||||||
@ -185,14 +187,14 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
if (detType == CHIPTESTBOARD) {
|
if (detType == CHIPTESTBOARD) {
|
||||||
ctbAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
|
ctbAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
|
||||||
}
|
}
|
||||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(
|
dataProcessor.push_back(make_unique<DataProcessor>(
|
||||||
i, detType, fifo_ptr, &dataStreamEnable, &streamingFrequency,
|
i, detType, fifo_ptr, &dataStreamEnable, &streamingFrequency,
|
||||||
&streamingTimerInMs, &streamingStartFnum, &framePadding,
|
&streamingTimerInMs, &streamingStartFnum, &framePadding,
|
||||||
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
|
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
listener.clear();
|
listener.clear();
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not create listener/dataprocessor threads (index:" +
|
"Could not create listener/dataprocessor threads (index:" +
|
||||||
std::to_string(i) + ")");
|
std::to_string(i) + ")");
|
||||||
}
|
}
|
||||||
@ -209,7 +211,7 @@ void Implementation::setDetectorType(const detectorType d) {
|
|||||||
}
|
}
|
||||||
SetThreadPriorities();
|
SetThreadPriorities();
|
||||||
|
|
||||||
LOG(logDEBUG) << " Detector type set to " << sls::ToString(d);
|
LOG(logDEBUG) << " Detector type set to " << ToString(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
slsDetectorDefs::xy Implementation::getDetectorSize() const {
|
slsDetectorDefs::xy Implementation::getDetectorSize() const {
|
||||||
@ -240,7 +242,7 @@ void Implementation::setDetectorSize(const slsDetectorDefs::xy size) {
|
|||||||
it->SetNumberofPorts(numPorts);
|
it->SetNumberofPorts(numPorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << "Detector Size (ports): " << sls::ToString(numPorts);
|
LOG(logINFO) << "Detector Size (ports): " << ToString(numPorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Implementation::getModulePositionId() const { return modulePos; }
|
int Implementation::getModulePositionId() const { return modulePos; }
|
||||||
@ -303,7 +305,7 @@ Implementation::getFrameDiscardPolicy() const {
|
|||||||
|
|
||||||
void Implementation::setFrameDiscardPolicy(const frameDiscardPolicy i) {
|
void Implementation::setFrameDiscardPolicy(const frameDiscardPolicy i) {
|
||||||
frameDiscardMode = i;
|
frameDiscardMode = i;
|
||||||
LOG(logINFO) << "Frame Discard Policy: " << sls::ToString(frameDiscardMode);
|
LOG(logINFO) << "Frame Discard Policy: " << ToString(frameDiscardMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Implementation::getFramePaddingEnable() const { return framePadding; }
|
bool Implementation::getFramePaddingEnable() const { return framePadding; }
|
||||||
@ -406,7 +408,7 @@ void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(logDEBUG)
|
LOG(logDEBUG)
|
||||||
<< iPort << ": portfullroi:" << sls::ToString(portFullRoi);
|
<< iPort << ": portfullroi:" << ToString(portFullRoi);
|
||||||
|
|
||||||
// no roi
|
// no roi
|
||||||
if (arg.xmin > portFullRoi.xmax ||
|
if (arg.xmin > portFullRoi.xmax ||
|
||||||
@ -440,15 +442,15 @@ void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
|
|||||||
}
|
}
|
||||||
for (size_t i = 0; i != dataProcessor.size(); ++i)
|
for (size_t i = 0; i != dataProcessor.size(); ++i)
|
||||||
dataProcessor[i]->SetReceiverROI(portRois[i]);
|
dataProcessor[i]->SetReceiverROI(portRois[i]);
|
||||||
LOG(logINFO) << "receiver roi: " << sls::ToString(receiverRoi);
|
LOG(logINFO) << "receiver roi: " << ToString(receiverRoi);
|
||||||
if (numUDPInterfaces == 2 && detType != slsDetectorDefs::GOTTHARD2) {
|
if (numUDPInterfaces == 2 && detType != slsDetectorDefs::GOTTHARD2) {
|
||||||
LOG(logINFO) << "port rois: " << sls::ToString(portRois);
|
LOG(logINFO) << "port rois: " << ToString(portRois);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setReceiverROIMetadata(const ROI arg) {
|
void Implementation::setReceiverROIMetadata(const ROI arg) {
|
||||||
receiverRoiMetadata = arg;
|
receiverRoiMetadata = arg;
|
||||||
LOG(logINFO) << "receiver roi Metadata: " << sls::ToString(receiverRoiMetadata);
|
LOG(logINFO) << "receiver roi Metadata: " << ToString(receiverRoiMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
@ -472,20 +474,20 @@ void Implementation::setFileFormat(const fileFormat f) {
|
|||||||
fileFormatType = BINARY;
|
fileFormatType = BINARY;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError("Unknown file format");
|
throw RuntimeError("Unknown file format");
|
||||||
}
|
}
|
||||||
for (const auto &it : dataProcessor)
|
for (const auto &it : dataProcessor)
|
||||||
it->SetupFileWriter(fileWriteEnable, fileFormatType, &hdf5LibMutex);
|
it->SetupFileWriter(fileWriteEnable, fileFormatType, &hdf5LibMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
|
LOG(logINFO) << "File Format: " << ToString(fileFormatType);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Implementation::getFilePath() const { return filePath; }
|
std::string Implementation::getFilePath() const { return filePath; }
|
||||||
|
|
||||||
void Implementation::setFilePath(const std::string &c) {
|
void Implementation::setFilePath(const std::string &c) {
|
||||||
if (!c.empty()) {
|
if (!c.empty()) {
|
||||||
sls::mkdir_p(c); // throws if it can't create
|
mkdir_p(c); // throws if it can't create
|
||||||
filePath = c;
|
filePath = c;
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "File path: " << filePath;
|
LOG(logINFO) << "File path: " << filePath;
|
||||||
@ -615,7 +617,7 @@ std::vector<int64_t> Implementation::getNumMissingPackets() const {
|
|||||||
|
|
||||||
void Implementation::setScan(slsDetectorDefs::scanParameters s) {
|
void Implementation::setScan(slsDetectorDefs::scanParameters s) {
|
||||||
scanParams = s;
|
scanParams = s;
|
||||||
LOG(logINFO) << "Scan parameters: " << sls::ToString(scanParams);
|
LOG(logINFO) << "Scan parameters: " << ToString(scanParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::startReceiver() {
|
void Implementation::startReceiver() {
|
||||||
@ -634,7 +636,7 @@ void Implementation::startReceiver() {
|
|||||||
startAcquisitionCallBack(filePath, fileName, fileIndex, imageSize,
|
startAcquisitionCallBack(filePath, fileName, fileIndex, imageSize,
|
||||||
pStartAcquisition);
|
pStartAcquisition);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
throw sls::RuntimeError("Start Acquisition Callback Error: " +
|
throw RuntimeError("Start Acquisition Callback Error: " +
|
||||||
std::string(e.what()));
|
std::string(e.what()));
|
||||||
}
|
}
|
||||||
if (rawDataReadyCallBack != nullptr) {
|
if (rawDataReadyCallBack != nullptr) {
|
||||||
@ -657,7 +659,7 @@ void Implementation::startReceiver() {
|
|||||||
StartRunning();
|
StartRunning();
|
||||||
|
|
||||||
LOG(logINFO) << "Receiver Started";
|
LOG(logINFO) << "Receiver Started";
|
||||||
LOG(logINFO) << "Status: " << sls::ToString(status);
|
LOG(logINFO) << "Status: " << ToString(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setStoppedFlag(bool stopped) { stoppedFlag = stopped; }
|
void Implementation::setStoppedFlag(bool stopped) { stoppedFlag = stopped; }
|
||||||
@ -698,7 +700,7 @@ void Implementation::stopReceiver() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
status = RUN_FINISHED;
|
status = RUN_FINISHED;
|
||||||
LOG(logINFO) << "Status: " << sls::ToString(status);
|
LOG(logINFO) << "Status: " << ToString(status);
|
||||||
|
|
||||||
{ // statistics
|
{ // statistics
|
||||||
auto mp = getNumMissingPackets();
|
auto mp = getNumMissingPackets();
|
||||||
@ -741,8 +743,8 @@ void Implementation::stopReceiver() {
|
|||||||
// change status
|
// change status
|
||||||
status = IDLE;
|
status = IDLE;
|
||||||
LOG(logINFO) << "Receiver Stopped";
|
LOG(logINFO) << "Receiver Stopped";
|
||||||
LOG(logINFO) << "Status: " << sls::ToString(status);
|
LOG(logINFO) << "Status: " << ToString(status);
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Acquisition Finished Callback Error: " +
|
"Acquisition Finished Callback Error: " +
|
||||||
std::string(e.what()));
|
std::string(e.what()));
|
||||||
}
|
}
|
||||||
@ -752,7 +754,7 @@ void Implementation::stopReceiver() {
|
|||||||
// change status
|
// change status
|
||||||
status = IDLE;
|
status = IDLE;
|
||||||
LOG(logINFO) << "Receiver Stopped";
|
LOG(logINFO) << "Receiver Stopped";
|
||||||
LOG(logINFO) << "Status: " << sls::ToString(status);
|
LOG(logINFO) << "Status: " << ToString(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::startReadout() {
|
void Implementation::startReadout() {
|
||||||
@ -823,9 +825,9 @@ void Implementation::CreateUDPSockets() {
|
|||||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||||
listener[i]->CreateUDPSockets();
|
listener[i]->CreateUDPSockets();
|
||||||
}
|
}
|
||||||
} catch (const sls::RuntimeError &e) {
|
} catch (const RuntimeError &e) {
|
||||||
shutDownUDPSockets();
|
shutDownUDPSockets();
|
||||||
throw sls::RuntimeError("Could not create UDP Socket(s).");
|
throw RuntimeError("Could not create UDP Socket(s).");
|
||||||
}
|
}
|
||||||
LOG(logDEBUG) << "UDP socket(s) created successfully.";
|
LOG(logDEBUG) << "UDP socket(s) created successfully.";
|
||||||
}
|
}
|
||||||
@ -838,11 +840,11 @@ void Implementation::SetupWriter() {
|
|||||||
modulePos, numUDPInterfaces, udpPortNum[i], framesPerFile,
|
modulePos, numUDPInterfaces, udpPortNum[i], framesPerFile,
|
||||||
numberOfTotalFrames, dynamicRange, detectorDataStream[i]);
|
numberOfTotalFrames, dynamicRange, detectorDataStream[i]);
|
||||||
}
|
}
|
||||||
} catch (const sls::RuntimeError &e) {
|
} catch (const RuntimeError &e) {
|
||||||
shutDownUDPSockets();
|
shutDownUDPSockets();
|
||||||
for (const auto &it : dataProcessor)
|
for (const auto &it : dataProcessor)
|
||||||
it->CloseFiles();
|
it->CloseFiles();
|
||||||
throw sls::RuntimeError("Could not create first data file.");
|
throw RuntimeError("Could not create first data file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,7 +970,7 @@ int Implementation::getNumberofUDPInterfaces() const {
|
|||||||
// not Eiger
|
// not Eiger
|
||||||
void Implementation::setNumberofUDPInterfaces(const int n) {
|
void Implementation::setNumberofUDPInterfaces(const int n) {
|
||||||
if (detType == EIGER) {
|
if (detType == EIGER) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Cannot set number of UDP interfaces for Eiger");
|
"Cannot set number of UDP interfaces for Eiger");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -994,7 +996,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
// listener and dataprocessor threads
|
// listener and dataprocessor threads
|
||||||
try {
|
try {
|
||||||
auto fifo_ptr = fifo[i].get();
|
auto fifo_ptr = fifo[i].get();
|
||||||
listener.push_back(sls::make_unique<Listener>(
|
listener.push_back(make_unique<Listener>(
|
||||||
i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i],
|
i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i],
|
||||||
&udpSocketBufferSize, &actualUDPSocketBufferSize,
|
&udpSocketBufferSize, &actualUDPSocketBufferSize,
|
||||||
&framesPerFile, &frameDiscardMode, &detectorDataStream[i],
|
&framesPerFile, &frameDiscardMode, &detectorDataStream[i],
|
||||||
@ -1007,7 +1009,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
ctbAnalogDataBytes =
|
ctbAnalogDataBytes =
|
||||||
generalData->GetNumberOfAnalogDatabytes();
|
generalData->GetNumberOfAnalogDatabytes();
|
||||||
}
|
}
|
||||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(
|
dataProcessor.push_back(make_unique<DataProcessor>(
|
||||||
i, detType, fifo_ptr, &dataStreamEnable,
|
i, detType, fifo_ptr, &dataStreamEnable,
|
||||||
&streamingFrequency, &streamingTimerInMs,
|
&streamingFrequency, &streamingTimerInMs,
|
||||||
&streamingStartFnum, &framePadding, &ctbDbitList,
|
&streamingStartFnum, &framePadding, &ctbDbitList,
|
||||||
@ -1018,7 +1020,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
} catch (...) {
|
} catch (...) {
|
||||||
listener.clear();
|
listener.clear();
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not create listener/dataprocessor threads (index:" +
|
"Could not create listener/dataprocessor threads (index:" +
|
||||||
std::to_string(i) + ")");
|
std::to_string(i) + ")");
|
||||||
}
|
}
|
||||||
@ -1029,7 +1031,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
flip = (i == 1 ? true : false);
|
flip = (i == 1 ? true : false);
|
||||||
}
|
}
|
||||||
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
dataStreamer.push_back(make_unique<DataStreamer>(
|
||||||
i, fifo[i].get(), &dynamicRange, &detectorRoi,
|
i, fifo[i].get(), &dynamicRange, &detectorRoi,
|
||||||
&fileIndex, flip, numPorts, &quadEnable,
|
&fileIndex, flip, numPorts, &quadEnable,
|
||||||
&numberOfTotalFrames));
|
&numberOfTotalFrames));
|
||||||
@ -1044,7 +1046,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
|||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
dataStreamEnable = false;
|
dataStreamEnable = false;
|
||||||
}
|
}
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not create datastreamer threads (index:" +
|
"Could not create datastreamer threads (index:" +
|
||||||
std::to_string(i) + ")");
|
std::to_string(i) + ")");
|
||||||
}
|
}
|
||||||
@ -1116,7 +1118,7 @@ void Implementation::setUDPSocketBufferSize(const int s) {
|
|||||||
size_t listSize = listener.size();
|
size_t listSize = listener.size();
|
||||||
if ((detType == JUNGFRAU || detType == GOTTHARD2) &&
|
if ((detType == JUNGFRAU || detType == GOTTHARD2) &&
|
||||||
(int)listSize != numUDPInterfaces) {
|
(int)listSize != numUDPInterfaces) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Number of Interfaces " + std::to_string(numUDPInterfaces) +
|
"Number of Interfaces " + std::to_string(numUDPInterfaces) +
|
||||||
" do not match listener size " + std::to_string(listSize));
|
" do not match listener size " + std::to_string(listSize));
|
||||||
}
|
}
|
||||||
@ -1126,7 +1128,7 @@ void Implementation::setUDPSocketBufferSize(const int s) {
|
|||||||
}
|
}
|
||||||
// custom and didnt set, throw error
|
// custom and didnt set, throw error
|
||||||
if (s != 0 && udpSocketBufferSize != s) {
|
if (s != 0 && udpSocketBufferSize != s) {
|
||||||
throw sls::RuntimeError("Could not set udp socket buffer size. (No "
|
throw RuntimeError("Could not set udp socket buffer size. (No "
|
||||||
"CAP_NET_ADMIN privileges?)");
|
"CAP_NET_ADMIN privileges?)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1156,7 +1158,7 @@ void Implementation::setDataStreamEnable(const bool enable) {
|
|||||||
if (quadEnable) {
|
if (quadEnable) {
|
||||||
flip = (i == 1 ? true : false);
|
flip = (i == 1 ? true : false);
|
||||||
}
|
}
|
||||||
dataStreamer.push_back(sls::make_unique<DataStreamer>(
|
dataStreamer.push_back(make_unique<DataStreamer>(
|
||||||
i, fifo[i].get(), &dynamicRange, &detectorRoi,
|
i, fifo[i].get(), &dynamicRange, &detectorRoi,
|
||||||
&fileIndex, flip, numPorts, &quadEnable,
|
&fileIndex, flip, numPorts, &quadEnable,
|
||||||
&numberOfTotalFrames));
|
&numberOfTotalFrames));
|
||||||
@ -1169,7 +1171,7 @@ void Implementation::setDataStreamEnable(const bool enable) {
|
|||||||
} catch (...) {
|
} catch (...) {
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
dataStreamEnable = false;
|
dataStreamEnable = false;
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not set data stream enable.");
|
"Could not set data stream enable.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1213,11 +1215,11 @@ void Implementation::setStreamingPort(const uint32_t i) {
|
|||||||
LOG(logINFO) << "Streaming Port: " << streamingPort;
|
LOG(logINFO) << "Streaming Port: " << streamingPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::IpAddr Implementation::getStreamingSourceIP() const {
|
IpAddr Implementation::getStreamingSourceIP() const {
|
||||||
return streamingSrcIP;
|
return streamingSrcIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setStreamingSourceIP(const sls::IpAddr ip) {
|
void Implementation::setStreamingSourceIP(const IpAddr ip) {
|
||||||
streamingSrcIP = ip;
|
streamingSrcIP = ip;
|
||||||
LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP;
|
LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP;
|
||||||
}
|
}
|
||||||
@ -1243,7 +1245,7 @@ void Implementation::setAdditionalJsonHeader(
|
|||||||
it->SetAdditionalJsonHeader(c);
|
it->SetAdditionalJsonHeader(c);
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Additional JSON Header: "
|
LOG(logINFO) << "Additional JSON Header: "
|
||||||
<< sls::ToString(additionalJsonHeader);
|
<< ToString(additionalJsonHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
@ -1251,7 +1253,7 @@ Implementation::getAdditionalJsonParameter(const std::string &key) const {
|
|||||||
if (additionalJsonHeader.find(key) != additionalJsonHeader.end()) {
|
if (additionalJsonHeader.find(key) != additionalJsonHeader.end()) {
|
||||||
return additionalJsonHeader.at(key);
|
return additionalJsonHeader.at(key);
|
||||||
}
|
}
|
||||||
throw sls::RuntimeError("No key " + key +
|
throw RuntimeError("No key " + key +
|
||||||
" found in additional json header");
|
" found in additional json header");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1286,7 +1288,7 @@ void Implementation::setAdditionalJsonParameter(const std::string &key,
|
|||||||
it->SetAdditionalJsonHeader(additionalJsonHeader);
|
it->SetAdditionalJsonHeader(additionalJsonHeader);
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Additional JSON Header: "
|
LOG(logINFO) << "Additional JSON Header: "
|
||||||
<< sls::ToString(additionalJsonHeader);
|
<< ToString(additionalJsonHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
@ -1322,7 +1324,7 @@ void Implementation::updateTotalNumberOfFrames() {
|
|||||||
numberOfTotalFrames =
|
numberOfTotalFrames =
|
||||||
numFrames * repeats * (int64_t)(numberOfAdditionalStorageCells + 1);
|
numFrames * repeats * (int64_t)(numberOfAdditionalStorageCells + 1);
|
||||||
if (numberOfTotalFrames == 0) {
|
if (numberOfTotalFrames == 0) {
|
||||||
throw sls::RuntimeError("Invalid total number of frames to receive: 0");
|
throw RuntimeError("Invalid total number of frames to receive: 0");
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Total Number of Frames: " << numberOfTotalFrames;
|
LOG(logINFO) << "Total Number of Frames: " << numberOfTotalFrames;
|
||||||
}
|
}
|
||||||
@ -1393,7 +1395,7 @@ ns Implementation::getAcquisitionPeriod() const { return acquisitionPeriod; }
|
|||||||
|
|
||||||
void Implementation::setAcquisitionPeriod(const ns i) {
|
void Implementation::setAcquisitionPeriod(const ns i) {
|
||||||
acquisitionPeriod = i;
|
acquisitionPeriod = i;
|
||||||
LOG(logINFO) << "Acquisition Period: " << sls::ToString(acquisitionPeriod);
|
LOG(logINFO) << "Acquisition Period: " << ToString(acquisitionPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
ns Implementation::getAcquisitionTime() const { return acquisitionTime; }
|
ns Implementation::getAcquisitionTime() const { return acquisitionTime; }
|
||||||
@ -1409,54 +1411,54 @@ void Implementation::updateAcquisitionTime() {
|
|||||||
|
|
||||||
void Implementation::setAcquisitionTime(const ns i) {
|
void Implementation::setAcquisitionTime(const ns i) {
|
||||||
acquisitionTime = i;
|
acquisitionTime = i;
|
||||||
LOG(logINFO) << "Acquisition Time: " << sls::ToString(acquisitionTime);
|
LOG(logINFO) << "Acquisition Time: " << ToString(acquisitionTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setAcquisitionTime1(const ns i) {
|
void Implementation::setAcquisitionTime1(const ns i) {
|
||||||
acquisitionTime1 = i;
|
acquisitionTime1 = i;
|
||||||
LOG(logINFO) << "Acquisition Time1: " << sls::ToString(acquisitionTime1);
|
LOG(logINFO) << "Acquisition Time1: " << ToString(acquisitionTime1);
|
||||||
updateAcquisitionTime();
|
updateAcquisitionTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setAcquisitionTime2(const ns i) {
|
void Implementation::setAcquisitionTime2(const ns i) {
|
||||||
acquisitionTime2 = i;
|
acquisitionTime2 = i;
|
||||||
LOG(logINFO) << "Acquisition Time2: " << sls::ToString(acquisitionTime2);
|
LOG(logINFO) << "Acquisition Time2: " << ToString(acquisitionTime2);
|
||||||
updateAcquisitionTime();
|
updateAcquisitionTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setAcquisitionTime3(const ns i) {
|
void Implementation::setAcquisitionTime3(const ns i) {
|
||||||
acquisitionTime3 = i;
|
acquisitionTime3 = i;
|
||||||
LOG(logINFO) << "Acquisition Time3: " << sls::ToString(acquisitionTime3);
|
LOG(logINFO) << "Acquisition Time3: " << ToString(acquisitionTime3);
|
||||||
updateAcquisitionTime();
|
updateAcquisitionTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setGateDelay1(const ns i) {
|
void Implementation::setGateDelay1(const ns i) {
|
||||||
gateDelay1 = i;
|
gateDelay1 = i;
|
||||||
LOG(logINFO) << "Gate Delay1: " << sls::ToString(gateDelay1);
|
LOG(logINFO) << "Gate Delay1: " << ToString(gateDelay1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setGateDelay2(const ns i) {
|
void Implementation::setGateDelay2(const ns i) {
|
||||||
gateDelay2 = i;
|
gateDelay2 = i;
|
||||||
LOG(logINFO) << "Gate Delay2: " << sls::ToString(gateDelay2);
|
LOG(logINFO) << "Gate Delay2: " << ToString(gateDelay2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setGateDelay3(const ns i) {
|
void Implementation::setGateDelay3(const ns i) {
|
||||||
gateDelay3 = i;
|
gateDelay3 = i;
|
||||||
LOG(logINFO) << "Gate Delay3: " << sls::ToString(gateDelay3);
|
LOG(logINFO) << "Gate Delay3: " << ToString(gateDelay3);
|
||||||
}
|
}
|
||||||
|
|
||||||
ns Implementation::getSubExpTime() const { return subExpTime; }
|
ns Implementation::getSubExpTime() const { return subExpTime; }
|
||||||
|
|
||||||
void Implementation::setSubExpTime(const ns i) {
|
void Implementation::setSubExpTime(const ns i) {
|
||||||
subExpTime = i;
|
subExpTime = i;
|
||||||
LOG(logINFO) << "Sub Exposure Time: " << sls::ToString(subExpTime);
|
LOG(logINFO) << "Sub Exposure Time: " << ToString(subExpTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
ns Implementation::getSubPeriod() const { return subPeriod; }
|
ns Implementation::getSubPeriod() const { return subPeriod; }
|
||||||
|
|
||||||
void Implementation::setSubPeriod(const ns i) {
|
void Implementation::setSubPeriod(const ns i) {
|
||||||
subPeriod = i;
|
subPeriod = i;
|
||||||
LOG(logINFO) << "Sub Period: " << sls::ToString(subPeriod);
|
LOG(logINFO) << "Sub Period: " << ToString(subPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Implementation::getNumberofAnalogSamples() const {
|
uint32_t Implementation::getNumberofAnalogSamples() const {
|
||||||
@ -1497,7 +1499,7 @@ void Implementation::setCounterMask(const uint32_t i) {
|
|||||||
counterMask = i;
|
counterMask = i;
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Counter mask: " << sls::ToStringHex(counterMask);
|
LOG(logINFO) << "Counter mask: " << ToStringHex(counterMask);
|
||||||
int ncounters = __builtin_popcount(counterMask);
|
int ncounters = __builtin_popcount(counterMask);
|
||||||
LOG(logINFO) << "Number of counters: " << ncounters;
|
LOG(logINFO) << "Number of counters: " << ncounters;
|
||||||
}
|
}
|
||||||
@ -1530,7 +1532,7 @@ void Implementation::setDetectorROI(slsDetectorDefs::ROI arg) {
|
|||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logINFO) << "Detector ROI: " << sls::ToString(detectorRoi);
|
LOG(logINFO) << "Detector ROI: " << ToString(detectorRoi);
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1553,9 +1555,9 @@ void Implementation::setTenGigaEnable(const bool b) {
|
|||||||
detectorDataStream[RIGHT] = detectorDataStream10GbE[RIGHT];
|
detectorDataStream[RIGHT] = detectorDataStream10GbE[RIGHT];
|
||||||
}
|
}
|
||||||
LOG(logDEBUG) << "Detector datastream updated [Left: "
|
LOG(logDEBUG) << "Detector datastream updated [Left: "
|
||||||
<< sls::ToString(detectorDataStream[LEFT])
|
<< ToString(detectorDataStream[LEFT])
|
||||||
<< ", Right: "
|
<< ", Right: "
|
||||||
<< sls::ToString(detectorDataStream[RIGHT]) << "]";
|
<< ToString(detectorDataStream[RIGHT]) << "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Ten Giga: " << (tengigaEnable ? "enabled" : "disabled");
|
LOG(logINFO) << "Ten Giga: " << (tengigaEnable ? "enabled" : "disabled");
|
||||||
@ -1623,14 +1625,14 @@ void Implementation::setDetectorDataStream(const portPosition port,
|
|||||||
const bool enable) {
|
const bool enable) {
|
||||||
int index = (port == LEFT ? 0 : 1);
|
int index = (port == LEFT ? 0 : 1);
|
||||||
detectorDataStream10GbE[index] = enable;
|
detectorDataStream10GbE[index] = enable;
|
||||||
LOG(logINFO) << "Detector 10GbE datastream (" << sls::ToString(port)
|
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
|
||||||
<< " Port): " << sls::ToString(detectorDataStream10GbE[index]);
|
<< " Port): " << ToString(detectorDataStream10GbE[index]);
|
||||||
// update datastream for 10g
|
// update datastream for 10g
|
||||||
if (tengigaEnable) {
|
if (tengigaEnable) {
|
||||||
detectorDataStream[index] = detectorDataStream10GbE[index];
|
detectorDataStream[index] = detectorDataStream10GbE[index];
|
||||||
LOG(logDEBUG) << "Detector datastream updated ["
|
LOG(logDEBUG) << "Detector datastream updated ["
|
||||||
<< (index == 0 ? "Left" : "Right")
|
<< (index == 0 ? "Left" : "Right")
|
||||||
<< "] : " << sls::ToString(detectorDataStream[index]);
|
<< "] : " << ToString(detectorDataStream[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1649,12 +1651,12 @@ void Implementation::setThresholdEnergy(const int value) {
|
|||||||
void Implementation::setThresholdEnergy(const std::array<int, 3> value) {
|
void Implementation::setThresholdEnergy(const std::array<int, 3> value) {
|
||||||
thresholdAllEnergyeV = value;
|
thresholdAllEnergyeV = value;
|
||||||
LOG(logINFO) << "Threshold Energy (eV): "
|
LOG(logINFO) << "Threshold Energy (eV): "
|
||||||
<< sls::ToString(thresholdAllEnergyeV);
|
<< ToString(thresholdAllEnergyeV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Implementation::setRateCorrections(const std::vector<int64_t> &t) {
|
void Implementation::setRateCorrections(const std::vector<int64_t> &t) {
|
||||||
rateCorrections = t;
|
rateCorrections = t;
|
||||||
LOG(logINFO) << "Rate Corrections: " << sls::ToString(rateCorrections);
|
LOG(logINFO) << "Rate Corrections: " << ToString(rateCorrections);
|
||||||
}
|
}
|
||||||
|
|
||||||
slsDetectorDefs::readoutMode Implementation::getReadoutMode() const {
|
slsDetectorDefs::readoutMode Implementation::getReadoutMode() const {
|
||||||
@ -1668,7 +1670,7 @@ void Implementation::setReadoutMode(const readoutMode f) {
|
|||||||
generalData->SetReadoutMode(f);
|
generalData->SetReadoutMode(f);
|
||||||
SetupFifoStructure();
|
SetupFifoStructure();
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Readout Mode: " << sls::ToString(f);
|
LOG(logINFO) << "Readout Mode: " << ToString(f);
|
||||||
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1748,3 +1750,5 @@ void Implementation::registerCallBackRawDataModifyReady(
|
|||||||
it->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,
|
it->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,
|
||||||
pRawDataReady);
|
pRawDataReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -6,12 +6,7 @@
|
|||||||
#include "sls/container_utils.h"
|
#include "sls/container_utils.h"
|
||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/network_utils.h"
|
#include "sls/network_utils.h"
|
||||||
class GeneralData;
|
#include "sls/sls_detector_defs.h"
|
||||||
class Listener;
|
|
||||||
class DataProcessor;
|
|
||||||
class DataStreamer;
|
|
||||||
class Fifo;
|
|
||||||
class slsDetectorDefs;
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -20,8 +15,16 @@ class slsDetectorDefs;
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
using ns = std::chrono::nanoseconds;
|
using ns = std::chrono::nanoseconds;
|
||||||
|
|
||||||
|
class GeneralData;
|
||||||
|
class Listener;
|
||||||
|
class DataProcessor;
|
||||||
|
class DataStreamer;
|
||||||
|
class Fifo;
|
||||||
|
|
||||||
class Implementation : private virtual slsDetectorDefs {
|
class Implementation : private virtual slsDetectorDefs {
|
||||||
public:
|
public:
|
||||||
explicit Implementation(const detectorType d);
|
explicit Implementation(const detectorType d);
|
||||||
@ -137,8 +140,8 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
void setStreamingStartingFrameNumber(const uint32_t fnum);
|
void setStreamingStartingFrameNumber(const uint32_t fnum);
|
||||||
uint32_t getStreamingPort() const;
|
uint32_t getStreamingPort() const;
|
||||||
void setStreamingPort(const uint32_t i);
|
void setStreamingPort(const uint32_t i);
|
||||||
sls::IpAddr getStreamingSourceIP() const;
|
IpAddr getStreamingSourceIP() const;
|
||||||
void setStreamingSourceIP(const sls::IpAddr ip);
|
void setStreamingSourceIP(const IpAddr ip);
|
||||||
int getStreamingHwm() const;
|
int getStreamingHwm() const;
|
||||||
void setStreamingHwm(const int i);
|
void setStreamingHwm(const int i);
|
||||||
std::map<std::string, std::string> getAdditionalJsonHeader() const;
|
std::map<std::string, std::string> getAdditionalJsonHeader() const;
|
||||||
@ -338,7 +341,7 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
uint32_t streamingTimerInMs{DEFAULT_STREAMING_TIMER_IN_MS};
|
uint32_t streamingTimerInMs{DEFAULT_STREAMING_TIMER_IN_MS};
|
||||||
uint32_t streamingStartFnum{0};
|
uint32_t streamingStartFnum{0};
|
||||||
uint32_t streamingPort{0};
|
uint32_t streamingPort{0};
|
||||||
sls::IpAddr streamingSrcIP = sls::IpAddr{};
|
IpAddr streamingSrcIP = IpAddr{};
|
||||||
int streamingHwm{-1};
|
int streamingHwm{-1};
|
||||||
std::map<std::string, std::string> additionalJsonHeader;
|
std::map<std::string, std::string> additionalJsonHeader;
|
||||||
|
|
||||||
@ -406,3 +409,5 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
// mutex shared across all hdf5 virtual, master and data files
|
// mutex shared across all hdf5 virtual, master and data files
|
||||||
std::mutex hdf5LibMutex;
|
std::mutex hdf5LibMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
#include "GeneralData.h"
|
#include "GeneralData.h"
|
||||||
#include "sls/UdpRxSocket.h"
|
#include "sls/UdpRxSocket.h"
|
||||||
#include "sls/container_utils.h" // For sls::make_unique<>
|
#include "sls/container_utils.h" // For make_unique<>
|
||||||
#include "sls/network_utils.h"
|
#include "sls/network_utils.h"
|
||||||
#include "sls/sls_detector_exceptions.h"
|
#include "sls/sls_detector_exceptions.h"
|
||||||
|
|
||||||
@ -19,6 +19,8 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
const std::string Listener::TypeName = "Listener";
|
const std::string Listener::TypeName = "Listener";
|
||||||
|
|
||||||
Listener::Listener(int ind, detectorType dtype, Fifo *f,
|
Listener::Listener(int ind, detectorType dtype, Fifo *f,
|
||||||
@ -86,9 +88,9 @@ void Listener::ResetParametersforNewAcquisition() {
|
|||||||
if (myDetectorType == GOTTHARD2 && index != 0) {
|
if (myDetectorType == GOTTHARD2 && index != 0) {
|
||||||
packetSize = generalData->vetoPacketSize;
|
packetSize = generalData->vetoPacketSize;
|
||||||
}
|
}
|
||||||
carryOverPacket = sls::make_unique<char[]>(packetSize);
|
carryOverPacket = make_unique<char[]>(packetSize);
|
||||||
memset(carryOverPacket.get(), 0, packetSize);
|
memset(carryOverPacket.get(), 0, packetSize);
|
||||||
listeningPacket = sls::make_unique<char[]>(packetSize);
|
listeningPacket = make_unique<char[]>(packetSize);
|
||||||
memset(carryOverPacket.get(), 0, packetSize);
|
memset(carryOverPacket.get(), 0, packetSize);
|
||||||
|
|
||||||
numPacketsStatistic = 0;
|
numPacketsStatistic = 0;
|
||||||
@ -139,14 +141,14 @@ void Listener::CreateUDPSockets() {
|
|||||||
|
|
||||||
// InterfaceNameToIp(eth).str().c_str()
|
// InterfaceNameToIp(eth).str().c_str()
|
||||||
try {
|
try {
|
||||||
udpSocket = sls::make_unique<sls::UdpRxSocket>(
|
udpSocket = make_unique<UdpRxSocket>(
|
||||||
*udpPortNumber, packetSize,
|
*udpPortNumber, packetSize,
|
||||||
((*eth).length() ? sls::InterfaceNameToIp(*eth).str().c_str()
|
((*eth).length() ? InterfaceNameToIp(*eth).str().c_str()
|
||||||
: nullptr),
|
: nullptr),
|
||||||
*udpSocketBufferSize);
|
*udpSocketBufferSize);
|
||||||
LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw sls::RuntimeError("Could not create UDP socket on port " +
|
throw RuntimeError("Could not create UDP socket on port " +
|
||||||
std::to_string(*udpPortNumber));
|
std::to_string(*udpPortNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,9 +190,9 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
|
|||||||
|
|
||||||
// create dummy socket
|
// create dummy socket
|
||||||
try {
|
try {
|
||||||
sls::UdpRxSocket g(*udpPortNumber, packetSize,
|
UdpRxSocket g(*udpPortNumber, packetSize,
|
||||||
((*eth).length()
|
((*eth).length()
|
||||||
? sls::InterfaceNameToIp(*eth).str().c_str()
|
? InterfaceNameToIp(*eth).str().c_str()
|
||||||
: nullptr),
|
: nullptr),
|
||||||
*udpSocketBufferSize);
|
*udpSocketBufferSize);
|
||||||
|
|
||||||
@ -204,7 +206,7 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw sls::RuntimeError("Could not create a test UDP socket on port " +
|
throw RuntimeError("Could not create a test UDP socket on port " +
|
||||||
std::to_string(*udpPortNumber));
|
std::to_string(*udpPortNumber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -649,3 +651,5 @@ void Listener::PrintFifoStatistics() {
|
|||||||
<< " \tFree_Slots_Min_Level:" << fifo->GetMinLevelForFifoFree()
|
<< " \tFree_Slots_Min_Level:" << fifo->GetMinLevelForFifoFree()
|
||||||
<< " \tCurrent_Frame#:" << currentFrameIndex;
|
<< " \tCurrent_Frame#:" << currentFrameIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class GeneralData;
|
class GeneralData;
|
||||||
class Fifo;
|
class Fifo;
|
||||||
|
|
||||||
@ -117,7 +119,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
// individual members
|
// individual members
|
||||||
detectorType myDetectorType;
|
detectorType myDetectorType;
|
||||||
std::atomic<runStatus> *status;
|
std::atomic<runStatus> *status;
|
||||||
std::unique_ptr<sls::UdpRxSocket> udpSocket{nullptr};
|
std::unique_ptr<UdpRxSocket> udpSocket{nullptr};
|
||||||
uint32_t *udpPortNumber;
|
uint32_t *udpPortNumber;
|
||||||
std::string *eth;
|
std::string *eth;
|
||||||
int *udpSocketBufferSize;
|
int *udpSocketBufferSize;
|
||||||
@ -172,3 +174,5 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* (pecific to gotthard, can vary between modules, hence defined here) */
|
* (pecific to gotthard, can vary between modules, hence defined here) */
|
||||||
bool oddStartingPacket{true};
|
bool oddStartingPacket{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#include "MasterAttributes.h"
|
#include "MasterAttributes.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
void MasterAttributes::GetBinaryAttributes(
|
void MasterAttributes::GetBinaryAttributes(
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||||
w->StartObject();
|
w->StartObject();
|
||||||
@ -29,7 +31,7 @@ void MasterAttributes::GetBinaryAttributes(
|
|||||||
GetCtbBinaryAttributes(w);
|
GetCtbBinaryAttributes(w);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Unknown Detector type to get master attributes");
|
"Unknown Detector type to get master attributes");
|
||||||
}
|
}
|
||||||
GetFinalBinaryAttributes(w);
|
GetFinalBinaryAttributes(w);
|
||||||
@ -62,7 +64,7 @@ void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
WriteCtbHDF5Attributes(fd, group);
|
WriteCtbHDF5Attributes(fd, group);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Unknown Detector type to get master attributes");
|
"Unknown Detector type to get master attributes");
|
||||||
}
|
}
|
||||||
WriteFinalHDF5Attributes(fd, group);
|
WriteFinalHDF5Attributes(fd, group);
|
||||||
@ -75,14 +77,14 @@ void MasterAttributes::GetCommonBinaryAttributes(
|
|||||||
w->SetMaxDecimalPlaces(2);
|
w->SetMaxDecimalPlaces(2);
|
||||||
w->Double(BINARY_WRITER_VERSION);
|
w->Double(BINARY_WRITER_VERSION);
|
||||||
w->Key("Timestamp");
|
w->Key("Timestamp");
|
||||||
time_t t = time(nullptr);
|
time_t t = std::time(nullptr);
|
||||||
std::string sTime(ctime(&t));
|
std::string sTime(ctime(&t));
|
||||||
std::replace(sTime.begin(), sTime.end(), '\n', '\0');
|
std::replace(sTime.begin(), sTime.end(), '\n', '\0');
|
||||||
w->String(sTime.c_str());
|
w->String(sTime.c_str());
|
||||||
w->Key("Detector Type");
|
w->Key("Detector Type");
|
||||||
w->String(sls::ToString(detType).c_str());
|
w->String(ToString(detType).c_str());
|
||||||
w->Key("Timing Mode");
|
w->Key("Timing Mode");
|
||||||
w->String(sls::ToString(timingMode).c_str());
|
w->String(ToString(timingMode).c_str());
|
||||||
w->Key("Geometry");
|
w->Key("Geometry");
|
||||||
w->StartObject();
|
w->StartObject();
|
||||||
w->Key("x");
|
w->Key("x");
|
||||||
@ -102,11 +104,11 @@ void MasterAttributes::GetCommonBinaryAttributes(
|
|||||||
w->Key("Max Frames Per File");
|
w->Key("Max Frames Per File");
|
||||||
w->Uint(maxFramesPerFile);
|
w->Uint(maxFramesPerFile);
|
||||||
w->Key("Frame Discard Policy");
|
w->Key("Frame Discard Policy");
|
||||||
w->String(sls::ToString(frameDiscardMode).c_str());
|
w->String(ToString(frameDiscardMode).c_str());
|
||||||
w->Key("Frame Padding");
|
w->Key("Frame Padding");
|
||||||
w->Uint(framePadding);
|
w->Uint(framePadding);
|
||||||
w->Key("Scan Parameters");
|
w->Key("Scan Parameters");
|
||||||
w->String(sls::ToString(scanParams).c_str());
|
w->String(ToString(scanParams).c_str());
|
||||||
w->Key("Total Frames");
|
w->Key("Total Frames");
|
||||||
w->Uint64(totalFrames);
|
w->Uint64(totalFrames);
|
||||||
w->Key("Receiver Roi");
|
w->Key("Receiver Roi");
|
||||||
@ -127,7 +129,7 @@ void MasterAttributes::GetFinalBinaryAttributes(
|
|||||||
// adding few common parameters to the end
|
// adding few common parameters to the end
|
||||||
if (!additionalJsonHeader.empty()) {
|
if (!additionalJsonHeader.empty()) {
|
||||||
w->Key("Additional Json Header");
|
w->Key("Additional Json Header");
|
||||||
w->String(sls::ToString(additionalJsonHeader).c_str());
|
w->String(ToString(additionalJsonHeader).c_str());
|
||||||
}
|
}
|
||||||
w->Key("Frames in File");
|
w->Key("Frames in File");
|
||||||
w->Uint64(framesInFile);
|
w->Uint64(framesInFile);
|
||||||
@ -182,7 +184,7 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Timestamp", strdatatype, dataspace);
|
group->createDataSet("Timestamp", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, std::string(ctime(&t)));
|
strcpy_safe(c, std::string(ctime(&t)));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
// detector type
|
// detector type
|
||||||
@ -191,7 +193,7 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Detector Type", strdatatype, dataspace);
|
group->createDataSet("Detector Type", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(detType));
|
strcpy_safe(c, ToString(detType));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
// timing mode
|
// timing mode
|
||||||
@ -200,7 +202,7 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Timing Mode", strdatatype, dataspace);
|
group->createDataSet("Timing Mode", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(timingMode));
|
strcpy_safe(c, ToString(timingMode));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
// TODO: make this into an array?
|
// TODO: make this into an array?
|
||||||
@ -228,7 +230,7 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
Attribute attribute =
|
Attribute attribute =
|
||||||
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
||||||
sls::strcpy_safe(c, "bytes");
|
strcpy_safe(c, "bytes");
|
||||||
attribute.write(strdatatype, c);
|
attribute.write(strdatatype, c);
|
||||||
}
|
}
|
||||||
// TODO: make this into an array?
|
// TODO: make this into an array?
|
||||||
@ -259,7 +261,7 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
DataSet dataset = group->createDataSet("Frame Discard Policy",
|
DataSet dataset = group->createDataSet("Frame Discard Policy",
|
||||||
strdatatype, dataspace);
|
strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(frameDiscardMode));
|
strcpy_safe(c, ToString(frameDiscardMode));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
// Frame Padding
|
// Frame Padding
|
||||||
@ -275,7 +277,7 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Scan Parameters", strdatatype, dataspace);
|
group->createDataSet("Scan Parameters", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(scanParams));
|
strcpy_safe(c, ToString(scanParams));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
// Total Frames
|
// Total Frames
|
||||||
@ -326,12 +328,12 @@ void MasterAttributes::WriteFinalHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
}
|
}
|
||||||
// additional json header
|
// additional json header
|
||||||
if (!additionalJsonHeader.empty()) {
|
if (!additionalJsonHeader.empty()) {
|
||||||
std::string json = sls::ToString(additionalJsonHeader);
|
std::string json = ToString(additionalJsonHeader);
|
||||||
StrType strdatatype(PredType::C_S1, json.length());
|
StrType strdatatype(PredType::C_S1, json.length());
|
||||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||||
DataSet dataset = group->createDataSet("Additional JSON Header",
|
DataSet dataset = group->createDataSet("Additional JSON Header",
|
||||||
strdatatype, dataspace);
|
strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(additionalJsonHeader));
|
strcpy_safe(c, ToString(additionalJsonHeader));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -342,7 +344,7 @@ void MasterAttributes::WriteHDF5Exptime(H5File *fd, Group *group) {
|
|||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Exposure Time", strdatatype, dataspace);
|
group->createDataSet("Exposure Time", strdatatype, dataspace);
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
sls::strcpy_safe(c, sls::ToString(exptime));
|
strcpy_safe(c, ToString(exptime));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,7 +354,7 @@ void MasterAttributes::WriteHDF5Period(H5File *fd, Group *group) {
|
|||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Acquisition Period", strdatatype, dataspace);
|
group->createDataSet("Acquisition Period", strdatatype, dataspace);
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
sls::strcpy_safe(c, sls::ToString(period));
|
strcpy_safe(c, ToString(period));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +419,7 @@ void MasterAttributes::WriteHDF5ThresholdEnergy(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
Attribute attribute =
|
Attribute attribute =
|
||||||
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
||||||
sls::strcpy_safe(c, "eV");
|
strcpy_safe(c, "eV");
|
||||||
attribute.write(strdatatype, c);
|
attribute.write(strdatatype, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +429,7 @@ void MasterAttributes::WriteHDF5ThresholdEnergies(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 1024);
|
StrType strdatatype(PredType::C_S1, 1024);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Threshold Energies", strdatatype, dataspace);
|
group->createDataSet("Threshold Energies", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(thresholdAllEnergyeV));
|
strcpy_safe(c, ToString(thresholdAllEnergyeV));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +439,7 @@ void MasterAttributes::WriteHDF5SubExpTime(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Sub Exposure Time", strdatatype, dataspace);
|
group->createDataSet("Sub Exposure Time", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(subExptime));
|
strcpy_safe(c, ToString(subExptime));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +449,7 @@ void MasterAttributes::WriteHDF5SubPeriod(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Sub Period", strdatatype, dataspace);
|
group->createDataSet("Sub Period", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(subPeriod));
|
strcpy_safe(c, ToString(subPeriod));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +466,7 @@ void MasterAttributes::WriteHDF5RateCorrections(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 1024);
|
StrType strdatatype(PredType::C_S1, 1024);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Rate Corrections", strdatatype, dataspace);
|
group->createDataSet("Rate Corrections", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(ratecorr));
|
strcpy_safe(c, ToString(ratecorr));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +484,7 @@ void MasterAttributes::WriteHDF5ExptimeArray(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Exposure Time1", strdatatype, dataspace);
|
group->createDataSet("Exposure Time1", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(exptimeArray[i]));
|
strcpy_safe(c, ToString(exptimeArray[i]));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,7 +496,7 @@ void MasterAttributes::WriteHDF5GateDelayArray(H5File *fd, Group *group) {
|
|||||||
StrType strdatatype(PredType::C_S1, 256);
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Gate Delay1", strdatatype, dataspace);
|
group->createDataSet("Gate Delay1", strdatatype, dataspace);
|
||||||
sls::strcpy_safe(c, sls::ToString(gateDelayArray[i]));
|
strcpy_safe(c, ToString(gateDelayArray[i]));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -512,7 +514,7 @@ void MasterAttributes::WriteHDF5BurstMode(H5File *fd, Group *group) {
|
|||||||
DataSet dataset =
|
DataSet dataset =
|
||||||
group->createDataSet("Burst Mode", strdatatype, dataspace);
|
group->createDataSet("Burst Mode", strdatatype, dataspace);
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
sls::strcpy_safe(c, sls::ToString(burstMode));
|
strcpy_safe(c, ToString(burstMode));
|
||||||
dataset.write(c, strdatatype);
|
dataset.write(c, strdatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,9 +571,9 @@ void MasterAttributes::WriteHDF5DbitList(H5File *fd, Group *group) {
|
|||||||
void MasterAttributes::GetGotthardBinaryAttributes(
|
void MasterAttributes::GetGotthardBinaryAttributes(
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||||
w->Key("Exptime");
|
w->Key("Exptime");
|
||||||
w->String(sls::ToString(exptime).c_str());
|
w->String(ToString(exptime).c_str());
|
||||||
w->Key("Period");
|
w->Key("Period");
|
||||||
w->String(sls::ToString(period).c_str());
|
w->String(ToString(period).c_str());
|
||||||
w->Key("Detector Roi");
|
w->Key("Detector Roi");
|
||||||
w->StartObject();
|
w->StartObject();
|
||||||
w->Key("xmin");
|
w->Key("xmin");
|
||||||
@ -592,9 +594,9 @@ void MasterAttributes::WriteGotthardHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
void MasterAttributes::GetJungfrauBinaryAttributes(
|
void MasterAttributes::GetJungfrauBinaryAttributes(
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||||
w->Key("Exptime");
|
w->Key("Exptime");
|
||||||
w->String(sls::ToString(exptime).c_str());
|
w->String(ToString(exptime).c_str());
|
||||||
w->Key("Period");
|
w->Key("Period");
|
||||||
w->String(sls::ToString(period).c_str());
|
w->String(ToString(period).c_str());
|
||||||
w->Key("Number of UDP Interfaces");
|
w->Key("Number of UDP Interfaces");
|
||||||
w->Uint(numUDPInterfaces);
|
w->Uint(numUDPInterfaces);
|
||||||
w->Key("Number of rows");
|
w->Key("Number of rows");
|
||||||
@ -617,21 +619,21 @@ void MasterAttributes::GetEigerBinaryAttributes(
|
|||||||
w->Key("Ten Giga");
|
w->Key("Ten Giga");
|
||||||
w->Uint(tenGiga);
|
w->Uint(tenGiga);
|
||||||
w->Key("Exptime");
|
w->Key("Exptime");
|
||||||
w->String(sls::ToString(exptime).c_str());
|
w->String(ToString(exptime).c_str());
|
||||||
w->Key("Period");
|
w->Key("Period");
|
||||||
w->String(sls::ToString(period).c_str());
|
w->String(ToString(period).c_str());
|
||||||
w->Key("Threshold Energy");
|
w->Key("Threshold Energy");
|
||||||
w->Int(thresholdEnergyeV);
|
w->Int(thresholdEnergyeV);
|
||||||
w->Key("Sub Exptime");
|
w->Key("Sub Exptime");
|
||||||
w->String(sls::ToString(subExptime).c_str());
|
w->String(ToString(subExptime).c_str());
|
||||||
w->Key("Sub Period");
|
w->Key("Sub Period");
|
||||||
w->String(sls::ToString(subPeriod).c_str());
|
w->String(ToString(subPeriod).c_str());
|
||||||
w->Key("Quad");
|
w->Key("Quad");
|
||||||
w->Int(quad);
|
w->Int(quad);
|
||||||
w->Key("Number of rows");
|
w->Key("Number of rows");
|
||||||
w->Int(readNRows);
|
w->Int(readNRows);
|
||||||
w->Key("Rate Corrections");
|
w->Key("Rate Corrections");
|
||||||
w->String(sls::ToString(ratecorr).c_str());
|
w->String(ToString(ratecorr).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
@ -656,21 +658,21 @@ void MasterAttributes::GetMythen3BinaryAttributes(
|
|||||||
w->Key("Ten Giga");
|
w->Key("Ten Giga");
|
||||||
w->Uint(tenGiga);
|
w->Uint(tenGiga);
|
||||||
w->Key("Period");
|
w->Key("Period");
|
||||||
w->String(sls::ToString(period).c_str());
|
w->String(ToString(period).c_str());
|
||||||
w->Key("Counter Mask");
|
w->Key("Counter Mask");
|
||||||
w->String(sls::ToStringHex(counterMask).c_str());
|
w->String(ToStringHex(counterMask).c_str());
|
||||||
for (int i = 0; i != 3; ++i) {
|
for (int i = 0; i != 3; ++i) {
|
||||||
w->Key((std::string("Exptime") + std::to_string(i + 1)).c_str());
|
w->Key((std::string("Exptime") + std::to_string(i + 1)).c_str());
|
||||||
w->String(sls::ToString(exptimeArray[i]).c_str());
|
w->String(ToString(exptimeArray[i]).c_str());
|
||||||
}
|
}
|
||||||
for (int i = 0; i != 3; ++i) {
|
for (int i = 0; i != 3; ++i) {
|
||||||
w->Key((std::string("GateDelay") + std::to_string(i + 1)).c_str());
|
w->Key((std::string("GateDelay") + std::to_string(i + 1)).c_str());
|
||||||
w->String(sls::ToString(gateDelayArray[i]).c_str());
|
w->String(ToString(gateDelayArray[i]).c_str());
|
||||||
}
|
}
|
||||||
w->Key("Gates");
|
w->Key("Gates");
|
||||||
w->Uint(gates);
|
w->Uint(gates);
|
||||||
w->Key("Threshold Energies");
|
w->Key("Threshold Energies");
|
||||||
w->String(sls::ToString(thresholdAllEnergyeV).c_str());
|
w->String(ToString(thresholdAllEnergyeV).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
@ -689,11 +691,11 @@ void MasterAttributes::WriteMythen3HDF5Attributes(H5File *fd, Group *group) {
|
|||||||
void MasterAttributes::GetGotthard2BinaryAttributes(
|
void MasterAttributes::GetGotthard2BinaryAttributes(
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||||
w->Key("Exptime");
|
w->Key("Exptime");
|
||||||
w->String(sls::ToString(exptime).c_str());
|
w->String(ToString(exptime).c_str());
|
||||||
w->Key("Period");
|
w->Key("Period");
|
||||||
w->String(sls::ToString(period).c_str());
|
w->String(ToString(period).c_str());
|
||||||
w->Key("Burst Mode");
|
w->Key("Burst Mode");
|
||||||
w->String(sls::ToString(burstMode).c_str());
|
w->String(ToString(burstMode).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
@ -707,13 +709,13 @@ void MasterAttributes::WriteGotthard2HDF5Attributes(H5File *fd, Group *group) {
|
|||||||
void MasterAttributes::GetMoenchBinaryAttributes(
|
void MasterAttributes::GetMoenchBinaryAttributes(
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||||
w->Key("Exptime");
|
w->Key("Exptime");
|
||||||
w->String(sls::ToString(exptime).c_str());
|
w->String(ToString(exptime).c_str());
|
||||||
w->Key("Period");
|
w->Key("Period");
|
||||||
w->String(sls::ToString(period).c_str());
|
w->String(ToString(period).c_str());
|
||||||
w->Key("Ten Giga");
|
w->Key("Ten Giga");
|
||||||
w->Uint(tenGiga);
|
w->Uint(tenGiga);
|
||||||
w->Key("ADC Mask");
|
w->Key("ADC Mask");
|
||||||
w->String(sls::ToStringHex(adcmask).c_str());
|
w->String(ToStringHex(adcmask).c_str());
|
||||||
w->Key("Analog Samples");
|
w->Key("Analog Samples");
|
||||||
w->Uint(analogSamples);
|
w->Uint(analogSamples);
|
||||||
}
|
}
|
||||||
@ -731,13 +733,13 @@ void MasterAttributes::WriteMoenchHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
void MasterAttributes::GetCtbBinaryAttributes(
|
void MasterAttributes::GetCtbBinaryAttributes(
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w) {
|
||||||
w->Key("Exptime");
|
w->Key("Exptime");
|
||||||
w->String(sls::ToString(exptime).c_str());
|
w->String(ToString(exptime).c_str());
|
||||||
w->Key("Period");
|
w->Key("Period");
|
||||||
w->String(sls::ToString(period).c_str());
|
w->String(ToString(period).c_str());
|
||||||
w->Key("Ten Giga");
|
w->Key("Ten Giga");
|
||||||
w->Uint(tenGiga);
|
w->Uint(tenGiga);
|
||||||
w->Key("ADC Mask");
|
w->Key("ADC Mask");
|
||||||
w->String(sls::ToStringHex(adcmask).c_str());
|
w->String(ToStringHex(adcmask).c_str());
|
||||||
w->Key("Analog Flag");
|
w->Key("Analog Flag");
|
||||||
w->Uint(analog);
|
w->Uint(analog);
|
||||||
w->Key("Analog Samples");
|
w->Key("Analog Samples");
|
||||||
@ -766,3 +768,5 @@ void MasterAttributes::WriteCtbHDF5Attributes(H5File *fd, Group *group) {
|
|||||||
MasterAttributes::WriteHDF5DbitList(fd, group);
|
MasterAttributes::WriteHDF5DbitList(fd, group);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
|
|
||||||
#include <rapidjson/prettywriter.h>
|
#include <rapidjson/prettywriter.h>
|
||||||
#include <rapidjson/stringbuffer.h>
|
#include <rapidjson/stringbuffer.h>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
using ns = std::chrono::nanoseconds;
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
#include "H5Cpp.h"
|
#include "H5Cpp.h"
|
||||||
@ -17,9 +22,6 @@ using namespace H5;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
using ns = std::chrono::nanoseconds;
|
|
||||||
|
|
||||||
class MasterAttributes {
|
class MasterAttributes {
|
||||||
public:
|
public:
|
||||||
// (before acquisition)
|
// (before acquisition)
|
||||||
@ -148,3 +150,5 @@ class MasterAttributes {
|
|||||||
void WriteCtbHDF5Attributes(H5File *fd, Group *group);
|
void WriteCtbHDF5Attributes(H5File *fd, Group *group);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
namespace masterFileUtility {
|
namespace masterFileUtility {
|
||||||
|
|
||||||
std::string CreateMasterBinaryFile(const std::string &filePath,
|
std::string CreateMasterBinaryFile(const std::string &filePath,
|
||||||
@ -23,7 +25,7 @@ std::string CreateMasterBinaryFile(const std::string &filePath,
|
|||||||
mode = "wx";
|
mode = "wx";
|
||||||
FILE *fd = fopen(fileName.c_str(), mode.c_str());
|
FILE *fd = fopen(fileName.c_str(), mode.c_str());
|
||||||
if(!fd) {
|
if(!fd) {
|
||||||
throw sls::RuntimeError("Could not create/overwrite binary master file " +
|
throw RuntimeError("Could not create/overwrite binary master file " +
|
||||||
fileName);
|
fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ std::string CreateMasterBinaryFile(const std::string &filePath,
|
|||||||
attr->GetBinaryAttributes(&writer);
|
attr->GetBinaryAttributes(&writer);
|
||||||
if (fwrite(s.GetString(), 1, strlen(s.GetString()), fd) !=
|
if (fwrite(s.GetString(), 1, strlen(s.GetString()), fd) !=
|
||||||
strlen(s.GetString())) {
|
strlen(s.GetString())) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Master binary file incorrect number of bytes written to file");
|
"Master binary file incorrect number of bytes written to file");
|
||||||
}
|
}
|
||||||
if (fd) {
|
if (fd) {
|
||||||
@ -64,7 +66,7 @@ void LinkHDF5FileInMaster(const std::string &masterFileName,
|
|||||||
FileCreatPropList::DEFAULT, flist);
|
FileCreatPropList::DEFAULT, flist);
|
||||||
|
|
||||||
// open data file
|
// open data file
|
||||||
fd = sls::make_unique<H5File>(dataFilename.c_str(), H5F_ACC_RDONLY,
|
fd = make_unique<H5File>(dataFilename.c_str(), H5F_ACC_RDONLY,
|
||||||
FileCreatPropList::DEFAULT, flist);
|
FileCreatPropList::DEFAULT, flist);
|
||||||
|
|
||||||
// create link for data dataset
|
// create link for data dataset
|
||||||
@ -73,7 +75,7 @@ void LinkHDF5FileInMaster(const std::string &masterFileName,
|
|||||||
if (H5Lcreate_external(dataFilename.c_str(), dataSetname.c_str(),
|
if (H5Lcreate_external(dataFilename.c_str(), dataSetname.c_str(),
|
||||||
masterfd.getLocId(), linkname.c_str(),
|
masterfd.getLocId(), linkname.c_str(),
|
||||||
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not create link to data dataset in master");
|
"Could not create link to data dataset in master");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +87,7 @@ void LinkHDF5FileInMaster(const std::string &masterFileName,
|
|||||||
parameterNames[i].c_str(),
|
parameterNames[i].c_str(),
|
||||||
masterfd.getLocId(), linkname.c_str(),
|
masterfd.getLocId(), linkname.c_str(),
|
||||||
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not create link to parameter dataset in master");
|
"Could not create link to parameter dataset in master");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +97,7 @@ void LinkHDF5FileInMaster(const std::string &masterFileName,
|
|||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
if (fd != nullptr)
|
if (fd != nullptr)
|
||||||
fd->close();
|
fd->close();
|
||||||
throw sls::RuntimeError("Could not link in master hdf5 file");
|
throw RuntimeError("Could not link in master hdf5 file");
|
||||||
}
|
}
|
||||||
if (!silentMode) {
|
if (!silentMode) {
|
||||||
LOG(logINFO) << "Linked in Master File: " << dataFilename;
|
LOG(logINFO) << "Linked in Master File: " << dataFilename;
|
||||||
@ -127,7 +129,7 @@ std::string CreateMasterHDF5File(const std::string &filePath,
|
|||||||
if (overWriteEnable) {
|
if (overWriteEnable) {
|
||||||
createFlags = H5F_ACC_TRUNC;
|
createFlags = H5F_ACC_TRUNC;
|
||||||
}
|
}
|
||||||
fd = sls::make_unique<H5File>(fileName.c_str(), createFlags,
|
fd = make_unique<H5File>(fileName.c_str(), createFlags,
|
||||||
FileCreatPropList::DEFAULT, flist);
|
FileCreatPropList::DEFAULT, flist);
|
||||||
|
|
||||||
// attributes - version
|
// attributes - version
|
||||||
@ -151,7 +153,7 @@ std::string CreateMasterHDF5File(const std::string &filePath,
|
|||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
if (fd != nullptr)
|
if (fd != nullptr)
|
||||||
fd->close();
|
fd->close();
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not create/overwrite master HDF5 handles");
|
"Could not create/overwrite master HDF5 handles");
|
||||||
}
|
}
|
||||||
if (!silentMode) {
|
if (!silentMode) {
|
||||||
@ -195,10 +197,10 @@ std::array<std::string, 2> CreateVirtualHDF5File(
|
|||||||
FileAccPropList fapl;
|
FileAccPropList fapl;
|
||||||
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||||
if (!overWriteEnable)
|
if (!overWriteEnable)
|
||||||
fd = sls::make_unique<H5File>(fileName.c_str(), H5F_ACC_EXCL,
|
fd = make_unique<H5File>(fileName.c_str(), H5F_ACC_EXCL,
|
||||||
FileCreatPropList::DEFAULT, fapl);
|
FileCreatPropList::DEFAULT, fapl);
|
||||||
else
|
else
|
||||||
fd = sls::make_unique<H5File>(fileName.c_str(), H5F_ACC_TRUNC,
|
fd = make_unique<H5File>(fileName.c_str(), H5F_ACC_TRUNC,
|
||||||
FileCreatPropList::DEFAULT, fapl);
|
FileCreatPropList::DEFAULT, fapl);
|
||||||
|
|
||||||
// attributes - version
|
// attributes - version
|
||||||
@ -338,7 +340,7 @@ std::array<std::string, 2> CreateVirtualHDF5File(
|
|||||||
if (fd) {
|
if (fd) {
|
||||||
fd->close();
|
fd->close();
|
||||||
}
|
}
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Could not create/overwrite virtual HDF5 handles");
|
"Could not create/overwrite virtual HDF5 handles");
|
||||||
}
|
}
|
||||||
if (!silentMode) {
|
if (!silentMode) {
|
||||||
@ -349,3 +351,5 @@ std::array<std::string, 2> CreateVirtualHDF5File(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace masterFileUtility
|
} // namespace masterFileUtility
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
#include "MasterAttributes.h"
|
#include "MasterAttributes.h"
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
namespace masterFileUtility {
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
#include "H5Cpp.h"
|
#include "H5Cpp.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -12,7 +16,6 @@ using namespace H5;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace masterFileUtility {
|
|
||||||
|
|
||||||
std::string CreateMasterBinaryFile(const std::string &filePath,
|
std::string CreateMasterBinaryFile(const std::string &filePath,
|
||||||
const std::string &fileNamePrefix,
|
const std::string &fileNamePrefix,
|
||||||
@ -48,3 +51,5 @@ std::array<std::string, 2> CreateVirtualHDF5File(
|
|||||||
bool gotthard25um);
|
bool gotthard25um);
|
||||||
#endif
|
#endif
|
||||||
} // namespace masterFileUtility
|
} // namespace masterFileUtility
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -53,7 +53,7 @@ void printHelp() {
|
|||||||
*/
|
*/
|
||||||
int StartAcq(const std::string &filePath, const std::string &fileName,
|
int StartAcq(const std::string &filePath, const std::string &fileName,
|
||||||
uint64_t fileIndex, size_t imageSize, void *objectPointer) {
|
uint64_t fileIndex, size_t imageSize, void *objectPointer) {
|
||||||
LOG(logINFOBLUE) << "#### StartAcq: filePath:" << filePath
|
LOG(sls::logINFOBLUE) << "#### StartAcq: filePath:" << filePath
|
||||||
<< " fileName:" << fileName << " fileIndex:" << fileIndex
|
<< " fileName:" << fileName << " fileIndex:" << fileIndex
|
||||||
<< " imageSize:" << imageSize << " ####";
|
<< " imageSize:" << imageSize << " ####";
|
||||||
return 0;
|
return 0;
|
||||||
@ -61,7 +61,7 @@ int StartAcq(const std::string &filePath, const std::string &fileName,
|
|||||||
|
|
||||||
/** Acquisition Finished Call back */
|
/** Acquisition Finished Call back */
|
||||||
void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) {
|
void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) {
|
||||||
LOG(logINFOBLUE) << "#### AcquisitionFinished: framesCaught:"
|
LOG(sls::logINFOBLUE) << "#### AcquisitionFinished: framesCaught:"
|
||||||
<< framesCaught << " ####";
|
<< framesCaught << " ####";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ int main(int argc, char *argv[]) {
|
|||||||
try {
|
try {
|
||||||
receiver = sls::make_unique<sls::Receiver>(startTCPPort + i);
|
receiver = sls::make_unique<sls::Receiver>(startTCPPort + i);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LOG(logINFOBLUE)
|
LOG(sls::logINFOBLUE)
|
||||||
<< "Exiting Child Process [ Tid: " << gettid() << " ]";
|
<< "Exiting Child Process [ Tid: " << gettid() << " ]";
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
// gettid added in glibc 2.30
|
// gettid added in glibc 2.30
|
||||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#define gettid() syscall(SYS_gettid)
|
#define gettid() syscall(SYS_gettid)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace sls {
|
|
||||||
|
|
||||||
Receiver::~Receiver() = default;
|
Receiver::~Receiver() = default;
|
||||||
|
|
||||||
Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
||||||
@ -66,7 +66,7 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
|||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
if (sscanf(optarg, "%u", &userid) != 1) {
|
if (sscanf(optarg, "%u", &userid) != 1) {
|
||||||
throw sls::RuntimeError("Could not scan uid");
|
throw RuntimeError("Could not scan uid");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
|||||||
"\t started with privileges. \n\n";
|
"\t started with privileges. \n\n";
|
||||||
|
|
||||||
// std::cout << help_message << std::endl;
|
// std::cout << help_message << std::endl;
|
||||||
throw sls::RuntimeError(help_message);
|
throw RuntimeError(help_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,25 +103,25 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
|||||||
if (seteuid(userid) != 0) {
|
if (seteuid(userid) != 0) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Could not set Effective UID to " << userid;
|
oss << "Could not set Effective UID to " << userid;
|
||||||
throw sls::RuntimeError(oss.str());
|
throw RuntimeError(oss.str());
|
||||||
}
|
}
|
||||||
if (geteuid() != userid) {
|
if (geteuid() != userid) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Could not set Effective UID to " << userid << ". Got "
|
oss << "Could not set Effective UID to " << userid << ". Got "
|
||||||
<< geteuid();
|
<< geteuid();
|
||||||
throw sls::RuntimeError(oss.str());
|
throw RuntimeError(oss.str());
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Process Effective UID changed to " << userid;
|
LOG(logINFO) << "Process Effective UID changed to " << userid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// might throw an exception
|
// might throw an exception
|
||||||
tcpipInterface = sls::make_unique<ClientInterface>(tcpip_port_no);
|
tcpipInterface = make_unique<ClientInterface>(tcpip_port_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
Receiver::Receiver(int tcpip_port_no) {
|
Receiver::Receiver(int tcpip_port_no) {
|
||||||
// might throw an exception
|
// might throw an exception
|
||||||
tcpipInterface = sls::make_unique<ClientInterface>(tcpip_port_no);
|
tcpipInterface = make_unique<ClientInterface>(tcpip_port_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Receiver::getReceiverVersion() {
|
int64_t Receiver::getReceiverVersion() {
|
||||||
|
@ -24,7 +24,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
sem_init(&semaphore, 1, 0);
|
sem_init(&semaphore, 1, 0);
|
||||||
|
|
||||||
LOG(logINFOBLUE) << "Created [ Tid: " << gettid() << " ]";
|
LOG(sls::logINFOBLUE) << "Created [ Tid: " << gettid() << " ]";
|
||||||
|
|
||||||
// Catch signal SIGINT to close files and call destructors properly
|
// Catch signal SIGINT to close files and call destructors properly
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
|
|||||||
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation
|
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation
|
||||||
// of handler
|
// of handler
|
||||||
if (sigaction(SIGINT, &sa, nullptr) == -1) {
|
if (sigaction(SIGINT, &sa, nullptr) == -1) {
|
||||||
LOG(logERROR) << "Could not set handler function for SIGINT";
|
LOG(sls::logERROR) << "Could not set handler function for SIGINT";
|
||||||
}
|
}
|
||||||
|
|
||||||
// if socket crash, ignores SISPIPE, prevents global signal handler
|
// if socket crash, ignores SISPIPE, prevents global signal handler
|
||||||
@ -44,18 +44,18 @@ int main(int argc, char *argv[]) {
|
|||||||
sigemptyset(&asa.sa_mask); // dont block additional signals during
|
sigemptyset(&asa.sa_mask); // dont block additional signals during
|
||||||
// invocation of handler
|
// invocation of handler
|
||||||
if (sigaction(SIGPIPE, &asa, nullptr) == -1) {
|
if (sigaction(SIGPIPE, &asa, nullptr) == -1) {
|
||||||
LOG(logERROR) << "Could not set handler function for SIGPIPE";
|
LOG(sls::logERROR) << "Could not set handler function for SIGPIPE";
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sls::Receiver r(argc, argv);
|
sls::Receiver r(argc, argv);
|
||||||
LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
LOG(sls::logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
||||||
sem_wait(&semaphore);
|
sem_wait(&semaphore);
|
||||||
sem_destroy(&semaphore);
|
sem_destroy(&semaphore);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]";
|
LOG(sls::logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]";
|
||||||
LOG(logINFO) << "Exiting Receiver";
|
LOG(sls::logINFO) << "Exiting Receiver";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
// gettid added in glibc 2.30
|
// gettid added in glibc 2.30
|
||||||
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
@ -23,7 +25,7 @@ ThreadObject::ThreadObject(int threadIndex, std::string threadType)
|
|||||||
try {
|
try {
|
||||||
threadObject = std::thread(&ThreadObject::RunningThread, this);
|
threadObject = std::thread(&ThreadObject::RunningThread, this);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw sls::RuntimeError("Could not create " + type +
|
throw RuntimeError("Could not create " + type +
|
||||||
" thread with index " + std::to_string(index));
|
" thread with index " + std::to_string(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,3 +77,5 @@ void ThreadObject::SetThreadPriority(int priority) {
|
|||||||
LOG(logINFO) << "Priorities set - " << type << ": " << priority;
|
LOG(logINFO) << "Priorities set - " << type << ": " << priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
class ThreadObject : private virtual slsDetectorDefs {
|
class ThreadObject : private virtual slsDetectorDefs {
|
||||||
protected:
|
protected:
|
||||||
const int index{0};
|
const int index{0};
|
||||||
@ -47,3 +49,5 @@ class ThreadObject : private virtual slsDetectorDefs {
|
|||||||
const std::string type;
|
const std::string type;
|
||||||
std::atomic<pid_t> threadId{0};
|
std::atomic<pid_t> threadId{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
#define MAX_DIMENSIONS (2)
|
#define MAX_DIMENSIONS (2)
|
||||||
#define MAX_NUMBER_OF_LISTENING_THREADS (2)
|
#define MAX_NUMBER_OF_LISTENING_THREADS (2)
|
||||||
|
|
||||||
@ -55,3 +57,6 @@
|
|||||||
#define PROCESSOR_PRIORITY (70)
|
#define PROCESSOR_PRIORITY (70)
|
||||||
#define STREAMER_PRIORITY (10)
|
#define STREAMER_PRIORITY (10)
|
||||||
#define TCP_PRIORITY (10)
|
#define TCP_PRIORITY (10)
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -193,7 +193,7 @@ bool operator!=(const std::vector<T> &lhs,
|
|||||||
|
|
||||||
template <typename T, size_t Capacity>
|
template <typename T, size_t Capacity>
|
||||||
std::ostream &operator<<(std::ostream &os,
|
std::ostream &operator<<(std::ostream &os,
|
||||||
const sls::StaticVector<T, Capacity> &c) {
|
const StaticVector<T, Capacity> &c) {
|
||||||
return os << ToString(c);
|
return os << ToString(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ T StringTo(const std::string &t, const std::string &unit) {
|
|||||||
try {
|
try {
|
||||||
tval = std::stod(t);
|
tval = std::stod(t);
|
||||||
} catch (const std::invalid_argument &e) {
|
} catch (const std::invalid_argument &e) {
|
||||||
throw sls::RuntimeError("Could not convert string to time");
|
throw RuntimeError("Could not convert string to time");
|
||||||
}
|
}
|
||||||
|
|
||||||
using std::chrono::duration;
|
using std::chrono::duration;
|
||||||
@ -287,7 +287,7 @@ T StringTo(const std::string &t, const std::string &unit) {
|
|||||||
} else if (unit == "s" || unit.empty()) {
|
} else if (unit == "s" || unit.empty()) {
|
||||||
return duration_cast<T>(std::chrono::duration<double>(tval));
|
return duration_cast<T>(std::chrono::duration<double>(tval));
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Invalid unit in conversion from string to std::chrono::duration");
|
"Invalid unit in conversion from string to std::chrono::duration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,17 +10,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sls/sls_detector_exceptions.h"
|
#include "sls/sls_detector_exceptions.h"
|
||||||
|
#include "sls/container_utils.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <rapidjson/document.h> //json header in zmq stream
|
#include <rapidjson/document.h> //json header in zmq stream
|
||||||
|
#include <zmq.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
#define MAX_STR_LENGTH 1000
|
#define MAX_STR_LENGTH 1000
|
||||||
|
|
||||||
// #define ZMQ_DETAIL
|
// #define ZMQ_DETAIL
|
||||||
#define ROIVERBOSITY
|
#define ROIVERBOSITY
|
||||||
|
|
||||||
class zmq_msg_t;
|
|
||||||
#include "sls/container_utils.h"
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
/** zmq header structure */
|
/** zmq header structure */
|
||||||
struct zmqHeader {
|
struct zmqHeader {
|
||||||
/** true if incoming data, false if end of acquisition */
|
/** true if incoming data, false if end of acquisition */
|
||||||
@ -222,5 +225,7 @@ class ZmqSocket {
|
|||||||
mySocketDescriptors sockfd;
|
mySocketDescriptors sockfd;
|
||||||
|
|
||||||
std::unique_ptr<char[]> header_buffer =
|
std::unique_ptr<char[]> header_buffer =
|
||||||
sls::make_unique<char[]>(MAX_STR_LENGTH);
|
make_unique<char[]>(MAX_STR_LENGTH);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
enum TLogLevel {
|
enum TLogLevel {
|
||||||
logERROR,
|
logERROR,
|
||||||
logWARNING,
|
logWARNING,
|
||||||
@ -25,7 +27,7 @@ enum TLogLevel {
|
|||||||
|
|
||||||
// Compiler should optimize away anything below this value
|
// Compiler should optimize away anything below this value
|
||||||
#ifndef LOG_MAX_REPORTING_LEVEL
|
#ifndef LOG_MAX_REPORTING_LEVEL
|
||||||
#define LOG_MAX_REPORTING_LEVEL logINFO
|
#define LOG_MAX_REPORTING_LEVEL sls::logINFO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __AT__ \
|
#define __AT__ \
|
||||||
@ -37,7 +39,6 @@ enum TLogLevel {
|
|||||||
std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + \
|
std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + \
|
||||||
std::string(__func__) + std::string("(): ")
|
std::string(__func__) + std::string("(): ")
|
||||||
|
|
||||||
namespace sls {
|
|
||||||
class Logger {
|
class Logger {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
TLogLevel level = LOG_MAX_REPORTING_LEVEL;
|
TLogLevel level = LOG_MAX_REPORTING_LEVEL;
|
||||||
|
@ -93,7 +93,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
|||||||
Receive(retval, retval_size);
|
Receive(retval, retval_size);
|
||||||
}
|
}
|
||||||
// debugging
|
// debugging
|
||||||
catch (sls::SocketError &e) {
|
catch (SocketError &e) {
|
||||||
if (socketType == "Receiver") {
|
if (socketType == "Receiver") {
|
||||||
throw ReceiverError("Receiver returned: " + std::string(e.what()));
|
throw ReceiverError("Receiver returned: " + std::string(e.what()));
|
||||||
} else if (socketType == "Detector") {
|
} else if (socketType == "Detector") {
|
||||||
|
@ -65,7 +65,7 @@ int DataSocket::Receive(void *buffer, size_t size) {
|
|||||||
ss << "TCP socket read " << bytes_read << " bytes instead of "
|
ss << "TCP socket read " << bytes_read << " bytes instead of "
|
||||||
<< bytes_expected << " bytes ("
|
<< bytes_expected << " bytes ("
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
|
||||||
throw sls::SocketError(ss.str());
|
throw SocketError(ss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ int DataSocket::Send(const void *buffer, size_t size) {
|
|||||||
ss << "TCP socket sent " << bytes_sent << " bytes instead of "
|
ss << "TCP socket sent " << bytes_sent << " bytes instead of "
|
||||||
<< data_size << " bytes ("
|
<< data_size << " bytes ("
|
||||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
|
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
|
||||||
throw sls::SocketError(ss.str());
|
throw SocketError(ss.str());
|
||||||
}
|
}
|
||||||
return bytes_sent;
|
return bytes_sent;
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
#define DEFAULT_PACKET_SIZE 1286
|
#define DEFAULT_PACKET_SIZE 1286
|
||||||
#define SOCKET_BUFFER_SIZE (100 * 1024 * 1024) // 100 MB
|
#define SOCKET_BUFFER_SIZE (100 * 1024 * 1024) // 100 MB
|
||||||
#define DEFAULT_BACKLOG 5
|
#define DEFAULT_BACKLOG 5
|
||||||
|
|
||||||
namespace sls {
|
|
||||||
|
|
||||||
ServerSocket::ServerSocket(int port)
|
ServerSocket::ServerSocket(int port)
|
||||||
: DataSocket(socket(AF_INET, SOCK_STREAM, 0)), serverPort(port) {
|
: DataSocket(socket(AF_INET, SOCK_STREAM, 0)), serverPort(port) {
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ ServerSocket::ServerSocket(int port)
|
|||||||
if (bind(getSocketId(), (struct sockaddr *)&serverAddr,
|
if (bind(getSocketId(), (struct sockaddr *)&serverAddr,
|
||||||
sizeof(serverAddr)) != 0) {
|
sizeof(serverAddr)) != 0) {
|
||||||
close();
|
close();
|
||||||
throw sls::SocketError(
|
throw SocketError(
|
||||||
std::string("Server ERROR: cannot bind socket with port number ") +
|
std::string("Server ERROR: cannot bind socket with port number ") +
|
||||||
std::to_string(port) +
|
std::to_string(port) +
|
||||||
std::string(". Please check if another instance is running."));
|
std::string(". Please check if another instance is running."));
|
||||||
@ -49,7 +51,7 @@ ServerInterface ServerSocket::accept() {
|
|||||||
int newSocket =
|
int newSocket =
|
||||||
::accept(getSocketId(), (struct sockaddr *)&clientAddr, &addr_size);
|
::accept(getSocketId(), (struct sockaddr *)&clientAddr, &addr_size);
|
||||||
if (newSocket == -1) {
|
if (newSocket == -1) {
|
||||||
throw sls::SocketError("Server ERROR: socket accept failed\n");
|
throw SocketError("Server ERROR: socket accept failed\n");
|
||||||
}
|
}
|
||||||
char tc[INET_ADDRSTRLEN]{};
|
char tc[INET_ADDRSTRLEN]{};
|
||||||
inet_ntop(AF_INET, &(clientAddr.sin_addr), tc, INET_ADDRSTRLEN);
|
inet_ntop(AF_INET, &(clientAddr.sin_addr), tc, INET_ADDRSTRLEN);
|
||||||
|
@ -38,11 +38,11 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
|
|||||||
<< "hostname:" << r.hostname << std::endl
|
<< "hostname:" << r.hostname << std::endl
|
||||||
<< "udpInterfaces:" << r.udpInterfaces << std::endl
|
<< "udpInterfaces:" << r.udpInterfaces << std::endl
|
||||||
<< "udp_dstport:" << r.udp_dstport << std::endl
|
<< "udp_dstport:" << r.udp_dstport << std::endl
|
||||||
<< "udp_dstip:" << sls::IpAddr(r.udp_dstip) << std::endl
|
<< "udp_dstip:" << IpAddr(r.udp_dstip) << std::endl
|
||||||
<< "udp_dstmac:" << sls::MacAddr(r.udp_dstmac) << std::endl
|
<< "udp_dstmac:" << MacAddr(r.udp_dstmac) << std::endl
|
||||||
<< "udp_dstport2:" << r.udp_dstport2 << std::endl
|
<< "udp_dstport2:" << r.udp_dstport2 << std::endl
|
||||||
<< "udp_dstip2:" << sls::IpAddr(r.udp_dstip2) << std::endl
|
<< "udp_dstip2:" << IpAddr(r.udp_dstip2) << std::endl
|
||||||
<< "udp_dstmac2:" << sls::MacAddr(r.udp_dstmac2) << std::endl
|
<< "udp_dstmac2:" << MacAddr(r.udp_dstmac2) << std::endl
|
||||||
<< "frames:" << r.frames << std::endl
|
<< "frames:" << r.frames << std::endl
|
||||||
<< "triggers:" << r.triggers << std::endl
|
<< "triggers:" << r.triggers << std::endl
|
||||||
<< "bursts:" << r.bursts << std::endl
|
<< "bursts:" << r.bursts << std::endl
|
||||||
@ -86,7 +86,7 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
|
|||||||
<< "gateDelay3:" << ToString(std::chrono::nanoseconds(r.gateDelay3Ns))
|
<< "gateDelay3:" << ToString(std::chrono::nanoseconds(r.gateDelay3Ns))
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< "gates:" << r.gates << std::endl
|
<< "gates:" << r.gates << std::endl
|
||||||
<< "scanParams:" << sls::ToString(r.scanParams) << std::endl
|
<< "scanParams:" << ToString(r.scanParams) << std::endl
|
||||||
<< ']';
|
<< ']';
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ std::ostream &operator<<(std::ostream &os,
|
|||||||
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
|
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if (r.fix < -1 || r.fix > 1 || r.normal < -1 || r.normal > 1) {
|
if (r.fix < -1 || r.fix > 1 || r.normal < -1 || r.normal > 1) {
|
||||||
throw sls::RuntimeError(
|
throw RuntimeError(
|
||||||
"Invalid current source parameters. Cannot print.");
|
"Invalid current source parameters. Cannot print.");
|
||||||
}
|
}
|
||||||
oss << '[';
|
oss << '[';
|
||||||
@ -674,7 +674,7 @@ template <> defs::detectorType StringTo(const std::string &s) {
|
|||||||
return defs::MYTHEN3;
|
return defs::MYTHEN3;
|
||||||
if (s == "Gotthard2")
|
if (s == "Gotthard2")
|
||||||
return defs::GOTTHARD2;
|
return defs::GOTTHARD2;
|
||||||
throw sls::RuntimeError("Unknown detector type " + s);
|
throw RuntimeError("Unknown detector type " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::detectorSettings StringTo(const std::string &s) {
|
template <> defs::detectorSettings StringTo(const std::string &s) {
|
||||||
@ -718,7 +718,7 @@ template <> defs::detectorSettings StringTo(const std::string &s) {
|
|||||||
return defs::GAIN0;
|
return defs::GAIN0;
|
||||||
if (s == "g4_lg")
|
if (s == "g4_lg")
|
||||||
return defs::G4_LOWGAIN;
|
return defs::G4_LOWGAIN;
|
||||||
throw sls::RuntimeError("Unknown setting " + s);
|
throw RuntimeError("Unknown setting " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::speedLevel StringTo(const std::string &s) {
|
template <> defs::speedLevel StringTo(const std::string &s) {
|
||||||
@ -738,7 +738,7 @@ template <> defs::speedLevel StringTo(const std::string &s) {
|
|||||||
return defs::G2_108MHZ;
|
return defs::G2_108MHZ;
|
||||||
if (s == "144")
|
if (s == "144")
|
||||||
return defs::G2_144MHZ;
|
return defs::G2_144MHZ;
|
||||||
throw sls::RuntimeError("Unknown speed " + s);
|
throw RuntimeError("Unknown speed " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::timingMode StringTo(const std::string &s) {
|
template <> defs::timingMode StringTo(const std::string &s) {
|
||||||
@ -752,7 +752,7 @@ template <> defs::timingMode StringTo(const std::string &s) {
|
|||||||
return defs::BURST_TRIGGER;
|
return defs::BURST_TRIGGER;
|
||||||
if (s == "trigger_gating")
|
if (s == "trigger_gating")
|
||||||
return defs::TRIGGER_GATED;
|
return defs::TRIGGER_GATED;
|
||||||
throw sls::RuntimeError("Unknown timing mode " + s);
|
throw RuntimeError("Unknown timing mode " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::frameDiscardPolicy StringTo(const std::string &s) {
|
template <> defs::frameDiscardPolicy StringTo(const std::string &s) {
|
||||||
@ -762,7 +762,7 @@ template <> defs::frameDiscardPolicy StringTo(const std::string &s) {
|
|||||||
return defs::DISCARD_EMPTY_FRAMES;
|
return defs::DISCARD_EMPTY_FRAMES;
|
||||||
if (s == "discardpartial")
|
if (s == "discardpartial")
|
||||||
return defs::DISCARD_PARTIAL_FRAMES;
|
return defs::DISCARD_PARTIAL_FRAMES;
|
||||||
throw sls::RuntimeError("Unknown frame discard policy " + s);
|
throw RuntimeError("Unknown frame discard policy " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::fileFormat StringTo(const std::string &s) {
|
template <> defs::fileFormat StringTo(const std::string &s) {
|
||||||
@ -770,7 +770,7 @@ template <> defs::fileFormat StringTo(const std::string &s) {
|
|||||||
return defs::HDF5;
|
return defs::HDF5;
|
||||||
if (s == "binary")
|
if (s == "binary")
|
||||||
return defs::BINARY;
|
return defs::BINARY;
|
||||||
throw sls::RuntimeError("Unknown file format " + s);
|
throw RuntimeError("Unknown file format " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::externalSignalFlag StringTo(const std::string &s) {
|
template <> defs::externalSignalFlag StringTo(const std::string &s) {
|
||||||
@ -782,7 +782,7 @@ template <> defs::externalSignalFlag StringTo(const std::string &s) {
|
|||||||
return defs::INVERSION_ON;
|
return defs::INVERSION_ON;
|
||||||
if (s == "inversion_off")
|
if (s == "inversion_off")
|
||||||
return defs::INVERSION_OFF;
|
return defs::INVERSION_OFF;
|
||||||
throw sls::RuntimeError("Unknown external signal flag " + s);
|
throw RuntimeError("Unknown external signal flag " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::readoutMode StringTo(const std::string &s) {
|
template <> defs::readoutMode StringTo(const std::string &s) {
|
||||||
@ -792,7 +792,7 @@ template <> defs::readoutMode StringTo(const std::string &s) {
|
|||||||
return defs::DIGITAL_ONLY;
|
return defs::DIGITAL_ONLY;
|
||||||
if (s == "analog_digital")
|
if (s == "analog_digital")
|
||||||
return defs::ANALOG_AND_DIGITAL;
|
return defs::ANALOG_AND_DIGITAL;
|
||||||
throw sls::RuntimeError("Unknown readout mode " + s);
|
throw RuntimeError("Unknown readout mode " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::dacIndex StringTo(const std::string &s) {
|
template <> defs::dacIndex StringTo(const std::string &s) {
|
||||||
@ -982,7 +982,7 @@ template <> defs::dacIndex StringTo(const std::string &s) {
|
|||||||
return defs::TEMPERATURE_FPGA3;
|
return defs::TEMPERATURE_FPGA3;
|
||||||
if (s == "temp_slowadc")
|
if (s == "temp_slowadc")
|
||||||
return defs::SLOW_ADC_TEMP;
|
return defs::SLOW_ADC_TEMP;
|
||||||
throw sls::RuntimeError("Unknown dac Index " + s);
|
throw RuntimeError("Unknown dac Index " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::burstMode StringTo(const std::string &s) {
|
template <> defs::burstMode StringTo(const std::string &s) {
|
||||||
@ -994,7 +994,7 @@ template <> defs::burstMode StringTo(const std::string &s) {
|
|||||||
return defs::CONTINUOUS_INTERNAL;
|
return defs::CONTINUOUS_INTERNAL;
|
||||||
if (s == "cw_external")
|
if (s == "cw_external")
|
||||||
return defs::CONTINUOUS_EXTERNAL;
|
return defs::CONTINUOUS_EXTERNAL;
|
||||||
throw sls::RuntimeError("Unknown burst mode " + s);
|
throw RuntimeError("Unknown burst mode " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::timingSourceType StringTo(const std::string &s) {
|
template <> defs::timingSourceType StringTo(const std::string &s) {
|
||||||
@ -1002,7 +1002,7 @@ template <> defs::timingSourceType StringTo(const std::string &s) {
|
|||||||
return defs::TIMING_INTERNAL;
|
return defs::TIMING_INTERNAL;
|
||||||
if (s == "external")
|
if (s == "external")
|
||||||
return defs::TIMING_EXTERNAL;
|
return defs::TIMING_EXTERNAL;
|
||||||
throw sls::RuntimeError("Unknown timing source type " + s);
|
throw RuntimeError("Unknown timing source type " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::M3_GainCaps StringTo(const std::string &s) {
|
template <> defs::M3_GainCaps StringTo(const std::string &s) {
|
||||||
@ -1018,7 +1018,7 @@ template <> defs::M3_GainCaps StringTo(const std::string &s) {
|
|||||||
return defs::M3_C225ACsh;
|
return defs::M3_C225ACsh;
|
||||||
if (s == "C15pre")
|
if (s == "C15pre")
|
||||||
return defs::M3_C15pre;
|
return defs::M3_C15pre;
|
||||||
throw sls::RuntimeError("Unknown gain cap " + s);
|
throw RuntimeError("Unknown gain cap " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::portPosition StringTo(const std::string &s) {
|
template <> defs::portPosition StringTo(const std::string &s) {
|
||||||
@ -1030,7 +1030,7 @@ template <> defs::portPosition StringTo(const std::string &s) {
|
|||||||
return defs::TOP;
|
return defs::TOP;
|
||||||
if (s == "bottom")
|
if (s == "bottom")
|
||||||
return defs::BOTTOM;
|
return defs::BOTTOM;
|
||||||
throw sls::RuntimeError("Unknown port position " + s);
|
throw RuntimeError("Unknown port position " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::streamingInterface StringTo(const std::string &s) {
|
template <> defs::streamingInterface StringTo(const std::string &s) {
|
||||||
@ -1043,7 +1043,7 @@ template <> defs::streamingInterface StringTo(const std::string &s) {
|
|||||||
return defs::streamingInterface::LOW_LATENCY_LINK;
|
return defs::streamingInterface::LOW_LATENCY_LINK;
|
||||||
if (rs == "10gbe")
|
if (rs == "10gbe")
|
||||||
return defs::streamingInterface::ETHERNET_10GB;
|
return defs::streamingInterface::ETHERNET_10GB;
|
||||||
throw sls::RuntimeError("Unknown streamingInterface type " + s);
|
throw RuntimeError("Unknown streamingInterface type " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::vetoAlgorithm StringTo(const std::string &s) {
|
template <> defs::vetoAlgorithm StringTo(const std::string &s) {
|
||||||
@ -1051,7 +1051,7 @@ template <> defs::vetoAlgorithm StringTo(const std::string &s) {
|
|||||||
return defs::ALG_HITS;
|
return defs::ALG_HITS;
|
||||||
if (s == "raw")
|
if (s == "raw")
|
||||||
return defs::ALG_RAW;
|
return defs::ALG_RAW;
|
||||||
throw sls::RuntimeError("Unknown veto algorithm " + s);
|
throw RuntimeError("Unknown veto algorithm " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::gainMode StringTo(const std::string &s) {
|
template <> defs::gainMode StringTo(const std::string &s) {
|
||||||
@ -1067,7 +1067,7 @@ template <> defs::gainMode StringTo(const std::string &s) {
|
|||||||
return defs::FIX_G2;
|
return defs::FIX_G2;
|
||||||
if (s == "fixg0")
|
if (s == "fixg0")
|
||||||
return defs::FIX_G0;
|
return defs::FIX_G0;
|
||||||
throw sls::RuntimeError("Unknown gain mode " + s);
|
throw RuntimeError("Unknown gain mode " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> defs::polarity StringTo(const std::string &s) {
|
template <> defs::polarity StringTo(const std::string &s) {
|
||||||
@ -1075,7 +1075,7 @@ template <> defs::polarity StringTo(const std::string &s) {
|
|||||||
return defs::POSITIVE;
|
return defs::POSITIVE;
|
||||||
if (s == "neg")
|
if (s == "neg")
|
||||||
return defs::NEGATIVE;
|
return defs::NEGATIVE;
|
||||||
throw sls::RuntimeError("Unknown polarity mode " + s);
|
throw RuntimeError("Unknown polarity mode " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> uint32_t StringTo(const std::string &s) {
|
template <> uint32_t StringTo(const std::string &s) {
|
||||||
@ -1101,7 +1101,7 @@ template <> bool StringTo(const std::string &s) {
|
|||||||
case 1:
|
case 1:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
throw sls::RuntimeError("Unknown boolean. Expecting be 0 or 1.");
|
throw RuntimeError("Unknown boolean. Expecting be 0 or 1.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,14 +10,15 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <zmq.h>
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
|
ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
|
||||||
const uint32_t portnumber)
|
const uint32_t portnumber)
|
||||||
: portno(portnumber), sockfd(false) {
|
: portno(portnumber), sockfd(false) {
|
||||||
// Extra check that throws if conversion fails, could be removed
|
// Extra check that throws if conversion fails, could be removed
|
||||||
auto ipstr = sls::HostnameToIp(hostname_or_ip).str();
|
auto ipstr = HostnameToIp(hostname_or_ip).str();
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "tcp://" << ipstr << ":" << portno;
|
oss << "tcp://" << ipstr << ":" << portno;
|
||||||
sockfd.serverAddress = oss.str();
|
sockfd.serverAddress = oss.str();
|
||||||
@ -26,20 +27,20 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
|
|||||||
// create context
|
// create context
|
||||||
sockfd.contextDescriptor = zmq_ctx_new();
|
sockfd.contextDescriptor = zmq_ctx_new();
|
||||||
if (sockfd.contextDescriptor == nullptr)
|
if (sockfd.contextDescriptor == nullptr)
|
||||||
throw sls::ZmqSocketError("Could not create contextDescriptor");
|
throw ZmqSocketError("Could not create contextDescriptor");
|
||||||
|
|
||||||
// create subscriber
|
// create subscriber
|
||||||
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_SUB);
|
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_SUB);
|
||||||
if (sockfd.socketDescriptor == nullptr) {
|
if (sockfd.socketDescriptor == nullptr) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could not create socket");
|
throw ZmqSocketError("Could not create socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Socket Options provided above
|
// Socket Options provided above
|
||||||
// an empty string implies receiving any messages
|
// an empty string implies receiving any messages
|
||||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) {
|
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could set socket opt");
|
throw ZmqSocketError("Could set socket opt");
|
||||||
}
|
}
|
||||||
// ZMQ_LINGER default is already -1 means no messages discarded. use this
|
// ZMQ_LINGER default is already -1 means no messages discarded. use this
|
||||||
// options if optimizing required ZMQ_SNDHWM default is 0 means no limit.
|
// options if optimizing required ZMQ_SNDHWM default is 0 means no limit.
|
||||||
@ -48,7 +49,7 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
|
|||||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_LINGER, &value,
|
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_LINGER, &value,
|
||||||
sizeof(value))) {
|
sizeof(value))) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could not set ZMQ_LINGER");
|
throw ZmqSocketError("Could not set ZMQ_LINGER");
|
||||||
}
|
}
|
||||||
LOG(logDEBUG) << "Default receive high water mark:"
|
LOG(logDEBUG) << "Default receive high water mark:"
|
||||||
<< GetReceiveHighWaterMark();
|
<< GetReceiveHighWaterMark();
|
||||||
@ -59,13 +60,13 @@ ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip)
|
|||||||
// create context
|
// create context
|
||||||
sockfd.contextDescriptor = zmq_ctx_new();
|
sockfd.contextDescriptor = zmq_ctx_new();
|
||||||
if (sockfd.contextDescriptor == nullptr)
|
if (sockfd.contextDescriptor == nullptr)
|
||||||
throw sls::ZmqSocketError("Could not create contextDescriptor");
|
throw ZmqSocketError("Could not create contextDescriptor");
|
||||||
|
|
||||||
// create publisher
|
// create publisher
|
||||||
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_PUB);
|
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_PUB);
|
||||||
if (sockfd.socketDescriptor == nullptr) {
|
if (sockfd.socketDescriptor == nullptr) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could not create socket");
|
throw ZmqSocketError("Could not create socket");
|
||||||
}
|
}
|
||||||
LOG(logDEBUG) << "Default send high water mark:" << GetSendHighWaterMark();
|
LOG(logDEBUG) << "Default send high water mark:" << GetSendHighWaterMark();
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip)
|
|||||||
// bind address
|
// bind address
|
||||||
if (zmq_bind(sockfd.socketDescriptor, sockfd.serverAddress.c_str())) {
|
if (zmq_bind(sockfd.socketDescriptor, sockfd.serverAddress.c_str())) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could not bind socket");
|
throw ZmqSocketError("Could not bind socket");
|
||||||
}
|
}
|
||||||
// sleep to allow a slow-joiner
|
// sleep to allow a slow-joiner
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
@ -90,7 +91,7 @@ int ZmqSocket::GetSendHighWaterMark() {
|
|||||||
if (zmq_getsockopt(sockfd.socketDescriptor, ZMQ_SNDHWM, &value,
|
if (zmq_getsockopt(sockfd.socketDescriptor, ZMQ_SNDHWM, &value,
|
||||||
&value_size)) {
|
&value_size)) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could not get ZMQ_SNDHWM");
|
throw ZmqSocketError("Could not get ZMQ_SNDHWM");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -99,7 +100,7 @@ void ZmqSocket::SetSendHighWaterMark(int limit) {
|
|||||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SNDHWM, &limit,
|
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SNDHWM, &limit,
|
||||||
sizeof(limit))) {
|
sizeof(limit))) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could not set ZMQ_SNDHWM");
|
throw ZmqSocketError("Could not set ZMQ_SNDHWM");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ int ZmqSocket::GetReceiveHighWaterMark() {
|
|||||||
if (zmq_getsockopt(sockfd.socketDescriptor, ZMQ_RCVHWM, &value,
|
if (zmq_getsockopt(sockfd.socketDescriptor, ZMQ_RCVHWM, &value,
|
||||||
&value_size)) {
|
&value_size)) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could not get ZMQ_SNDHWM");
|
throw ZmqSocketError("Could not get ZMQ_SNDHWM");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -118,7 +119,7 @@ void ZmqSocket::SetReceiveHighWaterMark(int limit) {
|
|||||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_RCVHWM, &limit,
|
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_RCVHWM, &limit,
|
||||||
sizeof(limit))) {
|
sizeof(limit))) {
|
||||||
PrintError();
|
PrintError();
|
||||||
throw sls::ZmqSocketError("Could not set ZMQ_SNDHWM");
|
throw ZmqSocketError("Could not set ZMQ_SNDHWM");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,3 +415,6 @@ void ZmqSocket::mySocketDescriptors::Close() {
|
|||||||
contextDescriptor = nullptr;
|
contextDescriptor = nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
||||||
|
|
||||||
|
@ -60,28 +60,28 @@ std::vector<char> readBinaryFile(const std::string &fname,
|
|||||||
// check if it exists
|
// check if it exists
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(fname.c_str(), &st) != 0) {
|
if (stat(fname.c_str(), &st) != 0) {
|
||||||
throw sls::RuntimeError(errorPrefix +
|
throw RuntimeError(errorPrefix +
|
||||||
std::string(" (file does not exist)"));
|
std::string(" (file does not exist)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fp = fopen(fname.c_str(), "rb");
|
FILE *fp = fopen(fname.c_str(), "rb");
|
||||||
if (fp == nullptr) {
|
if (fp == nullptr) {
|
||||||
throw sls::RuntimeError(errorPrefix +
|
throw RuntimeError(errorPrefix +
|
||||||
std::string(" (Could not open file: ") + fname +
|
std::string(" (Could not open file: ") + fname +
|
||||||
std::string(")"));
|
std::string(")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get file size to print progress
|
// get file size to print progress
|
||||||
ssize_t filesize = sls::getFileSize(fp, errorPrefix);
|
ssize_t filesize = getFileSize(fp, errorPrefix);
|
||||||
|
|
||||||
std::vector<char> buffer(filesize, 0);
|
std::vector<char> buffer(filesize, 0);
|
||||||
if ((ssize_t)fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
|
if ((ssize_t)fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
|
||||||
throw sls::RuntimeError(errorPrefix +
|
throw RuntimeError(errorPrefix +
|
||||||
std::string(" (Could not read file)"));
|
std::string(" (Could not read file)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fclose(fp) != 0) {
|
if (fclose(fp) != 0) {
|
||||||
throw sls::RuntimeError(errorPrefix +
|
throw RuntimeError(errorPrefix +
|
||||||
std::string(" (Could not close file)"));
|
std::string(" (Could not close file)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ void mkdir_p(const std::string &path, std::string dir) {
|
|||||||
}
|
}
|
||||||
if (mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
if (mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
||||||
if (errno != EEXIST)
|
if (errno != EEXIST)
|
||||||
throw sls::RuntimeError("Could not create: " + dir);
|
throw RuntimeError("Could not create: " + dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i + 1 < path.length())
|
if (i + 1 < path.length())
|
||||||
|
Reference in New Issue
Block a user