Merge pull request #291 from slsdetectorgroup/j10partial

J10partial
This commit is contained in:
Dhanya Thattil 2021-08-16 17:18:01 +02:00 committed by GitHub
commit 3d90c1527a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 415 additions and 254 deletions

View File

@ -73,6 +73,11 @@ vetoalg
vetostream
serialnumber (put)
dbitpipeline
readnlines->partialread
setting number of udp interfaces from 1 to 2, didnt get image in gui
virtual server plots increasing values for every packet.. not every pixel
3. Firmware Requirements
========================

View File

@ -488,7 +488,7 @@ TEST_CASE("Eiger or Jungfrau nextframenumber",
CHECK(m.getNextFrameNumber() == (val + 1));
}
TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
TEST_CASE("Eiger partialread", "[.eigerintegration][partialread]") {
SingleDetectorConfig c;
// pick up multi detector from shm id 0
@ -501,16 +501,16 @@ TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
m.setDynamicRange(16);
m.enableTenGigabitEthernet(0);
m.setReadNLines(256);
CHECK(m.getReadNLines() == 256);
m.setReadNLines(1);
CHECK(m.getReadNLines() == 1);
m.setPartialReadout(256);
CHECK(m.getPartialReadout() == 256);
m.setPartialReadout(1);
CHECK(m.getPartialReadout() == 1);
m.setDynamicRange(8);
m.setReadNLines(256);
CHECK(m.getReadNLines() == 256);
CHECK_THROWS_AS(m.setReadNLines(1), sls::RuntimeError);
CHECK(m.getReadNLines() == 256);
CHECK_THROWS_AS(m.setReadNLines(0), sls::RuntimeError);
m.setReadNLines(256);
m.setPartialReadout(256);
CHECK(m.getPartialReadout() == 256);
CHECK_THROWS_AS(m.setPartialReadout(1), sls::RuntimeError);
CHECK(m.getPartialReadout() == 256);
CHECK_THROWS_AS(m.setPartialReadout(0), sls::RuntimeError);
m.setPartialReadout(256);
}

View File

@ -1846,18 +1846,20 @@ class Detector(CppDetectorApi):
@property
@element
def readnlines(self):
def partialread(self):
"""
[Eiger] Number of lines to read out per half module
[Eiger] Number of rows to read out per half module starting from the centre.
[Jungfrau] Number of rows to read per module starting from the centre.
Note
----
Options: 0 - 256. 256 is default. \n
The permissible values depend on dynamic range and 10Gbe enabled.
[Eiger] Options: 1 - 256. 256 is default. \n
[Eiger]The permissible values depend on dynamic range and 10Gbe enabled.\n\n
[Jungfrau] Options: 8 - 512 (multiples of 8)
"""
return self.getPartialReadout()
@readnlines.setter
def readnlines(self, value):
@partialread.setter
def partialread(self, value):
ut.set_using_dict(self.setPartialReadout, value)

View File

@ -473,7 +473,6 @@ void qTabSettings::Refresh() {
GetThresholdEnergies();
// eiger
else if (spinThreshold->isEnabled()) {
LOG(logINFOBLUE) << "calling it!";
GetThresholdEnergy();
}

View File

@ -38,7 +38,7 @@ int Beb_top = 0;
uint64_t Beb_deactivatedNextFrameNumber = 0;
int Beb_quadEnable = 0;
int Beb_positions[2] = {0, 0};
int Beb_readNLines = MAX_ROWS_PER_READOUT;
int Beb_partialReadout = MAX_ROWS_PER_READOUT;
int Beb_deactivated_transmission_flowcontrol_10g = 0;
int Beb_deactivated_transmission_delay_frame = 0;
int Beb_deactivated_transmission_delay_left = 0;
@ -1214,7 +1214,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
unsigned int maxnl = MAX_ROWS_PER_READOUT;
unsigned int maxnp = (ten_gig ? 4 : 16) * Beb_bit_mode;
unsigned int nl = Beb_readNLines;
unsigned int nl = Beb_partialReadout;
unsigned int npackets = (nl * maxnp) / maxnl;
if ((nl * maxnp) % maxnl) {
LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image "
@ -1612,7 +1612,7 @@ int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable) {
return OK;
}
void Beb_SetReadNLines(int value) { Beb_readNLines = value; }
void Beb_SetPartialReadout(int value) { Beb_partialReadout = value; }
uint16_t Beb_swap_uint16(uint16_t val) { return (val << 8) | (val >> 8); }

View File

@ -108,7 +108,7 @@ int Beb_SetDetectorPosition(int pos[]);
int Beb_SetNextFrameNumber(uint64_t value);
int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable);
void Beb_SetReadNLines(int value);
void Beb_SetPartialReadout(int value);
uint16_t Beb_swap_uint16(uint16_t val);
int Beb_open(u_int32_t **csp0base, u_int32_t offset);

View File

@ -1554,24 +1554,24 @@ int Feb_Control_SetChipSignalsToTrimQuad(int enable) {
return 1;
}
int Feb_Control_SetReadNLines(int value) {
LOG(logINFO, ("Setting Read N Lines to %d\n", value));
int Feb_Control_SetPartialReadout(int value) {
LOG(logINFO, ("Setting Partial Readout to %d\n", value));
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_PARTIAL_READOUT, value, 0, 0)) {
LOG(logERROR, ("Could not write %d to read n lines reg\n", value));
LOG(logERROR, ("Could not write %d to Partial Readout reg\n", value));
return 0;
}
return 1;
}
int Feb_Control_GetReadNLines() {
int Feb_Control_GetPartialReadout() {
uint32_t regVal = 0;
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
DAQ_REG_PARTIAL_READOUT, &regVal)) {
LOG(logERROR, ("Could not read back read n lines reg\n"));
LOG(logERROR, ("Could not read back Partial Readout reg\n"));
return -1;
}
LOG(logDEBUG1, ("Retval read n lines: %d\n", regVal));
LOG(logDEBUG1, ("Retval Partial Readout: %d\n", regVal));
return regVal;
}

View File

@ -88,8 +88,8 @@ void Feb_Control_SetMasterVariable(int val);
int Feb_Control_SetMaster(enum MASTERINDEX ind);
int Feb_Control_SetQuad(int val);
int Feb_Control_SetChipSignalsToTrimQuad(int enable);
int Feb_Control_SetReadNLines(int value);
int Feb_Control_GetReadNLines();
int Feb_Control_SetPartialReadout(int value);
int Feb_Control_GetPartialReadout();
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval);

View File

