mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 18:40:42 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
409a3977db
@ -83,6 +83,11 @@ This document describes the differences between v7.0.0 and v6.x.x
|
|||||||
-udp_srcip and udp_Srcip2: can set to auto (for virtual or 1g data networks)
|
-udp_srcip and udp_Srcip2: can set to auto (for virtual or 1g data networks)
|
||||||
- set dataset name for all hdf5 files to "data" only
|
- set dataset name for all hdf5 files to "data" only
|
||||||
- number of storage cells is not updated in teh receiver. done. and also allowing it to be modified in running status
|
- number of storage cells is not updated in teh receiver. done. and also allowing it to be modified in running status
|
||||||
|
- refactored memory structure in receiver and listener code (maybe resolves stuck issue, need to check)
|
||||||
|
- callback modified to have rx header and not rx header pointer
|
||||||
|
- rx udp socket refactored (maybe resolves getting stuck?)remove check for eiger header and isntead checks for malformed packets for every detector
|
||||||
|
-help should not create a new object
|
||||||
|
|
||||||
|
|
||||||
2. Resolved Issues
|
2. Resolved Issues
|
||||||
==================
|
==================
|
||||||
|
@ -106,4 +106,3 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8de7772cc72daca8e947b79b83fea46214931604
|
Subproject commit 914c06fb252b6cc3727d0eedab6736e88a3fcb01
|
@ -8,8 +8,8 @@
|
|||||||
#include <qwt_plot.h>
|
#include <qwt_plot.h>
|
||||||
#include <qwt_plot_curve.h>
|
#include <qwt_plot_curve.h>
|
||||||
#include <qwt_plot_marker.h>
|
#include <qwt_plot_marker.h>
|
||||||
#include <qwt_scale_div.h>
|
|
||||||
#include <qwt_plot_shapeitem.h>
|
#include <qwt_plot_shapeitem.h>
|
||||||
|
#include <qwt_scale_div.h>
|
||||||
|
|
||||||
class QPen;
|
class QPen;
|
||||||
class QwtSymbol;
|
class QwtSymbol;
|
||||||
@ -176,5 +176,3 @@ class SlsQt1DPlot : public QwtPlot {
|
|||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#include "SlsQt2DZoomer.h"
|
#include "SlsQt2DZoomer.h"
|
||||||
#include <qlist.h>
|
#include <qlist.h>
|
||||||
#include <qwt_plot.h>
|
#include <qwt_plot.h>
|
||||||
#include <qwt_plot_spectrogram.h>
|
|
||||||
#include <qwt_plot_shapeitem.h>
|
#include <qwt_plot_shapeitem.h>
|
||||||
|
#include <qwt_plot_spectrogram.h>
|
||||||
|
|
||||||
class QwtPlotPanner;
|
class QwtPlotPanner;
|
||||||
class QwtScaleWidget;
|
class QwtScaleWidget;
|
||||||
|
@ -444,7 +444,6 @@ void SlsQt1DPlot::SetLog(int axisId, bool yes) {
|
|||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SlsQt1DPlot::EnableRoiBox(std::array<int, 4> roi) {
|
void SlsQt1DPlot::EnableRoiBox(std::array<int, 4> roi) {
|
||||||
if (roiBox == nullptr) {
|
if (roiBox == nullptr) {
|
||||||
roiBox = new QwtPlotShapeItem();
|
roiBox = new QwtPlotShapeItem();
|
||||||
@ -465,7 +464,6 @@ void SlsQt1DPlot::DisableRoiBox() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SlsQt1DPlot::UnZoom() {
|
void SlsQt1DPlot::UnZoom() {
|
||||||
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
|
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
|
||||||
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
|
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
|
||||||
|
@ -59,7 +59,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
fname = optarg;
|
fname = optarg;
|
||||||
LOG(sls::logDEBUG) << long_options[option_index].name << " " << optarg;
|
LOG(sls::logDEBUG)
|
||||||
|
<< long_options[option_index].name << " " << optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
@ -101,7 +102,8 @@ int main(int argc, char **argv) {
|
|||||||
app.exec();
|
app.exec();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
sls::qDefs::Message(sls::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;
|
||||||
}
|
}
|
||||||
@ -243,16 +245,14 @@ 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 "
|
||||||
<< ToString(det->getDetectorType().squash())
|
<< ToString(det->getDetectorType().squash()) << " detector type ("
|
||||||
<< " detector type (" << std::to_string(detType)
|
<< std::to_string(detType) << "). Exiting GUI.";
|
||||||
<< "). Exiting GUI.";
|
|
||||||
std::string errorMess = os.str();
|
std::string errorMess = os.str();
|
||||||
throw RuntimeError(errorMess.c_str());
|
throw RuntimeError(errorMess.c_str());
|
||||||
}
|
}
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "SLS Detector GUI : "
|
os << "SLS Detector GUI : " << 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;
|
||||||
setWindowTitle(QString(title.c_str()));
|
setWindowTitle(QString(title.c_str()));
|
||||||
@ -344,7 +344,8 @@ void qDetectorMain::EnableModes(QAction *action) {
|
|||||||
enable = actionExpert->isChecked();
|
enable = actionExpert->isChecked();
|
||||||
|
|
||||||
tabs->setTabEnabled(ADVANCED, enable);
|
tabs->setTabEnabled(ADVANCED, enable);
|
||||||
bool visible = enable && (detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::MYTHEN3);
|
bool visible = enable && (detType == slsDetectorDefs::EIGER ||
|
||||||
|
detType == slsDetectorDefs::MYTHEN3);
|
||||||
actionLoadTrimbits->setVisible(visible);
|
actionLoadTrimbits->setVisible(visible);
|
||||||
actionSaveTrimbits->setVisible(visible);
|
actionSaveTrimbits->setVisible(visible);
|
||||||
tabSettings->SetExportMode(enable);
|
tabSettings->SetExportMode(enable);
|
||||||
|
@ -628,7 +628,6 @@ void qDrawPlot::SetGapPixels(bool enable) {
|
|||||||
isGapPixels = enable;
|
isGapPixels = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void qDrawPlot::GetStatistics(double &min, double &max, double &sum) {
|
void qDrawPlot::GetStatistics(double &min, double &max, double &sum) {
|
||||||
LOG(logDEBUG) << "Calculating Statistics";
|
LOG(logDEBUG) << "Calculating Statistics";
|
||||||
double *array = data2d;
|
double *array = data2d;
|
||||||
@ -782,12 +781,12 @@ 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: " << ToString(rxRoi);
|
LOG(logINFO) << "Rx_roi recalculated with gap pixels: "
|
||||||
|
<< ToString(rxRoi);
|
||||||
}
|
}
|
||||||
LOG(logDEBUG) << "Rx_roi: " << ToString(rxRoi);
|
LOG(logDEBUG) << "Rx_roi: " << ToString(rxRoi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 1d check if npixelX has changed (m3 for different counters enabled)
|
// 1d check if npixelX has changed (m3 for different counters enabled)
|
||||||
if (is1d && static_cast<int>(nPixelsX) != data->nx) {
|
if (is1d && static_cast<int>(nPixelsX) != data->nx) {
|
||||||
nPixelsX = data->nx;
|
nPixelsX = data->nx;
|
||||||
@ -1034,16 +1033,21 @@ void qDrawPlot::Update1dPlot() {
|
|||||||
}
|
}
|
||||||
lblRxRoiEnabled->hide();
|
lblRxRoiEnabled->hide();
|
||||||
} else {
|
} else {
|
||||||
plot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax, (int)plot1d->GetYMinimum(), (int)plot1d->GetYMaximum()});
|
plot1d->EnableRoiBox(std::array<int, 4>{
|
||||||
|
rxRoi.xmin, rxRoi.xmax, (int)plot1d->GetYMinimum(),
|
||||||
|
(int)plot1d->GetYMaximum()});
|
||||||
if (isGainDataExtracted) {
|
if (isGainDataExtracted) {
|
||||||
gainplot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax, 0, 3});
|
gainplot1d->EnableRoiBox(
|
||||||
|
std::array<int, 4>{rxRoi.xmin, rxRoi.xmax, 0, 3});
|
||||||
}
|
}
|
||||||
lblRxRoiEnabled->show();
|
lblRxRoiEnabled->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ymin and ymax could change (so replot roi every time)
|
// ymin and ymax could change (so replot roi every time)
|
||||||
if (!rxRoi.completeRoi()) {
|
if (!rxRoi.completeRoi()) {
|
||||||
plot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax, (int)plot1d->GetYMinimum(), (int)plot1d->GetYMaximum()});
|
plot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax,
|
||||||
|
(int)plot1d->GetYMinimum(),
|
||||||
|
(int)plot1d->GetYMaximum()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
qTabAdvanced::qTabAdvanced(QWidget *parent, Detector *detector,
|
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);
|
||||||
SetupWidgetWindow();
|
SetupWidgetWindow();
|
||||||
@ -445,8 +444,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(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.",
|
||||||
"qTabAdvanced::SetDetectorUDPIP", this,
|
"qTabAdvanced::SetDetectorUDPIP", this,
|
||||||
@ -463,8 +461,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(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.",
|
||||||
"qTabAdvanced::SetDetectorUDPMAC", this,
|
"qTabAdvanced::SetDetectorUDPMAC", this,
|
||||||
@ -491,8 +488,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(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.",
|
||||||
"qTabAdvanced::SetCltZMQIP", this,
|
"qTabAdvanced::SetCltZMQIP", this,
|
||||||
|
@ -255,7 +255,8 @@ void qTabSettings::GetHighVoltage() {
|
|||||||
master_retvals.push_back(retvals[i]);
|
master_retvals.push_back(retvals[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
retval = master_retvals.tsquash("Inconsistent values for high voltage.");
|
retval =
|
||||||
|
master_retvals.tsquash("Inconsistent values for high voltage.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// spinHV
|
// spinHV
|
||||||
@ -296,8 +297,7 @@ void qTabSettings::GetHighVoltage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CATCH_DISPLAY("Could not get high voltage.",
|
CATCH_DISPLAY("Could not get high voltage.", "qTabSettings::GetHighVoltage")
|
||||||
"qTabSettings::GetHighVoltage")
|
|
||||||
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
|
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
|
||||||
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
|
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
|
||||||
SLOT(SetHighVoltage()));
|
SLOT(SetHighVoltage()));
|
||||||
@ -515,8 +515,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 " << ToString(eV)
|
LOG(logINFO) << "Setting Threshold Energies to " << ToString(eV) << " (eV)";
|
||||||
<< " (eV)";
|
|
||||||
try {
|
try {
|
||||||
det->setThresholdEnergy(eV, sett);
|
det->setThresholdEnergy(eV, sett);
|
||||||
}
|
}
|
||||||
@ -555,8 +554,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 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)));
|
||||||
}
|
}
|
||||||
counters[i]->setChecked(true);
|
counters[i]->setChecked(true);
|
||||||
|
@ -1150,8 +1150,10 @@ int setModule(sls_detector_module myMod, char *mess) {
|
|||||||
|
|
||||||
LOG(logINFO, ("Setting module with settings %d\n", myMod.reg));
|
LOG(logINFO, ("Setting module with settings %d\n", myMod.reg));
|
||||||
|
|
||||||
if (((myMod.nchan) > (detectorModules->nchan)) || ((myMod.ndac) > (detectorModules->ndac))) {
|
if (((myMod.nchan) > (detectorModules->nchan)) ||
|
||||||
strcpy(mess, "Could not set module as the number of channels or dacs do not match to the one in the detector server\n");
|
((myMod.ndac) > (detectorModules->ndac))) {
|
||||||
|
strcpy(mess, "Could not set module as the number of channels or dacs "
|
||||||
|
"do not match to the one in the detector server\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -2219,7 +2221,6 @@ int setTrimbits(int* chanregs, char* mess) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int setAllTrimbits(int val) {
|
int setAllTrimbits(int val) {
|
||||||
LOG(logINFO, ("Setting all trimbits to %d\n", val));
|
LOG(logINFO, ("Setting all trimbits to %d\n", val));
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
|
Binary file not shown.
@ -2271,10 +2271,6 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
|||||||
clkDivider[ind] = val;
|
clkDivider[ind] = val;
|
||||||
LOG(logINFO, ("\t%s clock (%d) divider set to %d\n", clock_names[ind], ind,
|
LOG(logINFO, ("\t%s clock (%d) divider set to %d\n", clock_names[ind], ind,
|
||||||
clkDivider[ind]));
|
clkDivider[ind]));
|
||||||
// update system frequency
|
|
||||||
if (ind == SYSTEM_C0) {
|
|
||||||
setTimingSource(getTimingSource());
|
|
||||||
}
|
|
||||||
|
|
||||||
// phase is reset by pll (when setting output frequency)
|
// phase is reset by pll (when setting output frequency)
|
||||||
if (ind < SYSTEM_C0) {
|
if (ind < SYSTEM_C0) {
|
||||||
|
@ -862,7 +862,8 @@ int setROI(ROI arg) {
|
|||||||
rois.ymin = -1;
|
rois.ymin = -1;
|
||||||
rois.ymax = -1;
|
rois.ymax = -1;
|
||||||
} else {
|
} else {
|
||||||
LOG(logINFO, ("Setting ROI:(%d, %d, %d, %d)\n", arg.xmin, arg.xmax, arg.ymin, arg.ymax));
|
LOG(logINFO, ("Setting ROI:(%d, %d, %d, %d)\n", arg.xmin, arg.xmax,
|
||||||
|
arg.ymin, arg.ymax));
|
||||||
// validation
|
// validation
|
||||||
// xmin divisible by 256 and less than 1280
|
// xmin divisible by 256 and less than 1280
|
||||||
if (((arg.xmin % NCHAN_PER_ADC) != 0) ||
|
if (((arg.xmin % NCHAN_PER_ADC) != 0) ||
|
||||||
@ -896,7 +897,8 @@ ROI getROI() {
|
|||||||
if (rois.xmin == -1) {
|
if (rois.xmin == -1) {
|
||||||
LOG(logINFO, ("\tROI: None\n"));
|
LOG(logINFO, ("\tROI: None\n"));
|
||||||
} else {
|
} else {
|
||||||
LOG(logINFO, ("ROI: (%d,%d,%d,%d)\n", rois.xmin, rois.xmax, rois.ymin, rois.ymax));
|
LOG(logINFO, ("ROI: (%d,%d,%d,%d)\n", rois.xmin, rois.xmax, rois.ymin,
|
||||||
|
rois.ymax));
|
||||||
}
|
}
|
||||||
return rois;
|
return rois;
|
||||||
}
|
}
|
||||||
|
@ -572,7 +572,6 @@
|
|||||||
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
|
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
|
||||||
#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
|
#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
|
||||||
|
|
||||||
|
|
||||||
/* Pattern Loop 3 Address RW regiser */
|
/* Pattern Loop 3 Address RW regiser */
|
||||||
#define PATTERN_LOOP_3_ADDR_REG (0x84 << MEM_MAP_SHIFT)
|
#define PATTERN_LOOP_3_ADDR_REG (0x84 << MEM_MAP_SHIFT)
|
||||||
|
|
||||||
|
@ -488,7 +488,6 @@ void setupDetector() {
|
|||||||
// dynamic range
|
// dynamic range
|
||||||
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
|
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
|
||||||
|
|
||||||
|
|
||||||
// Initialization of acquistion parameters
|
// Initialization of acquistion parameters
|
||||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||||
setNumTriggers(DEFAULT_NUM_CYCLES);
|
setNumTriggers(DEFAULT_NUM_CYCLES);
|
||||||
@ -1302,8 +1301,10 @@ void getModule(sls_detector_module* myMod) {
|
|||||||
int setModule(sls_detector_module myMod, char *mess) {
|
int setModule(sls_detector_module myMod, char *mess) {
|
||||||
LOG(logINFO, ("Setting module\n"));
|
LOG(logINFO, ("Setting module\n"));
|
||||||
|
|
||||||
if (((myMod.nchan) > (detectorModules->nchan)) || ((myMod.ndac) > (detectorModules->ndac))) {
|
if (((myMod.nchan) > (detectorModules->nchan)) ||
|
||||||
strcpy(mess, "Could not set module as the number of channels or dacs do not match to the one in the detector server\n");
|
((myMod.ndac) > (detectorModules->ndac))) {
|
||||||
|
strcpy(mess, "Could not set module as the number of channels or dacs "
|
||||||
|
"do not match to the one in the detector server\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -1359,7 +1360,8 @@ int setTrimbits(int *trimbits) {
|
|||||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||||
|
|
||||||
// set to trimming clock
|
// set to trimming clock
|
||||||
if (setClockDividerWithTimeUpdateOption(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) {
|
if (setClockDividerWithTimeUpdateOption(
|
||||||
|
SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) {
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
("Could not start trimming. Could not set to trimming clock\n"));
|
("Could not start trimming. Could not set to trimming clock\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -2271,7 +2273,8 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
|||||||
return setClockDividerWithTimeUpdateOption(ind, val, 1);
|
return setClockDividerWithTimeUpdateOption(ind, val, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int timeUpdate) {
|
int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val,
|
||||||
|
int timeUpdate) {
|
||||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||||
LOG(logERROR, ("Unknown clock index %d to set clock divider\n", ind));
|
LOG(logERROR, ("Unknown clock index %d to set clock divider\n", ind));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -2470,7 +2473,8 @@ void *start_timer(void *arg) {
|
|||||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)i;
|
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)i;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
*((uint32_t *)(imageData + i * sizeof(uint32_t))) = ((uint32_t)i & 0xFFFFFF); // 24 bit
|
*((uint32_t *)(imageData + i * sizeof(uint32_t))) =
|
||||||
|
((uint32_t)i & 0xFFFFFF); // 24 bit
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -2492,7 +2496,6 @@ void *start_timer(void *arg) {
|
|||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
usleep(expUs);
|
usleep(expUs);
|
||||||
|
|
||||||
|
|
||||||
int srcOffset = 0;
|
int srcOffset = 0;
|
||||||
// loop packet
|
// loop packet
|
||||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||||
@ -2712,7 +2715,8 @@ int setChipStatusRegister(int csr) {
|
|||||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||||
|
|
||||||
// set to trimming clock
|
// set to trimming clock
|
||||||
if (setClockDividerWithTimeUpdateOption(SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) {
|
if (setClockDividerWithTimeUpdateOption(
|
||||||
|
SYSTEM_C0, DEFAULT_TRIMMING_RUN_CLKDIV, 0) == FAIL) {
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
("Could not set to trimming clock in order to change CSR\n"));
|
("Could not set to trimming clock in order to change CSR\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -29,9 +29,10 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
|||||||
ssize_t fsize, int forceDeleteNormalFile);
|
ssize_t fsize, int forceDeleteNormalFile);
|
||||||
int getDrive(char *mess, enum PROGRAM_INDEX index);
|
int getDrive(char *mess, enum PROGRAM_INDEX index);
|
||||||
/** Notify fpga not to touch flash, open src and flash drive to write */
|
/** Notify fpga not to touch flash, open src and flash drive to write */
|
||||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
|
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd,
|
||||||
|
FILE **srcfd, int forceDeleteNormalFile);
|
||||||
|
int checkNormalFile(char *mess, enum PROGRAM_INDEX index,
|
||||||
int forceDeleteNormalFile);
|
int forceDeleteNormalFile);
|
||||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile);
|
|
||||||
int eraseFlash(char *mess);
|
int eraseFlash(char *mess);
|
||||||
/* write from tmp file to flash */
|
/* write from tmp file to flash */
|
||||||
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd);
|
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd);
|
||||||
|
@ -569,7 +569,8 @@ int getFrequency(enum CLKINDEX ind);
|
|||||||
int getVCOFrequency(enum CLKINDEX ind);
|
int getVCOFrequency(enum CLKINDEX ind);
|
||||||
int getMaxClockDivider();
|
int getMaxClockDivider();
|
||||||
int setClockDivider(enum CLKINDEX ind, int val);
|
int setClockDivider(enum CLKINDEX ind, int val);
|
||||||
int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int timeUpdate);
|
int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val,
|
||||||
|
int timeUpdate);
|
||||||
int getClockDivider(enum CLKINDEX ind);
|
int getClockDivider(enum CLKINDEX ind);
|
||||||
|
|
||||||
#elif GOTTHARD2D
|
#elif GOTTHARD2D
|
||||||
|
@ -411,14 +411,14 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
|||||||
LOG(level, ("Sending Module\n"));
|
LOG(level, ("Sending Module\n"));
|
||||||
int ts = 0, n = 0;
|
int ts = 0, n = 0;
|
||||||
|
|
||||||
n = sendData(file_des, &(myMod->serialnumber),
|
n = sendData(file_des, &(myMod->serialnumber), sizeof(myMod->serialnumber),
|
||||||
sizeof(myMod->serialnumber), INT32);
|
INT32);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ts += n;
|
ts += n;
|
||||||
LOG(level, ("serialno sent %d bytes. serialno: %d\n", n,
|
LOG(level,
|
||||||
myMod->serialnumber));
|
("serialno sent %d bytes. serialno: %d\n", n, myMod->serialnumber));
|
||||||
n = sendData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
n = sendData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -448,8 +448,7 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ts += n;
|
ts += n;
|
||||||
LOG(level,
|
LOG(level, ("iodelay sent %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||||
("iodelay sent %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
|
||||||
n = sendData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
n = sendData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -494,8 +493,8 @@ int receiveModule(int file_des, sls_detector_module *myMod) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ts += n;
|
ts += n;
|
||||||
LOG(level, ("serialno received %d bytes. serialno: %d\n", n,
|
LOG(level,
|
||||||
myMod->serialnumber));
|
("serialno received %d bytes. serialno: %d\n", n, myMod->serialnumber));
|
||||||
n = receiveData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
n = receiveData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -525,8 +524,7 @@ int receiveModule(int file_des, sls_detector_module *myMod) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ts += n;
|
ts += n;
|
||||||
LOG(level,
|
LOG(level, ("iodelay received %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||||
("iodelay received %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
|
||||||
n = receiveData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
n = receiveData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -164,8 +164,10 @@ void writePatternWord(int addr, uint64_t word) {
|
|||||||
int validate_getPatternWaitAddresses(char *message, int level, int *addr) {
|
int validate_getPatternWaitAddresses(char *message, int level, int *addr) {
|
||||||
// validate input
|
// validate input
|
||||||
if (level < 0 || level >= MAX_LEVELS) {
|
if (level < 0 || level >= MAX_LEVELS) {
|
||||||
sprintf(message,
|
sprintf(
|
||||||
"Cannot get patwait address. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
message,
|
||||||
|
"Cannot get patwait address. Level %d must be between 0 and %d.\n",
|
||||||
|
level, MAX_LEVELS - 1);
|
||||||
LOG(logERROR, (message));
|
LOG(logERROR, (message));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -203,8 +205,10 @@ int getPatternWaitAddress(int level) {
|
|||||||
int validate_setPatternWaitAddresses(char *message, int level, int addr) {
|
int validate_setPatternWaitAddresses(char *message, int level, int addr) {
|
||||||
// validate input
|
// validate input
|
||||||
if (level < 0 || level >= MAX_LEVELS) {
|
if (level < 0 || level >= MAX_LEVELS) {
|
||||||
sprintf(message,
|
sprintf(
|
||||||
"Cannot set patwait address. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
message,
|
||||||
|
"Cannot set patwait address. Level %d must be between 0 and %d.\n",
|
||||||
|
level, MAX_LEVELS - 1);
|
||||||
LOG(logERROR, (message));
|
LOG(logERROR, (message));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -274,7 +278,8 @@ int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
|
|||||||
// validate input
|
// validate input
|
||||||
if (level < 0 || level >= MAX_LEVELS) {
|
if (level < 0 || level >= MAX_LEVELS) {
|
||||||
sprintf(message,
|
sprintf(message,
|
||||||
"Cannot get patwaittime. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
"Cannot get patwaittime. Level %d must be between 0 and %d.\n",
|
||||||
|
level, MAX_LEVELS - 1);
|
||||||
LOG(logERROR, (message));
|
LOG(logERROR, (message));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -313,7 +318,8 @@ int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
|
|||||||
// validate input
|
// validate input
|
||||||
if (level < 0 || level >= MAX_LEVELS) {
|
if (level < 0 || level >= MAX_LEVELS) {
|
||||||
sprintf(message,
|
sprintf(message,
|
||||||
"Cannot set patwaittime. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
"Cannot set patwaittime. Level %d must be between 0 and %d.\n",
|
||||||
|
level, MAX_LEVELS - 1);
|
||||||
LOG(logERROR, (message));
|
LOG(logERROR, (message));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -376,7 +382,8 @@ int validate_getPatternLoopCycles(char *message, int level, int *numLoops) {
|
|||||||
// validate input
|
// validate input
|
||||||
if (level < 0 || level >= MAX_LEVELS) {
|
if (level < 0 || level >= MAX_LEVELS) {
|
||||||
sprintf(message,
|
sprintf(message,
|
||||||
"Cannot get patnloop. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
"Cannot get patnloop. Level %d must be between 0 and %d.\n",
|
||||||
|
level, MAX_LEVELS - 1);
|
||||||
LOG(logERROR, (message));
|
LOG(logERROR, (message));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -409,7 +416,8 @@ int validate_setPatternLoopCycles(char *message, int level, int numLoops) {
|
|||||||
// validate input
|
// validate input
|
||||||
if (level < 0 || level >= MAX_LEVELS) {
|
if (level < 0 || level >= MAX_LEVELS) {
|
||||||
sprintf(message,
|
sprintf(message,
|
||||||
"Cannot set patnloop. Level %d must be between 0 and %d.\n", level, MAX_LEVELS);
|
"Cannot set patnloop. Level %d must be between 0 and %d.\n",
|
||||||
|
level, MAX_LEVELS);
|
||||||
LOG(logERROR, (message));
|
LOG(logERROR, (message));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -519,9 +527,10 @@ int validate_getPatternLoopAddresses(char *message, int level, int *startAddr,
|
|||||||
int *stopAddr) {
|
int *stopAddr) {
|
||||||
// validate input
|
// validate input
|
||||||
if (level < 0 || level >= MAX_LEVELS) {
|
if (level < 0 || level >= MAX_LEVELS) {
|
||||||
sprintf(
|
sprintf(message,
|
||||||
message,
|
"Cannot get patloop addresses. Level %d must be between 0 and "
|
||||||
"Cannot get patloop addresses. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
"%d.\n",
|
||||||
|
level, MAX_LEVELS - 1);
|
||||||
LOG(logERROR, (message));
|
LOG(logERROR, (message));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -591,9 +600,10 @@ int validate_setPatternLoopAddresses(char *message, int level, int startAddr,
|
|||||||
int stopAddr) {
|
int stopAddr) {
|
||||||
// validate input
|
// validate input
|
||||||
if (level < 0 || level >= MAX_LEVELS) {
|
if (level < 0 || level >= MAX_LEVELS) {
|
||||||
sprintf(
|
sprintf(message,
|
||||||
message,
|
"Cannot set patloop addresses. Level %d must be between 0 and "
|
||||||
"Cannot set patloop addresses. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
"%d.\n",
|
||||||
|
level, MAX_LEVELS - 1);
|
||||||
LOG(logERROR, (message));
|
LOG(logERROR, (message));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -975,8 +985,8 @@ int loadPatternFile(char *patFname, char *errMessage) {
|
|||||||
int startAddr = 0;
|
int startAddr = 0;
|
||||||
int stopAddr = 0;
|
int stopAddr = 0;
|
||||||
// cannot scan values
|
// cannot scan values
|
||||||
if (sscanf(line, "%s %d 0x%x 0x%x", command, &level, &startAddr, &stopAddr) !=
|
if (sscanf(line, "%s %d 0x%x 0x%x", command, &level, &startAddr,
|
||||||
4) {
|
&stopAddr) != 4) {
|
||||||
strcpy(temp, "Could not scan patloop arguments.\n");
|
strcpy(temp, "Could not scan patloop arguments.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,8 @@ int defineGPIOpins(char *mess) {
|
|||||||
if (access(CMD_GPIO9_EXIST, F_OK) != 0) {
|
if (access(CMD_GPIO9_EXIST, F_OK) != 0) {
|
||||||
if (executeCommand(CMD_GPIO9_DEFINE, retvals, logDEBUG1) == FAIL) {
|
if (executeCommand(CMD_GPIO9_DEFINE, retvals, logDEBUG1) == FAIL) {
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
snprintf(mess, MAX_STR_LENGTH,
|
||||||
"Could not define gpio9 (nConfig) for fpga (%s)\n", retvals);
|
"Could not define gpio9 (nConfig) for fpga (%s)\n",
|
||||||
|
retvals);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -146,7 +147,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
|||||||
// define gpio9 as output
|
// define gpio9 as output
|
||||||
if (executeCommand(CMD_GPIO9_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
if (executeCommand(CMD_GPIO9_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
snprintf(mess, MAX_STR_LENGTH,
|
||||||
"Could not set gpio9 (nConfig) as output for fpga (%s)\n", retvals);
|
"Could not set gpio9 (nConfig) as output for fpga (%s)\n",
|
||||||
|
retvals);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -156,7 +158,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
|||||||
if (programming && latestKernelVerified == 1) {
|
if (programming && latestKernelVerified == 1) {
|
||||||
if (executeCommand(CMD_GPIO3_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
if (executeCommand(CMD_GPIO3_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
snprintf(mess, MAX_STR_LENGTH,
|
||||||
"Could not set gpio3 (nCE) as output for fpga (%s)\n", retvals);
|
"Could not set gpio3 (nCE) as output for fpga (%s)\n",
|
||||||
|
retvals);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -166,7 +169,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
|||||||
// tell FPGA to not: gpio9
|
// tell FPGA to not: gpio9
|
||||||
if (executeCommand(CMD_GPIO9_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
if (executeCommand(CMD_GPIO9_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
||||||
FAIL) {
|
FAIL) {
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
snprintf(
|
||||||
|
mess, MAX_STR_LENGTH,
|
||||||
"Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n",
|
"Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n",
|
||||||
retvals);
|
retvals);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
@ -178,7 +182,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
|||||||
if (programming && latestKernelVerified == 1) {
|
if (programming && latestKernelVerified == 1) {
|
||||||
if (executeCommand(CMD_GPIO3_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
if (executeCommand(CMD_GPIO3_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
||||||
FAIL) {
|
FAIL) {
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
snprintf(
|
||||||
|
mess, MAX_STR_LENGTH,
|
||||||
"Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n",
|
"Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n",
|
||||||
retvals);
|
retvals);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
@ -198,7 +203,8 @@ int FPGATouchFlash(char *mess, int programming) {
|
|||||||
// tell FPGA to touch flash to program itself
|
// tell FPGA to touch flash to program itself
|
||||||
if (executeCommand(CMD_GPIO9_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
if (executeCommand(CMD_GPIO9_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
snprintf(mess, MAX_STR_LENGTH,
|
||||||
"Could not set gpio9 (nConfig) as input for fpga (%s)\n", retvals);
|
"Could not set gpio9 (nConfig) as input for fpga (%s)\n",
|
||||||
|
retvals);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -207,7 +213,8 @@ int FPGATouchFlash(char *mess, int programming) {
|
|||||||
if (programming && latestKernelVerified == 1) {
|
if (programming && latestKernelVerified == 1) {
|
||||||
if (executeCommand(CMD_GPIO3_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
if (executeCommand(CMD_GPIO3_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
snprintf(mess, MAX_STR_LENGTH,
|
||||||
"Could not set gpio3 (nCE) as input for fpga (%s)\n", retvals);
|
"Could not set gpio3 (nCE) as input for fpga (%s)\n",
|
||||||
|
retvals);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -341,8 +348,8 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
|||||||
|
|
||||||
FILE *flashfd = NULL;
|
FILE *flashfd = NULL;
|
||||||
FILE *srcfd = NULL;
|
FILE *srcfd = NULL;
|
||||||
if (openFileForFlash(mess, index, &flashfd, &srcfd, forceDeleteNormalFile) ==
|
if (openFileForFlash(mess, index, &flashfd, &srcfd,
|
||||||
FAIL) {
|
forceDeleteNormalFile) == FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,8 +453,8 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
|
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd,
|
||||||
int forceDeleteNormalFile) {
|
FILE **srcfd, int forceDeleteNormalFile) {
|
||||||
// open src file
|
// open src file
|
||||||
*srcfd = fopen(TEMP_PROG_FILE_NAME, "r");
|
*srcfd = fopen(TEMP_PROG_FILE_NAME, "r");
|
||||||
if (*srcfd == NULL) {
|
if (*srcfd == NULL) {
|
||||||
@ -480,13 +487,13 @@ int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile) {
|
int checkNormalFile(char *mess, enum PROGRAM_INDEX index,
|
||||||
|
int forceDeleteNormalFile) {
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
// check if its a normal file or special file
|
// check if its a normal file or special file
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (stat(flashDriveName, &buf) == -1) {
|
if (stat(flashDriveName, &buf) == -1) {
|
||||||
sprintf(mess,
|
sprintf(mess, "Could not %s. Unable to find the flash drive %s\n",
|
||||||
"Could not %s. Unable to find the flash drive %s\n",
|
|
||||||
messageType, flashDriveName);
|
messageType, flashDriveName);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -507,9 +514,12 @@ int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalF
|
|||||||
// user does not allow to fix it (default)
|
// user does not allow to fix it (default)
|
||||||
if (forceDeleteNormalFile == 0) {
|
if (forceDeleteNormalFile == 0) {
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not %s. The flash drive %s found for fpga programming is a normal file. To "
|
"Could not %s. The flash drive %s found for fpga "
|
||||||
"fix this (by deleting this file, creating the flash drive and proceeding with "
|
"programming is a normal file. To "
|
||||||
"programming), re-run the programming command 'programfpga' with parameter "
|
"fix this (by deleting this file, creating the flash drive "
|
||||||
|
"and proceeding with "
|
||||||
|
"programming), re-run the programming command "
|
||||||
|
"'programfpga' with parameter "
|
||||||
"'--force-delete-normal-file'\n",
|
"'--force-delete-normal-file'\n",
|
||||||
messageType, flashDriveName);
|
messageType, flashDriveName);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
@ -517,7 +527,8 @@ int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalF
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fpga memory stays after a reboot, user allowed to fix it
|
// fpga memory stays after a reboot, user allowed to fix it
|
||||||
LOG(logWARNING, ("Flash drive invalidated (normal file). Fixing it...\n"));
|
LOG(logWARNING,
|
||||||
|
("Flash drive invalidated (normal file). Fixing it...\n"));
|
||||||
|
|
||||||
// user allows to fix it, so force delete normal file
|
// user allows to fix it, so force delete normal file
|
||||||
char cmd[MAX_STR_LENGTH] = {0};
|
char cmd[MAX_STR_LENGTH] = {0};
|
||||||
@ -678,7 +689,8 @@ int waitForFPGAtoTouchFlash(char *mess) {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
LOG(logINFO, ("\tWaiting for FPGA to program from flash... \n\t[gpio7 (CD) should be High when done]\n"));
|
LOG(logINFO, ("\tWaiting for FPGA to program from flash... \n\t[gpio7 (CD) "
|
||||||
|
"should be High when done]\n"));
|
||||||
int timeSpent = 0;
|
int timeSpent = 0;
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -718,6 +730,7 @@ int waitForFPGAtoTouchFlash(char *mess) {
|
|||||||
}
|
}
|
||||||
LOG(logDEBUG1, ("gpi07 (CD)returned %d\n", result));
|
LOG(logDEBUG1, ("gpi07 (CD)returned %d\n", result));
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("\tFPGA has picked up the program from flash. gpio7 (CD) is High\n"));
|
LOG(logINFO,
|
||||||
|
("\tFPGA has picked up the program from flash. gpio7 (CD) is High\n"));
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include "slsDetectorServer_defs.h"
|
#include "slsDetectorServer_defs.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h> // usleep
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h> // usleep
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
|
|
||||||
@ -151,8 +151,7 @@ int openFileForFlash(char *mess, FILE **flashfd) {
|
|||||||
// check if its a normal file or special file
|
// check if its a normal file or special file
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (stat(flashDriveName, &buf) == -1) {
|
if (stat(flashDriveName, &buf) == -1) {
|
||||||
sprintf(mess,
|
sprintf(mess, "Could not %s. Unable to find the flash drive %s\n",
|
||||||
"Could not %s. Unable to find the flash drive %s\n",
|
|
||||||
messageType, flashDriveName);
|
messageType, flashDriveName);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -1605,7 +1605,8 @@ int get_module(int file_des) {
|
|||||||
|
|
||||||
// ensure nchan is not 0, else trimbits not copied
|
// ensure nchan is not 0, else trimbits not copied
|
||||||
if (module.nchan == 0) {
|
if (module.nchan == 0) {
|
||||||
strcpy(mess, "Could not get module as the number of channels to copy is 0\n");
|
strcpy(mess, "Could not get module as the number of channels to "
|
||||||
|
"copy is 0\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -1625,7 +1626,6 @@ int get_module(int file_des) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int set_module(int file_des) {
|
int set_module(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
@ -1885,7 +1885,8 @@ int acquire(int blocking, int file_des) {
|
|||||||
uint64_t sourcemac = getDetectorMAC();
|
uint64_t sourcemac = getDetectorMAC();
|
||||||
char src_mac[MAC_ADDRESS_SIZE];
|
char src_mac[MAC_ADDRESS_SIZE];
|
||||||
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
|
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
|
||||||
sprintf(mess,
|
sprintf(
|
||||||
|
mess,
|
||||||
"Invalid udp source mac address for this detector. Must be "
|
"Invalid udp source mac address for this detector. Must be "
|
||||||
"same as hardware detector mac address %s\n",
|
"same as hardware detector mac address %s\n",
|
||||||
src_mac);
|
src_mac);
|
||||||
@ -1898,7 +1899,8 @@ int acquire(int blocking, int file_des) {
|
|||||||
getIpAddressinString(src_ip, sourceip);
|
getIpAddressinString(src_ip, sourceip);
|
||||||
sprintf(
|
sprintf(
|
||||||
mess,
|
mess,
|
||||||
"Invalid udp source ip address for this detector. Must be same "
|
"Invalid udp source ip address for this detector. Must be "
|
||||||
|
"same "
|
||||||
"as hardware detector ip address %s in 1G readout mode \n",
|
"as hardware detector ip address %s in 1G readout mode \n",
|
||||||
src_ip);
|
src_ip);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
@ -2118,7 +2120,8 @@ int set_num_frames(int file_des) {
|
|||||||
arg > MAX_FRAMES_IN_BURST_MODE) {
|
arg > MAX_FRAMES_IN_BURST_MODE) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not set number of frames %lld. Must be less than equal to %d in "
|
"Could not set number of frames %lld. Must be less "
|
||||||
|
"than equal to %d in "
|
||||||
"burst mode.\n",
|
"burst mode.\n",
|
||||||
(long long unsigned int)arg, MAX_FRAMES_IN_BURST_MODE);
|
(long long unsigned int)arg, MAX_FRAMES_IN_BURST_MODE);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
@ -9260,11 +9263,12 @@ int clear_all_udp_dst(int file_des) {
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
numUdpDestinations = numdest;
|
numUdpDestinations = numdest;
|
||||||
LOG(logINFOBLUE, ("Number of UDP Destinations: %d\n",
|
LOG(logINFOBLUE,
|
||||||
numUdpDestinations));
|
("Number of UDP Destinations: %d\n", numUdpDestinations));
|
||||||
ret = configureMAC();
|
ret = configureMAC();
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
strcpy(mess, "Could not clear all destinations in the fpga.\n");
|
strcpy(mess,
|
||||||
|
"Could not clear all destinations in the fpga.\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9968,7 +9972,8 @@ int set_interpolation(int file_des) {
|
|||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (getPumpProbe() && arg) {
|
if (getPumpProbe() && arg) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess, "Could not set interpolation. Disable pump probe mode first.\n");
|
sprintf(mess, "Could not set interpolation. Disable pump probe "
|
||||||
|
"mode first.\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
} else {
|
} else {
|
||||||
ret = setInterpolation(arg);
|
ret = setInterpolation(arg);
|
||||||
@ -10024,7 +10029,8 @@ int set_pump_probe(int file_des) {
|
|||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (getInterpolation() && arg) {
|
if (getInterpolation() && arg) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess, "Could not set pump probe mode. Disable interpolation mode first.\n");
|
sprintf(mess, "Could not set pump probe mode. Disable "
|
||||||
|
"interpolation mode first.\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
} else {
|
} else {
|
||||||
ret = setPumpProbe(arg);
|
ret = setPumpProbe(arg);
|
||||||
@ -10033,7 +10039,8 @@ int set_pump_probe(int file_des) {
|
|||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
} else {
|
} else {
|
||||||
int retval = getPumpProbe();
|
int retval = getPumpProbe();
|
||||||
validate(&ret, mess, (int)arg, (int)retval, "set pump probe", DEC);
|
validate(&ret, mess, (int)arg, (int)retval, "set pump probe",
|
||||||
|
DEC);
|
||||||
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
|
LOG(logDEBUG1, ("pump probe retval: %u\n", retval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
using ns = std::chrono::nanoseconds;
|
using ns = std::chrono::nanoseconds;
|
||||||
class detectorData;
|
class detectorData;
|
||||||
@ -144,7 +143,8 @@ class Detector {
|
|||||||
defs::detectorSettings settings = defs::STANDARD,
|
defs::detectorSettings settings = defs::STANDARD,
|
||||||
bool trimbits = true, Positions pos = {});
|
bool trimbits = true, Positions pos = {});
|
||||||
|
|
||||||
/** [Mythen3] It loads trim files from settingspath. An energy of -1 will pick up values from detector */
|
/** [Mythen3] It loads trim files from settingspath. An energy of -1 will
|
||||||
|
* pick up values from detector */
|
||||||
void setThresholdEnergy(std::array<int, 3> threshold_ev,
|
void setThresholdEnergy(std::array<int, 3> threshold_ev,
|
||||||
defs::detectorSettings settings = defs::STANDARD,
|
defs::detectorSettings settings = defs::STANDARD,
|
||||||
bool trimbits = true, Positions pos = {});
|
bool trimbits = true, Positions pos = {});
|
||||||
@ -1495,13 +1495,15 @@ class Detector {
|
|||||||
/** [Mythen3] */
|
/** [Mythen3] */
|
||||||
Result<bool> getInterpolation(Positions pos = {}) const;
|
Result<bool> getInterpolation(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [Mythen3] interpolation mode enables all counters and disables vth3. Disabling sets back counter mask and vth3. */
|
/** [Mythen3] interpolation mode enables all counters and disables vth3.
|
||||||
|
* Disabling sets back counter mask and vth3. */
|
||||||
void setInterpolation(bool value, Positions pos = {});
|
void setInterpolation(bool value, Positions pos = {});
|
||||||
|
|
||||||
/** [Mythen3] */
|
/** [Mythen3] */
|
||||||
Result<bool> getPumpProbe(Positions pos = {}) const;
|
Result<bool> getPumpProbe(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [Mythen3] pump probe mode only enables vth2. Disabling sets back to previous value */
|
/** [Mythen3] pump probe mode only enables vth2. Disabling sets back to
|
||||||
|
* previous value */
|
||||||
void setPumpProbe(bool value, Positions pos = {});
|
void setPumpProbe(bool value, Positions pos = {});
|
||||||
|
|
||||||
/** [Mythen3] */
|
/** [Mythen3] */
|
||||||
|
@ -11,11 +11,22 @@ namespace sls {
|
|||||||
*/
|
*/
|
||||||
class detectorData {
|
class detectorData {
|
||||||
public:
|
public:
|
||||||
detectorData(double progressIndex, std::string fileName, int nx, int ny, char *data, int databytes, int dynamicRange, uint64_t fileIndex, bool completeImage)
|
detectorData(double progressIndex, std::string fileName, int nx, int ny,
|
||||||
: progressIndex(progressIndex), fileName(fileName), fileIndex(fileIndex), nx(nx), ny(ny), data(data), databytes(databytes), dynamicRange(dynamicRange), completeImage(completeImage){};
|
char *data, int databytes, int dynamicRange,
|
||||||
|
uint64_t fileIndex, bool completeImage)
|
||||||
|
: progressIndex(progressIndex), fileName(fileName),
|
||||||
|
fileIndex(fileIndex), nx(nx), ny(ny), data(data),
|
||||||
|
databytes(databytes), dynamicRange(dynamicRange),
|
||||||
|
completeImage(completeImage){};
|
||||||
|
|
||||||
detectorData(double progressIndex, std::string fileName, int nx, int ny, char *data, int databytes, int dynamicRange, uint64_t fileIndex, bool completeImage, std::array<int, 4> rxRoi)
|
detectorData(double progressIndex, std::string fileName, int nx, int ny,
|
||||||
: progressIndex(progressIndex), fileName(fileName), fileIndex(fileIndex), nx(nx), ny(ny), data(data), databytes(databytes), dynamicRange(dynamicRange), completeImage(completeImage), rxRoi(rxRoi) {};
|
char *data, int databytes, int dynamicRange,
|
||||||
|
uint64_t fileIndex, bool completeImage,
|
||||||
|
std::array<int, 4> rxRoi)
|
||||||
|
: progressIndex(progressIndex), fileName(fileName),
|
||||||
|
fileIndex(fileIndex), nx(nx), ny(ny), data(data),
|
||||||
|
databytes(databytes), dynamicRange(dynamicRange),
|
||||||
|
completeImage(completeImage), rxRoi(rxRoi){};
|
||||||
/**
|
/**
|
||||||
* data has to be deleted by caller
|
* data has to be deleted by caller
|
||||||
*/
|
*/
|
||||||
|
@ -53,17 +53,19 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (parser.isHelp())
|
if (parser.isHelp())
|
||||||
action = slsDetectorDefs::HELP_ACTION;
|
action = slsDetectorDefs::HELP_ACTION;
|
||||||
|
else {
|
||||||
|
|
||||||
// Free shared memory should work also without a detector
|
// Free shared memory should work also without a detector
|
||||||
// if we have an option for verify in the detector constructor
|
// if we have an option for verify in the detector constructor
|
||||||
// we could avoid this but clutter the code
|
// we could avoid this but clutter the code
|
||||||
if (parser.command() == "free" && action != slsDetectorDefs::HELP_ACTION) {
|
if (parser.command() == "free") {
|
||||||
if (parser.detector_id() != -1)
|
if (parser.detector_id() != -1)
|
||||||
std::cout << "Cannot free shared memory of sub-detector\n";
|
std::cout << "Cannot free shared memory of sub-detector\n";
|
||||||
else
|
else
|
||||||
sls::freeSharedMemory(parser.multi_id());
|
sls::freeSharedMemory(parser.multi_id());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// prevent mem size check
|
// prevent mem size check
|
||||||
if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) {
|
if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) {
|
||||||
@ -71,8 +73,11 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sls::Detector det(parser.multi_id());
|
std::unique_ptr<sls::Detector> det{nullptr};
|
||||||
sls::CmdProxy proxy(&det);
|
if (action != slsDetectorDefs::HELP_ACTION) {
|
||||||
|
det = sls::make_unique<sls::Detector>(parser.multi_id());
|
||||||
|
}
|
||||||
|
sls::CmdProxy proxy(det.get());
|
||||||
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
||||||
action, std::cout, parser.receiver_id());
|
action, std::cout, parser.receiver_id());
|
||||||
} catch (const sls::RuntimeError &e) {
|
} catch (const sls::RuntimeError &e) {
|
||||||
|
@ -48,8 +48,8 @@ void CmdProxy::Call(const std::string &command,
|
|||||||
if (it != functions.end()) {
|
if (it != functions.end()) {
|
||||||
os << ((*this).*(it->second))(action);
|
os << ((*this).*(it->second))(action);
|
||||||
} else {
|
} else {
|
||||||
throw RuntimeError(
|
throw RuntimeError(cmd +
|
||||||
cmd + " Unknown command, use list to list all commands");
|
" Unknown command, use list to list all commands");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,12 +219,10 @@ std::string CmdProxy::Acquire(int action) {
|
|||||||
<< '\n';
|
<< '\n';
|
||||||
} else {
|
} else {
|
||||||
if (det->empty()) {
|
if (det->empty()) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("This shared memory has no detectors added.");
|
||||||
"This shared memory has no detectors added.");
|
|
||||||
}
|
}
|
||||||
if (det_id >= 0) {
|
if (det_id >= 0) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Individual detectors not allowed for readout.");
|
||||||
"Individual detectors not allowed for readout.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
det->acquire();
|
det->acquire();
|
||||||
@ -456,7 +454,10 @@ std::string CmdProxy::Trimbits(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[fname]\n\t[Eiger][Mythen3] Put will load the trimbit file to detector. If no extension specified, serial number of each module is attached. Get will save the trimbits from the detector to file with serial number added to file name."
|
os << "[fname]\n\t[Eiger][Mythen3] Put will load the trimbit file to "
|
||||||
|
"detector. If no extension specified, serial number of each "
|
||||||
|
"module is attached. Get will save the trimbits from the "
|
||||||
|
"detector to file with serial number added to file name."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
@ -476,7 +477,6 @@ std::string CmdProxy::Trimbits(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string CmdProxy::TrimEnergies(int action) {
|
std::string CmdProxy::TrimEnergies(int action) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
@ -553,8 +553,7 @@ std::string CmdProxy::Exptime(int action) {
|
|||||||
} else if (cmd == "exptime3") {
|
} else if (cmd == "exptime3") {
|
||||||
gateIndex = 2;
|
gateIndex = 2;
|
||||||
} else {
|
} else {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Unknown command, use list to list all commands");
|
||||||
"Unknown command, use list to list all commands");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
@ -699,8 +698,7 @@ std::string CmdProxy::Adcphase(int action) {
|
|||||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||||
det_type == defs::GOTTHARD2) {
|
det_type == defs::GOTTHARD2) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("adcphase not implemented for this detector");
|
||||||
"adcphase not implemented for this detector");
|
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
Result<int> t;
|
Result<int> t;
|
||||||
@ -710,8 +708,7 @@ std::string CmdProxy::Adcphase(int action) {
|
|||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
if (args[0] != "deg") {
|
if (args[0] != "deg") {
|
||||||
throw RuntimeError("Unknown adcphase argument " +
|
throw RuntimeError("Unknown adcphase argument " +
|
||||||
args[0] +
|
args[0] + ". Did you mean deg? ");
|
||||||
". Did you mean deg? ");
|
|
||||||
}
|
}
|
||||||
t = det->getADCPhaseInDegrees(std::vector<int>{det_id});
|
t = det->getADCPhaseInDegrees(std::vector<int>{det_id});
|
||||||
os << OutString(t) << " deg\n";
|
os << OutString(t) << " deg\n";
|
||||||
@ -754,8 +751,7 @@ std::string CmdProxy::Dbitphase(int action) {
|
|||||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||||
det_type == defs::GOTTHARD2) {
|
det_type == defs::GOTTHARD2) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("dbitphase not implemented for this detector");
|
||||||
"dbitphase not implemented for this detector");
|
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
Result<int> t;
|
Result<int> t;
|
||||||
@ -764,8 +760,8 @@ std::string CmdProxy::Dbitphase(int action) {
|
|||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
if (args[0] != "deg") {
|
if (args[0] != "deg") {
|
||||||
throw RuntimeError("Unknown dbitphase argument " +
|
throw RuntimeError("Unknown dbitphase argument " + args[0] +
|
||||||
args[0] + ". Did you mean deg? ");
|
". Did you mean deg? ");
|
||||||
}
|
}
|
||||||
t = det->getDBITPhaseInDegrees(std::vector<int>{det_id});
|
t = det->getDBITPhaseInDegrees(std::vector<int>{det_id});
|
||||||
os << OutString(t) << " deg\n";
|
os << OutString(t) << " deg\n";
|
||||||
@ -805,8 +801,7 @@ std::string CmdProxy::ClockFrequency(int action) {
|
|||||||
} else {
|
} else {
|
||||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("clkfreq not implemented for this detector.");
|
||||||
"clkfreq not implemented for this detector.");
|
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
@ -836,8 +831,7 @@ std::string CmdProxy::ClockPhase(int action) {
|
|||||||
} else {
|
} else {
|
||||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("clkphase not implemented for this detector.");
|
||||||
"clkphase not implemented for this detector.");
|
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
@ -919,8 +913,7 @@ std::string CmdProxy::ClockDivider(int action) {
|
|||||||
} else {
|
} else {
|
||||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("clkdiv not implemented for this detector.");
|
||||||
"clkdiv not implemented for this detector.");
|
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
@ -1177,8 +1170,7 @@ std::string CmdProxy::DacList(const int action) {
|
|||||||
"names. Cannot change them.");
|
"names. Cannot change them.");
|
||||||
}
|
}
|
||||||
if (det_id != -1) {
|
if (det_id != -1) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Cannot configure dacnames at module level");
|
||||||
"Cannot configure dacnames at module level");
|
|
||||||
}
|
}
|
||||||
if (args.size() != 18) {
|
if (args.size() != 18) {
|
||||||
WrongNumberOfParameters(18);
|
WrongNumberOfParameters(18);
|
||||||
@ -1543,7 +1535,11 @@ std::string CmdProxy::UDPSourceIP(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[x.x.x.x] or auto\n\tIp address of the detector (source) udp interface. Must be same subnet as destination udp ip.\n\t[Eiger] Set only for 10G. For 1G, detector will replace with its own DHCP IP address. If 'auto' used, then ip is set to ip of rx_hostname."
|
os << "[x.x.x.x] or auto\n\tIp address of the detector (source) udp "
|
||||||
|
"interface. Must be same subnet as destination udp "
|
||||||
|
"ip.\n\t[Eiger] Set only for 10G. For 1G, detector will replace "
|
||||||
|
"with its own DHCP IP address. If 'auto' used, then ip is set to "
|
||||||
|
"ip of rx_hostname."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getSourceUDPIP(std::vector<int>{det_id});
|
auto t = det->getSourceUDPIP(std::vector<int>{det_id});
|
||||||
@ -1576,7 +1572,11 @@ std::string CmdProxy::UDPSourceIP2(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[x.x.x.x] or auto\n\t[Jungfrau][Gotthard2] Ip address of the detector (source) udp interface 2. Must be same subnet as destination udp ip2.\n\t [Jungfrau] top half or inner interface\n\t [Gotthard2] veto debugging. If 'auto' used, then ip is set to ip of rx_hostname."
|
os << "[x.x.x.x] or auto\n\t[Jungfrau][Gotthard2] Ip address of the "
|
||||||
|
"detector (source) udp interface 2. Must be same subnet as "
|
||||||
|
"destination udp ip2.\n\t [Jungfrau] top half or inner "
|
||||||
|
"interface\n\t [Gotthard2] veto debugging. If 'auto' used, then "
|
||||||
|
"ip is set to ip of rx_hostname."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getSourceUDPIP2(std::vector<int>{det_id});
|
auto t = det->getSourceUDPIP2(std::vector<int>{det_id});
|
||||||
@ -1591,8 +1591,8 @@ std::string CmdProxy::UDPSourceIP2(int action) {
|
|||||||
IpAddr val;
|
IpAddr val;
|
||||||
if (args[0] == "auto") {
|
if (args[0] == "auto") {
|
||||||
val = getIpFromAuto();
|
val = getIpFromAuto();
|
||||||
LOG(logINFO) << "Setting udp_srcip2 of detector " << det_id << " to "
|
LOG(logINFO) << "Setting udp_srcip2 of detector " << det_id
|
||||||
<< val;
|
<< " to " << val;
|
||||||
} else {
|
} else {
|
||||||
val = IpAddr(args[0]);
|
val = IpAddr(args[0]);
|
||||||
}
|
}
|
||||||
@ -1744,7 +1744,8 @@ std::string CmdProxy::Rx_ROI(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[xmin] [xmax] [ymin] [ymax]\n\tRegion of interest in "
|
os << "[xmin] [xmax] [ymin] [ymax]\n\tRegion of interest in "
|
||||||
"receiver.\n\tOnly allowed at multi module level and without gap pixels."
|
"receiver.\n\tOnly allowed at multi module level and without gap "
|
||||||
|
"pixels."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (!args.empty()) {
|
if (!args.empty()) {
|
||||||
@ -2144,8 +2145,7 @@ std::string CmdProxy::VetoFile(int action) {
|
|||||||
"file should have 128 rows of gain index and 12 bit value in dec"
|
"file should have 128 rows of gain index and 12 bit value in dec"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("cannot get vetofile. Did you mean vetophoton?");
|
||||||
"cannot get vetofile. Did you mean vetophoton?");
|
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
@ -2266,8 +2266,7 @@ std::string CmdProxy::VetoAlgorithm(int action) {
|
|||||||
defs::streamingInterface interface =
|
defs::streamingInterface interface =
|
||||||
StringTo<defs::streamingInterface>(args[0]);
|
StringTo<defs::streamingInterface>(args[0]);
|
||||||
if (interface == defs::streamingInterface::NONE) {
|
if (interface == defs::streamingInterface::NONE) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Must specify an interface to set algorithm");
|
||||||
"Must specify an interface to set algorithm");
|
|
||||||
}
|
}
|
||||||
auto t = det->getVetoAlgorithm(interface, std::vector<int>{det_id});
|
auto t = det->getVetoAlgorithm(interface, std::vector<int>{det_id});
|
||||||
os << OutString(t) << ' ' << ToString(interface) << '\n';
|
os << OutString(t) << ' ' << ToString(interface) << '\n';
|
||||||
@ -2279,8 +2278,7 @@ std::string CmdProxy::VetoAlgorithm(int action) {
|
|||||||
defs::streamingInterface interface =
|
defs::streamingInterface interface =
|
||||||
StringTo<defs::streamingInterface>(args[1]);
|
StringTo<defs::streamingInterface>(args[1]);
|
||||||
if (interface == defs::streamingInterface::NONE) {
|
if (interface == defs::streamingInterface::NONE) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Must specify an interface to set algorithm");
|
||||||
"Must specify an interface to set algorithm");
|
|
||||||
}
|
}
|
||||||
det->setVetoAlgorithm(alg, interface, std::vector<int>{det_id});
|
det->setVetoAlgorithm(alg, interface, std::vector<int>{det_id});
|
||||||
os << ToString(alg) << ' ' << ToString(interface) << '\n';
|
os << ToString(alg) << ' ' << ToString(interface) << '\n';
|
||||||
@ -2368,7 +2366,9 @@ std::string CmdProxy::Counters(int action) {
|
|||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
if (std::any_of(args.cbegin(), args.cend(), [](std::string s){ return (StringTo<int>(s) < 0 || StringTo<int>(s) > 2); })) {
|
if (std::any_of(args.cbegin(), args.cend(), [](std::string s) {
|
||||||
|
return (StringTo<int>(s) < 0 || StringTo<int>(s) > 2);
|
||||||
|
})) {
|
||||||
throw RuntimeError("Invalid counter indices list. Example: 0 1 2");
|
throw RuntimeError("Invalid counter indices list. Example: 0 1 2");
|
||||||
}
|
}
|
||||||
// convert vector to counter enable mask
|
// convert vector to counter enable mask
|
||||||
@ -2402,8 +2402,7 @@ std::string CmdProxy::GateDelay(int action) {
|
|||||||
} else if (cmd == "gatedelay3") {
|
} else if (cmd == "gatedelay3") {
|
||||||
gateIndex = 2;
|
gateIndex = 2;
|
||||||
} else {
|
} else {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Unknown command, use list to list all commands");
|
||||||
"Unknown command, use list to list all commands");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
@ -2705,12 +2704,17 @@ std::string CmdProxy::PatternWord(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdProxy::GetLevelAndUpdateArgIndex(int action, std::string levelSeparatedCommand, int& level, int& iArg, size_t nGetArgs, size_t nPutArgs) {
|
void CmdProxy::GetLevelAndUpdateArgIndex(int action,
|
||||||
|
std::string levelSeparatedCommand,
|
||||||
|
int &level, int &iArg, size_t nGetArgs,
|
||||||
|
size_t nPutArgs) {
|
||||||
if (cmd == levelSeparatedCommand) {
|
if (cmd == levelSeparatedCommand) {
|
||||||
++nGetArgs;
|
++nGetArgs;
|
||||||
++nPutArgs;
|
++nPutArgs;
|
||||||
} else {
|
} else {
|
||||||
LOG(logWARNING) << "This command is deprecated and will be removed. Please migrate to " << levelSeparatedCommand;
|
LOG(logWARNING) << "This command is deprecated and will be removed. "
|
||||||
|
"Please migrate to "
|
||||||
|
<< levelSeparatedCommand;
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION && args.size() != nGetArgs) {
|
if (action == defs::GET_ACTION && args.size() != nGetArgs) {
|
||||||
WrongNumberOfParameters(nGetArgs);
|
WrongNumberOfParameters(nGetArgs);
|
||||||
@ -2725,9 +2729,9 @@ void CmdProxy::GetLevelAndUpdateArgIndex(int action, std::string levelSeparatedC
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string CmdProxy::PatternLoopAddresses(int action) {
|
std::string CmdProxy::PatternLoopAddresses(int action) {
|
||||||
if (cmd != "patlimits" && cmd != "patloop0" && cmd != "patloop1" && cmd != "patloop2" && cmd != "patloop") {
|
if (cmd != "patlimits" && cmd != "patloop0" && cmd != "patloop1" &&
|
||||||
throw RuntimeError(
|
cmd != "patloop2" && cmd != "patloop") {
|
||||||
"Unknown command, use list to list all commands");
|
throw RuntimeError("Unknown command, use list to list all commands");
|
||||||
}
|
}
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
@ -2737,17 +2741,17 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
|
|||||||
"of complete pattern."
|
"of complete pattern."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (cmd == "patloop") {
|
} else if (cmd == "patloop") {
|
||||||
os << "[0-6] [start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of the loop level provided."
|
os << "[0-6] [start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] "
|
||||||
<< "\n\t[Mythen3] Level options: 0-3 only."
|
"Limits of the loop level provided."
|
||||||
<< '\n';
|
<< "\n\t[Mythen3] Level options: 0-3 only." << '\n';
|
||||||
} else {
|
} else {
|
||||||
os << "Depreciated command. Use patloop."
|
os << "Depreciated command. Use patloop." << '\n';
|
||||||
<< '\n';
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
|
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
|
||||||
if (cmd != "patlimits") {
|
if (cmd != "patlimits") {
|
||||||
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, nPutArgs);
|
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
|
||||||
|
nPutArgs);
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
auto t =
|
auto t =
|
||||||
@ -2768,25 +2772,25 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string CmdProxy::PatternLoopCycles(int action) {
|
std::string CmdProxy::PatternLoopCycles(int action) {
|
||||||
if (cmd != "patnloop0" && cmd != "patnloop1" && cmd != "patnloop2" && cmd != "patnloop") {
|
if (cmd != "patnloop0" && cmd != "patnloop1" && cmd != "patnloop2" &&
|
||||||
throw RuntimeError(
|
cmd != "patnloop") {
|
||||||
"Unknown command, use list to list all commands");
|
throw RuntimeError("Unknown command, use list to list all commands");
|
||||||
}
|
}
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
if (cmd == "patnloop") {
|
if (cmd == "patnloop") {
|
||||||
os << "[0-6] [n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
|
os << "[0-6] [n_cycles] \n\t[Ctb][Moench][Mythen3] Number of "
|
||||||
|
"cycles of "
|
||||||
"the loop level provided."
|
"the loop level provided."
|
||||||
<< "\n\t[Mythen3] Level options: 0-3 only."
|
<< "\n\t[Mythen3] Level options: 0-3 only." << '\n';
|
||||||
<< '\n';
|
|
||||||
} else {
|
} else {
|
||||||
os << "Depreciated command. Use patnloop."
|
os << "Depreciated command. Use patnloop." << '\n';
|
||||||
<< '\n';
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
|
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
|
||||||
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, nPutArgs);
|
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs,
|
||||||
|
nPutArgs);
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
|
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
@ -2802,15 +2806,16 @@ std::string CmdProxy::PatternLoopCycles(int action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string CmdProxy::PatternWaitAddress(int action) {
|
std::string CmdProxy::PatternWaitAddress(int action) {
|
||||||
if (cmd != "patwait0" && cmd != "patwait1" && cmd != "patwait2" && cmd != "patwait") {
|
if (cmd != "patwait0" && cmd != "patwait1" && cmd != "patwait2" &&
|
||||||
throw RuntimeError(
|
cmd != "patwait") {
|
||||||
"Unknown command, use list to list all commands");
|
throw RuntimeError("Unknown command, use list to list all commands");
|
||||||
}
|
}
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
if (cmd == "patwait") {
|
if (cmd == "patwait") {
|
||||||
os << "[0-6] [addr] \n\t[Ctb][Moench][Mythen3] Wait address for loop level provided."
|
os << "[0-6] [addr] \n\t[Ctb][Moench][Mythen3] Wait address for "
|
||||||
|
"loop level provided."
|
||||||
<< "\n\t[Mythen3] Level options: 0-3 only.";
|
<< "\n\t[Mythen3] Level options: 0-3 only.";
|
||||||
} else {
|
} else {
|
||||||
os << "Depreciated command. Use patwait.";
|
os << "Depreciated command. Use patwait.";
|
||||||
@ -2818,7 +2823,8 @@ std::string CmdProxy::PatternWaitAddress(int action) {
|
|||||||
os << '\n';
|
os << '\n';
|
||||||
} else {
|
} else {
|
||||||
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
|
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
|
||||||
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, nPutArgs);
|
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs,
|
||||||
|
nPutArgs);
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
|
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
|
||||||
os << OutStringHex(t, 4) << '\n';
|
os << OutStringHex(t, 4) << '\n';
|
||||||
@ -2834,9 +2840,9 @@ std::string CmdProxy::PatternWaitAddress(int action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string CmdProxy::PatternWaitTime(int action) {
|
std::string CmdProxy::PatternWaitTime(int action) {
|
||||||
if (cmd != "patwaittime0" && cmd != "patwaittime1" && cmd != "patwaittime2" && cmd != "patwaittime") {
|
if (cmd != "patwaittime0" && cmd != "patwaittime1" &&
|
||||||
throw RuntimeError(
|
cmd != "patwaittime2" && cmd != "patwaittime") {
|
||||||
"Unknown command, use list to list all commands");
|
throw RuntimeError("Unknown command, use list to list all commands");
|
||||||
}
|
}
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
@ -2844,15 +2850,14 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
|||||||
if (cmd == "patwaittime") {
|
if (cmd == "patwaittime") {
|
||||||
os << "[0-6] [n_clk] \n\t[Ctb][Moench][Mythen3] Wait time in clock "
|
os << "[0-6] [n_clk] \n\t[Ctb][Moench][Mythen3] Wait time in clock "
|
||||||
"cycles for the loop provided."
|
"cycles for the loop provided."
|
||||||
<< "\n\t[Mythen3] Level options: 0-3 only."
|
<< "\n\t[Mythen3] Level options: 0-3 only." << '\n';
|
||||||
<< '\n';
|
|
||||||
} else {
|
} else {
|
||||||
os << "Depreciated command. Use patwaittime."
|
os << "Depreciated command. Use patwaittime." << '\n';
|
||||||
<< '\n';
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
|
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
|
||||||
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs, nPutArgs);
|
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs,
|
||||||
|
nPutArgs);
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
|
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
@ -2965,8 +2970,7 @@ std::string CmdProxy::ProgramFpga(int action) {
|
|||||||
bool forceDeteleNormalFile = false;
|
bool forceDeteleNormalFile = false;
|
||||||
if (args.size() == 2) {
|
if (args.size() == 2) {
|
||||||
if (args[1] != "--force-delete-normal-file") {
|
if (args[1] != "--force-delete-normal-file") {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Could not scan second argument. Did you "
|
||||||
"Could not scan second argument. Did you "
|
|
||||||
"mean --force-delete-normal-file?");
|
"mean --force-delete-normal-file?");
|
||||||
}
|
}
|
||||||
forceDeteleNormalFile = true;
|
forceDeteleNormalFile = true;
|
||||||
|
@ -254,8 +254,7 @@ namespace sls {
|
|||||||
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 RuntimeError( \
|
throw RuntimeError("Cannot execute this at module level"); \
|
||||||
"Cannot execute this at module level"); \
|
|
||||||
} \
|
} \
|
||||||
if (args.size() != 1) { \
|
if (args.size() != 1) { \
|
||||||
WrongNumberOfParameters(1); \
|
WrongNumberOfParameters(1); \
|
||||||
@ -1196,7 +1195,10 @@ class CmdProxy {
|
|||||||
/* Pattern */
|
/* Pattern */
|
||||||
std::string Pattern(int action);
|
std::string Pattern(int action);
|
||||||
std::string PatternWord(int action);
|
std::string PatternWord(int action);
|
||||||
void GetLevelAndUpdateArgIndex(int action, std::string levelSeparatedCommand, int& level, int& iArg, size_t nGetArgs, size_t nPutArgs);
|
void GetLevelAndUpdateArgIndex(int action,
|
||||||
|
std::string levelSeparatedCommand,
|
||||||
|
int &level, int &iArg, size_t nGetArgs,
|
||||||
|
size_t nPutArgs);
|
||||||
std::string PatternLoopAddresses(int action);
|
std::string PatternLoopAddresses(int action);
|
||||||
std::string PatternLoopCycles(int action);
|
std::string PatternLoopCycles(int action);
|
||||||
std::string PatternWaitAddress(int action);
|
std::string PatternWaitAddress(int action);
|
||||||
@ -1604,7 +1606,6 @@ class CmdProxy {
|
|||||||
"out from in a round robin fashion. The entry must not have been "
|
"out from in a round robin fashion. The entry must not have been "
|
||||||
"empty. Default: 0");
|
"empty. Default: 0");
|
||||||
|
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr,
|
udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr,
|
||||||
"[x:x:x:x:x:x]\n\tMac address of the detector (source) udp "
|
"[x:x:x:x:x:x]\n\tMac address of the detector (source) udp "
|
||||||
@ -1981,8 +1982,7 @@ class CmdProxy {
|
|||||||
"users only.");
|
"users only.");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(
|
INTEGER_COMMAND_VEC_ID(
|
||||||
gainmode, getGainMode, setGainMode,
|
gainmode, getGainMode, setGainMode, 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!!!");
|
||||||
@ -2047,11 +2047,15 @@ class CmdProxy {
|
|||||||
INTEGER_COMMAND_VEC_ID(interpolation, getInterpolation, setInterpolation,
|
INTEGER_COMMAND_VEC_ID(interpolation, getInterpolation, setInterpolation,
|
||||||
StringTo<int>,
|
StringTo<int>,
|
||||||
"[0, 1]\n\t[Mythen3] Enables or disables "
|
"[0, 1]\n\t[Mythen3] Enables or disables "
|
||||||
"interpolation. Default is disabled. Interpolation mode enables all counters and disables vth3. Disabling sets back counter mask and vth3.");
|
"interpolation. Default is disabled. Interpolation "
|
||||||
|
"mode enables all counters and disables vth3. "
|
||||||
|
"Disabling sets back counter mask and vth3.");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(pumpprobe, getPumpProbe, setPumpProbe, StringTo<int>,
|
INTEGER_COMMAND_VEC_ID(
|
||||||
|
pumpprobe, getPumpProbe, setPumpProbe, StringTo<int>,
|
||||||
"[0, 1]\n\t[Mythen3] Enables or disables pump probe "
|
"[0, 1]\n\t[Mythen3] Enables or disables pump probe "
|
||||||
"mode. Default is disabled. Pump probe mode only enables vth2. Disabling sets back to previous value.");
|
"mode. Default is disabled. Pump probe mode only enables vth2. "
|
||||||
|
"Disabling sets back to previous value.");
|
||||||
|
|
||||||
INTEGER_COMMAND_VEC_ID(apulse, getAnalogPulsing, setAnalogPulsing,
|
INTEGER_COMMAND_VEC_ID(apulse, getAnalogPulsing, setAnalogPulsing,
|
||||||
StringTo<int>,
|
StringTo<int>,
|
||||||
|
@ -65,8 +65,6 @@ std::vector<std::string> CtbConfig::getDacNames() const {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CtbConfig::shm_tag(){
|
const char *CtbConfig::shm_tag() { return shm_tag_; }
|
||||||
return shm_tag_;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
@ -3,7 +3,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
|
||||||
class CtbConfig {
|
class CtbConfig {
|
||||||
static constexpr size_t name_length = 20;
|
static constexpr size_t name_length = 20;
|
||||||
static constexpr size_t num_dacs = 18;
|
static constexpr size_t num_dacs = 18;
|
||||||
@ -27,5 +26,4 @@ class CtbConfig {
|
|||||||
static const char *shm_tag();
|
static const char *shm_tag();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -55,8 +55,7 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
|
|||||||
|
|
||||||
using defs = slsDetectorDefs;
|
using defs = slsDetectorDefs;
|
||||||
|
|
||||||
Detector::Detector(int shm_id)
|
Detector::Detector(int shm_id) : pimpl(make_unique<DetectorImpl>(shm_id)) {}
|
||||||
: pimpl(make_unique<DetectorImpl>(shm_id)) {}
|
|
||||||
|
|
||||||
Detector::~Detector() = default;
|
Detector::~Detector() = default;
|
||||||
|
|
||||||
|
@ -185,8 +185,7 @@ void DetectorImpl::initializeMembers(bool verify) {
|
|||||||
// get objects from single det shared memory (open)
|
// get objects from single det shared memory (open)
|
||||||
for (int i = 0; i < shm()->totalNumberOfModules; i++) {
|
for (int i = 0; i < shm()->totalNumberOfModules; i++) {
|
||||||
try {
|
try {
|
||||||
modules.push_back(
|
modules.push_back(make_unique<Module>(detectorIndex, i, verify));
|
||||||
make_unique<Module>(detectorIndex, i, verify));
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
modules.clear();
|
modules.clear();
|
||||||
throw;
|
throw;
|
||||||
@ -307,8 +306,7 @@ void DetectorImpl::addModule(const std::string &hostname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto pos = modules.size();
|
auto pos = modules.size();
|
||||||
modules.emplace_back(
|
modules.emplace_back(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);
|
||||||
@ -672,7 +670,6 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
<< "\n\t databytes: " << multisize
|
<< "\n\t databytes: " << multisize
|
||||||
<< "\n\t dynamicRange: " << dynamicRange;
|
<< "\n\t dynamicRange: " << dynamicRange;
|
||||||
|
|
||||||
|
|
||||||
// send data to callback
|
// send data to callback
|
||||||
if (data) {
|
if (data) {
|
||||||
char *callbackImage = multiframe.get();
|
char *callbackImage = multiframe.get();
|
||||||
@ -1463,7 +1460,8 @@ defs::ROI DetectorImpl::getRxROI() const {
|
|||||||
auto t = Parallel(&Module::getRxROI, {});
|
auto t = Parallel(&Module::getRxROI, {});
|
||||||
if (t.equal() && t.front().completeRoi()) {
|
if (t.equal() && t.front().completeRoi()) {
|
||||||
LOG(logDEBUG) << "no roi";
|
LOG(logDEBUG) << "no roi";
|
||||||
return defs::ROI (0, shm()->numberOfChannels.x - 1, 0, shm()->numberOfChannels.y - 1);
|
return defs::ROI(0, shm()->numberOfChannels.x - 1, 0,
|
||||||
|
shm()->numberOfChannels.y - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
defs::xy numChansPerMod = modules[0]->getNumberOfChannels();
|
defs::xy numChansPerMod = modules[0]->getNumberOfChannels();
|
||||||
@ -1537,21 +1535,26 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
|
|||||||
throw RuntimeError("Invalid Roi of size 0.");
|
throw RuntimeError("Invalid Roi of size 0.");
|
||||||
}
|
}
|
||||||
if (arg.completeRoi()) {
|
if (arg.completeRoi()) {
|
||||||
throw RuntimeError("Did you mean the clear roi command (API: clearRxROI, cmd: rx_clearroi)?");
|
throw RuntimeError("Did you mean the clear roi command (API: "
|
||||||
|
"clearRxROI, cmd: rx_clearroi)?");
|
||||||
}
|
}
|
||||||
if (arg.xmin > arg.xmax || arg.ymin > arg.ymax) {
|
if (arg.xmin > arg.xmax || arg.ymin > arg.ymax) {
|
||||||
throw RuntimeError("Invalid Receiver Roi. xmin/ymin exceeds xmax/ymax.");
|
throw RuntimeError(
|
||||||
|
"Invalid Receiver Roi. xmin/ymin exceeds xmax/ymax.");
|
||||||
}
|
}
|
||||||
|
|
||||||
defs::xy numChansPerMod = modules[0]->getNumberOfChannels();
|
defs::xy numChansPerMod = modules[0]->getNumberOfChannels();
|
||||||
bool is2D = (numChansPerMod.y > 1 ? true : false);
|
bool is2D = (numChansPerMod.y > 1 ? true : false);
|
||||||
defs::xy geometry = getPortGeometry();
|
defs::xy geometry = getPortGeometry();
|
||||||
|
|
||||||
if (!is2D && ((arg.ymin != -1 && arg.ymin != 0) || (arg.ymax != -1 && arg.ymax != 0))) {
|
if (!is2D && ((arg.ymin != -1 && arg.ymin != 0) ||
|
||||||
throw RuntimeError("Invalid Receiver roi. Cannot set 2d roi for a 1d detector.");
|
(arg.ymax != -1 && arg.ymax != 0))) {
|
||||||
|
throw RuntimeError(
|
||||||
|
"Invalid Receiver roi. Cannot set 2d roi for a 1d detector.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg.xmin < 0 || arg.xmax >= shm()->numberOfChannels.x || (is2D && (arg.ymin < 0 || arg.ymax >= shm()->numberOfChannels.y))) {
|
if (arg.xmin < 0 || arg.xmax >= shm()->numberOfChannels.x ||
|
||||||
|
(is2D && (arg.ymin < 0 || arg.ymax >= shm()->numberOfChannels.y))) {
|
||||||
throw RuntimeError("Invalid Receiver Roi. Outside detector range.");
|
throw RuntimeError("Invalid Receiver Roi. Outside detector range.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1576,7 +1579,8 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
|
|||||||
--moduleRoi.xmax;
|
--moduleRoi.xmax;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw RuntimeError("Cannot have more than 2 modules for a Gotthard2 detector");
|
throw RuntimeError("Cannot have more than 2 modules for a "
|
||||||
|
"Gotthard2 detector");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// get module limits
|
// get module limits
|
||||||
@ -1625,7 +1629,9 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
|
|||||||
|
|
||||||
// metadata
|
// metadata
|
||||||
if (arg.completeRoi()) {
|
if (arg.completeRoi()) {
|
||||||
modules[0]->setRxROIMetadata(defs::ROI (0, shm()->numberOfChannels.x - 1, 0, shm()->numberOfChannels.y - 1));
|
modules[0]->setRxROIMetadata(defs::ROI(0, shm()->numberOfChannels.x - 1,
|
||||||
|
0,
|
||||||
|
shm()->numberOfChannels.y - 1));
|
||||||
} else {
|
} else {
|
||||||
modules[0]->setRxROIMetadata(arg);
|
modules[0]->setRxROIMetadata(arg);
|
||||||
}
|
}
|
||||||
@ -1639,7 +1645,6 @@ void DetectorImpl::clearRxROI() {
|
|||||||
shm()->rx_roi.ymax = -1;
|
shm()->rx_roi.ymax = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> DetectorImpl::getCtbDacNames() const {
|
std::vector<std::string> DetectorImpl::getCtbDacNames() const {
|
||||||
return ctb_shm()->getDacNames();
|
return ctb_shm()->getDacNames();
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "CtbConfig.h"
|
||||||
#include "SharedMemory.h"
|
#include "SharedMemory.h"
|
||||||
#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 <future>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <numeric>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <future>
|
|
||||||
#include <numeric>
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
@ -142,8 +142,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename... CT>
|
template <typename... CT>
|
||||||
void Parallel(void (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())
|
||||||
@ -296,8 +295,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);
|
||||||
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,
|
||||||
defs::detectorSettings sett, Positions pos);
|
defs::detectorSettings sett, Positions pos);
|
||||||
|
@ -237,15 +237,16 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
|||||||
throw RuntimeError("This detector should have called with 3 energies");
|
throw RuntimeError("This detector should have called with 3 energies");
|
||||||
}
|
}
|
||||||
if (shm()->trimEnergies.empty()) {
|
if (shm()->trimEnergies.empty()) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Trim energies have not been defined for this "
|
||||||
"Trim energies have not been defined for this module yet! Use trimen.");
|
"module yet! Use trimen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> energy(e_eV.begin(), e_eV.end());
|
std::vector<int> energy(e_eV.begin(), e_eV.end());
|
||||||
// if all energies are same
|
// if all energies are same
|
||||||
if (allEqualTo(energy, energy[0])) {
|
if (allEqualTo(energy, energy[0])) {
|
||||||
if (energy[0] == -1) {
|
if (energy[0] == -1) {
|
||||||
throw RuntimeError("Every energy provided to set threshold energy is -1. Typo?");
|
throw RuntimeError(
|
||||||
|
"Every energy provided to set threshold energy is -1. Typo?");
|
||||||
}
|
}
|
||||||
energy.resize(1);
|
energy.resize(1);
|
||||||
}
|
}
|
||||||
@ -309,7 +310,9 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
|||||||
trim2, trimbits);
|
trim2, trimbits);
|
||||||
// csr
|
// csr
|
||||||
if (myMod1.reg != myMod2.reg) {
|
if (myMod1.reg != myMod2.reg) {
|
||||||
throw RuntimeError("setAllThresholdEnergy: chip shift register values do not match between files for energy (eV) " +
|
throw RuntimeError(
|
||||||
|
"setAllThresholdEnergy: chip shift register values do not "
|
||||||
|
"match between files for energy (eV) " +
|
||||||
std::to_string(energy[i]));
|
std::to_string(energy[i]));
|
||||||
}
|
}
|
||||||
myMods[i].reg = myMod1.reg;
|
myMods[i].reg = myMod1.reg;
|
||||||
@ -319,12 +322,10 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
|||||||
sls_detector_module myMod{shm()->detType};
|
sls_detector_module myMod{shm()->detType};
|
||||||
myMod = myMods[0];
|
myMod = myMods[0];
|
||||||
|
|
||||||
|
|
||||||
// if multiple thresholds, combine
|
// if multiple thresholds, combine
|
||||||
if (myMods.size() > 1) {
|
if (myMods.size() > 1) {
|
||||||
auto counters = getSetBits(getCounterMask());
|
auto counters = getSetBits(getCounterMask());
|
||||||
|
|
||||||
|
|
||||||
// average vtrim of enabled counters
|
// average vtrim of enabled counters
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (size_t i = 0; i < counters.size(); ++i) {
|
for (size_t i = 0; i < counters.size(); ++i) {
|
||||||
@ -364,7 +365,9 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
|||||||
}
|
}
|
||||||
// csr
|
// csr
|
||||||
if (myMods[0].reg != myMods[1].reg || myMods[1].reg != myMods[2].reg) {
|
if (myMods[0].reg != myMods[1].reg || myMods[1].reg != myMods[2].reg) {
|
||||||
throw RuntimeError("setAllThresholdEnergy: chip shift register values do not match between files for all energies");
|
throw RuntimeError(
|
||||||
|
"setAllThresholdEnergy: chip shift register values do not "
|
||||||
|
"match between files for all energies");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2397,8 +2400,7 @@ void Module::setReceiverDbitList(std::vector<int> list) {
|
|||||||
}
|
}
|
||||||
for (auto &it : list) {
|
for (auto &it : list) {
|
||||||
if (it < 0 || it > 63) {
|
if (it < 0 || it > 63) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Dbit list value must be between 0 and 63\n");
|
||||||
"Dbit list value must be between 0 and 63\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::sort(begin(list), end(list));
|
std::sort(begin(list), end(list));
|
||||||
@ -3297,8 +3299,8 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (out_of_range) {
|
if (out_of_range) {
|
||||||
LOG(logWARNING)
|
LOG(logWARNING) << "Some trimbits were out of range, these have "
|
||||||
<< "Some trimbits were out of range, these have been replaced with 0 or 63.";
|
"been replaced with 0 or 63.";
|
||||||
}
|
}
|
||||||
// check dacs
|
// check dacs
|
||||||
out_of_range = false;
|
out_of_range = false;
|
||||||
@ -3318,7 +3320,8 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (out_of_range) {
|
if (out_of_range) {
|
||||||
LOG(logWARNING) << "Some dacs were out of range, "
|
LOG(logWARNING)
|
||||||
|
<< "Some dacs were out of range, "
|
||||||
"these have been replaced with 0/200 or 2800/2400.";
|
"these have been replaced with 0/200 or 2800/2400.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3391,14 +3394,18 @@ void Module::sendModule(sls_detector_module *myMod, ClientSocket &client) {
|
|||||||
ts += n;
|
ts += n;
|
||||||
LOG(level) << "channels sent. " << n << " bytes";
|
LOG(level) << "channels sent. " << n << " bytes";
|
||||||
|
|
||||||
int expectedBytesSent = sizeof(sls_detector_module) - sizeof(myMod->dacs) - sizeof(myMod->chanregs) + (myMod->ndac * sizeof(int)) + (myMod->nchan * sizeof(int));
|
int expectedBytesSent = sizeof(sls_detector_module) - sizeof(myMod->dacs) -
|
||||||
|
sizeof(myMod->chanregs) +
|
||||||
|
(myMod->ndac * sizeof(int)) +
|
||||||
|
(myMod->nchan * sizeof(int));
|
||||||
|
|
||||||
if (expectedBytesSent != ts) {
|
if (expectedBytesSent != ts) {
|
||||||
throw RuntimeError("Module size " + std::to_string(ts) + " sent does not match expected size to be sent " + std::to_string(expectedBytesSent));
|
throw RuntimeError("Module size " + std::to_string(ts) +
|
||||||
|
" sent does not match expected size to be sent " +
|
||||||
|
std::to_string(expectedBytesSent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Module::receiveModule(sls_detector_module *myMod, ClientSocket &client) {
|
void Module::receiveModule(sls_detector_module *myMod, ClientSocket &client) {
|
||||||
constexpr TLogLevel level = logDEBUG1;
|
constexpr TLogLevel level = logDEBUG1;
|
||||||
LOG(level) << "Receiving Module";
|
LOG(level) << "Receiving Module";
|
||||||
@ -3630,7 +3637,8 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
|
|||||||
return myMod;
|
return myMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::saveSettingsFile(sls_detector_module &myMod, const std::string &fname) {
|
void Module::saveSettingsFile(sls_detector_module &myMod,
|
||||||
|
const std::string &fname) {
|
||||||
LOG(logDEBUG1) << moduleIndex << ": Saving settings to " << fname;
|
LOG(logDEBUG1) << moduleIndex << ": Saving settings to " << fname;
|
||||||
std::ofstream outfile(fname);
|
std::ofstream outfile(fname);
|
||||||
if (!outfile) {
|
if (!outfile) {
|
||||||
@ -3654,9 +3662,11 @@ void Module::saveSettingsFile(sls_detector_module &myMod, const std::string &fna
|
|||||||
sizeof(int) * (myMod.nchan));
|
sizeof(int) * (myMod.nchan));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError("Saving settings file is not implemented for this detector.");
|
throw RuntimeError(
|
||||||
|
"Saving settings file is not implemented for this detector.");
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Settings for " << shm()->hostname << " written to " << fname;
|
LOG(logINFO) << "Settings for " << shm()->hostname << " written to "
|
||||||
|
<< fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
||||||
|
@ -29,11 +29,13 @@ bool Pattern::operator==(const Pattern &other) const {
|
|||||||
if (pat->limits[i] != other.pat->limits[i])
|
if (pat->limits[i] != other.pat->limits[i])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < (sizeof(pat->startloop) / sizeof(pat->startloop[0])); ++i) {
|
for (size_t i = 0; i < (sizeof(pat->startloop) / sizeof(pat->startloop[0]));
|
||||||
|
++i) {
|
||||||
if (pat->startloop[i] != other.pat->startloop[i])
|
if (pat->startloop[i] != other.pat->startloop[i])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < (sizeof(pat->stoploop) / sizeof(pat->stoploop[0])); ++i) {
|
for (size_t i = 0; i < (sizeof(pat->stoploop) / sizeof(pat->stoploop[0]));
|
||||||
|
++i) {
|
||||||
if (pat->stoploop[i] != other.pat->stoploop[i])
|
if (pat->stoploop[i] != other.pat->stoploop[i])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -70,11 +72,10 @@ void Pattern::validate() const {
|
|||||||
for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
|
for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
|
||||||
if (pat->startloop[i] >= MAX_PATTERN_LENGTH ||
|
if (pat->startloop[i] >= MAX_PATTERN_LENGTH ||
|
||||||
pat->stoploop[i] >= MAX_PATTERN_LENGTH) {
|
pat->stoploop[i] >= MAX_PATTERN_LENGTH) {
|
||||||
throw RuntimeError(
|
throw RuntimeError("Invalid Pattern loop address for level " +
|
||||||
"Invalid Pattern loop address for level " + ToString(i) +
|
ToString(i) + std::string(" [") +
|
||||||
std::string(" [") + ToString(pat->startloop[i]) +
|
ToString(pat->startloop[i]) + std::string(", ") +
|
||||||
std::string(", ") + ToString(pat->stoploop[i]) +
|
ToString(pat->stoploop[i]) + std::string("]"));
|
||||||
std::string("]"));
|
|
||||||
}
|
}
|
||||||
if (pat->wait[i] >= MAX_PATTERN_LENGTH) {
|
if (pat->wait[i] >= MAX_PATTERN_LENGTH) {
|
||||||
throw RuntimeError("Invalid Pattern wait address for level " +
|
throw RuntimeError("Invalid Pattern wait address for level " +
|
||||||
@ -129,8 +130,7 @@ void Pattern::load(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
pat->limits[0] = StringTo<uint32_t>(args[1]);
|
pat->limits[0] = StringTo<uint32_t>(args[1]);
|
||||||
pat->limits[1] = StringTo<uint32_t>(args[2]);
|
pat->limits[1] = StringTo<uint32_t>(args[2]);
|
||||||
}
|
} else if (cmd == "patloop0" || cmd == "patloop1" ||
|
||||||
else if (cmd == "patloop0" || cmd == "patloop1" ||
|
|
||||||
cmd == "patloop2" || cmd == "patloop") {
|
cmd == "patloop2" || cmd == "patloop") {
|
||||||
int level = -1, iArg = 1;
|
int level = -1, iArg = 1;
|
||||||
if (cmd == "patloop") {
|
if (cmd == "patloop") {
|
||||||
@ -140,7 +140,8 @@ void Pattern::load(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
level = StringTo<int>(args[iArg++]);
|
level = StringTo<int>(args[iArg++]);
|
||||||
} else {
|
} else {
|
||||||
LOG(logWARNING) << "Depreciated command. Please use patloop next time.";
|
LOG(logWARNING)
|
||||||
|
<< "Depreciated command. Please use patloop next time.";
|
||||||
if (nargs != 2) {
|
if (nargs != 2) {
|
||||||
throw RuntimeError("Invalid arguments for " +
|
throw RuntimeError("Invalid arguments for " +
|
||||||
ToString(args));
|
ToString(args));
|
||||||
@ -148,7 +149,8 @@ void Pattern::load(const std::string &fname) {
|
|||||||
level = cmd[cmd.find_first_of("012")] - '0';
|
level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
}
|
}
|
||||||
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
|
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
|
||||||
throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
|
throw RuntimeError("Invalid Pattern level. Options 0-" +
|
||||||
|
std::to_string(MAX_PATTERN_LEVELS - 1));
|
||||||
}
|
}
|
||||||
int loop1 = StringTo<uint32_t>(args[iArg++]);
|
int loop1 = StringTo<uint32_t>(args[iArg++]);
|
||||||
int loop2 = StringTo<uint32_t>(args[iArg++]);
|
int loop2 = StringTo<uint32_t>(args[iArg++]);
|
||||||
@ -164,7 +166,8 @@ void Pattern::load(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
level = StringTo<int>(args[iArg++]);
|
level = StringTo<int>(args[iArg++]);
|
||||||
} else {
|
} else {
|
||||||
LOG(logWARNING) << "Depreciated command. Please use patnloop next time.";
|
LOG(logWARNING) << "Depreciated command. Please use "
|
||||||
|
"patnloop next time.";
|
||||||
if (nargs != 1) {
|
if (nargs != 1) {
|
||||||
throw RuntimeError("Invalid arguments for " +
|
throw RuntimeError("Invalid arguments for " +
|
||||||
ToString(args));
|
ToString(args));
|
||||||
@ -172,7 +175,8 @@ void Pattern::load(const std::string &fname) {
|
|||||||
level = cmd[cmd.find_first_of("012")] - '0';
|
level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
}
|
}
|
||||||
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
|
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
|
||||||
throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
|
throw RuntimeError("Invalid Pattern level. Options 0-" +
|
||||||
|
std::to_string(MAX_PATTERN_LEVELS - 1));
|
||||||
}
|
}
|
||||||
pat->nloop[level] = StringTo<uint32_t>(args[iArg++]);
|
pat->nloop[level] = StringTo<uint32_t>(args[iArg++]);
|
||||||
} else if (cmd == "patwait0" || cmd == "patwait1" ||
|
} else if (cmd == "patwait0" || cmd == "patwait1" ||
|
||||||
@ -185,7 +189,8 @@ void Pattern::load(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
level = StringTo<int>(args[iArg++]);
|
level = StringTo<int>(args[iArg++]);
|
||||||
} else {
|
} else {
|
||||||
LOG(logWARNING) << "Depreciated command. Please use patwait next time.";
|
LOG(logWARNING)
|
||||||
|
<< "Depreciated command. Please use patwait next time.";
|
||||||
if (nargs != 1) {
|
if (nargs != 1) {
|
||||||
throw RuntimeError("Invalid arguments for " +
|
throw RuntimeError("Invalid arguments for " +
|
||||||
ToString(args));
|
ToString(args));
|
||||||
@ -193,7 +198,8 @@ void Pattern::load(const std::string &fname) {
|
|||||||
level = cmd[cmd.find_first_of("012")] - '0';
|
level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
}
|
}
|
||||||
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
|
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
|
||||||
throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
|
throw RuntimeError("Invalid Pattern level. Options 0-" +
|
||||||
|
std::to_string(MAX_PATTERN_LEVELS - 1));
|
||||||
}
|
}
|
||||||
pat->wait[level] = StringTo<uint32_t>(args[iArg++]);
|
pat->wait[level] = StringTo<uint32_t>(args[iArg++]);
|
||||||
} else if (cmd == "patwaittime0" || cmd == "patwaittime1" ||
|
} else if (cmd == "patwaittime0" || cmd == "patwaittime1" ||
|
||||||
@ -206,7 +212,8 @@ void Pattern::load(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
level = StringTo<int>(args[iArg++]);
|
level = StringTo<int>(args[iArg++]);
|
||||||
} else {
|
} else {
|
||||||
LOG(logWARNING) << "Depreciated command. Please use patwaittime next time.";
|
LOG(logWARNING) << "Depreciated command. Please use "
|
||||||
|
"patwaittime next time.";
|
||||||
if (nargs != 1) {
|
if (nargs != 1) {
|
||||||
throw RuntimeError("Invalid arguments for " +
|
throw RuntimeError("Invalid arguments for " +
|
||||||
ToString(args));
|
ToString(args));
|
||||||
@ -214,7 +221,8 @@ void Pattern::load(const std::string &fname) {
|
|||||||
level = cmd[cmd.find_first_of("012")] - '0';
|
level = cmd[cmd.find_first_of("012")] - '0';
|
||||||
}
|
}
|
||||||
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
|
if (level < 0 || level >= MAX_PATTERN_LEVELS) {
|
||||||
throw RuntimeError("Invalid Pattern level. Options 0-" + std::to_string(MAX_PATTERN_LEVELS - 1));
|
throw RuntimeError("Invalid Pattern level. Options 0-" +
|
||||||
|
std::to_string(MAX_PATTERN_LEVELS - 1));
|
||||||
}
|
}
|
||||||
pat->waittime[level] = StringTo<uint64_t>(args[iArg++]);
|
pat->waittime[level] = StringTo<uint64_t>(args[iArg++]);
|
||||||
} else {
|
} else {
|
||||||
@ -279,10 +287,12 @@ std::string Pattern::str() const {
|
|||||||
<< ToStringHex(pat->limits[1], addr_width) << std::endl;
|
<< ToStringHex(pat->limits[1], addr_width) << std::endl;
|
||||||
|
|
||||||
for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
|
for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
|
||||||
oss << "patloop " << i << ' ' << ToStringHex(pat->startloop[i], addr_width) << " "
|
oss << "patloop " << i << ' '
|
||||||
|
<< ToStringHex(pat->startloop[i], addr_width) << " "
|
||||||
<< ToStringHex(pat->stoploop[i], addr_width) << std::endl
|
<< ToStringHex(pat->stoploop[i], addr_width) << std::endl
|
||||||
<< "patnloop " << pat->nloop[i] << std::endl
|
<< "patnloop " << pat->nloop[i] << std::endl
|
||||||
<< "patwait " << i << ' ' << ToStringHex(pat->wait[i], addr_width) << std::endl
|
<< "patwait " << i << ' ' << ToStringHex(pat->wait[i], addr_width)
|
||||||
|
<< std::endl
|
||||||
<< "patwaittime " << i << ' ' << pat->waittime[i] << std::endl;
|
<< "patwaittime " << i << ' ' << pat->waittime[i] << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,17 +13,16 @@
|
|||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_exceptions.h"
|
#include "sls/sls_detector_exceptions.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cerrno> // errno
|
#include <cerrno> // errno
|
||||||
|
#include <cstdlib>
|
||||||
#include <cstring> // strerror
|
#include <cstring> // strerror
|
||||||
#include <fcntl.h> // O_CREAT, O_TRUNC..
|
#include <fcntl.h> // O_CREAT, O_TRUNC..
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
#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>
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
@ -10,5 +10,4 @@ void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname,
|
|||||||
void test_onchip_dac(slsDetectorDefs::dacIndex index,
|
void test_onchip_dac(slsDetectorDefs::dacIndex index,
|
||||||
const std::string &dacname, int dacvalue);
|
const std::string &dacname, int dacvalue);
|
||||||
|
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -511,18 +511,23 @@ TEST_CASE("interpolation", "[.cmd]") {
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("interpolation", {"1"}, -1, PUT, oss);
|
proxy.Call("interpolation", {"1"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "interpolation 1\n");
|
REQUIRE(oss.str() == "interpolation 1\n");
|
||||||
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
|
REQUIRE(det.getCounterMask().tsquash(
|
||||||
7);
|
"inconsistent counter mask") == 7);
|
||||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth3 dac value") == disabledDacValue);
|
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
|
||||||
|
.tsquash("inconsistent vth3 dac value") ==
|
||||||
|
disabledDacValue);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("interpolation", {"0"}, -1, PUT, oss);
|
proxy.Call("interpolation", {"0"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "interpolation 0\n");
|
REQUIRE(oss.str() == "interpolation 0\n");
|
||||||
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
|
REQUIRE(det.getCounterMask().tsquash(
|
||||||
fixedMask[i]);
|
"inconsistent counter mask") == fixedMask[i]);
|
||||||
uint32_t expectedVth3DacVal = (fixedMask[i] & 0x4 ? fixedVth3DacVal : disabledDacValue);
|
uint32_t expectedVth3DacVal =
|
||||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth3 dac value") == expectedVth3DacVal);
|
(fixedMask[i] & 0x4 ? fixedVth3DacVal : disabledDacValue);
|
||||||
|
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
|
||||||
|
.tsquash("inconsistent vth3 dac value") ==
|
||||||
|
expectedVth3DacVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,7 +540,6 @@ TEST_CASE("interpolation", "[.cmd]") {
|
|||||||
det.setCounterMask(prev_mask[i], {i});
|
det.setCounterMask(prev_mask[i], {i});
|
||||||
det.setInterpolation(prev_interpolation[i], {i});
|
det.setInterpolation(prev_interpolation[i], {i});
|
||||||
det.setDAC(defs::VTH3, prev_vth3DacVal[i], 0, {i});
|
det.setDAC(defs::VTH3, prev_vth3DacVal[i], 0, {i});
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("interpolation", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("interpolation", {}, -1, GET));
|
||||||
@ -567,9 +571,15 @@ TEST_CASE("pumpprobe", "[.cmd]") {
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("pumpprobe", {"1"}, -1, PUT, oss);
|
proxy.Call("pumpprobe", {"1"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "pumpprobe 1\n");
|
REQUIRE(oss.str() == "pumpprobe 1\n");
|
||||||
REQUIRE(det.getDAC(defs::VTH1, 0, {0}).tsquash("inconsistent vth2 dac value") == disabledDacValue);
|
REQUIRE(det.getDAC(defs::VTH1, 0, {0})
|
||||||
REQUIRE(det.getDAC(defs::VTH2, 0, {0}).tsquash("inconsistent vth2 dac value") == fixedVthDacVal);
|
.tsquash("inconsistent vth2 dac value") ==
|
||||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth2 dac value") == disabledDacValue);
|
disabledDacValue);
|
||||||
|
REQUIRE(det.getDAC(defs::VTH2, 0, {0})
|
||||||
|
.tsquash("inconsistent vth2 dac value") ==
|
||||||
|
fixedVthDacVal);
|
||||||
|
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
|
||||||
|
.tsquash("inconsistent vth2 dac value") ==
|
||||||
|
disabledDacValue);
|
||||||
}
|
}
|
||||||
// interpolation and pump probe
|
// interpolation and pump probe
|
||||||
REQUIRE_THROWS(proxy.Call("interpolation", {"1"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("interpolation", {"1"}, -1, PUT));
|
||||||
@ -578,12 +588,21 @@ TEST_CASE("pumpprobe", "[.cmd]") {
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("pumpprobe", {"0"}, -1, PUT, oss);
|
proxy.Call("pumpprobe", {"0"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "pumpprobe 0\n");
|
REQUIRE(oss.str() == "pumpprobe 0\n");
|
||||||
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") == 7);
|
REQUIRE(det.getCounterMask().tsquash(
|
||||||
REQUIRE(det.getDAC(defs::VTH1, 0, {0}).tsquash("inconsistent vth1 dac value") == (fixedMask[i] & 0x1 ? fixedVthDacVal : disabledDacValue));
|
"inconsistent counter mask") == 7);
|
||||||
REQUIRE(det.getDAC(defs::VTH2, 0, {0}).tsquash("inconsistent vth2 dac value") == (fixedMask[i] & 0x2 ? fixedVthDacVal : disabledDacValue));
|
REQUIRE(
|
||||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth3 dac value") == (fixedMask[i] & 0x4 ? fixedVthDacVal : disabledDacValue));
|
det.getDAC(defs::VTH1, 0, {0})
|
||||||
|
.tsquash("inconsistent vth1 dac value") ==
|
||||||
|
(fixedMask[i] & 0x1 ? fixedVthDacVal : disabledDacValue));
|
||||||
|
REQUIRE(
|
||||||
|
det.getDAC(defs::VTH2, 0, {0})
|
||||||
|
.tsquash("inconsistent vth2 dac value") ==
|
||||||
|
(fixedMask[i] & 0x2 ? fixedVthDacVal : disabledDacValue));
|
||||||
|
REQUIRE(
|
||||||
|
det.getDAC(defs::VTH3, 0, {0})
|
||||||
|
.tsquash("inconsistent vth3 dac value") ==
|
||||||
|
(fixedMask[i] & 0x4 ? fixedVthDacVal : disabledDacValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
@ -192,7 +192,8 @@ TEST_CASE("patloop", "[.cmd]") {
|
|||||||
REQUIRE(oss.str() == "patloop [0x0020, 0x005c]\n");
|
REQUIRE(oss.str() == "patloop [0x0020, 0x005c]\n");
|
||||||
}
|
}
|
||||||
for (int iDet = 0; iDet != det.size(); ++iDet) {
|
for (int iDet = 0; iDet != det.size(); ++iDet) {
|
||||||
det.setPatternLoopAddresses(iLoop, prev_val[iDet][0], prev_val[iDet][1], {iDet});
|
det.setPatternLoopAddresses(iLoop, prev_val[iDet][0],
|
||||||
|
prev_val[iDet][1], {iDet});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -465,7 +465,8 @@ TEST_CASE("rx_roi", "[.cmd]") {
|
|||||||
REQUIRE(oss.str() == "rx_roi [10, 15]\n");
|
REQUIRE(oss.str() == "rx_roi [10, 15]\n");
|
||||||
}
|
}
|
||||||
REQUIRE_THROWS(proxy.Call("rx_roi", {"-1", "-1"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("rx_roi", {"-1", "-1"}, -1, PUT));
|
||||||
REQUIRE_THROWS(proxy.Call("rx_roi", {"10", "15", "25", "30"}, -1, PUT));
|
REQUIRE_THROWS(
|
||||||
|
proxy.Call("rx_roi", {"10", "15", "25", "30"}, -1, PUT));
|
||||||
}
|
}
|
||||||
// 2d
|
// 2d
|
||||||
else {
|
else {
|
||||||
@ -481,10 +482,18 @@ TEST_CASE("rx_roi", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("rx_roi", {"1", std::to_string(detsize.x - 5), "1", std::to_string(detsize.y - 5)}, -1, PUT, oss);
|
proxy.Call("rx_roi",
|
||||||
REQUIRE(oss.str() == std::string("rx_roi [1, ") + std::to_string(detsize.x - 5) + std::string(", ") + std::to_string(detsize.y - 5) + std::string(", 1]\n"));
|
{"1", std::to_string(detsize.x - 5), "1",
|
||||||
|
std::to_string(detsize.y - 5)},
|
||||||
|
-1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == std::string("rx_roi [1, ") +
|
||||||
|
std::to_string(detsize.x - 5) +
|
||||||
|
std::string(", ") +
|
||||||
|
std::to_string(detsize.y - 5) +
|
||||||
|
std::string(", 1]\n"));
|
||||||
}
|
}
|
||||||
REQUIRE_THROWS(proxy.Call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT));
|
REQUIRE_THROWS(
|
||||||
|
proxy.Call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
@ -22,9 +22,8 @@ TEST_CASE("Calling help doesn't throw or cause segfault"){
|
|||||||
auto commands = proxy.GetProxyCommands();
|
auto commands = proxy.GetProxyCommands();
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
for (const auto &cmd : commands)
|
for (const auto &cmd : commands)
|
||||||
REQUIRE_NOTHROW(proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
|
REQUIRE_NOTHROW(
|
||||||
|
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Unknown command", "[.cmd]") {
|
TEST_CASE("Unknown command", "[.cmd]") {
|
||||||
@ -338,8 +337,7 @@ TEST_CASE("threshold", "[.cmd]") {
|
|||||||
det.setTrimEnergies(prev_energies);
|
det.setTrimEnergies(prev_energies);
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
if (prev_threshold[i][0] >= 0) {
|
if (prev_threshold[i][0] >= 0) {
|
||||||
std::cout
|
std::cout << "prev cvalues:" << ToString(prev_threshold[i])
|
||||||
<< "prev cvalues:" << ToString(prev_threshold[i])
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
det.setThresholdEnergy(prev_threshold[i], prev_settings,
|
det.setThresholdEnergy(prev_threshold[i], prev_settings,
|
||||||
true, {i});
|
true, {i});
|
||||||
@ -585,7 +583,8 @@ TEST_CASE("master", "[.cmd]") {
|
|||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) {
|
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||||
|
det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) {
|
||||||
REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET));
|
||||||
if (det_type == defs::EIGER) {
|
if (det_type == defs::EIGER) {
|
||||||
// get previous master
|
// get previous master
|
||||||
@ -2265,10 +2264,8 @@ TEST_CASE("scan", "[.cmd]") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT,
|
proxy.Call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT, oss);
|
||||||
oss);
|
CHECK(oss.str() == "scan [" + ToString(ind) + ", 500, 1500, 500]\n");
|
||||||
CHECK(oss.str() ==
|
|
||||||
"scan [" + ToString(ind) + ", 500, 1500, 500]\n");
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -2279,8 +2276,8 @@ TEST_CASE("scan", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1,
|
proxy.Call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1, PUT,
|
||||||
PUT, oss);
|
oss);
|
||||||
CHECK(oss.str() ==
|
CHECK(oss.str() ==
|
||||||
"scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n");
|
"scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n");
|
||||||
}
|
}
|
||||||
@ -2305,16 +2302,14 @@ TEST_CASE("scan", "[.cmd]") {
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("scan", {ToString(ind), "1500", "500", "-500"}, -1, PUT,
|
proxy.Call("scan", {ToString(ind), "1500", "500", "-500"}, -1, PUT,
|
||||||
oss);
|
oss);
|
||||||
CHECK(oss.str() ==
|
CHECK(oss.str() == "scan [" + ToString(ind) + ", 1500, 500, -500]\n");
|
||||||
"scan [" + ToString(ind) + ", 1500, 500, -500]\n");
|
|
||||||
}
|
}
|
||||||
CHECK_THROWS(proxy.Call(
|
CHECK_THROWS(proxy.Call(
|
||||||
"scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1,
|
"scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1, PUT));
|
||||||
PUT));
|
CHECK_THROWS(
|
||||||
CHECK_THROWS(proxy.Call("scan", {ToString(ind), "500", "1500", "-500"},
|
proxy.Call("scan", {ToString(ind), "500", "1500", "-500"}, -1, PUT));
|
||||||
-1, PUT));
|
CHECK_THROWS(
|
||||||
CHECK_THROWS(proxy.Call("scan", {ToString(ind), "1500", "500", "500"},
|
proxy.Call("scan", {ToString(ind), "1500", "500", "500"}, -1, PUT));
|
||||||
-1, PUT));
|
|
||||||
|
|
||||||
if (det_type == defs::MYTHEN3 || defs::EIGER) {
|
if (det_type == defs::MYTHEN3 || defs::EIGER) {
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "SharedMemory.h"
|
|
||||||
#include "CtbConfig.h"
|
#include "CtbConfig.h"
|
||||||
|
#include "SharedMemory.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
@ -97,7 +97,6 @@ TEST_CASE("Move SharedMemory", "[detector]") {
|
|||||||
shm.createSharedMemory();
|
shm.createSharedMemory();
|
||||||
shm()->x = 9;
|
shm()->x = 9;
|
||||||
|
|
||||||
|
|
||||||
SharedMemory<Data> shm2(shm_id + 1, -1);
|
SharedMemory<Data> shm2(shm_id + 1, -1);
|
||||||
shm2 = std::move(shm); // shm is now a moved from object!
|
shm2 = std::move(shm); // shm is now a moved from object!
|
||||||
|
|
||||||
@ -135,7 +134,6 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
|||||||
TEST_CASE("Create create a shared memory with a tag") {
|
TEST_CASE("Create create a shared memory with a tag") {
|
||||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||||
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs");
|
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
|
TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
|
||||||
@ -156,7 +154,6 @@ TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set"){
|
|||||||
unsetenv(SHM_ENV_NAME);
|
unsetenv(SHM_ENV_NAME);
|
||||||
else
|
else
|
||||||
setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1);
|
setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("map int64 to int32 throws") {
|
TEST_CASE("map int64 to int32 throws") {
|
||||||
|
@ -4,7 +4,6 @@ set(SOURCES
|
|||||||
src/Implementation.cpp
|
src/Implementation.cpp
|
||||||
src/ClientInterface.cpp
|
src/ClientInterface.cpp
|
||||||
src/Receiver.cpp
|
src/Receiver.cpp
|
||||||
src/File.cpp
|
|
||||||
src/BinaryDataFile.cpp
|
src/BinaryDataFile.cpp
|
||||||
src/ThreadObject.cpp
|
src/ThreadObject.cpp
|
||||||
src/Listener.cpp
|
src/Listener.cpp
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
class ClientInterface;
|
class ClientInterface;
|
||||||
@ -40,16 +39,17 @@ class Receiver : private virtual slsDetectorDefs {
|
|||||||
int64_t getReceiverVersion();
|
int64_t getReceiverVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start Acquisition Call back (slsMultiReceiver writes data if file write enabled)
|
* Start Acquisition Call back (slsMultiReceiver writes data if file write
|
||||||
* if registerCallBackRawDataReady or registerCallBackRawDataModifyReady registered,
|
* enabled) if registerCallBackRawDataReady or
|
||||||
* users get data
|
* registerCallBackRawDataModifyReady registered, users get data callback
|
||||||
* callback arguments are:
|
* arguments are:
|
||||||
* - file path
|
* - file path
|
||||||
* - file name prefix
|
* - file name prefix
|
||||||
* - file index
|
* - file index
|
||||||
* - image size in bytes
|
* - image size in bytes
|
||||||
*/
|
*/
|
||||||
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
|
void registerCallBackStartAcquisition(int (*func)(const std::string &,
|
||||||
|
const std::string &,
|
||||||
uint64_t, size_t, void *),
|
uint64_t, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class Receiver : private virtual slsDetectorDefs {
|
|||||||
* - pointer to data
|
* - pointer to data
|
||||||
* - image size in bytes
|
* - image size in bytes
|
||||||
*/
|
*/
|
||||||
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
|
void registerCallBackRawDataReady(void (*func)(sls_receiver_header &,
|
||||||
char *, size_t, void *),
|
char *, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ class Receiver : private virtual slsDetectorDefs {
|
|||||||
* Can be modified to the new size to be written/streamed. (only smaller
|
* Can be modified to the new size to be written/streamed. (only smaller
|
||||||
* value allowed).
|
* value allowed).
|
||||||
*/
|
*/
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
|
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header &,
|
||||||
char *, size_t &,
|
char *, size_t &,
|
||||||
void *),
|
void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
@ -37,4 +37,3 @@ class Arping {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|
||||||
|
@ -4,110 +4,112 @@
|
|||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
BinaryDataFile::BinaryDataFile(const int index) : File(BINARY), index_(index) {}
|
BinaryDataFile::BinaryDataFile(const int index) : index(index) {}
|
||||||
|
|
||||||
BinaryDataFile::~BinaryDataFile() { CloseFile(); }
|
BinaryDataFile::~BinaryDataFile() { CloseFile(); }
|
||||||
|
|
||||||
|
slsDetectorDefs::fileFormat BinaryDataFile::GetFileFormat() const {
|
||||||
|
return BINARY;
|
||||||
|
}
|
||||||
|
|
||||||
void BinaryDataFile::CloseFile() {
|
void BinaryDataFile::CloseFile() {
|
||||||
if (fd_) {
|
if (fd) {
|
||||||
fclose(fd_);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
fd_ = nullptr;
|
fd = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryDataFile::CreateFirstBinaryDataFile(
|
void BinaryDataFile::CreateFirstBinaryDataFile(const std::string &fNamePrefix,
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const uint64_t fIndex,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const bool ovEnable,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const bool sMode,
|
||||||
const uint32_t udpPortNumber, const uint32_t maxFramesPerFile) {
|
const uint32_t uPortNumber,
|
||||||
|
const uint32_t mFramesPerFile) {
|
||||||
|
|
||||||
subFileIndex_ = 0;
|
subFileIndex = 0;
|
||||||
numFramesInFile_ = 0;
|
numFramesInFile = 0;
|
||||||
|
|
||||||
filePath_ = filePath;
|
fileNamePrefix = fNamePrefix;
|
||||||
fileNamePrefix_ = fileNamePrefix;
|
fileIndex = fIndex;
|
||||||
fileIndex_ = fileIndex;
|
overWriteEnable = ovEnable;
|
||||||
overWriteEnable_ = overWriteEnable;
|
silentMode = sMode;
|
||||||
silentMode_ = silentMode;
|
udpPortNumber = uPortNumber;
|
||||||
detIndex_ = modulePos;
|
maxFramesPerFile = mFramesPerFile;
|
||||||
numUnitsPerReadout_ = numUnitsPerReadout;
|
|
||||||
udpPortNumber_ = udpPortNumber;
|
|
||||||
maxFramesPerFile_ = maxFramesPerFile;
|
|
||||||
|
|
||||||
CreateFile();
|
CreateFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryDataFile::CreateFile() {
|
void BinaryDataFile::CreateFile() {
|
||||||
numFramesInFile_ = 0;
|
numFramesInFile = 0;
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << filePath_ << "/" << fileNamePrefix_ << "_d"
|
os << fileNamePrefix << "_f" << subFileIndex << '_' << fileIndex << ".raw";
|
||||||
<< (detIndex_ * numUnitsPerReadout_ + index_) << "_f" << subFileIndex_
|
fileName = os.str();
|
||||||
<< '_' << fileIndex_ << ".raw";
|
|
||||||
fileName_ = os.str();
|
|
||||||
|
|
||||||
if (!overWriteEnable_) {
|
if (!overWriteEnable) {
|
||||||
if (nullptr == (fd_ = fopen((const char *)fileName_.c_str(), "wx"))) {
|
if (nullptr == (fd = fopen(fileName.c_str(), "wx"))) {
|
||||||
fd_ = nullptr;
|
fd = nullptr;
|
||||||
throw 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(fileName.c_str(), "w"))) {
|
||||||
fd_ = nullptr;
|
fd = nullptr;
|
||||||
throw 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);
|
||||||
|
|
||||||
if (!silentMode_) {
|
if (!silentMode) {
|
||||||
LOG(logINFO) << "[" << udpPortNumber_
|
LOG(logINFO) << "[" << udpPortNumber
|
||||||
<< "]: Binary File created: " << fileName_;
|
<< "]: Binary File created: " << fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryDataFile::WriteToFile(char *buffer, const int buffersize,
|
void BinaryDataFile::WriteToFile(char *imageData, sls_receiver_header &header,
|
||||||
|
const int imageSize,
|
||||||
const uint64_t currentFrameNumber,
|
const uint64_t currentFrameNumber,
|
||||||
const uint32_t numPacketsCaught) {
|
const uint32_t numPacketsCaught) {
|
||||||
// check if maxframesperfile = 0 for infinite
|
// check if maxframesperfile = 0 for infinite
|
||||||
if (maxFramesPerFile_ && (numFramesInFile_ >= maxFramesPerFile_)) {
|
if (maxFramesPerFile && (numFramesInFile >= maxFramesPerFile)) {
|
||||||
CloseFile();
|
CloseFile();
|
||||||
++subFileIndex_;
|
++subFileIndex;
|
||||||
CreateFile();
|
CreateFile();
|
||||||
}
|
}
|
||||||
++numFramesInFile_;
|
++numFramesInFile;
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
int ret = 0;
|
size_t ret = 0;
|
||||||
|
|
||||||
// contiguous bitset
|
// contiguous bitset (write header + image)
|
||||||
if (sizeof(sls_bitset) == sizeof(bitset_storage)) {
|
if (sizeof(sls_bitset) == sizeof(bitset_storage)) {
|
||||||
ret = fwrite(buffer, 1, buffersize, fd_);
|
ret = fwrite(&header, sizeof(sls_receiver_header) + imageSize, 1, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// not contiguous bitset
|
// not contiguous bitset
|
||||||
else {
|
else {
|
||||||
// write detector header
|
// write detector header
|
||||||
ret = fwrite(buffer, 1, sizeof(sls_detector_header), fd_);
|
ret = fwrite(&header, sizeof(sls_detector_header), 1, fd);
|
||||||
|
|
||||||
// get contiguous representation of bit mask
|
// get contiguous representation of bit mask
|
||||||
bitset_storage storage;
|
bitset_storage storage;
|
||||||
memset(storage, 0, sizeof(bitset_storage));
|
memset(storage, 0, sizeof(bitset_storage));
|
||||||
sls_bitset bits = *(sls_bitset *)(buffer + sizeof(sls_detector_header));
|
sls_bitset bits = header.packetsMask;
|
||||||
for (int i = 0; i < MAX_NUM_PACKETS; ++i)
|
for (int i = 0; i < MAX_NUM_PACKETS; ++i)
|
||||||
storage[i >> 3] |= (bits[i] << (i & 7));
|
storage[i >> 3] |= (bits[i] << (i & 7));
|
||||||
// write bitmask
|
// write bitmask
|
||||||
ret += fwrite((char *)storage, 1, sizeof(bitset_storage), fd_);
|
ret += fwrite(storage, sizeof(bitset_storage), 1, fd);
|
||||||
|
|
||||||
// write data
|
// write data
|
||||||
ret += fwrite(buffer + sizeof(sls_detector_header), 1,
|
ret += fwrite(imageData, imageSize, 1, fd);
|
||||||
buffersize - sizeof(sls_receiver_header), fd_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if write error
|
// if write error
|
||||||
if (ret != buffersize) {
|
if (ret != imageSize + sizeof(sls_receiver_header)) {
|
||||||
throw 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) + ". Wrote " +
|
||||||
|
std::to_string(ret) + " bytes instead of " +
|
||||||
|
std::to_string(imageSize + sizeof(sls_receiver_header)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,38 +12,32 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File {
|
|||||||
BinaryDataFile(const int index);
|
BinaryDataFile(const int index);
|
||||||
~BinaryDataFile();
|
~BinaryDataFile();
|
||||||
|
|
||||||
|
fileFormat GetFileFormat() const override;
|
||||||
void CloseFile() override;
|
void CloseFile() override;
|
||||||
void CreateFirstBinaryDataFile(const std::string filePath,
|
void CreateFirstBinaryDataFile(const std::string &fNamePrefix,
|
||||||
const std::string fileNamePrefix,
|
const uint64_t fIndex, const bool ovEnable,
|
||||||
const uint64_t fileIndex,
|
const bool sMode, const uint32_t uPortNumber,
|
||||||
const bool overWriteEnable,
|
const uint32_t mFramesPerFile) override;
|
||||||
const bool silentMode, const int modulePos,
|
|
||||||
const int numUnitsPerReadout,
|
|
||||||
const uint32_t udpPortNumber,
|
|
||||||
const uint32_t maxFramesPerFile) override;
|
|
||||||
|
|
||||||
void WriteToFile(char *buffer, const int buffersize,
|
void WriteToFile(char *imageData, sls_receiver_header &header,
|
||||||
const uint64_t currentFrameNumber,
|
const int imageSize, const uint64_t currentFrameNumber,
|
||||||
const uint32_t numPacketsCaught) override;
|
const uint32_t numPacketsCaught) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateFile();
|
void CreateFile();
|
||||||
|
|
||||||
uint32_t index_;
|
uint32_t index;
|
||||||
FILE *fd_{nullptr};
|
FILE *fd{nullptr};
|
||||||
std::string fileName_;
|
std::string fileName;
|
||||||
uint32_t numFramesInFile_{0};
|
uint32_t numFramesInFile{0};
|
||||||
uint32_t subFileIndex_{0};
|
uint32_t subFileIndex{0};
|
||||||
|
|
||||||
std::string filePath_;
|
std::string fileNamePrefix;
|
||||||
std::string fileNamePrefix_;
|
uint64_t fileIndex{0};
|
||||||
uint64_t fileIndex_{0};
|
bool overWriteEnable{false};
|
||||||
bool overWriteEnable_{false};
|
bool silentMode{false};
|
||||||
bool silentMode_{false};
|
uint32_t udpPortNumber{0};
|
||||||
int detIndex_{0};
|
uint32_t maxFramesPerFile{0};
|
||||||
int numUnitsPerReadout_{0};
|
|
||||||
uint32_t udpPortNumber_{0};
|
|
||||||
uint32_t maxFramesPerFile_{0};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
using ns = std::chrono::nanoseconds;
|
using ns = std::chrono::nanoseconds;
|
||||||
@ -34,7 +33,6 @@ using Interface = 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;
|
||||||
@ -72,13 +70,13 @@ void ClientInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClientInterface::registerCallBackRawDataReady(
|
void ClientInterface::registerCallBackRawDataReady(
|
||||||
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
|
void (*func)(sls_receiver_header &, char *, size_t, void *), void *arg) {
|
||||||
rawDataReadyCallBack = func;
|
rawDataReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientInterface::registerCallBackRawDataModifyReady(
|
void ClientInterface::registerCallBackRawDataModifyReady(
|
||||||
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
|
void (*func)(sls_receiver_header &, char *, size_t &, void *), void *arg) {
|
||||||
rawDataModifyReadyCallBack = func;
|
rawDataModifyReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
@ -1176,7 +1174,8 @@ int ClientInterface::get_additional_json_header(Interface &socket) {
|
|||||||
int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
|
int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
|
||||||
auto size = socket.Receive<int>();
|
auto size = socket.Receive<int>();
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
throw RuntimeError("Receiver socket buffer size must be > 0.");
|
throw RuntimeError(
|
||||||
|
"Receiver socket buffer size must be greater than 0.");
|
||||||
}
|
}
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
verifyIdle(socket);
|
verifyIdle(socket);
|
||||||
|
@ -34,7 +34,8 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
|
|
||||||
//***callback functions***
|
//***callback functions***
|
||||||
/** params: file path, file name, file index, image size */
|
/** params: file path, file name, file index, image size */
|
||||||
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
|
void registerCallBackStartAcquisition(int (*func)(const std::string &,
|
||||||
|
const std::string &,
|
||||||
uint64_t, size_t, void *),
|
uint64_t, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
@ -42,13 +43,13 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/** params: sls_receiver_header pointer, pointer to data, image size */
|
/** params: sls_receiver_header, pointer to data, image size */
|
||||||
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
|
void registerCallBackRawDataReady(void (*func)(sls_receiver_header &,
|
||||||
char *, size_t, void *),
|
char *, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
|
/** params: sls_receiver_header, pointer to data, reference to image size */
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
|
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header &,
|
||||||
char *, size_t &,
|
char *, size_t &,
|
||||||
void *),
|
void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
@ -180,19 +181,18 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int (ClientInterface::*flist[NUM_REC_FUNCTIONS])(
|
int (ClientInterface::*flist[NUM_REC_FUNCTIONS])(ServerInterface &socket);
|
||||||
ServerInterface &socket);
|
|
||||||
|
|
||||||
//***callback parameters***
|
//***callback parameters***
|
||||||
|
|
||||||
int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
|
int (*startAcquisitionCallBack)(const std::string &, const std::string &,
|
||||||
void *) = nullptr;
|
uint64_t, size_t, void *) = nullptr;
|
||||||
void *pStartAcquisition{nullptr};
|
void *pStartAcquisition{nullptr};
|
||||||
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
|
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
|
||||||
void *pAcquisitionFinished{nullptr};
|
void *pAcquisitionFinished{nullptr};
|
||||||
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
|
void (*rawDataReadyCallBack)(sls_receiver_header &, char *, size_t,
|
||||||
void *) = nullptr;
|
void *) = nullptr;
|
||||||
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
|
void (*rawDataModifyReadyCallBack)(sls_receiver_header &, char *, size_t &,
|
||||||
void *) = nullptr;
|
void *) = nullptr;
|
||||||
void *pRawDataReady{nullptr};
|
void *pRawDataReady{nullptr};
|
||||||
|
|
||||||
|
@ -26,72 +26,82 @@
|
|||||||
|
|
||||||
namespace sls {
|
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) : ThreadObject(index, typeName) {
|
||||||
bool *dataStreamEnable,
|
|
||||||
uint32_t *streamingFrequency,
|
|
||||||
uint32_t *streamingTimerInMs,
|
|
||||||
uint32_t *streamingStartFnum, bool *framePadding,
|
|
||||||
std::vector<int> *ctbDbitList, int *ctbDbitOffset,
|
|
||||||
int *ctbAnalogDataBytes)
|
|
||||||
: ThreadObject(index, typeName_), fifo_(fifo), detectorType_(detectorType),
|
|
||||||
dataStreamEnable_(dataStreamEnable),
|
|
||||||
streamingFrequency_(streamingFrequency),
|
|
||||||
streamingTimerInMs_(streamingTimerInMs),
|
|
||||||
streamingStartFnum_(streamingStartFnum), framePadding_(framePadding),
|
|
||||||
ctbDbitList_(ctbDbitList), ctbDbitOffset_(ctbDbitOffset),
|
|
||||||
ctbAnalogDataBytes_(ctbAnalogDataBytes) {
|
|
||||||
|
|
||||||
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
||||||
}
|
}
|
||||||
|
|
||||||
DataProcessor::~DataProcessor() { DeleteFiles(); }
|
DataProcessor::~DataProcessor() { DeleteFiles(); }
|
||||||
|
|
||||||
bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
|
bool DataProcessor::GetStartedFlag() const { return startedFlag; }
|
||||||
|
|
||||||
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
|
void DataProcessor::SetFifo(Fifo *f) { fifo = f; }
|
||||||
|
|
||||||
void DataProcessor::SetActivate(bool enable) { activated_ = enable; }
|
void DataProcessor::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||||
|
|
||||||
|
void DataProcessor::SetActivate(bool enable) { activated = enable; }
|
||||||
|
|
||||||
void DataProcessor::SetReceiverROI(ROI roi) {
|
void DataProcessor::SetReceiverROI(ROI roi) {
|
||||||
receiverRoi_ = roi;
|
receiverRoi = roi;
|
||||||
receiverRoiEnabled_ = receiverRoi_.completeRoi() ? false : true;
|
receiverRoiEnabled = receiverRoi.completeRoi() ? false : true;
|
||||||
receiverNoRoi_ = receiverRoi_.noRoi();
|
receiverNoRoi = receiverRoi.noRoi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetDataStreamEnable(bool enable) {
|
||||||
|
dataStreamEnable = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetStreamingFrequency(uint32_t value) {
|
||||||
|
streamingFrequency = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetStreamingTimerInMs(uint32_t value) {
|
||||||
|
streamingTimerInMs = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetStreamingStartFnum(uint32_t value) {
|
||||||
|
streamingStartFnum = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetFramePadding(bool enable) { framePadding = enable; }
|
||||||
|
|
||||||
|
void DataProcessor::SetCtbDbitList(std::vector<int> value) {
|
||||||
|
ctbDbitList = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataProcessor::SetCtbDbitOffset(int value) { ctbDbitOffset = value; }
|
||||||
|
|
||||||
void DataProcessor::ResetParametersforNewAcquisition() {
|
void DataProcessor::ResetParametersforNewAcquisition() {
|
||||||
StopRunning();
|
StopRunning();
|
||||||
startedFlag_ = false;
|
startedFlag = false;
|
||||||
numFramesCaught_ = 0;
|
numFramesCaught = 0;
|
||||||
firstIndex_ = 0;
|
firstIndex = 0;
|
||||||
currentFrameIndex_ = 0;
|
currentFrameIndex = 0;
|
||||||
firstStreamerFrame_ = true;
|
firstStreamerFrame = true;
|
||||||
streamCurrentFrame_ = false;
|
streamCurrentFrame = false;
|
||||||
completeImageToStreamBeforeCropping = make_unique<char[]>(generalData_->imageSize);
|
completeImageToStreamBeforeCropping =
|
||||||
|
make_unique<char[]>(generalData->imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
||||||
// listen to this fnum, later +1
|
// listen to this fnum, later +1
|
||||||
currentFrameIndex_ = fnum;
|
currentFrameIndex = fnum;
|
||||||
startedFlag_ = true;
|
startedFlag = true;
|
||||||
firstIndex_ = fnum;
|
firstIndex = fnum;
|
||||||
LOG(logDEBUG1) << index << " First Index:" << firstIndex_;
|
LOG(logDEBUG1) << index << " First Index:" << firstIndex;
|
||||||
}
|
|
||||||
|
|
||||||
void DataProcessor::SetGeneralData(GeneralData *generalData) {
|
|
||||||
generalData_ = generalData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::CloseFiles() {
|
void DataProcessor::CloseFiles() {
|
||||||
if (dataFile_)
|
if (dataFile)
|
||||||
dataFile_->CloseFile();
|
dataFile->CloseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::DeleteFiles() {
|
void DataProcessor::DeleteFiles() {
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
delete dataFile_;
|
delete dataFile;
|
||||||
dataFile_ = nullptr;
|
dataFile = nullptr;
|
||||||
}
|
}
|
||||||
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
||||||
const fileFormat fileFormatType,
|
const fileFormat fileFormatType,
|
||||||
@ -101,60 +111,59 @@ void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
|||||||
switch (fileFormatType) {
|
switch (fileFormatType) {
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
case HDF5:
|
case HDF5:
|
||||||
dataFile_ = new HDF5DataFile(index, hdf5LibMutex);
|
dataFile = new HDF5DataFile(index, hdf5LibMutex);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case BINARY:
|
case BINARY:
|
||||||
dataFile_ = new BinaryDataFile(index);
|
dataFile = new BinaryDataFile(index);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError(
|
throw RuntimeError("Unknown file format (compile with hdf5 flags");
|
||||||
"Unknown file format (compile with hdf5 flags");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::CreateFirstFiles(
|
void DataProcessor::CreateFirstFiles(const std::string &fileNamePrefix,
|
||||||
const std::string &filePath, const std::string &fileNamePrefix,
|
const uint64_t fileIndex,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const bool overWriteEnable,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const bool silentMode,
|
||||||
const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
|
const uint32_t udpPortNumber,
|
||||||
const uint64_t numImages, const uint32_t dynamicRange,
|
const uint64_t numImages,
|
||||||
const bool detectorDataStream) {
|
const bool detectorDataStream) {
|
||||||
if (dataFile_ == nullptr) {
|
if (dataFile == nullptr) {
|
||||||
throw RuntimeError("file object not contstructed");
|
throw RuntimeError("file object not contstructed");
|
||||||
}
|
}
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
|
|
||||||
// deactivated (half module/ single port or no roi), dont write file
|
// deactivated (half module/ single port or no roi), dont write file
|
||||||
if (!activated_ || !detectorDataStream || receiverNoRoi_) {
|
if (!activated || !detectorDataStream || receiverNoRoi) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
int nx = generalData_->nPixelsX;
|
int nx = generalData->nPixelsX;
|
||||||
int ny = generalData_->nPixelsY;
|
int ny = generalData->nPixelsY;
|
||||||
if (receiverRoiEnabled_) {
|
if (receiverRoiEnabled) {
|
||||||
nx = receiverRoi_.xmax - receiverRoi_.xmin + 1;
|
nx = receiverRoi.xmax - receiverRoi.xmin + 1;
|
||||||
ny = receiverRoi_.ymax - receiverRoi_.ymin + 1;
|
ny = receiverRoi.ymax - receiverRoi.ymin + 1;
|
||||||
if (receiverRoi_.ymax == -1 || receiverRoi_.ymin == -1) {
|
if (receiverRoi.ymax == -1 || receiverRoi.ymin == -1) {
|
||||||
ny = 1;
|
ny = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
switch (dataFile_->GetFileFormat()) {
|
switch (dataFile->GetFileFormat()) {
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
case HDF5:
|
case HDF5:
|
||||||
dataFile_->CreateFirstHDF5DataFile(
|
dataFile->CreateFirstHDF5DataFile(
|
||||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile,
|
udpPortNumber, generalData->framesPerFile, numImages, nx, ny,
|
||||||
numImages, nx, ny, dynamicRange);
|
generalData->dynamicRange);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case BINARY:
|
case BINARY:
|
||||||
dataFile_->CreateFirstBinaryDataFile(
|
dataFile->CreateFirstBinaryDataFile(
|
||||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile);
|
udpPortNumber, generalData->framesPerFile);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError("Unknown file format (compile with hdf5 flags");
|
throw RuntimeError("Unknown file format (compile with hdf5 flags");
|
||||||
@ -163,32 +172,32 @@ void DataProcessor::CreateFirstFiles(
|
|||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
uint32_t DataProcessor::GetFilesInAcquisition() const {
|
uint32_t DataProcessor::GetFilesInAcquisition() const {
|
||||||
if (dataFile_ == nullptr) {
|
if (dataFile == nullptr) {
|
||||||
throw 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DataProcessor::CreateVirtualFile(
|
std::string DataProcessor::CreateVirtualFile(
|
||||||
const std::string &filePath, const std::string &fileNamePrefix,
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const int modulePos, const uint64_t numImages, const int numModX,
|
||||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
const int numModY, std::mutex *hdf5LibMutex) {
|
||||||
const int numModX, const int numModY, const uint32_t dynamicRange,
|
|
||||||
std::mutex *hdf5LibMutex) {
|
|
||||||
|
|
||||||
if (receiverRoiEnabled_) {
|
if (receiverRoiEnabled) {
|
||||||
throw std::runtime_error("Skipping virtual hdf5 file since rx_roi is enabled.");
|
throw std::runtime_error(
|
||||||
|
"Skipping virtual hdf5 file since rx_roi is enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gotthard25um =
|
bool gotthard25um = ((generalData->detType == GOTTHARD ||
|
||||||
((detectorType_ == GOTTHARD || detectorType_ == GOTTHARD2) &&
|
generalData->detType == GOTTHARD2) &&
|
||||||
(numModX * numModY) == 2);
|
(numModX * numModY) == 2);
|
||||||
|
|
||||||
// maxframesperfile = 0 for infinite files
|
// 0 for infinite files
|
||||||
uint32_t framesPerFile =
|
uint32_t framesPerFile =
|
||||||
((maxFramesPerFile == 0) ? numFramesCaught_ : maxFramesPerFile);
|
((generalData->framesPerFile == 0) ? numFramesCaught
|
||||||
|
: generalData->framesPerFile);
|
||||||
|
|
||||||
// TODO: assumption 1: create virtual file even if no data in other
|
// TODO: assumption 1: create virtual file even if no data in other
|
||||||
// files (they exist anyway) assumption2: virtual file max frame index
|
// files (they exist anyway) assumption2: virtual file max frame index
|
||||||
@ -196,10 +205,10 @@ std::string DataProcessor::CreateVirtualFile(
|
|||||||
// stop acquisition)
|
// stop acquisition)
|
||||||
return masterFileUtility::CreateVirtualHDF5File(
|
return masterFileUtility::CreateVirtualHDF5File(
|
||||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||||
modulePos, numUnitsPerReadout, framesPerFile,
|
modulePos, generalData->numUDPInterfaces, framesPerFile,
|
||||||
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
|
generalData->nPixelsX, generalData->nPixelsY, generalData->dynamicRange,
|
||||||
numFramesCaught_, numModX, numModY, dataFile_->GetPDataType(),
|
numFramesCaught, numModX, numModY, dataFile->GetPDataType(),
|
||||||
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes(),
|
dataFile->GetParameterNames(), dataFile->GetParameterDataTypes(),
|
||||||
hdf5LibMutex, gotthard25um);
|
hdf5LibMutex, gotthard25um);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,16 +217,17 @@ void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
|
|||||||
const bool silentMode,
|
const bool silentMode,
|
||||||
std::mutex *hdf5LibMutex) {
|
std::mutex *hdf5LibMutex) {
|
||||||
|
|
||||||
if (receiverRoiEnabled_) {
|
if (receiverRoiEnabled) {
|
||||||
throw std::runtime_error("Should not be here, roi with hdf5 virtual should throw.");
|
throw std::runtime_error(
|
||||||
|
"Should not be here, roi with hdf5 virtual should throw.");
|
||||||
}
|
}
|
||||||
std::string fname{virtualFileName}, masterfname{masterFileName};
|
std::string fname{virtualFileName}, masterfname{masterFileName};
|
||||||
// if no virtual file, link data file
|
// if no virtual file, link data file
|
||||||
if (virtualFileName.empty()) {
|
if (virtualFileName.empty()) {
|
||||||
fname = dataFile_->GetFileName();
|
fname = dataFile->GetFileName();
|
||||||
}
|
}
|
||||||
masterFileUtility::LinkHDF5FileInMaster(masterfname, fname,
|
masterFileUtility::LinkHDF5FileInMaster(masterfname, fname,
|
||||||
dataFile_->GetParameterNames(),
|
dataFile->GetParameterNames(),
|
||||||
silentMode, hdf5LibMutex);
|
silentMode, hdf5LibMutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -228,7 +238,7 @@ std::string DataProcessor::CreateMasterFile(
|
|||||||
const fileFormat fileFormatType, MasterAttributes *attr,
|
const fileFormat fileFormatType, MasterAttributes *attr,
|
||||||
std::mutex *hdf5LibMutex) {
|
std::mutex *hdf5LibMutex) {
|
||||||
|
|
||||||
attr->framesInFile = numFramesCaught_;
|
attr->framesInFile = numFramesCaught;
|
||||||
|
|
||||||
std::unique_ptr<File> masterFile{nullptr};
|
std::unique_ptr<File> masterFile{nullptr};
|
||||||
switch (fileFormatType) {
|
switch (fileFormatType) {
|
||||||
@ -249,35 +259,38 @@ std::string DataProcessor::CreateMasterFile(
|
|||||||
|
|
||||||
void DataProcessor::ThreadExecution() {
|
void DataProcessor::ThreadExecution() {
|
||||||
char *buffer = nullptr;
|
char *buffer = nullptr;
|
||||||
fifo_->PopAddress(buffer);
|
fifo->PopAddress(buffer);
|
||||||
LOG(logDEBUG5) << "DataProcessor " << index << ", " << std::hex
|
LOG(logDEBUG5) << "DataProcessor " << index << ", " << std::hex
|
||||||
<< static_cast<void *>(buffer) << std::dec << ":" << buffer;
|
<< static_cast<void *>(buffer) << std::dec << ":" << buffer;
|
||||||
|
auto *memImage = reinterpret_cast<image_structure *>(buffer);
|
||||||
|
|
||||||
// check dummy
|
// check dummy
|
||||||
auto numBytes = *reinterpret_cast<uint32_t *>(buffer);
|
LOG(logDEBUG1) << "DataProcessor " << index
|
||||||
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
|
<< ", Numbytes:" << memImage->size;
|
||||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
if (memImage->size == DUMMY_PACKET_VALUE) {
|
||||||
StopProcessing(buffer);
|
StopProcessing(buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProcessAnImage(buffer);
|
ProcessAnImage(memImage->header, memImage->size, memImage->firstIndex,
|
||||||
|
memImage->data);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
fifo_->FreeAddress(buffer);
|
fifo->FreeAddress(buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stream (if time/freq to stream) or free
|
// stream (if time/freq to stream) or free
|
||||||
if (streamCurrentFrame_) {
|
if (streamCurrentFrame) {
|
||||||
// copy the complete image back if roi enabled
|
// copy the complete image back if roi enabled
|
||||||
if (receiverRoiEnabled_) {
|
if (receiverRoiEnabled) {
|
||||||
(*((uint32_t *)buffer)) = generalData_->imageSize;
|
memImage->size = generalData->imageSize;
|
||||||
memcpy(buffer + generalData_->fifoBufferHeaderSize, &completeImageToStreamBeforeCropping[0], generalData_->imageSize);
|
memcpy(memImage->data, &completeImageToStreamBeforeCropping[0],
|
||||||
|
generalData->imageSize);
|
||||||
}
|
}
|
||||||
fifo_->PushAddressToStream(buffer);
|
fifo->PushAddressToStream(buffer);
|
||||||
} else {
|
} else {
|
||||||
fifo_->FreeAddress(buffer);
|
fifo->FreeAddress(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,107 +298,86 @@ void DataProcessor::StopProcessing(char *buf) {
|
|||||||
LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy";
|
LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy";
|
||||||
|
|
||||||
// stream or free
|
// stream or free
|
||||||
if (*dataStreamEnable_)
|
if (dataStreamEnable)
|
||||||
fifo_->PushAddressToStream(buf);
|
fifo->PushAddressToStream(buf);
|
||||||
else
|
else
|
||||||
fifo_->FreeAddress(buf);
|
fifo->FreeAddress(buf);
|
||||||
|
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
StopRunning();
|
StopRunning();
|
||||||
LOG(logDEBUG1) << index << ": Processing Completed";
|
LOG(logDEBUG1) << index << ": Processing Completed";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::ProcessAnImage(char *buf) {
|
void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
|
||||||
|
size_t &firstImageIndex, char *data) {
|
||||||
auto *rheader =
|
uint64_t fnum = header.detHeader.frameNumber;
|
||||||
reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
|
|
||||||
sls_detector_header header = rheader->detHeader;
|
|
||||||
uint64_t fnum = header.frameNumber;
|
|
||||||
currentFrameIndex_ = fnum;
|
|
||||||
numFramesCaught_++;
|
|
||||||
uint32_t nump = header.packetNumber;
|
|
||||||
|
|
||||||
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
||||||
|
currentFrameIndex = fnum;
|
||||||
|
numFramesCaught++;
|
||||||
|
uint32_t nump = header.detHeader.packetNumber;
|
||||||
|
|
||||||
if (!startedFlag_) {
|
if (!startedFlag) {
|
||||||
RecordFirstIndex(fnum);
|
RecordFirstIndex(fnum);
|
||||||
if (*dataStreamEnable_) {
|
if (dataStreamEnable) {
|
||||||
// restart timer
|
// restart timer
|
||||||
clock_gettime(CLOCK_REALTIME, &timerbegin_);
|
clock_gettime(CLOCK_REALTIME, &timerbegin);
|
||||||
timerbegin_.tv_sec -= (*streamingTimerInMs_) / 1000;
|
timerbegin.tv_sec -= streamingTimerInMs / 1000;
|
||||||
timerbegin_.tv_nsec -= ((*streamingTimerInMs_) % 1000) * 1000000;
|
timerbegin.tv_nsec -= (streamingTimerInMs % 1000) * 1000000;
|
||||||
|
|
||||||
// to send first image
|
// to send first image
|
||||||
currentFreqCount_ = *streamingFrequency_ - *streamingStartFnum_;
|
currentFreqCount = streamingFrequency - streamingStartFnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// frame padding
|
// frame padding
|
||||||
if (activated_ && *framePadding_ && nump < generalData_->packetsPerFrame)
|
if (framePadding && nump < generalData->packetsPerFrame)
|
||||||
PadMissingPackets(buf);
|
PadMissingPackets(header, data);
|
||||||
|
|
||||||
// rearrange ctb digital bits (if ctbDbitlist is not empty)
|
// rearrange ctb digital bits (if ctbDbitlist is not empty)
|
||||||
if (!(*ctbDbitList_).empty()) {
|
if (!ctbDbitList.empty()) {
|
||||||
RearrangeDbitData(buf);
|
RearrangeDbitData(size, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'stream Image' check has to be done here before crop image
|
// 'stream Image' check has to be done here before crop image
|
||||||
// stream (if time/freq to stream) or free
|
// stream (if time/freq to stream) or free
|
||||||
if (*dataStreamEnable_ && SendToStreamer()) {
|
if (dataStreamEnable && SendToStreamer()) {
|
||||||
// if first frame to stream, add frame index to fifo header (might
|
if (firstStreamerFrame) {
|
||||||
// not be the first)
|
firstStreamerFrame = false;
|
||||||
if (firstStreamerFrame_) {
|
// write to memory structure of first streamer frame
|
||||||
firstStreamerFrame_ = false;
|
firstImageIndex = firstIndex;
|
||||||
(*((uint32_t *)(buf + FIFO_DATASIZE_NUMBYTES))) =
|
|
||||||
(uint32_t)(fnum - firstIndex_);
|
|
||||||
}
|
}
|
||||||
streamCurrentFrame_ = true;
|
streamCurrentFrame = true;
|
||||||
} else {
|
} else {
|
||||||
streamCurrentFrame_ = false;
|
streamCurrentFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (receiverRoiEnabled) {
|
||||||
if (receiverRoiEnabled_) {
|
|
||||||
// copy the complete image to stream before cropping
|
// copy the complete image to stream before cropping
|
||||||
if (streamCurrentFrame_) {
|
if (streamCurrentFrame) {
|
||||||
memcpy(&completeImageToStreamBeforeCropping[0], buf + generalData_->fifoBufferHeaderSize, generalData_->imageSize);
|
memcpy(&completeImageToStreamBeforeCropping[0], data,
|
||||||
|
generalData->imageSize);
|
||||||
}
|
}
|
||||||
CropImage(buf);
|
CropImage(size, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// normal call back
|
// normal call back
|
||||||
if (rawDataReadyCallBack != nullptr) {
|
if (rawDataReadyCallBack != nullptr) {
|
||||||
std::size_t dsize = *reinterpret_cast<uint32_t *>(buf);
|
rawDataReadyCallBack(header, data, size, pRawDataReady);
|
||||||
rawDataReadyCallBack(rheader,
|
|
||||||
buf + FIFO_HEADER_NUMBYTES +
|
|
||||||
sizeof(sls_receiver_header),
|
|
||||||
dsize, pRawDataReady);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// call back with modified size
|
// call back with modified size
|
||||||
else if (rawDataModifyReadyCallBack != nullptr) {
|
else if (rawDataModifyReadyCallBack != nullptr) {
|
||||||
std::size_t revsize = *reinterpret_cast<uint32_t *>(buf);
|
rawDataModifyReadyCallBack(header, data, size, pRawDataReady);
|
||||||
rawDataModifyReadyCallBack(rheader,
|
|
||||||
buf + FIFO_HEADER_NUMBYTES +
|
|
||||||
sizeof(sls_receiver_header),
|
|
||||||
revsize, pRawDataReady);
|
|
||||||
(*((uint32_t *)buf)) = revsize;
|
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
throw RuntimeError("Get Data Callback Error: " +
|
throw RuntimeError("Get Data Callback Error: " + std::string(e.what()));
|
||||||
std::string(e.what()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
if (dataFile_) {
|
if (dataFile) {
|
||||||
try {
|
try {
|
||||||
dataFile_->WriteToFile(
|
dataFile->WriteToFile(data, header, size, fnum - firstIndex, nump);
|
||||||
buf + FIFO_HEADER_NUMBYTES,
|
|
||||||
sizeof(sls_receiver_header) +
|
|
||||||
(uint32_t)(*((uint32_t *)buf)), //+ size of data (resizable
|
|
||||||
// from previous call back
|
|
||||||
fnum - firstIndex_, nump);
|
|
||||||
} catch (const 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)
|
||||||
@ -395,7 +387,7 @@ void DataProcessor::ProcessAnImage(char *buf) {
|
|||||||
|
|
||||||
bool DataProcessor::SendToStreamer() {
|
bool DataProcessor::SendToStreamer() {
|
||||||
// skip
|
// skip
|
||||||
if ((*streamingFrequency_) == 0u) {
|
if (streamingFrequency == 0u) {
|
||||||
if (!CheckTimer())
|
if (!CheckTimer())
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -409,9 +401,9 @@ bool DataProcessor::CheckTimer() {
|
|||||||
struct timespec end;
|
struct timespec end;
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
|
||||||
auto elapsed_s = (end.tv_sec - timerbegin_.tv_sec) +
|
auto elapsed_s = (end.tv_sec - timerbegin.tv_sec) +
|
||||||
(end.tv_nsec - timerbegin_.tv_nsec) / 1e9;
|
(end.tv_nsec - timerbegin.tv_nsec) / 1e9;
|
||||||
double timer_s = *streamingTimerInMs_ / 1e3;
|
double timer_s = streamingTimerInMs / 1e3;
|
||||||
|
|
||||||
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
|
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
|
||||||
<< " seconds";
|
<< " seconds";
|
||||||
@ -421,47 +413,45 @@ bool DataProcessor::CheckTimer() {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// restart timer
|
// restart timer
|
||||||
clock_gettime(CLOCK_REALTIME, &timerbegin_);
|
clock_gettime(CLOCK_REALTIME, &timerbegin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataProcessor::CheckCount() {
|
bool DataProcessor::CheckCount() {
|
||||||
if (currentFreqCount_ == *streamingFrequency_) {
|
if (currentFreqCount == streamingFrequency) {
|
||||||
currentFreqCount_ = 1;
|
currentFreqCount = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
currentFreqCount_++;
|
currentFreqCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::registerCallBackRawDataReady(
|
void DataProcessor::registerCallBackRawDataReady(
|
||||||
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
|
void (*func)(sls_receiver_header &, char *, size_t, void *), void *arg) {
|
||||||
rawDataReadyCallBack = func;
|
rawDataReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::registerCallBackRawDataModifyReady(
|
void DataProcessor::registerCallBackRawDataModifyReady(
|
||||||
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
|
void (*func)(sls_receiver_header &, char *, size_t &, void *), void *arg) {
|
||||||
rawDataModifyReadyCallBack = func;
|
rawDataModifyReadyCallBack = func;
|
||||||
pRawDataReady = arg;
|
pRawDataReady = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::PadMissingPackets(char *buf) {
|
void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) {
|
||||||
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||||
|
|
||||||
uint32_t pperFrame = generalData_->packetsPerFrame;
|
uint32_t pperFrame = generalData->packetsPerFrame;
|
||||||
auto *header =
|
|
||||||
reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
|
|
||||||
uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
|
|
||||||
sls_bitset pmask = header->packetsMask;
|
|
||||||
|
|
||||||
uint32_t dsize = generalData_->dataSize;
|
uint32_t nmissing = pperFrame - header.detHeader.packetNumber;
|
||||||
if (detectorType_ == GOTTHARD2 && index != 0) {
|
sls_bitset pmask = header.packetsMask;
|
||||||
dsize = generalData_->vetoDataSize;
|
|
||||||
|
uint32_t dsize = generalData->dataSize;
|
||||||
|
if (generalData->detType == GOTTHARD2 && index != 0) {
|
||||||
|
dsize = generalData->vetoDataSize;
|
||||||
}
|
}
|
||||||
uint32_t fifohsize = generalData_->fifoBufferHeaderSize;
|
|
||||||
uint32_t corrected_dsize =
|
uint32_t corrected_dsize =
|
||||||
dsize - ((pperFrame * dsize) - generalData_->imageSize);
|
dsize - ((pperFrame * dsize) - generalData->imageSize);
|
||||||
LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
|
LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
|
||||||
|
|
||||||
for (unsigned int pnum = 0; pnum < pperFrame; ++pnum) {
|
for (unsigned int pnum = 0; pnum < pperFrame; ++pnum) {
|
||||||
@ -478,26 +468,26 @@ void DataProcessor::PadMissingPackets(char *buf) {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// missing packet
|
// missing packet
|
||||||
switch (detectorType_) {
|
switch (generalData->detType) {
|
||||||
// for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes
|
// for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes
|
||||||
// data
|
// data
|
||||||
// 2nd packet: 4 bytes fnum, previous 1*2 bytes data +
|
// 2nd packet: 4 bytes fnum, previous 1*2 bytes data +
|
||||||
// 640*2 bytes data !!
|
// 640*2 bytes data !!
|
||||||
case GOTTHARD:
|
case GOTTHARD:
|
||||||
if (pnum == 0u)
|
if (pnum == 0u)
|
||||||
memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize - 2);
|
memset(data + (pnum * dsize), 0xFF, dsize - 2);
|
||||||
else
|
else
|
||||||
memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize + 2);
|
memset(data + (pnum * dsize), 0xFF, dsize + 2);
|
||||||
break;
|
break;
|
||||||
case CHIPTESTBOARD:
|
case CHIPTESTBOARD:
|
||||||
case MOENCH:
|
case MOENCH:
|
||||||
if (pnum == (pperFrame - 1))
|
if (pnum == (pperFrame - 1))
|
||||||
memset(buf + fifohsize + (pnum * dsize), 0xFF, corrected_dsize);
|
memset(data + (pnum * dsize), 0xFF, corrected_dsize);
|
||||||
else
|
else
|
||||||
memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize);
|
memset(data + (pnum * dsize), 0xFF, dsize);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
memset(buf + fifohsize + (pnum * dsize), 0xFF, dsize);
|
memset(data + (pnum * dsize), 0xFF, dsize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--nmissing;
|
--nmissing;
|
||||||
@ -505,11 +495,10 @@ void DataProcessor::PadMissingPackets(char *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** ctb specific */
|
/** ctb specific */
|
||||||
void DataProcessor::RearrangeDbitData(char *buf) {
|
void DataProcessor::RearrangeDbitData(size_t &size, char *data) {
|
||||||
|
int nAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
|
||||||
// TODO! (Erik) Refactor and add tests
|
// TODO! (Erik) Refactor and add tests
|
||||||
int totalSize = (int)(*((uint32_t *)buf));
|
int ctbDigitalDataBytes = size - nAnalogDataBytes - ctbDbitOffset;
|
||||||
int ctbDigitalDataBytes =
|
|
||||||
totalSize - (*ctbAnalogDataBytes_) - (*ctbDbitOffset_);
|
|
||||||
|
|
||||||
// no digital data
|
// no digital data
|
||||||
if (ctbDigitalDataBytes == 0) {
|
if (ctbDigitalDataBytes == 0) {
|
||||||
@ -519,20 +508,17 @@ void DataProcessor::RearrangeDbitData(char *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int numSamples = (ctbDigitalDataBytes / sizeof(uint64_t));
|
const int numSamples = (ctbDigitalDataBytes / sizeof(uint64_t));
|
||||||
const int digOffset = FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header) +
|
|
||||||
(*ctbAnalogDataBytes_);
|
|
||||||
|
|
||||||
// ceil as numResult8Bits could be decimal
|
// ceil as numResult8Bits could be decimal
|
||||||
const int numResult8Bits =
|
const int numResult8Bits = ceil((numSamples * ctbDbitList.size()) / 8.00);
|
||||||
ceil((numSamples * (*ctbDbitList_).size()) / 8.00);
|
|
||||||
std::vector<uint8_t> result(numResult8Bits);
|
std::vector<uint8_t> result(numResult8Bits);
|
||||||
uint8_t *dest = &result[0];
|
uint8_t *dest = &result[0];
|
||||||
|
|
||||||
auto *source = (uint64_t *)(buf + digOffset + (*ctbDbitOffset_));
|
auto *source = (uint64_t *)(data + nAnalogDataBytes + ctbDbitOffset);
|
||||||
|
|
||||||
// loop through digital bit enable vector
|
// loop through digital bit enable vector
|
||||||
int bitoffset = 0;
|
int bitoffset = 0;
|
||||||
for (auto bi : (*ctbDbitList_)) {
|
for (auto bi : ctbDbitList) {
|
||||||
// where numbits * numsamples is not a multiple of 8
|
// where numbits * numsamples is not a multiple of 8
|
||||||
if (bitoffset != 0) {
|
if (bitoffset != 0) {
|
||||||
bitoffset = 0;
|
bitoffset = 0;
|
||||||
@ -553,18 +539,19 @@ void DataProcessor::RearrangeDbitData(char *buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy back to buf and update size
|
// copy back to memory and update size
|
||||||
memcpy(buf + digOffset, result.data(), numResult8Bits * sizeof(uint8_t));
|
memcpy(data + nAnalogDataBytes, result.data(),
|
||||||
(*((uint32_t *)buf)) = numResult8Bits * sizeof(uint8_t);
|
numResult8Bits * sizeof(uint8_t));
|
||||||
|
size = numResult8Bits * sizeof(uint8_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::CropImage(char *buf) {
|
void DataProcessor::CropImage(size_t &size, char *data) {
|
||||||
LOG(logDEBUG) << "Cropping Image to ROI " << 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;
|
||||||
int ymin = receiverRoi_.ymin;
|
int ymin = receiverRoi.ymin;
|
||||||
int ymax = receiverRoi_.ymax;
|
int ymax = receiverRoi.ymax;
|
||||||
int xwidth = xmax - xmin + 1;
|
int xwidth = xmax - xmin + 1;
|
||||||
int ywidth = ymax - ymin + 1;
|
int ywidth = ymax - ymin + 1;
|
||||||
if (ymin == -1 || ymax == -1) {
|
if (ymin == -1 || ymax == -1) {
|
||||||
@ -573,16 +560,16 @@ void DataProcessor::CropImage(char *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculate total roi size
|
// calculate total roi size
|
||||||
double bytesPerPixel = generalData_->dynamicRange / 8.00;
|
double bytesPerPixel = generalData->dynamicRange / 8.00;
|
||||||
int startOffset = (int)((nPixelsX * ymin + xmin) * bytesPerPixel);
|
int startOffset = (int)((nPixelsX * ymin + xmin) * bytesPerPixel);
|
||||||
|
|
||||||
// write size into fifo buffer header
|
// write size into memory
|
||||||
std::size_t roiImageSize = xwidth * ywidth * bytesPerPixel;
|
std::size_t roiImageSize = xwidth * ywidth * bytesPerPixel;
|
||||||
LOG(logDEBUG) << "roiImageSize:" << roiImageSize;
|
LOG(logDEBUG) << "roiImageSize:" << roiImageSize;
|
||||||
(*((uint32_t *)buf)) = roiImageSize;
|
size = roiImageSize;
|
||||||
|
|
||||||
// copy the roi to the beginning of the image
|
// copy the roi to the beginning of the image
|
||||||
char *dstOffset = buf + generalData_->fifoBufferHeaderSize;
|
char *dstOffset = data;
|
||||||
char *srcOffset = dstOffset + startOffset;
|
char *srcOffset = dstOffset + startOffset;
|
||||||
|
|
||||||
// entire width
|
// entire width
|
||||||
@ -594,7 +581,7 @@ void DataProcessor::CropImage(char *buf) {
|
|||||||
for (int y = 0; y != ywidth; ++y) {
|
for (int y = 0; y != ywidth; ++y) {
|
||||||
memcpy(dstOffset, srcOffset, xwidth * bytesPerPixel);
|
memcpy(dstOffset, srcOffset, xwidth * bytesPerPixel);
|
||||||
dstOffset += (int)(xwidth * bytesPerPixel);
|
dstOffset += (int)(xwidth * bytesPerPixel);
|
||||||
srcOffset += (int)(generalData_->nPixelsX * bytesPerPixel);
|
srcOffset += (int)(generalData->nPixelsX * bytesPerPixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,46 +29,45 @@ struct MasterAttributes;
|
|||||||
class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataProcessor(int index, detectorType detectorType, Fifo *fifo,
|
DataProcessor(int index);
|
||||||
bool *dataStreamEnable, uint32_t *streamingFrequency,
|
|
||||||
uint32_t *streamingTimerInMs, uint32_t *streamingStartFnum,
|
|
||||||
bool *framePadding, std::vector<int> *ctbDbitList,
|
|
||||||
int *ctbDbitOffset, int *ctbAnalogDataBytes);
|
|
||||||
|
|
||||||
~DataProcessor() override;
|
~DataProcessor() override;
|
||||||
|
|
||||||
bool GetStartedFlag() const;
|
bool GetStartedFlag() const;
|
||||||
|
|
||||||
void SetFifo(Fifo *f);
|
void SetFifo(Fifo *f);
|
||||||
void SetActivate(bool enable);
|
|
||||||
void SetReceiverROI(ROI roi);
|
|
||||||
void ResetParametersforNewAcquisition();
|
|
||||||
void SetGeneralData(GeneralData *generalData);
|
void SetGeneralData(GeneralData *generalData);
|
||||||
|
|
||||||
|
void SetActivate(bool enable);
|
||||||
|
void SetReceiverROI(ROI roi);
|
||||||
|
void SetDataStreamEnable(bool enable);
|
||||||
|
void SetStreamingFrequency(uint32_t value);
|
||||||
|
void SetStreamingTimerInMs(uint32_t value);
|
||||||
|
void SetStreamingStartFnum(uint32_t value);
|
||||||
|
void SetFramePadding(bool enable);
|
||||||
|
void SetCtbDbitList(std::vector<int> value);
|
||||||
|
void SetCtbDbitOffset(int value);
|
||||||
|
|
||||||
|
void ResetParametersforNewAcquisition();
|
||||||
void CloseFiles();
|
void CloseFiles();
|
||||||
void DeleteFiles();
|
void DeleteFiles();
|
||||||
void SetupFileWriter(const bool filewriteEnable,
|
void SetupFileWriter(const bool filewriteEnable,
|
||||||
const fileFormat fileFormatType,
|
const fileFormat fileFormatType,
|
||||||
std::mutex *hdf5LibMutex);
|
std::mutex *hdf5LibMutex);
|
||||||
|
|
||||||
void CreateFirstFiles(const std::string &filePath,
|
void CreateFirstFiles(const std::string &fileNamePrefix,
|
||||||
const std::string &fileNamePrefix,
|
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex, const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode, const uint32_t udpPortNumber,
|
||||||
const int numUnitsPerReadout,
|
const uint64_t numImages,
|
||||||
const uint32_t udpPortNumber,
|
|
||||||
const uint32_t maxFramesPerFile,
|
|
||||||
const uint64_t numImages, const uint32_t dynamicRange,
|
|
||||||
const bool detectorDataStream);
|
const bool detectorDataStream);
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
uint32_t GetFilesInAcquisition() const;
|
uint32_t GetFilesInAcquisition() const;
|
||||||
std::string CreateVirtualFile(
|
std::string CreateVirtualFile(const std::string &filePath,
|
||||||
const std::string &filePath, const std::string &fileNamePrefix,
|
const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const uint64_t fileIndex,
|
||||||
|
const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode, const int modulePos,
|
||||||
const int numUnitsPerReadout, const uint32_t maxFramesPerFile,
|
const uint64_t numImages, const int numModX,
|
||||||
const uint64_t numImages, const int numModX, const int numModY,
|
const int numModY, std::mutex *hdf5LibMutex);
|
||||||
const uint32_t dynamicRange, std::mutex *hdf5LibMutex);
|
|
||||||
void LinkFileInMaster(const std::string &masterFileName,
|
void LinkFileInMaster(const std::string &masterFileName,
|
||||||
const std::string &virtualFileName,
|
const std::string &virtualFileName,
|
||||||
const bool silentMode, std::mutex *hdf5LibMutex);
|
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||||
@ -82,14 +81,13 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
MasterAttributes *attr,
|
MasterAttributes *attr,
|
||||||
std::mutex *hdf5LibMutex);
|
std::mutex *hdf5LibMutex);
|
||||||
|
|
||||||
/** params: sls_receiver_header pointer, pointer to data, image size */
|
/** params: sls_receiver_header, pointer to data, image size */
|
||||||
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
|
void registerCallBackRawDataReady(void (*func)(sls_receiver_header &,
|
||||||
char *, size_t, void *),
|
char *, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
/** params: sls_receiver_header pointer, pointer to data, reference to image
|
/** params: sls_receiver_header, pointer to data, reference to image size */
|
||||||
* size */
|
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header &,
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
|
|
||||||
char *, size_t &,
|
char *, size_t &,
|
||||||
void *),
|
void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
@ -114,7 +112,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Process an image popped from fifo,
|
* Process an image popped from fifo,
|
||||||
* write to file if fw enabled & update parameters
|
* write to file if fw enabled & update parameters
|
||||||
*/
|
*/
|
||||||
void ProcessAnImage(char *buf);
|
void ProcessAnImage(sls_receiver_header &header, size_t &size,
|
||||||
|
size_t &firstImageIndex, char *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls CheckTimer and CheckCount for streaming frequency and timer
|
* Calls CheckTimer and CheckCount for streaming frequency and timer
|
||||||
@ -137,52 +136,50 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
bool CheckCount();
|
bool CheckCount();
|
||||||
|
|
||||||
void PadMissingPackets(char *buf);
|
void PadMissingPackets(sls_receiver_header header, char *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Align corresponding digital bits together (CTB only if ctbDbitlist is not
|
* Align corresponding digital bits together (CTB only if ctbDbitlist is not
|
||||||
* empty)
|
* empty)
|
||||||
*/
|
*/
|
||||||
void RearrangeDbitData(char *buf);
|
void RearrangeDbitData(size_t &size, char *data);
|
||||||
|
|
||||||
void CropImage(char *buf);
|
void CropImage(size_t &size, char *data);
|
||||||
|
|
||||||
static const std::string typeName_;
|
static const std::string typeName;
|
||||||
|
|
||||||
const GeneralData *generalData_{nullptr};
|
GeneralData *generalData{nullptr};
|
||||||
Fifo *fifo_;
|
Fifo *fifo;
|
||||||
detectorType detectorType_;
|
bool dataStreamEnable;
|
||||||
bool *dataStreamEnable_;
|
bool activated{false};
|
||||||
bool activated_{false};
|
ROI receiverRoi{};
|
||||||
ROI receiverRoi_{};
|
bool receiverRoiEnabled{false};
|
||||||
bool receiverRoiEnabled_{false};
|
bool receiverNoRoi{false};
|
||||||
bool receiverNoRoi_{false};
|
|
||||||
std::unique_ptr<char[]> completeImageToStreamBeforeCropping;
|
std::unique_ptr<char[]> completeImageToStreamBeforeCropping;
|
||||||
/** if 0, sending random images with a timer */
|
/** if 0, sending random images with a timer */
|
||||||
uint32_t *streamingFrequency_;
|
uint32_t streamingFrequency;
|
||||||
uint32_t *streamingTimerInMs_;
|
uint32_t streamingTimerInMs;
|
||||||
uint32_t *streamingStartFnum_;
|
uint32_t streamingStartFnum;
|
||||||
uint32_t currentFreqCount_{0};
|
uint32_t currentFreqCount{0};
|
||||||
struct timespec timerbegin_ {};
|
struct timespec timerbegin {};
|
||||||
bool *framePadding_;
|
bool framePadding;
|
||||||
std::vector<int> *ctbDbitList_;
|
std::vector<int> ctbDbitList;
|
||||||
int *ctbDbitOffset_;
|
int ctbDbitOffset;
|
||||||
int *ctbAnalogDataBytes_;
|
std::atomic<bool> startedFlag{false};
|
||||||
std::atomic<bool> startedFlag_{false};
|
std::atomic<uint64_t> firstIndex{0};
|
||||||
std::atomic<uint64_t> firstIndex_{0};
|
|
||||||
|
|
||||||
// for statistics
|
// for statistics
|
||||||
uint64_t numFramesCaught_{0};
|
uint64_t numFramesCaught{0};
|
||||||
|
|
||||||
/** Frame Number of latest processed frame number */
|
/** Frame Number of latest processed frame number */
|
||||||
std::atomic<uint64_t> currentFrameIndex_{0};
|
std::atomic<uint64_t> currentFrameIndex{0};
|
||||||
|
|
||||||
/** first streamer frame to add frame index in fifo header */
|
/** first streamer frame to add frame index in fifo header */
|
||||||
bool firstStreamerFrame_{false};
|
bool firstStreamerFrame{false};
|
||||||
|
|
||||||
bool streamCurrentFrame_{false};
|
bool streamCurrentFrame{false};
|
||||||
|
|
||||||
File *dataFile_{nullptr};
|
File *dataFile{nullptr};
|
||||||
|
|
||||||
// call back
|
// call back
|
||||||
/**
|
/**
|
||||||
@ -192,7 +189,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* dataPointer is the pointer to the data
|
* dataPointer is the pointer to the data
|
||||||
* dataSize in bytes is the size of the data in bytes.
|
* dataSize in bytes is the size of the data in bytes.
|
||||||
*/
|
*/
|
||||||
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
|
void (*rawDataReadyCallBack)(sls_receiver_header &, char *, size_t,
|
||||||
void *) = nullptr;
|
void *) = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,7 +200,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* revDatasize is the reference of data size in bytes. Can be modified to
|
* revDatasize is the reference of data size in bytes. Can be modified to
|
||||||
* the new size to be written/streamed. (only smaller value).
|
* the new size to be written/streamed. (only smaller value).
|
||||||
*/
|
*/
|
||||||
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
|
void (*rawDataModifyReadyCallBack)(sls_receiver_header &, char *, size_t &,
|
||||||
void *) = nullptr;
|
void *) = nullptr;
|
||||||
|
|
||||||
void *pRawDataReady{nullptr};
|
void *pRawDataReady{nullptr};
|
||||||
|
@ -18,14 +18,8 @@ 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 index) : ThreadObject(index, TypeName) {
|
||||||
bool fr, slsDetectorDefs::xy np, bool *qe,
|
LOG(logDEBUG) << "DataStreamer " << index << " created";
|
||||||
uint64_t *tot)
|
|
||||||
: ThreadObject(ind, TypeName), fifo(f), dynamicRange(dr), detectorRoi(r),
|
|
||||||
fileIndex(fi), flipRows(fr), numPorts(np), quadEnable(qe),
|
|
||||||
totalNumFrames(tot) {
|
|
||||||
|
|
||||||
LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataStreamer::~DataStreamer() {
|
DataStreamer::~DataStreamer() {
|
||||||
@ -35,6 +29,33 @@ DataStreamer::~DataStreamer() {
|
|||||||
|
|
||||||
void DataStreamer::SetFifo(Fifo *f) { fifo = f; }
|
void DataStreamer::SetFifo(Fifo *f) { fifo = f; }
|
||||||
|
|
||||||
|
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||||
|
|
||||||
|
void DataStreamer::SetFileIndex(uint64_t value) { fileIndex = value; }
|
||||||
|
|
||||||
|
void DataStreamer::SetNumberofPorts(xy np) { numPorts = np; }
|
||||||
|
|
||||||
|
void DataStreamer::SetFlipRows(bool fd) {
|
||||||
|
flipRows = fd;
|
||||||
|
// flip only right port of quad
|
||||||
|
if (quadEnable) {
|
||||||
|
flipRows = (index == 1 ? true : false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataStreamer::SetQuadEnable(bool value) { quadEnable = value; }
|
||||||
|
|
||||||
|
void DataStreamer::SetNumberofTotalFrames(uint64_t value) {
|
||||||
|
nTotalFrames = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataStreamer::SetAdditionalJsonHeader(
|
||||||
|
const std::map<std::string, std::string> &json) {
|
||||||
|
std::lock_guard<std::mutex> lock(additionalJsonMutex);
|
||||||
|
additionalJsonHeader = json;
|
||||||
|
isAdditionalJsonUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
|
void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
|
||||||
StopRunning();
|
StopRunning();
|
||||||
startedFlag = false;
|
startedFlag = false;
|
||||||
@ -45,38 +66,23 @@ void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
|
|||||||
delete[] completeBuffer;
|
delete[] completeBuffer;
|
||||||
completeBuffer = nullptr;
|
completeBuffer = nullptr;
|
||||||
}
|
}
|
||||||
if (generalData->myDetectorType == GOTTHARD && detectorRoi->xmin != -1) {
|
if (generalData->detType == GOTTHARD &&
|
||||||
adcConfigured = generalData->GetAdcConfigured(index, *detectorRoi);
|
generalData->detectorRoi.xmin != -1) {
|
||||||
|
adcConfigured =
|
||||||
|
generalData->GetAdcConfigured(index, generalData->detectorRoi);
|
||||||
completeBuffer = new char[generalData->imageSizeComplete];
|
completeBuffer = new char[generalData->imageSizeComplete];
|
||||||
memset(completeBuffer, 0, generalData->imageSizeComplete);
|
memset(completeBuffer, 0, generalData->imageSizeComplete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::RecordFirstIndex(uint64_t fnum, char *buf) {
|
void DataStreamer::RecordFirstIndex(uint64_t fnum, size_t firstImageIndex) {
|
||||||
startedFlag = true;
|
startedFlag = true;
|
||||||
// streamer first index needn't be
|
firstIndex = firstImageIndex;
|
||||||
uint64_t firstVal = fnum - (*((uint32_t *)(buf + FIFO_DATASIZE_NUMBYTES)));
|
|
||||||
|
|
||||||
firstIndex = firstVal;
|
|
||||||
LOG(logDEBUG1) << index << " First Index: " << firstIndex
|
LOG(logDEBUG1) << index << " First Index: " << firstIndex
|
||||||
<< ", First Streamer Index:" << fnum;
|
<< ", First Streamer Index:" << fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
|
void DataStreamer::CreateZmqSockets(uint32_t port, const IpAddr ip, int hwm) {
|
||||||
|
|
||||||
void DataStreamer::SetNumberofPorts(xy np) { numPorts = np; }
|
|
||||||
|
|
||||||
void DataStreamer::SetFlipRows(bool fd) { flipRows = fd; }
|
|
||||||
|
|
||||||
void DataStreamer::SetAdditionalJsonHeader(
|
|
||||||
const std::map<std::string, std::string> &json) {
|
|
||||||
std::lock_guard<std::mutex> lock(additionalJsonMutex);
|
|
||||||
additionalJsonHeader = json;
|
|
||||||
isAdditionalJsonUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataStreamer::CreateZmqSockets(int *nunits, uint32_t port,
|
|
||||||
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 {
|
||||||
@ -110,20 +116,25 @@ void DataStreamer::CloseZmqSocket() {
|
|||||||
void DataStreamer::ThreadExecution() {
|
void DataStreamer::ThreadExecution() {
|
||||||
char *buffer = nullptr;
|
char *buffer = nullptr;
|
||||||
fifo->PopAddressToStream(buffer);
|
fifo->PopAddressToStream(buffer);
|
||||||
LOG(logDEBUG5) << "DataStreamer " << index
|
LOG(logDEBUG5) << "DataStreamer " << index << ", pop 0x" << std::hex
|
||||||
<< ", "
|
<< (void *)(buffer) << std::dec << ":" << buffer;
|
||||||
"pop 0x"
|
auto *memImage = reinterpret_cast<image_structure *>(buffer);
|
||||||
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
|
|
||||||
|
|
||||||
// check dummy
|
// check dummy
|
||||||
auto numBytes = *reinterpret_cast<uint32_t *>(buffer);
|
LOG(logDEBUG1) << "DataStreamer " << index
|
||||||
LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << numBytes;
|
<< ", Numbytes:" << memImage->size;
|
||||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
if (memImage->size == DUMMY_PACKET_VALUE) {
|
||||||
StopProcessing(buffer);
|
StopProcessing(buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessAnImage(buffer);
|
// streamer first index needn't be the very first index
|
||||||
|
if (!startedFlag) {
|
||||||
|
RecordFirstIndex(memImage->header.detHeader.frameNumber,
|
||||||
|
memImage->firstIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessAnImage(memImage->header.detHeader, memImage->size, memImage->data);
|
||||||
|
|
||||||
// free
|
// free
|
||||||
fifo->FreeAddress(buffer);
|
fifo->FreeAddress(buffer);
|
||||||
@ -131,12 +142,10 @@ void DataStreamer::ThreadExecution() {
|
|||||||
|
|
||||||
void DataStreamer::StopProcessing(char *buf) {
|
void DataStreamer::StopProcessing(char *buf) {
|
||||||
LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy";
|
LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy";
|
||||||
|
if (!SendDummyHeader()) {
|
||||||
sls_receiver_header *header = (sls_receiver_header *)(buf);
|
LOG(logERROR)
|
||||||
// send dummy header and data
|
<< "Could not send zmq dummy header for streamer for port "
|
||||||
if (!SendHeader(header, 0, 0, 0, true)) {
|
<< zmqSocket->GetPortNumber();
|
||||||
LOG(logERROR) << "Could not send zmq dummy header for streamer "
|
|
||||||
<< index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fifo->FreeAddress(buf);
|
fifo->FreeAddress(buf);
|
||||||
@ -145,35 +154,26 @@ void DataStreamer::StopProcessing(char *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** buf includes only the standard header */
|
/** buf includes only the standard header */
|
||||||
void DataStreamer::ProcessAnImage(char *buf) {
|
void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size,
|
||||||
|
char *data) {
|
||||||
|
|
||||||
sls_receiver_header *header =
|
uint64_t fnum = header.frameNumber;
|
||||||
(sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
|
|
||||||
uint64_t fnum = header->detHeader.frameNumber;
|
|
||||||
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
|
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
|
||||||
|
|
||||||
if (!startedFlag) {
|
|
||||||
RecordFirstIndex(fnum, buf);
|
|
||||||
}
|
|
||||||
auto numBytes = *reinterpret_cast<uint32_t *>(buf);
|
|
||||||
|
|
||||||
// shortframe gotthard
|
// shortframe gotthard
|
||||||
if (completeBuffer) {
|
if (completeBuffer) {
|
||||||
// disregarding the size modified from callback (always using
|
// disregarding the size modified from callback (always using
|
||||||
// imageSizeComplete
|
// imageSizeComplete instead of size because gui needs
|
||||||
// instead of buf (32 bit) because gui needs imagesizecomplete and
|
// imagesizecomplete and listener writes imagesize to size
|
||||||
// listener
|
|
||||||
// write imagesize
|
|
||||||
|
|
||||||
if (!SendHeader(header, generalData->imageSizeComplete,
|
if (!SendDataHeader(header, generalData->imageSizeComplete,
|
||||||
generalData->nPixelsXComplete,
|
generalData->nPixelsXComplete,
|
||||||
generalData->nPixelsYComplete, false)) {
|
generalData->nPixelsYComplete)) {
|
||||||
LOG(logERROR) << "Could not send zmq header for fnum " << fnum
|
LOG(logERROR) << "Could not send zmq header for fnum " << fnum
|
||||||
<< " and streamer " << index;
|
<< " and streamer " << index;
|
||||||
}
|
}
|
||||||
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
|
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
|
||||||
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
data, size);
|
||||||
numBytes);
|
|
||||||
|
|
||||||
if (!zmqSocket->SendData(completeBuffer,
|
if (!zmqSocket->SendData(completeBuffer,
|
||||||
generalData->imageSizeComplete)) {
|
generalData->imageSizeComplete)) {
|
||||||
@ -185,39 +185,36 @@ void DataStreamer::ProcessAnImage(char *buf) {
|
|||||||
// normal
|
// normal
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if (!SendHeader(header, numBytes, generalData->nPixelsX,
|
if (!SendDataHeader(header, size, generalData->nPixelsX,
|
||||||
generalData->nPixelsY,
|
generalData->nPixelsY)) {
|
||||||
false)) { // new size possibly from callback
|
|
||||||
LOG(logERROR) << "Could not send zmq header for fnum " << fnum
|
LOG(logERROR) << "Could not send zmq header for fnum " << fnum
|
||||||
<< " and streamer " << index;
|
<< " and streamer " << index;
|
||||||
}
|
}
|
||||||
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES +
|
if (!zmqSocket->SendData(data, size)) {
|
||||||
sizeof(sls_receiver_header),
|
|
||||||
numBytes)) { // new size possibly from callback
|
|
||||||
LOG(logERROR) << "Could not send zmq data for fnum " << fnum
|
LOG(logERROR) << "Could not send zmq data for fnum " << fnum
|
||||||
<< " and streamer " << index;
|
<< " and streamer " << index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size,
|
int DataStreamer::SendDummyHeader() {
|
||||||
uint32_t nx, uint32_t ny, bool dummy) {
|
|
||||||
|
|
||||||
zmqHeader zHeader;
|
zmqHeader zHeader;
|
||||||
zHeader.data = !dummy;
|
zHeader.data = false;
|
||||||
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
||||||
|
|
||||||
if (dummy) {
|
|
||||||
return zmqSocket->SendHeader(index, zHeader);
|
return zmqSocket->SendHeader(index, zHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_header header = rheader->detHeader;
|
int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
|
||||||
|
uint32_t nx, uint32_t ny) {
|
||||||
|
zmqHeader zHeader;
|
||||||
|
zHeader.data = true;
|
||||||
|
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
||||||
|
|
||||||
uint64_t frameIndex = header.frameNumber - firstIndex;
|
uint64_t frameIndex = header.frameNumber - firstIndex;
|
||||||
uint64_t acquisitionIndex = header.frameNumber;
|
uint64_t acquisitionIndex = header.frameNumber;
|
||||||
|
|
||||||
zHeader.dynamicRange = *dynamicRange;
|
zHeader.dynamicRange = generalData->dynamicRange;
|
||||||
zHeader.fileIndex = *fileIndex;
|
zHeader.fileIndex = fileIndex;
|
||||||
zHeader.ndetx = numPorts.x;
|
zHeader.ndetx = numPorts.x;
|
||||||
zHeader.ndety = numPorts.y;
|
zHeader.ndety = numPorts.y;
|
||||||
zHeader.npixelsx = nx;
|
zHeader.npixelsx = nx;
|
||||||
@ -226,7 +223,7 @@ int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size,
|
|||||||
zHeader.acqIndex = acquisitionIndex;
|
zHeader.acqIndex = acquisitionIndex;
|
||||||
zHeader.frameIndex = frameIndex;
|
zHeader.frameIndex = frameIndex;
|
||||||
zHeader.progress =
|
zHeader.progress =
|
||||||
100 * ((double)(frameIndex + 1) / (double)(*totalNumFrames));
|
100 * ((double)(frameIndex + 1) / (double)(nTotalFrames));
|
||||||
zHeader.fname = fileNametoStream;
|
zHeader.fname = fileNametoStream;
|
||||||
zHeader.frameNumber = header.frameNumber;
|
zHeader.frameNumber = header.frameNumber;
|
||||||
zHeader.expLength = header.expLength;
|
zHeader.expLength = header.expLength;
|
||||||
@ -242,7 +239,7 @@ int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size,
|
|||||||
zHeader.detType = header.detType;
|
zHeader.detType = header.detType;
|
||||||
zHeader.version = header.version;
|
zHeader.version = header.version;
|
||||||
zHeader.flipRows = static_cast<int>(flipRows);
|
zHeader.flipRows = static_cast<int>(flipRows);
|
||||||
zHeader.quad = *quadEnable;
|
zHeader.quad = quadEnable;
|
||||||
zHeader.completeImage =
|
zHeader.completeImage =
|
||||||
(header.packetNumber < generalData->packetsPerFrame ? false : true);
|
(header.packetNumber < generalData->packetsPerFrame ? false : true);
|
||||||
|
|
||||||
@ -258,14 +255,8 @@ int DataStreamer::SendHeader(sls_receiver_header *rheader, uint32_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataStreamer::RestreamStop() {
|
void DataStreamer::RestreamStop() {
|
||||||
// send dummy header
|
if (!SendDummyHeader()) {
|
||||||
zmqHeader zHeader;
|
throw RuntimeError("Could not restream Dummy Header via ZMQ for port " +
|
||||||
zHeader.data = false;
|
|
||||||
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
|
||||||
int ret = zmqSocket->SendHeader(index, zHeader);
|
|
||||||
if (!ret) {
|
|
||||||
throw RuntimeError(
|
|
||||||
"Could not restream Dummy Header via ZMQ for port " +
|
|
||||||
std::to_string(zmqSocket->GetPortNumber()));
|
std::to_string(zmqSocket->GetPortNumber()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,57 +25,38 @@ class ZmqSocket;
|
|||||||
class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
DataStreamer(int index);
|
||||||
* Constructor
|
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments
|
|
||||||
* NumberofDataStreamers
|
|
||||||
* @param ind self index
|
|
||||||
* @param f address of Fifo pointer
|
|
||||||
* @param dr pointer to dynamic range
|
|
||||||
* @param r detectorRoi
|
|
||||||
* @param fi pointer to file index
|
|
||||||
* @param fr flip rows
|
|
||||||
* @param nm number of ports in each dimension
|
|
||||||
* @param qe pointer to quad Enable
|
|
||||||
* @param tot pointer to total number of frames
|
|
||||||
*/
|
|
||||||
DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi, bool fr,
|
|
||||||
xy np, bool *qe, uint64_t *tot);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
* Calls Base Class DestroyThread() and decrements NumberofDataStreamers
|
|
||||||
*/
|
|
||||||
~DataStreamer();
|
~DataStreamer();
|
||||||
|
|
||||||
void SetFifo(Fifo *f);
|
void SetFifo(Fifo *f);
|
||||||
void ResetParametersforNewAcquisition(const std::string &fname);
|
|
||||||
void SetGeneralData(GeneralData *g);
|
void SetGeneralData(GeneralData *g);
|
||||||
|
|
||||||
|
void SetFileIndex(uint64_t value);
|
||||||
void SetNumberofPorts(xy np);
|
void SetNumberofPorts(xy np);
|
||||||
void SetFlipRows(bool fd);
|
void SetFlipRows(bool fd);
|
||||||
|
void SetQuadEnable(bool value);
|
||||||
|
void SetNumberofTotalFrames(uint64_t value);
|
||||||
void
|
void
|
||||||
SetAdditionalJsonHeader(const std::map<std::string, std::string> &json);
|
SetAdditionalJsonHeader(const std::map<std::string, std::string> &json);
|
||||||
|
|
||||||
|
void ResetParametersforNewAcquisition(const std::string &fname);
|
||||||
/**
|
/**
|
||||||
* Creates Zmq Sockets
|
* Creates Zmq Sockets
|
||||||
* (throws an exception if it couldnt create zmq sockets)
|
* (throws an exception if it couldnt create zmq sockets)
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
|
||||||
* @param port streaming port start index
|
* @param port streaming port start index
|
||||||
* @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 IpAddr ip,
|
void CreateZmqSockets(uint32_t port, const IpAddr ip, int hwm);
|
||||||
int hwm);
|
|
||||||
void CloseZmqSocket();
|
void CloseZmqSocket();
|
||||||
void RestreamStop();
|
void RestreamStop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Record First Index
|
* Record First Index
|
||||||
* @param fnum current frame number
|
|
||||||
* @param buf get frame index from buffer to calculate first index to record
|
|
||||||
*/
|
*/
|
||||||
void RecordFirstIndex(uint64_t fnum, char *buf);
|
void RecordFirstIndex(uint64_t fnum, size_t firstImageIndex);
|
||||||
|
|
||||||
void ThreadExecution();
|
void ThreadExecution();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,7 +69,9 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Process an image popped from fifo,
|
* Process an image popped from fifo,
|
||||||
* write to file if fw enabled & update parameters
|
* write to file if fw enabled & update parameters
|
||||||
*/
|
*/
|
||||||
void ProcessAnImage(char *buf);
|
void ProcessAnImage(sls_detector_header header, size_t size, char *data);
|
||||||
|
|
||||||
|
int SendDummyHeader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and send Json Header
|
* Create and send Json Header
|
||||||
@ -96,21 +79,18 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* @param size data size (could have been modified in call back)
|
* @param size data size (could have been modified in call back)
|
||||||
* @param nx number of pixels in x dim
|
* @param nx number of pixels in x dim
|
||||||
* @param ny number of pixels in y dim
|
* @param ny number of pixels in y dim
|
||||||
* @param dummy true if its a dummy header
|
|
||||||
* @returns 0 if error, else 1
|
* @returns 0 if error, else 1
|
||||||
*/
|
*/
|
||||||
int SendHeader(sls_receiver_header *rheader, uint32_t size = 0,
|
int SendDataHeader(sls_detector_header header, uint32_t size = 0,
|
||||||
uint32_t nx = 0, uint32_t ny = 0, bool dummy = true);
|
uint32_t nx = 0, uint32_t ny = 0);
|
||||||
|
|
||||||
static const std::string TypeName;
|
static const std::string TypeName;
|
||||||
const GeneralData *generalData{nullptr};
|
const GeneralData *generalData{nullptr};
|
||||||
Fifo *fifo;
|
Fifo *fifo{nullptr};
|
||||||
ZmqSocket *zmqSocket{nullptr};
|
ZmqSocket *zmqSocket{nullptr};
|
||||||
uint32_t *dynamicRange;
|
|
||||||
ROI *detectorRoi;
|
|
||||||
int adcConfigured{-1};
|
int adcConfigured{-1};
|
||||||
uint64_t *fileIndex;
|
uint64_t fileIndex{0};
|
||||||
bool flipRows;
|
bool flipRows{false};
|
||||||
std::map<std::string, std::string> additionalJsonHeader;
|
std::map<std::string, std::string> additionalJsonHeader;
|
||||||
|
|
||||||
/** Used by streamer thread to update local copy (reduce number of locks
|
/** Used by streamer thread to update local copy (reduce number of locks
|
||||||
@ -130,8 +110,8 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
char *completeBuffer{nullptr};
|
char *completeBuffer{nullptr};
|
||||||
|
|
||||||
xy numPorts{1, 1};
|
xy numPorts{1, 1};
|
||||||
bool *quadEnable;
|
bool quadEnable{false};
|
||||||
uint64_t *totalNumFrames;
|
uint64_t nTotalFrames{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth)
|
Fifo::Fifo(int index, size_t fifoItemSize, uint32_t fifoDepth)
|
||||||
: index(ind), memory(nullptr), fifoBound(nullptr), fifoFree(nullptr),
|
: index(index), memory(nullptr), fifoBound(nullptr), fifoFree(nullptr),
|
||||||
fifoStream(nullptr), fifoDepth(depth), status_fifoBound(0),
|
fifoStream(nullptr), fifoDepth(fifoDepth), status_fifoBound(0),
|
||||||
status_fifoFree(depth) {
|
status_fifoFree(fifoDepth) {
|
||||||
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
CreateFifos(fifoItemSize);
|
CreateFifos(fifoItemSize);
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ Fifo::~Fifo() {
|
|||||||
DestroyFifos();
|
DestroyFifos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
void Fifo::CreateFifos(size_t fifoItemSize) {
|
||||||
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
|
|
||||||
// destroy if not already
|
// destroy if not already
|
||||||
@ -41,7 +41,7 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
|||||||
fifoFree = new CircularFifo<char>(fifoDepth);
|
fifoFree = new CircularFifo<char>(fifoDepth);
|
||||||
fifoStream = new 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 = fifoItemSize * (size_t)fifoDepth * sizeof(char);
|
||||||
memory = (char *)malloc(mem_len);
|
memory = (char *)malloc(mem_len);
|
||||||
if (memory == nullptr) {
|
if (memory == nullptr) {
|
||||||
throw RuntimeError("Could not allocate memory for fifos");
|
throw RuntimeError("Could not allocate memory for fifos");
|
||||||
|
@ -21,95 +21,36 @@ namespace sls {
|
|||||||
class Fifo : private virtual slsDetectorDefs {
|
class Fifo : private virtual slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
Fifo(int index, size_t fifoItemSize, uint32_t fifoDepth);
|
||||||
* Constructor
|
|
||||||
* Calls CreateFifos that creates fifos and allocates memory
|
|
||||||
* @param ind self index
|
|
||||||
* @param fifoItemSize size of each fifo item
|
|
||||||
* @param depth fifo depth
|
|
||||||
*/
|
|
||||||
Fifo(int ind, uint32_t fifoItemSize, uint32_t depth);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
~Fifo();
|
~Fifo();
|
||||||
|
|
||||||
/**
|
|
||||||
* Frees the bound address by pushing into fifoFree
|
|
||||||
*/
|
|
||||||
void FreeAddress(char *&address);
|
void FreeAddress(char *&address);
|
||||||
|
|
||||||
/**
|
|
||||||
* Pops free address from fifoFree
|
|
||||||
*/
|
|
||||||
void GetNewAddress(char *&address);
|
void GetNewAddress(char *&address);
|
||||||
|
|
||||||
/**
|
/** to process data */
|
||||||
* Pushes bound address into fifoBound
|
|
||||||
*/
|
|
||||||
void PushAddress(char *&address);
|
void PushAddress(char *&address);
|
||||||
|
|
||||||
/**
|
|
||||||
* Pops bound address from fifoBound to process data
|
|
||||||
*/
|
|
||||||
void PopAddress(char *&address);
|
void PopAddress(char *&address);
|
||||||
|
|
||||||
/**
|
|
||||||
* Pushes bound address into fifoStream
|
|
||||||
*/
|
|
||||||
void PushAddressToStream(char *&address);
|
void PushAddressToStream(char *&address);
|
||||||
|
|
||||||
/**
|
|
||||||
* Pops bound address from fifoStream to stream data
|
|
||||||
*/
|
|
||||||
void PopAddressToStream(char *&address);
|
void PopAddressToStream(char *&address);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Maximum Level filled in Fifo Bound
|
|
||||||
* and reset this value for next intake
|
|
||||||
*/
|
|
||||||
int GetMaxLevelForFifoBound();
|
int GetMaxLevelForFifoBound();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Minimum Level filled in Fifo Free
|
|
||||||
* and reset this value to max for next intake
|
|
||||||
*/
|
|
||||||
int GetMinLevelForFifoFree();
|
int GetMinLevelForFifoFree();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/** also allocate memory & push addresses into free fifo */
|
||||||
* Create Fifos, allocate memory & push addresses into fifo
|
void CreateFifos(size_t fifoItemSize);
|
||||||
* @param fifoItemSize size of each fifo item
|
/** also deallocate memory */
|
||||||
*/
|
|
||||||
void CreateFifos(uint32_t fifoItemSize);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy Fifos and deallocate memory
|
|
||||||
*/
|
|
||||||
void DestroyFifos();
|
void DestroyFifos();
|
||||||
|
|
||||||
/** Self Index */
|
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
/** Memory allocated, whose addresses are pushed into the fifos */
|
|
||||||
char *memory;
|
char *memory;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of bound data in memory */
|
|
||||||
CircularFifo<char> *fifoBound;
|
CircularFifo<char> *fifoBound;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of freed data in memory */
|
|
||||||
CircularFifo<char> *fifoFree;
|
CircularFifo<char> *fifoFree;
|
||||||
|
|
||||||
/** Circular Fifo pointing to addresses of to be streamed data in memory */
|
|
||||||
CircularFifo<char> *fifoStream;
|
CircularFifo<char> *fifoStream;
|
||||||
|
|
||||||
/** Fifo depth set */
|
|
||||||
int fifoDepth;
|
int fifoDepth;
|
||||||
|
|
||||||
volatile int status_fifoBound;
|
volatile int status_fifoBound;
|
||||||
volatile int status_fifoFree;
|
volatile int status_fifoFree;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#include "File.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace sls {
|
|
||||||
|
|
||||||
File::File(const slsDetectorDefs::fileFormat format) : format_(format) {}
|
|
||||||
|
|
||||||
File::~File() {}
|
|
||||||
|
|
||||||
slsDetectorDefs::fileFormat File::GetFileFormat() const { return format_; }
|
|
||||||
|
|
||||||
} // namespace sls
|
|
@ -18,16 +18,15 @@ struct MasterAttributes;
|
|||||||
class File : private virtual slsDetectorDefs {
|
class File : private virtual slsDetectorDefs {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
File(const slsDetectorDefs::fileFormat format);
|
File(){};
|
||||||
virtual ~File();
|
virtual ~File(){};
|
||||||
|
|
||||||
fileFormat GetFileFormat() const;
|
virtual fileFormat GetFileFormat() const = 0;
|
||||||
virtual void CloseFile() = 0;
|
virtual void CloseFile() = 0;
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
virtual std::string GetFileName() const {
|
virtual std::string GetFileName() const {
|
||||||
LOG(logERROR)
|
LOG(logERROR) << "This is a generic function GetFileName that "
|
||||||
<< "This is a generic function GetFileName that "
|
|
||||||
"should be overloaded by a derived class";
|
"should be overloaded by a derived class";
|
||||||
return std::string{};
|
return std::string{};
|
||||||
}
|
}
|
||||||
@ -46,8 +45,7 @@ class File : private virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<std::string> GetParameterNames() const {
|
virtual std::vector<std::string> GetParameterNames() const {
|
||||||
LOG(logERROR)
|
LOG(logERROR) << "This is a generic function GetParameterNames that "
|
||||||
<< "This is a generic function GetParameterNames that "
|
|
||||||
"should be overloaded by a derived class";
|
"should be overloaded by a derived class";
|
||||||
return std::vector<std::string>{};
|
return std::vector<std::string>{};
|
||||||
};
|
};
|
||||||
@ -60,33 +58,31 @@ class File : private virtual slsDetectorDefs {
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual void CreateFirstHDF5DataFile(
|
virtual void CreateFirstHDF5DataFile(
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const std::string &fileNamePrefix, const uint64_t fileIndex,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const bool overWriteEnable, const bool silentMode,
|
||||||
const bool silentMode, const int modulePos,
|
const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
|
||||||
const int numUnitsPerReadout, const uint32_t udpPortNumber,
|
const uint64_t numImages, const uint32_t nPixelsX,
|
||||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
const uint32_t nPixelsY, const uint32_t dynamicRange) {
|
||||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
LOG(logERROR)
|
||||||
const uint32_t dynamicRange) {
|
<< "This is a generic function CreateFirstHDF5DataFile that "
|
||||||
LOG(logERROR) << "This is a generic function CreateFirstHDF5DataFile that "
|
|
||||||
"should be overloaded by a derived class";
|
"should be overloaded by a derived class";
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
virtual void CreateFirstBinaryDataFile(
|
virtual void CreateFirstBinaryDataFile(const std::string &fileNamePrefix,
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const uint64_t fileIndex,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const bool overWriteEnable,
|
||||||
const bool silentMode, const int modulePos,
|
const bool silentMode,
|
||||||
const int numUnitsPerReadout, const uint32_t udpPortNumber,
|
const uint32_t udpPortNumber,
|
||||||
const uint32_t maxFramesPerFile) {
|
const uint32_t maxFramesPerFile) {
|
||||||
LOG(logERROR) << "This is a generic function CreateFirstBinaryDataFile that "
|
LOG(logERROR)
|
||||||
|
<< "This is a generic function CreateFirstBinaryDataFile that "
|
||||||
"should be overloaded by a derived class";
|
"should be overloaded by a derived class";
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void WriteToFile(char *buffer, const int buffersize,
|
virtual void WriteToFile(char *imageData, sls_receiver_header &header,
|
||||||
|
const int imageSize,
|
||||||
const uint64_t currentFrameNumber,
|
const uint64_t currentFrameNumber,
|
||||||
const uint32_t numPacketsCaught) = 0;
|
const uint32_t numPacketsCaught) = 0;
|
||||||
|
|
||||||
protected:
|
|
||||||
slsDetectorDefs::fileFormat format_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -21,7 +21,7 @@ namespace sls {
|
|||||||
class GeneralData {
|
class GeneralData {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
slsDetectorDefs::detectorType myDetectorType{slsDetectorDefs::GENERIC};
|
slsDetectorDefs::detectorType detType{slsDetectorDefs::GENERIC};
|
||||||
uint32_t nPixelsX{0};
|
uint32_t nPixelsX{0};
|
||||||
uint32_t nPixelsY{0};
|
uint32_t nPixelsY{0};
|
||||||
uint32_t headerSizeinPacket{0};
|
uint32_t headerSizeinPacket{0};
|
||||||
@ -36,11 +36,9 @@ class GeneralData {
|
|||||||
uint32_t frameIndexOffset{0};
|
uint32_t frameIndexOffset{0};
|
||||||
uint32_t packetIndexMask{0};
|
uint32_t packetIndexMask{0};
|
||||||
uint32_t packetIndexOffset{0};
|
uint32_t packetIndexOffset{0};
|
||||||
uint32_t maxFramesPerFile{0};
|
uint32_t framesPerFile{0};
|
||||||
/** Header size of data saved into fifo buffer at a time*/
|
uint32_t fifoDepth{0};
|
||||||
uint32_t fifoBufferHeaderSize{0};
|
int numUDPInterfaces{1};
|
||||||
uint32_t defaultFifoDepth{0};
|
|
||||||
uint32_t numUDPInterfaces{1};
|
|
||||||
uint32_t headerPacketSize{0};
|
uint32_t headerPacketSize{0};
|
||||||
/** Streaming (for ROI - mainly short Gotthard) */
|
/** Streaming (for ROI - mainly short Gotthard) */
|
||||||
uint32_t nPixelsXComplete{0};
|
uint32_t nPixelsXComplete{0};
|
||||||
@ -50,7 +48,7 @@ class GeneralData {
|
|||||||
uint32_t imageSizeComplete{0};
|
uint32_t imageSizeComplete{0};
|
||||||
/** if standard header implemented in firmware */
|
/** if standard header implemented in firmware */
|
||||||
bool standardheader{false};
|
bool standardheader{false};
|
||||||
uint32_t defaultUdpSocketBufferSize{RECEIVE_SOCKET_BUFFER_SIZE};
|
uint32_t udpSocketBufferSize{RECEIVE_SOCKET_BUFFER_SIZE};
|
||||||
uint32_t vetoDataSize{0};
|
uint32_t vetoDataSize{0};
|
||||||
uint32_t vetoPacketSize{0};
|
uint32_t vetoPacketSize{0};
|
||||||
uint32_t vetoImageSize{0};
|
uint32_t vetoImageSize{0};
|
||||||
@ -63,7 +61,7 @@ class GeneralData {
|
|||||||
slsDetectorDefs::readoutMode readoutType{slsDetectorDefs::ANALOG_ONLY};
|
slsDetectorDefs::readoutMode readoutType{slsDetectorDefs::ANALOG_ONLY};
|
||||||
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
||||||
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
||||||
slsDetectorDefs::ROI roi{};
|
slsDetectorDefs::ROI detectorRoi{};
|
||||||
uint32_t counterMask{0};
|
uint32_t counterMask{0};
|
||||||
|
|
||||||
GeneralData(){};
|
GeneralData(){};
|
||||||
@ -163,12 +161,10 @@ class GotthardData : public GeneralData {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
GotthardData() {
|
GotthardData() {
|
||||||
myDetectorType = slsDetectorDefs::GOTTHARD;
|
detType = slsDetectorDefs::GOTTHARD;
|
||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
headerSizeinPacket = 6;
|
headerSizeinPacket = 6;
|
||||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
framesPerFile = MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferHeaderSize =
|
|
||||||
FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -251,7 +247,7 @@ class GotthardData : public GeneralData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void SetDetectorROI(slsDetectorDefs::ROI i) {
|
void SetDetectorROI(slsDetectorDefs::ROI i) {
|
||||||
roi = i;
|
detectorRoi = i;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -259,18 +255,18 @@ class GotthardData : public GeneralData {
|
|||||||
void UpdateImageSize() {
|
void UpdateImageSize() {
|
||||||
|
|
||||||
// all adcs
|
// all adcs
|
||||||
if (roi.xmin == -1) {
|
if (detectorRoi.xmin == -1) {
|
||||||
nPixelsX = 1280;
|
nPixelsX = 1280;
|
||||||
dataSize = 1280;
|
dataSize = 1280;
|
||||||
packetsPerFrame = 2;
|
packetsPerFrame = 2;
|
||||||
frameIndexMask = 0xFFFFFFFE;
|
frameIndexMask = 0xFFFFFFFE;
|
||||||
frameIndexOffset = 1;
|
frameIndexOffset = 1;
|
||||||
packetIndexMask = 1;
|
packetIndexMask = 1;
|
||||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
framesPerFile = MAX_FRAMES_PER_FILE;
|
||||||
nPixelsXComplete = 0;
|
nPixelsXComplete = 0;
|
||||||
nPixelsYComplete = 0;
|
nPixelsYComplete = 0;
|
||||||
imageSizeComplete = 0;
|
imageSizeComplete = 0;
|
||||||
defaultFifoDepth = 50000;
|
fifoDepth = 50000;
|
||||||
} else {
|
} else {
|
||||||
nPixelsX = 256;
|
nPixelsX = 256;
|
||||||
dataSize = 512;
|
dataSize = 512;
|
||||||
@ -278,11 +274,11 @@ class GotthardData : public GeneralData {
|
|||||||
frameIndexMask = 0xFFFFFFFF;
|
frameIndexMask = 0xFFFFFFFF;
|
||||||
frameIndexOffset = 0;
|
frameIndexOffset = 0;
|
||||||
packetIndexMask = 0;
|
packetIndexMask = 0;
|
||||||
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
framesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
||||||
nPixelsXComplete = 1280;
|
nPixelsXComplete = 1280;
|
||||||
nPixelsYComplete = 1;
|
nPixelsYComplete = 1;
|
||||||
imageSizeComplete = 1280 * 2;
|
imageSizeComplete = 1280 * 2;
|
||||||
defaultFifoDepth = 75000;
|
fifoDepth = 75000;
|
||||||
}
|
}
|
||||||
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
||||||
packetSize = headerSizeinPacket + dataSize;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
@ -294,11 +290,9 @@ class EigerData : public GeneralData {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
EigerData() {
|
EigerData() {
|
||||||
myDetectorType = slsDetectorDefs::EIGER;
|
detType = slsDetectorDefs::EIGER;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
framesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferHeaderSize =
|
|
||||||
FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
|
||||||
numUDPInterfaces = 2;
|
numUDPInterfaces = 2;
|
||||||
headerPacketSize = 40;
|
headerPacketSize = 40;
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
@ -324,7 +318,7 @@ class EigerData : public GeneralData {
|
|||||||
packetSize = headerSizeinPacket + dataSize;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
||||||
packetsPerFrame = imageSize / dataSize;
|
packetsPerFrame = imageSize / dataSize;
|
||||||
defaultFifoDepth = (dynamicRange == 32 ? 100 : 1000);
|
fifoDepth = (dynamicRange == 32 ? 100 : 1000);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -332,14 +326,12 @@ class JungfrauData : public GeneralData {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
JungfrauData() {
|
JungfrauData() {
|
||||||
myDetectorType = slsDetectorDefs::JUNGFRAU;
|
detType = slsDetectorDefs::JUNGFRAU;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
dataSize = 8192;
|
dataSize = 8192;
|
||||||
packetSize = headerSizeinPacket + dataSize;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
framesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferHeaderSize =
|
fifoDepth = 2500;
|
||||||
FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
|
||||||
defaultFifoDepth = 2500;
|
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
maxRowsPerReadout = 512;
|
maxRowsPerReadout = 512;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
@ -356,7 +348,7 @@ class JungfrauData : public GeneralData {
|
|||||||
nPixelsY = (256 * 2) / numUDPInterfaces;
|
nPixelsY = (256 * 2) / numUDPInterfaces;
|
||||||
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
imageSize = int(nPixelsX * nPixelsY * GetPixelDepth());
|
||||||
packetsPerFrame = imageSize / dataSize;
|
packetsPerFrame = imageSize / dataSize;
|
||||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
udpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -367,15 +359,13 @@ class Mythen3Data : public GeneralData {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Mythen3Data() {
|
Mythen3Data() {
|
||||||
myDetectorType = slsDetectorDefs::MYTHEN3;
|
detType = slsDetectorDefs::MYTHEN3;
|
||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
maxFramesPerFile = MYTHEN3_MAX_FRAMES_PER_FILE;
|
framesPerFile = MYTHEN3_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferHeaderSize =
|
fifoDepth = 50000;
|
||||||
FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
|
||||||
defaultFifoDepth = 50000;
|
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
|
udpSocketBufferSize = (1000 * 1024 * 1024);
|
||||||
dynamicRange = 32;
|
dynamicRange = 32;
|
||||||
tengigaEnable = true;
|
tengigaEnable = true;
|
||||||
SetCounterMask(0x7);
|
SetCounterMask(0x7);
|
||||||
@ -437,15 +427,13 @@ class Mythen3Data : public GeneralData {
|
|||||||
class Gotthard2Data : public GeneralData {
|
class Gotthard2Data : public GeneralData {
|
||||||
public:
|
public:
|
||||||
Gotthard2Data() {
|
Gotthard2Data() {
|
||||||
myDetectorType = slsDetectorDefs::GOTTHARD2;
|
detType = slsDetectorDefs::GOTTHARD2;
|
||||||
nPixelsX = 128 * 10;
|
nPixelsX = 128 * 10;
|
||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
dataSize = 2560; // 1280 channels * 2 bytes
|
dataSize = 2560; // 1280 channels * 2 bytes
|
||||||
maxFramesPerFile = GOTTHARD2_MAX_FRAMES_PER_FILE;
|
framesPerFile = GOTTHARD2_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferHeaderSize =
|
fifoDepth = 50000;
|
||||||
FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
|
||||||
defaultFifoDepth = 50000;
|
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
vetoDataSize = 160;
|
vetoDataSize = 160;
|
||||||
vetoHsize = 16;
|
vetoHsize = 16;
|
||||||
@ -481,7 +469,7 @@ class Gotthard2Data : public GeneralData {
|
|||||||
packetsPerFrame = imageSize / dataSize;
|
packetsPerFrame = imageSize / dataSize;
|
||||||
vetoPacketSize = vetoHsize + vetoDataSize;
|
vetoPacketSize = vetoHsize + vetoDataSize;
|
||||||
vetoImageSize = vetoDataSize * packetsPerFrame;
|
vetoImageSize = vetoDataSize * packetsPerFrame;
|
||||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
udpSocketBufferSize = (1000 * 1024 * 1024) / numUDPInterfaces;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -494,16 +482,14 @@ class ChipTestBoardData : public GeneralData {
|
|||||||
public:
|
public:
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
ChipTestBoardData() {
|
ChipTestBoardData() {
|
||||||
myDetectorType = slsDetectorDefs::CHIPTESTBOARD;
|
detType = slsDetectorDefs::CHIPTESTBOARD;
|
||||||
nPixelsY = 1; // number of samples
|
nPixelsY = 1; // number of samples
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
frameIndexMask = 0xFFFFFF; // 10g
|
frameIndexMask = 0xFFFFFF; // 10g
|
||||||
frameIndexOffset = 8; // 10g
|
frameIndexOffset = 8; // 10g
|
||||||
packetIndexMask = 0xFF; // 10g
|
packetIndexMask = 0xFF; // 10g
|
||||||
maxFramesPerFile = CTB_MAX_FRAMES_PER_FILE;
|
framesPerFile = CTB_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferHeaderSize =
|
fifoDepth = 2500;
|
||||||
FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
|
||||||
defaultFifoDepth = 2500;
|
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
@ -586,13 +572,11 @@ class MoenchData : public GeneralData {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MoenchData() {
|
MoenchData() {
|
||||||
myDetectorType = slsDetectorDefs::MOENCH;
|
detType = slsDetectorDefs::MOENCH;
|
||||||
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
|
||||||
frameIndexMask = 0xFFFFFF;
|
frameIndexMask = 0xFFFFFF;
|
||||||
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
framesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferHeaderSize =
|
fifoDepth = 2500;
|
||||||
FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
|
||||||
defaultFifoDepth = 2500;
|
|
||||||
standardheader = true;
|
standardheader = true;
|
||||||
UpdateImageSize();
|
UpdateImageSize();
|
||||||
};
|
};
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
|
HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
|
||||||
: File(HDF5), index_(index), hdf5Lib_(hdf5Lib) {
|
: index(index), hdf5Lib(hdf5Lib) {
|
||||||
|
|
||||||
parameterNames_ = std::vector<std::string>{
|
parameterNames = std::vector<std::string>{
|
||||||
"frame number",
|
"frame number",
|
||||||
"exp length or sub exposure time",
|
"exp length or sub exposure time",
|
||||||
"packets caught",
|
"packets caught",
|
||||||
@ -27,102 +27,98 @@ HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
|
|||||||
"packets caught bit mask",
|
"packets caught bit mask",
|
||||||
};
|
};
|
||||||
H5::StrType strdatatype(H5::PredType::C_S1, sizeof(bitset_storage));
|
H5::StrType strdatatype(H5::PredType::C_S1, sizeof(bitset_storage));
|
||||||
parameterDataTypes_ = std::vector<H5::DataType>{
|
parameterDataTypes = std::vector<H5::DataType>{
|
||||||
H5::PredType::STD_U64LE, H5::PredType::STD_U32LE, H5::PredType::STD_U32LE,
|
H5::PredType::STD_U64LE, H5::PredType::STD_U32LE,
|
||||||
H5::PredType::STD_U64LE, H5::PredType::STD_U64LE, H5::PredType::STD_U16LE,
|
H5::PredType::STD_U32LE, H5::PredType::STD_U64LE,
|
||||||
H5::PredType::STD_U16LE, H5::PredType::STD_U16LE, H5::PredType::STD_U16LE,
|
H5::PredType::STD_U64LE, H5::PredType::STD_U16LE,
|
||||||
H5::PredType::STD_U32LE, H5::PredType::STD_U16LE, H5::PredType::STD_U8LE,
|
H5::PredType::STD_U16LE, H5::PredType::STD_U16LE,
|
||||||
|
H5::PredType::STD_U16LE, H5::PredType::STD_U32LE,
|
||||||
|
H5::PredType::STD_U16LE, H5::PredType::STD_U8LE,
|
||||||
H5::PredType::STD_U8LE, strdatatype};
|
H5::PredType::STD_U8LE, strdatatype};
|
||||||
}
|
}
|
||||||
|
|
||||||
HDF5DataFile::~HDF5DataFile() { CloseFile(); }
|
HDF5DataFile::~HDF5DataFile() { CloseFile(); }
|
||||||
|
|
||||||
std::string HDF5DataFile::GetFileName() const {
|
std::string HDF5DataFile::GetFileName() const { return fileName; }
|
||||||
return fileName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t HDF5DataFile::GetFilesInAcquisition() const {
|
uint32_t HDF5DataFile::GetFilesInAcquisition() const {
|
||||||
return numFilesInAcquisition_;
|
return numFilesInAcquisition;
|
||||||
}
|
}
|
||||||
|
|
||||||
H5::DataType HDF5DataFile::GetPDataType() const { return dataType_; }
|
H5::DataType HDF5DataFile::GetPDataType() const { return dataType; }
|
||||||
|
|
||||||
std::vector<std::string> HDF5DataFile::GetParameterNames() const {
|
std::vector<std::string> HDF5DataFile::GetParameterNames() const {
|
||||||
return parameterNames_;
|
return parameterNames;
|
||||||
}
|
}
|
||||||
std::vector<H5::DataType> HDF5DataFile::GetParameterDataTypes() const {
|
std::vector<H5::DataType> HDF5DataFile::GetParameterDataTypes() const {
|
||||||
return parameterDataTypes_;
|
return parameterDataTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slsDetectorDefs::fileFormat HDF5DataFile::GetFileFormat() const { return HDF5; }
|
||||||
|
|
||||||
void HDF5DataFile::CloseFile() {
|
void HDF5DataFile::CloseFile() {
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
std::lock_guard<std::mutex> lock(*hdf5Lib);
|
||||||
try {
|
try {
|
||||||
H5::Exception::dontPrint(); // to handle errors
|
H5::Exception::dontPrint(); // to handle errors
|
||||||
if (fd_) {
|
if (fd) {
|
||||||
fd_->close();
|
fd->close();
|
||||||
delete fd_;
|
delete fd;
|
||||||
fd_ = nullptr;
|
fd = nullptr;
|
||||||
}
|
}
|
||||||
} catch (const H5::Exception &error) {
|
} catch (const H5::Exception &error) {
|
||||||
LOG(logERROR) << "Could not close data HDF5 handles of index "
|
LOG(logERROR) << "Could not close data HDF5 handles of index " << index;
|
||||||
<< index_;
|
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
}
|
}
|
||||||
if (dataSpace_) {
|
if (dataSpace) {
|
||||||
delete dataSpace_;
|
delete dataSpace;
|
||||||
dataSpace_ = nullptr;
|
dataSpace = nullptr;
|
||||||
}
|
}
|
||||||
if (dataSet_) {
|
if (dataSet) {
|
||||||
delete dataSet_;
|
delete dataSet;
|
||||||
dataSet_ = nullptr;
|
dataSet = nullptr;
|
||||||
}
|
}
|
||||||
if (dataSpacePara_) {
|
if (dataSpacePara) {
|
||||||
delete dataSpacePara_;
|
delete dataSpacePara;
|
||||||
dataSpacePara_ = nullptr;
|
dataSpacePara = nullptr;
|
||||||
}
|
}
|
||||||
for (auto it : dataSetPara_)
|
for (auto it : dataSetPara)
|
||||||
delete it;
|
delete it;
|
||||||
dataSetPara_.clear();
|
dataSetPara.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::CreateFirstHDF5DataFile(
|
void HDF5DataFile::CreateFirstHDF5DataFile(
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const std::string &fNamePrefix, const uint64_t fIndex, const bool owEnable,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const bool sMode, const uint32_t uPortNumber, const uint32_t mFramesPerFile,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const uint64_t nImages, const uint32_t nX, const uint32_t nY,
|
||||||
const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
|
const uint32_t dr) {
|
||||||
const uint64_t numImages, const uint32_t nPixelsX, const uint32_t nPixelsY,
|
|
||||||
const uint32_t dynamicRange) {
|
|
||||||
|
|
||||||
subFileIndex_ = 0;
|
subFileIndex = 0;
|
||||||
numFramesInFile_ = 0;
|
numFramesInFile = 0;
|
||||||
extNumImages_ = numImages;
|
extNumImages = nImages;
|
||||||
numFilesInAcquisition_ = 0;
|
numFilesInAcquisition = 0;
|
||||||
|
|
||||||
maxFramesPerFile_ = maxFramesPerFile;
|
maxFramesPerFile = mFramesPerFile;
|
||||||
numImages_ = numImages;
|
numImages = nImages;
|
||||||
nPixelsX_ = nPixelsX;
|
nPixelsX = nX;
|
||||||
nPixelsY_ = nPixelsY;
|
nPixelsY = nY;
|
||||||
dynamicRange_ = dynamicRange;
|
dynamicRange = dr;
|
||||||
|
|
||||||
filePath_ = filePath;
|
fileNamePrefix = fNamePrefix;
|
||||||
fileNamePrefix_ = fileNamePrefix;
|
fileIndex = fIndex;
|
||||||
fileIndex_ = fileIndex;
|
overWriteEnable = owEnable;
|
||||||
overWriteEnable_ = overWriteEnable;
|
silentMode = sMode;
|
||||||
silentMode_ = silentMode;
|
udpPortNumber = uPortNumber;
|
||||||
detIndex_ = modulePos;
|
|
||||||
numUnitsPerReadout_ = numUnitsPerReadout;
|
|
||||||
udpPortNumber_ = udpPortNumber;
|
|
||||||
|
|
||||||
switch (dynamicRange_) {
|
switch (dynamicRange) {
|
||||||
case 12:
|
case 12:
|
||||||
case 16:
|
case 16:
|
||||||
dataType_ = H5::PredType::STD_U16LE;
|
dataType = H5::PredType::STD_U16LE;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
dataType_ = H5::PredType::STD_U32LE;
|
dataType = H5::PredType::STD_U32LE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dataType_ = H5::PredType::STD_U8LE;
|
dataType = H5::PredType::STD_U8LE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,27 +126,25 @@ void HDF5DataFile::CreateFirstHDF5DataFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::CreateFile() {
|
void HDF5DataFile::CreateFile() {
|
||||||
numFramesInFile_ = 0;
|
numFramesInFile = 0;
|
||||||
numFilesInAcquisition_++;
|
numFilesInAcquisition++;
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << filePath_ << "/" << fileNamePrefix_ << "_d"
|
os << fileNamePrefix << "_f" << subFileIndex << '_' << fileIndex << ".h5";
|
||||||
<< (detIndex_ * numUnitsPerReadout_ + index_) << "_f" << subFileIndex_
|
fileName = os.str();
|
||||||
<< '_' << fileIndex_ << ".h5";
|
|
||||||
fileName_ = os.str();
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
std::lock_guard<std::mutex> lock(*hdf5Lib);
|
||||||
|
|
||||||
uint64_t framestosave =
|
uint64_t framestosave =
|
||||||
((maxFramesPerFile_ == 0) ? numImages_ : // infinite images
|
((maxFramesPerFile == 0) ? numImages : // infinite images
|
||||||
(((extNumImages_ - subFileIndex_) > maxFramesPerFile_)
|
(((extNumImages - subFileIndex) > maxFramesPerFile)
|
||||||
? // save up to maximum at a time
|
? // save up to maximum at a time
|
||||||
maxFramesPerFile_
|
maxFramesPerFile
|
||||||
: (extNumImages_ - subFileIndex_)));
|
: (extNumImages - subFileIndex)));
|
||||||
|
|
||||||
uint64_t nDimx = framestosave;
|
uint64_t nDimx = framestosave;
|
||||||
uint32_t nDimy = nPixelsY_;
|
uint32_t nDimy = nPixelsY;
|
||||||
uint32_t nDimz = ((dynamicRange_ == 4) ? (nPixelsX_ / 2) : nPixelsX_);
|
uint32_t nDimz = ((dynamicRange == 4) ? (nPixelsX / 2) : nPixelsX);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
H5::Exception::dontPrint(); // to handle errors
|
H5::Exception::dontPrint(); // to handle errors
|
||||||
@ -158,90 +152,88 @@ void HDF5DataFile::CreateFile() {
|
|||||||
// file
|
// file
|
||||||
H5::FileAccPropList fapl;
|
H5::FileAccPropList fapl;
|
||||||
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||||
fd_ = nullptr;
|
fd = nullptr;
|
||||||
if (!overWriteEnable_)
|
if (!overWriteEnable)
|
||||||
fd_ = new H5::H5File(fileName_.c_str(), H5F_ACC_EXCL,
|
fd = new H5::H5File(fileName.c_str(), H5F_ACC_EXCL,
|
||||||
H5::FileCreatPropList::DEFAULT, fapl);
|
H5::FileCreatPropList::DEFAULT, fapl);
|
||||||
else
|
else
|
||||||
fd_ = new H5::H5File(fileName_.c_str(), H5F_ACC_TRUNC,
|
fd = new H5::H5File(fileName.c_str(), H5F_ACC_TRUNC,
|
||||||
H5::FileCreatPropList::DEFAULT, fapl);
|
H5::FileCreatPropList::DEFAULT, fapl);
|
||||||
|
|
||||||
// attributes - version
|
// attributes - version
|
||||||
double dValue = HDF5_WRITER_VERSION;
|
double dValue = HDF5_WRITER_VERSION;
|
||||||
H5::DataSpace dataspace_attr = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace_attr = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::Attribute attribute = fd_->createAttribute(
|
H5::Attribute attribute = fd->createAttribute(
|
||||||
"version", H5::PredType::NATIVE_DOUBLE, dataspace_attr);
|
"version", H5::PredType::NATIVE_DOUBLE, dataspace_attr);
|
||||||
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
|
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
|
||||||
|
|
||||||
|
// dimensions
|
||||||
|
hsize_t dims[DATA_RANK] = {nDimx, nDimy, nDimz};
|
||||||
|
hsize_t dimsMax[DATA_RANK] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||||
|
hsize_t dimsPara[PARA_RANK] = {nDimx};
|
||||||
|
hsize_t dimsMaxPara[PARA_RANK] = {H5S_UNLIMITED};
|
||||||
|
// always create chunked dataset as unlimited is only
|
||||||
|
// supported with chunked layout
|
||||||
|
hsize_t dimsChunk[DATA_RANK] = {MAX_CHUNKED_IMAGES, nDimy, nDimz};
|
||||||
|
hsize_t dimsChunkPara[PARA_RANK] = {MAX_CHUNKED_IMAGES};
|
||||||
|
|
||||||
// dataspace
|
// dataspace
|
||||||
hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
|
dataSpace = nullptr;
|
||||||
hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
dataSpace = new H5::DataSpace(DATA_RANK, dims, dimsMax);
|
||||||
dataSpace_ = nullptr;
|
dataSpacePara = nullptr;
|
||||||
dataSpace_ = new H5::DataSpace(3, srcdims, srcdimsmax);
|
dataSpacePara = new H5::DataSpace(PARA_RANK, dimsPara, dimsMaxPara);
|
||||||
|
|
||||||
|
// property list
|
||||||
|
H5::DSetCreatPropList plist;
|
||||||
|
H5::DSetCreatPropList plistPara;
|
||||||
|
int fill_value = -1;
|
||||||
|
plist.setFillValue(dataType, &fill_value);
|
||||||
|
// plistPara.setFillValue(dataType, &fill_value);
|
||||||
|
plist.setChunk(DATA_RANK, dimsChunk);
|
||||||
|
plistPara.setChunk(PARA_RANK, dimsChunkPara);
|
||||||
|
|
||||||
// dataset
|
// dataset
|
||||||
// fill value
|
dataSet = nullptr;
|
||||||
H5::DSetCreatPropList plist;
|
dataSet = new H5::DataSet(
|
||||||
int fill_value = -1;
|
fd->createDataSet(DATASET_NAME, dataType, *dataSpace, plist));
|
||||||
plist.setFillValue(dataType_, &fill_value);
|
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
||||||
// always create chunked dataset as unlimited is only
|
H5::DataSet *ds = new H5::DataSet(fd->createDataSet(
|
||||||
// supported with chunked layout
|
parameterNames[i].c_str(), parameterDataTypes[i],
|
||||||
hsize_t chunk_dims[3] = {MAX_CHUNKED_IMAGES, nDimy, nDimz};
|
*dataSpacePara, plistPara));
|
||||||
plist.setChunk(3, chunk_dims);
|
dataSetPara.push_back(ds);
|
||||||
dataSet_ = nullptr;
|
|
||||||
dataSet_ = new H5::DataSet(fd_->createDataSet(
|
|
||||||
DATASET_NAME, dataType_, *dataSpace_, plist));
|
|
||||||
|
|
||||||
// create parameter datasets
|
|
||||||
hsize_t dims[1] = {nDimx};
|
|
||||||
hsize_t dimsmax[1] = {H5S_UNLIMITED};
|
|
||||||
dataSpacePara_ = nullptr;
|
|
||||||
dataSpacePara_ = new H5::DataSpace(1, dims, dimsmax);
|
|
||||||
|
|
||||||
// always create chunked dataset as unlimited is only
|
|
||||||
// supported with chunked layout
|
|
||||||
H5::DSetCreatPropList paralist;
|
|
||||||
hsize_t chunkpara_dims[3] = {MAX_CHUNKED_IMAGES};
|
|
||||||
paralist.setChunk(1, chunkpara_dims);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < parameterNames_.size(); ++i) {
|
|
||||||
H5::DataSet *ds = new H5::DataSet(fd_->createDataSet(
|
|
||||||
parameterNames_[i].c_str(), parameterDataTypes_[i],
|
|
||||||
*dataSpacePara_, paralist));
|
|
||||||
dataSetPara_.push_back(ds);
|
|
||||||
}
|
}
|
||||||
} catch (const H5::Exception &error) {
|
} catch (const H5::Exception &error) {
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
CloseFile();
|
CloseFile();
|
||||||
throw RuntimeError("Could not create HDF5 handles in object " +
|
throw RuntimeError("Could not create HDF5 handles in object " + index);
|
||||||
index_);
|
|
||||||
}
|
}
|
||||||
if (!silentMode_) {
|
if (!silentMode) {
|
||||||
LOG(logINFO) << "[" << udpPortNumber_
|
LOG(logINFO) << "[" << udpPortNumber
|
||||||
<< "]: HDF5 File created: " << fileName_;
|
<< "]: HDF5 File created: " << fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::WriteToFile(char *buffer, const int buffersize,
|
void HDF5DataFile::WriteToFile(char *imageData, sls_receiver_header &header,
|
||||||
|
const int imageSize,
|
||||||
const uint64_t currentFrameNumber,
|
const uint64_t currentFrameNumber,
|
||||||
const uint32_t numPacketsCaught) {
|
const uint32_t numPacketsCaught) {
|
||||||
|
|
||||||
// check if maxframesperfile = 0 for infinite
|
// check if maxframesperfile = 0 for infinite
|
||||||
if (maxFramesPerFile_ && (numFramesInFile_ >= maxFramesPerFile_)) {
|
if (maxFramesPerFile && (numFramesInFile >= maxFramesPerFile)) {
|
||||||
CloseFile();
|
CloseFile();
|
||||||
++subFileIndex_;
|
++subFileIndex;
|
||||||
CreateFile();
|
CreateFile();
|
||||||
}
|
}
|
||||||
++numFramesInFile_;
|
++numFramesInFile;
|
||||||
|
|
||||||
// extend dataset (when receiver start followed by many status starts
|
// extend dataset (when receiver start followed by many status starts
|
||||||
// (jungfrau)))
|
// (jungfrau)))
|
||||||
if (currentFrameNumber >= extNumImages_) {
|
if (currentFrameNumber >= extNumImages) {
|
||||||
ExtendDataset();
|
ExtendDataset();
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteDataFile(currentFrameNumber, buffer + sizeof(sls_receiver_header));
|
WriteImageDatasets(currentFrameNumber, imageData);
|
||||||
WriteParameterDatasets(currentFrameNumber, (sls_receiver_header *)(buffer));
|
WriteParameterDatasets(currentFrameNumber, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::Convert12to16Bit(uint16_t *dst, uint8_t *src) {
|
void HDF5DataFile::Convert12to16Bit(uint16_t *dst, uint8_t *src) {
|
||||||
@ -254,27 +246,27 @@ void HDF5DataFile::Convert12to16Bit(uint16_t *dst, uint8_t *src) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::WriteDataFile(const uint64_t currentFrameNumber,
|
void HDF5DataFile::WriteImageDatasets(const uint64_t currentFrameNumber,
|
||||||
char *buffer) {
|
char *buffer) {
|
||||||
// expand 12 bit to 16 bits
|
// expand 12 bit to 16 bits
|
||||||
char *revBuffer = buffer;
|
char *revBuffer = buffer;
|
||||||
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 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));
|
||||||
}
|
}
|
||||||
Convert12to16Bit((uint16_t *)revBuffer, (uint8_t *)buffer);
|
Convert12to16Bit((uint16_t *)revBuffer, (uint8_t *)buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
std::lock_guard<std::mutex> lock(*hdf5Lib);
|
||||||
|
|
||||||
uint64_t nDimx =
|
uint64_t nDimx =
|
||||||
((maxFramesPerFile_ == 0) ? currentFrameNumber
|
((maxFramesPerFile == 0) ? currentFrameNumber
|
||||||
: currentFrameNumber % maxFramesPerFile_);
|
: currentFrameNumber % maxFramesPerFile);
|
||||||
uint32_t nDimy = nPixelsY_;
|
uint32_t nDimy = nPixelsY;
|
||||||
uint32_t nDimz = ((dynamicRange_ == 4) ? (nPixelsX_ / 2) : nPixelsX_);
|
uint32_t nDimz = ((dynamicRange == 4) ? (nPixelsX / 2) : nPixelsX);
|
||||||
|
|
||||||
hsize_t count[3] = {1, nDimy, nDimz};
|
hsize_t count[3] = {1, nDimy, nDimz};
|
||||||
hsize_t start[3] = {nDimx, 0, 0};
|
hsize_t start[3] = {nDimx, 0, 0};
|
||||||
@ -282,85 +274,85 @@ void HDF5DataFile::WriteDataFile(const uint64_t currentFrameNumber,
|
|||||||
try {
|
try {
|
||||||
H5::Exception::dontPrint(); // to handle errors
|
H5::Exception::dontPrint(); // to handle errors
|
||||||
|
|
||||||
dataSpace_->selectHyperslab(H5S_SELECT_SET, count, start);
|
dataSpace->selectHyperslab(H5S_SELECT_SET, count, start);
|
||||||
H5::DataSpace memspace(2, dims2);
|
H5::DataSpace memspace(2, dims2);
|
||||||
dataSet_->write(revBuffer, dataType_, memspace, *dataSpace_);
|
dataSet->write(revBuffer, dataType, memspace, *dataSpace);
|
||||||
memspace.close();
|
memspace.close();
|
||||||
if (dynamicRange_ == 12) {
|
if (dynamicRange == 12) {
|
||||||
free(revBuffer);
|
free(revBuffer);
|
||||||
}
|
}
|
||||||
} catch (const H5::Exception &error) {
|
} catch (const H5::Exception &error) {
|
||||||
if (dynamicRange_ == 12) {
|
if (dynamicRange == 12) {
|
||||||
free(revBuffer);
|
free(revBuffer);
|
||||||
}
|
}
|
||||||
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 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
|
void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
|
||||||
sls_receiver_header *rheader) {
|
sls_receiver_header rheader) {
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
std::lock_guard<std::mutex> lock(*hdf5Lib);
|
||||||
|
|
||||||
uint64_t fnum =
|
uint64_t fnum =
|
||||||
((maxFramesPerFile_ == 0) ? currentFrameNumber
|
((maxFramesPerFile == 0) ? currentFrameNumber
|
||||||
: currentFrameNumber % maxFramesPerFile_);
|
: currentFrameNumber % maxFramesPerFile);
|
||||||
|
|
||||||
sls_detector_header header = rheader->detHeader;
|
sls_detector_header header = rheader.detHeader;
|
||||||
hsize_t count[1] = {1};
|
hsize_t count[PARA_RANK] = {1};
|
||||||
hsize_t start[1] = {fnum};
|
hsize_t start[PARA_RANK] = {fnum};
|
||||||
int i = 0;
|
int i = 0;
|
||||||
try {
|
try {
|
||||||
H5::Exception::dontPrint(); // to handle errors
|
H5::Exception::dontPrint(); // to handle errors
|
||||||
dataSpacePara_->selectHyperslab(H5S_SELECT_SET, count, start);
|
dataSpacePara->selectHyperslab(H5S_SELECT_SET, count, start);
|
||||||
H5::DataSpace memspace(H5S_SCALAR);
|
H5::DataSpace memspace(H5S_SCALAR);
|
||||||
dataSetPara_[0]->write(&header.frameNumber, parameterDataTypes_[0],
|
dataSetPara[0]->write(&header.frameNumber, parameterDataTypes[0],
|
||||||
memspace, *dataSpacePara_);
|
memspace, *dataSpacePara);
|
||||||
i = 1;
|
i = 1;
|
||||||
dataSetPara_[1]->write(&header.expLength, parameterDataTypes_[1],
|
dataSetPara[1]->write(&header.expLength, parameterDataTypes[1],
|
||||||
memspace, *dataSpacePara_);
|
memspace, *dataSpacePara);
|
||||||
i = 2;
|
i = 2;
|
||||||
dataSetPara_[2]->write(&header.packetNumber, parameterDataTypes_[2],
|
dataSetPara[2]->write(&header.packetNumber, parameterDataTypes[2],
|
||||||
memspace, *dataSpacePara_);
|
memspace, *dataSpacePara);
|
||||||
i = 3;
|
i = 3;
|
||||||
dataSetPara_[3]->write(&header.bunchId, parameterDataTypes_[3],
|
dataSetPara[3]->write(&header.bunchId, parameterDataTypes[3], memspace,
|
||||||
memspace, *dataSpacePara_);
|
*dataSpacePara);
|
||||||
i = 4;
|
i = 4;
|
||||||
dataSetPara_[4]->write(&header.timestamp, parameterDataTypes_[4],
|
dataSetPara[4]->write(&header.timestamp, parameterDataTypes[4],
|
||||||
memspace, *dataSpacePara_);
|
memspace, *dataSpacePara);
|
||||||
i = 5;
|
i = 5;
|
||||||
dataSetPara_[5]->write(&header.modId, parameterDataTypes_[5], memspace,
|
dataSetPara[5]->write(&header.modId, parameterDataTypes[5], memspace,
|
||||||
*dataSpacePara_);
|
*dataSpacePara);
|
||||||
i = 6;
|
i = 6;
|
||||||
dataSetPara_[6]->write(&header.row, parameterDataTypes_[6], memspace,
|
dataSetPara[6]->write(&header.row, parameterDataTypes[6], memspace,
|
||||||
*dataSpacePara_);
|
*dataSpacePara);
|
||||||
i = 7;
|
i = 7;
|
||||||
dataSetPara_[7]->write(&header.column, parameterDataTypes_[7], memspace,
|
dataSetPara[7]->write(&header.column, parameterDataTypes[7], memspace,
|
||||||
*dataSpacePara_);
|
*dataSpacePara);
|
||||||
i = 8;
|
i = 8;
|
||||||
dataSetPara_[8]->write(&header.reserved, parameterDataTypes_[8],
|
dataSetPara[8]->write(&header.reserved, parameterDataTypes[8], memspace,
|
||||||
memspace, *dataSpacePara_);
|
*dataSpacePara);
|
||||||
i = 9;
|
i = 9;
|
||||||
dataSetPara_[9]->write(&header.debug, parameterDataTypes_[9], memspace,
|
dataSetPara[9]->write(&header.debug, parameterDataTypes[9], memspace,
|
||||||
*dataSpacePara_);
|
*dataSpacePara);
|
||||||
i = 10;
|
i = 10;
|
||||||
dataSetPara_[10]->write(&header.roundRNumber, parameterDataTypes_[10],
|
dataSetPara[10]->write(&header.roundRNumber, parameterDataTypes[10],
|
||||||
memspace, *dataSpacePara_);
|
memspace, *dataSpacePara);
|
||||||
i = 11;
|
i = 11;
|
||||||
dataSetPara_[11]->write(&header.detType, parameterDataTypes_[11],
|
dataSetPara[11]->write(&header.detType, parameterDataTypes[11],
|
||||||
memspace, *dataSpacePara_);
|
memspace, *dataSpacePara);
|
||||||
i = 12;
|
i = 12;
|
||||||
dataSetPara_[12]->write(&header.version, parameterDataTypes_[12],
|
dataSetPara[12]->write(&header.version, parameterDataTypes[12],
|
||||||
memspace, *dataSpacePara_);
|
memspace, *dataSpacePara);
|
||||||
i = 13;
|
i = 13;
|
||||||
|
|
||||||
// contiguous bitset
|
// contiguous bitset
|
||||||
if (sizeof(sls_bitset) == sizeof(bitset_storage)) {
|
if (sizeof(sls_bitset) == sizeof(bitset_storage)) {
|
||||||
dataSetPara_[13]->write((char *)&(rheader->packetsMask),
|
dataSetPara[13]->write((char *)&(rheader.packetsMask),
|
||||||
parameterDataTypes_[13], memspace,
|
parameterDataTypes[13], memspace,
|
||||||
*dataSpacePara_);
|
*dataSpacePara);
|
||||||
}
|
}
|
||||||
|
|
||||||
// not contiguous bitset
|
// not contiguous bitset
|
||||||
@ -368,54 +360,53 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
|
|||||||
// get contiguous representation of bit mask
|
// get contiguous representation of bit mask
|
||||||
bitset_storage storage;
|
bitset_storage storage;
|
||||||
memset(storage, 0, sizeof(bitset_storage));
|
memset(storage, 0, sizeof(bitset_storage));
|
||||||
sls_bitset bits = rheader->packetsMask;
|
sls_bitset bits = rheader.packetsMask;
|
||||||
for (int i = 0; i < MAX_NUM_PACKETS; ++i)
|
for (int i = 0; i < MAX_NUM_PACKETS; ++i)
|
||||||
storage[i >> 3] |= (bits[i] << (i & 7));
|
storage[i >> 3] |= (bits[i] << (i & 7));
|
||||||
// write bitmask
|
// write bitmask
|
||||||
dataSetPara_[13]->write((char *)storage, parameterDataTypes_[13],
|
dataSetPara[13]->write((char *)storage, parameterDataTypes[13],
|
||||||
memspace, *dataSpacePara_);
|
memspace, *dataSpacePara);
|
||||||
}
|
}
|
||||||
i = 14;
|
i = 14;
|
||||||
} catch (const H5::Exception &error) {
|
} catch (const H5::Exception &error) {
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
throw 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5DataFile::ExtendDataset() {
|
void HDF5DataFile::ExtendDataset() {
|
||||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
std::lock_guard<std::mutex> lock(*hdf5Lib);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
H5::Exception::dontPrint(); // to handle errors
|
H5::Exception::dontPrint(); // to handle errors
|
||||||
|
|
||||||
hsize_t dims[3];
|
hsize_t dims[DATA_RANK];
|
||||||
dataSpace_->getSimpleExtentDims(dims);
|
dataSpace->getSimpleExtentDims(dims);
|
||||||
dims[0] += numImages_;
|
dims[0] += numImages;
|
||||||
|
dataSet->extend(dims);
|
||||||
|
delete dataSpace;
|
||||||
|
dataSpace = nullptr;
|
||||||
|
dataSpace = new H5::DataSpace(dataSet->getSpace());
|
||||||
|
|
||||||
dataSet_->extend(dims);
|
hsize_t dimsPara[PARA_RANK] = {dims[0]};
|
||||||
delete dataSpace_;
|
for (unsigned int i = 0; i < dataSetPara.size(); ++i)
|
||||||
dataSpace_ = nullptr;
|
dataSetPara[i]->extend(dimsPara);
|
||||||
dataSpace_ = new H5::DataSpace(dataSet_->getSpace());
|
delete dataSpacePara;
|
||||||
|
dataSpacePara = nullptr;
|
||||||
hsize_t dims_para[1] = {dims[0]};
|
dataSpacePara = new H5::DataSpace(dataSetPara[0]->getSpace());
|
||||||
for (unsigned int i = 0; i < dataSetPara_.size(); ++i)
|
|
||||||
dataSetPara_[i]->extend(dims_para);
|
|
||||||
delete dataSpacePara_;
|
|
||||||
dataSpacePara_ = nullptr;
|
|
||||||
dataSpacePara_ = new H5::DataSpace(dataSetPara_[0]->getSpace());
|
|
||||||
|
|
||||||
} catch (const H5::Exception &error) {
|
} catch (const H5::Exception &error) {
|
||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
throw 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) {
|
||||||
LOG(logINFO) << index_ << " Extending HDF5 dataset by " << extNumImages_
|
LOG(logINFO) << index << " Extending HDF5 dataset by " << extNumImages
|
||||||
<< ", Total x Dimension: " << (extNumImages_ + numImages_);
|
<< ", Total x Dimension: " << (extNumImages + numImages);
|
||||||
}
|
}
|
||||||
extNumImages_ += numImages_;
|
extNumImages += numImages;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -14,6 +14,7 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
|||||||
HDF5DataFile(const int index, std::mutex *hdf5Lib);
|
HDF5DataFile(const int index, std::mutex *hdf5Lib);
|
||||||
~HDF5DataFile();
|
~HDF5DataFile();
|
||||||
|
|
||||||
|
fileFormat GetFileFormat() const override;
|
||||||
std::string GetFileName() const override;
|
std::string GetFileName() const override;
|
||||||
uint32_t GetFilesInAcquisition() const override;
|
uint32_t GetFilesInAcquisition() const override;
|
||||||
H5::DataType GetPDataType() const override;
|
H5::DataType GetPDataType() const override;
|
||||||
@ -22,59 +23,53 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
|||||||
|
|
||||||
void CloseFile() override;
|
void CloseFile() override;
|
||||||
|
|
||||||
void CreateFirstHDF5DataFile(
|
void CreateFirstHDF5DataFile(const std::string &fNamePrefix,
|
||||||
const std::string filePath, const std::string fileNamePrefix,
|
const uint64_t fIndex, const bool owEnable,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable,
|
const bool sMode, const uint32_t uPortNumber,
|
||||||
const bool silentMode, const int modulePos,
|
const uint32_t mFramesPerFile,
|
||||||
const int numUnitsPerReadout, const uint32_t udpPortNumber,
|
const uint64_t nImages, const uint32_t nX,
|
||||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
const uint32_t nY, const uint32_t dr) override;
|
||||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
|
||||||
const uint32_t dynamicRange) override;
|
|
||||||
|
|
||||||
void WriteToFile(char *buffer, const int buffersize,
|
void WriteToFile(char *imageData, sls_receiver_header &header,
|
||||||
const uint64_t currentFrameNumber,
|
const int imageSize, const uint64_t currentFrameNumber,
|
||||||
const uint32_t numPacketsCaught) override;
|
const uint32_t numPacketsCaught) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateFile();
|
void CreateFile();
|
||||||
void Convert12to16Bit(uint16_t *dst, uint8_t *src);
|
void Convert12to16Bit(uint16_t *dst, uint8_t *src);
|
||||||
void WriteDataFile(const uint64_t currentFrameNumber, char *buffer);
|
void WriteImageDatasets(const uint64_t currentFrameNumber, char *buffer);
|
||||||
void WriteParameterDatasets(const uint64_t currentFrameNumber,
|
void WriteParameterDatasets(const uint64_t currentFrameNumber,
|
||||||
sls_receiver_header *rheader);
|
sls_receiver_header rheader);
|
||||||
void ExtendDataset();
|
void ExtendDataset();
|
||||||
|
|
||||||
int index_;
|
int index;
|
||||||
std::mutex *hdf5Lib_;
|
std::mutex *hdf5Lib;
|
||||||
H5::H5File *fd_{nullptr};
|
H5::H5File *fd{nullptr};
|
||||||
std::string fileName_;
|
std::string fileName;
|
||||||
std::string dataSetName_;
|
H5::DataSpace *dataSpace{nullptr};
|
||||||
H5::DataSpace *dataSpace_{nullptr};
|
H5::DataSet *dataSet{nullptr};
|
||||||
H5::DataSet *dataSet_{nullptr};
|
H5::DataType dataType{H5::PredType::STD_U16LE};
|
||||||
H5::DataType dataType_{H5::PredType::STD_U16LE};
|
|
||||||
|
|
||||||
H5::DataSpace *dataSpacePara_{nullptr};
|
H5::DataSpace *dataSpacePara{nullptr};
|
||||||
std::vector<H5::DataSet *> dataSetPara_{nullptr};
|
std::vector<H5::DataSet *> dataSetPara{nullptr};
|
||||||
std::vector<std::string> parameterNames_;
|
std::vector<std::string> parameterNames;
|
||||||
std::vector<H5::DataType> parameterDataTypes_;
|
std::vector<H5::DataType> parameterDataTypes;
|
||||||
|
|
||||||
uint32_t subFileIndex_{0};
|
uint32_t subFileIndex{0};
|
||||||
uint32_t numFramesInFile_{0};
|
uint32_t numFramesInFile{0};
|
||||||
uint32_t numFilesInAcquisition_{0};
|
uint32_t numFilesInAcquisition{0};
|
||||||
uint32_t maxFramesPerFile_{0};
|
uint32_t maxFramesPerFile{0};
|
||||||
uint64_t numImages_{0};
|
uint64_t numImages{0};
|
||||||
uint64_t extNumImages_{0};
|
uint64_t extNumImages{0};
|
||||||
uint32_t nPixelsX_{0};
|
uint32_t nPixelsX{0};
|
||||||
uint32_t nPixelsY_{0};
|
uint32_t nPixelsY{0};
|
||||||
uint32_t dynamicRange_{0};
|
uint32_t dynamicRange{0};
|
||||||
|
|
||||||
std::string filePath_;
|
std::string fileNamePrefix;
|
||||||
std::string fileNamePrefix_;
|
uint64_t fileIndex{0};
|
||||||
uint64_t fileIndex_{0};
|
bool overWriteEnable{false};
|
||||||
bool overWriteEnable_{false};
|
bool silentMode{false};
|
||||||
bool silentMode_{false};
|
uint32_t udpPortNumber{0};
|
||||||
int detIndex_{0};
|
|
||||||
int numUnitsPerReadout_{0};
|
|
||||||
uint32_t udpPortNumber_{0};
|
|
||||||
|
|
||||||
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};
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -266,13 +266,12 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
/** params: total frames caught */
|
/** params: total frames caught */
|
||||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
/** params: sls_receiver_header pointer, pointer to data, image size */
|
/** params: sls_receiver_header, pointer to data, image size */
|
||||||
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
|
void registerCallBackRawDataReady(void (*func)(sls_receiver_header &,
|
||||||
char *, size_t, void *),
|
char *, size_t, void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
/** params: sls_receiver_header pointer, pointer to data, reference to image
|
/** params: sls_receiver_header, pointer to data, reference to image size */
|
||||||
* size */
|
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header &,
|
||||||
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
|
|
||||||
char *, size_t &,
|
char *, size_t &,
|
||||||
void *),
|
void *),
|
||||||
void *arg);
|
void *arg);
|
||||||
@ -288,6 +287,9 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
void SetupWriter();
|
void SetupWriter();
|
||||||
void StartMasterWriter();
|
void StartMasterWriter();
|
||||||
void StartRunning();
|
void StartRunning();
|
||||||
|
void SetupListener(int i);
|
||||||
|
void SetupDataProcessor(int i);
|
||||||
|
void SetupDataStreamer(int i);
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
@ -296,13 +298,11 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
* ************************************************/
|
* ************************************************/
|
||||||
|
|
||||||
// config parameters
|
// config parameters
|
||||||
detectorType detType{GENERIC};
|
|
||||||
xy numModules{1, 1};
|
xy numModules{1, 1};
|
||||||
xy numPorts{1, 1};
|
xy numPorts{1, 1};
|
||||||
int modulePos{0};
|
int modulePos{0};
|
||||||
std::string detHostname;
|
std::string detHostname;
|
||||||
bool silentMode{false};
|
bool silentMode{false};
|
||||||
uint32_t fifoDepth{0};
|
|
||||||
frameDiscardPolicy frameDiscardMode{NO_DISCARD};
|
frameDiscardPolicy frameDiscardMode{NO_DISCARD};
|
||||||
bool framePadding{true};
|
bool framePadding{true};
|
||||||
pid_t parentThreadId;
|
pid_t parentThreadId;
|
||||||
@ -320,7 +320,6 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
bool fileWriteEnable{false};
|
bool fileWriteEnable{false};
|
||||||
bool masterFileWriteEnable{true};
|
bool masterFileWriteEnable{true};
|
||||||
bool overwriteEnable{true};
|
bool overwriteEnable{true};
|
||||||
uint32_t framesPerFile{0};
|
|
||||||
|
|
||||||
// acquisition
|
// acquisition
|
||||||
std::atomic<runStatus> status{IDLE};
|
std::atomic<runStatus> status{IDLE};
|
||||||
@ -328,11 +327,9 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
scanParameters scanParams{};
|
scanParameters scanParams{};
|
||||||
|
|
||||||
// network configuration (UDP)
|
// network configuration (UDP)
|
||||||
int numUDPInterfaces{1};
|
|
||||||
std::array<std::string, MAX_NUMBER_OF_LISTENING_THREADS> eth;
|
std::array<std::string, MAX_NUMBER_OF_LISTENING_THREADS> eth;
|
||||||
std::array<uint32_t, MAX_NUMBER_OF_LISTENING_THREADS> udpPortNum{
|
std::array<uint32_t, MAX_NUMBER_OF_LISTENING_THREADS> udpPortNum{
|
||||||
{DEFAULT_UDP_PORTNO, DEFAULT_UDP_PORTNO + 1}};
|
{DEFAULT_UDP_PORTNO, DEFAULT_UDP_PORTNO + 1}};
|
||||||
int udpSocketBufferSize{0};
|
|
||||||
int actualUDPSocketBufferSize{0};
|
int actualUDPSocketBufferSize{0};
|
||||||
|
|
||||||
// zmq parameters
|
// zmq parameters
|
||||||
@ -364,12 +361,6 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
ns gateDelay3 = std::chrono::nanoseconds(0);
|
ns gateDelay3 = std::chrono::nanoseconds(0);
|
||||||
ns subExpTime = std::chrono::nanoseconds(0);
|
ns subExpTime = std::chrono::nanoseconds(0);
|
||||||
ns subPeriod = std::chrono::nanoseconds(0);
|
ns subPeriod = std::chrono::nanoseconds(0);
|
||||||
uint32_t numberOfAnalogSamples{0};
|
|
||||||
uint32_t numberOfDigitalSamples{0};
|
|
||||||
uint32_t counterMask{0};
|
|
||||||
uint32_t dynamicRange{16};
|
|
||||||
ROI detectorRoi{};
|
|
||||||
bool tengigaEnable{false};
|
|
||||||
bool flipRows{false};
|
bool flipRows{false};
|
||||||
bool quadEnable{false};
|
bool quadEnable{false};
|
||||||
bool activated{true};
|
bool activated{true};
|
||||||
@ -380,9 +371,6 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
int thresholdEnergyeV{-1};
|
int thresholdEnergyeV{-1};
|
||||||
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
|
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
|
||||||
std::vector<int64_t> rateCorrections;
|
std::vector<int64_t> rateCorrections;
|
||||||
readoutMode readoutType{ANALOG_ONLY};
|
|
||||||
uint32_t adcEnableMaskOneGiga{BIT32_MASK};
|
|
||||||
uint32_t adcEnableMaskTenGiga{BIT32_MASK};
|
|
||||||
std::vector<int> ctbDbitList;
|
std::vector<int> ctbDbitList;
|
||||||
int ctbDbitOffset{0};
|
int ctbDbitOffset{0};
|
||||||
|
|
||||||
@ -392,9 +380,9 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
void *pStartAcquisition{nullptr};
|
void *pStartAcquisition{nullptr};
|
||||||
void (*acquisitionFinishedCallBack)(uint64_t, void *){nullptr};
|
void (*acquisitionFinishedCallBack)(uint64_t, void *){nullptr};
|
||||||
void *pAcquisitionFinished{nullptr};
|
void *pAcquisitionFinished{nullptr};
|
||||||
void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
|
void (*rawDataReadyCallBack)(sls_receiver_header &, char *, size_t,
|
||||||
void *){nullptr};
|
void *){nullptr};
|
||||||
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
|
void (*rawDataModifyReadyCallBack)(sls_receiver_header &, char *, size_t &,
|
||||||
void *){nullptr};
|
void *){nullptr};
|
||||||
void *pRawDataReady{nullptr};
|
void *pRawDataReady{nullptr};
|
||||||
|
|
||||||
|
@ -18,24 +18,21 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace sls {
|
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 index, std::atomic<runStatus> *status)
|
||||||
std::atomic<runStatus> *s, uint32_t *portno, std::string *e,
|
: ThreadObject(index, TypeName), status(status) {
|
||||||
int *us, int *as, uint32_t *fpf, frameDiscardPolicy *fdp,
|
LOG(logDEBUG) << "Listener " << index << " created";
|
||||||
bool *detds, bool *sm)
|
|
||||||
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), status(s),
|
|
||||||
udpPortNumber(portno), eth(e), udpSocketBufferSize(us),
|
|
||||||
actualUDPSocketBufferSize(as), framesPerFile(fpf), frameDiscardMode(fdp),
|
|
||||||
detectorDataStream(detds), silentMode(sm) {
|
|
||||||
LOG(logDEBUG) << "Listener " << ind << " created";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Listener::~Listener() = default;
|
Listener::~Listener() = default;
|
||||||
|
|
||||||
|
bool Listener::isPortDisabled() const { return disabledPort; }
|
||||||
|
|
||||||
uint64_t Listener::GetPacketsCaught() const { return numPacketsCaught; }
|
uint64_t Listener::GetPacketsCaught() const { return numPacketsCaught; }
|
||||||
|
|
||||||
uint64_t Listener::GetNumCompleteFramesCaught() const {
|
uint64_t Listener::GetNumCompleteFramesCaught() const {
|
||||||
@ -48,7 +45,7 @@ uint64_t Listener::GetLastFrameIndexCaught() const {
|
|||||||
|
|
||||||
int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
||||||
uint64_t numPackets) const {
|
uint64_t numPackets) const {
|
||||||
if (!activated || !(*detectorDataStream) || noRoi) {
|
if (disabledPort) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!stoppedFlag) {
|
if (!stoppedFlag) {
|
||||||
@ -72,6 +69,45 @@ uint64_t Listener::GetListenedIndex() const {
|
|||||||
|
|
||||||
void Listener::SetFifo(Fifo *f) { fifo = f; }
|
void Listener::SetFifo(Fifo *f) { fifo = f; }
|
||||||
|
|
||||||
|
void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||||
|
|
||||||
|
void Listener::SetUdpPortNumber(const uint32_t portNumber) {
|
||||||
|
udpPortNumber = portNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetEthernetInterface(const std::string e) {
|
||||||
|
eth = e;
|
||||||
|
// if eth is mistaken with ip address
|
||||||
|
if (eth.find('.') != std::string::npos) {
|
||||||
|
eth = "";
|
||||||
|
}
|
||||||
|
if (!eth.length()) {
|
||||||
|
LOG(logWARNING) << "ethernet interface for udp port " << udpPortNumber
|
||||||
|
<< " is empty. Listening to all";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetActivate(bool enable) {
|
||||||
|
activated = enable;
|
||||||
|
disabledPort = (!activated || !detectorDataStream || noRoi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetDetectorDatastream(bool enable) {
|
||||||
|
detectorDataStream = enable;
|
||||||
|
disabledPort = (!activated || !detectorDataStream || noRoi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetNoRoi(bool enable) {
|
||||||
|
noRoi = enable;
|
||||||
|
disabledPort = (!activated || !detectorDataStream || noRoi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetFrameDiscardPolicy(frameDiscardPolicy value) {
|
||||||
|
frameDiscardMode = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::SetSilentMode(bool enable) { silentMode = enable; }
|
||||||
|
|
||||||
void Listener::ResetParametersforNewAcquisition() {
|
void Listener::ResetParametersforNewAcquisition() {
|
||||||
StopRunning();
|
StopRunning();
|
||||||
startedFlag = false;
|
startedFlag = false;
|
||||||
@ -82,7 +118,7 @@ void Listener::ResetParametersforNewAcquisition() {
|
|||||||
lastCaughtFrameIndex = 0;
|
lastCaughtFrameIndex = 0;
|
||||||
carryOverFlag = false;
|
carryOverFlag = false;
|
||||||
uint32_t packetSize = generalData->packetSize;
|
uint32_t packetSize = generalData->packetSize;
|
||||||
if (myDetectorType == GOTTHARD2 && index != 0) {
|
if (generalData->detType == GOTTHARD2 && index != 0) {
|
||||||
packetSize = generalData->vetoPacketSize;
|
packetSize = generalData->vetoPacketSize;
|
||||||
}
|
}
|
||||||
carryOverPacket = make_unique<char[]>(packetSize);
|
carryOverPacket = make_unique<char[]>(packetSize);
|
||||||
@ -101,112 +137,97 @@ void Listener::RecordFirstIndex(uint64_t fnum) {
|
|||||||
// listen to this fnum, later +1
|
// listen to this fnum, later +1
|
||||||
currentFrameIndex = fnum;
|
currentFrameIndex = fnum;
|
||||||
lastCaughtFrameIndex = fnum;
|
lastCaughtFrameIndex = fnum;
|
||||||
|
|
||||||
startedFlag = true;
|
startedFlag = true;
|
||||||
firstIndex = fnum;
|
firstIndex = fnum;
|
||||||
|
|
||||||
if (!(*silentMode)) {
|
if (!silentMode) {
|
||||||
if (!index) {
|
if (!index) {
|
||||||
LOG(logINFOBLUE) << index << " First Index: " << firstIndex;
|
LOG(logINFOBLUE) << index << " First Index: " << firstIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
|
void Listener::CreateUDPSocket(int &actualSize) {
|
||||||
|
if (disabledPort) {
|
||||||
void Listener::SetActivate(bool enable) { activated = enable; }
|
|
||||||
|
|
||||||
void Listener::SetNoRoi(bool enable) {noRoi = enable; }
|
|
||||||
|
|
||||||
void Listener::CreateUDPSockets() {
|
|
||||||
if (!activated || !(*detectorDataStream) || noRoi) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if eth is mistaken with ip address
|
|
||||||
if ((*eth).find('.') != std::string::npos) {
|
|
||||||
(*eth) = "";
|
|
||||||
}
|
|
||||||
if (!(*eth).length()) {
|
|
||||||
LOG(logWARNING) << "eth is empty. Listening to all";
|
|
||||||
}
|
|
||||||
|
|
||||||
ShutDownUDPSocket();
|
|
||||||
|
|
||||||
uint32_t packetSize = generalData->packetSize;
|
uint32_t packetSize = generalData->packetSize;
|
||||||
if (myDetectorType == GOTTHARD2 && index != 0) {
|
if (generalData->detType == GOTTHARD2 && index != 0) {
|
||||||
packetSize = generalData->vetoPacketSize;
|
packetSize = generalData->vetoPacketSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// InterfaceNameToIp(eth).str().c_str()
|
|
||||||
try {
|
try {
|
||||||
|
udpSocket = nullptr;
|
||||||
udpSocket = make_unique<UdpRxSocket>(
|
udpSocket = make_unique<UdpRxSocket>(
|
||||||
*udpPortNumber, packetSize,
|
udpPortNumber, packetSize,
|
||||||
((*eth).length() ? InterfaceNameToIp(*eth).str().c_str()
|
(eth.length() ? InterfaceNameToIp(eth).str().c_str() : nullptr),
|
||||||
: nullptr),
|
generalData->udpSocketBufferSize);
|
||||||
*udpSocketBufferSize);
|
LOG(logINFO) << index << ": UDP port opened at port " << udpPortNumber;
|
||||||
LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
udpSocketAlive = true;
|
udpSocketAlive = true;
|
||||||
|
|
||||||
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
||||||
*actualUDPSocketBufferSize = udpSocket->getBufferSize();
|
actualSize = udpSocket->getBufferSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::ShutDownUDPSocket() {
|
void Listener::ShutDownUDPSocket() {
|
||||||
if (udpSocket) {
|
if (udpSocket) {
|
||||||
udpSocketAlive = false;
|
udpSocketAlive = false;
|
||||||
|
// give other thread time after udpSocketAlive is changed
|
||||||
|
usleep(0);
|
||||||
udpSocket->Shutdown();
|
udpSocket->Shutdown();
|
||||||
LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber;
|
LOG(logINFO) << "Shut down of UDP port " << udpPortNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
|
void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize) {
|
||||||
LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port "
|
// custom setup (s != 0)
|
||||||
<< *udpPortNumber;
|
// default setup at startup (s = 0)
|
||||||
|
int size = (s == 0 ? generalData->udpSocketBufferSize : s);
|
||||||
|
LOG(logINFO) << "Testing UDP Socket Buffer size " << size
|
||||||
|
<< " with test port " << udpPortNumber;
|
||||||
|
int previousSize = generalData->udpSocketBufferSize;
|
||||||
|
generalData->udpSocketBufferSize = size;
|
||||||
|
|
||||||
if (!activated || !(*detectorDataStream) || noRoi) {
|
if (disabledPort) {
|
||||||
*actualUDPSocketBufferSize = (s * 2);
|
actualSize = (generalData->udpSocketBufferSize * 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int temp = *udpSocketBufferSize;
|
|
||||||
*udpSocketBufferSize = s;
|
|
||||||
|
|
||||||
// if eth is mistaken with ip address
|
|
||||||
if ((*eth).find('.') != std::string::npos) {
|
|
||||||
(*eth) = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t packetSize = generalData->packetSize;
|
uint32_t packetSize = generalData->packetSize;
|
||||||
if (myDetectorType == GOTTHARD2 && index != 0) {
|
if (generalData->detType == GOTTHARD2 && index != 0) {
|
||||||
packetSize = generalData->vetoPacketSize;
|
packetSize = generalData->vetoPacketSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create dummy socket
|
// create dummy socket
|
||||||
try {
|
try {
|
||||||
UdpRxSocket g(*udpPortNumber, packetSize,
|
UdpRxSocket g(
|
||||||
((*eth).length()
|
udpPortNumber, packetSize,
|
||||||
? InterfaceNameToIp(*eth).str().c_str()
|
(eth.length() ? InterfaceNameToIp(eth).str().c_str() : nullptr),
|
||||||
: nullptr),
|
generalData->udpSocketBufferSize);
|
||||||
*udpSocketBufferSize);
|
|
||||||
|
|
||||||
// doubled due to kernel bookkeeping (could also be less due to
|
// doubled due to kernel bookkeeping (could also be less due to
|
||||||
// permissions)
|
// permissions)
|
||||||
*actualUDPSocketBufferSize = g.getBufferSize();
|
actualSize = g.getBufferSize();
|
||||||
if (*actualUDPSocketBufferSize == -1) {
|
if (actualSize == -1) {
|
||||||
*udpSocketBufferSize = temp;
|
generalData->udpSocketBufferSize = previousSize;
|
||||||
} else {
|
} else {
|
||||||
*udpSocketBufferSize = (*actualUDPSocketBufferSize) / 2;
|
generalData->udpSocketBufferSize = actualSize / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
// custom and didnt set, throw error
|
||||||
|
if (s != 0 && static_cast<int>(generalData->udpSocketBufferSize) != s) {
|
||||||
|
throw RuntimeError("Could not set udp socket buffer size. (No "
|
||||||
|
"CAP_NET_ADMIN privileges?)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,126 +240,83 @@ void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
|
|||||||
|
|
||||||
void Listener::ThreadExecution() {
|
void Listener::ThreadExecution() {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
fifo->GetNewAddress(buffer);
|
fifo->GetNewAddress(buffer);
|
||||||
LOG(logDEBUG5) << "Listener " << index
|
LOG(logDEBUG5) << "Listener " << index << ", pop 0x" << std::hex
|
||||||
<< ", "
|
<< (void *)(buffer) << std::dec << ":" << buffer;
|
||||||
"pop 0x"
|
auto *memImage = reinterpret_cast<image_structure *>(buffer);
|
||||||
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
|
|
||||||
|
|
||||||
// udpsocket doesnt exist
|
// udpsocket doesnt exist
|
||||||
if (activated && *detectorDataStream && !noRoi &&!udpSocketAlive && !carryOverFlag) {
|
if ((*status == TRANSMITTING || !udpSocketAlive) && !carryOverFlag) {
|
||||||
// LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not
|
StopListening(buffer, memImage->size);
|
||||||
// created or shut down earlier";
|
|
||||||
(*((uint32_t *)buffer)) = 0;
|
|
||||||
StopListening(buffer);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get data
|
// reset header and size and get data
|
||||||
if ((*status != TRANSMITTING &&
|
memset(memImage, 0, IMAGE_STRUCTURE_HEADER_SIZE);
|
||||||
(!activated || !(*detectorDataStream) || noRoi || udpSocketAlive)) ||
|
int rc = ListenToAnImage(memImage->header, memImage->data);
|
||||||
carryOverFlag) {
|
|
||||||
rc = ListenToAnImage(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// error check, (should not be here) if not transmitting yet (previous if)
|
// end of acquisition or discarding image
|
||||||
// rc should be > 0
|
if (rc <= 0) {
|
||||||
if (rc == 0) {
|
|
||||||
if (!udpSocketAlive) {
|
|
||||||
(*((uint32_t *)buffer)) = 0;
|
|
||||||
StopListening(buffer);
|
|
||||||
} else
|
|
||||||
fifo->FreeAddress(buffer);
|
fifo->FreeAddress(buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// discarding image
|
// valid image, set size and push into fifo
|
||||||
else if (rc < 0) {
|
memImage->size = rc;
|
||||||
fifo->FreeAddress(buffer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*((uint32_t *)buffer)) = rc;
|
|
||||||
|
|
||||||
// push into fifo
|
|
||||||
fifo->PushAddress(buffer);
|
fifo->PushAddress(buffer);
|
||||||
|
|
||||||
// Statistics
|
// Statistics
|
||||||
if (!(*silentMode)) {
|
if (!silentMode) {
|
||||||
numFramesStatistic++;
|
numFramesStatistic++;
|
||||||
if (numFramesStatistic >=
|
if (numFramesStatistic >=
|
||||||
// second condition also for infinite #number of frames
|
// second condition also for infinite #number of frames
|
||||||
(((*framesPerFile) == 0) ? STATISTIC_FRAMENUMBER_INFINITE
|
(generalData->framesPerFile == 0 ? STATISTIC_FRAMENUMBER_INFINITE
|
||||||
: (*framesPerFile)))
|
: generalData->framesPerFile))
|
||||||
PrintFifoStatistics();
|
PrintFifoStatistics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::StopListening(char *buf) {
|
void Listener::StopListening(char *buf, size_t &size) {
|
||||||
(*((uint32_t *)buf)) = DUMMY_PACKET_VALUE;
|
size = DUMMY_PACKET_VALUE;
|
||||||
fifo->PushAddress(buf);
|
fifo->PushAddress(buf);
|
||||||
StopRunning();
|
StopRunning();
|
||||||
LOG(logDEBUG1) << index << ": Listening Packets (" << *udpPortNumber
|
LOG(logDEBUG1) << index << ": Listening Completed. Packets ("
|
||||||
<< ") : " << numPacketsCaught;
|
<< udpPortNumber << ") : " << numPacketsCaught;
|
||||||
LOG(logDEBUG1) << index << ": Listening Completed";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* buf includes the fifo header and packet header */
|
/* buf includes the fifo header and packet header */
|
||||||
uint32_t Listener::ListenToAnImage(char *buf) {
|
uint32_t Listener::ListenToAnImage(sls_receiver_header &dstHeader,
|
||||||
|
char *dstData) {
|
||||||
|
|
||||||
int rc = 0;
|
|
||||||
uint64_t fnum = 0;
|
uint64_t fnum = 0;
|
||||||
uint32_t pnum = 0;
|
uint32_t pnum = 0;
|
||||||
uint64_t bnum = 0;
|
uint64_t bnum = 0;
|
||||||
uint32_t numpackets = 0;
|
uint32_t numpackets = 0;
|
||||||
|
|
||||||
uint32_t dsize = generalData->dataSize;
|
uint32_t dsize = generalData->dataSize;
|
||||||
uint32_t imageSize = generalData->imageSize;
|
uint32_t imageSize = generalData->imageSize;
|
||||||
uint32_t packetSize = generalData->packetSize;
|
uint32_t packetSize = generalData->packetSize;
|
||||||
uint32_t hsize = generalData->headerSizeinPacket;
|
uint32_t hsize = generalData->headerSizeinPacket;
|
||||||
uint32_t fifohsize = generalData->fifoBufferHeaderSize;
|
bool standardHeader = generalData->standardheader;
|
||||||
bool standardheader = generalData->standardheader;
|
if (generalData->detType == GOTTHARD2 && index != 0) {
|
||||||
if (myDetectorType == GOTTHARD2 && index != 0) {
|
|
||||||
dsize = generalData->vetoDataSize;
|
dsize = generalData->vetoDataSize;
|
||||||
imageSize = generalData->vetoImageSize;
|
imageSize = generalData->vetoImageSize;
|
||||||
packetSize = generalData->vetoPacketSize;
|
packetSize = generalData->vetoPacketSize;
|
||||||
hsize = generalData->vetoHsize;
|
hsize = generalData->vetoHsize;
|
||||||
standardheader = false;
|
standardHeader = false;
|
||||||
}
|
}
|
||||||
uint32_t pperFrame = generalData->packetsPerFrame;
|
uint32_t pperFrame = generalData->packetsPerFrame;
|
||||||
bool isHeaderEmpty = true;
|
bool isHeaderEmpty = true;
|
||||||
sls_detector_header *old_header = nullptr;
|
|
||||||
sls_receiver_header *new_header = nullptr;
|
|
||||||
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - imageSize);
|
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - imageSize);
|
||||||
|
sls_detector_header *srcDetHeader = nullptr;
|
||||||
|
|
||||||
// reset to -1
|
// carry over packet
|
||||||
memset(buf, 0, fifohsize);
|
|
||||||
new_header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
|
|
||||||
|
|
||||||
// deactivated port (eiger) or deactivated (eiger)
|
|
||||||
if (!(*detectorDataStream) || !activated || noRoi) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// look for carry over
|
|
||||||
if (carryOverFlag) {
|
if (carryOverFlag) {
|
||||||
LOG(logDEBUG3) << index << "carry flag";
|
LOG(logDEBUG3) << index << "carry flag";
|
||||||
// check if its the current image packet
|
GetPacketIndices(fnum, pnum, bnum, standardHeader,
|
||||||
// -------------------------- new header
|
carryOverPacket.get(), srcDetHeader);
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
if (standardheader) {
|
// future packet
|
||||||
old_header = (sls_detector_header *)(&carryOverPacket[0]);
|
|
||||||
fnum = old_header->frameNumber;
|
|
||||||
pnum = old_header->packetNumber;
|
|
||||||
}
|
|
||||||
// -------------------old header
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
else {
|
|
||||||
generalData->GetHeaderInfo(index, &carryOverPacket[0],
|
|
||||||
oddStartingPacket, fnum, pnum, bnum);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------------------------
|
|
||||||
if (fnum != currentFrameIndex) {
|
if (fnum != currentFrameIndex) {
|
||||||
if (fnum < currentFrameIndex) {
|
if (fnum < currentFrameIndex) {
|
||||||
LOG(logERROR)
|
LOG(logERROR)
|
||||||
@ -347,277 +325,72 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
|||||||
carryOverFlag = false;
|
carryOverFlag = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
switch (*frameDiscardMode) {
|
return HandleFuturePacket(false, numpackets, fnum, isHeaderEmpty,
|
||||||
case DISCARD_EMPTY_FRAMES:
|
imageSize, dstHeader);
|
||||||
if (!numpackets) {
|
|
||||||
LOG(logDEBUG)
|
|
||||||
<< index << " Skipped fnum:" << currentFrameIndex;
|
|
||||||
currentFrameIndex = fnum;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DISCARD_PARTIAL_FRAMES:
|
|
||||||
LOG(logDEBUG)
|
|
||||||
<< index << " discarding fnum:" << currentFrameIndex;
|
|
||||||
currentFrameIndex = fnum;
|
|
||||||
return -1;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
new_header->detHeader.packetNumber = numpackets;
|
|
||||||
if (isHeaderEmpty) {
|
|
||||||
new_header->detHeader.row = row;
|
|
||||||
new_header->detHeader.column = column;
|
|
||||||
}
|
|
||||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
|
||||||
++currentFrameIndex;
|
|
||||||
return imageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy packet
|
|
||||||
switch (myDetectorType) {
|
|
||||||
// for gotthard, 1st packet: 4 bytes fnum, CACA
|
|
||||||
// + CACA, 639*2 bytes data 2nd packet: 4
|
|
||||||
// bytes fnum, previous 1*2 bytes data + 640*2 bytes data !!
|
|
||||||
case GOTTHARD:
|
|
||||||
if (!pnum)
|
|
||||||
memcpy(buf + fifohsize, &carryOverPacket[hsize + 4], dsize - 2);
|
|
||||||
else
|
|
||||||
memcpy(buf + fifohsize + dsize - 2, &carryOverPacket[hsize],
|
|
||||||
dsize + 2);
|
|
||||||
break;
|
|
||||||
case CHIPTESTBOARD:
|
|
||||||
case MOENCH:
|
|
||||||
if (pnum == (pperFrame - 1))
|
|
||||||
memcpy(buf + fifohsize + (pnum * dsize),
|
|
||||||
&carryOverPacket[hsize], corrected_dsize);
|
|
||||||
else
|
|
||||||
memcpy(buf + fifohsize + (pnum * dsize),
|
|
||||||
&carryOverPacket[hsize], dsize);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
memcpy(buf + fifohsize + (pnum * dsize), &carryOverPacket[hsize],
|
|
||||||
dsize);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CopyPacket(dstData, carryOverPacket.get(), dsize, hsize,
|
||||||
|
corrected_dsize, numpackets, isHeaderEmpty, standardHeader,
|
||||||
|
dstHeader, srcDetHeader, pnum, bnum);
|
||||||
carryOverFlag = false;
|
carryOverFlag = false;
|
||||||
++numpackets; // number of packets in this image (each time its copied
|
|
||||||
// to buf)
|
|
||||||
new_header->packetsMask[(
|
|
||||||
(pnum < MAX_NUM_PACKETS) ? pnum : MAX_NUM_PACKETS - 1)] = 1;
|
|
||||||
|
|
||||||
// writer header
|
|
||||||
if (isHeaderEmpty) {
|
|
||||||
// -------------------------- new header
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
if (standardheader) {
|
|
||||||
memcpy((char *)new_header, (char *)old_header,
|
|
||||||
sizeof(sls_detector_header));
|
|
||||||
}
|
|
||||||
// -------------------old header
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
else {
|
|
||||||
new_header->detHeader.frameNumber = fnum;
|
|
||||||
new_header->detHeader.bunchId = bnum;
|
|
||||||
new_header->detHeader.row = row;
|
|
||||||
new_header->detHeader.column = column;
|
|
||||||
new_header->detHeader.detType =
|
|
||||||
(uint8_t)generalData->myDetectorType;
|
|
||||||
new_header->detHeader.version =
|
|
||||||
(uint8_t)SLS_DETECTOR_HEADER_VERSION;
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------------------------
|
|
||||||
isHeaderEmpty = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// until last packet isHeaderEmpty to account for gotthard short frame, else
|
// until last packet isHeaderEmpty to account for gotthard short frame, else
|
||||||
// never entering this loop)
|
// never entering this loop)
|
||||||
while (numpackets < pperFrame) {
|
while (numpackets < pperFrame) {
|
||||||
// listen to new packet
|
// listen to new packet
|
||||||
rc = 0;
|
if (!udpSocketAlive || !udpSocket->ReceivePacket(&listeningPacket[0])) {
|
||||||
if (udpSocketAlive) {
|
|
||||||
rc = udpSocket->ReceiveDataOnly(&listeningPacket[0]);
|
|
||||||
}
|
|
||||||
// end of acquisition
|
// end of acquisition
|
||||||
if (rc <= 0) {
|
|
||||||
if (numpackets == 0)
|
if (numpackets == 0)
|
||||||
return 0; // empty image
|
return 0;
|
||||||
|
return HandleFuturePacket(true, numpackets, fnum, isHeaderEmpty,
|
||||||
switch (*frameDiscardMode) {
|
imageSize, dstHeader);
|
||||||
case DISCARD_EMPTY_FRAMES:
|
|
||||||
if (!numpackets) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
break;
|
numPacketsCaught++;
|
||||||
case DISCARD_PARTIAL_FRAMES:
|
|
||||||
// empty packet now, but not empty image (EOA)
|
|
||||||
if (numpackets) {
|
|
||||||
LOG(logDEBUG)
|
|
||||||
<< index << " discarding fnum:" << currentFrameIndex;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
new_header->detHeader.packetNumber =
|
|
||||||
numpackets; // number of packets caught
|
|
||||||
if (isHeaderEmpty) {
|
|
||||||
new_header->detHeader.row = row;
|
|
||||||
new_header->detHeader.column = column;
|
|
||||||
}
|
|
||||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
|
||||||
return imageSize; // empty packet now, but not empty image (EOA)
|
|
||||||
}
|
|
||||||
|
|
||||||
// update parameters
|
|
||||||
numPacketsCaught++; // record immediately to get more time before socket
|
|
||||||
// shutdown
|
|
||||||
numPacketsStatistic++;
|
numPacketsStatistic++;
|
||||||
|
GetPacketIndices(fnum, pnum, bnum, standardHeader,
|
||||||
// -------------------------- new header
|
listeningPacket.get(), srcDetHeader);
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
if (standardheader) {
|
|
||||||
old_header = (sls_detector_header *)(&listeningPacket[0]);
|
|
||||||
fnum = old_header->frameNumber;
|
|
||||||
pnum = old_header->packetNumber;
|
|
||||||
}
|
|
||||||
// -------------------old header
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
else {
|
|
||||||
// set first packet to be odd or even (check required when switching
|
|
||||||
// from roi to no roi)
|
|
||||||
if (myDetectorType == GOTTHARD && !startedFlag) {
|
|
||||||
oddStartingPacket = generalData->SetOddStartingPacket(
|
|
||||||
index, &listeningPacket[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
generalData->GetHeaderInfo(index, &listeningPacket[0],
|
|
||||||
oddStartingPacket, fnum, pnum, bnum);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Eiger Firmware in a weird state
|
// Eiger Firmware in a weird state
|
||||||
if (myDetectorType == EIGER && fnum == 0) {
|
if (generalData->detType == EIGER && fnum == 0) {
|
||||||
LOG(logERROR) << "[" << *udpPortNumber
|
LOG(logERROR) << "[" << udpPortNumber
|
||||||
<< "]: Got Frame Number "
|
<< "]: Got Frame Number "
|
||||||
"Zero from Firmware. Discarding Packet";
|
"Zero from Firmware. Discarding Packet";
|
||||||
numPacketsCaught--;
|
numPacketsCaught--;
|
||||||
|
numPacketsStatistic--;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastCaughtFrameIndex = fnum;
|
lastCaughtFrameIndex = fnum;
|
||||||
|
|
||||||
LOG(logDEBUG1) << "Listening " << index
|
LOG(logDEBUG1) << "Listening " << index
|
||||||
<< ": currentfindex:" << currentFrameIndex
|
<< ": currentfindex:" << currentFrameIndex
|
||||||
<< ", fnum:" << fnum << ", pnum:" << pnum
|
<< ", fnum:" << fnum << ", pnum:" << pnum
|
||||||
<< ", numpackets:" << numpackets;
|
<< ", numpackets:" << numpackets;
|
||||||
|
|
||||||
if (!startedFlag)
|
if (!startedFlag)
|
||||||
RecordFirstIndex(fnum);
|
RecordFirstIndex(fnum);
|
||||||
|
|
||||||
|
// bad packet
|
||||||
if (pnum >= pperFrame) {
|
if (pnum >= pperFrame) {
|
||||||
LOG(logERROR) << "Bad packet " << pnum << "(fnum: " << fnum
|
LOG(logERROR) << "Bad packet " << pnum << "(fnum: " << fnum
|
||||||
<< "), throwing away. "
|
<< "), throwing away. Packets caught so far: "
|
||||||
"Packets caught so far: "
|
|
||||||
<< numpackets;
|
<< numpackets;
|
||||||
return 0; // bad packet
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// future packet by looking at image number (all other
|
// future packet
|
||||||
// detectors)
|
|
||||||
if (fnum != currentFrameIndex) {
|
if (fnum != currentFrameIndex) {
|
||||||
carryOverFlag = true;
|
carryOverFlag = true;
|
||||||
memcpy(carryOverPacket.get(), &listeningPacket[0], packetSize);
|
memcpy(carryOverPacket.get(), &listeningPacket[0], packetSize);
|
||||||
|
return HandleFuturePacket(false, numpackets, fnum, isHeaderEmpty,
|
||||||
switch (*frameDiscardMode) {
|
imageSize, dstHeader);
|
||||||
case DISCARD_EMPTY_FRAMES:
|
|
||||||
if (!numpackets) {
|
|
||||||
LOG(logDEBUG)
|
|
||||||
<< index << " Skipped fnum:" << currentFrameIndex;
|
|
||||||
currentFrameIndex = fnum;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DISCARD_PARTIAL_FRAMES:
|
|
||||||
LOG(logDEBUG)
|
|
||||||
<< index << " discarding fnum:" << currentFrameIndex;
|
|
||||||
currentFrameIndex = fnum;
|
|
||||||
return -1;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
new_header->detHeader.packetNumber =
|
|
||||||
numpackets; // number of packets caught
|
|
||||||
if (isHeaderEmpty) {
|
|
||||||
new_header->detHeader.row = row;
|
|
||||||
new_header->detHeader.column = column;
|
|
||||||
}
|
|
||||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
|
||||||
++currentFrameIndex;
|
|
||||||
return imageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy packet
|
|
||||||
switch (myDetectorType) {
|
|
||||||
// for gotthard, 1st packet: 4 bytes fnum, CACA
|
|
||||||
// + CACA, 639*2 bytes data 2nd packet: 4
|
|
||||||
// bytes fnum, previous 1*2 bytes data + 640*2 bytes data !!
|
|
||||||
case GOTTHARD:
|
|
||||||
if (!pnum)
|
|
||||||
memcpy(buf + fifohsize + (pnum * dsize),
|
|
||||||
&listeningPacket[hsize + 4], dsize - 2);
|
|
||||||
else
|
|
||||||
memcpy(buf + fifohsize + (pnum * dsize) - 2,
|
|
||||||
&listeningPacket[hsize], dsize + 2);
|
|
||||||
break;
|
|
||||||
case CHIPTESTBOARD:
|
|
||||||
case MOENCH:
|
|
||||||
if (pnum == (pperFrame - 1))
|
|
||||||
memcpy(buf + fifohsize + (pnum * dsize),
|
|
||||||
&listeningPacket[hsize], corrected_dsize);
|
|
||||||
else
|
|
||||||
memcpy(buf + fifohsize + (pnum * dsize),
|
|
||||||
&listeningPacket[hsize], dsize);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
memcpy(buf + fifohsize + (pnum * dsize), &listeningPacket[hsize],
|
|
||||||
dsize);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++numpackets; // number of packets in this image (each time its copied
|
|
||||||
// to buf)
|
|
||||||
new_header->packetsMask[(
|
|
||||||
(pnum < MAX_NUM_PACKETS) ? pnum : MAX_NUM_PACKETS - 1)] = 1;
|
|
||||||
|
|
||||||
if (isHeaderEmpty) {
|
|
||||||
// -------------------------- new header
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
if (standardheader) {
|
|
||||||
memcpy((char *)new_header, (char *)old_header,
|
|
||||||
sizeof(sls_detector_header));
|
|
||||||
}
|
|
||||||
// -------------------old header
|
|
||||||
// ------------------------------------------------------------------------------
|
|
||||||
else {
|
|
||||||
new_header->detHeader.frameNumber = fnum;
|
|
||||||
new_header->detHeader.bunchId = bnum;
|
|
||||||
new_header->detHeader.row = row;
|
|
||||||
new_header->detHeader.column = column;
|
|
||||||
new_header->detHeader.detType =
|
|
||||||
(uint8_t)generalData->myDetectorType;
|
|
||||||
new_header->detHeader.version =
|
|
||||||
(uint8_t)SLS_DETECTOR_HEADER_VERSION;
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------------------------
|
|
||||||
isHeaderEmpty = false;
|
|
||||||
}
|
}
|
||||||
|
CopyPacket(dstData, listeningPacket.get(), dsize, hsize,
|
||||||
|
corrected_dsize, numpackets, isHeaderEmpty, standardHeader,
|
||||||
|
dstHeader, srcDetHeader, pnum, bnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// complete image
|
// complete image
|
||||||
new_header->detHeader.packetNumber = numpackets; // number of packets caught
|
dstHeader.detHeader.packetNumber = numpackets;
|
||||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
|
||||||
if (numpackets == pperFrame) {
|
if (numpackets == pperFrame) {
|
||||||
++numCompleteFramesCaught;
|
++numCompleteFramesCaught;
|
||||||
}
|
}
|
||||||
@ -625,6 +398,121 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
|||||||
return imageSize;
|
return imageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Listener::HandleFuturePacket(bool EOA, uint32_t numpackets,
|
||||||
|
uint64_t fnum, bool isHeaderEmpty,
|
||||||
|
size_t imageSize,
|
||||||
|
sls_receiver_header &dstHeader) {
|
||||||
|
switch (frameDiscardMode) {
|
||||||
|
case DISCARD_EMPTY_FRAMES:
|
||||||
|
if (!numpackets) {
|
||||||
|
if (!EOA) {
|
||||||
|
LOG(logDEBUG) << index << " Skipped fnum:" << currentFrameIndex;
|
||||||
|
currentFrameIndex = fnum;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DISCARD_PARTIAL_FRAMES:
|
||||||
|
LOG(logDEBUG) << index << " discarding fnum:" << currentFrameIndex;
|
||||||
|
if (!EOA) {
|
||||||
|
currentFrameIndex = fnum;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dstHeader.detHeader.packetNumber = numpackets;
|
||||||
|
// for empty frames (padded)
|
||||||
|
if (isHeaderEmpty) {
|
||||||
|
dstHeader.detHeader.frameNumber = currentFrameIndex;
|
||||||
|
// no packet to get bnum
|
||||||
|
dstHeader.detHeader.row = row;
|
||||||
|
dstHeader.detHeader.column = column;
|
||||||
|
dstHeader.detHeader.detType =
|
||||||
|
static_cast<uint8_t>(generalData->detType);
|
||||||
|
dstHeader.detHeader.version =
|
||||||
|
static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION);
|
||||||
|
}
|
||||||
|
if (!EOA) {
|
||||||
|
++currentFrameIndex;
|
||||||
|
}
|
||||||
|
return imageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::CopyPacket(char *dst, char *src, uint32_t dataSize,
|
||||||
|
uint32_t detHeaderSize, uint32_t correctedDataSize,
|
||||||
|
uint32_t &numpackets, bool &isHeaderEmpty,
|
||||||
|
bool standardHeader, sls_receiver_header &dstHeader,
|
||||||
|
sls_detector_header *srcDetHeader, uint32_t pnum,
|
||||||
|
uint64_t bnum) {
|
||||||
|
|
||||||
|
// copy packet data
|
||||||
|
switch (generalData->detType) {
|
||||||
|
// for gotthard, 1st packet: 4 bytes fnum, CACA
|
||||||
|
// + CACA, 639*2 bytes data 2nd packet: 4
|
||||||
|
// bytes fnum, previous 1*2 bytes data + 640*2 bytes data !!
|
||||||
|
case GOTTHARD:
|
||||||
|
if (!pnum)
|
||||||
|
memcpy(dst, &src[detHeaderSize + 4], dataSize - 2);
|
||||||
|
else
|
||||||
|
memcpy(dst + dataSize - 2, &src[detHeaderSize], dataSize + 2);
|
||||||
|
break;
|
||||||
|
case CHIPTESTBOARD:
|
||||||
|
case MOENCH:
|
||||||
|
if (pnum == (generalData->packetsPerFrame - 1))
|
||||||
|
memcpy(dst + (pnum * dataSize), &src[detHeaderSize],
|
||||||
|
correctedDataSize);
|
||||||
|
else
|
||||||
|
memcpy(dst + (pnum * dataSize), &src[detHeaderSize], dataSize);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
memcpy(dst + (pnum * dataSize), &src[detHeaderSize], dataSize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++numpackets;
|
||||||
|
dstHeader
|
||||||
|
.packetsMask[((pnum < MAX_NUM_PACKETS) ? pnum : MAX_NUM_PACKETS - 1)] =
|
||||||
|
1;
|
||||||
|
|
||||||
|
// writer header
|
||||||
|
if (isHeaderEmpty) {
|
||||||
|
if (standardHeader) {
|
||||||
|
memcpy((char *)&dstHeader, (char *)srcDetHeader,
|
||||||
|
sizeof(sls_detector_header));
|
||||||
|
} else {
|
||||||
|
dstHeader.detHeader.frameNumber = currentFrameIndex;
|
||||||
|
dstHeader.detHeader.bunchId = bnum;
|
||||||
|
dstHeader.detHeader.row = row;
|
||||||
|
dstHeader.detHeader.column = column;
|
||||||
|
dstHeader.detHeader.detType =
|
||||||
|
static_cast<uint8_t>(generalData->detType);
|
||||||
|
dstHeader.detHeader.version =
|
||||||
|
static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION);
|
||||||
|
}
|
||||||
|
isHeaderEmpty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Listener::GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum,
|
||||||
|
bool standardHeader, char *packet,
|
||||||
|
sls_detector_header *&header) {
|
||||||
|
if (standardHeader) {
|
||||||
|
header = (sls_detector_header *)(&packet[0]);
|
||||||
|
fnum = header->frameNumber;
|
||||||
|
pnum = header->packetNumber;
|
||||||
|
} else {
|
||||||
|
// set first packet to be odd or even (check required when switching
|
||||||
|
// from roi to no roi)
|
||||||
|
if (generalData->detType == GOTTHARD && !startedFlag) {
|
||||||
|
oddStartingPacket =
|
||||||
|
generalData->SetOddStartingPacket(index, &packet[0]);
|
||||||
|
}
|
||||||
|
generalData->GetHeaderInfo(index, &packet[0], oddStartingPacket, fnum,
|
||||||
|
pnum, bnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Listener::PrintFifoStatistics() {
|
void Listener::PrintFifoStatistics() {
|
||||||
LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic
|
LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic
|
||||||
<< " numPacketsStatistic:" << numPacketsStatistic
|
<< " numPacketsStatistic:" << numPacketsStatistic
|
||||||
@ -638,7 +526,7 @@ void Listener::PrintFifoStatistics() {
|
|||||||
numFramesStatistic = 0;
|
numFramesStatistic = 0;
|
||||||
|
|
||||||
const auto color = loss ? logINFORED : logINFOGREEN;
|
const auto color = loss ? logINFORED : logINFOGREEN;
|
||||||
LOG(color) << "[" << *udpPortNumber
|
LOG(color) << "[" << udpPortNumber
|
||||||
<< "]: "
|
<< "]: "
|
||||||
"Packet_Loss:"
|
"Packet_Loss:"
|
||||||
<< loss << " (" << lossPercent << "%)"
|
<< loss << " (" << lossPercent << "%)"
|
||||||
|
@ -24,34 +24,10 @@ class Fifo;
|
|||||||
class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
Listener(int index, std::atomic<runStatus> *status);
|
||||||
* Constructor
|
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments
|
|
||||||
* NumberofListerners
|
|
||||||
* @param ind self index
|
|
||||||
* @param dtype detector type
|
|
||||||
* @param f address of Fifo pointer
|
|
||||||
* @param s pointer to receiver status
|
|
||||||
* @param portno pointer to udp port number
|
|
||||||
* @param e ethernet interface
|
|
||||||
* @param dr pointer to dynamic range
|
|
||||||
* @param us pointer to udp socket buffer size
|
|
||||||
* @param as pointer to actual udp socket buffer size
|
|
||||||
* @param fpf pointer to frames per file
|
|
||||||
* @param fdp frame discard policy
|
|
||||||
* @param detds pointer to detector data stream
|
|
||||||
* @param sm pointer to silent mode
|
|
||||||
*/
|
|
||||||
Listener(int ind, detectorType dtype, Fifo *f, std::atomic<runStatus> *s,
|
|
||||||
uint32_t *portno, std::string *e, int *us, int *as, uint32_t *fpf,
|
|
||||||
frameDiscardPolicy *fdp, bool *detds, bool *sm);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
* Calls Base Class DestroyThread() and decrements NumberofListerners
|
|
||||||
*/
|
|
||||||
~Listener();
|
~Listener();
|
||||||
|
|
||||||
|
bool isPortDisabled() const;
|
||||||
uint64_t GetPacketsCaught() const;
|
uint64_t GetPacketsCaught() const;
|
||||||
uint64_t GetNumCompleteFramesCaught() const;
|
uint64_t GetNumCompleteFramesCaught() const;
|
||||||
uint64_t GetLastFrameIndexCaught() const;
|
uint64_t GetLastFrameIndexCaught() const;
|
||||||
@ -62,19 +38,20 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
uint64_t GetListenedIndex() const;
|
uint64_t GetListenedIndex() const;
|
||||||
|
|
||||||
void SetFifo(Fifo *f);
|
void SetFifo(Fifo *f);
|
||||||
void ResetParametersforNewAcquisition();
|
|
||||||
void SetGeneralData(GeneralData *g);
|
void SetGeneralData(GeneralData *g);
|
||||||
|
void SetUdpPortNumber(const uint32_t portNumber);
|
||||||
|
void SetEthernetInterface(const std::string e);
|
||||||
void SetActivate(bool enable);
|
void SetActivate(bool enable);
|
||||||
|
void SetDetectorDatastream(bool enable);
|
||||||
void SetNoRoi(bool enable);
|
void SetNoRoi(bool enable);
|
||||||
void CreateUDPSockets();
|
void SetFrameDiscardPolicy(frameDiscardPolicy value);
|
||||||
void ShutDownUDPSocket();
|
void SetSilentMode(bool enable);
|
||||||
|
|
||||||
/**
|
void ResetParametersforNewAcquisition();
|
||||||
* Create & closes a dummy UDP socket
|
void CreateUDPSocket(int &actualSize);
|
||||||
* to set & get actual buffer size
|
void ShutDownUDPSocket();
|
||||||
* @param s UDP socket buffer size to be set
|
/** to set & get actual buffer size */
|
||||||
*/
|
void CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize);
|
||||||
void CreateDummySocketForUDPSocketBufferSize(int s);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set hard coded (calculated but not from detector) row and column
|
* Set hard coded (calculated but not from detector) row and column
|
||||||
@ -98,18 +75,31 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
* Pushes non empty buffers into fifo/ frees empty buffer,
|
* Pushes non empty buffers into fifo/ frees empty buffer,
|
||||||
* pushes dummy buffer into fifo
|
* pushes dummy buffer into fifo
|
||||||
* and reset running mask by calling StopRunning()
|
* and reset running mask by calling StopRunning()
|
||||||
* @param buf address of buffer
|
|
||||||
*/
|
*/
|
||||||
void StopListening(char *buf);
|
void StopListening(char *buf, size_t &size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen to the UDP Socket for an image,
|
* Listen to the UDP Socket for an image,
|
||||||
* place them in the right order
|
* place them in the right order
|
||||||
* @param buf address of buffer
|
|
||||||
* @returns number of bytes of relevant data, can be image size or 0 (stop
|
* @returns number of bytes of relevant data, can be image size or 0 (stop
|
||||||
* acquisition) or -1 to discard image
|
* acquisition) or -1 to discard image
|
||||||
*/
|
*/
|
||||||
uint32_t ListenToAnImage(char *buf);
|
uint32_t ListenToAnImage(sls_receiver_header &dstHeader, char *dstData);
|
||||||
|
|
||||||
|
size_t HandleFuturePacket(bool EOA, uint32_t numpackets, uint64_t fnum,
|
||||||
|
bool isHeaderEmpty, size_t imageSize,
|
||||||
|
sls_receiver_header &rxHeader);
|
||||||
|
|
||||||
|
void CopyPacket(char *dst, char *src, uint32_t dataSize,
|
||||||
|
uint32_t detHeaderSize, uint32_t correctedDataSize,
|
||||||
|
uint32_t &numpackets, bool &isHeaderEmpty,
|
||||||
|
bool standardHeader, sls_receiver_header &rxHeader,
|
||||||
|
sls_detector_header *detHeader, uint32_t pnum,
|
||||||
|
uint64_t bnum);
|
||||||
|
|
||||||
|
void GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum,
|
||||||
|
bool standardHeader, char *packet,
|
||||||
|
sls_detector_header *&header);
|
||||||
|
|
||||||
void PrintFifoStatistics();
|
void PrintFifoStatistics();
|
||||||
|
|
||||||
@ -118,20 +108,17 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
Fifo *fifo;
|
Fifo *fifo;
|
||||||
|
|
||||||
// individual members
|
// individual members
|
||||||
detectorType myDetectorType;
|
|
||||||
std::atomic<runStatus> *status;
|
std::atomic<runStatus> *status;
|
||||||
std::unique_ptr<UdpRxSocket> udpSocket{nullptr};
|
std::unique_ptr<UdpRxSocket> udpSocket{nullptr};
|
||||||
uint32_t *udpPortNumber;
|
|
||||||
std::string *eth;
|
uint32_t udpPortNumber{0};
|
||||||
int *udpSocketBufferSize;
|
std::string eth;
|
||||||
/** double due to kernel bookkeeping */
|
frameDiscardPolicy frameDiscardMode;
|
||||||
int *actualUDPSocketBufferSize;
|
|
||||||
uint32_t *framesPerFile;
|
|
||||||
frameDiscardPolicy *frameDiscardMode;
|
|
||||||
bool activated{false};
|
bool activated{false};
|
||||||
bool *detectorDataStream;
|
bool detectorDataStream{true};
|
||||||
bool noRoi{false};
|
bool noRoi{false};
|
||||||
bool *silentMode;
|
bool silentMode;
|
||||||
|
bool disabledPort{false};
|
||||||
|
|
||||||
/** row hardcoded as 1D or 2d,
|
/** row hardcoded as 1D or 2d,
|
||||||
* if detector does not send them yet or
|
* if detector does not send them yet or
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "MasterAttributes.h"
|
#include "MasterAttributes.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
void MasterAttributes::GetBinaryAttributes(
|
void MasterAttributes::GetBinaryAttributes(
|
||||||
@ -33,8 +32,7 @@ void MasterAttributes::GetBinaryAttributes(
|
|||||||
GetCtbBinaryAttributes(w);
|
GetCtbBinaryAttributes(w);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError(
|
throw RuntimeError("Unknown Detector type to get master attributes");
|
||||||
"Unknown Detector type to get master attributes");
|
|
||||||
}
|
}
|
||||||
GetFinalBinaryAttributes(w);
|
GetFinalBinaryAttributes(w);
|
||||||
w->EndObject();
|
w->EndObject();
|
||||||
@ -66,8 +64,7 @@ void MasterAttributes::WriteHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
|||||||
WriteCtbHDF5Attributes(fd, group);
|
WriteCtbHDF5Attributes(fd, group);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw RuntimeError(
|
throw RuntimeError("Unknown Detector type to get master attributes");
|
||||||
"Unknown Detector type to get master attributes");
|
|
||||||
}
|
}
|
||||||
WriteFinalHDF5Attributes(fd, group);
|
WriteFinalHDF5Attributes(fd, group);
|
||||||
}
|
}
|
||||||
@ -169,14 +166,15 @@ void MasterAttributes::GetFinalBinaryAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
// version
|
// version
|
||||||
{
|
{
|
||||||
double version = BINARY_WRITER_VERSION;
|
double version = BINARY_WRITER_VERSION;
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::Attribute attribute =
|
H5::Attribute attribute = fd->createAttribute(
|
||||||
fd->createAttribute("Version", H5::PredType::NATIVE_DOUBLE, dataspace);
|
"Version", H5::PredType::NATIVE_DOUBLE, dataspace);
|
||||||
attribute.write(H5::PredType::NATIVE_DOUBLE, &version);
|
attribute.write(H5::PredType::NATIVE_DOUBLE, &version);
|
||||||
}
|
}
|
||||||
// timestamp
|
// timestamp
|
||||||
@ -211,22 +209,22 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
|
|||||||
// geometry x
|
// geometry x
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Geometry in x axis",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Geometry in x axis", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&geometry.x, H5::PredType::NATIVE_INT);
|
dataset.write(&geometry.x, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// geometry y
|
// geometry y
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Geometry in y axis",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Geometry in y axis", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&geometry.y, H5::PredType::NATIVE_INT);
|
dataset.write(&geometry.y, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// Image Size
|
// Image Size
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("Image Size", H5::PredType::NATIVE_INT, dataspace);
|
"Image Size", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&imageSize, H5::PredType::NATIVE_INT);
|
dataset.write(&imageSize, H5::PredType::NATIVE_INT);
|
||||||
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::StrType strdatatype(H5::PredType::C_S1, 256);
|
H5::StrType strdatatype(H5::PredType::C_S1, 256);
|
||||||
@ -239,22 +237,22 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
|
|||||||
// npixels x
|
// npixels x
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Number of pixels in x axis",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Number of pixels in x axis", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&nPixels.x, H5::PredType::NATIVE_INT);
|
dataset.write(&nPixels.x, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// npixels y
|
// npixels y
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Number of pixels in y axis",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Number of pixels in y axis", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&nPixels.y, H5::PredType::NATIVE_INT);
|
dataset.write(&nPixels.y, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// Maximum frames per file
|
// Maximum frames per file
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Maximum frames per file",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Maximum frames per file", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&maxFramesPerFile, H5::PredType::NATIVE_INT);
|
dataset.write(&maxFramesPerFile, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// Frame Discard Policy
|
// Frame Discard Policy
|
||||||
@ -269,8 +267,8 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
|
|||||||
// Frame Padding
|
// Frame Padding
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Frame Padding",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Frame Padding", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&framePadding, H5::PredType::NATIVE_INT);
|
dataset.write(&framePadding, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// Scan Parameters
|
// Scan Parameters
|
||||||
@ -285,47 +283,48 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
|
|||||||
// Total Frames
|
// Total Frames
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Total Frames",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::STD_U64LE, dataspace);
|
"Total Frames", H5::PredType::STD_U64LE, dataspace);
|
||||||
dataset.write(&totalFrames, H5::PredType::STD_U64LE);
|
dataset.write(&totalFrames, H5::PredType::STD_U64LE);
|
||||||
}
|
}
|
||||||
// Receiver Roi xmin
|
// Receiver Roi xmin
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("receiver roi xmin",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"receiver roi xmin", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&receiverRoi.xmin, H5::PredType::NATIVE_INT);
|
dataset.write(&receiverRoi.xmin, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// Receiver Roi xmax
|
// Receiver Roi xmax
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("receiver roi xmax",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"receiver roi xmax", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&receiverRoi.xmax, H5::PredType::NATIVE_INT);
|
dataset.write(&receiverRoi.xmax, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// Receiver Roi ymin
|
// Receiver Roi ymin
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("receiver roi ymin",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"receiver roi ymin", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&receiverRoi.ymin, H5::PredType::NATIVE_INT);
|
dataset.write(&receiverRoi.ymin, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// Receiver Roi ymax
|
// Receiver Roi ymax
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("receiver roi ymax",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"receiver roi ymax", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&receiverRoi.ymax, H5::PredType::NATIVE_INT);
|
dataset.write(&receiverRoi.ymax, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
// Total Frames in file
|
// Total Frames in file
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Frames in File",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::STD_U64LE, dataspace);
|
"Frames in File", H5::PredType::STD_U64LE, dataspace);
|
||||||
dataset.write(&framesInFile, H5::PredType::STD_U64LE);
|
dataset.write(&framesInFile, H5::PredType::STD_U64LE);
|
||||||
}
|
}
|
||||||
// additional json header
|
// additional json header
|
||||||
@ -362,8 +361,8 @@ void MasterAttributes::WriteHDF5Period(H5::H5File *fd, H5::Group *group) {
|
|||||||
|
|
||||||
void MasterAttributes::WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("Dynamic Range", H5::PredType::NATIVE_INT, dataspace);
|
"Dynamic Range", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&dynamicRange, H5::PredType::NATIVE_INT);
|
dataset.write(&dynamicRange, H5::PredType::NATIVE_INT);
|
||||||
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::StrType strdatatype(H5::PredType::C_S1, 256);
|
H5::StrType strdatatype(H5::PredType::C_S1, 256);
|
||||||
@ -375,8 +374,8 @@ void MasterAttributes::WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group) {
|
|||||||
|
|
||||||
void MasterAttributes::WriteHDF5TenGiga(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5TenGiga(H5::H5File *fd, H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Ten Giga Enable",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Ten Giga Enable", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&tenGiga, H5::PredType::NATIVE_INT);
|
dataset.write(&tenGiga, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,38 +383,40 @@ void MasterAttributes::WriteHDF5ROI(H5::H5File *fd, H5::Group *group) {
|
|||||||
// Roi xmin
|
// Roi xmin
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("roi xmin", H5::PredType::NATIVE_INT, dataspace);
|
"roi xmin", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&detectorRoi.xmin, H5::PredType::NATIVE_INT);
|
dataset.write(&detectorRoi.xmin, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
// Roi xmax
|
// Roi xmax
|
||||||
{
|
{
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("roi xmax", H5::PredType::NATIVE_INT, dataspace);
|
"roi xmax", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&detectorRoi.xmax, H5::PredType::NATIVE_INT);
|
dataset.write(&detectorRoi.xmax, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5NumUDPInterfaces(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5NumUDPInterfaces(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Number of UDP Interfaces",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Number of UDP Interfaces", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&numUDPInterfaces, H5::PredType::NATIVE_INT);
|
dataset.write(&numUDPInterfaces, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5ReadNRows(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5ReadNRows(H5::H5File *fd, H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("Number of rows", H5::PredType::NATIVE_INT, dataspace);
|
"Number of rows", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&readNRows, H5::PredType::NATIVE_INT);
|
dataset.write(&readNRows, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Threshold Energy",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Threshold Energy", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&thresholdEnergyeV, H5::PredType::NATIVE_INT);
|
dataset.write(&thresholdEnergyeV, H5::PredType::NATIVE_INT);
|
||||||
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::StrType strdatatype(H5::PredType::C_S1, 256);
|
H5::StrType strdatatype(H5::PredType::C_S1, 256);
|
||||||
@ -425,7 +426,8 @@ void MasterAttributes::WriteHDF5ThresholdEnergy(H5::H5File *fd, H5::Group *group
|
|||||||
attribute.write(strdatatype, c);
|
attribute.write(strdatatype, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::StrType strdatatype(H5::PredType::C_S1, 1024);
|
H5::StrType strdatatype(H5::PredType::C_S1, 1024);
|
||||||
@ -462,7 +464,8 @@ void MasterAttributes::WriteHDF5SubQuad(H5::H5File *fd, H5::Group *group) {
|
|||||||
dataset.write(&quad, H5::PredType::NATIVE_INT);
|
dataset.write(&quad, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::StrType strdatatype(H5::PredType::C_S1, 1024);
|
H5::StrType strdatatype(H5::PredType::C_S1, 1024);
|
||||||
@ -474,8 +477,8 @@ void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd, H5::Group *group
|
|||||||
|
|
||||||
void MasterAttributes::WriteHDF5CounterMask(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5CounterMask(H5::H5File *fd, H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("Counter Mask", H5::PredType::STD_U32LE, dataspace);
|
"Counter Mask", H5::PredType::STD_U32LE, dataspace);
|
||||||
dataset.write(&counterMask, H5::PredType::STD_U32LE);
|
dataset.write(&counterMask, H5::PredType::STD_U32LE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +494,8 @@ void MasterAttributes::WriteHDF5ExptimeArray(H5::H5File *fd, H5::Group *group) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5GateDelayArray(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5GateDelayArray(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
for (int i = 0; i != 3; ++i) {
|
for (int i = 0; i != 3; ++i) {
|
||||||
char c[1024]{};
|
char c[1024]{};
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
@ -529,43 +533,45 @@ void MasterAttributes::WriteHDF5AdcMask(H5::H5File *fd, H5::Group *group) {
|
|||||||
|
|
||||||
void MasterAttributes::WriteHDF5AnalogFlag(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5AnalogFlag(H5::H5File *fd, H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("Analog Flag", H5::PredType::NATIVE_INT, dataspace);
|
"Analog Flag", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&analog, H5::PredType::NATIVE_INT);
|
dataset.write(&analog, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5AnalogSamples(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5AnalogSamples(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("Analog Samples", H5::PredType::NATIVE_INT, dataspace);
|
"Analog Samples", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&analogSamples, H5::PredType::NATIVE_INT);
|
dataset.write(&analogSamples, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5DigitalFlag(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5DigitalFlag(H5::H5File *fd, H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("Digital Flag", H5::PredType::NATIVE_INT, dataspace);
|
"Digital Flag", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&digital, H5::PredType::NATIVE_INT);
|
dataset.write(&digital, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5DigitalSamples(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5DigitalSamples(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Digital Samples",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::NATIVE_INT, dataspace);
|
"Digital Samples", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&digitalSamples, H5::PredType::NATIVE_INT);
|
dataset.write(&digitalSamples, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5DbitOffset(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5DbitOffset(H5::H5File *fd, H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset =
|
H5::DataSet dataset = group->createDataSet(
|
||||||
group->createDataSet("Dbit Offset", H5::PredType::NATIVE_INT, dataspace);
|
"Dbit Offset", H5::PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&dbitoffset, H5::PredType::NATIVE_INT);
|
dataset.write(&dbitoffset, H5::PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterAttributes::WriteHDF5DbitList(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteHDF5DbitList(H5::H5File *fd, H5::Group *group) {
|
||||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||||
H5::DataSet dataset = group->createDataSet("Dbit Bitset List",
|
H5::DataSet dataset = group->createDataSet(
|
||||||
H5::PredType::STD_U64LE, dataspace);
|
"Dbit Bitset List", H5::PredType::STD_U64LE, dataspace);
|
||||||
dataset.write(&dbitlist, H5::PredType::STD_U64LE);
|
dataset.write(&dbitlist, H5::PredType::STD_U64LE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -586,7 +592,8 @@ void MasterAttributes::GetGotthardBinaryAttributes(
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void MasterAttributes::WriteGotthardHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteGotthardHDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||||
MasterAttributes::WriteHDF5Period(fd, group);
|
MasterAttributes::WriteHDF5Period(fd, group);
|
||||||
MasterAttributes::WriteHDF5ROI(fd, group);
|
MasterAttributes::WriteHDF5ROI(fd, group);
|
||||||
@ -606,7 +613,8 @@ void MasterAttributes::GetJungfrauBinaryAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void MasterAttributes::WriteJungfrauHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteJungfrauHDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||||
MasterAttributes::WriteHDF5Period(fd, group);
|
MasterAttributes::WriteHDF5Period(fd, group);
|
||||||
MasterAttributes::WriteHDF5NumUDPInterfaces(fd, group);
|
MasterAttributes::WriteHDF5NumUDPInterfaces(fd, group);
|
||||||
@ -639,7 +647,8 @@ void MasterAttributes::GetEigerBinaryAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void MasterAttributes::WriteEigerHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteEigerHDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
MasterAttributes::WriteHDF5DynamicRange(fd, group);
|
MasterAttributes::WriteHDF5DynamicRange(fd, group);
|
||||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||||
@ -678,7 +687,8 @@ void MasterAttributes::GetMythen3BinaryAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void MasterAttributes::WriteMythen3HDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteMythen3HDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
MasterAttributes::WriteHDF5DynamicRange(fd, group);
|
MasterAttributes::WriteHDF5DynamicRange(fd, group);
|
||||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||||
MasterAttributes::WriteHDF5Period(fd, group);
|
MasterAttributes::WriteHDF5Period(fd, group);
|
||||||
@ -701,7 +711,8 @@ void MasterAttributes::GetGotthard2BinaryAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void MasterAttributes::WriteGotthard2HDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteGotthard2HDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||||
MasterAttributes::WriteHDF5Period(fd, group);
|
MasterAttributes::WriteHDF5Period(fd, group);
|
||||||
MasterAttributes::WriteHDF5BurstMode(fd, group);
|
MasterAttributes::WriteHDF5BurstMode(fd, group);
|
||||||
@ -723,7 +734,8 @@ void MasterAttributes::GetMoenchBinaryAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void MasterAttributes::WriteMoenchHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteMoenchHDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||||
MasterAttributes::WriteHDF5Period(fd, group);
|
MasterAttributes::WriteHDF5Period(fd, group);
|
||||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||||
@ -757,7 +769,8 @@ void MasterAttributes::GetCtbBinaryAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
void MasterAttributes::WriteCtbHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
void MasterAttributes::WriteCtbHDF5Attributes(H5::H5File *fd,
|
||||||
|
H5::Group *group) {
|
||||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||||
MasterAttributes::WriteHDF5Period(fd, group);
|
MasterAttributes::WriteHDF5Period(fd, group);
|
||||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||||
|
@ -7,21 +7,18 @@
|
|||||||
#include "sls/logger.h"
|
#include "sls/logger.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <rapidjson/prettywriter.h>
|
#include <rapidjson/prettywriter.h>
|
||||||
#include <rapidjson/stringbuffer.h>
|
#include <rapidjson/stringbuffer.h>
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
#include "H5Cpp.h"
|
#include "H5Cpp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
using ns = std::chrono::nanoseconds;
|
using ns = std::chrono::nanoseconds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MasterAttributes {
|
class MasterAttributes {
|
||||||
public:
|
public:
|
||||||
// (before acquisition)
|
// (before acquisition)
|
||||||
|
@ -70,7 +70,8 @@ void LinkHDF5FileInMaster(std::string &masterFileName,
|
|||||||
|
|
||||||
// create link for data dataset
|
// create link for data dataset
|
||||||
H5::DataSet dset = fd->openDataSet(DATASET_NAME);
|
H5::DataSet dset = fd->openDataSet(DATASET_NAME);
|
||||||
std::string linkname = std::string("/entry/data/") + std::string(DATASET_NAME);
|
std::string linkname =
|
||||||
|
std::string("/entry/data/") + std::string(DATASET_NAME);
|
||||||
if (H5Lcreate_external(dataFilename.c_str(), DATASET_NAME,
|
if (H5Lcreate_external(dataFilename.c_str(), DATASET_NAME,
|
||||||
masterfd.getLocId(), linkname.c_str(),
|
masterfd.getLocId(), linkname.c_str(),
|
||||||
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||||
@ -152,8 +153,7 @@ std::string CreateMasterHDF5File(const std::string &filePath,
|
|||||||
error.printErrorStack();
|
error.printErrorStack();
|
||||||
if (fd != nullptr)
|
if (fd != nullptr)
|
||||||
fd->close();
|
fd->close();
|
||||||
throw RuntimeError(
|
throw RuntimeError("Could not create/overwrite master HDF5 handles");
|
||||||
"Could not create/overwrite master HDF5 handles");
|
|
||||||
}
|
}
|
||||||
if (!silentMode) {
|
if (!silentMode) {
|
||||||
LOG(logINFO) << "Master File: " << fileName;
|
LOG(logINFO) << "Master File: " << fileName;
|
||||||
@ -165,13 +165,12 @@ std::string CreateVirtualHDF5File(
|
|||||||
const std::string &filePath, const std::string &fileNamePrefix,
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const int modulePos, const int numUnitsPerReadout,
|
||||||
const uint32_t maxFramesPerFile,
|
const uint32_t maxFramesPerFile, const uint32_t nPixelsX,
|
||||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
const uint32_t nPixelsY, const uint32_t dynamicRange,
|
||||||
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
const uint64_t numImagesCaught, const int numModX, const int numModY,
|
||||||
const int numModX, const int numModY, const H5::DataType dataType,
|
const H5::DataType dataType, const std::vector<std::string> parameterNames,
|
||||||
const std::vector<std::string> parameterNames,
|
const std::vector<H5::DataType> parameterDataTypes,
|
||||||
const std::vector<H5::DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
|
std::mutex *hdf5LibMutex, bool gotthard25um) {
|
||||||
bool gotthard25um) {
|
|
||||||
|
|
||||||
// virtual file name
|
// virtual file name
|
||||||
std::ostringstream osfn;
|
std::ostringstream osfn;
|
||||||
@ -207,21 +206,23 @@ std::string CreateVirtualHDF5File(
|
|||||||
"version", H5::PredType::NATIVE_DOUBLE, dataspace_attr);
|
"version", H5::PredType::NATIVE_DOUBLE, dataspace_attr);
|
||||||
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
|
attribute.write(H5::PredType::NATIVE_DOUBLE, &dValue);
|
||||||
|
|
||||||
// virtual dataspace
|
// dataspace
|
||||||
hsize_t vdsDims[3] = {numImagesCaught, numModY * nDimy,
|
hsize_t vdsDims[DATA_RANK] = {numImagesCaught, numModY * nDimy,
|
||||||
numModZ * nDimz};
|
numModZ * nDimz};
|
||||||
H5::DataSpace vdsDataSpace(3, vdsDims, nullptr);
|
hsize_t vdsDimsPara[VDS_PARA_RANK] = {numImagesCaught,
|
||||||
hsize_t vdsDimsPara[2] = {numImagesCaught,
|
numModY * numModZ};
|
||||||
(unsigned int)numModY * numModZ};
|
H5::DataSpace vdsDataSpace(DATA_RANK, vdsDims, nullptr);
|
||||||
H5::DataSpace vdsDataSpacePara(2, vdsDimsPara, nullptr);
|
H5::DataSpace vdsDataSpacePara(VDS_PARA_RANK, vdsDimsPara, nullptr);
|
||||||
|
|
||||||
// property list (fill value and datatype)
|
// property list
|
||||||
int fill_value = -1;
|
|
||||||
H5::DSetCreatPropList plist;
|
H5::DSetCreatPropList plist;
|
||||||
|
int fill_value = -1;
|
||||||
plist.setFillValue(dataType, &fill_value);
|
plist.setFillValue(dataType, &fill_value);
|
||||||
|
|
||||||
// property list for parameters (datatype)
|
|
||||||
std::vector<H5::DSetCreatPropList> plistPara(paraSize);
|
std::vector<H5::DSetCreatPropList> plistPara(paraSize);
|
||||||
|
// ignoring last fill (string)
|
||||||
|
for (unsigned int i = 0; i != plistPara.size() - 1; ++i) {
|
||||||
|
plistPara[i].setFillValue(parameterDataTypes[i], &fill_value);
|
||||||
|
}
|
||||||
|
|
||||||
// hyperslab (files)
|
// hyperslab (files)
|
||||||
int numFiles = numImagesCaught / maxFramesPerFile;
|
int numFiles = numImagesCaught / maxFramesPerFile;
|
||||||
@ -235,15 +236,15 @@ std::string CreateVirtualHDF5File(
|
|||||||
? maxFramesPerFile
|
? maxFramesPerFile
|
||||||
: (numImagesCaught - framesSaved);
|
: (numImagesCaught - framesSaved);
|
||||||
|
|
||||||
hsize_t startLocation[3] = {framesSaved, 0, 0};
|
hsize_t startLocation[DATA_RANK] = {framesSaved, 0, 0};
|
||||||
hsize_t strideBetweenBlocks[3] = {1, 1, 1};
|
hsize_t strideBetweenBlocks[DATA_RANK] = {1, 1, 1};
|
||||||
hsize_t numBlocks[3] = {nDimx, nDimy, nDimz};
|
hsize_t numBlocks[DATA_RANK] = {nDimx, nDimy, nDimz};
|
||||||
hsize_t blockSize[3] = {1, 1, 1};
|
hsize_t blockSize[DATA_RANK] = {1, 1, 1};
|
||||||
|
|
||||||
hsize_t startLocationPara[2] = {framesSaved, 0};
|
hsize_t startLocationPara[VDS_PARA_RANK] = {framesSaved, 0};
|
||||||
hsize_t strideBetweenBlocksPara[3] = {1, 1};
|
hsize_t strideBetweenBlocksPara[VDS_PARA_RANK] = {1, 1};
|
||||||
hsize_t numBlocksPara[2] = {1, 1};
|
hsize_t numBlocksPara[VDS_PARA_RANK] = {nDimx, 1};
|
||||||
hsize_t blockSizePara[3] = {nDimx, 1};
|
hsize_t blockSizePara[VDS_PARA_RANK] = {1, 1};
|
||||||
|
|
||||||
// interleaving for g2
|
// interleaving for g2
|
||||||
if (gotthard25um) {
|
if (gotthard25um) {
|
||||||
@ -284,12 +285,23 @@ std::string CreateVirtualHDF5File(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// source dataspace
|
// source dataspace
|
||||||
hsize_t srcDims[3] = {nDimx, nDimy, nDimz};
|
hsize_t srcDims[DATA_RANK] = {nDimx, nDimy, nDimz};
|
||||||
hsize_t srcDimsMax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
hsize_t srcDimsMax[DATA_RANK] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||||
H5::DataSpace srcDataSpace(3, srcDims, srcDimsMax);
|
H5::DataSpace srcDataSpace(DATA_RANK, srcDims, srcDimsMax);
|
||||||
hsize_t srcDimsPara[1] = {nDimx};
|
hsize_t srcDimsPara[PARA_RANK] = {nDimx};
|
||||||
hsize_t srcDimsMaxPara[1] = {H5S_UNLIMITED};
|
hsize_t srcDimsMaxPara[PARA_RANK] = {H5S_UNLIMITED};
|
||||||
H5::DataSpace srcDataSpacePara(1, srcDimsPara, srcDimsMaxPara);
|
H5::DataSpace srcDataSpacePara(PARA_RANK, srcDimsPara,
|
||||||
|
srcDimsMaxPara);
|
||||||
|
// temporary fixfor corner case bug:
|
||||||
|
// (framescaught not multiple of framesperfile,
|
||||||
|
// virtual parameter datasets error loading (bad scalar value))
|
||||||
|
if (nDimx != maxFramesPerFile) {
|
||||||
|
hsize_t count[1] = {nDimx};
|
||||||
|
hsize_t start[1] = {0};
|
||||||
|
srcDataSpacePara.selectHyperslab(
|
||||||
|
H5S_SELECT_SET, count, start, strideBetweenBlocksPara,
|
||||||
|
blockSizePara);
|
||||||
|
}
|
||||||
|
|
||||||
// mapping of property list
|
// mapping of property list
|
||||||
plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(),
|
plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(),
|
||||||
@ -310,13 +322,13 @@ std::string CreateVirtualHDF5File(
|
|||||||
startLocation[1] += nDimy;
|
startLocation[1] += nDimy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
startLocationPara[1]++;
|
++startLocationPara[1];
|
||||||
}
|
}
|
||||||
framesSaved += nDimx;
|
framesSaved += nDimx;
|
||||||
}
|
}
|
||||||
// datasets
|
// datasets
|
||||||
H5::DataSet vdsDataSet(fd->createDataSet(DATASET_NAME, dataType,
|
H5::DataSet vdsDataSet(
|
||||||
vdsDataSpace, plist));
|
fd->createDataSet(DATASET_NAME, dataType, vdsDataSpace, plist));
|
||||||
|
|
||||||
for (unsigned int p = 0; p < paraSize; ++p) {
|
for (unsigned int p = 0; p < paraSize; ++p) {
|
||||||
H5::DataSet vdsDataSetPara(fd->createDataSet(
|
H5::DataSet vdsDataSetPara(fd->createDataSet(
|
||||||
@ -330,8 +342,7 @@ std::string CreateVirtualHDF5File(
|
|||||||
if (fd) {
|
if (fd) {
|
||||||
fd->close();
|
fd->close();
|
||||||
}
|
}
|
||||||
throw RuntimeError(
|
throw RuntimeError("Could not create/overwrite virtual HDF5 handles");
|
||||||
"Could not create/overwrite virtual HDF5 handles");
|
|
||||||
}
|
}
|
||||||
if (!silentMode) {
|
if (!silentMode) {
|
||||||
LOG(logINFO) << "Virtual File: " << fileName;
|
LOG(logINFO) << "Virtual File: " << fileName;
|
||||||
|
@ -10,9 +10,6 @@ namespace sls {
|
|||||||
|
|
||||||
namespace masterFileUtility {
|
namespace masterFileUtility {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string CreateMasterBinaryFile(const std::string &filePath,
|
std::string CreateMasterBinaryFile(const std::string &filePath,
|
||||||
const std::string &fileNamePrefix,
|
const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex,
|
const uint64_t fileIndex,
|
||||||
@ -37,13 +34,12 @@ std::string CreateVirtualHDF5File(
|
|||||||
const std::string &filePath, const std::string &fileNamePrefix,
|
const std::string &filePath, const std::string &fileNamePrefix,
|
||||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||||
const int modulePos, const int numUnitsPerReadout,
|
const int modulePos, const int numUnitsPerReadout,
|
||||||
const uint32_t maxFramesPerFile,
|
const uint32_t maxFramesPerFile, const uint32_t nPixelsX,
|
||||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
const uint32_t nPixelsY, const uint32_t dynamicRange,
|
||||||
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
const uint64_t numImagesCaught, const int numModX, const int numModY,
|
||||||
const int numModX, const int numModY, const H5::DataType dataType,
|
const H5::DataType dataType, const std::vector<std::string> parameterNames,
|
||||||
const std::vector<std::string> parameterNames,
|
const std::vector<H5::DataType> parameterDataTypes,
|
||||||
const std::vector<H5::DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
|
std::mutex *hdf5LibMutex, bool gotthard25um);
|
||||||
bool gotthard25um);
|
|
||||||
#endif
|
#endif
|
||||||
} // namespace masterFileUtility
|
} // namespace masterFileUtility
|
||||||
|
|
||||||
|
@ -54,7 +54,8 @@ 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(sls::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;
|
||||||
}
|
}
|
||||||
@ -70,9 +71,9 @@ void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) {
|
|||||||
* Prints in different colors(for each receiver process) the different headers
|
* Prints in different colors(for each receiver process) the different headers
|
||||||
* for each image call back.
|
* for each image call back.
|
||||||
*/
|
*/
|
||||||
void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
|
void GetData(slsDetectorDefs::sls_receiver_header &header, char *dataPointer,
|
||||||
size_t imageSize, void *objectPointer) {
|
size_t imageSize, void *objectPointer) {
|
||||||
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
|
slsDetectorDefs::sls_detector_header detectorHeader = header.detHeader;
|
||||||
|
|
||||||
PRINT_IN_COLOR(
|
PRINT_IN_COLOR(
|
||||||
detectorHeader.modId ? detectorHeader.modId : detectorHeader.row,
|
detectorHeader.modId ? detectorHeader.modId : detectorHeader.row,
|
||||||
@ -101,9 +102,9 @@ void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
|
|||||||
* @param modifiedImageSize new data size in bytes after the callback.
|
* @param modifiedImageSize new data size in bytes after the callback.
|
||||||
* This will be the size written/streamed. (only smaller value is allowed).
|
* This will be the size written/streamed. (only smaller value is allowed).
|
||||||
*/
|
*/
|
||||||
void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
|
void GetData(slsDetectorDefs::sls_receiver_header &header, char *dataPointer,
|
||||||
size_t &modifiedImageSize, void *objectPointer) {
|
size_t &modifiedImageSize, void *objectPointer) {
|
||||||
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
|
slsDetectorDefs::sls_detector_header detectorHeader = header.detHeader;
|
||||||
|
|
||||||
PRINT_IN_COLOR(
|
PRINT_IN_COLOR(
|
||||||
detectorHeader.modId ? detectorHeader.modId : detectorHeader.row,
|
detectorHeader.modId ? detectorHeader.modId : detectorHeader.row,
|
||||||
@ -123,7 +124,7 @@ void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
|
|||||||
detectorHeader.debug, detectorHeader.roundRNumber,
|
detectorHeader.debug, detectorHeader.roundRNumber,
|
||||||
detectorHeader.detType, detectorHeader.version,
|
detectorHeader.detType, detectorHeader.version,
|
||||||
// header->packetsMask.to_string().c_str(),
|
// header->packetsMask.to_string().c_str(),
|
||||||
((uint8_t)(*((uint8_t *)(dataPointer)))), modifiedImageSize);
|
*reinterpret_cast<uint8_t *>(dataPointer), modifiedImageSize);
|
||||||
|
|
||||||
// if data is modified, eg ROI and size is reduced
|
// if data is modified, eg ROI and size is reduced
|
||||||
modifiedImageSize = 26000;
|
modifiedImageSize = 26000;
|
||||||
|
@ -128,8 +128,10 @@ int64_t Receiver::getReceiverVersion() {
|
|||||||
return tcpipInterface->getReceiverVersion();
|
return tcpipInterface->getReceiverVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::registerCallBackStartAcquisition(
|
void Receiver::registerCallBackStartAcquisition(int (*func)(const std::string &,
|
||||||
int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
|
const std::string &,
|
||||||
|
uint64_t, size_t,
|
||||||
|
void *),
|
||||||
void *arg) {
|
void *arg) {
|
||||||
tcpipInterface->registerCallBackStartAcquisition(func, arg);
|
tcpipInterface->registerCallBackStartAcquisition(func, arg);
|
||||||
}
|
}
|
||||||
@ -141,12 +143,12 @@ void Receiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::registerCallBackRawDataReady(
|
void Receiver::registerCallBackRawDataReady(
|
||||||
void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
|
void (*func)(sls_receiver_header &, char *, size_t, void *), void *arg) {
|
||||||
tcpipInterface->registerCallBackRawDataReady(func, arg);
|
tcpipInterface->registerCallBackRawDataReady(func, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::registerCallBackRawDataModifyReady(
|
void Receiver::registerCallBackRawDataModifyReady(
|
||||||
void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
|
void (*func)(sls_receiver_header &, char *, size_t &, void *), void *arg) {
|
||||||
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
|
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,15 +18,15 @@ namespace sls {
|
|||||||
#define gettid() syscall(SYS_gettid)
|
#define gettid() syscall(SYS_gettid)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ThreadObject::ThreadObject(int threadIndex, std::string threadType)
|
ThreadObject::ThreadObject(int index, std::string type)
|
||||||
: index(threadIndex), type(threadType) {
|
: index(index), type(type) {
|
||||||
LOG(logDEBUG) << type << " thread created: " << index;
|
LOG(logDEBUG) << type << " thread created: " << index;
|
||||||
sem_init(&semaphore, 1, 0);
|
sem_init(&semaphore, 1, 0);
|
||||||
try {
|
try {
|
||||||
threadObject = std::thread(&ThreadObject::RunningThread, this);
|
threadObject = std::thread(&ThreadObject::RunningThread, this);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw RuntimeError("Could not create " + type +
|
throw RuntimeError("Could not create " + type + " thread with index " +
|
||||||
" thread with index " + std::to_string(index));
|
std::to_string(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class ThreadObject : private virtual slsDetectorDefs {
|
|||||||
const int index{0};
|
const int index{0};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThreadObject(int threadIndex, std::string threadType);
|
ThreadObject(int index, std::string type);
|
||||||
virtual ~ThreadObject();
|
virtual ~ThreadObject();
|
||||||
pid_t GetThreadId() const;
|
pid_t GetThreadId() const;
|
||||||
bool IsRunning() const;
|
bool IsRunning() const;
|
||||||
|
@ -37,13 +37,21 @@ namespace sls {
|
|||||||
#define FILE_BUFFER_SIZE (16 * 1024 * 1024) // 16mb
|
#define FILE_BUFFER_SIZE (16 * 1024 * 1024) // 16mb
|
||||||
|
|
||||||
// fifo
|
// fifo
|
||||||
#define FIFO_HEADER_NUMBYTES (16)
|
struct image_structure {
|
||||||
#define FIFO_DATASIZE_NUMBYTES (4)
|
size_t size;
|
||||||
#define FIFO_PADDING_NUMBYTES \
|
size_t firstIndex;
|
||||||
(4) // for 8 byte alignment due to sls_receiver_header structure
|
slsDetectorDefs::sls_receiver_header header;
|
||||||
|
char data[];
|
||||||
|
};
|
||||||
|
#define IMAGE_STRUCTURE_HEADER_SIZE \
|
||||||
|
(sizeof(size_t) + sizeof(size_t) + \
|
||||||
|
sizeof(slsDetectorDefs::sls_receiver_header))
|
||||||
|
|
||||||
// hdf5
|
// hdf5
|
||||||
#define MAX_CHUNKED_IMAGES (1)
|
#define MAX_CHUNKED_IMAGES (1)
|
||||||
|
#define DATA_RANK (3)
|
||||||
|
#define PARA_RANK (1)
|
||||||
|
#define VDS_PARA_RANK (2)
|
||||||
|
|
||||||
// parameters to calculate fifo depth
|
// parameters to calculate fifo depth
|
||||||
#define SAMPLE_TIME_IN_NS (100000000) // 100ms
|
#define SAMPLE_TIME_IN_NS (100000000) // 100ms
|
||||||
@ -58,7 +66,6 @@ namespace sls {
|
|||||||
#define STREAMER_PRIORITY (10)
|
#define STREAMER_PRIORITY (10)
|
||||||
#define TCP_PRIORITY (10)
|
#define TCP_PRIORITY (10)
|
||||||
|
|
||||||
|
|
||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
#define DATASET_NAME "/data"
|
#define DATASET_NAME "/data"
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Empty buffer") {
|
TEST_CASE("Empty buffer") {
|
||||||
CircularFifo<char> fifo(0);
|
CircularFifo<char> fifo(0);
|
||||||
|
|
||||||
|
@ -192,8 +192,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 StaticVector<T, Capacity> &c) {
|
||||||
const StaticVector<T, Capacity> &c) {
|
|
||||||
return os << ToString(c);
|
return os << ToString(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,6 @@ class UdpRxSocket {
|
|||||||
void setBufferSize(int size);
|
void setBufferSize(int size);
|
||||||
ssize_t getPacketSize() const noexcept;
|
ssize_t getPacketSize() const noexcept;
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
// Only for backwards compatibility, this drops the EIGER small pkt, may be
|
|
||||||
// removed
|
|
||||||
ssize_t ReceiveDataOnly(char *dst) noexcept;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
*@short functions to open/close zmq sockets
|
*@short functions to open/close zmq sockets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sls/sls_detector_exceptions.h"
|
|
||||||
#include "sls/container_utils.h"
|
#include "sls/container_utils.h"
|
||||||
|
#include "sls/sls_detector_exceptions.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -23,7 +23,6 @@ namespace sls {
|
|||||||
// #define ZMQ_DETAIL
|
// #define ZMQ_DETAIL
|
||||||
#define ROIVERBOSITY
|
#define ROIVERBOSITY
|
||||||
|
|
||||||
|
|
||||||
/** 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 */
|
||||||
@ -224,8 +223,7 @@ class ZmqSocket {
|
|||||||
/** Socket descriptor */
|
/** Socket descriptor */
|
||||||
mySocketDescriptors sockfd;
|
mySocketDescriptors sockfd;
|
||||||
|
|
||||||
std::unique_ptr<char[]> header_buffer =
|
std::unique_ptr<char[]> header_buffer = make_unique<char[]>(MAX_STR_LENGTH);
|
||||||
make_unique<char[]>(MAX_STR_LENGTH);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#define APIGUI 0x220609
|
#define APIGUI 0x220609
|
||||||
#define APICTB 0x220714
|
#define APICTB 0x220714
|
||||||
#define APIGOTTHARD 0x220714
|
#define APIGOTTHARD 0x220714
|
||||||
#define APIGOTTHARD2 0x220714
|
|
||||||
#define APIJUNGFRAU 0x220714
|
#define APIJUNGFRAU 0x220714
|
||||||
#define APIMYTHEN3 0x220714
|
#define APIMYTHEN3 0x220714
|
||||||
#define APIMOENCH 0x220714
|
#define APIMOENCH 0x220714
|
||||||
#define APIEIGER 0x220714
|
#define APIEIGER 0x220714
|
||||||
|
#define APIGOTTHARD2 0x220811
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
#define DEFAULT_PACKET_SIZE 1286
|
#define DEFAULT_PACKET_SIZE 1286
|
||||||
|
@ -123,8 +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 RuntimeError(
|
throw RuntimeError("Invalid current source parameters. Cannot print.");
|
||||||
"Invalid current source parameters. Cannot print.");
|
|
||||||
}
|
}
|
||||||
oss << '[';
|
oss << '[';
|
||||||
if (r.enable) {
|
if (r.enable) {
|
||||||
|
@ -18,13 +18,11 @@ namespace sls {
|
|||||||
UdpRxSocket::UdpRxSocket(int port, ssize_t packet_size, const char *hostname,
|
UdpRxSocket::UdpRxSocket(int port, ssize_t packet_size, const char *hostname,
|
||||||
int kernel_buffer_size)
|
int kernel_buffer_size)
|
||||||
: packet_size_(packet_size) {
|
: packet_size_(packet_size) {
|
||||||
struct addrinfo hints;
|
struct addrinfo hints {};
|
||||||
memset(&hints, 0, sizeof(hints));
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
hints.ai_protocol = 0;
|
|
||||||
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
|
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
|
||||||
struct addrinfo *res = nullptr;
|
struct addrinfo *res{nullptr};
|
||||||
|
|
||||||
const std::string portname = std::to_string(port);
|
const std::string portname = std::to_string(port);
|
||||||
if (getaddrinfo(hostname, portname.c_str(), &hints, &res)) {
|
if (getaddrinfo(hostname, portname.c_str(), &hints, &res)) {
|
||||||
@ -36,6 +34,7 @@ UdpRxSocket::UdpRxSocket(int port, ssize_t packet_size, const char *hostname,
|
|||||||
throw RuntimeError("Failed to create UDP RX socket");
|
throw RuntimeError("Failed to create UDP RX socket");
|
||||||
}
|
}
|
||||||
if (bind(sockfd_, res->ai_addr, res->ai_addrlen) == -1) {
|
if (bind(sockfd_, res->ai_addr, res->ai_addrlen) == -1) {
|
||||||
|
close(sockfd_);
|
||||||
throw RuntimeError("Failed to bind UDP RX socket");
|
throw RuntimeError("Failed to bind UDP RX socket");
|
||||||
}
|
}
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
@ -56,29 +55,19 @@ UdpRxSocket::UdpRxSocket(int port, ssize_t packet_size, const char *hostname,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UdpRxSocket::~UdpRxSocket() { Shutdown(); }
|
UdpRxSocket::~UdpRxSocket() {
|
||||||
|
Shutdown();
|
||||||
|
close(sockfd_);
|
||||||
|
sockfd_ = -1;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t UdpRxSocket::getPacketSize() const noexcept { return packet_size_; }
|
ssize_t UdpRxSocket::getPacketSize() const noexcept { return packet_size_; }
|
||||||
|
|
||||||
bool UdpRxSocket::ReceivePacket(char *dst) noexcept {
|
bool UdpRxSocket::ReceivePacket(char *dst) noexcept {
|
||||||
auto bytes_received =
|
auto bytes_received =
|
||||||
recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr);
|
recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr);
|
||||||
return bytes_received == packet_size_;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t UdpRxSocket::ReceiveDataOnly(char *dst) noexcept {
|
return bytes_received == packet_size_;
|
||||||
auto r = recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr);
|
|
||||||
constexpr ssize_t eiger_header_packet = 40; // only detector that has this
|
|
||||||
if (r == eiger_header_packet) {
|
|
||||||
LOG(logWARNING) << "Got header pkg";
|
|
||||||
r = recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr);
|
|
||||||
}
|
|
||||||
// temporary workaround for Eiger firmware (stop sends bad packets of size 8
|
|
||||||
// bytes)
|
|
||||||
if (r == 8) {
|
|
||||||
LOG(logWARNING) << "Ignoring bad packet of size 8 bytes";
|
|
||||||
r = recvfrom(sockfd_, dst, packet_size_, 0, nullptr, nullptr);
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int UdpRxSocket::getBufferSize() const {
|
int UdpRxSocket::getBufferSize() const {
|
||||||
@ -95,10 +84,7 @@ void UdpRxSocket::setBufferSize(int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UdpRxSocket::Shutdown() {
|
void UdpRxSocket::Shutdown() {
|
||||||
|
// not closing yet on purpose, but read gives -1
|
||||||
shutdown(sockfd_, SHUT_RDWR);
|
shutdown(sockfd_, SHUT_RDWR);
|
||||||
if (sockfd_ >= 0) {
|
|
||||||
close(sockfd_);
|
|
||||||
sockfd_ = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // namespace sls
|
} // namespace sls
|
@ -417,4 +417,3 @@ void ZmqSocket::mySocketDescriptors::Close() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|
||||||
|
@ -60,8 +60,7 @@ 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 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");
|
||||||
@ -76,8 +75,7 @@ std::vector<char> readBinaryFile(const std::string &fname,
|
|||||||
|
|
||||||
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 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) {
|
||||||
|
@ -333,8 +333,7 @@ TEST_CASE("streamingInterface") {
|
|||||||
REQUIRE(ToString(defs::streamingInterface::ETHERNET_10GB) == "10gbe");
|
REQUIRE(ToString(defs::streamingInterface::ETHERNET_10GB) == "10gbe");
|
||||||
REQUIRE(ToString(defs::streamingInterface::LOW_LATENCY_LINK) == "lll");
|
REQUIRE(ToString(defs::streamingInterface::LOW_LATENCY_LINK) == "lll");
|
||||||
REQUIRE(ToString(defs::streamingInterface::LOW_LATENCY_LINK |
|
REQUIRE(ToString(defs::streamingInterface::LOW_LATENCY_LINK |
|
||||||
defs::streamingInterface::ETHERNET_10GB) ==
|
defs::streamingInterface::ETHERNET_10GB) == "lll, 10gbe");
|
||||||
"lll, 10gbe");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Speed level
|
// Speed level
|
||||||
@ -353,10 +352,8 @@ TEST_CASE("string to speedLevel") {
|
|||||||
defs::speedLevel::HALF_SPEED);
|
defs::speedLevel::HALF_SPEED);
|
||||||
REQUIRE(StringTo<defs::speedLevel>("quarter_speed") ==
|
REQUIRE(StringTo<defs::speedLevel>("quarter_speed") ==
|
||||||
defs::speedLevel::QUARTER_SPEED);
|
defs::speedLevel::QUARTER_SPEED);
|
||||||
REQUIRE(StringTo<defs::speedLevel>("108") ==
|
REQUIRE(StringTo<defs::speedLevel>("108") == defs::speedLevel::G2_108MHZ);
|
||||||
defs::speedLevel::G2_108MHZ);
|
REQUIRE(StringTo<defs::speedLevel>("144") == defs::speedLevel::G2_144MHZ);
|
||||||
REQUIRE(StringTo<defs::speedLevel>("144") ==
|
|
||||||
defs::speedLevel::G2_144MHZ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -33,8 +33,7 @@ int open_socket(int port) {
|
|||||||
|
|
||||||
const std::string portname = std::to_string(port);
|
const std::string portname = std::to_string(port);
|
||||||
if (getaddrinfo(host, portname.c_str(), &hints, &res)) {
|
if (getaddrinfo(host, portname.c_str(), &hints, &res)) {
|
||||||
throw RuntimeError("Failed at getaddrinfo with " +
|
throw RuntimeError("Failed at getaddrinfo with " + std::string(host));
|
||||||
std::string(host));
|
|
||||||
}
|
}
|
||||||
int fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
int fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Throws when cannot create socket") {
|
TEST_CASE("Throws when cannot create socket") {
|
||||||
REQUIRE_THROWS(ZmqSocket("sdiasodjajpvv", 5076001));
|
REQUIRE_THROWS(ZmqSocket("sdiasodjajpvv", 5076001));
|
||||||
}
|
}
|
||||||
@ -118,4 +117,4 @@ TEST_CASE("Send header and data") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace
|
} // namespace sls
|
@ -38,7 +38,8 @@ int main(int argc, char **argv) {
|
|||||||
for (int i = 0; i != 100; ++i) {
|
for (int i = 0; i != 100; ++i) {
|
||||||
std::cout << "Sending: " << i << "\n";
|
std::cout << "Sending: " << i << "\n";
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.Send(sls::func_id::read_int) << " bytes\n";
|
std::cout << "Sent: " << socket.Send(sls::func_id::read_int)
|
||||||
|
<< " bytes\n";
|
||||||
std::cout << "Sent: " << socket.Send(i) << " bytes\n";
|
std::cout << "Sent: " << socket.Send(i) << " bytes\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +47,8 @@ int main(int argc, char **argv) {
|
|||||||
for (int i = 0; i != 5; ++i) {
|
for (int i = 0; i != 5; ++i) {
|
||||||
std::cout << "Sending data\n";
|
std::cout << "Sending data\n";
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.Send(sls::func_id::read_data) << " bytes\n";
|
std::cout << "Sent: " << socket.Send(sls::func_id::read_data)
|
||||||
|
<< " bytes\n";
|
||||||
std::cout << "Sent: " << socket.Send(data.get(), sls::DATA_SIZE)
|
std::cout << "Sent: " << socket.Send(data.get(), sls::DATA_SIZE)
|
||||||
<< " bytes\n";
|
<< " bytes\n";
|
||||||
}
|
}
|
||||||
@ -54,7 +56,8 @@ int main(int argc, char **argv) {
|
|||||||
// Send too little data
|
// Send too little data
|
||||||
{
|
{
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.Send(sls::func_id::read_data) << " bytes\n";
|
std::cout << "Sent: " << socket.Send(sls::func_id::read_data)
|
||||||
|
<< " bytes\n";
|
||||||
std::cout << "Sent: " << socket.Send(data.get(), sls::DATA_SIZE / 2)
|
std::cout << "Sent: " << socket.Send(data.get(), sls::DATA_SIZE / 2)
|
||||||
<< " bytes\n";
|
<< " bytes\n";
|
||||||
}
|
}
|
||||||
@ -71,7 +74,8 @@ int main(int argc, char **argv) {
|
|||||||
for (int i = 0; i != 10; ++i) {
|
for (int i = 0; i != 10; ++i) {
|
||||||
std::cout << "Sending: " << i << "\n";
|
std::cout << "Sending: " << i << "\n";
|
||||||
auto socket = sls::ClientSocket("test", hostname, port);
|
auto socket = sls::ClientSocket("test", hostname, port);
|
||||||
std::cout << "Sent: " << socket.Send(sls::func_id::read_int) << " bytes\n";
|
std::cout << "Sent: " << socket.Send(sls::func_id::read_int)
|
||||||
|
<< " bytes\n";
|
||||||
std::cout << "Sent: " << socket.Send(i) << " bytes\n";
|
std::cout << "Sent: " << socket.Send(i) << " bytes\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,14 @@ int main(int argc, char *argv[]) {
|
|||||||
sls::test::my_ip = "undefined";
|
sls::test::my_ip = "undefined";
|
||||||
|
|
||||||
Catch::Session session;
|
Catch::Session session;
|
||||||
auto cli =
|
auto cli = session.cli() |
|
||||||
session.cli() |
|
|
||||||
sls::Opt(sls::test::hostname, "hostname")["-hn"]["--hostname"](
|
sls::Opt(sls::test::hostname, "hostname")["-hn"]["--hostname"](
|
||||||
"Detector hostname for integration tests") |
|
"Detector hostname for integration tests") |
|
||||||
sls::Opt(sls::test::detector_type, "detector_type")["-dt"]["--detector_type"](
|
sls::Opt(sls::test::detector_type,
|
||||||
|
"detector_type")["-dt"]["--detector_type"](
|
||||||
"Detector type for integration tests") |
|
"Detector type for integration tests") |
|
||||||
sls::Opt(sls::test::my_ip, "my_ip")["-hip"]["--host_ip"]("Host ip address");
|
sls::Opt(sls::test::my_ip,
|
||||||
|
"my_ip")["-hip"]["--host_ip"]("Host ip address");
|
||||||
|
|
||||||
session.cli(cli);
|
session.cli(cli);
|
||||||
|
|
||||||
@ -47,8 +48,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
sls::test::type = slsDetectorDefs::GENERIC;
|
sls::test::type = slsDetectorDefs::GENERIC;
|
||||||
if (!sls::test::detector_type.empty()) {
|
if (!sls::test::detector_type.empty()) {
|
||||||
sls::test::type =
|
sls::test::type = sls::StringTo<slsDetectorDefs::detectorType>(
|
||||||
sls::StringTo<slsDetectorDefs::detectorType>(sls::test::detector_type);
|
sls::test::detector_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return session.run();
|
return session.run();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user