Formatted package
This commit is contained in:
Dhanya Thattil 2022-08-05 15:39:34 +02:00 committed by GitHub
parent 7173785b29
commit 6bf9dbf6d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
89 changed files with 1366 additions and 1210 deletions

View File

@ -106,4 +106,3 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
} }
} // namespace sls } // namespace sls

View File

@ -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;
@ -140,7 +140,7 @@ class SlsQt1DPlot : public QwtPlot {
void SetLogX(bool yes = 1); void SetLogX(bool yes = 1);
void SetLogY(bool yes = 1); void SetLogY(bool yes = 1);
void EnableRoiBox(std::array<int, 4> roi); void EnableRoiBox(std::array<int, 4> roi);
void DisableRoiBox(); void DisableRoiBox();
private: private:
@ -176,5 +176,3 @@ class SlsQt1DPlot : public QwtPlot {
} // namespace sls } // namespace sls
#endif #endif

View File

@ -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;
@ -70,7 +70,7 @@ class SlsQt2DPlot : public QwtPlot {
void SetLogz(bool enable, bool isMin, bool isMax, double min, double max); void SetLogz(bool enable, bool isMin, bool isMax, double min, double max);
void SetZRange(bool isMin, bool isMax, double min, double max); void SetZRange(bool isMin, bool isMax, double min, double max);
void LogZ(bool on = 1); void LogZ(bool on = 1);
void EnableRoiBox(std::array<int, 4> roi); void EnableRoiBox(std::array<int, 4> roi);
void DisableRoiBox(); void DisableRoiBox();
public slots: public slots:

View File

@ -444,17 +444,16 @@ 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();
roiBox->attach(this); roiBox->attach(this);
roiBox->setPen(QColor(Qt::yellow), 2.0, Qt::SolidLine); roiBox->setPen(QColor(Qt::yellow), 2.0, Qt::SolidLine);
} }
// TopLeft - BottomRight (max points are +1 on graph) // TopLeft - BottomRight (max points are +1 on graph)
QRect myRect(QPoint(roi[0], roi[2]), QPoint(roi[1] - 1, roi[3] - 1)); QRect myRect(QPoint(roi[0], roi[2]), QPoint(roi[1] - 1, roi[3] - 1));
roiBox->setRect( QRectF(myRect) ); roiBox->setRect(QRectF(myRect));
replot(); replot();
} }
@ -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());

View File

@ -301,7 +301,7 @@ void SlsQt2DPlot::EnableRoiBox(std::array<int, 4> roi) {
// TopLeft - BottomRight (max points are +1 on graph) // TopLeft - BottomRight (max points are +1 on graph)
QRect myRect(QPoint(roi[0], roi[2]), QPoint(roi[1] - 1, roi[3] - 1)); QRect myRect(QPoint(roi[0], roi[2]), QPoint(roi[1] - 1, roi[3] - 1));
roiBox->setRect( QRectF(myRect) ); roiBox->setRect(QRectF(myRect));
roiBox->attach(this); roiBox->attach(this);
replot(); replot();

View File

@ -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':
@ -73,7 +74,7 @@ int main(int argc, char **argv) {
case 'v': case 'v':
tempval = APIGUI; tempval = APIGUI;
LOG(sls::logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x" LOG(sls::logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
<< std::hex << tempval << ")"; << std::hex << tempval << ")";
return 0; return 0;
case 'h': case 'h':
@ -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);

View File

@ -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;
@ -778,15 +777,15 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
rxRoi.ymax = data->rxRoi[3]; rxRoi.ymax = data->rxRoi[3];
// only for 2d anyway // only for 2d anyway
if (isGapPixels) { if (isGapPixels) {
rxRoi.xmin += ((rxRoi.xmin/1024) * 6 + (rxRoi.xmin/256) * 2); rxRoi.xmin += ((rxRoi.xmin / 1024) * 6 + (rxRoi.xmin / 256) * 2);
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) {
@ -1034,17 +1033,22 @@ 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()});
}
} }
void qDrawPlot::Update2dPlot() { void qDrawPlot::Update2dPlot() {

View File

@ -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,

View File

@ -235,7 +235,7 @@ void qTabDataOutput::GetFileFormat() {
break; break;
default: default:
throw RuntimeError(std::string("Unknown file format: ") + throw RuntimeError(std::string("Unknown file format: ") +
std::to_string(static_cast<int>(retval))); std::to_string(static_cast<int>(retval)));
} }
} }
CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat") CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat")

View File

@ -344,7 +344,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
@ -371,7 +371,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -397,7 +397,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
return slsDetectorDefs::TEMPERATURE_ADC; return slsDetectorDefs::TEMPERATURE_ADC;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -421,7 +421,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
return slsDetectorDefs::IBIAS_SFP; return slsDetectorDefs::IBIAS_SFP;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -463,7 +463,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
return slsDetectorDefs::VTHRESHOLD; return slsDetectorDefs::VTHRESHOLD;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;
@ -499,7 +499,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
return slsDetectorDefs::VCOM_ADC2; return slsDetectorDefs::VCOM_ADC2;
default: default:
throw RuntimeError(std::string("Unknown dac/adc index") + throw RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index)); std::to_string(index));
} }
break; break;

View File

@ -339,7 +339,7 @@ void qTabMeasurement::GetTimingMode() {
disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetTimingMode(int))); SLOT(SetTimingMode(int)));
try { try {
slsDetectorDefs::timingMode retval{slsDetectorDefs::AUTO_TIMING}; slsDetectorDefs::timingMode retval{slsDetectorDefs::AUTO_TIMING};
// m3: remove slave modes (always trigger) before squashing // m3: remove slave modes (always trigger) before squashing
if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) { if (det->getDetectorType().squash() == slsDetectorDefs::MYTHEN3) {
@ -373,7 +373,7 @@ void qTabMeasurement::GetTimingMode() {
break; break;
default: default:
throw RuntimeError(std::string("Unknown timing mode: ") + throw RuntimeError(std::string("Unknown timing mode: ") +
std::to_string(retval)); std::to_string(retval));
} }
} }
CATCH_DISPLAY("Could not get timing mode.", CATCH_DISPLAY("Could not get timing mode.",
@ -410,7 +410,7 @@ void qTabMeasurement::GetBurstMode() {
break; break;
default: default:
throw RuntimeError(std::string("Unknown burst mode: ") + throw RuntimeError(std::string("Unknown burst mode: ") +
std::to_string(retval)); std::to_string(retval));
} }
} }
CATCH_DISPLAY("Could not get burst mode.", "qTabMeasurement::GetBurstMode") CATCH_DISPLAY("Could not get burst mode.", "qTabMeasurement::GetBurstMode")

View File

@ -88,7 +88,7 @@ void qTabSettings::SetupWidgetWindow() {
} else if (detType == slsDetectorDefs::EIGER) { } else if (detType == slsDetectorDefs::EIGER) {
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
hvmin = 0; hvmin = 0;
lblDynamicRange->setEnabled(true); lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true); comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true); lblThreshold->setEnabled(true);
@ -103,11 +103,11 @@ void qTabSettings::SetupWidgetWindow() {
lblComboHV->show(); lblComboHV->show();
} else if (detType == slsDetectorDefs::MOENCH) { } else if (detType == slsDetectorDefs::MOENCH) {
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
} else if (detType == slsDetectorDefs::GOTTHARD2) { } else if (detType == slsDetectorDefs::GOTTHARD2) {
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
hvmin = 0; hvmin = 0;
} }
// default settings for the disabled // default settings for the disabled
@ -241,10 +241,10 @@ void qTabSettings::GetHighVoltage() {
try { try {
Result<int> retvals = det->getHighVoltage(); Result<int> retvals = det->getHighVoltage();
int retval = 0; int retval = 0;
if (det->getDetectorType().squash() != slsDetectorDefs::EIGER) { if (det->getDetectorType().squash() != slsDetectorDefs::EIGER) {
retval = retvals.tsquash("Inconsistent values for high voltage."); retval = retvals.tsquash("Inconsistent values for high voltage.");
} }
// eiger slaves return -999 // eiger slaves return -999
else { else {
@ -255,14 +255,15 @@ 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
if (spinHV->isVisible()) { if (spinHV->isVisible()) {
if (retval != 0 && retval < hvmin && retval > HV_MAX) { if (retval != 0 && retval < hvmin && retval > HV_MAX) {
throw RuntimeError(std::string("Unknown High Voltage: ") + throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval)); std::to_string(retval));
} }
spinHV->setValue(retval); spinHV->setValue(retval);
} }
@ -292,12 +293,11 @@ void qTabSettings::GetHighVoltage() {
break; break;
default: default:
throw RuntimeError(std::string("Unknown High Voltage: ") + throw RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval)); std::to_string(retval));
} }
} }
} }
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()));
@ -332,7 +332,7 @@ void qTabSettings::GetSettings() {
default: default:
if ((int)retval < -1 || (int)retval >= comboSettings->count()) { if ((int)retval < -1 || (int)retval >= comboSettings->count()) {
throw RuntimeError(std::string("Unknown settings: ") + throw RuntimeError(std::string("Unknown settings: ") +
std::to_string(retval)); std::to_string(retval));
} }
comboSettings->setCurrentIndex(retval); comboSettings->setCurrentIndex(retval);
break; break;
@ -367,7 +367,7 @@ void qTabSettings::GetGainMode() {
"Inconsistent gain mode for all detectors."); "Inconsistent gain mode for all detectors.");
if ((int)retval < 0 || (int)retval >= comboGainMode->count()) { if ((int)retval < 0 || (int)retval >= comboGainMode->count()) {
throw RuntimeError(std::string("Unknown gain mode: ") + throw RuntimeError(std::string("Unknown gain mode: ") +
std::to_string(retval)); std::to_string(retval));
} }
// warning when using fix_g0 and not in export mode // warning when using fix_g0 and not in export mode
if ((int)retval == FIX_G0 && !isVisibleFixG0) { if ((int)retval == FIX_G0 && !isVisibleFixG0) {
@ -438,7 +438,7 @@ void qTabSettings::GetDynamicRange() {
break; break;
default: default:
throw RuntimeError(std::string("Unknown dynamic range: ") + throw RuntimeError(std::string("Unknown dynamic range: ") +
std::to_string(retval)); std::to_string(retval));
} }
} }
CATCH_DISPLAY("Could not get dynamic range.", CATCH_DISPLAY("Could not get dynamic range.",
@ -469,7 +469,7 @@ void qTabSettings::SetDynamicRange(int index) {
break; break;
default: default:
throw RuntimeError(std::string("Unknown dynamic range: ") + throw RuntimeError(std::string("Unknown dynamic range: ") +
std::to_string(index)); std::to_string(index));
} }
} }
CATCH_HANDLE("Could not set dynamic range.", CATCH_HANDLE("Could not set dynamic range.",
@ -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,9 +554,8 @@ 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);
} }

View File

@ -1125,7 +1125,7 @@ int64_t getMeasuredSubPeriod() {
/* parameters - channel, module, settings */ /* parameters - channel, module, settings */
void getModule(sls_detector_module* myMod) { void getModule(sls_detector_module *myMod) {
// serial number // serial number
myMod->serialnumber = detectorModules->serialnumber; myMod->serialnumber = detectorModules->serialnumber;
// reg (settings) // reg (settings)
@ -1133,7 +1133,7 @@ void getModule(sls_detector_module* myMod) {
// iodelay // iodelay
myMod->iodelay = setIODelay(-1); myMod->iodelay = setIODelay(-1);
// tau // tau
myMod->tau = (int) getCurrentTau(); myMod->tau = (int)getCurrentTau();
// eV // eV
myMod->eV[0] = detectorModules->eV[0]; myMod->eV[0] = detectorModules->eV[0];
// dacs // dacs
@ -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;
} }
@ -2158,7 +2160,7 @@ void setExternalGating(int enable[]) {
enable[1] = eiger_extgatingpolarity; enable[1] = eiger_extgatingpolarity;
} }
int setTrimbits(int* chanregs, char* mess) { int setTrimbits(int *chanregs, char *mess) {
LOG(logINFO, ("Setting module with trimbits\n")); LOG(logINFO, ("Setting module with trimbits\n"));
#ifndef VIRTUAL #ifndef VIRTUAL
// include gap pixels // include gap pixels
@ -2190,7 +2192,7 @@ int setTrimbits(int* chanregs, char* mess) {
LOG(logERROR, (mess)); LOG(logERROR, (mess));
setSettings(UNDEFINED); setSettings(UNDEFINED);
LOG(logERROR, ("Settings has been changed to undefined (random " LOG(logERROR, ("Settings has been changed to undefined (random "
"trim file)\n")); "trim file)\n"));
// if quad, reset M8 and PROGRAM manually // if quad, reset M8 and PROGRAM manually
if (!Feb_Control_SetChipSignalsToTrimQuad(0)) { if (!Feb_Control_SetChipSignalsToTrimQuad(0)) {
@ -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

View File

@ -2305,9 +2305,9 @@ int setClockDivider(enum CLKINDEX ind, int val) {
int64_t period = getPeriod(); int64_t period = getPeriod();
int64_t delayAfterTrigger = getDelayAfterTrigger(); int64_t delayAfterTrigger = getDelayAfterTrigger();
int64_t burstPeriod = getBurstPeriod(); int64_t burstPeriod = getBurstPeriod();
systemFrequency = ((double)getVCOFrequency(SYSTEM_C0) / systemFrequency = ((double)getVCOFrequency(SYSTEM_C0) /
(double)clkDivider[SYSTEM_C0]); (double)clkDivider[SYSTEM_C0]);
setExpTime(exptime); setExpTime(exptime);
setPeriod(period); setPeriod(period);

View File

@ -67,11 +67,11 @@
#define SPEED_144_CLKDIV_0 (6) #define SPEED_144_CLKDIV_0 (6)
#define SPEED_144_CLKDIV_1 (6) #define SPEED_144_CLKDIV_1 (6)
#define SPEED_144_CLKPHASE_DEG_1 (122) // 125 not possible #define SPEED_144_CLKPHASE_DEG_1 (122) // 125 not possible
#define SPEED_144_DBIT_PIPELINE (1) #define SPEED_144_DBIT_PIPELINE (1)
#define SPEED_108_CLKDIV_0 (8) #define SPEED_108_CLKDIV_0 (8)
#define SPEED_108_CLKDIV_1 (8) #define SPEED_108_CLKDIV_1 (8)
#define SPEED_108_CLKPHASE_DEG_1 (268) // 270 not possible #define SPEED_108_CLKPHASE_DEG_1 (268) // 270 not possible
#define SPEED_108_DBIT_PIPELINE (1) #define SPEED_108_DBIT_PIPELINE (1)
/* Firmware Definitions */ /* Firmware Definitions */
#define FIXED_PLL_FREQUENCY (20000000) // 20MHz #define FIXED_PLL_FREQUENCY (20000000) // 20MHz

View File

@ -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;
} }

View File

@ -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)

View File

@ -422,7 +422,7 @@ void allocateDetectorStructureMemory() {
detectorDacs[idac] = 0; detectorDacs[idac] = 0;
} }
// trimbits start at 0 // trimbits start at 0
for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) { for (int ichan = 0; ichan < (detectorModules->nchan); ichan++) {
*((detectorModules->chanregs) + ichan) = 0; *((detectorModules->chanregs) + ichan) = 0;
} }
@ -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);
@ -1102,7 +1101,7 @@ void updateVthAndCounterMask() {
setVthDac(2, 0); setVthDac(2, 0);
} else { } else {
// previous counter values // previous counter values
setCounterMaskWithUpdateFlag(counterMask, 0); setCounterMaskWithUpdateFlag(counterMask, 0);
} }
if (pumpProbe) { if (pumpProbe) {
// enable only vth2 // enable only vth2
@ -1280,7 +1279,7 @@ int setDACS(int *dacs) {
return OK; return OK;
} }
void getModule(sls_detector_module* myMod) { void getModule(sls_detector_module *myMod) {
// serial number // serial number
myMod->serialnumber = detectorModules->serialnumber; myMod->serialnumber = detectorModules->serialnumber;
// csr reg // csr reg
@ -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;
@ -1479,7 +1481,7 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
void validateSettings() { void validateSettings() {
LOG(logWARNING, ("Not validating dac settings temporarily")); LOG(logWARNING, ("Not validating dac settings temporarily"));
return; return;
// if any special dac value is changed individually => undefined // if any special dac value is changed individually => undefined
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX; const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast, int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast,
@ -1541,7 +1543,7 @@ void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck) {
return; return;
} }
// threshold dacs // threshold dacs
// remember value, vthreshold: skip disabled, // remember value, vthreshold: skip disabled,
// others: disable or enable dac if counter mask // others: disable or enable dac if counter mask
// setDAC called directly: will set independent of counter enable // setDAC called directly: will set independent of counter enable
@ -1569,8 +1571,8 @@ void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck) {
// skip setting vthx dac (value remembered anyway) // skip setting vthx dac (value remembered anyway)
if (ind == M_VTHRESHOLD) { if (ind == M_VTHRESHOLD) {
continue; continue;
} }
// disable dac (except when setting dac directly) // disable dac (except when setting dac directly)
if (counterEnableCheck) { if (counterEnableCheck) {
val = DEFAULT_COUNTER_DISABLED_VTH_VAL; val = DEFAULT_COUNTER_DISABLED_VTH_VAL;
} }
@ -1624,7 +1626,7 @@ void setVthDac(int index, int enable) {
if (enable) { if (enable) {
value = vthEnabledVals[index]; value = vthEnabledVals[index];
} }
setGeneralDAC(vthdacs[index], value, 0); setGeneralDAC(vthdacs[index], value, 0);
} }
int getDAC(enum DACINDEX ind, int mV) { int getDAC(enum DACINDEX ind, int mV) {
@ -1790,11 +1792,11 @@ int setGainCaps(int caps) {
int setInterpolation(int enable) { int setInterpolation(int enable) {
LOG(logINFO, LOG(logINFO,
("%s Interpolation\n", enable == 0 ? "Disabling" : "Enabling")); ("%s Interpolation\n", enable == 0 ? "Disabling" : "Enabling"));
int csr = M3SetInterpolation(enable); int csr = M3SetInterpolation(enable);
int ret = setChipStatusRegister(csr); int ret = setChipStatusRegister(csr);
if (ret == OK) { if (ret == OK) {
updateVthAndCounterMask(); updateVthAndCounterMask();
} }
return ret; return ret;
} }
@ -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;
@ -2310,7 +2313,7 @@ int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val, int timeUpda
} }
int64_t period = getPeriod(); int64_t period = getPeriod();
int64_t delayAfterTrigger = getDelayAfterTrigger(); int64_t delayAfterTrigger = getDelayAfterTrigger();
clkDivider[ind] = val; clkDivider[ind] = val;
for (int i = 0; i != 3; ++i) { for (int i = 0; i != 3; ++i) {
@ -2461,8 +2464,8 @@ void *start_timer(void *arg) {
for (int i = 0; i < nchannels; ++i) { for (int i = 0; i < nchannels; ++i) {
switch (dr) { switch (dr) {
//case 1: // TODO: Not implemented in firmware yet // case 1: // TODO: Not implemented in firmware yet
// break; // break;
case 8: case 8:
*((uint8_t *)(imageData + i)) = (uint8_t)i; *((uint8_t *)(imageData + i)) = (uint8_t)i;
break; break;
@ -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;
@ -2491,8 +2495,7 @@ void *start_timer(void *arg) {
struct timespec begin, end; struct timespec begin, end;
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;

View File

@ -105,7 +105,7 @@ enum DACINDEX {
1220, /* vIpreOut */ \ 1220, /* vIpreOut */ \
2800, /* Vth3 */ \ 2800, /* Vth3 */ \
2800, /* Vth1 */ \ 2800, /* Vth1 */ \
800, /* vIcin */ \ 800, /* vIcin */ \
1800, /* cas */ \ 1800, /* cas */ \
1100, /* Vrpreamp */ \ 1100, /* Vrpreamp */ \
1100, /* Vcal_n */ \ 1100, /* Vcal_n */ \

View File

@ -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,
int forceDeleteNormalFile); FILE **srcfd, int forceDeleteNormalFile);
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, 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);

View File

@ -310,14 +310,14 @@ int64_t getMeasurementTime();
// parameters - module, settings // parameters - module, settings
#if defined(MYTHEN3D) || defined(EIGERD) #if defined(MYTHEN3D) || defined(EIGERD)
void getModule(sls_detector_module* myMod); void getModule(sls_detector_module *myMod);
#endif #endif
#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(GOTTHARD2D)) #if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(GOTTHARD2D))
int setModule(sls_detector_module myMod, char *mess); int setModule(sls_detector_module myMod, char *mess);
#endif #endif
#ifdef EIGERD #ifdef EIGERD
int setTrimbits(int* chanregs, char* mess); int setTrimbits(int *chanregs, char *mess);
#endif #endif
#ifdef MYTHEN3D #ifdef MYTHEN3D
int setTrimbits(int *trimbits); int setTrimbits(int *trimbits);
@ -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

View File

@ -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;
@ -471,7 +470,7 @@ int sendModule(int file_des, sls_detector_module *myMod) {
LOG(level, ("dacs sent %d bytes.\n", n)); LOG(level, ("dacs sent %d bytes.\n", n));
// channels // channels
n = sendData(file_des, myMod->chanregs, sizeof(int) * (myMod->nchan), n = sendData(file_des, myMod->chanregs, sizeof(int) * (myMod->nchan),
INT32); INT32);
LOG(level, ("chanregs sent %d bytes.\n", n)); LOG(level, ("chanregs sent %d bytes.\n", n));
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;

View File

@ -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;
} }
@ -970,13 +980,13 @@ int loadPatternFile(char *patFname, char *errMessage) {
} }
// patloop // patloop
if (!strncmp(line, "patloop", strlen("patloop"))){ if (!strncmp(line, "patloop", strlen("patloop"))) {
int level = -1; int level = -1;
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;
} }

View File

@ -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,9 +169,10 @@ 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(
"Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n", mess, MAX_STR_LENGTH,
retvals); "Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n",
retvals);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
@ -178,9 +182,10 @@ 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(
"Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n", mess, MAX_STR_LENGTH,
retvals); "Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n",
retvals);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
@ -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,17 +514,21 @@ 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 "
"'--force-delete-normal-file'\n", "and proceeding with "
messageType, flashDriveName); "programming), re-run the programming command "
"'programfpga' with parameter "
"'--force-delete-normal-file'\n",
messageType, flashDriveName);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
// 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;
} }

View File

@ -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;

View File

@ -1292,7 +1292,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
// ignore counter enable to force vth dac values // ignore counter enable to force vth dac values
setDAC(serverDacIndex, val, mV, 0); setDAC(serverDacIndex, val, mV, 0);
#else #else
setDAC(serverDacIndex, val, mV); setDAC(serverDacIndex, val, mV);
#endif #endif
retval = getDAC(serverDacIndex, mV); retval = getDAC(serverDacIndex, mV);
} }
@ -1573,7 +1573,7 @@ int get_module(int file_des) {
#if !defined(MYTHEN3D) && !defined(EIGERD) #if !defined(MYTHEN3D) && !defined(EIGERD)
functionNotImplemented(); functionNotImplemented();
#else #else
// allocate to receive module structure // allocate to receive module structure
// allocate dacs // allocate dacs
@ -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));
@ -1881,55 +1881,57 @@ int acquire(int blocking, int file_des) {
#ifdef EIGERD #ifdef EIGERD
// check for hardware mac and hardware ip // check for hardware mac and hardware ip
if (udpDetails[0].srcmac != getDetectorMAC()) { if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL; ret = FAIL;
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);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else if (!enableTenGigabitEthernet(GET_FLAG) && } else if (!enableTenGigabitEthernet(GET_FLAG) &&
(udpDetails[0].srcip != getDetectorIP())) { (udpDetails[0].srcip != getDetectorIP())) {
ret = FAIL;
uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip);
sprintf(
mess,
"Invalid udp source ip address for this detector. Must be same "
"as hardware detector ip address %s in 1G readout mode \n",
src_ip);
LOG(logERROR, (mess));
} else
#endif
if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess));
} else {
memset(scanErrMessage, 0, MAX_STR_LENGTH);
sharedMemory_setScanStop(0);
sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL; ret = FAIL;
strcpy(mess, "Could not start acquisition thread!\n"); uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip);
sprintf(
mess,
"Invalid udp source ip address for this detector. Must be "
"same "
"as hardware detector ip address %s in 1G readout mode \n",
src_ip);
LOG(logERROR, (mess));
} else
#endif
if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else { } else {
// only does not wait for non blocking and scan memset(scanErrMessage, 0, MAX_STR_LENGTH);
if (blocking || !scan) { sharedMemory_setScanStop(0);
pthread_join(pthread_tid, NULL); sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL;
strcpy(mess, "Could not start acquisition thread!\n");
LOG(logERROR, (mess));
} else {
// only does not wait for non blocking and scan
if (blocking || !scan) {
pthread_join(pthread_tid, NULL);
}
} }
} }
}
} }
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
} }
@ -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,21 +9972,22 @@ 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);
if (ret == FAIL) { if (ret == FAIL) {
if (arg) if (arg)
sprintf(mess, "Could not set interpolation or enable all " sprintf(mess, "Could not set interpolation or enable all "
"counters for it.\n"); "counters for it.\n");
else else
sprintf(mess, "Could not set interpolation\n"); sprintf(mess, "Could not set interpolation\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else { } else {
int retval = getInterpolation(); int retval = getInterpolation();
validate(&ret, mess, (int)arg, (int)retval, "set interpolation", validate(&ret, mess, (int)arg, (int)retval, "set interpolation",
DEC); DEC);
LOG(logDEBUG1, ("interpolation retval: %u\n", retval)); LOG(logDEBUG1, ("interpolation retval: %u\n", retval));
} }
} }
@ -10024,16 +10029,18 @@ 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);
if (ret == FAIL) { if (ret == FAIL) {
sprintf(mess, "Could not set pump probe\n"); sprintf(mess, "Could not set pump probe\n");
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));
} }
} }