@ -88,7 +88,7 @@ uint64_t eiger_virtual_nextframenumber = 1;
int eiger_virtual_detPos[2] = {0, 0};
int eiger_virtual_test_mode = 0;
int eiger_virtual_quad_mode = 0;
int eiger_virtual_read_nlines = 256;
int eiger_virtual_partial_readout = 256;
int eiger_virtual_interrupt_subframe = 0;
int eiger_virtual_left_datastream = 1;
int eiger_virtual_right_datastream = 1;
@ -708,7 +708,7 @@ void setupDetector() {
setIODelay(DEFAULT_IO_DELAY);
setTiming(DEFAULT_TIMING_MODE);
setNextFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
setReadNLines(MAX_ROWS_PER_READOUT);
setPartialReadout(MAX_ROWS_PER_READOUT);
// SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
eiger_tau_ns = DEFAULT_RATE_CORRECTION;
setRateCorrection(DEFAULT_RATE_CORRECTION);
@ -1671,29 +1671,29 @@ int getInterruptSubframe() {
#endif
}
int setReadNLines(int value) {
int setPartialReadout(int value) {
if (value < 0)
return FAIL;
#ifndef VIRTUAL
sharedMemory_lockLocalLink();
if (!Feb_Control_SetReadNLines(value)) {
if (!Feb_Control_SetPartialReadout(value)) {
sharedMemory_unlockLocalLink();
return FAIL;
}
sharedMemory_unlockLocalLink();
Beb_SetReadNLines(value);
Beb_SetPartialReadout(value);
#else
eiger_virtual_read_nlines = value;
eiger_virtual_partial_readout = value;
#endif
return OK;
}
int getReadNLines() {
int getPartialReadout() {
#ifdef VIRTUAL
return eiger_virtual_read_nlines;
return eiger_virtual_partial_readout;
#else
sharedMemory_lockLocalLink();
int retval = Feb_Control_GetReadNLines();
int retval = Feb_Control_GetPartialReadout();
sharedMemory_unlockLocalLink();
return retval;
#endif
@ -2306,55 +2306,75 @@ void *start_timer(void *arg) {
int tgEnable = send_to_ten_gig;
int datasize = (tgEnable ? 4096 : 1024);
int packetsize = datasize + sizeof(sls_detector_header);
int numPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
int maxPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
int npixelsx = 256 * 2 * bytesPerPixel;
int databytes = 256 * 256 * 2 * bytesPerPixel;
int row = eiger_virtual_detPos[0];
int colLeft = top ? eiger_virtual_detPos[1] : eiger_virtual_detPos[1] + 1;
int colRight = top ? eiger_virtual_detPos[1] + 1 : eiger_virtual_detPos[1];
int ntotpixels = 256 * 256 * 4;
int partialReadout = getPartialReadout();
if (partialReadout == -1) {
LOG(logERROR,
("partial readout is -1. Assuming no partial readout.\n"));
partialReadout = MAX_ROWS_PER_READOUT;
}
const int maxRows = MAX_ROWS_PER_READOUT;
const int packetsPerFrame =
(maxPacketsPerFrame * partialReadout) / maxRows;
LOG(logDEBUG1,
(" dr:%d\n bytesperpixel:%f\n tgenable:%d\n datasize:%d\n "
"packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n "
"ntotpixels:%d\n",
dr, bytesPerPixel, tgEnable, datasize, packetsize, numPacketsPerFrame,
npixelsx, databytes, ntotpixels));
"packetsize:%d\n maxnumpackes:%d\n npixelsx:%d\n databytes:%d\n",
dr, bytesPerPixel, tgEnable, datasize, packetsize, maxPacketsPerFrame,
npixelsx, databytes));
// Generate data
char imageData[databytes * 2];
memset(imageData, 0, databytes * 2);
{
switch (dr) {
case 4:
for (int i = 0; i < ntotpixels / 2; ++i) {
int npixels = NCHAN * NCHIP;
const int pixelsPerPacket = (double)datasize / bytesPerPixel;
int pixelVal = 0;
if (dr == 4) {
npixels /= 2;
}
LOG(logDBUG1,
("pixels:%d pixelsperpacket:%d\n", npixels, pixelsPerPacket));
for (int i = 0; i < npixels; ++i) {
if (i > 0 && i % pixelsPerPacket == 0) {
++pixelVal;
}
switch (dr) {
case 4:
*((uint8_t *)(imageData + i)) =
eiger_virtual_test_mode
? 0xEE
: (uint8_t)(((2 * i & 0xF) << 4) | ((2 * i + 1) & 0xF));
}
break;
case 8:
for (int i = 0; i < ntotpixels; ++i) {
: (uint8_t)(((2 * pixelVal & 0xF) << 4) |
((2 * pixelVal) & 0xF));
//: (uint8_t)(((2 * pixelVal & 0xF) << 4) | ((2 * pixelVal + 1)
//& 0xF));
break;
case 8:
*((uint8_t *)(imageData + i)) =
eiger_virtual_test_mode ? 0xFE : (uint8_t)i;
}
break;
case 16:
for (int i = 0; i < ntotpixels; ++i) {
eiger_virtual_test_mode ? 0xFE : (uint8_t)pixelVal;
break;
case 16:
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
eiger_virtual_test_mode ? 0xFFE : (uint16_t)i;
}
break;
case 32:
for (int i = 0; i < ntotpixels; ++i) {
eiger_virtual_test_mode ? 0xFFE
: (uint16_t)pixelVal;
break;
case 32:
*((uint32_t *)(imageData + i * sizeof(uint32_t))) =
eiger_virtual_test_mode ? 0xFFFFFE : (uint32_t)i;
eiger_virtual_test_mode ? 0xFFFFFE
: (uint32_t)pixelVal;
break;
default:
break;
}
break;
default:
break;
}
}
// Send data
@ -2381,7 +2401,13 @@ void *start_timer(void *arg) {
int srcOffset2 = npixelsx;
// loop packet
for (int i = 0; i != numPacketsPerFrame; ++i) {
for (int i = 0; i != maxPacketsPerFrame; ++i) {
// calculate for partial readout
const int startval = 0;
const int endval = startval + packetsPerFrame - 1;
// set header
char packetData[packetsize];
memset(packetData, 0, packetsize);
@ -2443,13 +2469,15 @@ void *start_timer(void *arg) {
}
}
}
if (eiger_virtual_left_datastream) {
if (eiger_virtual_left_datastream && i >= startval && i <= endval) {
usleep(eiger_virtual_transmission_delay_left);
sendUDPPacket(0, packetData, packetsize);
LOG(logDEBUG1, ("Sent left packet: %d\n", i));
}
if (eiger_virtual_right_datastream) {
if (eiger_virtual_right_datastream && i >= startval && i <= endval) {
usleep(eiger_virtual_transmission_delay_right);
sendUDPPacket(1, packetData2, packetsize);
LOG(logDEBUG1, ("Sent right packet: %d\n", i));
}
}
LOG(logINFO, ("Sent frame: %d[%lld]\n", iframes,

View File

@ -120,6 +120,7 @@ enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MAX_TRIMBITS_VALUE (63)
#define MIN_ROWS_PER_READOUT (1)
#define MAX_ROWS_PER_READOUT (256)
#define MAX_PACKETS_PER_REQUEST (256)

View File

@ -167,6 +167,15 @@
#define ADC_PORT_INVERT_ADC_3_OFST (24)
#define ADC_PORT_INVERT_ADC_3_MSK (0x000000FF << ADC_PORT_INVERT_ADC_3_OFST)
/** Partial Readout Register */
#define PARTIAL_READOUT_REG (0x44 << MEM_MAP_SHIFT)
#define PARTIAL_READOUT_NUM_ROWS_OFST (0)
#define PARTIAL_READOUT_NUM_ROWS_MSK (0x0000003F << PARTIAL_READOUT_NUM_ROWS_OFST)
#define PARTIAL_READOUT_ENBL_OFST (7)
#define PARTIAL_READOUT_ENBL_MSK (0x00000001 << PARTIAL_READOUT_ENBL_OFST)
/* Configuration Register */
#define CONFIG_REG (0x4D << MEM_MAP_SHIFT)

View File

@ -480,6 +480,7 @@ void setupDetector() {
setFilterCell(DEFAULT_FILTER_CELL);
}
disableCurrentSource();
setPartialReadout(MAX_ROWS_PER_READOUT);
}
int resetToDefaultDacs(int hardReset) {
@ -1596,6 +1597,39 @@ int *getDetectorPosition() { return detPos; }
/* jungfrau specific - powerchip, autocompdisable, asictimer, clockdiv, pll,
* flashing fpga */
int setPartialReadout(int value) {
if (value < 0 || (value % PARTIAL_READOUT_MULTIPLE != 0))
return FAIL;
// regval is numpackets - 1
int regval = (value / PARTIAL_READOUT_MULTIPLE) - 1;
uint32_t addr = PARTIAL_READOUT_REG;
LOG(logINFO, ("Setting Partial Readout: %d (regval:%d)\n", value, regval));
bus_w(addr, bus_r(addr) &~PARTIAL_READOUT_NUM_ROWS_MSK);
bus_w(addr, bus_r(addr) | ((regval << PARTIAL_READOUT_NUM_ROWS_OFST) & PARTIAL_READOUT_NUM_ROWS_MSK));
if (value == MAX_ROWS_PER_READOUT) {
LOG(logINFO, ("Disabling Partial Readout\n"));
bus_w(addr, bus_r(addr) &~PARTIAL_READOUT_ENBL_MSK);
} else {
LOG(logINFO, ("Enabling Partial Readout\n"));
bus_w(addr, bus_r(addr) | PARTIAL_READOUT_ENBL_MSK);
}
return OK;
}
int getPartialReadout() {
int enable = (bus_r(PARTIAL_READOUT_REG) & PARTIAL_READOUT_ENBL_MSK);
int regval = ((bus_r(PARTIAL_READOUT_REG) & PARTIAL_READOUT_NUM_ROWS_MSK) >> PARTIAL_READOUT_NUM_ROWS_OFST);
int maxRegval = (MAX_ROWS_PER_READOUT/ PARTIAL_READOUT_MULTIPLE) - 1;
if ((regval == maxRegval && enable) || (regval != maxRegval && !enable)) {
return -1;
}
return (regval + 1) * PARTIAL_READOUT_MULTIPLE;
}
void initReadoutConfiguration() {
LOG(logINFO, ("Initializing Readout Configuration:\n"
@ -2263,25 +2297,42 @@ void *start_timer(void *arg) {
return NULL;
}
int transmissionDelayUs = getTransmissionDelayFrame() * 1000;
int numInterfaces = getNumberofUDPInterfaces();
int64_t periodNs = getPeriod();
int numFrames = (getNumFrames() * getNumTriggers() *
(getNumAdditionalStorageCells() + 1));
int64_t expUs = getExpTime() / 1000;
const int npixels = 256 * 256 * 8;
const int dataSize = 8192;
const int packetsize = dataSize + sizeof(sls_detector_header);
const int packetsPerFrame = numInterfaces == 1 ? 128 : 64;
int transmissionDelayUs = getTransmissionDelayFrame() * 1000;
const int maxPacketsPerFrame = 128;
const int maxRows = MAX_ROWS_PER_READOUT;
int partialReadout = getPartialReadout();
if (partialReadout == -1) {
LOG(logERROR,
("partial readout is -1. Assuming no partial readout.\n"));
partialReadout = MAX_ROWS_PER_READOUT;
}
const int packetsPerFrame =
((maxPacketsPerFrame / 2) * partialReadout) / (maxRows / 2);
// Generate data
char imageData[DATA_BYTES];
memset(imageData, 0, DATA_BYTES);
for (int i = 0; i < npixels; ++i) {
// avoiding gain also being divided when gappixels enabled in call
// back
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
virtual_image_test_mode ? 0x0FFE : (uint16_t)i;
{
const int npixels = (NCHAN * NCHIP);
const int pixelsPerPacket = dataSize / NUM_BYTES_PER_PIXEL;
int pixelVal = 0;
for (int i = 0; i < npixels; ++i) {
// avoiding gain also being divided when gappixels enabled in call
// back
if (i > 0 && i % pixelsPerPacket == 0) {
++pixelVal;
}
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
virtual_image_test_mode ? 0x0FFE : (uint16_t)pixelVal;
}
}
// Send data
@ -2289,7 +2340,6 @@ void *start_timer(void *arg) {
uint64_t frameNr = 0;
getNextFrameNumber(&frameNr);
for (int iframes = 0; iframes != numFrames; ++iframes) {
usleep(transmissionDelayUs);
// check if manual stop
@ -2305,47 +2355,64 @@ void *start_timer(void *arg) {
int srcOffset = 0;
int srcOffset2 = DATA_BYTES / 2;
// loop packet
for (int i = 0; i != packetsPerFrame; ++i) {
// set header
char packetData[packetsize];
memset(packetData, 0, packetsize);
sls_detector_header *header =
(sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->modId = 0;
header->row = detPos[2];
header->column = detPos[3];
// loop packet (128 packets)
for (int i = 0; i != maxPacketsPerFrame; ++i) {
// fill data
memcpy(packetData + sizeof(sls_detector_header),
imageData + srcOffset, dataSize);
srcOffset += dataSize;
const int startval =
(maxPacketsPerFrame / 2) - (packetsPerFrame / 2);
const int endval = startval + packetsPerFrame - 1;
int pnum = i;
sendUDPPacket(0, packetData, packetsize);
// second interface
char packetData2[packetsize];
memset(packetData2, 0, packetsize);
if (numInterfaces == 2) {
header = (sls_detector_header *)(packetData2);
// first interface
if (numInterfaces == 1 || i < (maxPacketsPerFrame / 2)) {
char packetData[packetsize];
memset(packetData, 0, packetsize);
sls_detector_header *header =
(sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->packetNumber = pnum;
header->modId = 0;
header->row = detPos[0];
header->column = detPos[1];
// fill data
memcpy(packetData + sizeof(sls_detector_header),
imageData + srcOffset, dataSize);
srcOffset += dataSize;
if (i >= startval && i <= endval) {
sendUDPPacket(0, packetData, packetsize);
LOG(logDEBUG1, ("Sent packet: %d [interface 0]\n", i));
}
}
// second interface
else if (numInterfaces == 2 && i >= (maxPacketsPerFrame / 2)) {
pnum = i % (maxPacketsPerFrame / 2);
char packetData2[packetsize];
memset(packetData2, 0, packetsize);
sls_detector_header *header =
(sls_detector_header *)(packetData2);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = frameNr + iframes;
header->packetNumber = pnum;
header->modId = 0;
header->row = detPos[2];
header->column = detPos[3];
// fill data
memcpy(packetData2 + sizeof(sls_detector_header),
imageData + srcOffset2, dataSize);
srcOffset2 += dataSize;
sendUDPPacket(1, packetData2, packetsize);
if (i >= startval && i <= endval) {
sendUDPPacket(1, packetData2, packetsize);
LOG(logDEBUG1, ("Sent packet: %d [interface 1]\n", pnum));
}
}
}
LOG(logINFO, ("Sent frame: %d\n", iframes));

View File

@ -114,6 +114,9 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
#define DAC_MIN_MV (0)
#define DAC_MAX_MV (2500)
#define MAX_FILTER_CELL_VAL (12)
#define MIN_ROWS_PER_READOUT (8)
#define MAX_ROWS_PER_READOUT (512)
#define PARTIAL_READOUT_MULTIPLE (8) //512 rows/128packets * 2 interfaces
/* Defines in the Firmware */
#define MAX_TIMESLOT_VAL (0x1F)

View File

@ -409,8 +409,8 @@ int setQuad(int value);
int getQuad();
int setInterruptSubframe(int value);
int getInterruptSubframe();
int setReadNLines(int value);
int getReadNLines();
int setPartialReadout(int value);
int getPartialReadout();
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD) || \
defined(MYTHEN3D)
@ -449,6 +449,8 @@ void setDigitalIODelay(uint64_t pinMask, int delay);
// jungfrau specific - powerchip, autocompdisable, clockdiv, asictimer, clock,
// pll, flashing firmware
#ifdef JUNGFRAUD
int setPartialReadout(int value);
int getPartialReadout();
void initReadoutConfiguration();
int powerChip(int on);
int isChipConfigured();

View File

@ -144,8 +144,8 @@ int set_quad(int);
int get_quad(int);
int set_interrupt_subframe(int);
int get_interrupt_subframe(int);
int set_read_n_lines(int);
int get_read_n_lines(int);
int set_partial_readout(int);
int get_partial_readout(int);
void calculate_and_set_position();
int set_detector_position(int);
int check_detector_idle();

View File

@ -273,8 +273,8 @@ void function_table() {
flist[F_GET_QUAD] = &get_quad;
flist[F_SET_INTERRUPT_SUBFRAME] = &set_interrupt_subframe;
flist[F_GET_INTERRUPT_SUBFRAME] = &get_interrupt_subframe;
flist[F_SET_READ_N_LINES] = &set_read_n_lines;
flist[F_GET_READ_N_LINES] = &get_read_n_lines;
flist[F_SET_PARTIAL_READOUT] = &set_partial_readout;
flist[F_GET_PARTIAL_READOUT] = &get_partial_readout;
flist[F_SET_POSITION] = &set_detector_position;
flist[F_SET_SOURCE_UDP_MAC] = &set_source_udp_mac;
flist[F_GET_SOURCE_UDP_MAC] = &get_source_udp_mac;
@ -1694,8 +1694,8 @@ int acquire(int blocking, int file_des) {
// chipv1.1 has to be configured before acquisition
if (getChipVersion() == 11 && !isChipConfigured()) {
ret = FAIL;
strcpy(mess,
"Could not start acquisition. Chip is not configured.\n");
strcpy(mess, "Could not start acquisition. Chip is not configured. "
"Power it on to configure it.\n");
LOG(logERROR, (mess));
} else
#endif
@ -4717,16 +4717,16 @@ int get_interrupt_subframe(int file_des) {
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_read_n_lines(int file_des) {
int set_partial_readout(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting read n lines: %u\n", arg));
LOG(logDEBUG1, ("Setting partial readout: %u\n", arg));
#ifndef EIGERD
#if !defined(EIGERD) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// only set
@ -4734,11 +4734,12 @@ int set_read_n_lines(int file_des) {
if (arg <= 0 || arg > MAX_ROWS_PER_READOUT) {
ret = FAIL;
sprintf(mess,
"Could not set number of lines readout. Must be between 1 "
"Could not set partial readout. Must be between %d "
"and %d\n",
MAX_ROWS_PER_READOUT);
MIN_ROWS_PER_READOUT, MAX_ROWS_PER_READOUT);
LOG(logERROR, (mess));
} else {
#ifdef EIGERD
int dr = setDynamicRange(GET_FLAG);
int isTenGiga = enableTenGigabitEthernet(GET_FLAG);
unsigned int maxnl = MAX_ROWS_PER_READOUT;
@ -4746,24 +4747,35 @@ int set_read_n_lines(int file_des) {
if ((arg * maxnp) % maxnl) {
ret = FAIL;
sprintf(mess,
"Could not set %d number of lines readout. For %d bit "
"Could not set %d partial readout. For %d bit "
"mode and 10 giga %s, (%d (num "
"lines) x %d (max num packets for this mode)) must be "
"rows) x %d (max num packets for this mode)) must be "
"divisible by %d\n",
arg, dr, isTenGiga ? "enabled" : "disabled", arg, maxnp,
maxnl);
LOG(logERROR, (mess));
} else {
if (setReadNLines(arg) == FAIL) {
} else
#elif JUNGFRAUD
if (arg % PARTIAL_READOUT_MULTIPLE != 0) {
ret = FAIL;
sprintf(mess,
"Could not set partial readout. %d must be a multiple "
"of %d\n",
arg, PARTIAL_READOUT_MULTIPLE);
LOG(logERROR, (mess));
} else
#endif
{
if (setPartialReadout(arg) == FAIL) {
ret = FAIL;
sprintf(mess, "Could not set read n lines to %d.\n", arg);
sprintf(mess, "Could not set partial readout to %d.\n", arg);
LOG(logERROR, (mess));
} else {
int retval = getReadNLines();
int retval = getPartialReadout();
if (arg != retval) {
ret = FAIL;
sprintf(mess,
"Could not set read n lines. Set %d, but "
"Could not set partial readout. Set %d, but "
"read %d\n",
retval, arg);
LOG(logERROR, (mess));
@ -4776,24 +4788,24 @@ int set_read_n_lines(int file_des) {
return Server_SendResult(file_des, INT32, NULL, 0);
}
int get_read_n_lines(int file_des) {
int get_partial_readout(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting read n lines\n"));
LOG(logDEBUG1, ("Getting partial readout\n"));
#ifndef EIGERD
#if !defined(EIGERD) && !defined(JUNGFRAUD)
functionNotImplemented();
#else
// get only
retval = getReadNLines();
retval = getPartialReadout();
if (retval == -1) {
ret = FAIL;
sprintf(mess, "Could not get read n lines. \n");
sprintf(mess, "Could not get partial readout. \n");
LOG(logERROR, (mess));
} else {
LOG(logDEBUG1, ("Read N Lines retval: %u\n", retval));
LOG(logDEBUG1, ("Partial readout retval: %u\n", retval));
}
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
@ -7126,9 +7138,9 @@ int get_receiver_parameters(int file_des) {
if (n < 0)
return printSocketReadError();
// readnlines
#ifdef EIGERD
i32 = getReadNLines();
// partialReadout
#if defined(EIGERD) || defined(JUNGFRAUD)
i32 = getPartialReadout();
#else
i32 = 0;
#endif

View File

@ -509,6 +509,15 @@ class Detector {
/** [CTB] Options: 0-255 \n [Gotthard2] Options: 0-7 */
void setDBITPipeline(int value, Positions pos = {});
/** [Eiger][Jungfrau] */
Result<int> getPartialReadout(Positions pos = {}) const;
/** [Eiger] Number of lines to read out per half module
* Options: 0 - 256. 256 is default. The permissible values depend on
* dynamic range and 10Gbe enabled. \n[Jungfrau] Number of rows per module starting from the centre. Options: 8 - 512, must be multiples of 8. Default is 512.
*/
void setPartialReadout(const int lines, Positions pos = {});
///@{
/** @name Acquisition */
@ -1048,15 +1057,6 @@ class Detector {
*/
void setRateCorrection(ns dead_time, Positions pos = {});
/** [Eiger] */
Result<int> getPartialReadout(Positions pos = {}) const;
/** [Eiger] Number of lines to read out per half module
* Options: 0 - 256. 256 is default. The permissible values depend on
* dynamic range and 10Gbe enabled.
*/
void setPartialReadout(const int lines, Positions pos = {});
/** [Eiger] */
Result<bool> getInterruptSubframe(Positions pos = {}) const;

View File

@ -593,6 +593,7 @@ class CmdProxy {
{"vhighvoltage", "highvoltage"},
{"digitest", "imagetest"},
{"filter", "filterresistor"},
{"readnlines", "partialread"},
/** temperature */
@ -806,6 +807,7 @@ class CmdProxy {
{"filterresistor", &CmdProxy::filterresistor},
{"currentsource", &CmdProxy::CurrentSource},
{"dbitpipeline", &CmdProxy::dbitpipeline},
{"partialread", &CmdProxy::partialread},
/** temperature */
{"templist", &CmdProxy::templist},
@ -914,7 +916,6 @@ class CmdProxy {
{"subdeadtime", &CmdProxy::subdeadtime},
{"overflow", &CmdProxy::overflow},
{"ratecorr", &CmdProxy::RateCorrection},
{"readnlines", &CmdProxy::readnlines},
{"interruptsubframe", &CmdProxy::interruptsubframe},
{"measuredperiod", &CmdProxy::measuredperiod},
{"measuredsubperiod", &CmdProxy::measuredsubperiod},
@ -1368,6 +1369,12 @@ class CmdProxy {
"clock for latching digital bits.\n\t[Gotthard2] "
"Options: 0-7\n\t[CTB] Options: 0-255");
INTEGER_COMMAND_VEC_ID(
partialread, getPartialReadout, setPartialReadout, StringTo<int>,
"[1 - 256]\n\t[Eiger] Number of rows to readout per half module "
"starting from the centre. Options: 0 - 256. 256 is default. The "
"permissible values depend on dynamic range and 10Gbe enabled.\n[8-512 (multiple of 8)]\n\t[Jungfrau] Number of rows per module starting from the centre. Options: 8 - 512, must be multiples of 8. Default is 512.");
/** temperature */
GET_COMMAND_NOID(
templist, getTemperatureList,
@ -1808,12 +1815,6 @@ class CmdProxy {
"[0, 1]\n\t[Eiger] Enable or disable show overflow flag in "
"32 bit mode. Default is disabled.");
INTEGER_COMMAND_VEC_ID(
readnlines, getPartialReadout, setPartialReadout, StringTo<int>,
"[1 - 256]\n\t[Eiger] Number of rows to readout per half module "
"starting from the centre. Options: 0 - 256. 256 is default. The "
"permissible values depend on dynamic range and 10Gbe enabled.");
INTEGER_COMMAND_VEC_ID(
interruptsubframe, getInterruptSubframe, setInterruptSubframe,
StringTo<int>,

View File

@ -732,6 +732,14 @@ void Detector::setDBITPipeline(int value, Positions pos) {
pimpl->Parallel(&Module::setDBITPipeline, pos, value);
}
Result<int> Detector::getPartialReadout(Positions pos) const {
return pimpl->Parallel(&Module::getPartialReadout, pos);
}
void Detector::setPartialReadout(const int lines, Positions pos) {
pimpl->Parallel(&Module::setPartialReadout, pos, lines);
}
// Acquisition
void Detector::acquire() { pimpl->acquire(); }
@ -839,13 +847,14 @@ void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
bool useReceiver = getUseReceiverFlag().squash(false);
bool previouslyReceiverStreaming = false;
int startingPort = 0;
if (useReceiver) {
previouslyReceiverStreaming = getRxZmqDataStream(pos).squash(true);
startingPort = getRxZmqPort({0}).squash(0);
}
pimpl->Parallel(&Module::setNumberofUDPInterfaces, pos, n);
// ensure receiver zmq socket ports are multiplied by 2 (2 interfaces)
if (getUseReceiverFlag().squash(false) && size()) {
int startingPort = getRxZmqPort({0}).squash(0);
setRxZmqPort(startingPort, -1);
}
// redo the zmq sockets if enabled
@ -1372,14 +1381,6 @@ void Detector::updateRxRateCorrections() {
}
}
Result<int> Detector::getPartialReadout(Positions pos) const {
return pimpl->Parallel(&Module::getReadNLines, pos);
}
void Detector::setPartialReadout(const int lines, Positions pos) {
pimpl->Parallel(&Module::setReadNLines, pos, lines);
}
Result<bool> Detector::getInterruptSubframe(Positions pos) const {
return pimpl->Parallel(&Module::getInterruptSubframe, pos);
}

View File

@ -734,6 +734,17 @@ void Module::setDBITPipeline(int value) {
sendToDetector(F_SET_DBIT_PIPELINE, value, nullptr);
}
int Module::getPartialReadout() const {
return sendToDetector<int>(F_GET_PARTIAL_READOUT);
}
void Module::setPartialReadout(const int value) {
sendToDetector(F_SET_PARTIAL_READOUT, value, nullptr);
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_PARTIAL_READOUT, value, nullptr);
}
}
// Acquisition
void Module::startReceiver() {
@ -1469,17 +1480,6 @@ void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
}
}
int Module::getReadNLines() const {
return sendToDetector<int>(F_GET_READ_N_LINES);
}
void Module::setReadNLines(const int value) {
sendToDetector(F_SET_READ_N_LINES, value, nullptr);
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_READ_N_LINES, value, nullptr);
}
}
bool Module::getInterruptSubframe() const {
return sendToDetector<int>(F_GET_INTERRUPT_SUBFRAME);
}

View File

@ -178,7 +178,8 @@ class Module : public virtual slsDetectorDefs {
void setCurrentSource(defs::currentSrcParameters par);
int getDBITPipeline() const;
void setDBITPipeline(int value);
int getPartialReadout() const;
void setPartialReadout(const int value);
/**************************************************
* *
* Acquisition *
@ -337,8 +338,6 @@ class Module : public virtual slsDetectorDefs {
void setDefaultRateCorrection();
void setRateCorrection(int64_t t = 0);
void sendReceiverRateCorrections(const std::vector<int64_t> &t);
int getReadNLines() const;
void setReadNLines(const int value);
bool getInterruptSubframe() const;
void setInterruptSubframe(const bool enable);
int64_t getMeasuredPeriod() const;

View File

@ -374,36 +374,6 @@ TEST_CASE("ratecorr", "[.cmd]") {
}
}
TEST_CASE("readnlines", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto prev_val = det.getPartialReadout();
{
std::ostringstream oss;
proxy.Call("readnlines", {"256"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnlines 256\n");
}
{
std::ostringstream oss;
proxy.Call("readnlines", {}, -1, GET, oss);
REQUIRE(oss.str() == "readnlines 256\n");
}
{
std::ostringstream oss;
proxy.Call("readnlines", {"16"}, -1, PUT, oss);
REQUIRE(oss.str() == "readnlines 16\n");
}
REQUIRE_THROWS(proxy.Call("readnlines", {"0"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setPartialReadout(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("readnlines", {}, -1, GET));
}
}
TEST_CASE("interruptsubframe", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -1494,6 +1494,43 @@ TEST_CASE("dbitpipeline", "[.cmd]") {
}
}
TEST_CASE("partialread", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
auto prev_val = det.getPartialReadout();
{
std::ostringstream oss;
proxy.Call("partialread", {"256"}, -1, PUT, oss);
REQUIRE(oss.str() == "partialread 256\n");
}
{
std::ostringstream oss;
proxy.Call("partialread", {}, -1, GET, oss);
REQUIRE(oss.str() == "partialread 256\n");
}
{
std::ostringstream oss;
proxy.Call("partialread", {"16"}, -1, PUT, oss);
REQUIRE(oss.str() == "partialread 16\n");
}
if (det_type == defs::JUNGFRAU) {
REQUIRE_THROWS(proxy.Call("partialread", {"7"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("partialread", {"20"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("partialread", {"44"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("partialread", {"513"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("partialread", {"1"}, -1, PUT));
}
REQUIRE_THROWS(proxy.Call("partialread", {"0"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setPartialReadout(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("partialread", {}, -1, GET));
}
}
TEST_CASE("currentsource", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -187,7 +187,7 @@ int ClientInterface::functionTable(){
flist[F_SET_RECEIVER_DBIT_OFFSET] = &ClientInterface::set_dbit_offset;
flist[F_GET_RECEIVER_DBIT_OFFSET] = &ClientInterface::get_dbit_offset;
flist[F_SET_RECEIVER_QUAD] = &ClientInterface::set_quad_type;
flist[F_SET_RECEIVER_READ_N_LINES] = &ClientInterface::set_read_n_lines;
flist[F_SET_RECEIVER_PARTIAL_READOUT] = &ClientInterface::set_partial_readout;
flist[F_SET_RECEIVER_UDP_IP] = &ClientInterface::set_udp_ip;
flist[F_SET_RECEIVER_UDP_IP2] = &ClientInterface::set_udp_ip2;
flist[F_SET_RECEIVER_UDP_PORT] = &ClientInterface::set_udp_port;
@ -224,6 +224,7 @@ int ClientInterface::functionTable(){
int ClientInterface::decodeFunction(Interface &socket) {
ret = FAIL;
socket.Receive(fnum);
socket.setFnum(fnum);
if (fnum <= NUM_DET_FUNCTIONS || fnum >= NUM_REC_FUNCTIONS) {
throw RuntimeError("Unrecognized Function enum " +
std::to_string(fnum) + "\n");
@ -413,9 +414,11 @@ int ClientInterface::setup_receiver(Interface &socket) {
std::to_string(arg.quad) +
" due to fifo strucutre memory allocation");
}
impl()->setReadNLines(arg.numLinesReadout);
impl()->setThresholdEnergy(arg.thresholdEnergyeV[0]);
}
if (myDetectorType == EIGER || myDetectorType == JUNGFRAU) {
impl()->setPartialReadout(arg.partialReadout);
}
if (myDetectorType == MYTHEN3) {
std::array<int, 3> val;
for (int i = 0; i < 3; ++i) {
@ -1403,16 +1406,19 @@ int ClientInterface::set_quad_type(Interface &socket) {
return socket.Send(OK);
}
int ClientInterface::set_read_n_lines(Interface &socket) {
int ClientInterface::set_partial_readout(Interface &socket) {
auto arg = socket.Receive<int>();
if (arg >= 0) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting Read N Lines:" << arg;
impl()->setReadNLines(arg);
if (myDetectorType != EIGER && myDetectorType != JUNGFRAU) {
throw RuntimeError("Could not set partial readout. Not implemented for this detector");
}
LOG(logDEBUG1) << "Setting Partial Readout:" << arg;
impl()->setPartialReadout(arg);
}
int retval = impl()->getReadNLines();
validate(arg, retval, "set read n lines", DEC);
LOG(logDEBUG1) << "read n lines retval:" << retval;
int retval = impl()->getPartialReadout();
validate(arg, retval, "set partial readout", DEC);
LOG(logDEBUG1) << "read partial readout:" << retval;
return socket.Send(OK);
}

View File

@ -138,7 +138,7 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_dbit_offset(sls::ServerInterface &socket);
int get_dbit_offset(sls::ServerInterface &socket);
int set_quad_type(sls::ServerInterface &socket);
int set_read_n_lines(sls::ServerInterface &socket);
int set_partial_readout(sls::ServerInterface &socket);
sls::MacAddr setUdpIp(sls::IpAddr arg);
int set_udp_ip(sls::ServerInterface &socket);
sls::MacAddr setUdpIp2(sls::IpAddr arg);

View File

@ -51,6 +51,7 @@ class GeneralData {
uint32_t vetoPacketSize{0};
uint32_t vetoImageSize{0};
uint32_t vetoHsize{0};
uint32_t maxRowsPerReadout{0};
GeneralData(){};
virtual ~GeneralData(){};
@ -339,6 +340,7 @@ class EigerData : public GeneralData {
threadsPerReceiver = 2;
headerPacketSize = 40;
standardheader = true;
maxRowsPerReadout = 256;
};
/**
@ -384,6 +386,7 @@ class JungfrauData : public GeneralData {
defaultFifoDepth = 2500;
standardheader = true;
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
maxRowsPerReadout = 512;
};
/**

View File

@ -477,8 +477,8 @@ std::vector<uint64_t> Implementation::getNumMissingPackets() const {
int np = generalData->packetsPerFrame;
uint64_t totnp = np;
// partial readout
if (numLinesReadout != MAX_EIGER_ROWS_PER_READOUT) {
totnp = ((numLinesReadout * np) / MAX_EIGER_ROWS_PER_READOUT);
if (partialReadout != generalData->maxRowsPerReadout) {
totnp = ((partialReadout * np) / generalData->maxRowsPerReadout);
}
totnp *= numberOfTotalFrames;
mp[i] = listener[i]->GetNumMissingPacket(stoppedFlag, totnp);
@ -765,7 +765,7 @@ void Implementation::SetupWriter() {
masterAttributes->subExptime = subExpTime;
masterAttributes->subPeriod = subPeriod;
masterAttributes->quad = quadEnable;
masterAttributes->numLinesReadout = numLinesReadout;
masterAttributes->partialReadout = partialReadout;
masterAttributes->ratecorr = rateCorrections;
masterAttributes->adcmask =
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
@ -1533,11 +1533,11 @@ void Implementation::setDeactivatedPadding(bool enable) {
<< (deactivatedPaddingEnable ? "enabled" : "disabled");
}
int Implementation::getReadNLines() const { return numLinesReadout; }
int Implementation::getPartialReadout() const { return partialReadout; }
void Implementation::setReadNLines(const int value) {
numLinesReadout = value;
LOG(logINFO) << "Number of Lines to readout: " << numLinesReadout;
void Implementation::setPartialReadout(const int value) {
partialReadout = value;
LOG(logINFO) << "Partial readout (#rows): " << partialReadout;
}
void Implementation::setThresholdEnergy(const int value) {

View File

@ -218,9 +218,9 @@ class Implementation : private virtual slsDetectorDefs {
bool getDeactivatedPadding() const;
/* [Eiger] */
void setDeactivatedPadding(const bool enable);
int getReadNLines() const;
/* [Eiger] */
void setReadNLines(const int value);
int getPartialReadout() const;
/* [Eiger][Jungfrau] */
void setPartialReadout(const int value);
/** [Eiger] */
void setThresholdEnergy(const int value);
void setThresholdEnergy(const std::array<int, 3> value);
@ -352,7 +352,7 @@ class Implementation : private virtual slsDetectorDefs {
bool activated{true};
std::array<bool, 2> detectorDataStream = {{true, true}};
bool deactivatedPaddingEnable{true};
int numLinesReadout{MAX_EIGER_ROWS_PER_READOUT};
int partialReadout{0};
int thresholdEnergyeV{-1};
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
std::vector<int64_t> rateCorrections;

View File

@ -491,7 +491,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
lastCaughtFrameIndex = fnum;
LOG(logDEBUG5) << "Listening " << index
LOG(logDEBUG1) << "Listening " << index
<< ": currentfindex:" << currentFrameIndex
<< ", fnum:" << fnum << ", pnum:" << pnum
<< ", numpackets:" << numpackets;

View File

@ -37,7 +37,7 @@ struct MasterAttributes {
ns subExptime{0};
ns subPeriod{0};
uint32_t quad{0};
uint32_t numLinesReadout;
uint32_t partialReadout;
std::vector<int64_t> ratecorr;
uint32_t adcmask{0};
uint32_t analog{0};
@ -336,7 +336,8 @@ class JungfrauMasterAttributes : public MasterAttributes {
oss << MasterAttributes::GetBinaryMasterAttributes()
<< "Exptime : " << sls::ToString(exptime) << '\n'
<< "Period : " << sls::ToString(period) << '\n'
<< "Number of UDP Interfaces : " << numUDPInterfaces << '\n';
<< "Number of UDP Interfaces : " << numUDPInterfaces << '\n'
<< "Partial Readout (rows) : " << partialReadout << '\n';
std::string message = oss.str();
MasterAttributes::WriteBinaryAttributes(fd, message);
};
@ -352,6 +353,13 @@ class JungfrauMasterAttributes : public MasterAttributes {
"Number of UDP Interfaces", PredType::NATIVE_INT, dataspace);
dataset.write(&numUDPInterfaces, PredType::NATIVE_INT);
}
// partialReadout
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet(
"Partial readout (rows)", PredType::NATIVE_INT, dataspace);
dataset.write(&partialReadout, PredType::NATIVE_INT);
}
};
#endif
};
@ -373,7 +381,7 @@ class EigerMasterAttributes : public MasterAttributes {
<< "SubPeriod : " << sls::ToString(subPeriod)
<< '\n'
<< "Quad : " << quad << '\n'
<< "Number of Lines read out : " << numLinesReadout << '\n'
<< "Partial Readout (rows) : " << partialReadout << '\n'
<< "Rate Corrections : " << sls::ToString(ratecorr)
<< '\n';
std::string message = oss.str();
@ -427,12 +435,12 @@ class EigerMasterAttributes : public MasterAttributes {
group->createDataSet("Quad", PredType::NATIVE_INT, dataspace);
dataset.write(&quad, PredType::NATIVE_INT);
}
// numLinesReadout
// partialReadout
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet(
"Number of Lines read out", PredType::NATIVE_INT, dataspace);
dataset.write(&numLinesReadout, PredType::NATIVE_INT);
"Partial readout (rows)", PredType::NATIVE_INT, dataspace);
dataset.write(&partialReadout, PredType::NATIVE_INT);
}
// Rate corrections
{

View File

@ -43,7 +43,6 @@
// parameters to calculate fifo depth
#define SAMPLE_TIME_IN_NS (100000000) // 100ms
#define MAX_EIGER_ROWS_PER_READOUT (256)
// to differentiate between gotthard and short gotthard
#define GOTTHARD_PACKET_SIZE (1286)

View File

@ -25,6 +25,8 @@ class DataSocket {
DataSocket(const DataSocket &) = delete;
DataSocket &operator=(DataSocket const &) = delete;
int getSocketId() const { return sockfd_; }
int getFnum() const { return fnum_; }
void setFnum(const int fnum);
int Send(const void *buffer, size_t size);
@ -82,6 +84,7 @@ class DataSocket {
private:
int sockfd_ = -1;
int fnum_ {0};
};
}; // namespace sls

View File

@ -518,7 +518,7 @@ typedef struct {
int dataStreamLeft{0};
int dataStreamRight{0};
int quad{0};
int numLinesReadout{0};
int partialReadout{0};
int thresholdEnergyeV[3]{0, 0, 0};
int dynamicRange{16};
timingMode timMode{AUTO_TIMING};

View File

@ -124,8 +124,8 @@ enum detFuncs {
F_GET_QUAD,
F_SET_INTERRUPT_SUBFRAME,
F_GET_INTERRUPT_SUBFRAME,
F_SET_READ_N_LINES,
F_GET_READ_N_LINES,
F_SET_PARTIAL_READOUT,
F_GET_PARTIAL_READOUT,
F_SET_POSITION,
F_SET_SOURCE_UDP_MAC,
F_GET_SOURCE_UDP_MAC,
@ -326,7 +326,7 @@ enum detFuncs {
F_SET_RECEIVER_DBIT_OFFSET,
F_GET_RECEIVER_DBIT_OFFSET,
F_SET_RECEIVER_QUAD,
F_SET_RECEIVER_READ_N_LINES,
F_SET_RECEIVER_PARTIAL_READOUT,
F_SET_RECEIVER_UDP_IP,
F_SET_RECEIVER_UDP_IP2,
F_SET_RECEIVER_UDP_PORT,
@ -477,8 +477,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_GET_QUAD: return "F_GET_QUAD";
case F_SET_INTERRUPT_SUBFRAME: return "F_SET_INTERRUPT_SUBFRAME";
case F_GET_INTERRUPT_SUBFRAME: return "F_GET_INTERRUPT_SUBFRAME";
case F_SET_READ_N_LINES: return "F_SET_READ_N_LINES";
case F_GET_READ_N_LINES: return "F_GET_READ_N_LINES";
case F_SET_PARTIAL_READOUT: return "F_SET_PARTIAL_READOUT";
case F_GET_PARTIAL_READOUT: return "F_GET_PARTIAL_READOUT";
case F_SET_POSITION: return "F_SET_POSITION";
case F_SET_SOURCE_UDP_MAC: return "F_SET_SOURCE_UDP_MAC";
case F_GET_SOURCE_UDP_MAC: return "F_GET_SOURCE_UDP_MAC";
@ -677,7 +677,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_RECEIVER_DBIT_OFFSET: return "F_SET_RECEIVER_DBIT_OFFSET";
case F_GET_RECEIVER_DBIT_OFFSET: return "F_GET_RECEIVER_DBIT_OFFSET";
case F_SET_RECEIVER_QUAD: return "F_SET_RECEIVER_QUAD";
case F_SET_RECEIVER_READ_N_LINES: return "F_SET_RECEIVER_READ_N_LINES";
case F_SET_RECEIVER_PARTIAL_READOUT: return "F_SET_RECEIVER_PARTIAL_READOUT";
case F_SET_RECEIVER_UDP_IP: return "F_SET_RECEIVER_UDP_IP";
case F_SET_RECEIVER_UDP_IP2: return "F_SET_RECEIVER_UDP_IP2";
case F_SET_RECEIVER_UDP_PORT: return "F_SET_RECEIVER_UDP_PORT";

View File

@ -1,13 +1,13 @@
/** API versions */
#define GITBRANCH "developer"
#define APILIB 0x210225
#define APIRECEIVER 0x210225
#define APIGUI 0x210225
#define GITBRANCH "j10partial"
#define APICTB 0x210812
#define APIGOTTHARD 0x210812
#define APIJUNGFRAU 0x210812
#define APIMYTHEN3 0x210812
#define APIMOENCH 0x210812
#define APIEIGER 0x210812
#define APILIB 0x210816
#define APIRECEIVER 0x210816
#define APIGUI 0x210816
#define APICTB 0x210816
#define APIGOTTHARD 0x210816
#define APIGOTTHARD2 0x210816
#define APIJUNGFRAU 0x210816
#define APIMYTHEN3 0x210816
#define APIMOENCH 0x210816
#define APIEIGER 0x210816

View File

@ -63,6 +63,7 @@ int ClientSocket::sendCommandThenRead(int fnum, const void *args,
size_t retval_size) {
int ret = slsDetectorDefs::FAIL;
Send(&fnum, sizeof(fnum));
setFnum(fnum);
Send(args, args_size);
readReply(ret, retval, retval_size);
return ret;

View File

@ -1,5 +1,6 @@
#include "sls/DataSocket.h"
#include "sls/logger.h"
#include "sls/sls_detector_funcs.h"
#include "sls/sls_detector_exceptions.h"
#include <algorithm>
#include <arpa/inet.h>
@ -41,6 +42,10 @@ DataSocket &DataSocket::operator=(DataSocket &&move) noexcept {
return *this;
}
void DataSocket::setFnum(const int fnum) {
fnum_ = fnum;
}
int DataSocket::Receive(void *buffer, size_t size) {
// TODO!(Erik) Add sleep? how many reties?
int bytes_expected = static_cast<int>(size); // signed size
@ -58,7 +63,7 @@ int DataSocket::Receive(void *buffer, size_t size) {
} else {
std::ostringstream ss;
ss << "TCP socket read " << bytes_read << " bytes instead of "
<< bytes_expected << " bytes";
<< bytes_expected << " bytes (" << getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
throw sls::SocketError(ss.str());
}
}
@ -83,7 +88,7 @@ int DataSocket::Send(const void *buffer, size_t size) {
if (bytes_sent != data_size) {
std::ostringstream ss;
ss << "TCP socket sent " << bytes_sent << " bytes instead of "
<< data_size << " bytes";
<< data_size << " bytes (" << getFunctionNameFromEnum(static_cast<detFuncs>(fnum_)) << ')';
throw sls::SocketError(ss.str());
}
return bytes_sent;

View File

@ -55,7 +55,7 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
<< "leftDataStream:" << r.dataStreamLeft << std::endl
<< "rightDataStream:" << r.dataStreamRight << std::endl
<< "quad:" << r.quad << std::endl
<< "numLinesReadout:" << r.numLinesReadout << std::endl
<< "partialReadout:" << r.partialReadout << std::endl
<< "thresholdEnergyeV:" << ToString(r.thresholdEnergyeV) << std::endl
<< "dynamicRange:" << r.dynamicRange << std::endl
<< "timMode:" << r.timMode << std::endl

View File

@ -26,7 +26,7 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
if (sockfd.contextDescriptor == nullptr)
throw sls::ZmqSocketError("Could not create contextDescriptor");
// create publisher
// create subscriber
sockfd.socketDescriptor = zmq_socket(sockfd.contextDescriptor, ZMQ_SUB);
if (sockfd.socketDescriptor == nullptr) {
PrintError();