mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
eiger round robin
This commit is contained in:
@ -45,6 +45,7 @@ int Beb_deactivated_transmission_delay_left = 0;
|
||||
int Beb_deactivated_transmission_delay_right = 0;
|
||||
int Beb_deactivated_left_datastream = 1;
|
||||
int Beb_deactivated_right_datastream = 1;
|
||||
int Beb_deactivated_num_destinations = 1;
|
||||
|
||||
void BebInfo_BebInfo(struct BebInfo *bebInfo, unsigned int beb_num) {
|
||||
bebInfo->beb_number = beb_num;
|
||||
@ -1199,9 +1200,7 @@ int Beb_StopAcquisition() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
|
||||
unsigned int dst_number, unsigned int nimages,
|
||||
int test_just_send_out_packets_no_wait) {
|
||||
int Beb_RequestNImages(int ten_gig, unsigned int nimages, int test_just_send_out_packets_no_wait) {
|
||||
if (!Beb_activated)
|
||||
return 1;
|
||||
|
||||
@ -1225,10 +1224,10 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
|
||||
unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets
|
||||
|
||||
LOG(logDEBUG1, ("----Beb_RequestNImages Start----\n"));
|
||||
LOG(logINFO, ("beb_number:%d, ten_gig:%d,dst_number:%d, npackets:%d, "
|
||||
LOG(logINFO, ("ten_gig:%d, npackets:%d, "
|
||||
"Beb_bit_mode:%d, header_size:%d, nimages:%d, "
|
||||
"test_just_send_out_packets_no_wait:%d\n",
|
||||
beb_number, ten_gig, dst_number, npackets, Beb_bit_mode,
|
||||
ten_gig, npackets, Beb_bit_mode,
|
||||
header_size, nimages, test_just_send_out_packets_no_wait));
|
||||
|
||||
u_int32_t right_port_value = 0x2000;
|
||||
@ -1610,6 +1609,62 @@ int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable) {
|
||||
|
||||
void Beb_SetPartialReadout(int value) { Beb_partialReadout = value; }
|
||||
|
||||
int Beb_GetNumberofDestinations(int *retval) {
|
||||
if (!Beb_activated) {
|
||||
*retval = Beb_deactivated_num_destinations;
|
||||
return OK;
|
||||
}
|
||||
u_int32_t offset[2] = {LEFT_OFFSET + NUM_UDP_DEST_OFFSET,
|
||||
RIGHT_OFFSET + NUM_UDP_DEST_OFFSET};
|
||||
u_int32_t *csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_CMD_GENERATOR);
|
||||
if (fd <= 0) {
|
||||
LOG(logERROR, ("Could not read register to get number of udp "
|
||||
"destinations. FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
int retval1[2] = {0, 0};
|
||||
retval1[0] = Beb_Read32(csp0base, offset[0]);
|
||||
retval1[1] = Beb_Read32(csp0base, offset[1]);
|
||||
Beb_close(fd, csp0base);
|
||||
if (retval1[0] != retval1[1]) {
|
||||
LOG(logERROR, ("Inconsistent values on left (%d) and right (%d) "
|
||||
"fpga for number of destinations. FAIL\n",
|
||||
retval1[0], retval1[1]));
|
||||
return FAIL;
|
||||
}
|
||||
*retval = retval1[0];
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
int Beb_SetNumberofDestinations(int value) {
|
||||
LOG(logINFO, ("Setting number of destinations to %d\n", value));
|
||||
if (value < 0 || value >= MAX_UDP_DESTINATION) {
|
||||
LOG(logERROR, ("Invalid number of destinations %d\n", value));
|
||||
return FAIL;
|
||||
}
|
||||
if (!Beb_activated) {
|
||||
Beb_deactivated_num_destinations = value;
|
||||
return FAIL;
|
||||
}
|
||||
u_int32_t offset[2] = {LEFT_OFFSET + NUM_UDP_DEST_OFFSET,
|
||||
RIGHT_OFFSET + NUM_UDP_DEST_OFFSET};
|
||||
u_int32_t *csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_CMD_GENERATOR);
|
||||
if (fd <= 0) {
|
||||
LOG(logERROR, ("Could not read register to set number of udp "
|
||||
"destinations. FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset[0], value);
|
||||
Beb_Write32(csp0base, offset[1], value);
|
||||
Beb_deactivated_num_destinations = value;
|
||||
Beb_close(fd, csp0base);
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t Beb_swap_uint16(uint16_t val) { return (val << 8) | (val >> 8); }
|
||||
|
||||
int Beb_open(u_int32_t **csp0base, u_int32_t offset) {
|
||||
|
@ -92,8 +92,7 @@ int Beb_SetUpTransferParameters(short the_bit_mode);
|
||||
* ten_gig, unsigned int dst_number, unsigned int nimages, int
|
||||
* test_just_send_out_packets_no_wait=0); //all images go to the same
|
||||
* destination!*/
|
||||
int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
|
||||
unsigned int dst_number, unsigned int nimages,
|
||||
int Beb_RequestNImages(int ten_gig, unsigned int nimages,
|
||||
int test_just_send_out_packets_no_wait);
|
||||
|
||||
int Beb_Test(unsigned int beb_number);
|
||||
@ -110,6 +109,9 @@ int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable);
|
||||
|
||||
void Beb_SetPartialReadout(int value);
|
||||
|
||||
int Beb_GetNumberofDestinations(int *retval);
|
||||
int Beb_SetNumberofDestinations(int value);
|
||||
|
||||
uint16_t Beb_swap_uint16(uint16_t val);
|
||||
int Beb_open(u_int32_t **csp0base, u_int32_t offset);
|
||||
u_int32_t Beb_Read32(u_int32_t *baseaddr, u_int32_t offset);
|
||||
|
@ -208,6 +208,7 @@
|
||||
#define STOP_ACQ_BIT 0x40000000
|
||||
#define TWO_REQUESTS_OFFSET 0x1c
|
||||
#define TWO_REQUESTS_BIT 0x80000000
|
||||
#define NUM_UDP_DEST_OFFSET 0x20
|
||||
|
||||
// version
|
||||
#define FIRMWARE_VERSION_OFFSET 0x4
|
||||
|
@ -41,11 +41,7 @@ int *detectorChans = NULL;
|
||||
int *detectorDacs = NULL;
|
||||
|
||||
int send_to_ten_gig = 0;
|
||||
int ndsts_in_use = 32;
|
||||
unsigned int nimages_per_request = 1;
|
||||
int on_dst = 0;
|
||||
int dst_requested[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
int top = 0;
|
||||
int master = 0;
|
||||
@ -837,9 +833,6 @@ int setDynamicRange(int dr) {
|
||||
#ifndef VIRTUAL
|
||||
sharedMemory_lockLocalLink();
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
on_dst = 0;
|
||||
for (int i = 0; i < 32; ++i)
|
||||
dst_requested[i] = 0; // clear dst requested
|
||||
if (!Beb_SetUpTransferParameters(dr)) {
|
||||
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
sharedMemory_unlockLocalLink();
|
||||
@ -917,10 +910,6 @@ void setNumFrames(int64_t val) {
|
||||
sharedMemory_lockLocalLink();
|
||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) {
|
||||
eiger_nexposures = val;
|
||||
on_dst = 0;
|
||||
for (int i = 0; i < 32; ++i)
|
||||
dst_requested[i] = 0; // clear dst requested
|
||||
ndsts_in_use = 1;
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
@ -940,9 +929,6 @@ void setNumTriggers(int64_t val) {
|
||||
sharedMemory_lockLocalLink();
|
||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) {
|
||||
eiger_ntriggers = val;
|
||||
on_dst = 0;
|
||||
for (int i = 0; i < 32; ++i)
|
||||
dst_requested[i] = 0; // clear dst requested
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
@ -1521,6 +1507,24 @@ enum timingMode getTiming() {
|
||||
|
||||
/* configure mac */
|
||||
|
||||
int getNumberofDestinations(int *retval) {
|
||||
#ifdef VIRTUAL
|
||||
*retval = numUdpDestinations;
|
||||
return OK;
|
||||
#else
|
||||
return Beb_GetNumberofDestinations(retval);
|
||||
#endif
|
||||
}
|
||||
|
||||
int setNumberofDestinations(int value) {
|
||||
#ifdef VIRTUAL
|
||||
// already set in funcs.c
|
||||
return OK;
|
||||
#else
|
||||
return Beb_SetNumberofDestinations(value);
|
||||
#endif
|
||||
}
|
||||
|
||||
int configureMAC() {
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
@ -1595,12 +1599,6 @@ int configureMAC() {
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
on_dst = 0;
|
||||
|
||||
for (int i = 0; i < 32; ++i)
|
||||
dst_requested[i] = 0; // clear dst requested
|
||||
nimages_per_request = eiger_nexposures * eiger_ntriggers;
|
||||
#endif
|
||||
}
|
||||
return OK;
|
||||
@ -2594,30 +2592,13 @@ int softwareTrigger(int block) {
|
||||
}
|
||||
|
||||
int startReadOut() {
|
||||
|
||||
LOG(logINFO, ("Requesting images...\n"));
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#else
|
||||
// RequestImages();
|
||||
int ret_val = 0;
|
||||
dst_requested[0] = 1;
|
||||
while (dst_requested[on_dst]) {
|
||||
// waits on data
|
||||
int beb_num = detid;
|
||||
if ((ret_val = (!Beb_RequestNImages(beb_num, send_to_ten_gig, on_dst,
|
||||
nimages_per_request, 0))))
|
||||
break;
|
||||
|
||||
dst_requested[on_dst++] = 0;
|
||||
on_dst %= ndsts_in_use;
|
||||
}
|
||||
|
||||
if (ret_val)
|
||||
#ifndef VIRTUAL
|
||||
if (!Beb_RequestNImages(send_to_ten_gig, nimages_per_request, 0)) {
|
||||
return FAIL;
|
||||
else
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
|
Reference in New Issue
Block a user