View File

@ -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 = {});
@ -907,7 +907,7 @@ class Detector {
Result<defs::ROI> getIndividualRxROIs(Positions pos) const; Result<defs::ROI> getIndividualRxROIs(Positions pos) const;
defs::ROI getRxROI() const; defs::ROI getRxROI() const;
/** only at multi module level without gap pixels */ /** only at multi module level without gap pixels */
void setRxROI(const defs::ROI value); void setRxROI(const defs::ROI value);
@ -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] */

View File

@ -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
*/ */
@ -51,7 +62,7 @@ class detectorData {
int databytes; int databytes;
int dynamicRange; int dynamicRange;
bool completeImage; bool completeImage;
std::array<int,4> rxRoi{{-1, -1, -1, -1}}; std::array<int, 4> rxRoi{{-1, -1, -1, -1}};
}; };
} // namespace sls } // namespace sls

View File

@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
// prevent mem size check // prevent mem size check
if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) { if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) {
sls::freeSharedMemory(parser.multi_id()); sls::freeSharedMemory(parser.multi_id());
} }
try { try {
sls::Detector det(parser.multi_id()); sls::Detector det(parser.multi_id());

View File

@ -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,27 +454,29 @@ 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) {
WrongNumberOfParameters(1); WrongNumberOfParameters(1);
} }
det->saveTrimbits(args[0], std::vector<int>{det_id}); det->saveTrimbits(args[0], std::vector<int>{det_id});
os << args << '\n'; os << args << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() != 1) { if (args.size() != 1) {
WrongNumberOfParameters(1); WrongNumberOfParameters(1);
} }
det->loadTrimbits(args[0], std::vector<int>{det_id}); det->loadTrimbits(args[0], std::vector<int>{det_id});
os << args << '\n'; os << args << '\n';
} else { } else {
throw RuntimeError("Unknown action"); throw RuntimeError("Unknown 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";
@ -726,7 +723,7 @@ std::string CmdProxy::Adcphase(int action) {
} else if (args.size() == 2) { } else if (args.size() == 2) {
if (args[1] != "deg") { if (args[1] != "deg") {
throw RuntimeError("Unknown adcphase 2nd argument " + throw RuntimeError("Unknown adcphase 2nd argument " +
args[1] + ". Did you mean deg?"); args[1] + ". Did you mean deg?");
} }
det->setADCPhaseInDegrees(StringTo<int>(args[0]), det->setADCPhaseInDegrees(StringTo<int>(args[0]),
std::vector<int>{det_id}); std::vector<int>{det_id});
@ -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";
@ -780,7 +776,7 @@ std::string CmdProxy::Dbitphase(int action) {
} else if (args.size() == 2) { } else if (args.size() == 2) {
if (args[1] != "deg") { if (args[1] != "deg") {
throw RuntimeError("Unknown dbitphase 2nd argument " + throw RuntimeError("Unknown dbitphase 2nd argument " +
args[1] + ". Did you mean deg? "); args[1] + ". Did you mean deg? ");
} }
det->setDBITPhaseInDegrees(StringTo<int>(args[0]), det->setDBITPhaseInDegrees(StringTo<int>(args[0]),
std::vector<int>{det_id}); std::vector<int>{det_id});
@ -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) {
@ -847,7 +841,7 @@ std::string CmdProxy::ClockPhase(int action) {
} else if (args.size() == 2) { } else if (args.size() == 2) {
if (args[1] != "deg") { if (args[1] != "deg") {
throw RuntimeError("Cannot scan argument" + args[1] + throw RuntimeError("Cannot scan argument" + args[1] +
". Did you mean deg?"); ". Did you mean deg?");
} }
auto t = det->getClockPhaseinDegrees(StringTo<int>(args[0]), auto t = det->getClockPhaseinDegrees(StringTo<int>(args[0]),
{det_id}); {det_id});
@ -864,7 +858,7 @@ std::string CmdProxy::ClockPhase(int action) {
} else if (args.size() == 3) { } else if (args.size() == 3) {
if (args[2] != "deg") { if (args[2] != "deg") {
throw RuntimeError("Cannot scan argument" + args[2] + throw RuntimeError("Cannot scan argument" + args[2] +
". Did you mean deg?"); ". Did you mean deg?");
} }
det->setClockPhaseinDegrees(StringTo<int>(args[0]), det->setClockPhaseinDegrees(StringTo<int>(args[0]),
StringTo<int>(args[1]), StringTo<int>(args[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) {
@ -1010,7 +1003,7 @@ std::string CmdProxy::CurrentSource(int action) {
fix = false; fix = false;
} else { } else {
throw RuntimeError("Invalid argument: " + args[1] + throw RuntimeError("Invalid argument: " + args[1] +
". Did you mean fix or nofix?"); ". Did you mean fix or nofix?");
} }
if (args.size() == 3) { if (args.size() == 3) {
det->setCurrentSource(defs::currentSrcParameters( det->setCurrentSource(defs::currentSrcParameters(
@ -1023,7 +1016,7 @@ std::string CmdProxy::CurrentSource(int action) {
normalCurrent = false; normalCurrent = false;
} else { } else {
throw RuntimeError("Invalid argument: " + args[3] + throw RuntimeError("Invalid argument: " + args[3] +
". Did you mean normal or low?"); ". Did you mean normal or low?");
} }
det->setCurrentSource(defs::currentSrcParameters( det->setCurrentSource(defs::currentSrcParameters(
fix, StringTo<uint64_t>(args[2]), normalCurrent)); fix, StringTo<uint64_t>(args[2]), normalCurrent));
@ -1119,7 +1112,7 @@ std::string CmdProxy::Dac(int action) {
if (args.size() == 2) { if (args.size() == 2) {
if ((args[1] != "mv") && (args[1] != "mV")) { if ((args[1] != "mv") && (args[1] != "mV")) {
throw RuntimeError("Unknown argument " + args[1] + throw RuntimeError("Unknown argument " + args[1] +
". Did you mean mV?"); ". Did you mean mV?");
} }
mV = true; mV = true;
} else if (args.size() > 2) { } else if (args.size() > 2) {
@ -1140,7 +1133,7 @@ std::string CmdProxy::Dac(int action) {
if (args.size() == 3) { if (args.size() == 3) {
if ((args[2] != "mv") && (args[2] != "mV")) { if ((args[2] != "mv") && (args[2] != "mV")) {
throw RuntimeError("Unknown argument " + args[2] + throw RuntimeError("Unknown argument " + args[2] +
". Did you mean mV?"); ". Did you mean mV?");
} }
mV = true; mV = true;
} else if (args.size() > 3 || args.size() < 2) { } else if (args.size() > 3 || args.size() < 2) {
@ -1174,11 +1167,10 @@ std::string CmdProxy::DacList(const int action) {
} else if (action == slsDetectorDefs::PUT_ACTION) { } else if (action == slsDetectorDefs::PUT_ACTION) {
if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) { if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) {
throw RuntimeError("This detector already has fixed dac " throw RuntimeError("This detector already has fixed dac "
"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);
@ -1203,7 +1195,7 @@ std::string CmdProxy::DacValues(int action) {
if (args.size() == 1) { if (args.size() == 1) {
if ((args[0] != "mv") && (args[0] != "mV")) { if ((args[0] != "mv") && (args[0] != "mV")) {
throw RuntimeError("Unknown argument " + args[0] + throw RuntimeError("Unknown argument " + args[0] +
". Did you mean mV?"); ". Did you mean mV?");
} }
mv = true; mv = true;
} else if (args.size() > 1) { } else if (args.size() > 1) {
@ -1248,7 +1240,7 @@ std::string CmdProxy::ResetDacs(int action) {
if (args.size() == 1) { if (args.size() == 1) {
if (args[0] != "hard") { if (args[0] != "hard") {
throw RuntimeError("Unknown argument " + args[0] + throw RuntimeError("Unknown argument " + args[0] +
". Did you mean hard?"); ". Did you mean hard?");
} }
hardReset = true; hardReset = true;
} else if (args.size() > 1) { } else if (args.size() > 1) {
@ -1514,8 +1506,8 @@ std::string CmdProxy::UDPDestinationList(int action) {
} }
if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) { if (rx_id < 0 || rx_id >= MAX_UDP_DESTINATION) {
throw RuntimeError(std::string("Invalid receiver index ") + throw RuntimeError(std::string("Invalid receiver index ") +
std::to_string(rx_id) + std::to_string(rx_id) +
std::string(" to set round robin entry.")); std::string(" to set round robin entry."));
} }
auto t = det->getDestinationUDPList(rx_id, std::vector<int>{det_id}); auto t = det->getDestinationUDPList(rx_id, std::vector<int>{det_id});
os << OutString(t) << '\n'; os << OutString(t) << '\n';
@ -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});
@ -1565,7 +1561,7 @@ std::string CmdProxy::UDPSourceIP(int action) {
} }
det->setSourceUDPIP(val, std::vector<int>{det_id}); det->setSourceUDPIP(val, std::vector<int>{det_id});
os << val << '\n'; os << val << '\n';
} else { } else {
throw RuntimeError("Unknown action"); throw RuntimeError("Unknown action");
} }
@ -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,14 +1591,14 @@ 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]);
} }
det->setSourceUDPIP2(val, std::vector<int>{det_id}); det->setSourceUDPIP2(val, std::vector<int>{det_id});
os << val << '\n'; os << val << '\n';
} else { } else {
throw RuntimeError("Unknown action"); throw RuntimeError("Unknown action");
} }
@ -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()) {
@ -2009,7 +2010,7 @@ std::string CmdProxy::TemperatureEvent(int action) {
} }
if (StringTo<int>(args[0]) != 0) { if (StringTo<int>(args[0]) != 0) {
throw RuntimeError("Unknown argument for temp event. Did you " throw RuntimeError("Unknown argument for temp event. Did you "
"mean 0 to reset event?"); "mean 0 to reset event?");
} }
det->resetTemperatureEvent(std::vector<int>{det_id}); det->resetTemperatureEvent(std::vector<int>{det_id});
os << "cleared" << '\n'; os << "cleared" << '\n';
@ -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,30 +2704,35 @@ 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);
} else if (action == defs::PUT_ACTION && args.size() != nPutArgs) { } else if (action == defs::PUT_ACTION && args.size() != nPutArgs) {
WrongNumberOfParameters(nPutArgs); WrongNumberOfParameters(nPutArgs);
} }
if (cmd == levelSeparatedCommand) { if (cmd == levelSeparatedCommand) {
level = StringTo<int>(args[iArg++]); level = StringTo<int>(args[iArg++]);
} else { } else {
level = cmd[cmd.find_first_of("012")] - '0'; level = cmd[cmd.find_first_of("012")] - '0';
} }
} }
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 << ' ';
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
@ -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 =
@ -2755,11 +2759,11 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
os << OutStringHex(t, 4) << '\n'; os << OutStringHex(t, 4) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
int start = StringTo<int>(args[iArg++]); int start = StringTo<int>(args[iArg++]);
int stop = StringTo<int>(args[iArg++]); int stop = StringTo<int>(args[iArg++]);
det->setPatternLoopAddresses(level, start, stop, det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id}); std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4) os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< "]\n"; << "]\n";
} else { } else {
throw RuntimeError("Unknown action"); throw RuntimeError("Unknown action");
} }
@ -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,23 +2806,25 @@ 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 "
<< "\n\t[Mythen3] Level options: 0-3 only."; "loop level provided."
<< "\n\t[Mythen3] Level options: 0-3 only.";
} else { } else {
os << "Depreciated command. Use patwait."; os << "Depreciated command. Use patwait.";
} }
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,9 +2970,8 @@ 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;
} else if (args.size() != 1) { } else if (args.size() != 1) {

View File

@ -12,7 +12,7 @@
#include <vector> #include <vector>
namespace sls { namespace sls {
/** Macro to make an integer command. /** Macro to make an integer command.
* CMDNAME name of the function that does the command * CMDNAME name of the function that does the command
* GETFCN Detector function to get * GETFCN Detector function to get
@ -55,7 +55,7 @@ namespace sls {
os << args[0] << '\n'; \ os << args[0] << '\n'; \
} \ } \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -77,9 +77,9 @@ namespace sls {
WrongNumberOfParameters(1); \ WrongNumberOfParameters(1); \
} \ } \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
throw RuntimeError("cannot put"); \ throw RuntimeError("cannot put"); \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -104,7 +104,7 @@ namespace sls {
det->SETFCN(args[0], std::vector<int>{det_id}); \ det->SETFCN(args[0], std::vector<int>{det_id}); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -130,7 +130,7 @@ namespace sls {
det->SETFCN(val, std::vector<int>{det_id}); \ det->SETFCN(val, std::vector<int>{det_id}); \
os << ToStringHex(val, 16) << '\n'; \ os << ToStringHex(val, 16) << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -156,7 +156,7 @@ namespace sls {
det->SETFCN(val, std::vector<int>{det_id}); \ det->SETFCN(val, std::vector<int>{det_id}); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -182,7 +182,7 @@ namespace sls {
det->SETFCN(val, std::vector<int>{det_id}); \ det->SETFCN(val, std::vector<int>{det_id}); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -208,7 +208,7 @@ namespace sls {
det->SETFCN(val, det_id); \ det->SETFCN(val, det_id); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -234,7 +234,7 @@ namespace sls {
det->SETFCN(val, det_id); \ det->SETFCN(val, det_id); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -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); \
@ -264,7 +263,7 @@ namespace sls {
det->SETFCN(val); \ det->SETFCN(val); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -275,7 +274,7 @@ namespace sls {
std::ostringstream os; \ std::ostringstream os; \
os << cmd << ' '; \ os << cmd << ' '; \
if (det_id != -1) { \ if (det_id != -1) { \
throw RuntimeError("Cannot execute this at module level"); \ throw RuntimeError("Cannot execute this at module level"); \
} \ } \
if (action == slsDetectorDefs::HELP_ACTION) \ if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \ os << HLPSTR << '\n'; \
@ -293,7 +292,7 @@ namespace sls {
det->SETFCN(val); \ det->SETFCN(val); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -319,7 +318,7 @@ namespace sls {
det->SETFCN(INDEX, val, std::vector<int>{det_id}); \ det->SETFCN(INDEX, val, std::vector<int>{det_id}); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -347,7 +346,7 @@ namespace sls {
std::vector<int>{det_id}); \ std::vector<int>{det_id}); \
os << args[0] << ' ' << args[1] << '\n'; \ os << args[0] << ' ' << args[1] << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -358,12 +357,12 @@ namespace sls {
std::ostringstream os; \ std::ostringstream os; \
os << cmd << ' '; \ os << cmd << ' '; \
if (det_id != -1) { \ if (det_id != -1) { \
throw RuntimeError("Cannot execute this at module level"); \ throw RuntimeError("Cannot execute this at module level"); \
} \ } \
if (action == slsDetectorDefs::HELP_ACTION) \ if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \ os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \ else if (action == slsDetectorDefs::GET_ACTION) { \
throw RuntimeError("Cannot get"); \ throw RuntimeError("Cannot get"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
if (!args.empty()) { \ if (!args.empty()) { \
WrongNumberOfParameters(0); \ WrongNumberOfParameters(0); \
@ -371,7 +370,7 @@ namespace sls {
det->SETFCN(); \ det->SETFCN(); \
os << "successful\n"; \ os << "successful\n"; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -384,7 +383,7 @@ namespace sls {
if (action == slsDetectorDefs::HELP_ACTION) \ if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \ os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \ else if (action == slsDetectorDefs::GET_ACTION) { \
throw RuntimeError("Cannot get"); \ throw RuntimeError("Cannot get"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
if (!args.empty()) { \ if (!args.empty()) { \
WrongNumberOfParameters(0); \ WrongNumberOfParameters(0); \
@ -392,7 +391,7 @@ namespace sls {
det->SETFCN(std::vector<int>{det_id}); \ det->SETFCN(std::vector<int>{det_id}); \
os << "successful\n"; \ os << "successful\n"; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -403,12 +402,12 @@ namespace sls {
std::ostringstream os; \ std::ostringstream os; \
os << cmd << ' '; \ os << cmd << ' '; \
if (det_id != -1) { \ if (det_id != -1) { \
throw RuntimeError("Cannot execute this at module level"); \ throw RuntimeError("Cannot execute this at module level"); \
} \ } \
if (action == slsDetectorDefs::HELP_ACTION) \ if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \ os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \ else if (action == slsDetectorDefs::GET_ACTION) { \
throw RuntimeError("Cannot get"); \ throw RuntimeError("Cannot get"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
if (args.size() != 1) { \ if (args.size() != 1) { \
WrongNumberOfParameters(1); \ WrongNumberOfParameters(1); \
@ -416,7 +415,7 @@ namespace sls {
det->SETFCN(args[0]); \ det->SETFCN(args[0]); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -429,7 +428,7 @@ namespace sls {
if (action == slsDetectorDefs::HELP_ACTION) \ if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \ os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \ else if (action == slsDetectorDefs::GET_ACTION) { \
throw RuntimeError("Cannot get"); \ throw RuntimeError("Cannot get"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
if (args.size() != 1) { \ if (args.size() != 1) { \
WrongNumberOfParameters(1); \ WrongNumberOfParameters(1); \
@ -437,7 +436,7 @@ namespace sls {
det->SETFCN(args[0], std::vector<int>{det_id}); \ det->SETFCN(args[0], std::vector<int>{det_id}); \
os << args.front() << '\n'; \ os << args.front() << '\n'; \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -456,9 +455,9 @@ namespace sls {
auto t = det->GETFCN(std::vector<int>{det_id}); \ auto t = det->GETFCN(std::vector<int>{det_id}); \
os << OutString(t) << '\n'; \ os << OutString(t) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
throw RuntimeError("Cannot put"); \ throw RuntimeError("Cannot put"); \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -475,11 +474,11 @@ namespace sls {
WrongNumberOfParameters(0); \ WrongNumberOfParameters(0); \
} \ } \
auto t = det->GETFCN(); \ auto t = det->GETFCN(); \
os << ToString(t) << '\n'; \ os << ToString(t) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
throw RuntimeError("Cannot put"); \ throw RuntimeError("Cannot put"); \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -498,9 +497,9 @@ namespace sls {
auto t = det->GETFCN(std::vector<int>{det_id}); \ auto t = det->GETFCN(std::vector<int>{det_id}); \
os << OutStringHex(t) << '\n'; \ os << OutStringHex(t) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
throw RuntimeError("Cannot put"); \ throw RuntimeError("Cannot put"); \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -518,9 +517,9 @@ namespace sls {
auto t = det->GETFCN(VAL, std::vector<int>{det_id}); \ auto t = det->GETFCN(VAL, std::vector<int>{det_id}); \
os << OutString(t) << APPEND << '\n'; \ os << OutString(t) << APPEND << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \ } else if (action == slsDetectorDefs::PUT_ACTION) { \
throw RuntimeError("Cannot put"); \ throw RuntimeError("Cannot put"); \
} else { \ } else { \
throw RuntimeError("Unknown action"); \ throw RuntimeError("Unknown action"); \
} \ } \
return os.str(); \ return os.str(); \
} }
@ -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(
"[0, 1]\n\t[Mythen3] Enables or disables pump probe " pumpprobe, getPumpProbe, setPumpProbe, StringTo<int>,
"mode. Default is disabled. Pump probe mode only enables vth2. Disabling sets back to previous value."); "[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.");
INTEGER_COMMAND_VEC_ID(apulse, getAnalogPulsing, setAnalogPulsing, INTEGER_COMMAND_VEC_ID(apulse, getAnalogPulsing, setAnalogPulsing,
StringTo<int>, StringTo<int>,

View File

@ -10,9 +10,9 @@
namespace sls { namespace sls {
CtbConfig::CtbConfig(){ CtbConfig::CtbConfig() {
for (size_t i=0; i!=num_dacs; ++i){ for (size_t i = 0; i != num_dacs; ++i) {
setDacName(i, "dac"+ToString(i)); setDacName(i, "dac" + ToString(i));
} }
} }
@ -25,11 +25,11 @@ void CtbConfig::check_index(size_t i) const {
} }
void CtbConfig::check_size(const std::string &name) const { void CtbConfig::check_size(const std::string &name) const {
if (name.empty()) if (name.empty())
throw RuntimeError("Name needs to be at least one character"); throw RuntimeError("Name needs to be at least one character");
// dacname_length -1 to account for \0 termination // dacname_length -1 to account for \0 termination
if (!(name.size() < (name_length - 1))) { if (!(name.size() < (name_length - 1))) {
std::ostringstream oss; std::ostringstream oss;
oss << "Length of name needs to be less than " << name_length - 1 oss << "Length of name needs to be less than " << name_length - 1
@ -48,8 +48,8 @@ void CtbConfig::setDacName(size_t index, const std::string &name) {
memcpy(dst, &name[0], name.size()); memcpy(dst, &name[0], name.size());
} }
void CtbConfig::setDacNames(const std::vector<std::string>& names){ void CtbConfig::setDacNames(const std::vector<std::string> &names) {
for (size_t i = 0; i!=num_dacs; ++i){ for (size_t i = 0; i != num_dacs; ++i) {
setDacName(i, names[i]); setDacName(i, names[i]);
} }
} }
@ -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

View File

@ -3,11 +3,10 @@
#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;
static constexpr const char* shm_tag_ = "ctbdacs"; static constexpr const char *shm_tag_ = "ctbdacs";
char dacnames[name_length * num_dacs]{}; char dacnames[name_length * num_dacs]{};
void check_index(size_t i) const; void check_index(size_t i) const;
@ -15,17 +14,16 @@ class CtbConfig {
public: public:
CtbConfig(); CtbConfig();
CtbConfig(const CtbConfig&) = default; CtbConfig(const CtbConfig &) = default;
CtbConfig(CtbConfig&&) = default; CtbConfig(CtbConfig &&) = default;
CtbConfig& operator=(const CtbConfig&) = default; CtbConfig &operator=(const CtbConfig &) = default;
~CtbConfig() = default; ~CtbConfig() = default;
void setDacNames(const std::vector<std::string> &names); void setDacNames(const std::vector<std::string> &names);
void setDacName(size_t index, const std::string &name); void setDacName(size_t index, const std::string &name);
std::string getDacName(size_t index) const; std::string getDacName(size_t index) const;
std::vector<std::string> getDacNames() const; std::vector<std::string> getDacNames() const;
static const char* shm_tag(); static const char *shm_tag();
}; };
} // namespace sls } // namespace sls

View File

@ -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;
@ -1795,7 +1794,7 @@ void Detector::setVetoAlgorithm(const defs::vetoAlgorithm alg,
defs::streamingInterface interface, defs::streamingInterface interface,
Positions pos) { Positions pos) {
LOG(logDEBUG) << "alg:" << ToString(alg) LOG(logDEBUG) << "alg:" << ToString(alg)
<< " interface:" << ToString(interface); << " interface:" << ToString(interface);
pimpl->Parallel(&Module::setVetoAlgorithm, pos, alg, interface); pimpl->Parallel(&Module::setVetoAlgorithm, pos, alg, interface);
} }

View File

@ -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);
@ -459,17 +457,17 @@ int DetectorImpl::createReceivingDataSockets() {
try { try {
zmqSocket.push_back( zmqSocket.push_back(
make_unique<ZmqSocket>(modules[iSocket / numUDPInterfaces] make_unique<ZmqSocket>(modules[iSocket / numUDPInterfaces]
->getClientStreamingIP() ->getClientStreamingIP()
.str() .str()
.c_str(), .c_str(),
portnum)); portnum));
// set high water mark // set high water mark
int hwm = shm()->zmqHwm; int hwm = shm()->zmqHwm;
if (hwm >= 0) { if (hwm >= 0) {
zmqSocket[iSocket]->SetReceiveHighWaterMark(hwm); zmqSocket[iSocket]->SetReceiveHighWaterMark(hwm);
if (zmqSocket[iSocket]->GetReceiveHighWaterMark() != hwm) { if (zmqSocket[iSocket]->GetReceiveHighWaterMark() != hwm) {
throw ZmqSocketError("Could not set zmq rcv hwm to " + throw ZmqSocketError("Could not set zmq rcv hwm to " +
std::to_string(hwm)); std::to_string(hwm));
} }
} }
LOG(logINFO) << "Zmq Client[" << iSocket << "] at " LOG(logINFO) << "Zmq Client[" << iSocket << "] at "
@ -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();
@ -1063,7 +1060,7 @@ void DetectorImpl::setClientStreamingHwm(const int limit) {
if (it->GetReceiveHighWaterMark() != limit) { if (it->GetReceiveHighWaterMark() != limit) {
shm()->zmqHwm = -1; shm()->zmqHwm = -1;
throw ZmqSocketError("Could not set zmq rcv hwm to " + throw ZmqSocketError("Could not set zmq rcv hwm to " +
std::to_string(limit)); std::to_string(limit));
} }
} }
LOG(logINFO) << "Setting Client Zmq socket rcv hwm to " << limit; LOG(logINFO) << "Setting Client Zmq socket rcv hwm to " << limit;
@ -1186,10 +1183,10 @@ void DetectorImpl::startAcquisition(bool blocking, std::vector<int> positions) {
std::iota(begin(positions), end(positions), 0); std::iota(begin(positions), end(positions), 0);
} }
// could be all slaves in positions // could be all slaves in positions
slaves.reserve(positions.size()); slaves.reserve(positions.size());
auto is_master = Parallel(&Module::isMaster, positions); auto is_master = Parallel(&Module::isMaster, positions);
for (size_t i : positions) { for (size_t i : positions) {
if (is_master[i]) if (is_master[i])
master.push_back(i); master.push_back(i);
else else
slaves.push_back(i); slaves.push_back(i);
@ -1418,8 +1415,8 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
} }
Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index, Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index,
defs::detectorSettings sett, defs::detectorSettings sett,
Positions pos) { Positions pos) {
return Parallel(&Module::getDefaultDac, pos, index, sett); return Parallel(&Module::getDefaultDac, pos, index, sett);
} }
@ -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
@ -1593,27 +1597,27 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
if (arg.xmin > moduleFullRoi.xmax || if (arg.xmin > moduleFullRoi.xmax ||
arg.xmax < moduleFullRoi.xmin || arg.xmax < moduleFullRoi.xmin ||
(is2D && (arg.ymin > moduleFullRoi.ymax || (is2D && (arg.ymin > moduleFullRoi.ymax ||
arg.ymax < moduleFullRoi.ymin))) { arg.ymax < moduleFullRoi.ymin))) {
moduleRoi.setNoRoi(); moduleRoi.setNoRoi();
} }
// incomplete module roi // incomplete module roi
else if (arg.xmin > moduleFullRoi.xmin || else if (arg.xmin > moduleFullRoi.xmin ||
arg.xmax < moduleFullRoi.xmax || arg.xmax < moduleFullRoi.xmax ||
(is2D && (arg.ymin > moduleFullRoi.ymin || (is2D && (arg.ymin > moduleFullRoi.ymin ||
arg.ymax < moduleFullRoi.ymax))) { arg.ymax < moduleFullRoi.ymax))) {
moduleRoi.xmin = (arg.xmin <= moduleFullRoi.xmin) moduleRoi.xmin = (arg.xmin <= moduleFullRoi.xmin)
? 0 ? 0
: (arg.xmin % numChansPerMod.x); : (arg.xmin % numChansPerMod.x);
moduleRoi.xmax = (arg.xmax >= moduleFullRoi.xmax) moduleRoi.xmax = (arg.xmax >= moduleFullRoi.xmax)
? numChansPerMod.x - 1 ? numChansPerMod.x - 1
: (arg.xmax % numChansPerMod.x); : (arg.xmax % numChansPerMod.x);
if (is2D) { if (is2D) {
moduleRoi.ymin = (arg.ymin <= moduleFullRoi.ymin) moduleRoi.ymin = (arg.ymin <= moduleFullRoi.ymin)
? 0 ? 0
: (arg.ymin % numChansPerMod.y); : (arg.ymin % numChansPerMod.y);
moduleRoi.ymax = (arg.ymax >= moduleFullRoi.ymax) moduleRoi.ymax = (arg.ymax >= moduleFullRoi.ymax)
? numChansPerMod.y - 1 ? numChansPerMod.y - 1
: (arg.ymax % numChansPerMod.y); : (arg.ymax % numChansPerMod.y);
} }
} }
} }
@ -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();
} }

View File

@ -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 {
@ -87,8 +87,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
template <class CT> struct NonDeduced { using type = CT; }; template <class CT> struct NonDeduced { using type = CT; };
template <typename RT, typename... CT> template <typename RT, typename... CT>
Result<RT> Parallel(RT (Module::*somefunc)(CT...), Result<RT> Parallel(RT (Module::*somefunc)(CT...),
std::vector<int> positions, std::vector<int> positions,
typename NonDeduced<CT>::type... Args) { typename NonDeduced<CT>::type... Args) {
if (modules.empty()) if (modules.empty())
throw RuntimeError("No modules added"); throw RuntimeError("No modules added");
@ -115,8 +115,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
template <typename RT, typename... CT> template <typename RT, typename... CT>
Result<RT> Parallel(RT (Module::*somefunc)(CT...) const, Result<RT> Parallel(RT (Module::*somefunc)(CT...) const,
std::vector<int> positions, std::vector<int> positions,
typename NonDeduced<CT>::type... Args) const { typename NonDeduced<CT>::type... Args) const {
if (modules.empty()) if (modules.empty())
throw RuntimeError("No modules added"); throw RuntimeError("No modules added");
@ -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,9 +295,8 @@ 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);
defs::ROI getRxROI() const; defs::ROI getRxROI() const;

View File

@ -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,8 +310,10 @@ 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(
std::to_string(energy[i])); "setAllThresholdEnergy: chip shift register values do not "
"match between files for energy (eV) " +
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,8 +3320,9 @@ 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)
"these have been replaced with 0/200 or 2800/2400."; << "Some dacs were out of range, "
"these have been replaced with 0/200 or 2800/2400.";
} }
} }
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
@ -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,33 +3637,36 @@ 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) {
throw RuntimeError("Could not write settings file: " + fname); throw RuntimeError("Could not write settings file: " + fname);
} }
switch (shm()->detType) { switch (shm()->detType) {
case MYTHEN3: case MYTHEN3:
outfile.write(reinterpret_cast<char *>(&myMod.reg), sizeof(myMod.reg)); outfile.write(reinterpret_cast<char *>(&myMod.reg), sizeof(myMod.reg));
outfile.write(reinterpret_cast<char *>(myMod.dacs), outfile.write(reinterpret_cast<char *>(myMod.dacs),
sizeof(int) * (myMod.ndac)); sizeof(int) * (myMod.ndac));
outfile.write(reinterpret_cast<char *>(myMod.chanregs), outfile.write(reinterpret_cast<char *>(myMod.chanregs),
sizeof(int) * (myMod.nchan)); sizeof(int) * (myMod.nchan));
break; break;
case EIGER: case EIGER:
outfile.write(reinterpret_cast<char *>(myMod.dacs), outfile.write(reinterpret_cast<char *>(myMod.dacs),
sizeof(int) * (myMod.ndac)); sizeof(int) * (myMod.ndac));
outfile.write(reinterpret_cast<char *>(&myMod.iodelay), outfile.write(reinterpret_cast<char *>(&myMod.iodelay),
sizeof(myMod.iodelay)); sizeof(myMod.iodelay));
outfile.write(reinterpret_cast<char *>(&myMod.tau), sizeof(myMod.tau)); outfile.write(reinterpret_cast<char *>(&myMod.tau), sizeof(myMod.tau));
outfile.write(reinterpret_cast<char *>(myMod.chanregs), outfile.write(reinterpret_cast<char *>(myMod.chanregs),
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,

View File

@ -791,22 +791,22 @@ class Module : public virtual slsDetectorDefs {
static const int NIOS_WRITE_TO_FLASH_TIME_KERNEL = 40; static const int NIOS_WRITE_TO_FLASH_TIME_KERNEL = 40;
enum mythen3_DacIndex { enum mythen3_DacIndex {
M_VCASSH, M_VCASSH,
M_VTH2, M_VTH2,
M_VRSHAPER, M_VRSHAPER,
M_VRSHAPER_N, M_VRSHAPER_N,
M_VIPRE_OUT, M_VIPRE_OUT,
M_VTH3, M_VTH3,
M_VTH1, M_VTH1,
M_VICIN, M_VICIN,
M_VCAS, M_VCAS,
M_VRPREAMP, M_VRPREAMP,
M_VCAL_N, M_VCAL_N,
M_VIPRE, M_VIPRE,
M_VISHAPER, M_VISHAPER,
M_VCAL_P, M_VCAL_P,
M_VTRIM, M_VTRIM,
M_VDCSH M_VDCSH
}; };
enum eiger_DacIndex { enum eiger_DacIndex {

View File

@ -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,26 +130,27 @@ 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") {
if (nargs != 3) { if (nargs != 3) {
throw RuntimeError("Invalid arguments for " + throw RuntimeError("Invalid arguments for " +
ToString(args)); ToString(args));
} }
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));
} }
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++]);
@ -160,19 +162,21 @@ void Pattern::load(const std::string &fname) {
if (cmd == "patnloop") { if (cmd == "patnloop") {
if (nargs != 2) { if (nargs != 2) {
throw RuntimeError("Invalid arguments for " + throw RuntimeError("Invalid arguments for " +
ToString(args)); ToString(args));
} }
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));
} }
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" ||
@ -181,19 +185,21 @@ void Pattern::load(const std::string &fname) {
if (cmd == "patwait") { if (cmd == "patwait") {
if (nargs != 2) { if (nargs != 2) {
throw RuntimeError("Invalid arguments for " + throw RuntimeError("Invalid arguments for " +
ToString(args)); ToString(args));
} }
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));
} }
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" ||
@ -202,19 +208,21 @@ void Pattern::load(const std::string &fname) {
if (cmd == "patwaittime") { if (cmd == "patwaittime") {
if (nargs != 2) { if (nargs != 2) {
throw RuntimeError("Invalid arguments for " + throw RuntimeError("Invalid arguments for " +
ToString(args)); ToString(args));
} }
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));
} }
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;
} }

View File

@ -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 <cerrno> // errno
#include <cstdlib> #include <cstdlib>
#include <cerrno> // errno
#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 {

View File

@ -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

View File

@ -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,23 +571,38 @@ 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})
// interpolation and pump probe .tsquash("inconsistent vth2 dac value") ==
fixedVthDacVal);
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
.tsquash("inconsistent vth2 dac value") ==
disabledDacValue);
}
// interpolation and pump probe
REQUIRE_THROWS(proxy.Call("interpolation", {"1"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("interpolation", {"1"}, -1, PUT));
{ {
// none // none
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;

View File

@ -170,12 +170,12 @@ TEST_CASE("patloop", "[.cmd]") {
std::string sLoop = ToString(iLoop); std::string sLoop = ToString(iLoop);
if (iLoop < 3) { if (iLoop < 3) {
std::string deprecatedCmd = "patloop" + sLoop; std::string deprecatedCmd = "patloop" + sLoop;
{// depreciated { // depreciated
std::ostringstream oss; std::ostringstream oss;
proxy.Call(deprecatedCmd, {"0x20", "0x5c"}, -1, PUT, oss); proxy.Call(deprecatedCmd, {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n"); REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n");
} }
{// depreciated { // depreciated
std::ostringstream oss; std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss); proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n"); REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n");
@ -190,9 +190,10 @@ TEST_CASE("patloop", "[.cmd]") {
std::ostringstream oss; std::ostringstream oss;
proxy.Call("patloop", {sLoop}, -1, GET, oss); proxy.Call("patloop", {sLoop}, -1, GET, oss);
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 {
@ -216,12 +217,12 @@ TEST_CASE("patnloop", "[.cmd]") {
std::string sLoop = ToString(iLoop); std::string sLoop = ToString(iLoop);
if (iLoop < 3) { if (iLoop < 3) {
std::string deprecatedCmd = "patnloop" + sLoop; std::string deprecatedCmd = "patnloop" + sLoop;
{// depreciated { // depreciated
std::ostringstream oss; std::ostringstream oss;
proxy.Call(deprecatedCmd, {"5"}, -1, PUT, oss); proxy.Call(deprecatedCmd, {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 5\n"); REQUIRE(oss.str() == deprecatedCmd + " 5\n");
} }
{// depreciated { // depreciated
std::ostringstream oss; std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss); proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 5\n"); REQUIRE(oss.str() == deprecatedCmd + " 5\n");
@ -262,12 +263,12 @@ TEST_CASE("patwait", "[.cmd]") {
std::string sLoop = ToString(iLoop); std::string sLoop = ToString(iLoop);
if (iLoop < 3) { if (iLoop < 3) {
std::string deprecatedCmd = "patwait" + sLoop; std::string deprecatedCmd = "patwait" + sLoop;
{// depreciated { // depreciated
std::ostringstream oss; std::ostringstream oss;
proxy.Call(deprecatedCmd, {"0x5c"}, -1, PUT, oss); proxy.Call(deprecatedCmd, {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n"); REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n");
} }
{// depreciated { // depreciated
std::ostringstream oss; std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss); proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n"); REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n");
@ -308,12 +309,12 @@ TEST_CASE("patwaittime", "[.cmd]") {
std::string sLoop = ToString(iLoop); std::string sLoop = ToString(iLoop);
if (iLoop < 3) { if (iLoop < 3) {
std::string deprecatedCmd = "patwaittime" + sLoop; std::string deprecatedCmd = "patwaittime" + sLoop;
{// depreciated { // depreciated
std::ostringstream oss; std::ostringstream oss;
proxy.Call(deprecatedCmd, {"8589936640"}, -1, PUT, oss); proxy.Call(deprecatedCmd, {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n"); REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n");
} }
{// depreciated { // depreciated
std::ostringstream oss; std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss); proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n"); REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n");

View File

@ -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)},
REQUIRE_THROWS(proxy.Call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT)); -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));
} }
for (int i = 0; i != det.size(); ++i) { for (int i = 0; i != det.size(); ++i) {
@ -574,7 +583,7 @@ TEST_CASE("fname", "[.cmd]") {
} }
REQUIRE_THROWS(proxy.Call("fname", {"fdf/dfd"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("fname", {"fdf/dfd"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("fname", {"fdf dfd"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("fname", {"fdf dfd"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) { for (int i = 0; i != det.size(); ++i) {
det.setFileNamePrefix(prev_val[i], {i}); det.setFileNamePrefix(prev_val[i], {i});
} }

View File

@ -16,15 +16,14 @@ namespace sls {
using test::GET; using test::GET;
using test::PUT; using test::PUT;
TEST_CASE("Calling help doesn't throw or cause segfault"){ TEST_CASE("Calling help doesn't throw or cause segfault") {
//Dont add [.cmd] tag this should run with normal tests // Dont add [.cmd] tag this should run with normal tests
CmdProxy proxy(nullptr); CmdProxy proxy(nullptr);
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,9 +337,8 @@ 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) {
{ {

View File

@ -3,14 +3,14 @@
#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 {
TEST_CASE("Default construction"){ TEST_CASE("Default construction") {
static_assert(sizeof(CtbConfig) == 360); // 18*20 static_assert(sizeof(CtbConfig) == 360); // 18*20
CtbConfig c; CtbConfig c;
auto names = c.getDacNames(); auto names = c.getDacNames();
@ -21,7 +21,7 @@ TEST_CASE("Default construction"){
REQUIRE(names[3] == "dac3"); REQUIRE(names[3] == "dac3");
} }
TEST_CASE("Set and get a single dac name"){ TEST_CASE("Set and get a single dac name") {
CtbConfig c; CtbConfig c;
c.setDacName(3, "vrf"); c.setDacName(3, "vrf");
auto names = c.getDacNames(); auto names = c.getDacNames();
@ -30,28 +30,28 @@ TEST_CASE("Set and get a single dac name"){
REQUIRE(names[3] == "vrf"); REQUIRE(names[3] == "vrf");
} }
TEST_CASE("Set a name that is too large throws"){ TEST_CASE("Set a name that is too large throws") {
CtbConfig c; CtbConfig c;
REQUIRE_THROWS(c.setDacName(3, "somestringthatisreallytolongforadatac")); REQUIRE_THROWS(c.setDacName(3, "somestringthatisreallytolongforadatac"));
} }
TEST_CASE("Length of dac name cannot be 0"){ TEST_CASE("Length of dac name cannot be 0") {
CtbConfig c; CtbConfig c;
REQUIRE_THROWS(c.setDacName(1, "")); REQUIRE_THROWS(c.setDacName(1, ""));
} }
TEST_CASE("Copy a CTB config"){ TEST_CASE("Copy a CTB config") {
CtbConfig c1; CtbConfig c1;
c1.setDacName(5, "somename"); c1.setDacName(5, "somename");
auto c2 = c1; auto c2 = c1;
//change the name on the first object // change the name on the first object
//to detecto shallow copy // to detecto shallow copy
c1.setDacName(5, "someothername"); c1.setDacName(5, "someothername");
REQUIRE(c2.getDacName(5) == "somename"); REQUIRE(c2.getDacName(5) == "somename");
} }
TEST_CASE("Move CtbConfig "){ TEST_CASE("Move CtbConfig ") {
CtbConfig c1; CtbConfig c1;
c1.setDacName(3, "yetanothername"); c1.setDacName(3, "yetanothername");
CtbConfig c2(std::move(c1)); CtbConfig c2(std::move(c1));

View File

@ -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!
@ -132,13 +131,12 @@ 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") {
// if SLSDETNAME is already set we unset it but // if SLSDETNAME is already set we unset it but
// save the value // save the value
@ -156,10 +154,9 @@ 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") {
SharedMemory<int32_t> shm(shm_id, -1); SharedMemory<int32_t> shm(shm_id, -1);
shm.createSharedMemory(); shm.createSharedMemory();
*shm() = 7; *shm() = 7;

View File

@ -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);
@ -66,9 +66,9 @@ class Receiver : private virtual slsDetectorDefs {
* args to raw data ready callback are: * args to raw data ready callback are:
* - sls_receiver_header frame metadata, * - sls_receiver_header frame metadata,
* - 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);

View File

@ -19,8 +19,8 @@ void Arping::SetInterfacesAndIps(const int index, const std::string &interface,
if (interface.empty() || ip.empty()) { if (interface.empty() || ip.empty()) {
throw RuntimeError("Could not arping. Interface name and ip not " throw RuntimeError("Could not arping. Interface name and ip not "
"set up for interface " + "set up for interface " +
std::to_string(index)); std::to_string(index));
} }
// create commands to arping // create commands to arping
std::ostringstream os; std::ostringstream os;

View File

@ -37,4 +37,3 @@ class Arping {
}; };
} // namespace sls } // namespace sls

View File

@ -19,10 +19,12 @@ void BinaryDataFile::CloseFile() {
fd = nullptr; fd = nullptr;
} }
void BinaryDataFile::CreateFirstBinaryDataFile( void BinaryDataFile::CreateFirstBinaryDataFile(const std::string &fNamePrefix,
const std::string& fNamePrefix, const uint64_t fIndex,
const uint64_t fIndex, const bool ovEnable, const bool sMode, const bool ovEnable,
const uint32_t uPortNumber, const uint32_t mFramesPerFile) { const bool sMode,
const uint32_t uPortNumber,
const uint32_t mFramesPerFile) {
subFileIndex = 0; subFileIndex = 0;
numFramesInFile = 0; numFramesInFile = 0;
@ -41,15 +43,13 @@ void BinaryDataFile::CreateFile() {
numFramesInFile = 0; numFramesInFile = 0;
std::ostringstream os; std::ostringstream os;
os << fileNamePrefix << "_f" << subFileIndex os << fileNamePrefix << "_f" << subFileIndex << '_' << fileIndex << ".raw";
<< '_' << fileIndex << ".raw";
fileName = os.str(); fileName = os.str();
if (!overWriteEnable) { if (!overWriteEnable) {
if (nullptr == (fd = fopen(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(fileName.c_str(), "w"))) { } else if (nullptr == (fd = fopen(fileName.c_str(), "w"))) {
fd = nullptr; fd = nullptr;
@ -64,7 +64,10 @@ void BinaryDataFile::CreateFile() {
} }
} }
void BinaryDataFile::WriteToFile(char *imageData, sls_receiver_header& header, const int imageSize, const uint64_t currentFrameNumber, const uint32_t numPacketsCaught) { void BinaryDataFile::WriteToFile(char *imageData, sls_receiver_header &header,
const int imageSize,
const uint64_t currentFrameNumber,
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();
@ -101,7 +104,12 @@ void BinaryDataFile::WriteToFile(char *imageData, sls_receiver_header& header, c
// if write error // if write error
if (ret != imageSize + sizeof(sls_receiver_header)) { if (ret != imageSize + sizeof(sls_receiver_header)) {
throw RuntimeError(std::to_string(index) + " : Write to file failed for image number " + std::to_string(currentFrameNumber) + ". Wrote " + std::to_string(ret) + " bytes instead of " + std::to_string(imageSize + sizeof(sls_receiver_header))); throw RuntimeError(
std::to_string(index) +
" : Write to file failed for image number " +
std::to_string(currentFrameNumber) + ". Wrote " +
std::to_string(ret) + " bytes instead of " +
std::to_string(imageSize + sizeof(sls_receiver_header)));
} }
} }

View File

@ -14,14 +14,14 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File {
fileFormat GetFileFormat() const override; fileFormat GetFileFormat() const override;
void CloseFile() override; void CloseFile() override;
void CreateFirstBinaryDataFile(const std::string& fNamePrefix, void CreateFirstBinaryDataFile(const std::string &fNamePrefix,
const uint64_t fIndex, const uint64_t fIndex, const bool ovEnable,
const bool ovEnable, const bool sMode, const uint32_t uPortNumber,
const bool sMode,
const uint32_t uPortNumber,
const uint32_t mFramesPerFile) override; const uint32_t mFramesPerFile) override;
void WriteToFile(char *imageData, sls_receiver_header& header, const int imageSize, const uint64_t currentFrameNumber, const uint32_t numPacketsCaught) override; void WriteToFile(char *imageData, sls_receiver_header &header,
const int imageSize, const uint64_t currentFrameNumber,
const uint32_t numPacketsCaught) override;
private: private:
void CreateFile(); void CreateFile();

View File

@ -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 greater than 0."); throw RuntimeError(
"Receiver socket buffer size must be greater than 0.");
} }
if (size > 0) { if (size > 0) {
verifyIdle(socket); verifyIdle(socket);

View File

@ -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);
@ -43,12 +44,12 @@ class ClientInterface : private virtual slsDetectorDefs {
void *arg); void *arg);
/** params: sls_receiver_header, 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 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};

View File

@ -28,8 +28,7 @@ namespace sls {
const std::string DataProcessor::typeName = "DataProcessor"; const std::string DataProcessor::typeName = "DataProcessor";
DataProcessor::DataProcessor(int index) DataProcessor::DataProcessor(int index) : ThreadObject(index, typeName) {
: ThreadObject(index, typeName) {
LOG(logDEBUG) << "DataProcessor " << index << " created"; LOG(logDEBUG) << "DataProcessor " << index << " created";
} }
@ -40,41 +39,39 @@ bool DataProcessor::GetStartedFlag() const { return startedFlag; }
void DataProcessor::SetFifo(Fifo *f) { fifo = f; } void DataProcessor::SetFifo(Fifo *f) { fifo = f; }
void DataProcessor::SetGeneralData(GeneralData *g) { void DataProcessor::SetGeneralData(GeneralData *g) { generalData = g; }
generalData = g;
}
void DataProcessor::SetActivate(bool enable) { activated = enable; } 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::SetDataStreamEnable(bool enable) {
dataStreamEnable = enable;
}
void DataProcessor::SetStreamingFrequency(uint32_t value) { void DataProcessor::SetStreamingFrequency(uint32_t value) {
streamingFrequency = value; streamingFrequency = value;
} }
void DataProcessor::SetStreamingTimerInMs(uint32_t value) { void DataProcessor::SetStreamingTimerInMs(uint32_t value) {
streamingTimerInMs = value; streamingTimerInMs = value;
} }
void DataProcessor::SetStreamingStartFnum(uint32_t value) { void DataProcessor::SetStreamingStartFnum(uint32_t value) {
streamingStartFnum = value; streamingStartFnum = value;
} }
void DataProcessor::SetFramePadding(bool enable) { framePadding = enable; } void DataProcessor::SetFramePadding(bool enable) { framePadding = enable; }
void DataProcessor::SetCtbDbitList(std::vector<int> value) { void DataProcessor::SetCtbDbitList(std::vector<int> value) {
ctbDbitList = value; ctbDbitList = value;
} }
void DataProcessor::SetCtbDbitOffset(int value) { void DataProcessor::SetCtbDbitOffset(int value) { ctbDbitOffset = value; }
ctbDbitOffset = value;
}
void DataProcessor::ResetParametersforNewAcquisition() { void DataProcessor::ResetParametersforNewAcquisition() {
StopRunning(); StopRunning();
@ -84,7 +81,8 @@ void DataProcessor::ResetParametersforNewAcquisition() {
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) {
@ -120,18 +118,18 @@ void DataProcessor::SetupFileWriter(const bool filewriteEnable,
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 &fileNamePrefix, const uint64_t fileIndex,
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, const bool overWriteEnable,
const uint32_t udpPortNumber, const bool silentMode,
const uint64_t numImages, const uint32_t udpPortNumber,
const bool detectorDataStream) { const uint64_t numImages,
const bool detectorDataStream) {
if (dataFile == nullptr) { if (dataFile == nullptr) {
throw RuntimeError("file object not contstructed"); throw RuntimeError("file object not contstructed");
} }
@ -158,8 +156,8 @@ void DataProcessor::CreateFirstFiles(
case HDF5: case HDF5:
dataFile->CreateFirstHDF5DataFile( dataFile->CreateFirstHDF5DataFile(
fileNamePrefix, fileIndex, overWriteEnable, silentMode, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
udpPortNumber, generalData->framesPerFile, udpPortNumber, generalData->framesPerFile, numImages, nx, ny,
numImages, nx, ny, generalData->dynamicRange); generalData->dynamicRange);
break; break;
#endif #endif
case BINARY: case BINARY:
@ -176,7 +174,7 @@ void DataProcessor::CreateFirstFiles(
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();
} }
@ -184,22 +182,22 @@ uint32_t DataProcessor::GetFilesInAcquisition() const {
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 modulePos, const uint64_t numImages, const int numModX,
const uint64_t numImages, const int numModY, std::mutex *hdf5LibMutex) {
const int numModX, const int numModY,
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 ||
((generalData->detType == GOTTHARD || generalData->detType == GOTTHARD2) && generalData->detType == GOTTHARD2) &&
(numModX * numModY) == 2); (numModX * numModY) == 2);
// 0 for infinite files // 0 for infinite files
uint32_t framesPerFile = uint32_t framesPerFile =
((generalData->framesPerFile == 0) ? numFramesCaught : generalData->framesPerFile); ((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
@ -207,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, generalData->numUDPInterfaces, framesPerFile, modulePos, generalData->numUDPInterfaces, framesPerFile,
generalData->nPixelsX, generalData->nPixelsY, generalData->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);
} }
@ -220,7 +218,8 @@ void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
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
@ -266,14 +265,16 @@ void DataProcessor::ThreadExecution() {
auto *memImage = reinterpret_cast<image_structure *>(buffer); auto *memImage = reinterpret_cast<image_structure *>(buffer);
// check dummy // check dummy
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << memImage->size; LOG(logDEBUG1) << "DataProcessor " << index
<< ", Numbytes:" << memImage->size;
if (memImage->size == DUMMY_PACKET_VALUE) { if (memImage->size == DUMMY_PACKET_VALUE) {
StopProcessing(buffer); StopProcessing(buffer);
return; return;
} }
try { try {
ProcessAnImage(memImage->header, memImage->size, memImage->firstIndex, memImage->data); 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;
@ -284,7 +285,8 @@ void DataProcessor::ThreadExecution() {
// copy the complete image back if roi enabled // copy the complete image back if roi enabled
if (receiverRoiEnabled) { if (receiverRoiEnabled) {
memImage->size = generalData->imageSize; memImage->size = generalData->imageSize;
memcpy(memImage->data, &completeImageToStreamBeforeCropping[0], generalData->imageSize); memcpy(memImage->data, &completeImageToStreamBeforeCropping[0],
generalData->imageSize);
} }
fifo->PushAddressToStream(buffer); fifo->PushAddressToStream(buffer);
} else { } else {
@ -306,7 +308,8 @@ void DataProcessor::StopProcessing(char *buf) {
LOG(logDEBUG1) << index << ": Processing Completed"; LOG(logDEBUG1) << index << ": Processing Completed";
} }
void DataProcessor::ProcessAnImage(sls_receiver_header & header, size_t &size, size_t &firstImageIndex, char* data) { void DataProcessor::ProcessAnImage(sls_receiver_header &header, size_t &size,
size_t &firstImageIndex, char *data) {
uint64_t fnum = header.detHeader.frameNumber; uint64_t fnum = header.detHeader.frameNumber;
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum; LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
currentFrameIndex = fnum; currentFrameIndex = fnum;
@ -335,7 +338,7 @@ void DataProcessor::ProcessAnImage(sls_receiver_header & header, size_t &size, s
RearrangeDbitData(size, data); 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 (firstStreamerFrame) { if (firstStreamerFrame) {
@ -348,11 +351,11 @@ void DataProcessor::ProcessAnImage(sls_receiver_header & header, size_t &size, s
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], data, generalData->imageSize); memcpy(&completeImageToStreamBeforeCropping[0], data,
generalData->imageSize);
} }
CropImage(size, data); CropImage(size, data);
} }
@ -368,8 +371,7 @@ void DataProcessor::ProcessAnImage(sls_receiver_header & header, size_t &size, s
rawDataModifyReadyCallBack(header, data, size, pRawDataReady); rawDataModifyReadyCallBack(header, data, size, pRawDataReady);
} }
} 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
@ -425,18 +427,18 @@ bool DataProcessor::CheckCount() {
} }
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(sls_receiver_header header, char* data) { 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;
@ -493,7 +495,7 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char* data) {
} }
/** ctb specific */ /** ctb specific */
void DataProcessor::RearrangeDbitData(size_t & size, char *data) { void DataProcessor::RearrangeDbitData(size_t &size, char *data) {
int nAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes(); int nAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
// TODO! (Erik) Refactor and add tests // TODO! (Erik) Refactor and add tests
int ctbDigitalDataBytes = size - nAnalogDataBytes - ctbDbitOffset; int ctbDigitalDataBytes = size - nAnalogDataBytes - ctbDbitOffset;
@ -508,8 +510,7 @@ void DataProcessor::RearrangeDbitData(size_t & size, char *data) {
const int numSamples = (ctbDigitalDataBytes / sizeof(uint64_t)); const int numSamples = (ctbDigitalDataBytes / sizeof(uint64_t));
// 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];
@ -539,11 +540,12 @@ void DataProcessor::RearrangeDbitData(size_t & size, char *data) {
} }
// copy back to memory and update size // copy back to memory and update size
memcpy(data + nAnalogDataBytes, result.data(), numResult8Bits * sizeof(uint8_t)); memcpy(data + nAnalogDataBytes, result.data(),
numResult8Bits * sizeof(uint8_t));
size = numResult8Bits * sizeof(uint8_t); size = numResult8Bits * sizeof(uint8_t);
} }
void DataProcessor::CropImage(size_t & size, char *data) { 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;

View File

@ -56,18 +56,18 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
void CreateFirstFiles(const std::string &fileNamePrefix, void CreateFirstFiles(const std::string &fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable, const uint64_t fileIndex, const bool overWriteEnable,
const bool silentMode, const bool silentMode, const uint32_t udpPortNumber,
const uint32_t udpPortNumber,
const uint64_t numImages, const uint64_t numImages,
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 silentMode, const int modulePos, const bool overWriteEnable,
const uint64_t numImages, const int numModX, const int numModY, const bool silentMode, const int modulePos,
std::mutex *hdf5LibMutex); const uint64_t numImages, const int numModX,
const int numModY, 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,10 +82,16 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
std::mutex *hdf5LibMutex); std::mutex *hdf5LibMutex);
/** params: sls_receiver_header, pointer to data, image size */ /** params: sls_receiver_header, pointer to data, image size */
void registerCallBackRawDataReady(void (*func)(sls_receiver_header&, char *, size_t, void *), void *arg); void registerCallBackRawDataReady(void (*func)(sls_receiver_header &,
char *, size_t, void *),
void *arg);
/** params: sls_receiver_header, 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&, char *, size_t &, void *), void *arg); void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header &,
char *, size_t &,
void *),
void *arg);
private: private:
void RecordFirstIndex(uint64_t fnum); void RecordFirstIndex(uint64_t fnum);
@ -106,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(sls_receiver_header & header, size_t &size, size_t &firstImageIndex, char* data); 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
@ -129,15 +136,15 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
*/ */
bool CheckCount(); bool CheckCount();
void PadMissingPackets(sls_receiver_header header, char* data); 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(size_t & size, char *data); void RearrangeDbitData(size_t &size, char *data);
void CropImage(size_t & size, char *data); void CropImage(size_t &size, char *data);
static const std::string typeName; static const std::string typeName;
@ -182,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;
/** /**
@ -193,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};

View File

@ -31,14 +31,12 @@ void DataStreamer::SetFifo(Fifo *f) { fifo = f; }
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; } void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
void DataStreamer::SetFileIndex(uint64_t value) { void DataStreamer::SetFileIndex(uint64_t value) { fileIndex = value; }
fileIndex = value;
}
void DataStreamer::SetNumberofPorts(xy np) { numPorts = np; } void DataStreamer::SetNumberofPorts(xy np) { numPorts = np; }
void DataStreamer::SetFlipRows(bool fd) { void DataStreamer::SetFlipRows(bool fd) {
flipRows = fd; flipRows = fd;
// flip only right port of quad // flip only right port of quad
if (quadEnable) { if (quadEnable) {
flipRows = (index == 1 ? true : false); flipRows = (index == 1 ? true : false);
@ -68,8 +66,10 @@ void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
delete[] completeBuffer; delete[] completeBuffer;
completeBuffer = nullptr; completeBuffer = nullptr;
} }
if (generalData->detType == GOTTHARD && generalData->detectorRoi.xmin != -1) { if (generalData->detType == GOTTHARD &&
adcConfigured = generalData->GetAdcConfigured(index, generalData->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);
} }
@ -82,8 +82,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, size_t firstImageIndex) {
<< ", First Streamer Index:" << fnum; << ", First Streamer Index:" << fnum;
} }
void DataStreamer::CreateZmqSockets(uint32_t port, void DataStreamer::CreateZmqSockets(uint32_t port, const IpAddr ip, int hwm) {
const IpAddr ip, int hwm) {
uint32_t portnum = port + index; uint32_t portnum = port + index;
std::string sip = ip.str(); std::string sip = ip.str();
try { try {
@ -117,12 +116,13 @@ 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 << ", pop 0x" LOG(logDEBUG5) << "DataStreamer " << index << ", pop 0x" << std::hex
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer; << (void *)(buffer) << std::dec << ":" << buffer;
auto *memImage = reinterpret_cast<image_structure *>(buffer); auto *memImage = reinterpret_cast<image_structure *>(buffer);
// check dummy // check dummy
LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << memImage->size ; LOG(logDEBUG1) << "DataStreamer " << index
<< ", Numbytes:" << memImage->size;
if (memImage->size == DUMMY_PACKET_VALUE) { if (memImage->size == DUMMY_PACKET_VALUE) {
StopProcessing(buffer); StopProcessing(buffer);
return; return;
@ -130,7 +130,8 @@ void DataStreamer::ThreadExecution() {
// streamer first index needn't be the very first index // streamer first index needn't be the very first index
if (!startedFlag) { if (!startedFlag) {
RecordFirstIndex(memImage->header.detHeader.frameNumber, memImage->firstIndex); RecordFirstIndex(memImage->header.detHeader.frameNumber,
memImage->firstIndex);
} }
ProcessAnImage(memImage->header.detHeader, memImage->size, memImage->data); ProcessAnImage(memImage->header.detHeader, memImage->size, memImage->data);
@ -142,8 +143,9 @@ 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()) { if (!SendDummyHeader()) {
LOG(logERROR) << "Could not send zmq dummy header for streamer for port " LOG(logERROR)
<< zmqSocket->GetPortNumber(); << "Could not send zmq dummy header for streamer for port "
<< zmqSocket->GetPortNumber();
} }
fifo->FreeAddress(buf); fifo->FreeAddress(buf);
@ -152,26 +154,29 @@ void DataStreamer::StopProcessing(char *buf) {
} }
/** buf includes only the standard header */ /** buf includes only the standard header */
void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size, char* data) { void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size,
char *data) {
uint64_t fnum = header.frameNumber; uint64_t fnum = header.frameNumber;
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum; LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
// 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 instead of size because gui needs // imageSizeComplete instead of size because gui needs
// imagesizecomplete and listener writes imagesize to size // imagesizecomplete and listener writes imagesize to size
if (!SendDataHeader(header, generalData->imageSizeComplete, if (!SendDataHeader(header, generalData->imageSizeComplete,
generalData->nPixelsXComplete, generalData->nPixelsYComplete)) { generalData->nPixelsXComplete,
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),
data, size); data, size);
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) { if (!zmqSocket->SendData(completeBuffer,
generalData->imageSizeComplete)) {
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;
} }
@ -180,7 +185,8 @@ void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size, char*
// normal // normal
else { else {
if (!SendDataHeader(header, size, generalData->nPixelsX, generalData->nPixelsY)) { if (!SendDataHeader(header, size, generalData->nPixelsX,
generalData->nPixelsY)) {
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;
} }
@ -199,7 +205,7 @@ int DataStreamer::SendDummyHeader() {
} }
int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size, int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
uint32_t nx, uint32_t ny) { uint32_t nx, uint32_t ny) {
zmqHeader zHeader; zmqHeader zHeader;
zHeader.data = true; zHeader.data = true;
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION; zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
@ -250,9 +256,8 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
void DataStreamer::RestreamStop() { void DataStreamer::RestreamStop() {
if (!SendDummyHeader()) { if (!SendDummyHeader()) {
throw RuntimeError( throw RuntimeError("Could not restream Dummy Header via ZMQ for port " +
"Could not restream Dummy Header via ZMQ for port " + std::to_string(zmqSocket->GetPortNumber()));
std::to_string(zmqSocket->GetPortNumber()));
} }
} }

View File

@ -47,8 +47,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param ip streaming source ip * @param ip streaming source ip
* @param hwm streaming high water mark * @param hwm streaming high water mark
*/ */
void CreateZmqSockets(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();
@ -57,7 +56,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* Record First Index * Record First Index
*/ */
void RecordFirstIndex(uint64_t fnum, size_t firstImageIndex); void RecordFirstIndex(uint64_t fnum, size_t firstImageIndex);
void ThreadExecution(); void ThreadExecution();
/** /**
@ -70,10 +69,10 @@ 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(sls_detector_header header, size_t size, char* data); void ProcessAnImage(sls_detector_header header, size_t size, char *data);
int SendDummyHeader(); int SendDummyHeader();
/** /**
* Create and send Json Header * Create and send Json Header
* @param rheader header of image * @param rheader header of image
@ -83,8 +82,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @returns 0 if error, else 1 * @returns 0 if error, else 1
*/ */
int SendDataHeader(sls_detector_header header, uint32_t size = 0, int SendDataHeader(sls_detector_header header, uint32_t size = 0,
uint32_t nx = 0, uint32_t ny = 0); 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};

View File

@ -23,7 +23,7 @@ class Fifo : private virtual slsDetectorDefs {
public: public:
Fifo(int index, size_t fifoItemSize, uint32_t fifoDepth); Fifo(int index, size_t fifoItemSize, uint32_t fifoDepth);
~Fifo(); ~Fifo();
void FreeAddress(char *&address); void FreeAddress(char *&address);
void GetNewAddress(char *&address); void GetNewAddress(char *&address);
@ -36,7 +36,7 @@ class Fifo : private virtual slsDetectorDefs {
int GetMaxLevelForFifoBound(); int GetMaxLevelForFifoBound();
int GetMinLevelForFifoFree(); int GetMinLevelForFifoFree();
private: private:
/** also allocate memory & push addresses into free fifo */ /** also allocate memory & push addresses into free fifo */
void CreateFifos(size_t fifoItemSize); void CreateFifos(size_t fifoItemSize);
@ -54,4 +54,3 @@ class Fifo : private virtual slsDetectorDefs {
}; };
} // namespace sls } // namespace sls

View File

@ -26,9 +26,8 @@ class File : private virtual slsDetectorDefs {
#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,9 +45,8 @@ 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,26 +58,31 @@ class File : private virtual slsDetectorDefs {
}; };
virtual void CreateFirstHDF5DataFile( virtual void CreateFirstHDF5DataFile(
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 uint32_t udpPortNumber, const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
const uint32_t maxFramesPerFile, const uint64_t numImages, const uint64_t numImages, const uint32_t nPixelsX,
const uint32_t nPixelsX, const uint32_t nPixelsY, const uint32_t nPixelsY, const uint32_t dynamicRange) {
const uint32_t dynamicRange) { LOG(logERROR)
LOG(logERROR) << "This is a generic function CreateFirstHDF5DataFile that " << "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& fileNamePrefix, const uint64_t fileIndex,
const uint64_t fileIndex, const bool overWriteEnable, const bool overWriteEnable,
const bool silentMode, const uint32_t udpPortNumber, const bool silentMode,
const uint32_t maxFramesPerFile) { const uint32_t udpPortNumber,
LOG(logERROR) << "This is a generic function CreateFirstBinaryDataFile that " const uint32_t maxFramesPerFile) {
"should be overloaded by a derived class"; LOG(logERROR)
<< "This is a generic function CreateFirstBinaryDataFile that "
"should be overloaded by a derived class";
}; };
virtual void WriteToFile(char *imageData, sls_receiver_header& header, const int imageSize, const uint64_t currentFrameNumber,const uint32_t numPacketsCaught) = 0; virtual void WriteToFile(char *imageData, sls_receiver_header &header,
const int imageSize,
const uint64_t currentFrameNumber,
const uint32_t numPacketsCaught) = 0;
}; };
} // namespace sls } // namespace sls

View File

@ -386,7 +386,7 @@ class Mythen3Data : public GeneralData {
int n = __builtin_popcount(mask); int n = __builtin_popcount(mask);
if (n < 1 || n > 3) { if (n < 1 || n > 3) {
throw RuntimeError("Invalid number of counters " + throw RuntimeError("Invalid number of counters " +
std::to_string(n) + ". Expected 1-3."); std::to_string(n) + ". Expected 1-3.");
} }
counterMask = mask; counterMask = mask;
ncounters = n; ncounters = n;

View File

@ -28,18 +28,18 @@ HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
}; };
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;
@ -54,9 +54,7 @@ std::vector<H5::DataType> HDF5DataFile::GetParameterDataTypes() const {
return parameterDataTypes; return parameterDataTypes;
} }
slsDetectorDefs::fileFormat HDF5DataFile::GetFileFormat() const { slsDetectorDefs::fileFormat HDF5DataFile::GetFileFormat() const { return HDF5; }
return HDF5;
}
void HDF5DataFile::CloseFile() { void HDF5DataFile::CloseFile() {
std::lock_guard<std::mutex> lock(*hdf5Lib); std::lock_guard<std::mutex> lock(*hdf5Lib);
@ -68,8 +66,7 @@ void HDF5DataFile::CloseFile() {
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) {
@ -90,9 +87,8 @@ void HDF5DataFile::CloseFile() {
} }
void HDF5DataFile::CreateFirstHDF5DataFile( void HDF5DataFile::CreateFirstHDF5DataFile(
const std::string& fNamePrefix, const std::string &fNamePrefix, const uint64_t fIndex, const bool owEnable,
const uint64_t fIndex, const bool owEnable, const bool sMode, const bool sMode, const uint32_t uPortNumber, const uint32_t mFramesPerFile,
const uint32_t uPortNumber, const uint32_t mFramesPerFile,
const uint64_t nImages, const uint32_t nX, const uint32_t nY, const uint64_t nImages, const uint32_t nX, const uint32_t nY,
const uint32_t dr) { const uint32_t dr) {
@ -134,8 +130,7 @@ void HDF5DataFile::CreateFile() {
numFilesInAcquisition++; numFilesInAcquisition++;
std::ostringstream os; std::ostringstream os;
os << fileNamePrefix << "_f" << subFileIndex os << fileNamePrefix << "_f" << subFileIndex << '_' << fileIndex << ".h5";
<< '_' << fileIndex << ".h5";
fileName = os.str(); fileName = os.str();
std::lock_guard<std::mutex> lock(*hdf5Lib); std::lock_guard<std::mutex> lock(*hdf5Lib);
@ -160,10 +155,10 @@ void HDF5DataFile::CreateFile() {
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;
@ -193,14 +188,14 @@ void HDF5DataFile::CreateFile() {
H5::DSetCreatPropList plistPara; H5::DSetCreatPropList plistPara;
int fill_value = -1; int fill_value = -1;
plist.setFillValue(dataType, &fill_value); plist.setFillValue(dataType, &fill_value);
//plistPara.setFillValue(dataType, &fill_value); // plistPara.setFillValue(dataType, &fill_value);
plist.setChunk(DATA_RANK, dimsChunk); plist.setChunk(DATA_RANK, dimsChunk);
plistPara.setChunk(PARA_RANK, dimsChunkPara); plistPara.setChunk(PARA_RANK, dimsChunkPara);
// dataset // dataset
dataSet = nullptr; dataSet = nullptr;
dataSet = new H5::DataSet(fd->createDataSet( dataSet = new H5::DataSet(
DATASET_NAME, dataType, *dataSpace, plist)); fd->createDataSet(DATASET_NAME, dataType, *dataSpace, plist));
for (unsigned int i = 0; i < parameterNames.size(); ++i) { for (unsigned int i = 0; i < parameterNames.size(); ++i) {
H5::DataSet *ds = new H5::DataSet(fd->createDataSet( H5::DataSet *ds = new H5::DataSet(fd->createDataSet(
parameterNames[i].c_str(), parameterDataTypes[i], parameterNames[i].c_str(), parameterDataTypes[i],
@ -210,8 +205,7 @@ void HDF5DataFile::CreateFile() {
} 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
@ -219,7 +213,10 @@ void HDF5DataFile::CreateFile() {
} }
} }
void HDF5DataFile::WriteToFile(char *imageData, sls_receiver_header& header, const int imageSize, const uint64_t currentFrameNumber, const uint32_t numPacketsCaught) { void HDF5DataFile::WriteToFile(char *imageData, sls_receiver_header &header,
const int imageSize,
const uint64_t currentFrameNumber,
const uint32_t numPacketsCaught) {
// check if maxframesperfile = 0 for infinite // check if maxframesperfile = 0 for infinite
if (maxFramesPerFile && (numFramesInFile >= maxFramesPerFile)) { if (maxFramesPerFile && (numFramesInFile >= maxFramesPerFile)) {
@ -250,15 +247,15 @@ void HDF5DataFile::Convert12to16Bit(uint16_t *dst, uint8_t *src) {
} }
void HDF5DataFile::WriteImageDatasets(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);
} }
@ -267,7 +264,7 @@ void HDF5DataFile::WriteImageDatasets(const uint64_t currentFrameNumber,
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);
@ -291,7 +288,7 @@ void HDF5DataFile::WriteImageDatasets(const uint64_t currentFrameNumber,
LOG(logERROR) << "Could not write to file in object " << index; LOG(logERROR) << "Could not write to file in object " << index;
error.printErrorStack(); error.printErrorStack();
throw 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));
} }
} }
@ -301,7 +298,7 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
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[PARA_RANK] = {1}; hsize_t count[PARA_RANK] = {1};
@ -312,50 +309,50 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
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,7 +365,7 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
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) {
@ -403,7 +400,7 @@ void HDF5DataFile::ExtendDataset() {
} 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

View File

@ -23,15 +23,16 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
void CloseFile() override; void CloseFile() override;
void CreateFirstHDF5DataFile( void CreateFirstHDF5DataFile(const std::string &fNamePrefix,
const std::string& fNamePrefix, const uint64_t fIndex, const bool owEnable,
const uint64_t fIndex, const bool owEnable, const bool sMode, const uint32_t uPortNumber,
const bool sMode, const uint32_t uPortNumber, const uint32_t mFramesPerFile,
const uint32_t mFramesPerFile, const uint64_t nImages, const uint64_t nImages, const uint32_t nX,
const uint32_t nX, const uint32_t nY, const uint32_t nY, const uint32_t dr) override;
const uint32_t dr) override;
void WriteToFile(char *imageData, sls_receiver_header& header, const int imageSize, const uint64_t currentFrameNumber, const uint32_t numPacketsCaught) override; void WriteToFile(char *imageData, sls_receiver_header &header,
const int imageSize, const uint64_t currentFrameNumber,
const uint32_t numPacketsCaught) override;
private: private:
void CreateFile(); void CreateFile();

View File

@ -76,13 +76,13 @@ void Implementation::SetupFifoStructure() {
// create fifo structure // create fifo structure
try { try {
fifo.push_back(sls::make_unique<Fifo>(i, datasize, generalData->fifoDepth)); fifo.push_back(
sls::make_unique<Fifo>(i, datasize, generalData->fifoDepth));
} catch (...) { } catch (...) {
fifo.clear(); fifo.clear();
generalData->fifoDepth = 0; generalData->fifoDepth = 0;
throw RuntimeError( throw RuntimeError("Could not allocate memory for fifo structure " +
"Could not allocate memory for fifo structure " + std::to_string(i) + ". FifoDepth is now 0.");
std::to_string(i) + ". FifoDepth is now 0.");
} }
// set the listener & dataprocessor threads to point to the right fifo // set the listener & dataprocessor threads to point to the right fifo
if (listener.size()) if (listener.size())
@ -97,7 +97,8 @@ void Implementation::SetupFifoStructure() {
(double)(1024 * 1024) (double)(1024 * 1024)
<< " MB"; << " MB";
} }
LOG(logINFO) << generalData->numUDPInterfaces << " Fifo structure(s) reconstructed"; LOG(logINFO) << generalData->numUDPInterfaces
<< " Fifo structure(s) reconstructed";
} }
/************************************************** /**************************************************
@ -120,7 +121,7 @@ void Implementation::setDetectorType(const detectorType d) {
break; break;
default: default:
throw RuntimeError("This is an unknown receiver type " + throw RuntimeError("This is an unknown receiver type " +
std::to_string(static_cast<int>(d))); std::to_string(static_cast<int>(d)));
} }
delete generalData; delete generalData;
@ -160,8 +161,7 @@ void Implementation::setDetectorType(const detectorType d) {
for (int i = 0; i < generalData->numUDPInterfaces; ++i) { for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
try { try {
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(i, &status));
i, &status));
SetupListener(i); SetupListener(i);
dataProcessor.push_back(sls::make_unique<DataProcessor>(i)); dataProcessor.push_back(sls::make_unique<DataProcessor>(i));
SetupDataProcessor(i); SetupDataProcessor(i);
@ -197,7 +197,7 @@ void Implementation::SetupDataProcessor(int i) {
dataProcessor[i]->SetActivate(activated); dataProcessor[i]->SetActivate(activated);
dataProcessor[i]->SetReceiverROI(portRois[i]); dataProcessor[i]->SetReceiverROI(portRois[i]);
dataProcessor[i]->SetDataStreamEnable(dataStreamEnable); dataProcessor[i]->SetDataStreamEnable(dataStreamEnable);
dataProcessor[i]->SetStreamingFrequency(streamingFrequency); dataProcessor[i]->SetStreamingFrequency(streamingFrequency);
dataProcessor[i]->SetStreamingTimerInMs(streamingTimerInMs); dataProcessor[i]->SetStreamingTimerInMs(streamingTimerInMs);
dataProcessor[i]->SetStreamingStartFnum(streamingStartFnum); dataProcessor[i]->SetStreamingStartFnum(streamingStartFnum);
dataProcessor[i]->SetFramePadding(framePadding); dataProcessor[i]->SetFramePadding(framePadding);
@ -208,7 +208,8 @@ void Implementation::SetupDataProcessor(int i) {
void Implementation::SetupDataStreamer(int i) { void Implementation::SetupDataStreamer(int i) {
dataStreamer[i]->SetFifo(fifo[i].get()); dataStreamer[i]->SetFifo(fifo[i].get());
dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(streamingPort, streamingSrcIP, streamingHwm); dataStreamer[i]->CreateZmqSockets(streamingPort, streamingSrcIP,
streamingHwm);
dataStreamer[i]->SetAdditionalJsonHeader(additionalJsonHeader); dataStreamer[i]->SetAdditionalJsonHeader(additionalJsonHeader);
dataStreamer[i]->SetFileIndex(fileIndex); dataStreamer[i]->SetFileIndex(fileIndex);
dataStreamer[i]->SetFlipRows(flipRows); dataStreamer[i]->SetFlipRows(flipRows);
@ -288,8 +289,8 @@ bool Implementation::getSilentMode() const { return silentMode; }
void Implementation::setSilentMode(const bool i) { void Implementation::setSilentMode(const bool i) {
silentMode = i; silentMode = i;
for (const auto &it : listener) for (const auto &it : listener)
it->SetSilentMode(silentMode); it->SetSilentMode(silentMode);
LOG(logINFO) << "Silent Mode: " << i; LOG(logINFO) << "Silent Mode: " << i;
} }
@ -310,7 +311,7 @@ Implementation::getFrameDiscardPolicy() const {
void Implementation::setFrameDiscardPolicy(const frameDiscardPolicy i) { void Implementation::setFrameDiscardPolicy(const frameDiscardPolicy i) {
frameDiscardMode = i; frameDiscardMode = i;
for (const auto &it : listener) for (const auto &it : listener)
it->SetFrameDiscardPolicy(frameDiscardMode); it->SetFrameDiscardPolicy(frameDiscardMode);
LOG(logINFO) << "Frame Discard Policy: " << ToString(frameDiscardMode); LOG(logINFO) << "Frame Discard Policy: " << ToString(frameDiscardMode);
} }
@ -367,7 +368,8 @@ void Implementation::setArping(const bool i,
// setup interface // setup interface
for (int i = 0; i != generalData->numUDPInterfaces; ++i) { for (int i = 0; i != generalData->numUDPInterfaces; ++i) {
// ignore eiger with 2 interfaces (only udp port) // ignore eiger with 2 interfaces (only udp port)
if (i == 1 && (generalData->numUDPInterfaces == 1 || generalData->detType == EIGER)) { if (i == 1 && (generalData->numUDPInterfaces == 1 ||
generalData->detType == EIGER)) {
break; break;
} }
arping.SetInterfacesAndIps(i, eth[i], ips[i]); arping.SetInterfacesAndIps(i, eth[i], ips[i]);
@ -384,7 +386,8 @@ slsDetectorDefs::ROI Implementation::getReceiverROI() const {
void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) { void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
receiverRoi = arg; receiverRoi = arg;
if (generalData->numUDPInterfaces == 1 || generalData->detType == slsDetectorDefs::GOTTHARD2) { if (generalData->numUDPInterfaces == 1 ||
generalData->detType == slsDetectorDefs::GOTTHARD2) {
portRois[0] = arg; portRois[0] = arg;
} else { } else {
slsDetectorDefs::xy nPortDim(generalData->nPixelsX, slsDetectorDefs::xy nPortDim(generalData->nPixelsX,
@ -454,7 +457,8 @@ void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
for (size_t i = 0; i != dataProcessor.size(); ++i) for (size_t i = 0; i != dataProcessor.size(); ++i)
dataProcessor[i]->SetReceiverROI(portRois[i]); dataProcessor[i]->SetReceiverROI(portRois[i]);
LOG(logINFO) << "receiver roi: " << ToString(receiverRoi); LOG(logINFO) << "receiver roi: " << ToString(receiverRoi);
if (generalData->numUDPInterfaces == 2 && generalData->detType != slsDetectorDefs::GOTTHARD2) { if (generalData->numUDPInterfaces == 2 &&
generalData->detType != slsDetectorDefs::GOTTHARD2) {
LOG(logINFO) << "port rois: " << ToString(portRois); LOG(logINFO) << "port rois: " << ToString(portRois);
} }
} }
@ -552,7 +556,9 @@ void Implementation::setOverwriteEnable(const bool b) {
<< (overwriteEnable ? "enabled" : "disabled"); << (overwriteEnable ? "enabled" : "disabled");
} }
uint32_t Implementation::getFramesPerFile() const { return generalData->framesPerFile; } uint32_t Implementation::getFramesPerFile() const {
return generalData->framesPerFile;
}
void Implementation::setFramesPerFile(const uint32_t i) { void Implementation::setFramesPerFile(const uint32_t i) {
generalData->framesPerFile = i; generalData->framesPerFile = i;
@ -609,7 +615,7 @@ double Implementation::getProgress() const {
totalFrames /= 2; totalFrames /= 2;
} }
} }
} }
double progress = 0; double progress = 0;
int index = 0; int index = 0;
@ -660,7 +666,7 @@ void Implementation::startReceiver() {
pStartAcquisition); pStartAcquisition);
} catch (const std::exception &e) { } catch (const std::exception &e) {
throw RuntimeError("Start Acquisition Callback Error: " + throw RuntimeError("Start Acquisition Callback Error: " +
std::string(e.what())); std::string(e.what()));
} }
if (rawDataReadyCallBack != nullptr) { if (rawDataReadyCallBack != nullptr) {
LOG(logINFO) << "Data Write has been defined externally"; LOG(logINFO) << "Data Write has been defined externally";
@ -747,7 +753,7 @@ void Implementation::stopReceiver() {
} else if (portRois[i].noRoi()) { } else if (portRois[i].noRoi()) {
summary = (i == 0 ? "\n\tNo Roi on Left Port" summary = (i == 0 ? "\n\tNo Roi on Left Port"
: "\n\tNo Roi on Right Port"); : "\n\tNo Roi on Right Port");
} else { } else {
std::ostringstream os; std::ostringstream os;
os << "\n\tMissing Packets\t\t: " << mpMessage os << "\n\tMissing Packets\t\t: " << mpMessage
<< "\n\tComplete Frames\t\t: " << nf << "\n\tComplete Frames\t\t: " << nf
@ -763,16 +769,16 @@ void Implementation::stopReceiver() {
// callback // callback
if (acquisitionFinishedCallBack) { if (acquisitionFinishedCallBack) {
try { try {
acquisitionFinishedCallBack((tot / generalData->numUDPInterfaces), acquisitionFinishedCallBack(
pAcquisitionFinished); (tot / generalData->numUDPInterfaces),
pAcquisitionFinished);
} catch (const std::exception &e) { } catch (const std::exception &e) {
// change status // change status
status = IDLE; status = IDLE;
LOG(logINFO) << "Receiver Stopped"; LOG(logINFO) << "Receiver Stopped";
LOG(logINFO) << "Status: " << ToString(status); LOG(logINFO) << "Status: " << ToString(status);
throw RuntimeError( throw RuntimeError("Acquisition Finished Callback Error: " +
"Acquisition Finished Callback Error: " + std::string(e.what()));
std::string(e.what()));
} }
} }
} }
@ -862,7 +868,8 @@ void Implementation::SetupWriter() {
try { try {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
std::ostringstream os; std::ostringstream os;
os << filePath << "/" << fileName << "_d" << (modulePos * generalData->numUDPInterfaces + i); os << filePath << "/" << fileName << "_d"
<< (modulePos * generalData->numUDPInterfaces + i);
std::string fileNamePrefix = os.str(); std::string fileNamePrefix = os.str();
dataProcessor[i]->CreateFirstFiles( dataProcessor[i]->CreateFirstFiles(
fileNamePrefix, fileIndex, overwriteEnable, silentMode, fileNamePrefix, fileIndex, overwriteEnable, silentMode,
@ -893,8 +900,7 @@ void Implementation::StartMasterWriter() {
masterAttributes.framePadding = framePadding; masterAttributes.framePadding = framePadding;
masterAttributes.scanParams = scanParams; masterAttributes.scanParams = scanParams;
masterAttributes.totalFrames = numberOfTotalFrames; masterAttributes.totalFrames = numberOfTotalFrames;
masterAttributes.receiverRoi = masterAttributes.receiverRoi = receiverRoiMetadata;
receiverRoiMetadata;
masterAttributes.exptime = acquisitionTime; masterAttributes.exptime = acquisitionTime;
masterAttributes.period = acquisitionPeriod; masterAttributes.period = acquisitionPeriod;
masterAttributes.burstMode = burstMode; masterAttributes.burstMode = burstMode;
@ -908,18 +914,21 @@ void Implementation::StartMasterWriter() {
masterAttributes.quad = quadEnable; masterAttributes.quad = quadEnable;
masterAttributes.readNRows = readNRows; masterAttributes.readNRows = readNRows;
masterAttributes.ratecorr = rateCorrections; masterAttributes.ratecorr = rateCorrections;
masterAttributes.adcmask = masterAttributes.adcmask = generalData->tengigaEnable
generalData->tengigaEnable ? generalData->adcEnableMaskTenGiga : generalData->adcEnableMaskOneGiga; ? generalData->adcEnableMaskTenGiga
masterAttributes.analog = (generalData->readoutType == ANALOG_ONLY || : generalData->adcEnableMaskOneGiga;
generalData->readoutType == ANALOG_AND_DIGITAL) masterAttributes.analog =
? 1 (generalData->readoutType == ANALOG_ONLY ||
: 0; generalData->readoutType == ANALOG_AND_DIGITAL)
masterAttributes.analogSamples = generalData->nAnalogSamples; ? 1
masterAttributes.digital = (generalData->readoutType == DIGITAL_ONLY || : 0;
generalData->readoutType == ANALOG_AND_DIGITAL) masterAttributes.analogSamples = generalData->nAnalogSamples;
? 1 masterAttributes.digital =
: 0; (generalData->readoutType == DIGITAL_ONLY ||
masterAttributes.digitalSamples = generalData->nDigitalSamples; generalData->readoutType == ANALOG_AND_DIGITAL)
? 1
: 0;
masterAttributes.digitalSamples = generalData->nDigitalSamples;
masterAttributes.dbitoffset = ctbDbitOffset; masterAttributes.dbitoffset = ctbDbitOffset;
masterAttributes.dbitlist = 0; masterAttributes.dbitlist = 0;
for (auto &i : ctbDbitList) { for (auto &i : ctbDbitList) {
@ -947,11 +956,10 @@ void Implementation::StartMasterWriter() {
// create virtual hdf5 file (if multiple files) // create virtual hdf5 file (if multiple files)
if (dataProcessor[0]->GetFilesInAcquisition() > 1 || if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
(numPorts.x * numPorts.y) > 1) { (numPorts.x * numPorts.y) > 1) {
virtualFileName = virtualFileName = dataProcessor[0]->CreateVirtualFile(
dataProcessor[0]->CreateVirtualFile( filePath, fileName, fileIndex, overwriteEnable, silentMode,
filePath, fileName, fileIndex, overwriteEnable, modulePos, numberOfTotalFrames, numPorts.x, numPorts.y,
silentMode, modulePos, numberOfTotalFrames, numPorts.x, numPorts.y, &hdf5LibMutex);
&hdf5LibMutex);
} }
// link file in master // link file in master
if (masterFileWriteEnable) { if (masterFileWriteEnable) {
@ -962,7 +970,8 @@ void Implementation::StartMasterWriter() {
#endif #endif
} catch (std::exception &e) { } catch (std::exception &e) {
// ignore it and just print it // ignore it and just print it
LOG(logWARNING) << "Caught exception when handling virtual hdf5 file [" << e.what() << "]"; LOG(logWARNING) << "Caught exception when handling virtual hdf5 file ["
<< e.what() << "]";
} }
} }
@ -996,8 +1005,7 @@ int Implementation::getNumberofUDPInterfaces() const {
// not Eiger // not Eiger
void Implementation::setNumberofUDPInterfaces(const int n) { void Implementation::setNumberofUDPInterfaces(const int n) {
if (generalData->detType == EIGER) { if (generalData->detType == EIGER) {
throw RuntimeError( throw RuntimeError("Cannot set number of UDP interfaces for Eiger");
"Cannot set number of UDP interfaces for Eiger");
} }
if (generalData->numUDPInterfaces != n) { if (generalData->numUDPInterfaces != n) {
@ -1020,8 +1028,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
for (int i = 0; i < generalData->numUDPInterfaces; ++i) { for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
// listener and dataprocessor threads // listener and dataprocessor threads
try { try {
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(i, &status));
i, &status));
SetupListener(i); SetupListener(i);
dataProcessor.push_back(sls::make_unique<DataProcessor>(i)); dataProcessor.push_back(sls::make_unique<DataProcessor>(i));
SetupDataProcessor(i); SetupDataProcessor(i);
@ -1042,7 +1049,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
if (dataStreamEnable) { if (dataStreamEnable) {
dataStreamer.clear(); dataStreamer.clear();
dataStreamEnable = false; dataStreamEnable = false;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetDataStreamEnable(dataStreamEnable); it->SetDataStreamEnable(dataStreamEnable);
} }
throw RuntimeError( throw RuntimeError(
@ -1120,15 +1127,18 @@ int Implementation::getUDPSocketBufferSize() const {
void Implementation::setUDPSocketBufferSize(const int s) { void Implementation::setUDPSocketBufferSize(const int s) {
size_t listSize = listener.size(); size_t listSize = listener.size();
if ((generalData->detType == JUNGFRAU || generalData->detType == GOTTHARD2) && if ((generalData->detType == JUNGFRAU ||
generalData->detType == GOTTHARD2) &&
(int)listSize != generalData->numUDPInterfaces) { (int)listSize != generalData->numUDPInterfaces) {
throw RuntimeError( throw RuntimeError("Number of Interfaces " +
"Number of Interfaces " + std::to_string(generalData->numUDPInterfaces) + std::to_string(generalData->numUDPInterfaces) +
" do not match listener size " + std::to_string(listSize)); " do not match listener size " +
std::to_string(listSize));
} }
for (auto &l : listener) { for (auto &l : listener) {
l->CreateDummySocketForUDPSocketBufferSize(s, actualUDPSocketBufferSize); l->CreateDummySocketForUDPSocketBufferSize(s,
actualUDPSocketBufferSize);
} }
} }
@ -1158,16 +1168,15 @@ void Implementation::setDataStreamEnable(const bool enable) {
} catch (...) { } catch (...) {
dataStreamer.clear(); dataStreamer.clear();
dataStreamEnable = false; dataStreamEnable = false;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetDataStreamEnable(dataStreamEnable); it->SetDataStreamEnable(dataStreamEnable);
throw RuntimeError( throw RuntimeError("Could not set data stream enable.");
"Could not set data stream enable.");
} }
} }
SetThreadPriorities(); SetThreadPriorities();
} }
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetDataStreamEnable(dataStreamEnable); it->SetDataStreamEnable(dataStreamEnable);
} }
LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable; LOG(logINFO) << "Data Send to Gui: " << dataStreamEnable;
} }
@ -1179,7 +1188,7 @@ uint32_t Implementation::getStreamingFrequency() const {
void Implementation::setStreamingFrequency(const uint32_t freq) { void Implementation::setStreamingFrequency(const uint32_t freq) {
streamingFrequency = freq; streamingFrequency = freq;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetStreamingFrequency(streamingFrequency); it->SetStreamingFrequency(streamingFrequency);
LOG(logINFO) << "Streaming Frequency: " << streamingFrequency; LOG(logINFO) << "Streaming Frequency: " << streamingFrequency;
} }
@ -1212,9 +1221,7 @@ void Implementation::setStreamingPort(const uint32_t i) {
LOG(logINFO) << "Streaming Port: " << streamingPort; LOG(logINFO) << "Streaming Port: " << streamingPort;
} }
IpAddr Implementation::getStreamingSourceIP() const { IpAddr Implementation::getStreamingSourceIP() const { return streamingSrcIP; }
return streamingSrcIP;
}
void Implementation::setStreamingSourceIP(const IpAddr ip) { void Implementation::setStreamingSourceIP(const IpAddr ip) {
streamingSrcIP = ip; streamingSrcIP = ip;
@ -1250,8 +1257,7 @@ Implementation::getAdditionalJsonParameter(const std::string &key) const {
if (additionalJsonHeader.find(key) != additionalJsonHeader.end()) { if (additionalJsonHeader.find(key) != additionalJsonHeader.end()) {
return additionalJsonHeader.at(key); return additionalJsonHeader.at(key);
} }
throw RuntimeError("No key " + key + throw RuntimeError("No key " + key + " found in additional json header");
" found in additional json header");
} }
void Implementation::setAdditionalJsonParameter(const std::string &key, void Implementation::setAdditionalJsonParameter(const std::string &key,
@ -1461,32 +1467,35 @@ void Implementation::setSubPeriod(const ns i) {
} }
uint32_t Implementation::getNumberofAnalogSamples() const { uint32_t Implementation::getNumberofAnalogSamples() const {
return generalData->nAnalogSamples; return generalData->nAnalogSamples;
} }
void Implementation::setNumberofAnalogSamples(const uint32_t i) { void Implementation::setNumberofAnalogSamples(const uint32_t i) {
if ( generalData->nAnalogSamples != i) { if (generalData->nAnalogSamples != i) {
generalData->SetNumberOfAnalogSamples(i); generalData->SetNumberOfAnalogSamples(i);
SetupFifoStructure(); SetupFifoStructure();
} }
LOG(logINFO) << "Number of Analog Samples: " << generalData->nAnalogSamples; LOG(logINFO) << "Number of Analog Samples: " << generalData->nAnalogSamples;
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame); LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
} }
uint32_t Implementation::getNumberofDigitalSamples() const { uint32_t Implementation::getNumberofDigitalSamples() const {
return generalData->nDigitalSamples; return generalData->nDigitalSamples;
} }
void Implementation::setNumberofDigitalSamples(const uint32_t i) { void Implementation::setNumberofDigitalSamples(const uint32_t i) {
if ( generalData->nDigitalSamples != i) { if (generalData->nDigitalSamples != i) {
generalData->SetNumberOfDigitalSamples(i); generalData->SetNumberOfDigitalSamples(i);
SetupFifoStructure(); SetupFifoStructure();
} }
LOG(logINFO) << "Number of Digital Samples: " << generalData->nDigitalSamples; LOG(logINFO) << "Number of Digital Samples: "
<< generalData->nDigitalSamples;
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame); LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
} }
uint32_t Implementation::getCounterMask() const { return generalData->counterMask; } uint32_t Implementation::getCounterMask() const {
return generalData->counterMask;
}
void Implementation::setCounterMask(const uint32_t i) { void Implementation::setCounterMask(const uint32_t i) {
if (generalData->counterMask != i) { if (generalData->counterMask != i) {
@ -1498,7 +1507,9 @@ void Implementation::setCounterMask(const uint32_t i) {
LOG(logINFO) << "Number of counters: " << ncounters; LOG(logINFO) << "Number of counters: " << ncounters;
} }
uint32_t Implementation::getDynamicRange() const { return generalData->dynamicRange; } uint32_t Implementation::getDynamicRange() const {
return generalData->dynamicRange;
}
void Implementation::setDynamicRange(const uint32_t i) { void Implementation::setDynamicRange(const uint32_t i) {
if (generalData->dynamicRange != i) { if (generalData->dynamicRange != i) {
@ -1510,10 +1521,13 @@ void Implementation::setDynamicRange(const uint32_t i) {
LOG(logINFO) << "Dynamic Range: " << generalData->dynamicRange; LOG(logINFO) << "Dynamic Range: " << generalData->dynamicRange;
} }
slsDetectorDefs::ROI Implementation::getROI() const { return generalData->detectorRoi; } slsDetectorDefs::ROI Implementation::getROI() const {
return generalData->detectorRoi;
}
void Implementation::setDetectorROI(slsDetectorDefs::ROI arg) { void Implementation::setDetectorROI(slsDetectorDefs::ROI arg) {
if (generalData->detectorRoi.xmin != arg.xmin || generalData->detectorRoi.xmax != arg.xmax) { if (generalData->detectorRoi.xmin != arg.xmin ||
generalData->detectorRoi.xmax != arg.xmax) {
// only for gotthard // only for gotthard
generalData->SetDetectorROI(arg); generalData->SetDetectorROI(arg);
SetupFifoStructure(); SetupFifoStructure();
@ -1523,10 +1537,12 @@ void Implementation::setDetectorROI(slsDetectorDefs::ROI arg) {
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame); LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
} }
bool Implementation::getTenGigaEnable() const { return generalData->tengigaEnable; } bool Implementation::getTenGigaEnable() const {
return generalData->tengigaEnable;
}
void Implementation::setTenGigaEnable(const bool b) { void Implementation::setTenGigaEnable(const bool b) {
if ( generalData->tengigaEnable != b) { if (generalData->tengigaEnable != b) {
generalData->SetTenGigaEnable(b); generalData->SetTenGigaEnable(b);
SetupFifoStructure(); SetupFifoStructure();
@ -1541,11 +1557,12 @@ void Implementation::setTenGigaEnable(const bool b) {
} }
LOG(logDEBUG) << "Detector datastream updated [Left: " LOG(logDEBUG) << "Detector datastream updated [Left: "
<< ToString(detectorDataStream[LEFT]) << ToString(detectorDataStream[LEFT])
<< ", Right: " << ", Right: " << ToString(detectorDataStream[RIGHT])
<< ToString(detectorDataStream[RIGHT]) << "]"; << "]";
} }
} }
LOG(logINFO) << "Ten Giga: " << ( generalData->tengigaEnable ? "enabled" : "disabled"); LOG(logINFO) << "Ten Giga: "
<< (generalData->tengigaEnable ? "enabled" : "disabled");
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame); LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
} }
@ -1596,7 +1613,7 @@ void Implementation::setDetectorDataStream(const portPosition port,
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port) LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
<< " Port): " << ToString(detectorDataStream10GbE[index]); << " Port): " << ToString(detectorDataStream10GbE[index]);
// update datastream for 10g // update datastream for 10g
if ( generalData->tengigaEnable) { if (generalData->tengigaEnable) {
detectorDataStream[index] = detectorDataStream10GbE[index]; detectorDataStream[index] = detectorDataStream10GbE[index];
LOG(logDEBUG) << "Detector datastream updated [" LOG(logDEBUG) << "Detector datastream updated ["
<< (index == 0 ? "Left" : "Right") << (index == 0 ? "Left" : "Right")
@ -1618,8 +1635,7 @@ void Implementation::setThresholdEnergy(const int value) {
void Implementation::setThresholdEnergy(const std::array<int, 3> value) { void Implementation::setThresholdEnergy(const std::array<int, 3> value) {
thresholdAllEnergyeV = value; thresholdAllEnergyeV = value;
LOG(logINFO) << "Threshold Energy (eV): " LOG(logINFO) << "Threshold Energy (eV): " << ToString(thresholdAllEnergyeV);
<< ToString(thresholdAllEnergyeV);
} }
void Implementation::setRateCorrections(const std::vector<int64_t> &t) { void Implementation::setRateCorrections(const std::vector<int64_t> &t) {
@ -1670,8 +1686,8 @@ void Implementation::setTenGigaADCEnableMask(uint32_t mask) {
std::vector<int> Implementation::getDbitList() const { return ctbDbitList; } std::vector<int> Implementation::getDbitList() const { return ctbDbitList; }
void Implementation::setDbitList(const std::vector<int> &v) { void Implementation::setDbitList(const std::vector<int> &v) {
ctbDbitList = v; ctbDbitList = v;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetCtbDbitList(ctbDbitList); it->SetCtbDbitList(ctbDbitList);
LOG(logINFO) << "Dbit list: " << ToString(ctbDbitList); LOG(logINFO) << "Dbit list: " << ToString(ctbDbitList);
@ -1679,8 +1695,8 @@ void Implementation::setDbitList(const std::vector<int> &v) {
int Implementation::getDbitOffset() const { return ctbDbitOffset; } int Implementation::getDbitOffset() const { return ctbDbitOffset; }
void Implementation::setDbitOffset(const int s) { void Implementation::setDbitOffset(const int s) {
ctbDbitOffset = s; ctbDbitOffset = s;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetCtbDbitOffset(ctbDbitOffset); it->SetCtbDbitOffset(ctbDbitOffset);
LOG(logINFO) << "Dbit offset: " << ctbDbitOffset; LOG(logINFO) << "Dbit offset: " << ctbDbitOffset;
@ -1707,7 +1723,7 @@ void Implementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
} }
void Implementation::registerCallBackRawDataReady( void Implementation::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;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
@ -1715,7 +1731,7 @@ void Implementation::registerCallBackRawDataReady(
} }
void Implementation::registerCallBackRawDataModifyReady( void Implementation::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;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)

View File

@ -267,11 +267,11 @@ class Implementation : 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 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 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);
@ -380,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};

View File

@ -31,9 +31,7 @@ Listener::Listener(int index, std::atomic<runStatus> *status)
Listener::~Listener() = default; Listener::~Listener() = default;
bool Listener::isPortDisabled() const { bool Listener::isPortDisabled() const { return disabledPort; }
return disabledPort;
}
uint64_t Listener::GetPacketsCaught() const { return numPacketsCaught; } uint64_t Listener::GetPacketsCaught() const { return numPacketsCaught; }
@ -84,22 +82,23 @@ void Listener::SetEthernetInterface(const std::string e) {
eth = ""; eth = "";
} }
if (!eth.length()) { if (!eth.length()) {
LOG(logWARNING) << "ethernet interface for udp port " << udpPortNumber << " is empty. Listening to all"; LOG(logWARNING) << "ethernet interface for udp port " << udpPortNumber
<< " is empty. Listening to all";
} }
} }
void Listener::SetActivate(bool enable) { void Listener::SetActivate(bool enable) {
activated = enable; activated = enable;
disabledPort = (!activated || !detectorDataStream || noRoi); disabledPort = (!activated || !detectorDataStream || noRoi);
} }
void Listener::SetDetectorDatastream(bool enable) { void Listener::SetDetectorDatastream(bool enable) {
detectorDataStream = enable; detectorDataStream = enable;
disabledPort = (!activated || !detectorDataStream || noRoi); disabledPort = (!activated || !detectorDataStream || noRoi);
} }
void Listener::SetNoRoi(bool enable) { void Listener::SetNoRoi(bool enable) {
noRoi = enable; noRoi = enable;
disabledPort = (!activated || !detectorDataStream || noRoi); disabledPort = (!activated || !detectorDataStream || noRoi);
} }
@ -107,10 +106,7 @@ void Listener::SetFrameDiscardPolicy(frameDiscardPolicy value) {
frameDiscardMode = value; frameDiscardMode = value;
} }
void Listener::SetSilentMode(bool enable) { void Listener::SetSilentMode(bool enable) { silentMode = enable; }
silentMode = enable;
}
void Listener::ResetParametersforNewAcquisition() { void Listener::ResetParametersforNewAcquisition() {
StopRunning(); StopRunning();
@ -151,7 +147,7 @@ void Listener::RecordFirstIndex(uint64_t fnum) {
} }
} }
void Listener::CreateUDPSocket(int& actualSize) { void Listener::CreateUDPSocket(int &actualSize) {
if (disabledPort) { if (disabledPort) {
return; return;
} }
@ -163,13 +159,14 @@ void Listener::CreateUDPSocket(int& actualSize) {
} }
try { try {
udpSocket = make_unique<UdpRxSocket>(udpPortNumber, packetSize, udpSocket = make_unique<UdpRxSocket>(
(eth.length() ? InterfaceNameToIp(eth).str().c_str() udpPortNumber, packetSize,
: nullptr), generalData->udpSocketBufferSize); (eth.length() ? InterfaceNameToIp(eth).str().c_str() : nullptr),
generalData->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;
@ -188,12 +185,12 @@ void Listener::ShutDownUDPSocket() {
} }
} }
void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int& actualSize) { void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize) {
// custom setup (s != 0) // custom setup (s != 0)
// default setup at startup (s = 0) // default setup at startup (s = 0)
int size = (s == 0 ? generalData->udpSocketBufferSize : s); int size = (s == 0 ? generalData->udpSocketBufferSize : s);
LOG(logINFO) << "Testing UDP Socket Buffer size " << size << " with test port " LOG(logINFO) << "Testing UDP Socket Buffer size " << size
<< udpPortNumber; << " with test port " << udpPortNumber;
int previousSize = generalData->udpSocketBufferSize; int previousSize = generalData->udpSocketBufferSize;
generalData->udpSocketBufferSize = size; generalData->udpSocketBufferSize = size;
@ -209,10 +206,10 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int& actualSize) {
// 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); generalData->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)
@ -225,13 +222,13 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int& actualSize) {
} 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 // custom and didnt set, throw error
if (s != 0 && static_cast<int>(generalData->udpSocketBufferSize) != s) { if (s != 0 && static_cast<int>(generalData->udpSocketBufferSize) != s) {
throw RuntimeError("Could not set udp socket buffer size. (No " throw RuntimeError("Could not set udp socket buffer size. (No "
"CAP_NET_ADMIN privileges?)"); "CAP_NET_ADMIN privileges?)");
} }
} }
@ -245,8 +242,8 @@ void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
void Listener::ThreadExecution() { void Listener::ThreadExecution() {
char *buffer; char *buffer;
fifo->GetNewAddress(buffer); fifo->GetNewAddress(buffer);
LOG(logDEBUG5) << "Listener " << index << ", pop 0x" LOG(logDEBUG5) << "Listener " << index << ", pop 0x" << std::hex
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer; << (void *)(buffer) << std::dec << ":" << buffer;
auto *memImage = reinterpret_cast<image_structure *>(buffer); auto *memImage = reinterpret_cast<image_structure *>(buffer);
// udpsocket doesnt exist // udpsocket doesnt exist
@ -261,8 +258,8 @@ void Listener::ThreadExecution() {
// end of acquisition or discarding image // end of acquisition or discarding image
if (rc <= 0) { if (rc <= 0) {
fifo->FreeAddress(buffer); fifo->FreeAddress(buffer);
return; return;
} }
// valid image, set size and push into fifo // valid image, set size and push into fifo
@ -275,27 +272,28 @@ void Listener::ThreadExecution() {
if (numFramesStatistic >= if (numFramesStatistic >=
// second condition also for infinite #number of frames // second condition also for infinite #number of frames
(generalData->framesPerFile == 0 ? STATISTIC_FRAMENUMBER_INFINITE (generalData->framesPerFile == 0 ? STATISTIC_FRAMENUMBER_INFINITE
: generalData->framesPerFile)) : generalData->framesPerFile))
PrintFifoStatistics(); PrintFifoStatistics();
} }
} }
void Listener::StopListening(char *buf, size_t & size) { void Listener::StopListening(char *buf, size_t &size) {
size = DUMMY_PACKET_VALUE; size = DUMMY_PACKET_VALUE;
fifo->PushAddress(buf); fifo->PushAddress(buf);
StopRunning(); StopRunning();
LOG(logDEBUG1) << index << ": Listening Completed. Packets (" << udpPortNumber LOG(logDEBUG1) << index << ": Listening Completed. Packets ("
<< ") : " << numPacketsCaught; << udpPortNumber << ") : " << numPacketsCaught;
} }
/* buf includes the fifo header and packet header */ /* buf includes the fifo header and packet header */
uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstData) { uint32_t Listener::ListenToAnImage(sls_receiver_header &dstHeader,
char *dstData) {
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;
@ -316,7 +314,8 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
// carry over packet // carry over packet
if (carryOverFlag) { if (carryOverFlag) {
LOG(logDEBUG3) << index << "carry flag"; LOG(logDEBUG3) << index << "carry flag";
GetPacketIndices(fnum, pnum, bnum, standardHeader, carryOverPacket.get(), srcDetHeader); GetPacketIndices(fnum, pnum, bnum, standardHeader,
carryOverPacket.get(), srcDetHeader);
// future packet // future packet
if (fnum != currentFrameIndex) { if (fnum != currentFrameIndex) {
@ -327,10 +326,13 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
carryOverFlag = false; carryOverFlag = false;
return 0; return 0;
} }
return HandleFuturePacket(false, numpackets, fnum, isHeaderEmpty, imageSize, dstHeader); return HandleFuturePacket(false, numpackets, fnum, isHeaderEmpty,
imageSize, dstHeader);
} }
CopyPacket(dstData, carryOverPacket.get(), dsize, hsize, corrected_dsize, numpackets, isHeaderEmpty, standardHeader, dstHeader, srcDetHeader, pnum, bnum); CopyPacket(dstData, carryOverPacket.get(), dsize, hsize,
corrected_dsize, numpackets, isHeaderEmpty, standardHeader,
dstHeader, srcDetHeader, pnum, bnum);
carryOverFlag = false; carryOverFlag = false;
} }
@ -345,13 +347,15 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
// end of acquisition // end of acquisition
if (rc <= 0) { if (rc <= 0) {
if (numpackets == 0) if (numpackets == 0)
return 0; return 0;
return HandleFuturePacket(true, numpackets, fnum, isHeaderEmpty, imageSize, dstHeader); return HandleFuturePacket(true, numpackets, fnum, isHeaderEmpty,
imageSize, dstHeader);
} }
numPacketsCaught++; numPacketsCaught++;
numPacketsStatistic++; numPacketsStatistic++;
GetPacketIndices(fnum, pnum, bnum, standardHeader, listeningPacket.get(), srcDetHeader); GetPacketIndices(fnum, pnum, bnum, standardHeader,
listeningPacket.get(), srcDetHeader);
// Eiger Firmware in a weird state // Eiger Firmware in a weird state
if (generalData->detType == EIGER && fnum == 0) { if (generalData->detType == EIGER && fnum == 0) {
@ -376,16 +380,19 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
LOG(logERROR) << "Bad packet " << pnum << "(fnum: " << fnum LOG(logERROR) << "Bad packet " << pnum << "(fnum: " << fnum
<< "), throwing away. Packets caught so far: " << "), throwing away. Packets caught so far: "
<< numpackets; << numpackets;
return 0; return 0;
} }
// future packet // future packet
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, imageSize, dstHeader); return HandleFuturePacket(false, numpackets, fnum, isHeaderEmpty,
imageSize, dstHeader);
} }
CopyPacket(dstData, listeningPacket.get(), dsize, hsize, corrected_dsize, numpackets, isHeaderEmpty, standardHeader, dstHeader, srcDetHeader, pnum, bnum); CopyPacket(dstData, listeningPacket.get(), dsize, hsize,
corrected_dsize, numpackets, isHeaderEmpty, standardHeader,
dstHeader, srcDetHeader, pnum, bnum);
} }
// complete image // complete image
@ -397,7 +404,10 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
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) { size_t Listener::HandleFuturePacket(bool EOA, uint32_t numpackets,
uint64_t fnum, bool isHeaderEmpty,
size_t imageSize,
sls_receiver_header &dstHeader) {
switch (frameDiscardMode) { switch (frameDiscardMode) {
case DISCARD_EMPTY_FRAMES: case DISCARD_EMPTY_FRAMES:
if (!numpackets) { if (!numpackets) {
@ -417,15 +427,17 @@ size_t Listener::HandleFuturePacket(bool EOA, uint32_t numpackets, uint64_t fnum
default: default:
break; break;
} }
dstHeader.detHeader.packetNumber = numpackets; dstHeader.detHeader.packetNumber = numpackets;
// for empty frames (padded) // for empty frames (padded)
if (isHeaderEmpty) { if (isHeaderEmpty) {
dstHeader.detHeader.frameNumber = currentFrameIndex; dstHeader.detHeader.frameNumber = currentFrameIndex;
// no packet to get bnum // no packet to get bnum
dstHeader.detHeader.row = row; dstHeader.detHeader.row = row;
dstHeader.detHeader.column = column; dstHeader.detHeader.column = column;
dstHeader.detHeader.detType = static_cast<uint8_t>(generalData->detType); dstHeader.detHeader.detType =
dstHeader.detHeader.version = static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION); static_cast<uint8_t>(generalData->detType);
dstHeader.detHeader.version =
static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION);
} }
if (!EOA) { if (!EOA) {
++currentFrameIndex; ++currentFrameIndex;
@ -433,7 +445,12 @@ size_t Listener::HandleFuturePacket(bool EOA, uint32_t numpackets, uint64_t fnum
return imageSize; 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) { 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 // copy packet data
switch (generalData->detType) { switch (generalData->detType) {
@ -449,7 +466,8 @@ void Listener::CopyPacket(char* dst, char* src, uint32_t dataSize, uint32_t detH
case CHIPTESTBOARD: case CHIPTESTBOARD:
case MOENCH: case MOENCH:
if (pnum == (generalData->packetsPerFrame - 1)) if (pnum == (generalData->packetsPerFrame - 1))
memcpy(dst + (pnum * dataSize), &src[detHeaderSize], correctedDataSize); memcpy(dst + (pnum * dataSize), &src[detHeaderSize],
correctedDataSize);
else else
memcpy(dst + (pnum * dataSize), &src[detHeaderSize], dataSize); memcpy(dst + (pnum * dataSize), &src[detHeaderSize], dataSize);
break; break;
@ -458,27 +476,33 @@ void Listener::CopyPacket(char* dst, char* src, uint32_t dataSize, uint32_t detH
break; break;
} }
++numpackets; ++numpackets;
dstHeader.packetsMask[( dstHeader
(pnum < MAX_NUM_PACKETS) ? pnum : MAX_NUM_PACKETS - 1)] = 1; .packetsMask[((pnum < MAX_NUM_PACKETS) ? pnum : MAX_NUM_PACKETS - 1)] =
1;
// writer header // writer header
if (isHeaderEmpty) { if (isHeaderEmpty) {
if (standardHeader) { if (standardHeader) {
memcpy((char *)&dstHeader, (char *)srcDetHeader, sizeof(sls_detector_header)); memcpy((char *)&dstHeader, (char *)srcDetHeader,
sizeof(sls_detector_header));
} else { } else {
dstHeader.detHeader.frameNumber = currentFrameIndex; dstHeader.detHeader.frameNumber = currentFrameIndex;
dstHeader.detHeader.bunchId = bnum; dstHeader.detHeader.bunchId = bnum;
dstHeader.detHeader.row = row; dstHeader.detHeader.row = row;
dstHeader.detHeader.column = column; dstHeader.detHeader.column = column;
dstHeader.detHeader.detType = static_cast<uint8_t>(generalData->detType); dstHeader.detHeader.detType =
dstHeader.detHeader.version = static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION); static_cast<uint8_t>(generalData->detType);
dstHeader.detHeader.version =
static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION);
} }
isHeaderEmpty = false; isHeaderEmpty = false;
} }
} }
void Listener::GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum, bool standardHeader, char* packet, sls_detector_header*& header) { void Listener::GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum,
bool standardHeader, char *packet,
sls_detector_header *&header) {
if (standardHeader) { if (standardHeader) {
header = (sls_detector_header *)(&packet[0]); header = (sls_detector_header *)(&packet[0]);
fnum = header->frameNumber; fnum = header->frameNumber;
@ -487,14 +511,14 @@ void Listener::GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum,
// set first packet to be odd or even (check required when switching // set first packet to be odd or even (check required when switching
// from roi to no roi) // from roi to no roi)
if (generalData->detType == GOTTHARD && !startedFlag) { if (generalData->detType == GOTTHARD && !startedFlag) {
oddStartingPacket = generalData->SetOddStartingPacket(index, &packet[0]); oddStartingPacket =
generalData->SetOddStartingPacket(index, &packet[0]);
} }
generalData->GetHeaderInfo(index, &packet[0], oddStartingPacket, fnum, pnum, bnum); 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

View File

@ -47,12 +47,11 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
void SetFrameDiscardPolicy(frameDiscardPolicy value); void SetFrameDiscardPolicy(frameDiscardPolicy value);
void SetSilentMode(bool enable); void SetSilentMode(bool enable);
void ResetParametersforNewAcquisition(); void ResetParametersforNewAcquisition();
void CreateUDPSocket(int& actualSize); void CreateUDPSocket(int &actualSize);
void ShutDownUDPSocket(); void ShutDownUDPSocket();
/** to set & get actual buffer size */ /** to set & get actual buffer size */
void CreateDummySocketForUDPSocketBufferSize(int s, int & actualSize); void CreateDummySocketForUDPSocketBufferSize(int s, int &actualSize);
/** /**
* Set hard coded (calculated but not from detector) row and column * Set hard coded (calculated but not from detector) row and column
@ -77,7 +76,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
* pushes dummy buffer into fifo * pushes dummy buffer into fifo
* and reset running mask by calling StopRunning() * and reset running mask by calling StopRunning()
*/ */
void StopListening(char *buf, size_t& size); void StopListening(char *buf, size_t &size);
/** /**
* Listen to the UDP Socket for an image, * Listen to the UDP Socket for an image,
@ -85,13 +84,22 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
* @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(sls_receiver_header & dstHeader, char *dstData); 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); 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 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 GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum,
bool standardHeader, char *packet,
sls_detector_header *&header);
void PrintFifoStatistics(); void PrintFifoStatistics();

View File

@ -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
@ -262,15 +260,15 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::StrType strdatatype(H5::PredType::C_S1, 256); H5::StrType strdatatype(H5::PredType::C_S1, 256);
H5::DataSet dataset = group->createDataSet("Frame Discard Policy", H5::DataSet dataset = group->createDataSet("Frame Discard Policy",
strdatatype, dataspace); strdatatype, dataspace);
strcpy_safe(c, ToString(frameDiscardMode)); strcpy_safe(c, ToString(frameDiscardMode));
dataset.write(c, strdatatype); dataset.write(c, strdatatype);
} }
// 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
@ -334,7 +333,7 @@ void MasterAttributes::WriteFinalHDF5Attributes(H5::H5File *fd, H5::Group *group
H5::StrType strdatatype(H5::PredType::C_S1, json.length()); H5::StrType strdatatype(H5::PredType::C_S1, json.length());
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR); H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
H5::DataSet dataset = group->createDataSet("Additional JSON Header", H5::DataSet dataset = group->createDataSet("Additional JSON Header",
strdatatype, dataspace); strdatatype, dataspace);
strcpy_safe(c, ToString(additionalJsonHeader)); strcpy_safe(c, ToString(additionalJsonHeader));
dataset.write(c, strdatatype); dataset.write(c, strdatatype);
} }
@ -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);

View File

@ -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)

View File

@ -24,9 +24,9 @@ std::string CreateMasterBinaryFile(const std::string &filePath,
if (!overWriteEnable) if (!overWriteEnable)
mode = "wx"; mode = "wx";
FILE *fd = fopen(fileName.c_str(), mode.c_str()); FILE *fd = fopen(fileName.c_str(), mode.c_str());
if(!fd) { if (!fd) {
throw RuntimeError("Could not create/overwrite binary master file " + throw RuntimeError("Could not create/overwrite binary master file " +
fileName); fileName);
} }
rapidjson::StringBuffer s; rapidjson::StringBuffer s;
@ -62,15 +62,16 @@ void LinkHDF5FileInMaster(std::string &masterFileName,
// open master file // open master file
H5::H5File masterfd(masterFileName.c_str(), H5F_ACC_RDWR, H5::H5File masterfd(masterFileName.c_str(), H5F_ACC_RDWR,
H5::FileCreatPropList::DEFAULT, flist); H5::FileCreatPropList::DEFAULT, flist);
// open data file // open data file
fd = make_unique<H5::H5File>(dataFilename.c_str(), H5F_ACC_RDONLY, fd = make_unique<H5::H5File>(dataFilename.c_str(), H5F_ACC_RDONLY,
H5::FileCreatPropList::DEFAULT, flist); H5::FileCreatPropList::DEFAULT, flist);
// 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) {
@ -129,7 +130,7 @@ std::string CreateMasterHDF5File(const std::string &filePath,
createFlags = H5F_ACC_TRUNC; createFlags = H5F_ACC_TRUNC;
} }
fd = make_unique<H5::H5File>(fileName.c_str(), createFlags, fd = make_unique<H5::H5File>(fileName.c_str(), createFlags,
H5::FileCreatPropList::DEFAULT, flist); H5::FileCreatPropList::DEFAULT, flist);
// attributes - version // attributes - version
double dValue = HDF5_WRITER_VERSION; double dValue = HDF5_WRITER_VERSION;
@ -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;
@ -195,10 +194,10 @@ std::string CreateVirtualHDF5File(
fapl.setFcloseDegree(H5F_CLOSE_STRONG); fapl.setFcloseDegree(H5F_CLOSE_STRONG);
if (!overWriteEnable) if (!overWriteEnable)
fd = make_unique<H5::H5File>(fileName.c_str(), H5F_ACC_EXCL, fd = make_unique<H5::H5File>(fileName.c_str(), H5F_ACC_EXCL,
H5::FileCreatPropList::DEFAULT, fapl); H5::FileCreatPropList::DEFAULT, fapl);
else else
fd = make_unique<H5::H5File>(fileName.c_str(), H5F_ACC_TRUNC, fd = make_unique<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;
@ -209,8 +208,9 @@ std::string CreateVirtualHDF5File(
// dataspace // dataspace
hsize_t vdsDims[DATA_RANK] = {numImagesCaught, numModY * nDimy, hsize_t vdsDims[DATA_RANK] = {numImagesCaught, numModY * nDimy,
numModZ * nDimz}; numModZ * nDimz};
hsize_t vdsDimsPara[VDS_PARA_RANK] = {numImagesCaught, numModY * numModZ}; hsize_t vdsDimsPara[VDS_PARA_RANK] = {numImagesCaught,
numModY * numModZ};
H5::DataSpace vdsDataSpace(DATA_RANK, vdsDims, nullptr); H5::DataSpace vdsDataSpace(DATA_RANK, vdsDims, nullptr);
H5::DataSpace vdsDataSpacePara(VDS_PARA_RANK, vdsDimsPara, nullptr); H5::DataSpace vdsDataSpacePara(VDS_PARA_RANK, vdsDimsPara, nullptr);
@ -290,17 +290,19 @@ std::string CreateVirtualHDF5File(
H5::DataSpace srcDataSpace(DATA_RANK, srcDims, srcDimsMax); H5::DataSpace srcDataSpace(DATA_RANK, srcDims, srcDimsMax);
hsize_t srcDimsPara[PARA_RANK] = {nDimx}; hsize_t srcDimsPara[PARA_RANK] = {nDimx};
hsize_t srcDimsMaxPara[PARA_RANK] = {H5S_UNLIMITED}; hsize_t srcDimsMaxPara[PARA_RANK] = {H5S_UNLIMITED};
H5::DataSpace srcDataSpacePara(PARA_RANK, srcDimsPara, srcDimsMaxPara); H5::DataSpace srcDataSpacePara(PARA_RANK, srcDimsPara,
srcDimsMaxPara);
// temporary fixfor corner case bug: // temporary fixfor corner case bug:
// (framescaught not multiple of framesperfile, // (framescaught not multiple of framesperfile,
// virtual parameter datasets error loading (bad scalar value)) // virtual parameter datasets error loading (bad scalar value))
if (nDimx != maxFramesPerFile) { if (nDimx != maxFramesPerFile) {
hsize_t count[1] = {nDimx}; hsize_t count[1] = {nDimx};
hsize_t start[1] = {0}; hsize_t start[1] = {0};
srcDataSpacePara.selectHyperslab(H5S_SELECT_SET, count, start, strideBetweenBlocksPara, blockSizePara); 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(),
DATASET_NAME, srcDataSpace); DATASET_NAME, srcDataSpace);
@ -325,8 +327,8 @@ std::string CreateVirtualHDF5File(
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(
@ -340,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;

View File

@ -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

View File

@ -54,15 +54,16 @@ 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
<< " imageSize:" << imageSize << " ####"; << " fileIndex:" << fileIndex
<< " imageSize:" << imageSize << " ####";
return 0; return 0;
} }
/** Acquisition Finished Call back */ /** Acquisition Finished Call back */
void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) { void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) {
LOG(sls::logINFOBLUE) << "#### AcquisitionFinished: framesCaught:" LOG(sls::logINFOBLUE) << "#### AcquisitionFinished: framesCaught:"
<< framesCaught << " ####"; << framesCaught << " ####";
} }
/** /**
@ -70,7 +71,7 @@ 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;
@ -101,7 +102,8 @@ 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, size_t &modifiedImageSize, void *objectPointer) { void GetData(slsDetectorDefs::sls_receiver_header &header, char *dataPointer,
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(

View File

@ -128,9 +128,11 @@ 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 &,
void *arg) { uint64_t, size_t,
void *),
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);
} }

View File

@ -25,8 +25,8 @@ ThreadObject::ThreadObject(int index, std::string type)
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));
} }
} }

View File

@ -36,20 +36,22 @@ namespace sls {
// binary // binary
#define FILE_BUFFER_SIZE (16 * 1024 * 1024) // 16mb #define FILE_BUFFER_SIZE (16 * 1024 * 1024) // 16mb
// fifo // fifo
struct image_structure { struct image_structure {
size_t size; size_t size;
size_t firstIndex; size_t firstIndex;
slsDetectorDefs::sls_receiver_header header; slsDetectorDefs::sls_receiver_header header;
char data[]; char data[];
}; };
#define IMAGE_STRUCTURE_HEADER_SIZE (sizeof(size_t) + sizeof(size_t) + sizeof(slsDetectorDefs::sls_receiver_header)) #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 DATA_RANK (3)
#define PARA_RANK (1) #define PARA_RANK (1)
#define VDS_PARA_RANK (2) #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
@ -64,7 +66,6 @@ struct image_structure {
#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

View File

@ -6,7 +6,6 @@
namespace sls { namespace sls {
TEST_CASE("Empty buffer") { TEST_CASE("Empty buffer") {
CircularFifo<char> fifo(0); CircularFifo<char> fifo(0);

View File

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

View File

@ -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

View File

@ -69,8 +69,8 @@
#define MAX_STR_LENGTH 1000 #define MAX_STR_LENGTH 1000
#define SHORT_STR_LENGTH 20 #define SHORT_STR_LENGTH 20
#define MAX_PATTERN_LENGTH 0x2000 #define MAX_PATTERN_LENGTH 0x2000
#define MAX_PATTERN_LEVELS 6 #define MAX_PATTERN_LEVELS 6
#define M3_MAX_PATTERN_LEVELS 3 #define M3_MAX_PATTERN_LEVELS 3
#define DEFAULT_STREAMING_TIMER_IN_MS 500 #define DEFAULT_STREAMING_TIMER_IN_MS 500
@ -179,8 +179,8 @@ class slsDetectorDefs {
ROI(int xmin, int xmax, int ymin, int ymax) ROI(int xmin, int xmax, int ymin, int ymax)
: xmin(xmin), xmax(xmax), ymin(ymin), ymax(ymax){}; : xmin(xmin), xmax(xmax), ymin(ymin), ymax(ymax){};
constexpr std::array<int, 4> getIntArray() const { constexpr std::array<int, 4> getIntArray() const {
return std::array<int, 4> ({xmin, xmax, ymin, ymax}); return std::array<int, 4>({xmin, xmax, ymin, ymax});
} }
constexpr bool completeRoi() const { constexpr bool completeRoi() const {
return (xmin == -1 && xmax == -1 && ymin == -1 && ymax == -1); return (xmin == -1 && xmax == -1 && ymin == -1 && ymax == -1);
} }

View File

@ -2,13 +2,13 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */ /** API versions */
#define GITBRANCH "developer" #define GITBRANCH "developer"
#define APILIB 0x220609 #define APILIB 0x220609
#define APIRECEIVER 0x220609 #define APIRECEIVER 0x220609
#define APIGUI 0x220609 #define APIGUI 0x220609
#define APICTB 0x220714 #define APICTB 0x220714
#define APIGOTTHARD 0x220714 #define APIGOTTHARD 0x220714
#define APIGOTTHARD2 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

View File

@ -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

View File

@ -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) {

View File

@ -417,4 +417,3 @@ void ZmqSocket::mySocketDescriptors::Close() {
}; };
} // namespace sls } // namespace sls

View File

@ -60,15 +60,14 @@ 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");
if (fp == nullptr) { if (fp == nullptr) {
throw RuntimeError(errorPrefix + throw RuntimeError(errorPrefix +
std::string(" (Could not open file: ") + fname + std::string(" (Could not open file: ") + fname +
std::string(")")); std::string(")"));
} }
// get file size to print progress // get file size to print progress
@ -76,13 +75,12 @@ 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) {
throw RuntimeError(errorPrefix + throw RuntimeError(errorPrefix +
std::string(" (Could not close file)")); std::string(" (Could not close file)"));
} }
LOG(logDEBUG1) << "Read file into memory"; LOG(logDEBUG1) << "Read file into memory";

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

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

View File

@ -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,
sls::Opt(sls::test::detector_type, "detector_type")["-dt"]["--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();