mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-19 10:30:02 +02:00
parent
7173785b29
commit
6bf9dbf6d3
@ -106,4 +106,3 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_plot_curve.h>
|
||||
#include <qwt_plot_marker.h>
|
||||
#include <qwt_scale_div.h>
|
||||
#include <qwt_plot_shapeitem.h>
|
||||
#include <qwt_scale_div.h>
|
||||
|
||||
class QPen;
|
||||
class QwtSymbol;
|
||||
@ -176,5 +176,3 @@ class SlsQt1DPlot : public QwtPlot {
|
||||
} // namespace sls
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include "SlsQt2DZoomer.h"
|
||||
#include <qlist.h>
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_plot_spectrogram.h>
|
||||
#include <qwt_plot_shapeitem.h>
|
||||
#include <qwt_plot_spectrogram.h>
|
||||
|
||||
class QwtPlotPanner;
|
||||
class QwtScaleWidget;
|
||||
|
@ -444,7 +444,6 @@ void SlsQt1DPlot::SetLog(int axisId, bool yes) {
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
void SlsQt1DPlot::EnableRoiBox(std::array<int, 4> roi) {
|
||||
if (roiBox == nullptr) {
|
||||
roiBox = new QwtPlotShapeItem();
|
||||
@ -465,7 +464,6 @@ void SlsQt1DPlot::DisableRoiBox() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SlsQt1DPlot::UnZoom() {
|
||||
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
|
||||
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
|
||||
|
@ -59,7 +59,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
case 'f':
|
||||
fname = optarg;
|
||||
LOG(sls::logDEBUG) << long_options[option_index].name << " " << optarg;
|
||||
LOG(sls::logDEBUG)
|
||||
<< long_options[option_index].name << " " << optarg;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
@ -101,7 +102,8 @@ int main(int argc, char **argv) {
|
||||
app.exec();
|
||||
} catch (const std::exception &e) {
|
||||
sls::qDefs::Message(sls::qDefs::CRITICAL,
|
||||
std::string(e.what()) + "\nExiting Gui :'( ", "main");
|
||||
std::string(e.what()) + "\nExiting Gui :'( ",
|
||||
"main");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -243,16 +245,14 @@ void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
|
||||
default:
|
||||
std::ostringstream os;
|
||||
os << det->getHostname() << " has "
|
||||
<< ToString(det->getDetectorType().squash())
|
||||
<< " detector type (" << std::to_string(detType)
|
||||
<< "). Exiting GUI.";
|
||||
<< ToString(det->getDetectorType().squash()) << " detector type ("
|
||||
<< std::to_string(detType) << "). Exiting GUI.";
|
||||
std::string errorMess = os.str();
|
||||
throw RuntimeError(errorMess.c_str());
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << "SLS Detector GUI : "
|
||||
<< ToString(det->getDetectorType().squash()) << " - "
|
||||
<< det->getHostname();
|
||||
os << "SLS Detector GUI : " << ToString(det->getDetectorType().squash())
|
||||
<< " - " << det->getHostname();
|
||||
std::string title = os.str();
|
||||
LOG(logINFO) << title;
|
||||
setWindowTitle(QString(title.c_str()));
|
||||
@ -344,7 +344,8 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
enable = actionExpert->isChecked();
|
||||
|
||||
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);
|
||||
actionSaveTrimbits->setVisible(visible);
|
||||
tabSettings->SetExportMode(enable);
|
||||
|
@ -628,7 +628,6 @@ void qDrawPlot::SetGapPixels(bool enable) {
|
||||
isGapPixels = enable;
|
||||
}
|
||||
|
||||
|
||||
void qDrawPlot::GetStatistics(double &min, double &max, double &sum) {
|
||||
LOG(logDEBUG) << "Calculating Statistics";
|
||||
double *array = data2d;
|
||||
@ -782,12 +781,12 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
rxRoi.xmax += ((rxRoi.xmax / 1024) * 6 + (rxRoi.xmax / 256) * 2);
|
||||
rxRoi.ymin += ((rxRoi.ymin / 512) * 34 + (rxRoi.ymin / 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);
|
||||
}
|
||||
|
||||
|
||||
// 1d check if npixelX has changed (m3 for different counters enabled)
|
||||
if (is1d && static_cast<int>(nPixelsX) != data->nx) {
|
||||
nPixelsX = data->nx;
|
||||
@ -1034,16 +1033,21 @@ void qDrawPlot::Update1dPlot() {
|
||||
}
|
||||
lblRxRoiEnabled->hide();
|
||||
} 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) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
// ymin and ymax could change (so replot roi every time)
|
||||
if (!rxRoi.completeRoi()) {
|
||||
plot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax, (int)plot1d->GetYMinimum(), (int)plot1d->GetYMaximum()});
|
||||
plot1d->EnableRoiBox(std::array<int, 4>{rxRoi.xmin, rxRoi.xmax,
|
||||
(int)plot1d->GetYMinimum(),
|
||||
(int)plot1d->GetYMaximum()});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
qTabAdvanced::qTabAdvanced(QWidget *parent, Detector *detector,
|
||||
qDrawPlot *p)
|
||||
qTabAdvanced::qTabAdvanced(QWidget *parent, Detector *detector, qDrawPlot *p)
|
||||
: QWidget(parent), det(detector), plot(p) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
@ -445,8 +444,7 @@ void qTabAdvanced::SetDetectorUDPIP(bool force) {
|
||||
std::string s = dispDetectorUDPIP->text().toAscii().constData();
|
||||
LOG(logINFO) << "Setting Detector UDP IP:" << s;
|
||||
try {
|
||||
det->setSourceUDPIP(IpAddr{s},
|
||||
{comboDetector->currentIndex()});
|
||||
det->setSourceUDPIP(IpAddr{s}, {comboDetector->currentIndex()});
|
||||
}
|
||||
CATCH_HANDLE("Could not set Detector UDP IP.",
|
||||
"qTabAdvanced::SetDetectorUDPIP", this,
|
||||
@ -463,8 +461,7 @@ void qTabAdvanced::SetDetectorUDPMAC(bool force) {
|
||||
std::string s = dispDetectorUDPMAC->text().toAscii().constData();
|
||||
LOG(logINFO) << "Setting Detector UDP MAC:" << s;
|
||||
try {
|
||||
det->setSourceUDPMAC(MacAddr{s},
|
||||
{comboDetector->currentIndex()});
|
||||
det->setSourceUDPMAC(MacAddr{s}, {comboDetector->currentIndex()});
|
||||
}
|
||||
CATCH_HANDLE("Could not set Detector UDP MAC.",
|
||||
"qTabAdvanced::SetDetectorUDPMAC", this,
|
||||
@ -491,8 +488,7 @@ void qTabAdvanced::SetCltZMQIP(bool force) {
|
||||
std::string s = dispZMQIP->text().toAscii().constData();
|
||||
LOG(logINFO) << "Setting Client ZMQ IP:" << s;
|
||||
try {
|
||||
det->setClientZmqIp(IpAddr{s},
|
||||
{comboDetector->currentIndex()});
|
||||
det->setClientZmqIp(IpAddr{s}, {comboDetector->currentIndex()});
|
||||
}
|
||||
CATCH_HANDLE("Could not set Client ZMQ IP.",
|
||||
"qTabAdvanced::SetCltZMQIP", this,
|
||||
|
@ -255,7 +255,8 @@ void qTabSettings::GetHighVoltage() {
|
||||
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
|
||||
@ -296,8 +297,7 @@ void qTabSettings::GetHighVoltage() {
|
||||
}
|
||||
}
|
||||
}
|
||||
CATCH_DISPLAY("Could not get high voltage.",
|
||||
"qTabSettings::GetHighVoltage")
|
||||
CATCH_DISPLAY("Could not get high voltage.", "qTabSettings::GetHighVoltage")
|
||||
connect(spinHV, SIGNAL(valueChanged(int)), this, SLOT(SetHighVoltage()));
|
||||
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetHighVoltage()));
|
||||
@ -515,8 +515,7 @@ void qTabSettings::SetThresholdEnergies() {
|
||||
slsDetectorDefs::detectorSettings sett =
|
||||
static_cast<slsDetectorDefs::detectorSettings>(
|
||||
comboSettings->currentIndex());
|
||||
LOG(logINFO) << "Setting Threshold Energies to " << ToString(eV)
|
||||
<< " (eV)";
|
||||
LOG(logINFO) << "Setting Threshold Energies to " << ToString(eV) << " (eV)";
|
||||
try {
|
||||
det->setThresholdEnergy(eV, sett);
|
||||
}
|
||||
@ -555,8 +554,7 @@ void qTabSettings::GetCounterMask() {
|
||||
// if retval[i] = 2, chkCounter2 is checked
|
||||
for (auto i : retval) {
|
||||
if (i > 3) {
|
||||
throw RuntimeError(
|
||||
std::string("Unknown counter index : ") +
|
||||
throw RuntimeError(std::string("Unknown counter index : ") +
|
||||
std::to_string(static_cast<int>(i)));
|
||||
}
|
||||
counters[i]->setChecked(true);
|
||||
|
@ -1150,8 +1150,10 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
LOG(logINFO, ("Setting module with settings %d\n", myMod.reg));
|
||||
|
||||
if (((myMod.nchan) > (detectorModules->nchan)) || ((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");
|
||||
if (((myMod.nchan) > (detectorModules->nchan)) ||
|
||||
((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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -2219,7 +2221,6 @@ int setTrimbits(int* chanregs, char* mess) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int setAllTrimbits(int val) {
|
||||
LOG(logINFO, ("Setting all trimbits to %d\n", val));
|
||||
#ifndef VIRTUAL
|
||||
|
@ -862,7 +862,8 @@ int setROI(ROI arg) {
|
||||
rois.ymin = -1;
|
||||
rois.ymax = -1;
|
||||
} 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
|
||||
// xmin divisible by 256 and less than 1280
|
||||
if (((arg.xmin % NCHAN_PER_ADC) != 0) ||
|
||||
@ -896,7 +897,8 @@ ROI getROI() {
|
||||
if (rois.xmin == -1) {
|
||||
LOG(logINFO, ("\tROI: None\n"));
|
||||
} 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;
|
||||
}
|
||||
|
@ -572,7 +572,6 @@
|
||||
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
|
||||
#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
|
||||
|
||||
|
||||
/* Pattern Loop 3 Address RW regiser */
|
||||
#define PATTERN_LOOP_3_ADDR_REG (0x84 << MEM_MAP_SHIFT)
|
||||
|
||||
|
@ -488,7 +488,6 @@ void setupDetector() {
|
||||
// dynamic range
|
||||
setDynamicRange(DEFAULT_DYNAMIC_RANGE);
|
||||
|
||||
|
||||
// Initialization of acquistion parameters
|
||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||
setNumTriggers(DEFAULT_NUM_CYCLES);
|
||||
@ -1302,8 +1301,10 @@ void getModule(sls_detector_module* myMod) {
|
||||
int setModule(sls_detector_module myMod, char *mess) {
|
||||
LOG(logINFO, ("Setting module\n"));
|
||||
|
||||
if (((myMod.nchan) > (detectorModules->nchan)) || ((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");
|
||||
if (((myMod.nchan) > (detectorModules->nchan)) ||
|
||||
((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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -1359,7 +1360,8 @@ int setTrimbits(int *trimbits) {
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
|
||||
// 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,
|
||||
("Could not start trimming. Could not set to trimming clock\n"));
|
||||
return FAIL;
|
||||
@ -2271,7 +2273,8 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
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) {
|
||||
LOG(logERROR, ("Unknown clock index %d to set clock divider\n", ind));
|
||||
return FAIL;
|
||||
@ -2470,7 +2473,8 @@ void *start_timer(void *arg) {
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)i;
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
@ -2492,7 +2496,6 @@ void *start_timer(void *arg) {
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(expUs);
|
||||
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||
@ -2712,7 +2715,8 @@ int setChipStatusRegister(int csr) {
|
||||
uint32_t prevRunClk = clkDivider[SYSTEM_C0];
|
||||
|
||||
// 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,
|
||||
("Could not set to trimming clock in order to change CSR\n"));
|
||||
return FAIL;
|
||||
|
@ -29,9 +29,10 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
ssize_t fsize, int forceDeleteNormalFile);
|
||||
int getDrive(char *mess, enum PROGRAM_INDEX index);
|
||||
/** Notify fpga not to touch flash, open src and flash drive to write */
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd,
|
||||
FILE **srcfd, int forceDeleteNormalFile);
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index,
|
||||
int forceDeleteNormalFile);
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile);
|
||||
int eraseFlash(char *mess);
|
||||
/* write from tmp file to flash */
|
||||
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd);
|
||||
|
@ -569,7 +569,8 @@ int getFrequency(enum CLKINDEX ind);
|
||||
int getVCOFrequency(enum CLKINDEX ind);
|
||||
int getMaxClockDivider();
|
||||
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);
|
||||
|
||||
#elif GOTTHARD2D
|
||||
|
@ -411,14 +411,14 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
LOG(level, ("Sending Module\n"));
|
||||
int ts = 0, n = 0;
|
||||
|
||||
n = sendData(file_des, &(myMod->serialnumber),
|
||||
sizeof(myMod->serialnumber), INT32);
|
||||
n = sendData(file_des, &(myMod->serialnumber), sizeof(myMod->serialnumber),
|
||||
INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
LOG(level, ("serialno sent %d bytes. serialno: %d\n", n,
|
||||
myMod->serialnumber));
|
||||
LOG(level,
|
||||
("serialno sent %d bytes. serialno: %d\n", n, myMod->serialnumber));
|
||||
n = sendData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
@ -448,8 +448,7 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
LOG(level,
|
||||
("iodelay sent %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||
LOG(level, ("iodelay sent %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||
n = sendData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
@ -494,8 +493,8 @@ int receiveModule(int file_des, sls_detector_module *myMod) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
LOG(level, ("serialno received %d bytes. serialno: %d\n", n,
|
||||
myMod->serialnumber));
|
||||
LOG(level,
|
||||
("serialno received %d bytes. serialno: %d\n", n, myMod->serialnumber));
|
||||
n = receiveData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
@ -525,8 +524,7 @@ int receiveModule(int file_des, sls_detector_module *myMod) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
LOG(level,
|
||||
("iodelay received %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||
LOG(level, ("iodelay received %d bytes. iodelay: %d\n", n, myMod->iodelay));
|
||||
n = receiveData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
|
@ -164,8 +164,10 @@ void writePatternWord(int addr, uint64_t word) {
|
||||
int validate_getPatternWaitAddresses(char *message, int level, int *addr) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(message,
|
||||
"Cannot get patwait address. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
sprintf(
|
||||
message,
|
||||
"Cannot get patwait address. Level %d must be between 0 and %d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -203,8 +205,10 @@ int getPatternWaitAddress(int level) {
|
||||
int validate_setPatternWaitAddresses(char *message, int level, int addr) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(message,
|
||||
"Cannot set patwait address. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
sprintf(
|
||||
message,
|
||||
"Cannot set patwait address. Level %d must be between 0 and %d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -274,7 +278,8 @@ int validate_getPatternWaitTime(char *message, int level, uint64_t *waittime) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -313,7 +318,8 @@ int validate_setPatternWaitTime(char *message, int level, uint64_t waittime) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -376,7 +382,8 @@ int validate_getPatternLoopCycles(char *message, int level, int *numLoops) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -409,7 +416,8 @@ int validate_setPatternLoopCycles(char *message, int level, int numLoops) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -519,9 +527,10 @@ int validate_getPatternLoopAddresses(char *message, int level, int *startAddr,
|
||||
int *stopAddr) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(
|
||||
message,
|
||||
"Cannot get patloop addresses. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
sprintf(message,
|
||||
"Cannot get patloop addresses. Level %d must be between 0 and "
|
||||
"%d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -591,9 +600,10 @@ int validate_setPatternLoopAddresses(char *message, int level, int startAddr,
|
||||
int stopAddr) {
|
||||
// validate input
|
||||
if (level < 0 || level >= MAX_LEVELS) {
|
||||
sprintf(
|
||||
message,
|
||||
"Cannot set patloop addresses. Level %d must be between 0 and %d.\n", level, MAX_LEVELS - 1);
|
||||
sprintf(message,
|
||||
"Cannot set patloop addresses. Level %d must be between 0 and "
|
||||
"%d.\n",
|
||||
level, MAX_LEVELS - 1);
|
||||
LOG(logERROR, (message));
|
||||
return FAIL;
|
||||
}
|
||||
@ -975,8 +985,8 @@ int loadPatternFile(char *patFname, char *errMessage) {
|
||||
int startAddr = 0;
|
||||
int stopAddr = 0;
|
||||
// cannot scan values
|
||||
if (sscanf(line, "%s %d 0x%x 0x%x", command, &level, &startAddr, &stopAddr) !=
|
||||
4) {
|
||||
if (sscanf(line, "%s %d 0x%x 0x%x", command, &level, &startAddr,
|
||||
&stopAddr) != 4) {
|
||||
strcpy(temp, "Could not scan patloop arguments.\n");
|
||||
break;
|
||||
}
|
||||
|
@ -110,7 +110,8 @@ int defineGPIOpins(char *mess) {
|
||||
if (access(CMD_GPIO9_EXIST, F_OK) != 0) {
|
||||
if (executeCommand(CMD_GPIO9_DEFINE, retvals, logDEBUG1) == FAIL) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -146,7 +147,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
// define gpio9 as output
|
||||
if (executeCommand(CMD_GPIO9_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -156,7 +158,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DEFINE_OUT, retvals, logDEBUG1) == FAIL) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -166,7 +169,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
// tell FPGA to not: gpio9
|
||||
if (executeCommand(CMD_GPIO9_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
||||
FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio9 (nConfig) to not touch flash for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
@ -178,7 +182,8 @@ int FPGAdontTouchFlash(char *mess, int programming) {
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DONT_TOUCH_FLASH, retvals, logDEBUG1) ==
|
||||
FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not set gpio3 (nCE) to not touch flash for fpga (%s)\n",
|
||||
retvals);
|
||||
LOG(logERROR, (mess));
|
||||
@ -198,7 +203,8 @@ int FPGATouchFlash(char *mess, int programming) {
|
||||
// tell FPGA to touch flash to program itself
|
||||
if (executeCommand(CMD_GPIO9_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -207,7 +213,8 @@ int FPGATouchFlash(char *mess, int programming) {
|
||||
if (programming && latestKernelVerified == 1) {
|
||||
if (executeCommand(CMD_GPIO3_DEFINE_IN, retvals, logDEBUG1) == FAIL) {
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -341,8 +348,8 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
|
||||
FILE *flashfd = NULL;
|
||||
FILE *srcfd = NULL;
|
||||
if (openFileForFlash(mess, index, &flashfd, &srcfd, forceDeleteNormalFile) ==
|
||||
FAIL) {
|
||||
if (openFileForFlash(mess, index, &flashfd, &srcfd,
|
||||
forceDeleteNormalFile) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -446,8 +453,8 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
|
||||
int forceDeleteNormalFile) {
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd,
|
||||
FILE **srcfd, int forceDeleteNormalFile) {
|
||||
// open src file
|
||||
*srcfd = fopen(TEMP_PROG_FILE_NAME, "r");
|
||||
if (*srcfd == NULL) {
|
||||
@ -480,13 +487,13 @@ int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE
|
||||
return OK;
|
||||
}
|
||||
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile) {
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index,
|
||||
int forceDeleteNormalFile) {
|
||||
#ifndef VIRTUAL
|
||||
// check if its a normal file or special file
|
||||
struct stat buf;
|
||||
if (stat(flashDriveName, &buf) == -1) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to find the flash drive %s\n",
|
||||
sprintf(mess, "Could not %s. Unable to find the flash drive %s\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
@ -507,9 +514,12 @@ int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalF
|
||||
// user does not allow to fix it (default)
|
||||
if (forceDeleteNormalFile == 0) {
|
||||
sprintf(mess,
|
||||
"Could not %s. The flash drive %s found for fpga programming is a normal file. To "
|
||||
"fix this (by deleting this file, creating the flash drive and proceeding with "
|
||||
"programming), re-run the programming command 'programfpga' with parameter "
|
||||
"Could not %s. The flash drive %s found for fpga "
|
||||
"programming is a normal file. To "
|
||||
"fix this (by deleting this file, creating the flash drive "
|
||||
"and proceeding with "
|
||||
"programming), re-run the programming command "
|
||||
"'programfpga' with parameter "
|
||||
"'--force-delete-normal-file'\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
@ -517,7 +527,8 @@ int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalF
|
||||
}
|
||||
|
||||
// fpga memory stays after a reboot, user allowed to fix it
|
||||
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
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
@ -678,7 +689,8 @@ int waitForFPGAtoTouchFlash(char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#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 result = 0;
|
||||
@ -718,6 +730,7 @@ int waitForFPGAtoTouchFlash(char *mess) {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
/* global variables */
|
||||
|
||||
@ -151,8 +151,7 @@ int openFileForFlash(char *mess, FILE **flashfd) {
|
||||
// check if its a normal file or special file
|
||||
struct stat buf;
|
||||
if (stat(flashDriveName, &buf) == -1) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to find the flash drive %s\n",
|
||||
sprintf(mess, "Could not %s. Unable to find the flash drive %s\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
|
@ -1605,7 +1605,8 @@ int get_module(int file_des) {
|
||||
|
||||
// ensure nchan is not 0, else trimbits not copied
|
||||
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));
|
||||
return FAIL;
|
||||
}
|
||||
@ -1625,7 +1626,6 @@ int get_module(int file_des) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int set_module(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -1885,7 +1885,8 @@ int acquire(int blocking, int file_des) {
|
||||
uint64_t sourcemac = getDetectorMAC();
|
||||
char src_mac[MAC_ADDRESS_SIZE];
|
||||
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
|
||||
sprintf(mess,
|
||||
sprintf(
|
||||
mess,
|
||||
"Invalid udp source mac address for this detector. Must be "
|
||||
"same as hardware detector mac address %s\n",
|
||||
src_mac);
|
||||
@ -1898,7 +1899,8 @@ int acquire(int blocking, int file_des) {
|
||||
getIpAddressinString(src_ip, sourceip);
|
||||
sprintf(
|
||||
mess,
|
||||
"Invalid udp source ip address for this detector. Must be same "
|
||||
"Invalid udp source ip address for this detector. Must be "
|
||||
"same "
|
||||
"as hardware detector ip address %s in 1G readout mode \n",
|
||||
src_ip);
|
||||
LOG(logERROR, (mess));
|
||||
@ -2118,7 +2120,8 @@ int set_num_frames(int file_des) {
|
||||
arg > MAX_FRAMES_IN_BURST_MODE) {
|
||||
ret = FAIL;
|
||||
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",
|
||||
(long long unsigned int)arg, MAX_FRAMES_IN_BURST_MODE);
|
||||
LOG(logERROR, (mess));
|
||||
@ -9260,11 +9263,12 @@ int clear_all_udp_dst(int file_des) {
|
||||
#endif
|
||||
{
|
||||
numUdpDestinations = numdest;
|
||||
LOG(logINFOBLUE, ("Number of UDP Destinations: %d\n",
|
||||
numUdpDestinations));
|
||||
LOG(logINFOBLUE,
|
||||
("Number of UDP Destinations: %d\n", numUdpDestinations));
|
||||
ret = configureMAC();
|
||||
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));
|
||||
}
|
||||
}
|
||||
@ -9968,7 +9972,8 @@ int set_interpolation(int file_des) {
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (getPumpProbe() && arg) {
|
||||
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));
|
||||
} else {
|
||||
ret = setInterpolation(arg);
|
||||
@ -10024,7 +10029,8 @@ int set_pump_probe(int file_des) {
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (getInterpolation() && arg) {
|
||||
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));
|
||||
} else {
|
||||
ret = setPumpProbe(arg);
|
||||
@ -10033,7 +10039,8 @@ int set_pump_probe(int file_des) {
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace sls {
|
||||
using ns = std::chrono::nanoseconds;
|
||||
class detectorData;
|
||||
@ -144,7 +143,8 @@ class Detector {
|
||||
defs::detectorSettings settings = defs::STANDARD,
|
||||
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,
|
||||
defs::detectorSettings settings = defs::STANDARD,
|
||||
bool trimbits = true, Positions pos = {});
|
||||
@ -1495,13 +1495,15 @@ class Detector {
|
||||
/** [Mythen3] */
|
||||
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 = {});
|
||||
|
||||
/** [Mythen3] */
|
||||
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 = {});
|
||||
|
||||
/** [Mythen3] */
|
||||
|
@ -11,11 +11,22 @@ namespace sls {
|
||||
*/
|
||||
class detectorData {
|
||||
public:
|
||||
detectorData(double progressIndex, std::string fileName, int nx, int ny, 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)
|
||||
: 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)
|
||||
: progressIndex(progressIndex), fileName(fileName), fileIndex(fileIndex), nx(nx), ny(ny), data(data), databytes(databytes), dynamicRange(dynamicRange), completeImage(completeImage), rxRoi(rxRoi) {};
|
||||
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)
|
||||
: 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
|
||||
*/
|
||||
|
@ -48,8 +48,8 @@ void CmdProxy::Call(const std::string &command,
|
||||
if (it != functions.end()) {
|
||||
os << ((*this).*(it->second))(action);
|
||||
} else {
|
||||
throw RuntimeError(
|
||||
cmd + " Unknown command, use list to list all commands");
|
||||
throw RuntimeError(cmd +
|
||||
" Unknown command, use list to list all commands");
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,12 +219,10 @@ std::string CmdProxy::Acquire(int action) {
|
||||
<< '\n';
|
||||
} else {
|
||||
if (det->empty()) {
|
||||
throw RuntimeError(
|
||||
"This shared memory has no detectors added.");
|
||||
throw RuntimeError("This shared memory has no detectors added.");
|
||||
}
|
||||
if (det_id >= 0) {
|
||||
throw RuntimeError(
|
||||
"Individual detectors not allowed for readout.");
|
||||
throw RuntimeError("Individual detectors not allowed for readout.");
|
||||
}
|
||||
|
||||
det->acquire();
|
||||
@ -456,7 +454,10 @@ std::string CmdProxy::Trimbits(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
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';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
@ -476,7 +477,6 @@ std::string CmdProxy::Trimbits(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
std::string CmdProxy::TrimEnergies(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
@ -553,8 +553,7 @@ std::string CmdProxy::Exptime(int action) {
|
||||
} else if (cmd == "exptime3") {
|
||||
gateIndex = 2;
|
||||
} else {
|
||||
throw RuntimeError(
|
||||
"Unknown command, use list to list all commands");
|
||||
throw RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
|
||||
std::ostringstream os;
|
||||
@ -699,8 +698,7 @@ std::string CmdProxy::Adcphase(int action) {
|
||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||
det_type == defs::GOTTHARD2) {
|
||||
throw RuntimeError(
|
||||
"adcphase not implemented for this detector");
|
||||
throw RuntimeError("adcphase not implemented for this detector");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
@ -710,8 +708,7 @@ std::string CmdProxy::Adcphase(int action) {
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw RuntimeError("Unknown adcphase argument " +
|
||||
args[0] +
|
||||
". Did you mean deg? ");
|
||||
args[0] + ". Did you mean deg? ");
|
||||
}
|
||||
t = det->getADCPhaseInDegrees(std::vector<int>{det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
@ -754,8 +751,7 @@ std::string CmdProxy::Dbitphase(int action) {
|
||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||
det_type == defs::GOTTHARD2) {
|
||||
throw RuntimeError(
|
||||
"dbitphase not implemented for this detector");
|
||||
throw RuntimeError("dbitphase not implemented for this detector");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
Result<int> t;
|
||||
@ -764,8 +760,8 @@ std::string CmdProxy::Dbitphase(int action) {
|
||||
os << OutString(t) << '\n';
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] != "deg") {
|
||||
throw RuntimeError("Unknown dbitphase argument " +
|
||||
args[0] + ". Did you mean deg? ");
|
||||
throw RuntimeError("Unknown dbitphase argument " + args[0] +
|
||||
". Did you mean deg? ");
|
||||
}
|
||||
t = det->getDBITPhaseInDegrees(std::vector<int>{det_id});
|
||||
os << OutString(t) << " deg\n";
|
||||
@ -805,8 +801,7 @@ std::string CmdProxy::ClockFrequency(int action) {
|
||||
} else {
|
||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||
throw RuntimeError(
|
||||
"clkfreq not implemented for this detector.");
|
||||
throw RuntimeError("clkfreq not implemented for this detector.");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
@ -836,8 +831,7 @@ std::string CmdProxy::ClockPhase(int action) {
|
||||
} else {
|
||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||
throw RuntimeError(
|
||||
"clkphase not implemented for this detector.");
|
||||
throw RuntimeError("clkphase not implemented for this detector.");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (args.size() == 1) {
|
||||
@ -919,8 +913,7 @@ std::string CmdProxy::ClockDivider(int action) {
|
||||
} else {
|
||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||
throw RuntimeError(
|
||||
"clkdiv not implemented for this detector.");
|
||||
throw RuntimeError("clkdiv not implemented for this detector.");
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
@ -1177,8 +1170,7 @@ std::string CmdProxy::DacList(const int action) {
|
||||
"names. Cannot change them.");
|
||||
}
|
||||
if (det_id != -1) {
|
||||
throw RuntimeError(
|
||||
"Cannot configure dacnames at module level");
|
||||
throw RuntimeError("Cannot configure dacnames at module level");
|
||||
}
|
||||
if (args.size() != 18) {
|
||||
WrongNumberOfParameters(18);
|
||||
@ -1543,7 +1535,11 @@ std::string CmdProxy::UDPSourceIP(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
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';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
auto t = det->getSourceUDPIP(std::vector<int>{det_id});
|
||||
@ -1576,7 +1572,11 @@ std::string CmdProxy::UDPSourceIP2(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
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';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
auto t = det->getSourceUDPIP2(std::vector<int>{det_id});
|
||||
@ -1591,8 +1591,8 @@ std::string CmdProxy::UDPSourceIP2(int action) {
|
||||
IpAddr val;
|
||||
if (args[0] == "auto") {
|
||||
val = getIpFromAuto();
|
||||
LOG(logINFO) << "Setting udp_srcip2 of detector " << det_id << " to "
|
||||
<< val;
|
||||
LOG(logINFO) << "Setting udp_srcip2 of detector " << det_id
|
||||
<< " to " << val;
|
||||
} else {
|
||||
val = IpAddr(args[0]);
|
||||
}
|
||||
@ -1744,7 +1744,8 @@ std::string CmdProxy::Rx_ROI(int action) {
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
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';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
@ -2144,8 +2145,7 @@ std::string CmdProxy::VetoFile(int action) {
|
||||
"file should have 128 rows of gain index and 12 bit value in dec"
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw RuntimeError(
|
||||
"cannot get vetofile. Did you mean vetophoton?");
|
||||
throw RuntimeError("cannot get vetofile. Did you mean vetophoton?");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
@ -2266,8 +2266,7 @@ std::string CmdProxy::VetoAlgorithm(int action) {
|
||||
defs::streamingInterface interface =
|
||||
StringTo<defs::streamingInterface>(args[0]);
|
||||
if (interface == defs::streamingInterface::NONE) {
|
||||
throw RuntimeError(
|
||||
"Must specify an interface to set algorithm");
|
||||
throw RuntimeError("Must specify an interface to set algorithm");
|
||||
}
|
||||
auto t = det->getVetoAlgorithm(interface, std::vector<int>{det_id});
|
||||
os << OutString(t) << ' ' << ToString(interface) << '\n';
|
||||
@ -2279,8 +2278,7 @@ std::string CmdProxy::VetoAlgorithm(int action) {
|
||||
defs::streamingInterface interface =
|
||||
StringTo<defs::streamingInterface>(args[1]);
|
||||
if (interface == defs::streamingInterface::NONE) {
|
||||
throw RuntimeError(
|
||||
"Must specify an interface to set algorithm");
|
||||
throw RuntimeError("Must specify an interface to set algorithm");
|
||||
}
|
||||
det->setVetoAlgorithm(alg, interface, std::vector<int>{det_id});
|
||||
os << ToString(alg) << ' ' << ToString(interface) << '\n';
|
||||
@ -2368,7 +2366,9 @@ std::string CmdProxy::Counters(int action) {
|
||||
if (args.empty()) {
|
||||
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");
|
||||
}
|
||||
// convert vector to counter enable mask
|
||||
@ -2402,8 +2402,7 @@ std::string CmdProxy::GateDelay(int action) {
|
||||
} else if (cmd == "gatedelay3") {
|
||||
gateIndex = 2;
|
||||
} else {
|
||||
throw RuntimeError(
|
||||
"Unknown command, use list to list all commands");
|
||||
throw RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
|
||||
std::ostringstream os;
|
||||
@ -2705,12 +2704,17 @@ std::string CmdProxy::PatternWord(int action) {
|
||||
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) {
|
||||
++nGetArgs;
|
||||
++nPutArgs;
|
||||
} 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) {
|
||||
WrongNumberOfParameters(nGetArgs);
|
||||
@ -2725,9 +2729,9 @@ void CmdProxy::GetLevelAndUpdateArgIndex(int action, std::string levelSeparatedC
|
||||
}
|
||||
|
||||
std::string CmdProxy::PatternLoopAddresses(int action) {
|
||||
if (cmd != "patlimits" && cmd != "patloop0" && cmd != "patloop1" && cmd != "patloop2" && cmd != "patloop") {
|
||||
throw RuntimeError(
|
||||
"Unknown command, use list to list all commands");
|
||||
if (cmd != "patlimits" && cmd != "patloop0" && cmd != "patloop1" &&
|
||||
cmd != "patloop2" && cmd != "patloop") {
|
||||
throw RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
@ -2737,17 +2741,17 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
|
||||
"of complete pattern."
|
||||
<< '\n';
|
||||
} else if (cmd == "patloop") {
|
||||
os << "[0-6] [start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of the loop level provided."
|
||||
<< "\n\t[Mythen3] Level options: 0-3 only."
|
||||
<< '\n';
|
||||
os << "[0-6] [start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] "
|
||||
"Limits of the loop level provided."
|
||||
<< "\n\t[Mythen3] Level options: 0-3 only." << '\n';
|
||||
} else {
|
||||
os << "Depreciated command. Use patloop."
|
||||
<< '\n';
|
||||
os << "Depreciated command. Use patloop." << '\n';
|
||||
}
|
||||
} else {
|
||||
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
|
||||
if (cmd != "patlimits") {
|
||||
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, nPutArgs);
|
||||
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs,
|
||||
nPutArgs);
|
||||
}
|
||||
if (action == defs::GET_ACTION) {
|
||||
auto t =
|
||||
@ -2768,25 +2772,25 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
|
||||
}
|
||||
|
||||
std::string CmdProxy::PatternLoopCycles(int action) {
|
||||
if (cmd != "patnloop0" && cmd != "patnloop1" && cmd != "patnloop2" && cmd != "patnloop") {
|
||||
throw RuntimeError(
|
||||
"Unknown command, use list to list all commands");
|
||||
if (cmd != "patnloop0" && cmd != "patnloop1" && cmd != "patnloop2" &&
|
||||
cmd != "patnloop") {
|
||||
throw RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
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."
|
||||
<< "\n\t[Mythen3] Level options: 0-3 only."
|
||||
<< '\n';
|
||||
<< "\n\t[Mythen3] Level options: 0-3 only." << '\n';
|
||||
} else {
|
||||
os << "Depreciated command. Use patnloop."
|
||||
<< '\n';
|
||||
os << "Depreciated command. Use patnloop." << '\n';
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
@ -2802,15 +2806,16 @@ std::string CmdProxy::PatternLoopCycles(int action) {
|
||||
}
|
||||
|
||||
std::string CmdProxy::PatternWaitAddress(int action) {
|
||||
if (cmd != "patwait0" && cmd != "patwait1" && cmd != "patwait2" && cmd != "patwait") {
|
||||
throw RuntimeError(
|
||||
"Unknown command, use list to list all commands");
|
||||
if (cmd != "patwait0" && cmd != "patwait1" && cmd != "patwait2" &&
|
||||
cmd != "patwait") {
|
||||
throw RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
if (cmd == "patwait") {
|
||||
os << "[0-6] [addr] \n\t[Ctb][Moench][Mythen3] Wait address for loop level provided."
|
||||
os << "[0-6] [addr] \n\t[Ctb][Moench][Mythen3] Wait address for "
|
||||
"loop level provided."
|
||||
<< "\n\t[Mythen3] Level options: 0-3 only.";
|
||||
} else {
|
||||
os << "Depreciated command. Use patwait.";
|
||||
@ -2818,7 +2823,8 @@ std::string CmdProxy::PatternWaitAddress(int action) {
|
||||
os << '\n';
|
||||
} else {
|
||||
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) {
|
||||
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
|
||||
os << OutStringHex(t, 4) << '\n';
|
||||
@ -2834,9 +2840,9 @@ std::string CmdProxy::PatternWaitAddress(int action) {
|
||||
}
|
||||
|
||||
std::string CmdProxy::PatternWaitTime(int action) {
|
||||
if (cmd != "patwaittime0" && cmd != "patwaittime1" && cmd != "patwaittime2" && cmd != "patwaittime") {
|
||||
throw RuntimeError(
|
||||
"Unknown command, use list to list all commands");
|
||||
if (cmd != "patwaittime0" && cmd != "patwaittime1" &&
|
||||
cmd != "patwaittime2" && cmd != "patwaittime") {
|
||||
throw RuntimeError("Unknown command, use list to list all commands");
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
@ -2844,15 +2850,14 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
||||
if (cmd == "patwaittime") {
|
||||
os << "[0-6] [n_clk] \n\t[Ctb][Moench][Mythen3] Wait time in clock "
|
||||
"cycles for the loop provided."
|
||||
<< "\n\t[Mythen3] Level options: 0-3 only."
|
||||
<< '\n';
|
||||
<< "\n\t[Mythen3] Level options: 0-3 only." << '\n';
|
||||
} else {
|
||||
os << "Depreciated command. Use patwaittime."
|
||||
<< '\n';
|
||||
os << "Depreciated command. Use patwaittime." << '\n';
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
@ -2965,8 +2970,7 @@ std::string CmdProxy::ProgramFpga(int action) {
|
||||
bool forceDeteleNormalFile = false;
|
||||
if (args.size() == 2) {
|
||||
if (args[1] != "--force-delete-normal-file") {
|
||||
throw RuntimeError(
|
||||
"Could not scan second argument. Did you "
|
||||
throw RuntimeError("Could not scan second argument. Did you "
|
||||
"mean --force-delete-normal-file?");
|
||||
}
|
||||
forceDeteleNormalFile = true;
|
||||
|
@ -254,8 +254,7 @@ namespace sls {
|
||||
os << OutString(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (det_id != -1) { \
|
||||
throw RuntimeError( \
|
||||
"Cannot execute this at module level"); \
|
||||
throw RuntimeError("Cannot execute this at module level"); \
|
||||
} \
|
||||
if (args.size() != 1) { \
|
||||
WrongNumberOfParameters(1); \
|
||||
@ -1196,7 +1195,10 @@ class CmdProxy {
|
||||
/* Pattern */
|
||||
std::string Pattern(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 PatternLoopCycles(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 "
|
||||
"empty. Default: 0");
|
||||
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr,
|
||||
"[x:x:x:x:x:x]\n\tMac address of the detector (source) udp "
|
||||
@ -1981,8 +1982,7 @@ class CmdProxy {
|
||||
"users only.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
gainmode, getGainMode, setGainMode,
|
||||
StringTo<slsDetectorDefs::gainMode>,
|
||||
gainmode, getGainMode, setGainMode, StringTo<slsDetectorDefs::gainMode>,
|
||||
"[dynamicgain|forceswitchg1|forceswitchg2|fixg1|fixg2|fixg0]\n\t["
|
||||
"Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 without caution, "
|
||||
"you can damage the detector!!!");
|
||||
@ -2047,11 +2047,15 @@ class CmdProxy {
|
||||
INTEGER_COMMAND_VEC_ID(interpolation, getInterpolation, setInterpolation,
|
||||
StringTo<int>,
|
||||
"[0, 1]\n\t[Mythen3] Enables or disables "
|
||||
"interpolation. Default is disabled. Interpolation mode enables all counters and disables vth3. Disabling sets back counter mask and vth3.");
|
||||
"interpolation. Default is disabled. Interpolation "
|
||||
"mode enables all counters and disables vth3. "
|
||||
"Disabling sets back counter mask and vth3.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(pumpprobe, getPumpProbe, setPumpProbe, StringTo<int>,
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
pumpprobe, getPumpProbe, setPumpProbe, StringTo<int>,
|
||||
"[0, 1]\n\t[Mythen3] Enables or disables pump probe "
|
||||
"mode. Default is disabled. Pump probe mode only enables vth2. Disabling sets back to previous value.");
|
||||
"mode. Default is disabled. Pump probe mode only enables vth2. "
|
||||
"Disabling sets back to previous value.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(apulse, getAnalogPulsing, setAnalogPulsing,
|
||||
StringTo<int>,
|
||||
|
@ -65,8 +65,6 @@ std::vector<std::string> CtbConfig::getDacNames() const {
|
||||
return names;
|
||||
}
|
||||
|
||||
const char* CtbConfig::shm_tag(){
|
||||
return shm_tag_;
|
||||
}
|
||||
const char *CtbConfig::shm_tag() { return shm_tag_; }
|
||||
|
||||
} // namespace sls
|
@ -3,7 +3,6 @@
|
||||
#include <vector>
|
||||
namespace sls {
|
||||
|
||||
|
||||
class CtbConfig {
|
||||
static constexpr size_t name_length = 20;
|
||||
static constexpr size_t num_dacs = 18;
|
||||
@ -27,5 +26,4 @@ class CtbConfig {
|
||||
static const char *shm_tag();
|
||||
};
|
||||
|
||||
|
||||
} // namespace sls
|
||||
|
@ -55,8 +55,7 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
|
||||
|
||||
using defs = slsDetectorDefs;
|
||||
|
||||
Detector::Detector(int shm_id)
|
||||
: pimpl(make_unique<DetectorImpl>(shm_id)) {}
|
||||
Detector::Detector(int shm_id) : pimpl(make_unique<DetectorImpl>(shm_id)) {}
|
||||
|
||||
Detector::~Detector() = default;
|
||||
|
||||
|
@ -185,8 +185,7 @@ void DetectorImpl::initializeMembers(bool verify) {
|
||||
// get objects from single det shared memory (open)
|
||||
for (int i = 0; i < shm()->totalNumberOfModules; i++) {
|
||||
try {
|
||||
modules.push_back(
|
||||
make_unique<Module>(detectorIndex, i, verify));
|
||||
modules.push_back(make_unique<Module>(detectorIndex, i, verify));
|
||||
} catch (...) {
|
||||
modules.clear();
|
||||
throw;
|
||||
@ -307,8 +306,7 @@ void DetectorImpl::addModule(const std::string &hostname) {
|
||||
}
|
||||
|
||||
auto pos = modules.size();
|
||||
modules.emplace_back(
|
||||
make_unique<Module>(type, detectorIndex, pos, false));
|
||||
modules.emplace_back(make_unique<Module>(type, detectorIndex, pos, false));
|
||||
shm()->totalNumberOfModules = modules.size();
|
||||
modules[pos]->setControlPort(port);
|
||||
modules[pos]->setStopPort(port + 1);
|
||||
@ -672,7 +670,6 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
<< "\n\t databytes: " << multisize
|
||||
<< "\n\t dynamicRange: " << dynamicRange;
|
||||
|
||||
|
||||
// send data to callback
|
||||
if (data) {
|
||||
char *callbackImage = multiframe.get();
|
||||
@ -1463,7 +1460,8 @@ defs::ROI DetectorImpl::getRxROI() const {
|
||||
auto t = Parallel(&Module::getRxROI, {});
|
||||
if (t.equal() && t.front().completeRoi()) {
|
||||
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();
|
||||
@ -1537,21 +1535,26 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
|
||||
throw RuntimeError("Invalid Roi of size 0.");
|
||||
}
|
||||
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) {
|
||||
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();
|
||||
bool is2D = (numChansPerMod.y > 1 ? true : false);
|
||||
defs::xy geometry = getPortGeometry();
|
||||
|
||||
if (!is2D && ((arg.ymin != -1 && arg.ymin != 0) || (arg.ymax != -1 && arg.ymax != 0))) {
|
||||
throw RuntimeError("Invalid Receiver roi. Cannot set 2d roi for a 1d detector.");
|
||||
if (!is2D && ((arg.ymin != -1 && arg.ymin != 0) ||
|
||||
(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.");
|
||||
}
|
||||
|
||||
@ -1576,7 +1579,8 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
|
||||
--moduleRoi.xmax;
|
||||
}
|
||||
} 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 {
|
||||
// get module limits
|
||||
@ -1625,7 +1629,9 @@ void DetectorImpl::setRxROI(const defs::ROI arg) {
|
||||
|
||||
// metadata
|
||||
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 {
|
||||
modules[0]->setRxROIMetadata(arg);
|
||||
}
|
||||
@ -1639,7 +1645,6 @@ void DetectorImpl::clearRxROI() {
|
||||
shm()->rx_roi.ymax = -1;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> DetectorImpl::getCtbDacNames() const {
|
||||
return ctb_shm()->getDacNames();
|
||||
}
|
||||
|
@ -2,20 +2,20 @@
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
|
||||
#include "CtbConfig.h"
|
||||
#include "SharedMemory.h"
|
||||
#include "sls/Result.h"
|
||||
#include "sls/logger.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "CtbConfig.h"
|
||||
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <numeric>
|
||||
#include <semaphore.h>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <future>
|
||||
#include <numeric>
|
||||
|
||||
namespace sls {
|
||||
|
||||
@ -142,8 +142,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel(void (Module::*somefunc)(CT...),
|
||||
std::vector<int> positions,
|
||||
void Parallel(void (Module::*somefunc)(CT...), std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
if (modules.empty())
|
||||
@ -296,8 +295,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
std::vector<char> readProgrammingFile(const std::string &fname);
|
||||
|
||||
void setNumberofUDPInterfaces(int n, Positions pos);
|
||||
Result<int> getDefaultDac(defs::dacIndex index,
|
||||
defs::detectorSettings sett,
|
||||
Result<int> getDefaultDac(defs::dacIndex index, defs::detectorSettings sett,
|
||||
Positions pos = {});
|
||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett, Positions pos);
|
||||
|
@ -237,15 +237,16 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
throw RuntimeError("This detector should have called with 3 energies");
|
||||
}
|
||||
if (shm()->trimEnergies.empty()) {
|
||||
throw RuntimeError(
|
||||
"Trim energies have not been defined for this module yet! Use trimen.");
|
||||
throw RuntimeError("Trim energies have not been defined for this "
|
||||
"module yet! Use trimen.");
|
||||
}
|
||||
|
||||
std::vector<int> energy(e_eV.begin(), e_eV.end());
|
||||
// if all energies are same
|
||||
if (allEqualTo(energy, energy[0])) {
|
||||
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);
|
||||
}
|
||||
@ -309,7 +310,9 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
trim2, trimbits);
|
||||
// csr
|
||||
if (myMod1.reg != myMod2.reg) {
|
||||
throw RuntimeError("setAllThresholdEnergy: chip shift register values do not match between files for energy (eV) " +
|
||||
throw RuntimeError(
|
||||
"setAllThresholdEnergy: chip shift register values do not "
|
||||
"match between files for energy (eV) " +
|
||||
std::to_string(energy[i]));
|
||||
}
|
||||
myMods[i].reg = myMod1.reg;
|
||||
@ -319,12 +322,10 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
sls_detector_module myMod{shm()->detType};
|
||||
myMod = myMods[0];
|
||||
|
||||
|
||||
// if multiple thresholds, combine
|
||||
if (myMods.size() > 1) {
|
||||
auto counters = getSetBits(getCounterMask());
|
||||
|
||||
|
||||
// average vtrim of enabled counters
|
||||
int sum = 0;
|
||||
for (size_t i = 0; i < counters.size(); ++i) {
|
||||
@ -364,7 +365,9 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
}
|
||||
// csr
|
||||
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) {
|
||||
if (it < 0 || it > 63) {
|
||||
throw RuntimeError(
|
||||
"Dbit list value must be between 0 and 63\n");
|
||||
throw RuntimeError("Dbit list value must be between 0 and 63\n");
|
||||
}
|
||||
}
|
||||
std::sort(begin(list), end(list));
|
||||
@ -3297,8 +3299,8 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
|
||||
}
|
||||
}
|
||||
if (out_of_range) {
|
||||
LOG(logWARNING)
|
||||
<< "Some trimbits were out of range, these have been replaced with 0 or 63.";
|
||||
LOG(logWARNING) << "Some trimbits were out of range, these have "
|
||||
"been replaced with 0 or 63.";
|
||||
}
|
||||
// check dacs
|
||||
out_of_range = false;
|
||||
@ -3318,7 +3320,8 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
|
||||
}
|
||||
}
|
||||
if (out_of_range) {
|
||||
LOG(logWARNING) << "Some dacs were out of range, "
|
||||
LOG(logWARNING)
|
||||
<< "Some dacs were out of range, "
|
||||
"these have been replaced with 0/200 or 2800/2400.";
|
||||
}
|
||||
}
|
||||
@ -3391,14 +3394,18 @@ void Module::sendModule(sls_detector_module *myMod, ClientSocket &client) {
|
||||
ts += n;
|
||||
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) {
|
||||
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) {
|
||||
constexpr TLogLevel level = logDEBUG1;
|
||||
LOG(level) << "Receiving Module";
|
||||
@ -3630,7 +3637,8 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
|
||||
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;
|
||||
std::ofstream outfile(fname);
|
||||
if (!outfile) {
|
||||
@ -3654,9 +3662,11 @@ void Module::saveSettingsFile(sls_detector_module &myMod, const std::string &fna
|
||||
sizeof(int) * (myMod.nchan));
|
||||
break;
|
||||
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,
|
||||
|
@ -29,11 +29,13 @@ bool Pattern::operator==(const Pattern &other) const {
|
||||
if (pat->limits[i] != other.pat->limits[i])
|
||||
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])
|
||||
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])
|
||||
return false;
|
||||
}
|
||||
@ -70,11 +72,10 @@ void Pattern::validate() const {
|
||||
for (int i = 0; i != MAX_PATTERN_LEVELS; ++i) {
|
||||
if (pat->startloop[i] >= MAX_PATTERN_LENGTH ||
|
||||
pat->stoploop[i] >= MAX_PATTERN_LENGTH) {
|
||||
throw RuntimeError(
|
||||
"Invalid Pattern loop address for level " + ToString(i) +
|
||||
std::string(" [") + ToString(pat->startloop[i]) +
|
||||
std::string(", ") + ToString(pat->stoploop[i]) +
|
||||
std::string("]"));
|
||||
throw RuntimeError("Invalid Pattern loop address for level " +
|
||||
ToString(i) + std::string(" [") +
|
||||
ToString(pat->startloop[i]) + std::string(", ") +
|
||||
ToString(pat->stoploop[i]) + std::string("]"));
|
||||
}
|
||||
if (pat->wait[i] >= MAX_PATTERN_LENGTH) {
|
||||
throw RuntimeError("Invalid Pattern wait address for level " +
|
||||
@ -129,8 +130,7 @@ void Pattern::load(const std::string &fname) {
|
||||
}
|
||||
pat->limits[0] = StringTo<uint32_t>(args[1]);
|
||||
pat->limits[1] = StringTo<uint32_t>(args[2]);
|
||||
}
|
||||
else if (cmd == "patloop0" || cmd == "patloop1" ||
|
||||
} else if (cmd == "patloop0" || cmd == "patloop1" ||
|
||||
cmd == "patloop2" || cmd == "patloop") {
|
||||
int level = -1, iArg = 1;
|
||||
if (cmd == "patloop") {
|
||||
@ -140,7 +140,8 @@ void Pattern::load(const std::string &fname) {
|
||||
}
|
||||
level = StringTo<int>(args[iArg++]);
|
||||
} else {
|
||||
LOG(logWARNING) << "Depreciated command. Please use patloop next time.";
|
||||
LOG(logWARNING)
|
||||
<< "Depreciated command. Please use patloop next time.";
|
||||
if (nargs != 2) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
ToString(args));
|
||||
@ -148,7 +149,8 @@ void Pattern::load(const std::string &fname) {
|
||||
level = cmd[cmd.find_first_of("012")] - '0';
|
||||
}
|
||||
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 loop2 = StringTo<uint32_t>(args[iArg++]);
|
||||
@ -164,7 +166,8 @@ void Pattern::load(const std::string &fname) {
|
||||
}
|
||||
level = StringTo<int>(args[iArg++]);
|
||||
} else {
|
||||
LOG(logWARNING) << "Depreciated command. Please use patnloop next time.";
|
||||
LOG(logWARNING) << "Depreciated command. Please use "
|
||||
"patnloop next time.";
|
||||
if (nargs != 1) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
ToString(args));
|
||||
@ -172,7 +175,8 @@ void Pattern::load(const std::string &fname) {
|
||||
level = cmd[cmd.find_first_of("012")] - '0';
|
||||
}
|
||||
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++]);
|
||||
} else if (cmd == "patwait0" || cmd == "patwait1" ||
|
||||
@ -185,7 +189,8 @@ void Pattern::load(const std::string &fname) {
|
||||
}
|
||||
level = StringTo<int>(args[iArg++]);
|
||||
} else {
|
||||
LOG(logWARNING) << "Depreciated command. Please use patwait next time.";
|
||||
LOG(logWARNING)
|
||||
<< "Depreciated command. Please use patwait next time.";
|
||||
if (nargs != 1) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
ToString(args));
|
||||
@ -193,7 +198,8 @@ void Pattern::load(const std::string &fname) {
|
||||
level = cmd[cmd.find_first_of("012")] - '0';
|
||||
}
|
||||
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++]);
|
||||
} else if (cmd == "patwaittime0" || cmd == "patwaittime1" ||
|
||||
@ -206,7 +212,8 @@ void Pattern::load(const std::string &fname) {
|
||||
}
|
||||
level = StringTo<int>(args[iArg++]);
|
||||
} else {
|
||||
LOG(logWARNING) << "Depreciated command. Please use patwaittime next time.";
|
||||
LOG(logWARNING) << "Depreciated command. Please use "
|
||||
"patwaittime next time.";
|
||||
if (nargs != 1) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
ToString(args));
|
||||
@ -214,7 +221,8 @@ void Pattern::load(const std::string &fname) {
|
||||
level = cmd[cmd.find_first_of("012")] - '0';
|
||||
}
|
||||
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++]);
|
||||
} else {
|
||||
@ -279,10 +287,12 @@ std::string Pattern::str() const {
|
||||
<< ToStringHex(pat->limits[1], addr_width) << std::endl;
|
||||
|
||||
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
|
||||
<< "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;
|
||||
}
|
||||
|
||||
|
@ -13,17 +13,16 @@
|
||||
#include "sls/logger.h"
|
||||
#include "sls/sls_detector_exceptions.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cerrno> // errno
|
||||
#include <cstdlib>
|
||||
#include <cstring> // strerror
|
||||
#include <fcntl.h> // O_CREAT, O_TRUNC..
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/mman.h> // shared memory
|
||||
#include <sys/stat.h> // fstat
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace sls {
|
||||
|
||||
|
@ -10,5 +10,4 @@ void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname,
|
||||
void test_onchip_dac(slsDetectorDefs::dacIndex index,
|
||||
const std::string &dacname, int dacvalue);
|
||||
|
||||
|
||||
} // namespace sls
|
||||
|
@ -511,18 +511,23 @@ TEST_CASE("interpolation", "[.cmd]") {
|
||||
std::ostringstream oss;
|
||||
proxy.Call("interpolation", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "interpolation 1\n");
|
||||
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
|
||||
7);
|
||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth3 dac value") == disabledDacValue);
|
||||
REQUIRE(det.getCounterMask().tsquash(
|
||||
"inconsistent counter mask") == 7);
|
||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
|
||||
.tsquash("inconsistent vth3 dac value") ==
|
||||
disabledDacValue);
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("interpolation", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "interpolation 0\n");
|
||||
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
|
||||
fixedMask[i]);
|
||||
uint32_t expectedVth3DacVal = (fixedMask[i] & 0x4 ? fixedVth3DacVal : disabledDacValue);
|
||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth3 dac value") == expectedVth3DacVal);
|
||||
REQUIRE(det.getCounterMask().tsquash(
|
||||
"inconsistent counter mask") == fixedMask[i]);
|
||||
uint32_t 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.setInterpolation(prev_interpolation[i], {i});
|
||||
det.setDAC(defs::VTH3, prev_vth3DacVal[i], 0, {i});
|
||||
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("interpolation", {}, -1, GET));
|
||||
@ -567,9 +571,15 @@ TEST_CASE("pumpprobe", "[.cmd]") {
|
||||
std::ostringstream oss;
|
||||
proxy.Call("pumpprobe", {"1"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "pumpprobe 1\n");
|
||||
REQUIRE(det.getDAC(defs::VTH1, 0, {0}).tsquash("inconsistent vth2 dac value") == disabledDacValue);
|
||||
REQUIRE(det.getDAC(defs::VTH2, 0, {0}).tsquash("inconsistent vth2 dac value") == fixedVthDacVal);
|
||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth2 dac value") == disabledDacValue);
|
||||
REQUIRE(det.getDAC(defs::VTH1, 0, {0})
|
||||
.tsquash("inconsistent vth2 dac value") ==
|
||||
disabledDacValue);
|
||||
REQUIRE(det.getDAC(defs::VTH2, 0, {0})
|
||||
.tsquash("inconsistent vth2 dac value") ==
|
||||
fixedVthDacVal);
|
||||
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
|
||||
.tsquash("inconsistent vth2 dac value") ==
|
||||
disabledDacValue);
|
||||
}
|
||||
// interpolation and pump probe
|
||||
REQUIRE_THROWS(proxy.Call("interpolation", {"1"}, -1, PUT));
|
||||
@ -578,12 +588,21 @@ TEST_CASE("pumpprobe", "[.cmd]") {
|
||||
std::ostringstream oss;
|
||||
proxy.Call("pumpprobe", {"0"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "pumpprobe 0\n");
|
||||
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") == 7);
|
||||
REQUIRE(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));
|
||||
REQUIRE(det.getCounterMask().tsquash(
|
||||
"inconsistent counter mask") == 7);
|
||||
REQUIRE(
|
||||
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;
|
||||
|
@ -192,7 +192,8 @@ TEST_CASE("patloop", "[.cmd]") {
|
||||
REQUIRE(oss.str() == "patloop [0x0020, 0x005c]\n");
|
||||
}
|
||||
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 {
|
||||
|
@ -465,7 +465,8 @@ TEST_CASE("rx_roi", "[.cmd]") {
|
||||
REQUIRE(oss.str() == "rx_roi [10, 15]\n");
|
||||
}
|
||||
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
|
||||
else {
|
||||
@ -481,10 +482,18 @@ TEST_CASE("rx_roi", "[.cmd]") {
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_roi", {"1", std::to_string(detsize.x - 5), "1", std::to_string(detsize.y - 5)}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("rx_roi [1, ") + std::to_string(detsize.x - 5) + std::string(", ") + std::to_string(detsize.y - 5) + std::string(", 1]\n"));
|
||||
proxy.Call("rx_roi",
|
||||
{"1", std::to_string(detsize.x - 5), "1",
|
||||
std::to_string(detsize.y - 5)},
|
||||
-1, PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("rx_roi [1, ") +
|
||||
std::to_string(detsize.x - 5) +
|
||||
std::string(", ") +
|
||||
std::to_string(detsize.y - 5) +
|
||||
std::string(", 1]\n"));
|
||||
}
|
||||
REQUIRE_THROWS(proxy.Call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT));
|
||||
REQUIRE_THROWS(
|
||||
proxy.Call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT));
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
|
@ -22,9 +22,8 @@ TEST_CASE("Calling help doesn't throw or cause segfault"){
|
||||
auto commands = proxy.GetProxyCommands();
|
||||
std::ostringstream os;
|
||||
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]") {
|
||||
@ -338,8 +337,7 @@ TEST_CASE("threshold", "[.cmd]") {
|
||||
det.setTrimEnergies(prev_energies);
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
if (prev_threshold[i][0] >= 0) {
|
||||
std::cout
|
||||
<< "prev cvalues:" << ToString(prev_threshold[i])
|
||||
std::cout << "prev cvalues:" << ToString(prev_threshold[i])
|
||||
<< std::endl;
|
||||
det.setThresholdEnergy(prev_threshold[i], prev_settings,
|
||||
true, {i});
|
||||
@ -585,7 +583,8 @@ TEST_CASE("master", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
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));
|
||||
if (det_type == defs::EIGER) {
|
||||
// get previous master
|
||||
@ -2265,10 +2264,8 @@ TEST_CASE("scan", "[.cmd]") {
|
||||
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT,
|
||||
oss);
|
||||
CHECK(oss.str() ==
|
||||
"scan [" + ToString(ind) + ", 500, 1500, 500]\n");
|
||||
proxy.Call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT, oss);
|
||||
CHECK(oss.str() == "scan [" + ToString(ind) + ", 500, 1500, 500]\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -2279,8 +2276,8 @@ TEST_CASE("scan", "[.cmd]") {
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1,
|
||||
PUT, oss);
|
||||
proxy.Call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1, PUT,
|
||||
oss);
|
||||
CHECK(oss.str() ==
|
||||
"scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n");
|
||||
}
|
||||
@ -2305,16 +2302,14 @@ TEST_CASE("scan", "[.cmd]") {
|
||||
std::ostringstream oss;
|
||||
proxy.Call("scan", {ToString(ind), "1500", "500", "-500"}, -1, PUT,
|
||||
oss);
|
||||
CHECK(oss.str() ==
|
||||
"scan [" + ToString(ind) + ", 1500, 500, -500]\n");
|
||||
CHECK(oss.str() == "scan [" + ToString(ind) + ", 1500, 500, -500]\n");
|
||||
}
|
||||
CHECK_THROWS(proxy.Call(
|
||||
"scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1,
|
||||
PUT));
|
||||
CHECK_THROWS(proxy.Call("scan", {ToString(ind), "500", "1500", "-500"},
|
||||
-1, PUT));
|
||||
CHECK_THROWS(proxy.Call("scan", {ToString(ind), "1500", "500", "500"},
|
||||
-1, PUT));
|
||||
"scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1, PUT));
|
||||
CHECK_THROWS(
|
||||
proxy.Call("scan", {ToString(ind), "500", "1500", "-500"}, -1, PUT));
|
||||
CHECK_THROWS(
|
||||
proxy.Call("scan", {ToString(ind), "1500", "500", "500"}, -1, PUT));
|
||||
|
||||
if (det_type == defs::MYTHEN3 || defs::EIGER) {
|
||||
{
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "SharedMemory.h"
|
||||
#include "CtbConfig.h"
|
||||
#include "SharedMemory.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace sls {
|
||||
|
@ -97,7 +97,6 @@ TEST_CASE("Move SharedMemory", "[detector]") {
|
||||
shm.createSharedMemory();
|
||||
shm()->x = 9;
|
||||
|
||||
|
||||
SharedMemory<Data> shm2(shm_id + 1, -1);
|
||||
shm2 = std::move(shm); // shm is now a moved from object!
|
||||
|
||||
@ -135,7 +134,6 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
||||
TEST_CASE("Create create a shared memory with a tag") {
|
||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs");
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
|
||||
@ -156,7 +154,6 @@ TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set"){
|
||||
unsetenv(SHM_ENV_NAME);
|
||||
else
|
||||
setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1);
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("map int64 to int32 throws") {
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace sls {
|
||||
|
||||
class ClientInterface;
|
||||
@ -40,16 +39,17 @@ class Receiver : private virtual slsDetectorDefs {
|
||||
int64_t getReceiverVersion();
|
||||
|
||||
/**
|
||||
* Start Acquisition Call back (slsMultiReceiver writes data if file write enabled)
|
||||
* if registerCallBackRawDataReady or registerCallBackRawDataModifyReady registered,
|
||||
* users get data
|
||||
* callback arguments are:
|
||||
* Start Acquisition Call back (slsMultiReceiver writes data if file write
|
||||
* enabled) if registerCallBackRawDataReady or
|
||||
* registerCallBackRawDataModifyReady registered, users get data callback
|
||||
* arguments are:
|
||||
* - file path
|
||||
* - file name prefix
|
||||
* - file index
|
||||
* - 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 *),
|
||||
void *arg);
|
||||
|
||||
|
@ -37,4 +37,3 @@ class Arping {
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
||||
|
@ -19,10 +19,12 @@ void BinaryDataFile::CloseFile() {
|
||||
fd = nullptr;
|
||||
}
|
||||
|
||||
void BinaryDataFile::CreateFirstBinaryDataFile(
|
||||
const std::string& fNamePrefix,
|
||||
const uint64_t fIndex, const bool ovEnable, const bool sMode,
|
||||
const uint32_t uPortNumber, const uint32_t mFramesPerFile) {
|
||||
void BinaryDataFile::CreateFirstBinaryDataFile(const std::string &fNamePrefix,
|
||||
const uint64_t fIndex,
|
||||
const bool ovEnable,
|
||||
const bool sMode,
|
||||
const uint32_t uPortNumber,
|
||||
const uint32_t mFramesPerFile) {
|
||||
|
||||
subFileIndex = 0;
|
||||
numFramesInFile = 0;
|
||||
@ -41,15 +43,13 @@ void BinaryDataFile::CreateFile() {
|
||||
numFramesInFile = 0;
|
||||
|
||||
std::ostringstream os;
|
||||
os << fileNamePrefix << "_f" << subFileIndex
|
||||
<< '_' << fileIndex << ".raw";
|
||||
os << fileNamePrefix << "_f" << subFileIndex << '_' << fileIndex << ".raw";
|
||||
fileName = os.str();
|
||||
|
||||
if (!overWriteEnable) {
|
||||
if (nullptr == (fd = fopen(fileName.c_str(), "wx"))) {
|
||||
fd = nullptr;
|
||||
throw RuntimeError("Could not create/overwrite file " +
|
||||
fileName);
|
||||
throw RuntimeError("Could not create/overwrite file " + fileName);
|
||||
}
|
||||
} else if (nullptr == (fd = fopen(fileName.c_str(), "w"))) {
|
||||
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
|
||||
if (maxFramesPerFile && (numFramesInFile >= maxFramesPerFile)) {
|
||||
CloseFile();
|
||||
@ -101,7 +104,12 @@ void BinaryDataFile::WriteToFile(char *imageData, sls_receiver_header& header, c
|
||||
|
||||
// if write error
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,13 @@ class BinaryDataFile : private virtual slsDetectorDefs, public File {
|
||||
fileFormat GetFileFormat() const override;
|
||||
void CloseFile() override;
|
||||
void CreateFirstBinaryDataFile(const std::string &fNamePrefix,
|
||||
const uint64_t fIndex,
|
||||
const bool ovEnable,
|
||||
const bool sMode,
|
||||
const uint32_t uPortNumber,
|
||||
const uint64_t fIndex, const bool ovEnable,
|
||||
const bool sMode, const uint32_t uPortNumber,
|
||||
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:
|
||||
void CreateFile();
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace sls {
|
||||
|
||||
using ns = std::chrono::nanoseconds;
|
||||
@ -34,7 +33,6 @@ using Interface = ServerInterface;
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
|
||||
ClientInterface::~ClientInterface() {
|
||||
killTcpThread = true;
|
||||
LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
||||
@ -1176,7 +1174,8 @@ int ClientInterface::get_additional_json_header(Interface &socket) {
|
||||
int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
|
||||
auto size = socket.Receive<int>();
|
||||
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) {
|
||||
verifyIdle(socket);
|
||||
|
@ -34,7 +34,8 @@ class ClientInterface : private virtual slsDetectorDefs {
|
||||
|
||||
//***callback functions***
|
||||
/** 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 *),
|
||||
void *arg);
|
||||
|
||||
@ -180,13 +181,12 @@ class ClientInterface : private virtual slsDetectorDefs {
|
||||
}
|
||||
}
|
||||
|
||||
int (ClientInterface::*flist[NUM_REC_FUNCTIONS])(
|
||||
ServerInterface &socket);
|
||||
int (ClientInterface::*flist[NUM_REC_FUNCTIONS])(ServerInterface &socket);
|
||||
|
||||
//***callback parameters***
|
||||
|
||||
int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
|
||||
void *) = nullptr;
|
||||
int (*startAcquisitionCallBack)(const std::string &, const std::string &,
|
||||
uint64_t, size_t, void *) = nullptr;
|
||||
void *pStartAcquisition{nullptr};
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
|
||||
void *pAcquisitionFinished{nullptr};
|
||||
|
@ -28,8 +28,7 @@ namespace sls {
|
||||
|
||||
const std::string DataProcessor::typeName = "DataProcessor";
|
||||
|
||||
DataProcessor::DataProcessor(int index)
|
||||
: ThreadObject(index, typeName) {
|
||||
DataProcessor::DataProcessor(int index) : ThreadObject(index, typeName) {
|
||||
|
||||
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
||||
}
|
||||
@ -40,9 +39,7 @@ bool DataProcessor::GetStartedFlag() const { return startedFlag; }
|
||||
|
||||
void DataProcessor::SetFifo(Fifo *f) { fifo = f; }
|
||||
|
||||
void DataProcessor::SetGeneralData(GeneralData *g) {
|
||||
generalData = g;
|
||||
}
|
||||
void DataProcessor::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||
|
||||
void DataProcessor::SetActivate(bool enable) { activated = enable; }
|
||||
|
||||
@ -52,7 +49,9 @@ void DataProcessor::SetReceiverROI(ROI roi) {
|
||||
receiverNoRoi = receiverRoi.noRoi();
|
||||
}
|
||||
|
||||
void DataProcessor::SetDataStreamEnable(bool enable) { dataStreamEnable = enable; }
|
||||
void DataProcessor::SetDataStreamEnable(bool enable) {
|
||||
dataStreamEnable = enable;
|
||||
}
|
||||
|
||||
void DataProcessor::SetStreamingFrequency(uint32_t value) {
|
||||
streamingFrequency = value;
|
||||
@ -72,9 +71,7 @@ void DataProcessor::SetCtbDbitList(std::vector<int> value) {
|
||||
ctbDbitList = value;
|
||||
}
|
||||
|
||||
void DataProcessor::SetCtbDbitOffset(int value) {
|
||||
ctbDbitOffset = value;
|
||||
}
|
||||
void DataProcessor::SetCtbDbitOffset(int value) { ctbDbitOffset = value; }
|
||||
|
||||
void DataProcessor::ResetParametersforNewAcquisition() {
|
||||
StopRunning();
|
||||
@ -84,7 +81,8 @@ void DataProcessor::ResetParametersforNewAcquisition() {
|
||||
currentFrameIndex = 0;
|
||||
firstStreamerFrame = true;
|
||||
streamCurrentFrame = false;
|
||||
completeImageToStreamBeforeCropping = make_unique<char[]>(generalData->imageSize);
|
||||
completeImageToStreamBeforeCropping =
|
||||
make_unique<char[]>(generalData->imageSize);
|
||||
}
|
||||
|
||||
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
||||
@ -120,15 +118,15 @@ void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
||||
dataFile = new BinaryDataFile(index);
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError(
|
||||
"Unknown file format (compile with hdf5 flags");
|
||||
throw RuntimeError("Unknown file format (compile with hdf5 flags");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataProcessor::CreateFirstFiles(
|
||||
const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||
void DataProcessor::CreateFirstFiles(const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode,
|
||||
const uint32_t udpPortNumber,
|
||||
const uint64_t numImages,
|
||||
const bool detectorDataStream) {
|
||||
@ -158,8 +156,8 @@ void DataProcessor::CreateFirstFiles(
|
||||
case HDF5:
|
||||
dataFile->CreateFirstHDF5DataFile(
|
||||
fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||
udpPortNumber, generalData->framesPerFile,
|
||||
numImages, nx, ny, generalData->dynamicRange);
|
||||
udpPortNumber, generalData->framesPerFile, numImages, nx, ny,
|
||||
generalData->dynamicRange);
|
||||
break;
|
||||
#endif
|
||||
case BINARY:
|
||||
@ -184,22 +182,22 @@ uint32_t DataProcessor::GetFilesInAcquisition() const {
|
||||
std::string DataProcessor::CreateVirtualFile(
|
||||
const std::string &filePath, const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||
const int modulePos,
|
||||
const uint64_t numImages,
|
||||
const int numModX, const int numModY,
|
||||
std::mutex *hdf5LibMutex) {
|
||||
const int modulePos, const uint64_t numImages, const int numModX,
|
||||
const int numModY, std::mutex *hdf5LibMutex) {
|
||||
|
||||
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 =
|
||||
((generalData->detType == GOTTHARD || generalData->detType == GOTTHARD2) &&
|
||||
bool gotthard25um = ((generalData->detType == GOTTHARD ||
|
||||
generalData->detType == GOTTHARD2) &&
|
||||
(numModX * numModY) == 2);
|
||||
|
||||
// 0 for infinite files
|
||||
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
|
||||
// files (they exist anyway) assumption2: virtual file max frame index
|
||||
@ -220,7 +218,8 @@ void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
|
||||
std::mutex *hdf5LibMutex) {
|
||||
|
||||
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};
|
||||
// if no virtual file, link data file
|
||||
@ -266,14 +265,16 @@ void DataProcessor::ThreadExecution() {
|
||||
auto *memImage = reinterpret_cast<image_structure *>(buffer);
|
||||
|
||||
// check dummy
|
||||
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << memImage->size;
|
||||
LOG(logDEBUG1) << "DataProcessor " << index
|
||||
<< ", Numbytes:" << memImage->size;
|
||||
if (memImage->size == DUMMY_PACKET_VALUE) {
|
||||
StopProcessing(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
ProcessAnImage(memImage->header, memImage->size, memImage->firstIndex, memImage->data);
|
||||
ProcessAnImage(memImage->header, memImage->size, memImage->firstIndex,
|
||||
memImage->data);
|
||||
} catch (const std::exception &e) {
|
||||
fifo->FreeAddress(buffer);
|
||||
return;
|
||||
@ -284,7 +285,8 @@ void DataProcessor::ThreadExecution() {
|
||||
// copy the complete image back if roi enabled
|
||||
if (receiverRoiEnabled) {
|
||||
memImage->size = generalData->imageSize;
|
||||
memcpy(memImage->data, &completeImageToStreamBeforeCropping[0], generalData->imageSize);
|
||||
memcpy(memImage->data, &completeImageToStreamBeforeCropping[0],
|
||||
generalData->imageSize);
|
||||
}
|
||||
fifo->PushAddressToStream(buffer);
|
||||
} else {
|
||||
@ -306,7 +308,8 @@ void DataProcessor::StopProcessing(char *buf) {
|
||||
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;
|
||||
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
||||
currentFrameIndex = fnum;
|
||||
@ -348,11 +351,11 @@ void DataProcessor::ProcessAnImage(sls_receiver_header & header, size_t &size, s
|
||||
streamCurrentFrame = false;
|
||||
}
|
||||
|
||||
|
||||
if (receiverRoiEnabled) {
|
||||
// copy the complete image to stream before cropping
|
||||
if (streamCurrentFrame) {
|
||||
memcpy(&completeImageToStreamBeforeCropping[0], data, generalData->imageSize);
|
||||
memcpy(&completeImageToStreamBeforeCropping[0], data,
|
||||
generalData->imageSize);
|
||||
}
|
||||
CropImage(size, data);
|
||||
}
|
||||
@ -368,8 +371,7 @@ void DataProcessor::ProcessAnImage(sls_receiver_header & header, size_t &size, s
|
||||
rawDataModifyReadyCallBack(header, data, size, pRawDataReady);
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
throw RuntimeError("Get Data Callback Error: " +
|
||||
std::string(e.what()));
|
||||
throw RuntimeError("Get Data Callback Error: " + std::string(e.what()));
|
||||
}
|
||||
|
||||
// write to file
|
||||
@ -508,8 +510,7 @@ void DataProcessor::RearrangeDbitData(size_t & size, char *data) {
|
||||
const int numSamples = (ctbDigitalDataBytes / sizeof(uint64_t));
|
||||
|
||||
// ceil as numResult8Bits could be decimal
|
||||
const int numResult8Bits =
|
||||
ceil((numSamples * ctbDbitList.size()) / 8.00);
|
||||
const int numResult8Bits = ceil((numSamples * ctbDbitList.size()) / 8.00);
|
||||
std::vector<uint8_t> result(numResult8Bits);
|
||||
uint8_t *dest = &result[0];
|
||||
|
||||
@ -539,7 +540,8 @@ void DataProcessor::RearrangeDbitData(size_t & size, char *data) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -56,18 +56,18 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
|
||||
void CreateFirstFiles(const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable,
|
||||
const bool silentMode,
|
||||
const uint32_t udpPortNumber,
|
||||
const bool silentMode, const uint32_t udpPortNumber,
|
||||
const uint64_t numImages,
|
||||
const bool detectorDataStream);
|
||||
#ifdef HDF5C
|
||||
uint32_t GetFilesInAcquisition() const;
|
||||
std::string CreateVirtualFile(
|
||||
const std::string &filePath, const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable,
|
||||
std::string CreateVirtualFile(const std::string &filePath,
|
||||
const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode, const int modulePos,
|
||||
const uint64_t numImages, const int numModX, const int numModY,
|
||||
std::mutex *hdf5LibMutex);
|
||||
const uint64_t numImages, const int numModX,
|
||||
const int numModY, std::mutex *hdf5LibMutex);
|
||||
void LinkFileInMaster(const std::string &masterFileName,
|
||||
const std::string &virtualFileName,
|
||||
const bool silentMode, std::mutex *hdf5LibMutex);
|
||||
@ -82,10 +82,16 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
std::mutex *hdf5LibMutex);
|
||||
|
||||
/** 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 */
|
||||
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:
|
||||
void RecordFirstIndex(uint64_t fnum);
|
||||
|
||||
@ -106,7 +112,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* Process an image popped from fifo,
|
||||
* 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
|
||||
|
@ -31,9 +31,7 @@ void DataStreamer::SetFifo(Fifo *f) { fifo = f; }
|
||||
|
||||
void DataStreamer::SetGeneralData(GeneralData *g) { generalData = g; }
|
||||
|
||||
void DataStreamer::SetFileIndex(uint64_t value) {
|
||||
fileIndex = value;
|
||||
}
|
||||
void DataStreamer::SetFileIndex(uint64_t value) { fileIndex = value; }
|
||||
|
||||
void DataStreamer::SetNumberofPorts(xy np) { numPorts = np; }
|
||||
|
||||
@ -68,8 +66,10 @@ void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
|
||||
delete[] completeBuffer;
|
||||
completeBuffer = nullptr;
|
||||
}
|
||||
if (generalData->detType == GOTTHARD && generalData->detectorRoi.xmin != -1) {
|
||||
adcConfigured = generalData->GetAdcConfigured(index, generalData->detectorRoi);
|
||||
if (generalData->detType == GOTTHARD &&
|
||||
generalData->detectorRoi.xmin != -1) {
|
||||
adcConfigured =
|
||||
generalData->GetAdcConfigured(index, generalData->detectorRoi);
|
||||
completeBuffer = new char[generalData->imageSizeComplete];
|
||||
memset(completeBuffer, 0, generalData->imageSizeComplete);
|
||||
}
|
||||
@ -82,8 +82,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum, size_t firstImageIndex) {
|
||||
<< ", First Streamer Index:" << fnum;
|
||||
}
|
||||
|
||||
void DataStreamer::CreateZmqSockets(uint32_t port,
|
||||
const IpAddr ip, int hwm) {
|
||||
void DataStreamer::CreateZmqSockets(uint32_t port, const IpAddr ip, int hwm) {
|
||||
uint32_t portnum = port + index;
|
||||
std::string sip = ip.str();
|
||||
try {
|
||||
@ -117,12 +116,13 @@ void DataStreamer::CloseZmqSocket() {
|
||||
void DataStreamer::ThreadExecution() {
|
||||
char *buffer = nullptr;
|
||||
fifo->PopAddressToStream(buffer);
|
||||
LOG(logDEBUG5) << "DataStreamer " << index << ", pop 0x"
|
||||
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
|
||||
LOG(logDEBUG5) << "DataStreamer " << index << ", pop 0x" << std::hex
|
||||
<< (void *)(buffer) << std::dec << ":" << buffer;
|
||||
auto *memImage = reinterpret_cast<image_structure *>(buffer);
|
||||
|
||||
// check dummy
|
||||
LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << memImage->size ;
|
||||
LOG(logDEBUG1) << "DataStreamer " << index
|
||||
<< ", Numbytes:" << memImage->size;
|
||||
if (memImage->size == DUMMY_PACKET_VALUE) {
|
||||
StopProcessing(buffer);
|
||||
return;
|
||||
@ -130,7 +130,8 @@ void DataStreamer::ThreadExecution() {
|
||||
|
||||
// streamer first index needn't be the very first index
|
||||
if (!startedFlag) {
|
||||
RecordFirstIndex(memImage->header.detHeader.frameNumber, memImage->firstIndex);
|
||||
RecordFirstIndex(memImage->header.detHeader.frameNumber,
|
||||
memImage->firstIndex);
|
||||
}
|
||||
|
||||
ProcessAnImage(memImage->header.detHeader, memImage->size, memImage->data);
|
||||
@ -142,7 +143,8 @@ void DataStreamer::ThreadExecution() {
|
||||
void DataStreamer::StopProcessing(char *buf) {
|
||||
LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy";
|
||||
if (!SendDummyHeader()) {
|
||||
LOG(logERROR) << "Could not send zmq dummy header for streamer for port "
|
||||
LOG(logERROR)
|
||||
<< "Could not send zmq dummy header for streamer for port "
|
||||
<< zmqSocket->GetPortNumber();
|
||||
}
|
||||
|
||||
@ -152,7 +154,8 @@ void DataStreamer::StopProcessing(char *buf) {
|
||||
}
|
||||
|
||||
/** 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;
|
||||
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
|
||||
@ -164,14 +167,16 @@ void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size, char*
|
||||
// imagesizecomplete and listener writes imagesize to size
|
||||
|
||||
if (!SendDataHeader(header, generalData->imageSizeComplete,
|
||||
generalData->nPixelsXComplete, generalData->nPixelsYComplete)) {
|
||||
generalData->nPixelsXComplete,
|
||||
generalData->nPixelsYComplete)) {
|
||||
LOG(logERROR) << "Could not send zmq header for fnum " << fnum
|
||||
<< " and streamer " << index;
|
||||
}
|
||||
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
|
||||
data, size);
|
||||
|
||||
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) {
|
||||
if (!zmqSocket->SendData(completeBuffer,
|
||||
generalData->imageSizeComplete)) {
|
||||
LOG(logERROR) << "Could not send zmq data for fnum " << fnum
|
||||
<< " and streamer " << index;
|
||||
}
|
||||
@ -180,7 +185,8 @@ void DataStreamer::ProcessAnImage(sls_detector_header header, size_t size, char*
|
||||
// normal
|
||||
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
|
||||
<< " and streamer " << index;
|
||||
}
|
||||
@ -250,8 +256,7 @@ int DataStreamer::SendDataHeader(sls_detector_header header, uint32_t size,
|
||||
|
||||
void DataStreamer::RestreamStop() {
|
||||
if (!SendDummyHeader()) {
|
||||
throw RuntimeError(
|
||||
"Could not restream Dummy Header via ZMQ for port " +
|
||||
throw RuntimeError("Could not restream Dummy Header via ZMQ for port " +
|
||||
std::to_string(zmqSocket->GetPortNumber()));
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* @param ip streaming source ip
|
||||
* @param hwm streaming high water mark
|
||||
*/
|
||||
void CreateZmqSockets(uint32_t port, const IpAddr ip,
|
||||
int hwm);
|
||||
void CreateZmqSockets(uint32_t port, const IpAddr ip, int hwm);
|
||||
void CloseZmqSocket();
|
||||
void RestreamStop();
|
||||
|
||||
@ -85,7 +84,6 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
int SendDataHeader(sls_detector_header header, uint32_t size = 0,
|
||||
uint32_t nx = 0, uint32_t ny = 0);
|
||||
|
||||
|
||||
static const std::string TypeName;
|
||||
const GeneralData *generalData{nullptr};
|
||||
Fifo *fifo{nullptr};
|
||||
|
@ -54,4 +54,3 @@ class Fifo : private virtual slsDetectorDefs {
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
||||
|
@ -26,8 +26,7 @@ class File : private virtual slsDetectorDefs {
|
||||
|
||||
#ifdef HDF5C
|
||||
virtual std::string GetFileName() const {
|
||||
LOG(logERROR)
|
||||
<< "This is a generic function GetFileName that "
|
||||
LOG(logERROR) << "This is a generic function GetFileName that "
|
||||
"should be overloaded by a derived class";
|
||||
return std::string{};
|
||||
}
|
||||
@ -46,8 +45,7 @@ class File : private virtual slsDetectorDefs {
|
||||
}
|
||||
|
||||
virtual std::vector<std::string> GetParameterNames() const {
|
||||
LOG(logERROR)
|
||||
<< "This is a generic function GetParameterNames that "
|
||||
LOG(logERROR) << "This is a generic function GetParameterNames that "
|
||||
"should be overloaded by a derived class";
|
||||
return std::vector<std::string>{};
|
||||
};
|
||||
@ -60,26 +58,31 @@ class File : private virtual slsDetectorDefs {
|
||||
};
|
||||
|
||||
virtual void CreateFirstHDF5DataFile(
|
||||
const std::string& fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable,
|
||||
const bool silentMode, const uint32_t udpPortNumber,
|
||||
const uint32_t maxFramesPerFile, const uint64_t numImages,
|
||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||
const uint32_t dynamicRange) {
|
||||
LOG(logERROR) << "This is a generic function CreateFirstHDF5DataFile that "
|
||||
const std::string &fileNamePrefix, const uint64_t fileIndex,
|
||||
const bool overWriteEnable, const bool silentMode,
|
||||
const uint32_t udpPortNumber, const uint32_t maxFramesPerFile,
|
||||
const uint64_t numImages, const uint32_t nPixelsX,
|
||||
const uint32_t nPixelsY, const uint32_t dynamicRange) {
|
||||
LOG(logERROR)
|
||||
<< "This is a generic function CreateFirstHDF5DataFile that "
|
||||
"should be overloaded by a derived class";
|
||||
};
|
||||
#endif
|
||||
virtual void CreateFirstBinaryDataFile(
|
||||
const std::string& fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable,
|
||||
const bool silentMode, const uint32_t udpPortNumber,
|
||||
virtual void CreateFirstBinaryDataFile(const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
const bool overWriteEnable,
|
||||
const bool silentMode,
|
||||
const uint32_t udpPortNumber,
|
||||
const uint32_t maxFramesPerFile) {
|
||||
LOG(logERROR) << "This is a generic function CreateFirstBinaryDataFile that "
|
||||
LOG(logERROR)
|
||||
<< "This is a generic function CreateFirstBinaryDataFile that "
|
||||
"should be overloaded by a derived class";
|
||||
};
|
||||
|
||||
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
|
||||
|
@ -28,18 +28,18 @@ HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
|
||||
};
|
||||
H5::StrType strdatatype(H5::PredType::C_S1, sizeof(bitset_storage));
|
||||
parameterDataTypes = std::vector<H5::DataType>{
|
||||
H5::PredType::STD_U64LE, H5::PredType::STD_U32LE, H5::PredType::STD_U32LE,
|
||||
H5::PredType::STD_U64LE, H5::PredType::STD_U64LE, H5::PredType::STD_U16LE,
|
||||
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_U64LE, H5::PredType::STD_U32LE,
|
||||
H5::PredType::STD_U32LE, H5::PredType::STD_U64LE,
|
||||
H5::PredType::STD_U64LE, H5::PredType::STD_U16LE,
|
||||
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};
|
||||
}
|
||||
|
||||
HDF5DataFile::~HDF5DataFile() { CloseFile(); }
|
||||
|
||||
std::string HDF5DataFile::GetFileName() const {
|
||||
return fileName;
|
||||
}
|
||||
std::string HDF5DataFile::GetFileName() const { return fileName; }
|
||||
|
||||
uint32_t HDF5DataFile::GetFilesInAcquisition() const {
|
||||
return numFilesInAcquisition;
|
||||
@ -54,9 +54,7 @@ std::vector<H5::DataType> HDF5DataFile::GetParameterDataTypes() const {
|
||||
return parameterDataTypes;
|
||||
}
|
||||
|
||||
slsDetectorDefs::fileFormat HDF5DataFile::GetFileFormat() const {
|
||||
return HDF5;
|
||||
}
|
||||
slsDetectorDefs::fileFormat HDF5DataFile::GetFileFormat() const { return HDF5; }
|
||||
|
||||
void HDF5DataFile::CloseFile() {
|
||||
std::lock_guard<std::mutex> lock(*hdf5Lib);
|
||||
@ -68,8 +66,7 @@ void HDF5DataFile::CloseFile() {
|
||||
fd = nullptr;
|
||||
}
|
||||
} catch (const H5::Exception &error) {
|
||||
LOG(logERROR) << "Could not close data HDF5 handles of index "
|
||||
<< index;
|
||||
LOG(logERROR) << "Could not close data HDF5 handles of index " << index;
|
||||
error.printErrorStack();
|
||||
}
|
||||
if (dataSpace) {
|
||||
@ -90,9 +87,8 @@ void HDF5DataFile::CloseFile() {
|
||||
}
|
||||
|
||||
void HDF5DataFile::CreateFirstHDF5DataFile(
|
||||
const std::string& fNamePrefix,
|
||||
const uint64_t fIndex, const bool owEnable, const bool sMode,
|
||||
const uint32_t uPortNumber, const uint32_t mFramesPerFile,
|
||||
const std::string &fNamePrefix, const uint64_t fIndex, const bool owEnable,
|
||||
const bool sMode, const uint32_t uPortNumber, const uint32_t mFramesPerFile,
|
||||
const uint64_t nImages, const uint32_t nX, const uint32_t nY,
|
||||
const uint32_t dr) {
|
||||
|
||||
@ -134,8 +130,7 @@ void HDF5DataFile::CreateFile() {
|
||||
numFilesInAcquisition++;
|
||||
|
||||
std::ostringstream os;
|
||||
os << fileNamePrefix << "_f" << subFileIndex
|
||||
<< '_' << fileIndex << ".h5";
|
||||
os << fileNamePrefix << "_f" << subFileIndex << '_' << fileIndex << ".h5";
|
||||
fileName = os.str();
|
||||
|
||||
std::lock_guard<std::mutex> lock(*hdf5Lib);
|
||||
@ -199,8 +194,8 @@ void HDF5DataFile::CreateFile() {
|
||||
|
||||
// dataset
|
||||
dataSet = nullptr;
|
||||
dataSet = new H5::DataSet(fd->createDataSet(
|
||||
DATASET_NAME, dataType, *dataSpace, plist));
|
||||
dataSet = new H5::DataSet(
|
||||
fd->createDataSet(DATASET_NAME, dataType, *dataSpace, plist));
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
||||
H5::DataSet *ds = new H5::DataSet(fd->createDataSet(
|
||||
parameterNames[i].c_str(), parameterDataTypes[i],
|
||||
@ -210,8 +205,7 @@ void HDF5DataFile::CreateFile() {
|
||||
} catch (const H5::Exception &error) {
|
||||
error.printErrorStack();
|
||||
CloseFile();
|
||||
throw RuntimeError("Could not create HDF5 handles in object " +
|
||||
index);
|
||||
throw RuntimeError("Could not create HDF5 handles in object " + index);
|
||||
}
|
||||
if (!silentMode) {
|
||||
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
|
||||
if (maxFramesPerFile && (numFramesInFile >= maxFramesPerFile)) {
|
||||
@ -320,8 +317,8 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
|
||||
dataSetPara[2]->write(&header.packetNumber, parameterDataTypes[2],
|
||||
memspace, *dataSpacePara);
|
||||
i = 3;
|
||||
dataSetPara[3]->write(&header.bunchId, parameterDataTypes[3],
|
||||
memspace, *dataSpacePara);
|
||||
dataSetPara[3]->write(&header.bunchId, parameterDataTypes[3], memspace,
|
||||
*dataSpacePara);
|
||||
i = 4;
|
||||
dataSetPara[4]->write(&header.timestamp, parameterDataTypes[4],
|
||||
memspace, *dataSpacePara);
|
||||
@ -335,8 +332,8 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
|
||||
dataSetPara[7]->write(&header.column, parameterDataTypes[7], memspace,
|
||||
*dataSpacePara);
|
||||
i = 8;
|
||||
dataSetPara[8]->write(&header.reserved, parameterDataTypes[8],
|
||||
memspace, *dataSpacePara);
|
||||
dataSetPara[8]->write(&header.reserved, parameterDataTypes[8], memspace,
|
||||
*dataSpacePara);
|
||||
i = 9;
|
||||
dataSetPara[9]->write(&header.debug, parameterDataTypes[9], memspace,
|
||||
*dataSpacePara);
|
||||
|
@ -23,15 +23,16 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
||||
|
||||
void CloseFile() override;
|
||||
|
||||
void CreateFirstHDF5DataFile(
|
||||
const std::string& fNamePrefix,
|
||||
void CreateFirstHDF5DataFile(const std::string &fNamePrefix,
|
||||
const uint64_t fIndex, const bool owEnable,
|
||||
const bool sMode, const uint32_t uPortNumber,
|
||||
const uint32_t mFramesPerFile, const uint64_t nImages,
|
||||
const uint32_t nX, const uint32_t nY,
|
||||
const uint32_t dr) override;
|
||||
const uint32_t mFramesPerFile,
|
||||
const uint64_t nImages, const uint32_t nX,
|
||||
const uint32_t nY, 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:
|
||||
void CreateFile();
|
||||
|
@ -76,12 +76,12 @@ void Implementation::SetupFifoStructure() {
|
||||
|
||||
// create fifo structure
|
||||
try {
|
||||
fifo.push_back(sls::make_unique<Fifo>(i, datasize, generalData->fifoDepth));
|
||||
fifo.push_back(
|
||||
sls::make_unique<Fifo>(i, datasize, generalData->fifoDepth));
|
||||
} catch (...) {
|
||||
fifo.clear();
|
||||
generalData->fifoDepth = 0;
|
||||
throw RuntimeError(
|
||||
"Could not allocate memory for fifo structure " +
|
||||
throw RuntimeError("Could not allocate memory for fifo structure " +
|
||||
std::to_string(i) + ". FifoDepth is now 0.");
|
||||
}
|
||||
// set the listener & dataprocessor threads to point to the right fifo
|
||||
@ -97,7 +97,8 @@ void Implementation::SetupFifoStructure() {
|
||||
(double)(1024 * 1024)
|
||||
<< " MB";
|
||||
}
|
||||
LOG(logINFO) << generalData->numUDPInterfaces << " Fifo structure(s) reconstructed";
|
||||
LOG(logINFO) << generalData->numUDPInterfaces
|
||||
<< " Fifo structure(s) reconstructed";
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
@ -160,8 +161,7 @@ void Implementation::setDetectorType(const detectorType d) {
|
||||
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||
|
||||
try {
|
||||
listener.push_back(sls::make_unique<Listener>(
|
||||
i, &status));
|
||||
listener.push_back(sls::make_unique<Listener>(i, &status));
|
||||
SetupListener(i);
|
||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(i));
|
||||
SetupDataProcessor(i);
|
||||
@ -208,7 +208,8 @@ void Implementation::SetupDataProcessor(int i) {
|
||||
void Implementation::SetupDataStreamer(int i) {
|
||||
dataStreamer[i]->SetFifo(fifo[i].get());
|
||||
dataStreamer[i]->SetGeneralData(generalData);
|
||||
dataStreamer[i]->CreateZmqSockets(streamingPort, streamingSrcIP, streamingHwm);
|
||||
dataStreamer[i]->CreateZmqSockets(streamingPort, streamingSrcIP,
|
||||
streamingHwm);
|
||||
dataStreamer[i]->SetAdditionalJsonHeader(additionalJsonHeader);
|
||||
dataStreamer[i]->SetFileIndex(fileIndex);
|
||||
dataStreamer[i]->SetFlipRows(flipRows);
|
||||
@ -367,7 +368,8 @@ void Implementation::setArping(const bool i,
|
||||
// setup interface
|
||||
for (int i = 0; i != generalData->numUDPInterfaces; ++i) {
|
||||
// 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;
|
||||
}
|
||||
arping.SetInterfacesAndIps(i, eth[i], ips[i]);
|
||||
@ -384,7 +386,8 @@ slsDetectorDefs::ROI Implementation::getReceiverROI() const {
|
||||
void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
|
||||
receiverRoi = arg;
|
||||
|
||||
if (generalData->numUDPInterfaces == 1 || generalData->detType == slsDetectorDefs::GOTTHARD2) {
|
||||
if (generalData->numUDPInterfaces == 1 ||
|
||||
generalData->detType == slsDetectorDefs::GOTTHARD2) {
|
||||
portRois[0] = arg;
|
||||
} else {
|
||||
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)
|
||||
dataProcessor[i]->SetReceiverROI(portRois[i]);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -552,7 +556,9 @@ void Implementation::setOverwriteEnable(const bool b) {
|
||||
<< (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) {
|
||||
generalData->framesPerFile = i;
|
||||
@ -763,15 +769,15 @@ void Implementation::stopReceiver() {
|
||||
// callback
|
||||
if (acquisitionFinishedCallBack) {
|
||||
try {
|
||||
acquisitionFinishedCallBack((tot / generalData->numUDPInterfaces),
|
||||
acquisitionFinishedCallBack(
|
||||
(tot / generalData->numUDPInterfaces),
|
||||
pAcquisitionFinished);
|
||||
} catch (const std::exception &e) {
|
||||
// change status
|
||||
status = IDLE;
|
||||
LOG(logINFO) << "Receiver Stopped";
|
||||
LOG(logINFO) << "Status: " << ToString(status);
|
||||
throw RuntimeError(
|
||||
"Acquisition Finished Callback Error: " +
|
||||
throw RuntimeError("Acquisition Finished Callback Error: " +
|
||||
std::string(e.what()));
|
||||
}
|
||||
}
|
||||
@ -862,7 +868,8 @@ void Implementation::SetupWriter() {
|
||||
try {
|
||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
|
||||
std::ostringstream os;
|
||||
os << filePath << "/" << fileName << "_d" << (modulePos * generalData->numUDPInterfaces + i);
|
||||
os << filePath << "/" << fileName << "_d"
|
||||
<< (modulePos * generalData->numUDPInterfaces + i);
|
||||
std::string fileNamePrefix = os.str();
|
||||
dataProcessor[i]->CreateFirstFiles(
|
||||
fileNamePrefix, fileIndex, overwriteEnable, silentMode,
|
||||
@ -893,8 +900,7 @@ void Implementation::StartMasterWriter() {
|
||||
masterAttributes.framePadding = framePadding;
|
||||
masterAttributes.scanParams = scanParams;
|
||||
masterAttributes.totalFrames = numberOfTotalFrames;
|
||||
masterAttributes.receiverRoi =
|
||||
receiverRoiMetadata;
|
||||
masterAttributes.receiverRoi = receiverRoiMetadata;
|
||||
masterAttributes.exptime = acquisitionTime;
|
||||
masterAttributes.period = acquisitionPeriod;
|
||||
masterAttributes.burstMode = burstMode;
|
||||
@ -908,14 +914,17 @@ void Implementation::StartMasterWriter() {
|
||||
masterAttributes.quad = quadEnable;
|
||||
masterAttributes.readNRows = readNRows;
|
||||
masterAttributes.ratecorr = rateCorrections;
|
||||
masterAttributes.adcmask =
|
||||
generalData->tengigaEnable ? generalData->adcEnableMaskTenGiga : generalData->adcEnableMaskOneGiga;
|
||||
masterAttributes.analog = (generalData->readoutType == ANALOG_ONLY ||
|
||||
masterAttributes.adcmask = generalData->tengigaEnable
|
||||
? generalData->adcEnableMaskTenGiga
|
||||
: generalData->adcEnableMaskOneGiga;
|
||||
masterAttributes.analog =
|
||||
(generalData->readoutType == ANALOG_ONLY ||
|
||||
generalData->readoutType == ANALOG_AND_DIGITAL)
|
||||
? 1
|
||||
: 0;
|
||||
masterAttributes.analogSamples = generalData->nAnalogSamples;
|
||||
masterAttributes.digital = (generalData->readoutType == DIGITAL_ONLY ||
|
||||
masterAttributes.digital =
|
||||
(generalData->readoutType == DIGITAL_ONLY ||
|
||||
generalData->readoutType == ANALOG_AND_DIGITAL)
|
||||
? 1
|
||||
: 0;
|
||||
@ -947,10 +956,9 @@ void Implementation::StartMasterWriter() {
|
||||
// create virtual hdf5 file (if multiple files)
|
||||
if (dataProcessor[0]->GetFilesInAcquisition() > 1 ||
|
||||
(numPorts.x * numPorts.y) > 1) {
|
||||
virtualFileName =
|
||||
dataProcessor[0]->CreateVirtualFile(
|
||||
filePath, fileName, fileIndex, overwriteEnable,
|
||||
silentMode, modulePos, numberOfTotalFrames, numPorts.x, numPorts.y,
|
||||
virtualFileName = dataProcessor[0]->CreateVirtualFile(
|
||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||
modulePos, numberOfTotalFrames, numPorts.x, numPorts.y,
|
||||
&hdf5LibMutex);
|
||||
}
|
||||
// link file in master
|
||||
@ -962,7 +970,8 @@ void Implementation::StartMasterWriter() {
|
||||
#endif
|
||||
} catch (std::exception &e) {
|
||||
// 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
|
||||
void Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
if (generalData->detType == EIGER) {
|
||||
throw RuntimeError(
|
||||
"Cannot set number of UDP interfaces for Eiger");
|
||||
throw RuntimeError("Cannot set number of UDP interfaces for Eiger");
|
||||
}
|
||||
|
||||
if (generalData->numUDPInterfaces != n) {
|
||||
@ -1020,8 +1028,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
|
||||
// listener and dataprocessor threads
|
||||
try {
|
||||
listener.push_back(sls::make_unique<Listener>(
|
||||
i, &status));
|
||||
listener.push_back(sls::make_unique<Listener>(i, &status));
|
||||
SetupListener(i);
|
||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(i));
|
||||
SetupDataProcessor(i);
|
||||
@ -1120,15 +1127,18 @@ int Implementation::getUDPSocketBufferSize() const {
|
||||
|
||||
void Implementation::setUDPSocketBufferSize(const int s) {
|
||||
size_t listSize = listener.size();
|
||||
if ((generalData->detType == JUNGFRAU || generalData->detType == GOTTHARD2) &&
|
||||
if ((generalData->detType == JUNGFRAU ||
|
||||
generalData->detType == GOTTHARD2) &&
|
||||
(int)listSize != generalData->numUDPInterfaces) {
|
||||
throw RuntimeError(
|
||||
"Number of Interfaces " + std::to_string(generalData->numUDPInterfaces) +
|
||||
" do not match listener size " + std::to_string(listSize));
|
||||
throw RuntimeError("Number of Interfaces " +
|
||||
std::to_string(generalData->numUDPInterfaces) +
|
||||
" do not match listener size " +
|
||||
std::to_string(listSize));
|
||||
}
|
||||
|
||||
for (auto &l : listener) {
|
||||
l->CreateDummySocketForUDPSocketBufferSize(s, actualUDPSocketBufferSize);
|
||||
l->CreateDummySocketForUDPSocketBufferSize(s,
|
||||
actualUDPSocketBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1160,8 +1170,7 @@ void Implementation::setDataStreamEnable(const bool enable) {
|
||||
dataStreamEnable = false;
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetDataStreamEnable(dataStreamEnable);
|
||||
throw RuntimeError(
|
||||
"Could not set data stream enable.");
|
||||
throw RuntimeError("Could not set data stream enable.");
|
||||
}
|
||||
}
|
||||
SetThreadPriorities();
|
||||
@ -1212,9 +1221,7 @@ void Implementation::setStreamingPort(const uint32_t i) {
|
||||
LOG(logINFO) << "Streaming Port: " << streamingPort;
|
||||
}
|
||||
|
||||
IpAddr Implementation::getStreamingSourceIP() const {
|
||||
return streamingSrcIP;
|
||||
}
|
||||
IpAddr Implementation::getStreamingSourceIP() const { return streamingSrcIP; }
|
||||
|
||||
void Implementation::setStreamingSourceIP(const IpAddr ip) {
|
||||
streamingSrcIP = ip;
|
||||
@ -1250,8 +1257,7 @@ Implementation::getAdditionalJsonParameter(const std::string &key) const {
|
||||
if (additionalJsonHeader.find(key) != additionalJsonHeader.end()) {
|
||||
return additionalJsonHeader.at(key);
|
||||
}
|
||||
throw RuntimeError("No key " + key +
|
||||
" found in additional json header");
|
||||
throw RuntimeError("No key " + key + " found in additional json header");
|
||||
}
|
||||
|
||||
void Implementation::setAdditionalJsonParameter(const std::string &key,
|
||||
@ -1482,11 +1488,14 @@ void Implementation::setNumberofDigitalSamples(const uint32_t i) {
|
||||
generalData->SetNumberOfDigitalSamples(i);
|
||||
SetupFifoStructure();
|
||||
}
|
||||
LOG(logINFO) << "Number of Digital Samples: " << generalData->nDigitalSamples;
|
||||
LOG(logINFO) << "Number of Digital Samples: "
|
||||
<< generalData->nDigitalSamples;
|
||||
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) {
|
||||
if (generalData->counterMask != i) {
|
||||
@ -1498,7 +1507,9 @@ void Implementation::setCounterMask(const uint32_t i) {
|
||||
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) {
|
||||
if (generalData->dynamicRange != i) {
|
||||
@ -1510,10 +1521,13 @@ void Implementation::setDynamicRange(const uint32_t i) {
|
||||
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) {
|
||||
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
|
||||
generalData->SetDetectorROI(arg);
|
||||
SetupFifoStructure();
|
||||
@ -1523,7 +1537,9 @@ void Implementation::setDetectorROI(slsDetectorDefs::ROI arg) {
|
||||
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) {
|
||||
if (generalData->tengigaEnable != b) {
|
||||
@ -1541,11 +1557,12 @@ void Implementation::setTenGigaEnable(const bool b) {
|
||||
}
|
||||
LOG(logDEBUG) << "Detector datastream updated [Left: "
|
||||
<< ToString(detectorDataStream[LEFT])
|
||||
<< ", Right: "
|
||||
<< ToString(detectorDataStream[RIGHT]) << "]";
|
||||
<< ", 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);
|
||||
}
|
||||
|
||||
@ -1618,8 +1635,7 @@ void Implementation::setThresholdEnergy(const int value) {
|
||||
|
||||
void Implementation::setThresholdEnergy(const std::array<int, 3> value) {
|
||||
thresholdAllEnergyeV = value;
|
||||
LOG(logINFO) << "Threshold Energy (eV): "
|
||||
<< ToString(thresholdAllEnergyeV);
|
||||
LOG(logINFO) << "Threshold Energy (eV): " << ToString(thresholdAllEnergyeV);
|
||||
}
|
||||
|
||||
void Implementation::setRateCorrections(const std::vector<int64_t> &t) {
|
||||
|
@ -31,9 +31,7 @@ Listener::Listener(int index, std::atomic<runStatus> *status)
|
||||
|
||||
Listener::~Listener() = default;
|
||||
|
||||
bool Listener::isPortDisabled() const {
|
||||
return disabledPort;
|
||||
}
|
||||
bool Listener::isPortDisabled() const { return disabledPort; }
|
||||
|
||||
uint64_t Listener::GetPacketsCaught() const { return numPacketsCaught; }
|
||||
|
||||
@ -84,7 +82,8 @@ void Listener::SetEthernetInterface(const std::string e) {
|
||||
eth = "";
|
||||
}
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,10 +106,7 @@ void Listener::SetFrameDiscardPolicy(frameDiscardPolicy value) {
|
||||
frameDiscardMode = value;
|
||||
}
|
||||
|
||||
void Listener::SetSilentMode(bool enable) {
|
||||
silentMode = enable;
|
||||
}
|
||||
|
||||
void Listener::SetSilentMode(bool enable) { silentMode = enable; }
|
||||
|
||||
void Listener::ResetParametersforNewAcquisition() {
|
||||
StopRunning();
|
||||
@ -163,9 +159,10 @@ void Listener::CreateUDPSocket(int& actualSize) {
|
||||
}
|
||||
|
||||
try {
|
||||
udpSocket = make_unique<UdpRxSocket>(udpPortNumber, packetSize,
|
||||
(eth.length() ? InterfaceNameToIp(eth).str().c_str()
|
||||
: nullptr), generalData->udpSocketBufferSize);
|
||||
udpSocket = make_unique<UdpRxSocket>(
|
||||
udpPortNumber, packetSize,
|
||||
(eth.length() ? InterfaceNameToIp(eth).str().c_str() : nullptr),
|
||||
generalData->udpSocketBufferSize);
|
||||
LOG(logINFO) << index << ": UDP port opened at port " << udpPortNumber;
|
||||
} catch (...) {
|
||||
throw RuntimeError("Could not create UDP socket on port " +
|
||||
@ -192,8 +189,8 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int& actualSize) {
|
||||
// custom setup (s != 0)
|
||||
// default setup at startup (s = 0)
|
||||
int size = (s == 0 ? generalData->udpSocketBufferSize : s);
|
||||
LOG(logINFO) << "Testing UDP Socket Buffer size " << size << " with test port "
|
||||
<< udpPortNumber;
|
||||
LOG(logINFO) << "Testing UDP Socket Buffer size " << size
|
||||
<< " with test port " << udpPortNumber;
|
||||
int previousSize = generalData->udpSocketBufferSize;
|
||||
generalData->udpSocketBufferSize = size;
|
||||
|
||||
@ -209,10 +206,10 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s, int& actualSize) {
|
||||
|
||||
// create dummy socket
|
||||
try {
|
||||
UdpRxSocket g(udpPortNumber, packetSize,
|
||||
(eth.length()
|
||||
? InterfaceNameToIp(eth).str().c_str()
|
||||
: nullptr), generalData->udpSocketBufferSize);
|
||||
UdpRxSocket g(
|
||||
udpPortNumber, packetSize,
|
||||
(eth.length() ? InterfaceNameToIp(eth).str().c_str() : nullptr),
|
||||
generalData->udpSocketBufferSize);
|
||||
|
||||
// doubled due to kernel bookkeeping (could also be less due to
|
||||
// permissions)
|
||||
@ -245,8 +242,8 @@ void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
|
||||
void Listener::ThreadExecution() {
|
||||
char *buffer;
|
||||
fifo->GetNewAddress(buffer);
|
||||
LOG(logDEBUG5) << "Listener " << index << ", pop 0x"
|
||||
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
|
||||
LOG(logDEBUG5) << "Listener " << index << ", pop 0x" << std::hex
|
||||
<< (void *)(buffer) << std::dec << ":" << buffer;
|
||||
auto *memImage = reinterpret_cast<image_structure *>(buffer);
|
||||
|
||||
// udpsocket doesnt exist
|
||||
@ -284,12 +281,13 @@ void Listener::StopListening(char *buf, size_t & size) {
|
||||
size = DUMMY_PACKET_VALUE;
|
||||
fifo->PushAddress(buf);
|
||||
StopRunning();
|
||||
LOG(logDEBUG1) << index << ": Listening Completed. Packets (" << udpPortNumber
|
||||
<< ") : " << numPacketsCaught;
|
||||
LOG(logDEBUG1) << index << ": Listening Completed. Packets ("
|
||||
<< udpPortNumber << ") : " << numPacketsCaught;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
uint32_t pnum = 0;
|
||||
@ -316,7 +314,8 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
|
||||
// carry over packet
|
||||
if (carryOverFlag) {
|
||||
LOG(logDEBUG3) << index << "carry flag";
|
||||
GetPacketIndices(fnum, pnum, bnum, standardHeader, carryOverPacket.get(), srcDetHeader);
|
||||
GetPacketIndices(fnum, pnum, bnum, standardHeader,
|
||||
carryOverPacket.get(), srcDetHeader);
|
||||
|
||||
// future packet
|
||||
if (fnum != currentFrameIndex) {
|
||||
@ -327,10 +326,13 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
|
||||
carryOverFlag = false;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -346,12 +348,14 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
|
||||
if (rc <= 0) {
|
||||
if (numpackets == 0)
|
||||
return 0;
|
||||
return HandleFuturePacket(true, numpackets, fnum, isHeaderEmpty, imageSize, dstHeader);
|
||||
return HandleFuturePacket(true, numpackets, fnum, isHeaderEmpty,
|
||||
imageSize, dstHeader);
|
||||
}
|
||||
|
||||
numPacketsCaught++;
|
||||
numPacketsStatistic++;
|
||||
GetPacketIndices(fnum, pnum, bnum, standardHeader, listeningPacket.get(), srcDetHeader);
|
||||
GetPacketIndices(fnum, pnum, bnum, standardHeader,
|
||||
listeningPacket.get(), srcDetHeader);
|
||||
|
||||
// Eiger Firmware in a weird state
|
||||
if (generalData->detType == EIGER && fnum == 0) {
|
||||
@ -383,9 +387,12 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
|
||||
if (fnum != currentFrameIndex) {
|
||||
carryOverFlag = true;
|
||||
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
|
||||
@ -397,7 +404,10 @@ uint32_t Listener::ListenToAnImage(sls_receiver_header & dstHeader, char *dstDat
|
||||
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) {
|
||||
case DISCARD_EMPTY_FRAMES:
|
||||
if (!numpackets) {
|
||||
@ -424,8 +434,10 @@ size_t Listener::HandleFuturePacket(bool EOA, uint32_t numpackets, uint64_t fnum
|
||||
// no packet to get bnum
|
||||
dstHeader.detHeader.row = row;
|
||||
dstHeader.detHeader.column = column;
|
||||
dstHeader.detHeader.detType = static_cast<uint8_t>(generalData->detType);
|
||||
dstHeader.detHeader.version = static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION);
|
||||
dstHeader.detHeader.detType =
|
||||
static_cast<uint8_t>(generalData->detType);
|
||||
dstHeader.detHeader.version =
|
||||
static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION);
|
||||
}
|
||||
if (!EOA) {
|
||||
++currentFrameIndex;
|
||||
@ -433,7 +445,12 @@ size_t Listener::HandleFuturePacket(bool EOA, uint32_t numpackets, uint64_t fnum
|
||||
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
|
||||
switch (generalData->detType) {
|
||||
@ -449,7 +466,8 @@ void Listener::CopyPacket(char* dst, char* src, uint32_t dataSize, uint32_t detH
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
if (pnum == (generalData->packetsPerFrame - 1))
|
||||
memcpy(dst + (pnum * dataSize), &src[detHeaderSize], correctedDataSize);
|
||||
memcpy(dst + (pnum * dataSize), &src[detHeaderSize],
|
||||
correctedDataSize);
|
||||
else
|
||||
memcpy(dst + (pnum * dataSize), &src[detHeaderSize], dataSize);
|
||||
break;
|
||||
@ -459,26 +477,32 @@ void Listener::CopyPacket(char* dst, char* src, uint32_t dataSize, uint32_t detH
|
||||
}
|
||||
|
||||
++numpackets;
|
||||
dstHeader.packetsMask[(
|
||||
(pnum < MAX_NUM_PACKETS) ? pnum : MAX_NUM_PACKETS - 1)] = 1;
|
||||
dstHeader
|
||||
.packetsMask[((pnum < MAX_NUM_PACKETS) ? pnum : MAX_NUM_PACKETS - 1)] =
|
||||
1;
|
||||
|
||||
// writer header
|
||||
if (isHeaderEmpty) {
|
||||
if (standardHeader) {
|
||||
memcpy((char *)&dstHeader, (char *)srcDetHeader, sizeof(sls_detector_header));
|
||||
memcpy((char *)&dstHeader, (char *)srcDetHeader,
|
||||
sizeof(sls_detector_header));
|
||||
} else {
|
||||
dstHeader.detHeader.frameNumber = currentFrameIndex;
|
||||
dstHeader.detHeader.bunchId = bnum;
|
||||
dstHeader.detHeader.row = row;
|
||||
dstHeader.detHeader.column = column;
|
||||
dstHeader.detHeader.detType = static_cast<uint8_t>(generalData->detType);
|
||||
dstHeader.detHeader.version = static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION);
|
||||
dstHeader.detHeader.detType =
|
||||
static_cast<uint8_t>(generalData->detType);
|
||||
dstHeader.detHeader.version =
|
||||
static_cast<uint8_t>(SLS_DETECTOR_HEADER_VERSION);
|
||||
}
|
||||
isHeaderEmpty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Listener::GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum, bool standardHeader, char* packet, sls_detector_header*& header) {
|
||||
void Listener::GetPacketIndices(uint64_t &fnum, uint32_t &pnum, uint64_t &bnum,
|
||||
bool standardHeader, char *packet,
|
||||
sls_detector_header *&header) {
|
||||
if (standardHeader) {
|
||||
header = (sls_detector_header *)(&packet[0]);
|
||||
fnum = header->frameNumber;
|
||||
@ -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
|
||||
// from roi to no roi)
|
||||
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() {
|
||||
LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic
|
||||
<< " numPacketsStatistic:" << numPacketsStatistic
|
||||
|
@ -47,7 +47,6 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
void SetFrameDiscardPolicy(frameDiscardPolicy value);
|
||||
void SetSilentMode(bool enable);
|
||||
|
||||
|
||||
void ResetParametersforNewAcquisition();
|
||||
void CreateUDPSocket(int &actualSize);
|
||||
void ShutDownUDPSocket();
|
||||
@ -87,11 +86,20 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
*/
|
||||
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();
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "MasterAttributes.h"
|
||||
#include <time.h>
|
||||
|
||||
|
||||
namespace sls {
|
||||
|
||||
void MasterAttributes::GetBinaryAttributes(
|
||||
@ -33,8 +32,7 @@ void MasterAttributes::GetBinaryAttributes(
|
||||
GetCtbBinaryAttributes(w);
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError(
|
||||
"Unknown Detector type to get master attributes");
|
||||
throw RuntimeError("Unknown Detector type to get master attributes");
|
||||
}
|
||||
GetFinalBinaryAttributes(w);
|
||||
w->EndObject();
|
||||
@ -66,8 +64,7 @@ void MasterAttributes::WriteHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
||||
WriteCtbHDF5Attributes(fd, group);
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError(
|
||||
"Unknown Detector type to get master attributes");
|
||||
throw RuntimeError("Unknown Detector type to get master attributes");
|
||||
}
|
||||
WriteFinalHDF5Attributes(fd, group);
|
||||
}
|
||||
@ -169,14 +166,15 @@ void MasterAttributes::GetFinalBinaryAttributes(
|
||||
}
|
||||
|
||||
#ifdef HDF5C
|
||||
void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *group) {
|
||||
void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd,
|
||||
H5::Group *group) {
|
||||
char c[1024]{};
|
||||
// version
|
||||
{
|
||||
double version = BINARY_WRITER_VERSION;
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::Attribute attribute =
|
||||
fd->createAttribute("Version", H5::PredType::NATIVE_DOUBLE, dataspace);
|
||||
H5::Attribute attribute = fd->createAttribute(
|
||||
"Version", H5::PredType::NATIVE_DOUBLE, dataspace);
|
||||
attribute.write(H5::PredType::NATIVE_DOUBLE, &version);
|
||||
}
|
||||
// timestamp
|
||||
@ -211,22 +209,22 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
|
||||
// geometry x
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Geometry in x axis",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Geometry in x axis", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&geometry.x, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// geometry y
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Geometry in y axis",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Geometry in y axis", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&geometry.y, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// Image Size
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("Image Size", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Image Size", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&imageSize, H5::PredType::NATIVE_INT);
|
||||
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
||||
H5::StrType strdatatype(H5::PredType::C_S1, 256);
|
||||
@ -239,22 +237,22 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
|
||||
// npixels x
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Number of pixels in x axis",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Number of pixels in x axis", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&nPixels.x, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// npixels y
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Number of pixels in y axis",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Number of pixels in y axis", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&nPixels.y, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// Maximum frames per file
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Maximum frames per file",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Maximum frames per file", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&maxFramesPerFile, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// Frame Discard Policy
|
||||
@ -269,8 +267,8 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
|
||||
// Frame Padding
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Frame Padding",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Frame Padding", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&framePadding, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// Scan Parameters
|
||||
@ -285,47 +283,48 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5::H5File *fd, H5::Group *grou
|
||||
// Total Frames
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Total Frames",
|
||||
H5::PredType::STD_U64LE, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Total Frames", H5::PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&totalFrames, H5::PredType::STD_U64LE);
|
||||
}
|
||||
// Receiver Roi xmin
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("receiver roi xmin",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"receiver roi xmin", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&receiverRoi.xmin, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// Receiver Roi xmax
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("receiver roi xmax",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"receiver roi xmax", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&receiverRoi.xmax, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// Receiver Roi ymin
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("receiver roi ymin",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"receiver roi ymin", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&receiverRoi.ymin, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// Receiver Roi ymax
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("receiver roi ymax",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"receiver roi ymax", H5::PredType::NATIVE_INT, dataspace);
|
||||
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]{};
|
||||
// Total Frames in file
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Frames in File",
|
||||
H5::PredType::STD_U64LE, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Frames in File", H5::PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&framesInFile, H5::PredType::STD_U64LE);
|
||||
}
|
||||
// additional json header
|
||||
@ -362,8 +361,8 @@ void MasterAttributes::WriteHDF5Period(H5::H5File *fd, H5::Group *group) {
|
||||
|
||||
void MasterAttributes::WriteHDF5DynamicRange(H5::H5File *fd, H5::Group *group) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("Dynamic Range", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Dynamic Range", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&dynamicRange, H5::PredType::NATIVE_INT);
|
||||
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
||||
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) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Ten Giga Enable",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Ten Giga Enable", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&tenGiga, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
|
||||
@ -384,38 +383,40 @@ void MasterAttributes::WriteHDF5ROI(H5::H5File *fd, H5::Group *group) {
|
||||
// Roi xmin
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("roi xmin", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"roi xmin", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&detectorRoi.xmin, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
// Roi xmax
|
||||
{
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("roi xmax", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"roi xmax", H5::PredType::NATIVE_INT, dataspace);
|
||||
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::DataSet dataset = group->createDataSet("Number of UDP Interfaces",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Number of UDP Interfaces", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&numUDPInterfaces, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
|
||||
void MasterAttributes::WriteHDF5ReadNRows(H5::H5File *fd, H5::Group *group) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("Number of rows", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Number of rows", H5::PredType::NATIVE_INT, dataspace);
|
||||
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]{};
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Threshold Energy",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Threshold Energy", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&thresholdEnergyeV, H5::PredType::NATIVE_INT);
|
||||
H5::DataSpace dataspaceAttr = H5::DataSpace(H5S_SCALAR);
|
||||
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);
|
||||
}
|
||||
|
||||
void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd, H5::Group *group) {
|
||||
void MasterAttributes::WriteHDF5ThresholdEnergies(H5::H5File *fd,
|
||||
H5::Group *group) {
|
||||
char c[1024]{};
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
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);
|
||||
}
|
||||
|
||||
void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd, H5::Group *group) {
|
||||
void MasterAttributes::WriteHDF5RateCorrections(H5::H5File *fd,
|
||||
H5::Group *group) {
|
||||
char c[1024]{};
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
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) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("Counter Mask", H5::PredType::STD_U32LE, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Counter Mask", H5::PredType::STD_U32LE, dataspace);
|
||||
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) {
|
||||
char c[1024]{};
|
||||
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) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("Analog Flag", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Analog Flag", H5::PredType::NATIVE_INT, dataspace);
|
||||
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::DataSet dataset =
|
||||
group->createDataSet("Analog Samples", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Analog Samples", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&analogSamples, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
|
||||
void MasterAttributes::WriteHDF5DigitalFlag(H5::H5File *fd, H5::Group *group) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("Digital Flag", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Digital Flag", H5::PredType::NATIVE_INT, dataspace);
|
||||
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::DataSet dataset = group->createDataSet("Digital Samples",
|
||||
H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Digital Samples", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&digitalSamples, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
|
||||
void MasterAttributes::WriteHDF5DbitOffset(H5::H5File *fd, H5::Group *group) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset =
|
||||
group->createDataSet("Dbit Offset", H5::PredType::NATIVE_INT, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Dbit Offset", H5::PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&dbitoffset, H5::PredType::NATIVE_INT);
|
||||
}
|
||||
|
||||
void MasterAttributes::WriteHDF5DbitList(H5::H5File *fd, H5::Group *group) {
|
||||
H5::DataSpace dataspace = H5::DataSpace(H5S_SCALAR);
|
||||
H5::DataSet dataset = group->createDataSet("Dbit Bitset List",
|
||||
H5::PredType::STD_U64LE, dataspace);
|
||||
H5::DataSet dataset = group->createDataSet(
|
||||
"Dbit Bitset List", H5::PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&dbitlist, H5::PredType::STD_U64LE);
|
||||
}
|
||||
#endif
|
||||
@ -586,7 +592,8 @@ void MasterAttributes::GetGotthardBinaryAttributes(
|
||||
};
|
||||
|
||||
#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::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5ROI(fd, group);
|
||||
@ -606,7 +613,8 @@ void MasterAttributes::GetJungfrauBinaryAttributes(
|
||||
}
|
||||
|
||||
#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::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5NumUDPInterfaces(fd, group);
|
||||
@ -639,7 +647,8 @@ void MasterAttributes::GetEigerBinaryAttributes(
|
||||
}
|
||||
|
||||
#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::WriteHDF5TenGiga(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
@ -678,7 +687,8 @@ void MasterAttributes::GetMythen3BinaryAttributes(
|
||||
}
|
||||
|
||||
#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::WriteHDF5TenGiga(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
@ -701,7 +711,8 @@ void MasterAttributes::GetGotthard2BinaryAttributes(
|
||||
}
|
||||
|
||||
#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::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5BurstMode(fd, group);
|
||||
@ -723,7 +734,8 @@ void MasterAttributes::GetMoenchBinaryAttributes(
|
||||
}
|
||||
|
||||
#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::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
@ -757,7 +769,8 @@ void MasterAttributes::GetCtbBinaryAttributes(
|
||||
}
|
||||
|
||||
#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::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
|
@ -7,21 +7,18 @@
|
||||
#include "sls/logger.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <rapidjson/prettywriter.h>
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
#include <chrono>
|
||||
|
||||
#ifdef HDF5C
|
||||
#include "H5Cpp.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace sls {
|
||||
|
||||
using ns = std::chrono::nanoseconds;
|
||||
|
||||
|
||||
|
||||
class MasterAttributes {
|
||||
public:
|
||||
// (before acquisition)
|
||||
|
@ -70,7 +70,8 @@ void LinkHDF5FileInMaster(std::string &masterFileName,
|
||||
|
||||
// create link for data dataset
|
||||
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,
|
||||
masterfd.getLocId(), linkname.c_str(),
|
||||
H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||
@ -152,8 +153,7 @@ std::string CreateMasterHDF5File(const std::string &filePath,
|
||||
error.printErrorStack();
|
||||
if (fd != nullptr)
|
||||
fd->close();
|
||||
throw RuntimeError(
|
||||
"Could not create/overwrite master HDF5 handles");
|
||||
throw RuntimeError("Could not create/overwrite master HDF5 handles");
|
||||
}
|
||||
if (!silentMode) {
|
||||
LOG(logINFO) << "Master File: " << fileName;
|
||||
@ -165,13 +165,12 @@ std::string CreateVirtualHDF5File(
|
||||
const std::string &filePath, const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||
const int modulePos, const int numUnitsPerReadout,
|
||||
const uint32_t maxFramesPerFile,
|
||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
||||
const int numModX, const int numModY, const H5::DataType dataType,
|
||||
const std::vector<std::string> parameterNames,
|
||||
const std::vector<H5::DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
|
||||
bool gotthard25um) {
|
||||
const uint32_t maxFramesPerFile, const uint32_t nPixelsX,
|
||||
const uint32_t nPixelsY, const uint32_t dynamicRange,
|
||||
const uint64_t numImagesCaught, const int numModX, const int numModY,
|
||||
const H5::DataType dataType, const std::vector<std::string> parameterNames,
|
||||
const std::vector<H5::DataType> parameterDataTypes,
|
||||
std::mutex *hdf5LibMutex, bool gotthard25um) {
|
||||
|
||||
// virtual file name
|
||||
std::ostringstream osfn;
|
||||
@ -210,7 +209,8 @@ std::string CreateVirtualHDF5File(
|
||||
// dataspace
|
||||
hsize_t vdsDims[DATA_RANK] = {numImagesCaught, numModY * nDimy,
|
||||
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 vdsDataSpacePara(VDS_PARA_RANK, vdsDimsPara, nullptr);
|
||||
|
||||
@ -290,17 +290,19 @@ std::string CreateVirtualHDF5File(
|
||||
H5::DataSpace srcDataSpace(DATA_RANK, srcDims, srcDimsMax);
|
||||
hsize_t srcDimsPara[PARA_RANK] = {nDimx};
|
||||
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:
|
||||
// (framescaught not multiple of framesperfile,
|
||||
// virtual parameter datasets error loading (bad scalar value))
|
||||
if (nDimx != maxFramesPerFile) {
|
||||
hsize_t count[1] = {nDimx};
|
||||
hsize_t start[1] = {0};
|
||||
srcDataSpacePara.selectHyperslab(H5S_SELECT_SET, count, start, strideBetweenBlocksPara, blockSizePara);
|
||||
srcDataSpacePara.selectHyperslab(
|
||||
H5S_SELECT_SET, count, start, strideBetweenBlocksPara,
|
||||
blockSizePara);
|
||||
}
|
||||
|
||||
|
||||
// mapping of property list
|
||||
plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(),
|
||||
DATASET_NAME, srcDataSpace);
|
||||
@ -325,8 +327,8 @@ std::string CreateVirtualHDF5File(
|
||||
framesSaved += nDimx;
|
||||
}
|
||||
// datasets
|
||||
H5::DataSet vdsDataSet(fd->createDataSet(DATASET_NAME, dataType,
|
||||
vdsDataSpace, plist));
|
||||
H5::DataSet vdsDataSet(
|
||||
fd->createDataSet(DATASET_NAME, dataType, vdsDataSpace, plist));
|
||||
|
||||
for (unsigned int p = 0; p < paraSize; ++p) {
|
||||
H5::DataSet vdsDataSetPara(fd->createDataSet(
|
||||
@ -340,8 +342,7 @@ std::string CreateVirtualHDF5File(
|
||||
if (fd) {
|
||||
fd->close();
|
||||
}
|
||||
throw RuntimeError(
|
||||
"Could not create/overwrite virtual HDF5 handles");
|
||||
throw RuntimeError("Could not create/overwrite virtual HDF5 handles");
|
||||
}
|
||||
if (!silentMode) {
|
||||
LOG(logINFO) << "Virtual File: " << fileName;
|
||||
|
@ -10,9 +10,6 @@ namespace sls {
|
||||
|
||||
namespace masterFileUtility {
|
||||
|
||||
|
||||
|
||||
|
||||
std::string CreateMasterBinaryFile(const std::string &filePath,
|
||||
const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex,
|
||||
@ -37,13 +34,12 @@ std::string CreateVirtualHDF5File(
|
||||
const std::string &filePath, const std::string &fileNamePrefix,
|
||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||
const int modulePos, const int numUnitsPerReadout,
|
||||
const uint32_t maxFramesPerFile,
|
||||
const uint32_t nPixelsX, const uint32_t nPixelsY,
|
||||
const uint32_t dynamicRange, const uint64_t numImagesCaught,
|
||||
const int numModX, const int numModY, const H5::DataType dataType,
|
||||
const std::vector<std::string> parameterNames,
|
||||
const std::vector<H5::DataType> parameterDataTypes, std::mutex *hdf5LibMutex,
|
||||
bool gotthard25um);
|
||||
const uint32_t maxFramesPerFile, const uint32_t nPixelsX,
|
||||
const uint32_t nPixelsY, const uint32_t dynamicRange,
|
||||
const uint64_t numImagesCaught, const int numModX, const int numModY,
|
||||
const H5::DataType dataType, const std::vector<std::string> parameterNames,
|
||||
const std::vector<H5::DataType> parameterDataTypes,
|
||||
std::mutex *hdf5LibMutex, bool gotthard25um);
|
||||
#endif
|
||||
} // namespace masterFileUtility
|
||||
|
||||
|
@ -54,7 +54,8 @@ void printHelp() {
|
||||
int StartAcq(const std::string &filePath, const std::string &fileName,
|
||||
uint64_t fileIndex, size_t imageSize, void *objectPointer) {
|
||||
LOG(sls::logINFOBLUE) << "#### StartAcq: filePath:" << filePath
|
||||
<< " fileName:" << fileName << " fileIndex:" << fileIndex
|
||||
<< " fileName:" << fileName
|
||||
<< " fileIndex:" << fileIndex
|
||||
<< " imageSize:" << imageSize << " ####";
|
||||
return 0;
|
||||
}
|
||||
@ -101,7 +102,8 @@ void GetData(slsDetectorDefs::sls_receiver_header& header, char *dataPointer,
|
||||
* @param modifiedImageSize new data size in bytes after the callback.
|
||||
* 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;
|
||||
|
||||
PRINT_IN_COLOR(
|
||||
|
@ -128,8 +128,10 @@ int64_t Receiver::getReceiverVersion() {
|
||||
return tcpipInterface->getReceiverVersion();
|
||||
}
|
||||
|
||||
void Receiver::registerCallBackStartAcquisition(
|
||||
int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
|
||||
void Receiver::registerCallBackStartAcquisition(int (*func)(const std::string &,
|
||||
const std::string &,
|
||||
uint64_t, size_t,
|
||||
void *),
|
||||
void *arg) {
|
||||
tcpipInterface->registerCallBackStartAcquisition(func, arg);
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ ThreadObject::ThreadObject(int index, std::string type)
|
||||
try {
|
||||
threadObject = std::thread(&ThreadObject::RunningThread, this);
|
||||
} catch (...) {
|
||||
throw RuntimeError("Could not create " + type +
|
||||
" thread with index " + std::to_string(index));
|
||||
throw RuntimeError("Could not create " + type + " thread with index " +
|
||||
std::to_string(index));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,9 @@ struct image_structure {
|
||||
slsDetectorDefs::sls_receiver_header header;
|
||||
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
|
||||
#define MAX_CHUNKED_IMAGES (1)
|
||||
@ -64,7 +66,6 @@ struct image_structure {
|
||||
#define STREAMER_PRIORITY (10)
|
||||
#define TCP_PRIORITY (10)
|
||||
|
||||
|
||||
#ifdef HDF5C
|
||||
#define DATASET_NAME "/data"
|
||||
#endif
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
|
||||
TEST_CASE("Empty buffer") {
|
||||
CircularFifo<char> fifo(0);
|
||||
|
||||
|
@ -192,8 +192,7 @@ bool operator!=(const std::vector<T> &lhs,
|
||||
}
|
||||
|
||||
template <typename T, size_t Capacity>
|
||||
std::ostream &operator<<(std::ostream &os,
|
||||
const StaticVector<T, Capacity> &c) {
|
||||
std::ostream &operator<<(std::ostream &os, const StaticVector<T, Capacity> &c) {
|
||||
return os << ToString(c);
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
*@short functions to open/close zmq sockets
|
||||
*/
|
||||
|
||||
#include "sls/sls_detector_exceptions.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/sls_detector_exceptions.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -23,7 +23,6 @@ namespace sls {
|
||||
// #define ZMQ_DETAIL
|
||||
#define ROIVERBOSITY
|
||||
|
||||
|
||||
/** zmq header structure */
|
||||
struct zmqHeader {
|
||||
/** true if incoming data, false if end of acquisition */
|
||||
@ -224,8 +223,7 @@ class ZmqSocket {
|
||||
/** Socket descriptor */
|
||||
mySocketDescriptors sockfd;
|
||||
|
||||
std::unique_ptr<char[]> header_buffer =
|
||||
make_unique<char[]>(MAX_STR_LENGTH);
|
||||
std::unique_ptr<char[]> header_buffer = make_unique<char[]>(MAX_STR_LENGTH);
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <stdexcept>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
namespace sls {
|
||||
|
||||
#define DEFAULT_PACKET_SIZE 1286
|
||||
|
@ -123,8 +123,7 @@ std::ostream &operator<<(std::ostream &os,
|
||||
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
|
||||
std::ostringstream oss;
|
||||
if (r.fix < -1 || r.fix > 1 || r.normal < -1 || r.normal > 1) {
|
||||
throw RuntimeError(
|
||||
"Invalid current source parameters. Cannot print.");
|
||||
throw RuntimeError("Invalid current source parameters. Cannot print.");
|
||||
}
|
||||
oss << '[';
|
||||
if (r.enable) {
|
||||
|
@ -417,4 +417,3 @@ void ZmqSocket::mySocketDescriptors::Close() {
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
||||
|
@ -60,8 +60,7 @@ std::vector<char> readBinaryFile(const std::string &fname,
|
||||
// check if it exists
|
||||
struct stat st;
|
||||
if (stat(fname.c_str(), &st) != 0) {
|
||||
throw RuntimeError(errorPrefix +
|
||||
std::string(" (file does not exist)"));
|
||||
throw RuntimeError(errorPrefix + std::string(" (file does not exist)"));
|
||||
}
|
||||
|
||||
FILE *fp = fopen(fname.c_str(), "rb");
|
||||
@ -76,8 +75,7 @@ std::vector<char> readBinaryFile(const std::string &fname,
|
||||
|
||||
std::vector<char> buffer(filesize, 0);
|
||||
if ((ssize_t)fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
|
||||
throw RuntimeError(errorPrefix +
|
||||
std::string(" (Could not read file)"));
|
||||
throw RuntimeError(errorPrefix + std::string(" (Could not read file)"));
|
||||
}
|
||||
|
||||
if (fclose(fp) != 0) {
|
||||
|
@ -333,8 +333,7 @@ TEST_CASE("streamingInterface") {
|
||||
REQUIRE(ToString(defs::streamingInterface::ETHERNET_10GB) == "10gbe");
|
||||
REQUIRE(ToString(defs::streamingInterface::LOW_LATENCY_LINK) == "lll");
|
||||
REQUIRE(ToString(defs::streamingInterface::LOW_LATENCY_LINK |
|
||||
defs::streamingInterface::ETHERNET_10GB) ==
|
||||
"lll, 10gbe");
|
||||
defs::streamingInterface::ETHERNET_10GB) == "lll, 10gbe");
|
||||
}
|
||||
|
||||
// Speed level
|
||||
@ -353,10 +352,8 @@ TEST_CASE("string to speedLevel") {
|
||||
defs::speedLevel::HALF_SPEED);
|
||||
REQUIRE(StringTo<defs::speedLevel>("quarter_speed") ==
|
||||
defs::speedLevel::QUARTER_SPEED);
|
||||
REQUIRE(StringTo<defs::speedLevel>("108") ==
|
||||
defs::speedLevel::G2_108MHZ);
|
||||
REQUIRE(StringTo<defs::speedLevel>("144") ==
|
||||
defs::speedLevel::G2_144MHZ);
|
||||
REQUIRE(StringTo<defs::speedLevel>("108") == defs::speedLevel::G2_108MHZ);
|
||||
REQUIRE(StringTo<defs::speedLevel>("144") == defs::speedLevel::G2_144MHZ);
|
||||
}
|
||||
|
||||
} // namespace sls
|
||||
|
@ -33,8 +33,7 @@ int open_socket(int port) {
|
||||
|
||||
const std::string portname = std::to_string(port);
|
||||
if (getaddrinfo(host, portname.c_str(), &hints, &res)) {
|
||||
throw RuntimeError("Failed at getaddrinfo with " +
|
||||
std::string(host));
|
||||
throw RuntimeError("Failed at getaddrinfo with " + std::string(host));
|
||||
}
|
||||
int fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||
if (fd == -1) {
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
|
||||
TEST_CASE("Throws when cannot create socket") {
|
||||
REQUIRE_THROWS(ZmqSocket("sdiasodjajpvv", 5076001));
|
||||
}
|
||||
@ -118,4 +117,4 @@ TEST_CASE("Send header and data") {
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace
|
||||
} // namespace sls
|
@ -38,7 +38,8 @@ int main(int argc, char **argv) {
|
||||
for (int i = 0; i != 100; ++i) {
|
||||
std::cout << "Sending: " << i << "\n";
|
||||
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";
|
||||
}
|
||||
|
||||
@ -46,7 +47,8 @@ int main(int argc, char **argv) {
|
||||
for (int i = 0; i != 5; ++i) {
|
||||
std::cout << "Sending data\n";
|
||||
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)
|
||||
<< " bytes\n";
|
||||
}
|
||||
@ -54,7 +56,8 @@ int main(int argc, char **argv) {
|
||||
// Send too little data
|
||||
{
|
||||
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)
|
||||
<< " bytes\n";
|
||||
}
|
||||
@ -71,7 +74,8 @@ int main(int argc, char **argv) {
|
||||
for (int i = 0; i != 10; ++i) {
|
||||
std::cout << "Sending: " << i << "\n";
|
||||
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";
|
||||
}
|
||||
|
||||
|
@ -30,13 +30,14 @@ int main(int argc, char *argv[]) {
|
||||
sls::test::my_ip = "undefined";
|
||||
|
||||
Catch::Session session;
|
||||
auto cli =
|
||||
session.cli() |
|
||||
auto cli = session.cli() |
|
||||
sls::Opt(sls::test::hostname, "hostname")["-hn"]["--hostname"](
|
||||
"Detector hostname for integration tests") |
|
||||
sls::Opt(sls::test::detector_type, "detector_type")["-dt"]["--detector_type"](
|
||||
sls::Opt(sls::test::detector_type,
|
||||
"detector_type")["-dt"]["--detector_type"](
|
||||
"Detector type for integration tests") |
|
||||
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);
|
||||
|
||||
@ -47,8 +48,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
sls::test::type = slsDetectorDefs::GENERIC;
|
||||
if (!sls::test::detector_type.empty()) {
|
||||
sls::test::type =
|
||||
sls::StringTo<slsDetectorDefs::detectorType>(sls::test::detector_type);
|
||||
sls::test::type = sls::StringTo<slsDetectorDefs::detectorType>(
|
||||
sls::test::detector_type);
|
||||
}
|
||||
|
||||
return session.run();
|
||||
|
Loading…
x
Reference in New Issue
Block a user