jungfrau: switching between 2 and 1 interface, implementation for server required when firmware done

This commit is contained in:
maliakal_d 2019-03-26 15:00:19 +01:00
parent cd5aea895b
commit 7cd5bc8b2d
26 changed files with 1316 additions and 301 deletions

View File

@ -1523,7 +1523,7 @@ long int calcChecksum(int sourceip, int destip) {
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2){
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport){
#ifdef VIRTUAL
return OK;
#endif
@ -2152,6 +2152,7 @@ int stopStateMachine(){
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STP_ACQSTN_MSK);
FILE_LOG(logINFO, ("Status Register: %08x\n",bus_r(STATUS_REG)));
return OK;
}

View File

@ -1188,11 +1188,10 @@ void Beb_SetDetectorNumber(uint32_t detid) {
int Beb_SetDetectorPosition(int pos[]) {
if (!Beb_activated)
return OK;
FILE_LOG(logINFO, ("Got Position values %d %d %d...\n", pos[0],pos[1], pos[2]));
FILE_LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
pos[0] = Beb_swap_uint16(pos[0]);
//pos[1] = Beb_swap_uint16(pos[1]);
pos[2] = Beb_swap_uint16(pos[2]);
int ret = FAIL;
//mapping new memory to read master top module configuration
@ -1224,37 +1223,21 @@ int Beb_SetDetectorPosition(int pos[]) {
// y left (column)
// overwriting z anyway, so no need to look at previous z value
int posval = Beb_swap_uint16(Beb_top ? pos[1] : (pos[1]+1));
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
if (value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
value &= UDP_HEADER_Z_MSK; // to keep previous z value
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
if ((value & UDP_HEADER_Z_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
// y right
// overwriting z anyway, so no need to look at previous z value
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
value &= UDP_HEADER_Z_MSK; // to keep previous z value
posval = Beb_swap_uint16(Beb_top ? (pos[1]+1) : pos[1]);
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
if (value != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
// z left
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
value &= UDP_HEADER_Y_MSK; // to keep previous y value
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
if ((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK))
ret = FAIL;
// z right
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
value &= UDP_HEADER_Y_MSK; // to keep previous y value
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
if ((value & UDP_HEADER_Z_MSK) != ((pos[2] << UDP_HEADER_Z_OFST) & UDP_HEADER_Z_MSK))
if ((value & UDP_HEADER_Z_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK))
ret = FAIL;
@ -1263,10 +1246,10 @@ int Beb_SetDetectorPosition(int pos[]) {
}
if (ret == OK) {
FILE_LOG(logINFO, ("Position set to...\n"
"\tLeft: [%d, %d, %d]\n"
"\tRight:[%d, %d, %d]\n",
Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1), Beb_swap_uint16(pos[2]),
Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1], Beb_swap_uint16(pos[2])));
"\tLeft: [%d, %d]\n"
"\tRight:[%d, %d]\n",
Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1)),
Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1]);
}
return ret;

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/eigerDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: d9503bebf9aed76490b8166ef233e5ceeff97547
Revision: 29
Branch: refactor
Repsitory UUID: cd5aea895b07b7af25e3fb74a341a861f9aa291c
Revision: 30
Branch: jungfrau
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4465
Last Changed Date: 2019-03-21 14:03:50.000000002 +0100 ../slsDetectorServer/ALTERA_PLL.h
Last Changed Rev: 4473
Last Changed Date: 2019-03-22 17:13:44.000000002 +0100 ../slsDetectorServer/slsDetectorServer_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "d9503bebf9aed76490b8166ef233e5ceeff97547"
#define GITREPUUID "cd5aea895b07b7af25e3fb74a341a861f9aa291c"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4465
#define GITDATE 0x20190321
#define GITBRANCH "refactor"
#define GITREV 0x4473
#define GITDATE 0x20190322
#define GITBRANCH "jungfrau"

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 0765b330f116fd47b84c065d89789f4996573f23
Revision: 24
Branch: refactor
Repsitory UUID: cd5aea895b07b7af25e3fb74a341a861f9aa291c
Revision: 26
Branch: jungfrau
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4381
Last Changed Date: 2019-03-06 13:42:29.000000002 +0100 ./.target-makefrag
Last Changed Rev: 4473
Last Changed Date: 2019-03-22 17:13:44.000000002 +0100 ../slsDetectorServer/slsDetectorServer_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "0765b330f116fd47b84c065d89789f4996573f23"
#define GITREPUUID "cd5aea895b07b7af25e3fb74a341a861f9aa291c"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4381
#define GITDATE 0x20190306
#define GITBRANCH "refactor"
#define GITREV 0x4473
#define GITDATE 0x20190322
#define GITBRANCH "jungfrau"

View File

@ -1350,7 +1350,7 @@ void calcChecksum(mac_conf* mac, int sourceip, int destip) {
mac->ip.ip_chksum = checksum;
}
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2) {
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport) {
#ifdef VIRTUAL
return OK;
#endif

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/jungfrauDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 6cb043b2d999f9a15edb3a554ad91fbcded10f72
Revision: 28
Repsitory UUID: cd5aea895b07b7af25e3fb74a341a861f9aa291c
Revision: 30
Branch: jungfrau
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4471
Last Changed Date: 2019-03-22 11:20:39.000000002 +0100 ./slsDetectorFunctionList.c
Last Changed Rev: 4473
Last Changed Date: 2019-03-26 14:19:40.000000002 +0100 ./slsDetectorFunctionList.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "6cb043b2d999f9a15edb3a554ad91fbcded10f72"
#define GITREPUUID "cd5aea895b07b7af25e3fb74a341a861f9aa291c"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4471
#define GITDATE 0x20190322
#define GITREV 0x4473
#define GITDATE 0x20190326
#define GITBRANCH "jungfrau"

View File

@ -1021,13 +1021,19 @@ long int calcChecksum(int sourceip, int destip) {
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2){
int configureMAC(int numInterfaces, int selInterface,
uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport,
uint32_t destip2, uint64_t destmac2, uint64_t sourcemac2, uint32_t sourceip2, uint32_t udpport2) {
#ifdef VIRTUAL
return OK;
#endif
FILE_LOG(logINFOBLUE, ("Configuring MAC\n"));
uint32_t sourceport = DEFAULT_TX_UDP_PORT;
FILE_LOG(logINFO, ("\t#Interfaces : %d\n", numInterfaces));
FILE_LOG(logINFO, ("\tInterface : %d\n\n", selInterface));
FILE_LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
FILE_LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
@ -1040,7 +1046,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
(long long unsigned int)sourcemac));
FILE_LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t\t(0x%08x)\n",
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
FILE_LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
(unsigned int)((destmac>>40)&0xFF),
@ -1050,7 +1056,32 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
(unsigned int)((destmac>>8)&0xFF),
(unsigned int)((destmac>>0)&0xFF),
(long long unsigned int)destmac));
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",udpport, udpport));
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",udpport, udpport));
uint32_t sourceport2 = DEFAULT_TX_UDP_PORT + 1;
FILE_LOG(logINFO, ("\tSource IP2 : %d.%d.%d.%d \t\t(0x%08x)\n",
(sourceip2>>24)&0xff,(sourceip2>>16)&0xff,(sourceip2>>8)&0xff,(sourceip2)&0xff, sourceip2));
FILE_LOG(logINFO, ("\tSource MAC2 : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
(unsigned int)((sourcemac2>>40)&0xFF),
(unsigned int)((sourcemac2>>32)&0xFF),
(unsigned int)((sourcemac2>>24)&0xFF),
(unsigned int)((sourcemac2>>16)&0xFF),
(unsigned int)((sourcemac2>>8)&0xFF),
(unsigned int)((sourcemac2>>0)&0xFF),
(long long unsigned int)sourcemac2));
FILE_LOG(logINFO, ("\tSource Port2: %d \t\t\t(0x%08x)\n",sourceport2, sourceport2));
FILE_LOG(logINFO, ("\tDest. IP2 : %d.%d.%d.%d \t\t\t(0x%08x)\n",
(destip2>>24)&0xff,(destip2>>16)&0xff,(destip2>>8)&0xff,(destip2)&0xff, destip2));
FILE_LOG(logINFO, ("\tDest. MAC2 : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
(unsigned int)((destmac2>>40)&0xFF),
(unsigned int)((destmac2>>32)&0xFF),
(unsigned int)((destmac2>>24)&0xFF),
(unsigned int)((destmac2>>16)&0xFF),
(unsigned int)((destmac2>>8)&0xFF),
(unsigned int)((destmac2>>0)&0xFF),
(long long unsigned int)destmac2));
FILE_LOG(logINFO, ("\tDest. Port2 : %d \t\t\t(0x%08x)\n",udpport2, udpport2));
long int checksum=calcChecksum(sourceip, destip);
bus_w(TX_IP_REG, sourceip);
@ -1090,21 +1121,20 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
int setDetectorPosition(int pos[]) {
int ret = OK;
FILE_LOG(logDEBUG1, ("Setting detector position: (%d, %d), reserved: %d\n", pos[0], pos[1], pos[2]));
FILE_LOG(logDEBUG1, ("Setting detector position: (%d, %d)\n", pos[0], pos[1]));
bus_w(COORD_0_REG, bus_r(COORD_0_REG) & (~(COORD_0_X_MSK)));
bus_w(COORD_0_REG, bus_r(COORD_0_REG) | ((pos[0] << COORD_0_X_OFST) & COORD_0_X_MSK));
if ((bus_r(COORD_0_REG) & COORD_0_X_MSK) != ((pos[0] << COORD_0_X_OFST) & COORD_0_X_MSK))
ret = FAIL;
bus_w(COORD_0_REG, bus_r(COORD_0_REG) & (~(COORD_0_Y_MSK)));
bus_w(COORD_0_REG, bus_r(COORD_0_REG) | ((pos[1] << COORD_0_Y_OFST) & COORD_0_Y_MSK));
if ((bus_r(COORD_0_REG) & COORD_0_Y_MSK) != ((pos[1] << COORD_0_Y_OFST) & COORD_0_Y_MSK))
ret = FAIL;
bus_w(COORD_1_REG, bus_r(COORD_1_REG) | ((pos[2] << COORD_0_Z_OFST) & COORD_0_Z_MSK));
if ((bus_r(COORD_1_REG) & COORD_0_Z_MSK) != ((pos[2] << COORD_0_Z_OFST) & COORD_0_Z_MSK))
ret = FAIL;
if (ret == OK) {
FILE_LOG(logINFO, ("Position set to [%d, %d, %d]\n", pos[0], pos[1], pos[2]));
FILE_LOG(logINFO, ("Position set to [%d, %d]\n", pos[0], pos[1]));
}
return ret;
}

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/moenchDetectorServer
URL: origin https://www.github.com/slsdetectorgroup/slsDetectorPackage
Repository Root: origin https://www.github.com/slsdetectorgroup/slsDetectorPackage
Repsitory UUID: 6765fd0dc89176b4eceaf5e2304ef808a316ba9b
Revision: 16
Branch: refactor
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: cd5aea895b07b7af25e3fb74a341a861f9aa291c
Revision: 21
Branch: jungfrau
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4394
Last Changed Date: 2019-03-13 08:04:56.000000002 +0100 ./RegisterDefs.h
Last Changed Rev: 4473
Last Changed Date: 2019-03-22 17:13:44.000000002 +0100 ../slsDetectorServer/slsDetectorServer_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "https://www.github.com/slsdetectorgroup/slsDetectorPackage"
#define GITREPUUID "6765fd0dc89176b4eceaf5e2304ef808a316ba9b"
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "cd5aea895b07b7af25e3fb74a341a861f9aa291c"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4394
#define GITDATE 0x20190313
#define GITBRANCH "refactor"
#define GITREV 0x4473
#define GITDATE 0x20190322
#define GITBRANCH "jungfrau"

View File

@ -1143,7 +1143,7 @@ long int calcChecksum(int sourceip, int destip) {
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2){
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport){
#ifdef VIRTUAL
return OK;
#endif
@ -1926,69 +1926,25 @@ void unsetFifoReadStrobes() {
}
void readSample(int ns) {
uint32_t addr = DUMMY_REG;
uint32_t addr = DUMMY_REG;
// read adcs
if (analogEnable) {
// read digital output
// read strobe to digital fifo
bus_w(addr, bus_r(addr) | DUMMY_DGTL_FIFO_RD_STRBE_MSK);
bus_w(addr, bus_r(addr) & (~DUMMY_DGTL_FIFO_RD_STRBE_MSK));
// wait as it is connected directly to fifo running on a different clock
if (!(ns%1000)) {
FILE_LOG(logDEBUG1, ("Reading sample ns:%d of %d DEmtpy:%d DFull:%d Status:0x%x\n",
ns, nSamples,
((bus_r(FIFO_DIN_STATUS_REG) & FIFO_DIN_STATUS_FIFO_EMPTY_MSK) >> FIFO_DIN_STATUS_FIFO_EMPTY_OFST),
((bus_r(FIFO_DIN_STATUS_REG) & FIFO_DIN_STATUS_FIFO_FULL_MSK) >> FIFO_DIN_STATUS_FIFO_FULL_OFST),
bus_r(STATUS_REG)));
}
uint32_t fifoAddr = FIFO_DATA_REG;
// read fifo and write it to current position of data pointer
*((uint64_t*)now_ptr) = get64BitReg(FIFO_DIN_LSB_REG, FIFO_DIN_MSB_REG);
now_ptr += 8;
// read strobe to all analog fifos
bus_w(addr, bus_r(addr) | DUMMY_ANLG_FIFO_RD_STRBE_MSK);
bus_w(addr, bus_r(addr) & (~DUMMY_ANLG_FIFO_RD_STRBE_MSK));
// wait as it is connected directly to fifo running on a different clock
//usleep(WAIT_TIME_FIFO_RD_STROBE);
if (!(ns%1000)) {
FILE_LOG(logDEBUG1, ("Reading sample ns:%d of %d AEmtpy:0x%x AFull:0x%x Status:0x%x\n",
ns, nSamples, bus_r(FIFO_EMPTY_REG), bus_r(FIFO_FULL_REG), bus_r(STATUS_REG)));
}
// loop through all channels
int ich = 0;
for (ich = 0; ich < NCHAN_ANALOG; ++ich) {
// if channel is in ROI
if ((1 << ich) & ~(adcDisableMask)) {
// unselect channel
bus_w(addr, bus_r(addr) & ~(DUMMY_FIFO_CHNNL_SLCT_MSK));
// select channel
bus_w(addr, bus_r(addr) | ((ich << DUMMY_FIFO_CHNNL_SLCT_OFST) & DUMMY_FIFO_CHNNL_SLCT_MSK));
// read fifo and write it to current position of data pointer
*((uint16_t*)now_ptr) = bus_r16(fifoAddr);
// keep reading till the value is the same
/* while (*((uint16_t*)now_ptr) != bus_r16(fifoAddr)) {
FILE_LOG(logDEBUG1, ("%d ", ich));
*((uint16_t*)now_ptr) = bus_r16(fifoAddr);
}*/
// increment pointer to data out destination
now_ptr += 2;
}
}
}
// read digital output
if (digitalEnable) {
// read strobe to digital fifo
bus_w(addr, bus_r(addr) | DUMMY_DGTL_FIFO_RD_STRBE_MSK);
bus_w(addr, bus_r(addr) & (~DUMMY_DGTL_FIFO_RD_STRBE_MSK));
// wait as it is connected directly to fifo running on a different clock
if (!(ns%1000)) {
FILE_LOG(logDEBUG1, ("Reading sample ns:%d of %d DEmtpy:%d DFull:%d Status:0x%x\n",
ns, nSamples,
((bus_r(FIFO_DIN_STATUS_REG) & FIFO_DIN_STATUS_FIFO_EMPTY_MSK) >> FIFO_DIN_STATUS_FIFO_EMPTY_OFST),
((bus_r(FIFO_DIN_STATUS_REG) & FIFO_DIN_STATUS_FIFO_FULL_MSK) >> FIFO_DIN_STATUS_FIFO_FULL_OFST),
bus_r(STATUS_REG)));
}
// read fifo and write it to current position of data pointer
*((uint64_t*)now_ptr) = get64BitReg(FIFO_DIN_LSB_REG, FIFO_DIN_MSB_REG);
now_ptr += 8;
}
}
uint32_t checkDataInFifo() {

View File

@ -210,7 +210,17 @@ long int calcChecksum(int sourceip, int destip);
#ifdef GOTTHARDD
int getAdcConfigured();
#endif
#ifdef EIGERD
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2);
#elif JUNGFRAUD
int configureMAC(int numInterfaces, int selInterface,
uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport,
uint32_t destip2, uint64_t destmac2, uint64_t sourcemac2, uint32_t sourceip2, uint32_t udpport2);
#else
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport);
#endif
#if defined(JUNGFRAUD) || defined(EIGERD)
int setDetectorPosition(int pos[]);
#endif

View File

@ -152,6 +152,19 @@ const char* getSpeedName(enum speedVariable ind) {
}
}
const char* getRunStateName(enum runStatus ind) {
switch (ind) {
case IDLE: return "idle";
case ERROR: return "error";
case WAITING: return "waiting";
case RUN_FINISHED: return "run_finished";
case TRANSMITTING: return "transmitting";
case RUNNING: return "running";
case STOPPED: return "stopped";
default: return "unknown";
}
}
const char* getFunctionName(enum detFuncs func) {
switch (func) {
case F_EXEC_COMMAND: return "F_EXEC_COMMAND";
@ -2239,24 +2252,35 @@ int send_update(int file_des) {
int configure_mac(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
char args[9][50];
const size_t array_size = 50;
const size_t n_args = 14;
const size_t n_retvals = 2;
char args[n_args][array_size];
char retvals[n_retvals][array_size];
memset(args, 0, sizeof(args));
char retvals[2][50];
memset(retvals, 0, sizeof(retvals));
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
return printSocketReadError();
FILE_LOG(logDEBUG1, ("\n Configuring MAC\n"));
// dest port
uint32_t dstPort = 0;
sscanf(args[0], "%x", &dstPort);
FILE_LOG(logDEBUG1, ("Dst Port: %x\n", dstPort));
// dest ip
uint32_t dstIp = 0;
sscanf(args[0], "%x", &dstIp);
sscanf(args[1], "%x", &dstIp);
FILE_LOG(logDEBUG1, ("Dst Ip Addr: %d.%d.%d.%d = 0x%x \n",
(dstIp >> 24) & 0xff, (dstIp >> 16) & 0xff, (dstIp >> 8) & 0xff, (dstIp) & 0xff,
dstIp));
// dest mac
uint64_t dstMac = 0;
#ifdef VIRTUAL
sscanf(args[1], "%lx", &dstMac);
sscanf(args[2], "%lx", &dstMac);
#else
sscanf(args[1], "%llx", &dstMac);
sscanf(args[2], "%llx", &dstMac);
#endif
FILE_LOG(logDEBUG1, ("Dst Mac Addr: (0x) "));
{
@ -2269,17 +2293,18 @@ int configure_mac(int file_des) {
}
}
FILE_LOG(logDEBUG1, (" = %llx\n", dstMac));
uint32_t dstPort = 0;
sscanf(args[2], "%x", &dstPort);
FILE_LOG(logDEBUG1, ("Dst Port: %x\n", dstPort));
uint32_t dstPort2 = 0;
sscanf(args[5], "%x", &dstPort2);
FILE_LOG(logDEBUG1, ("Dst Port2: %x\n", dstPort2));
// source ip
uint32_t srcIp = 0;
sscanf(args[3], "%x", &srcIp);
FILE_LOG(logDEBUG1, ("Src Ip Addr: %d.%d.%d.%d = 0x%x \n",
(srcIp >> 24) & 0xff, (srcIp >> 16) & 0xff, (srcIp >> 8) & 0xff, (srcIp) & 0xff,
srcIp));
// source mac
uint64_t srcMac = 0;
#ifdef VIRTUAL
sscanf(args[3], "%lx", &srcMac);
sscanf(args[4], "%lx", &srcMac);
#else
sscanf(args[3], "%llx", &srcMac);
sscanf(args[4], "%llx", &srcMac);
#endif
FILE_LOG(logDEBUG1, ("Src Mac Addr: (0x) "));
{
@ -2292,30 +2317,98 @@ int configure_mac(int file_des) {
}
}
FILE_LOG(logDEBUG1, (" = %llx\n", srcMac));
uint32_t srcIp = 0;
sscanf(args[4], "%x", &srcIp);
FILE_LOG(logDEBUG1, ("Src Ip Addr: %d.%d.%d.%d = 0x%x \n",
(srcIp >> 24) & 0xff, (srcIp >> 16) & 0xff, (srcIp >> 8) & 0xff, (srcIp) & 0xff,
srcIp));
#if defined(JUNGFRAUD) || defined(EIGERD)
int pos[3] = {0, 0, 0};
sscanf(args[6], "%x", &pos[0]);
sscanf(args[7], "%x", &pos[1]);
sscanf(args[8], "%x", &pos[2]);
FILE_LOG(logDEBUG1, ("Position: [%d, %d, %d]\n", pos[0], pos[1], pos[2]));
// source port 2
uint32_t dstPort2 = 0;
sscanf(args[5], "%x", &dstPort2);
FILE_LOG(logDEBUG1, ("Dst Port2: %x\n", dstPort2));
#endif
#ifdef JUNGFRAUD
// dest ip2
uint32_t dstIp2 = 0;
sscanf(args[6], "%x", &dstIp2);
FILE_LOG(logDEBUG1, ("Dst Ip Addr: %d.%d.%d.%d = 0x%x \n",
(dstIp2 >> 24) & 0xff, (dstIp2 >> 16) & 0xff, (dstIp2 >> 8) & 0xff, (dstIp2) & 0xff,
dstIp2));
// dest mac2
uint64_t dstMac2 = 0;
#ifdef VIRTUAL
sscanf(args[7], "%lx", &dstMac2);
#else
sscanf(args[7], "%llx", &dstMac2);
#endif
FILE_LOG(logDEBUG1, ("Dst Mac Addr: (0x) "));
{
int iloop = 5;
for (iloop = 5; iloop >= 0; --iloop) {
printf ("%x", (unsigned int)(((dstMac2 >> (8 * iloop)) & 0xFF)));
if (iloop > 0) {
printf(":");
}
}
}
FILE_LOG(logDEBUG1, (" = %llx\n", dstMac2));
// source ip2
uint32_t srcIp2 = 0;
sscanf(args[8], "%x", &srcIp2);
FILE_LOG(logDEBUG1, ("Src Ip Addr: %d.%d.%d.%d = 0x%x \n",
(srcIp2 >> 24) & 0xff, (srcIp2 >> 16) & 0xff, (srcIp2 >> 8) & 0xff, (srcIp2) & 0xff,
srcIp2));
// source mac2
uint64_t srcMac2 = 0;
#ifdef VIRTUAL
sscanf(args[9], "%lx", &srcMac2);
#else
sscanf(args[9], "%llx", &srcMac2);
#endif
FILE_LOG(logDEBUG1, ("Src Mac Addr: (0x) "));
{
int iloop = 5;
for (iloop = 5; iloop >= 0; --iloop) {
printf("%x", (unsigned int)(((srcMac2 >> (8 * iloop)) & 0xFF)));
if (iloop > 0) {
printf(":");
}
}
}
FILE_LOG(logDEBUG1, (" = %llx\n", srcMac2));
// number of interfaces
int numInterfaces = 0;
sscanf(args[10], "%d", &numInterfaces);
int selInterface = 1;
sscanf(args[11], "%d", &selInterface);
#endif
#if defined(JUNGFRAUD) || defined(EIGERD)
int pos[2] = {0, 0};
sscanf(args[12], "%x", &pos[0]);
sscanf(args[13], "%x", &pos[1]);
FILE_LOG(logDEBUG1, ("Position: [%d, %d]\n", pos[0], pos[1]));
#endif
// set only
if ((Server_VerifyLock() == OK)) {
// stop detector if it was running
if (getRunStatus() != IDLE) {
ret = FAIL;
sprintf(mess, "Cannot configure mac when detector is not idle\n");
FILE_LOG(logERROR,(mess));
enum runStatus status = getRunStatus();
if (status != IDLE && status != RUN_FINISHED && status != STOPPED) {
if (status == RUNNING)
stopStateMachine();
#ifndef EIGERD
cleanFifos();
#endif
status = getRunStatus();
if (status != IDLE && status != RUN_FINISHED && status != STOPPED) {
ret = FAIL;
sprintf(mess, "Cannot configure mac when detector is not idle. Detector at %s state\n", getRunStateName(status));
FILE_LOG(logERROR,(mess));
}
}
else {
if (ret == OK) {
#ifdef EIGERD
// change mac to hardware mac
if (srcMac != getDetectorMAC()) {
@ -2339,9 +2432,12 @@ int configure_mac(int file_des) {
// 10 gbe (use ip given from client)
else
srcIp = dhcpipad;
ret = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2);
#elif JUNGFRAUD
ret = configureMAC(numInterfaces, selInterface, dstIp, dstMac, srcMac, srcIp, dstPort, dstIp2, dstMac2, srcMac2, srcIp2, dstPort2);
#else
ret = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort);
#endif
ret = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2);
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
if (ret != OK) {
if (ret == FAIL)

View File

@ -860,6 +860,21 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
std::string getDetectorMAC(int detPos = -1);
/**
* Validates the format of the detector MAC address (bottom half) and sets it (Jungfrau only)
* @param detectorMAC detector MAC address (bottom half)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the detector MAC address (bottom half)
*/
std::string setDetectorMAC2(const std::string &detectorMAC, int detPos = -1);
/**
* Returns the detector MAC address (bottom half) Jungfrau only
* @param detPos -1 for all detectors in list or specific detector position
* @returns the detector MAC address (bottom half)
*/
std::string getDetectorMAC2(int detPos = -1);
/**
* Validates the format of the detector IP address and sets it
* @param detectorIP detector IP address
@ -875,6 +890,21 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
std::string getDetectorIP(int detPos = -1) const;
/**
* Validates the format of the detector IP address (bottom half) and sets it (Jungfrau only)
* @param detectorIP detector IP address (bottom half)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the detector IP address (bottom half)
*/
std::string setDetectorIP2(const std::string &detectorIP, int detPos = -1);
/**
* Returns the detector IP address (bottom half) Jungfrau only
* @param detPos -1 for all detectors in list or specific detector position
* @returns the detector IP address (bottom half)
*/
std::string getDetectorIP2(int detPos = -1) const;
/**
* Validates and sets the receiver.
* Also updates the receiver with all the shared memory parameters significant for the receiver
@ -907,6 +937,21 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
std::string getReceiverUDPIP(int detPos = -1) const;
/**
* Validates the format of the receiver UDP IP address (bottom half) and sets it(Jungfrau only)
* @param udpip receiver UDP IP address (bottom half)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP IP address (bottom half)
*/
std::string setReceiverUDPIP2(const std::string &udpip, int detPos = -1);
/**
* Returns the receiver UDP IP address (bottom half) Jungfrau only
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP IP address (bottom half)
*/
std::string getReceiverUDPIP2(int detPos = -1) const;
/**
* Validates the format of the receiver UDP MAC address and sets it
* @param udpmac receiver UDP MAC address
@ -922,6 +967,21 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
std::string getReceiverUDPMAC(int detPos = -1) const;
/**
* Validates the format of the receiver UDP MAC address (bottom half) and sets it (Jungfrau only)
* @param udpmac receiver UDP MAC address (bottom half)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP MAC address (bottom half)
*/
std::string setReceiverUDPMAC2(const std::string &udpmac, int detPos = -1);
/**
* Returns the receiver UDP MAC address (bottom half) Jungfrau only
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP MAC address (bottom half)
*/
std::string getReceiverUDPMAC2(int detPos = -1) const;
/**
* Sets the receiver UDP port
* @param udpport receiver UDP port
@ -938,7 +998,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int getReceiverUDPPort(int detPos = -1) const;
/**
* Sets the receiver UDP port 2
* Sets the receiver UDP port 2 (Eiger and Jungfrau only)
* @param udpport receiver UDP port 2
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP port 2
@ -946,12 +1006,42 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int setReceiverUDPPort2(int udpport, int detPos = -1);
/**
* Returns the receiver UDP port 2 of same interface
* Returns the receiver UDP port 2 of same interface (Eiger and Jungfrau only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP port 2 of same interface
*/
int getReceiverUDPPort2(int detPos = -1) const;
/**
* Sets the number of UDP interfaces to stream data from detector (Jungfrau only)
* @param n number of interfaces. Options 1 or 2.
* @param detPos -1 for all detectors in list or specific detector position
* @returns the number of interfaces
*/
int setNumberofUDPInterfaces(int n, int detPos = -1);
/**
* Returns the number of UDP interfaces to stream data from detector (Jungfrau only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the number of interfaces
*/
int getNumberofUDPInterfaces(int detPos = -1) const;
/**
* Selects the UDP interfaces to stream data from detector. Effective only when number of interfaces is 1. (Jungfrau only)
* @param n selected interface. Options 1 or 2.
* @param detPos -1 for all detectors in list or specific detector position
* @returns the interface selected
*/
int selectUDPInterface(int n, int detPos = -1);
/**
* Returns the UDP interfaces to stream data from detector. Effective only when number of interfaces is 1. (Jungfrau only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the interface selected
*/
int getSelectedUDPInterface(int detPos = -1) const;
/**
* (advanced users)
* Set/Get client streaming in ZMQ port and restarts client sockets

View File

@ -141,21 +141,39 @@ struct sharedSlsDetector {
int receiverUDPPort;
/** is the port used to communicate between second half module of
* Eiger detector and the receiver*/
* Eiger/ Jungfrau detector and the receiver*/
int receiverUDPPort2;
/** ip address of the receiver for the detector to send packets to**/
char receiverUDPIP[MAX_STR_LENGTH];
/** ip address of the receiver for the 2nd interface of the detector to send packets to**/
char receiverUDPIP2[MAX_STR_LENGTH];
/** mac address of receiver for the detector to send packets to **/
char receiverUDPMAC[MAX_STR_LENGTH];
/** mac address of receiver for the 2nd interface of the detector to send packets to **/
char receiverUDPMAC2[MAX_STR_LENGTH];
/** mac address of the detector **/
char detectorMAC[MAX_STR_LENGTH];
/** mac address of the 2nd interface of the detector **/
char detectorMAC2[MAX_STR_LENGTH];
/** ip address of the detector **/
char detectorIP[MAX_STR_LENGTH];
/** ip address of the 2nd interface of the detector **/
char detectorIP2[MAX_STR_LENGTH];
/** number of udp interface */
int numUDPInterfaces;
/** selected udp interface */
int selectedUDPInterface;
/** online flag - is set if the receiver is connected,
* unset if socket connection is not possible */
int receiverOnlineFlag;
@ -788,6 +806,19 @@ class slsDetector : public virtual slsDetectorDefs{
*/
std::string getDetectorMAC();
/**
* Validates the format of the detector MAC address (bottom half) and sets it (Jungfrau only)
* @param detectorMAC detector MAC address (bottom half)
* @returns the detector MAC address (bottom half)
*/
std::string setDetectorMAC2(const std::string &detectorMAC);
/**
* Returns the detector MAC address (bottom half) Jungfrau only
* @returns the detector MAC address (bottom half)
*/
std::string getDetectorMAC2();
/**
* Validates the format of the detector IP address and sets it \sa sharedSlsDetector
* @param detectorIP detector IP address
@ -801,6 +832,19 @@ class slsDetector : public virtual slsDetectorDefs{
*/
std::string getDetectorIP() const;
/**
* Validates the format of the detector IP address (bottom half) and sets it (Jungfrau only)
* @param detectorIP detector IP address (bottom half)
* @returns the detector IP address (bottom half)
*/
std::string setDetectorIP2(const std::string &detectorIP);
/**
* Returns the detector IP address (bottom half) Jungfrau only
* @returns the detector IP address (bottom half)
*/
std::string getDetectorIP2() const;
/**
* Validates and sets the receiver.
* Also updates the receiver with all the shared memory parameters significant for the receiver
@ -829,6 +873,19 @@ class slsDetector : public virtual slsDetectorDefs{
*/
std::string getReceiverUDPIP() const;
/**
* Validates the format of the receiver UDP IP address (bottom half) and sets it(Jungfrau only)
* @param udpip receiver UDP IP address (bottom half)
* @returns the receiver UDP IP address (bottom half)
*/
std::string setReceiverUDPIP2(const std::string &udpip);
/**
* Returns the receiver UDP IP address (bottom half) Jungfrau only
* @returns the receiver UDP IP address (bottom half)
*/
std::string getReceiverUDPIP2() const;
/**
* Validates the format of the receiver UDP MAC address and sets it \sa sharedSlsDetector
* @param udpmac receiver UDP MAC address
@ -842,6 +899,19 @@ class slsDetector : public virtual slsDetectorDefs{
*/
std::string getReceiverUDPMAC() const;
/**
* Validates the format of the receiver UDP MAC address (bottom half) and sets it (Jungfrau only)
* @param udpmac receiver UDP MAC address (bottom half)
* @returns the receiver UDP MAC address (bottom half)
*/
std::string setReceiverUDPMAC2(const std::string &udpmac);
/**
* Returns the receiver UDP MAC address (bottom half) Jungfrau only
* @returns the receiver UDP MAC address (bottom half)
*/
std::string getReceiverUDPMAC2() const;
/**
* Sets the receiver UDP port\sa sharedSlsDetector
* @param udpport receiver UDP port
@ -856,18 +926,44 @@ class slsDetector : public virtual slsDetectorDefs{
int getReceiverUDPPort() const;
/**
* Sets the receiver UDP port 2\sa sharedSlsDetector
* Sets the receiver UDP port 2\sa sharedSlsDetector (Eiger and Jungfrau only)
* @param udpport receiver UDP port 2
* @returns the receiver UDP port 2
*/
int setReceiverUDPPort2(int udpport);
/**
* Returns the receiver UDP port 2 of same interface\sa sharedSlsDetector
* Returns the receiver UDP port 2 of same interface\sa sharedSlsDetector (Eiger and Jungfrau only)
* @returns the receiver UDP port 2 of same interface
*/
int getReceiverUDPPort2() const;
/**
* Sets the number of UDP interfaces to stream data from detector (Jungfrau only)
* @param n number of interfaces. Options 1 or 2.
* @returns the number of interfaces
*/
int setNumberofUDPInterfaces(int n);
/**
* Returns the number of UDP interfaces to stream data from detector (Jungfrau only)
* @returns the number of interfaces
*/
int getNumberofUDPInterfaces() const;
/**
* Selects the UDP interfaces to stream data from detector. Effective only when number of interfaces is 1. (Jungfrau only)
* @param n selected interface. Options 1 or 2.
* @returns the interface selected
*/
int selectUDPInterface(int n);
/**
* Returns the UDP interfaces to stream data from detector. Effective only when number of interfaces is 1. (Jungfrau only)
* @returns the interface selected
*/
int getSelectedUDPInterface() const;
/**
* Sets the client zmq port\sa sharedSlsDetector
* @param port client zmq port

View File

@ -1438,6 +1438,28 @@ std::string multiSlsDetector::getDetectorMAC(int detPos) {
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::setDetectorMAC2(const std::string &detectorMAC, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setDetectorMAC2(detectorMAC);
}
// multi
auto r = parallelCall(&slsDetector::setDetectorMAC2, detectorMAC);
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::getDetectorMAC2(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getDetectorMAC2();
}
// multi
auto r = serialCall(&slsDetector::getDetectorMAC2);
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::setDetectorIP(const std::string &detectorIP, int detPos) {
// single
if (detPos >= 0) {
@ -1460,6 +1482,29 @@ std::string multiSlsDetector::getDetectorIP(int detPos) const {
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::setDetectorIP2(const std::string &detectorIP, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setDetectorIP2(detectorIP);
}
// multi
auto r = parallelCall(&slsDetector::setDetectorIP2, detectorIP);
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::getDetectorIP2(int detPos) const {
// single
if (detPos >= 0) {
return detectors[detPos]->getDetectorIP2();
}
// multi
auto r = serialCall(&slsDetector::getDetectorIP2);
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::setReceiverHostname(const std::string &receiver, int detPos) {
// single
if (detPos >= 0) {
@ -1504,6 +1549,28 @@ std::string multiSlsDetector::getReceiverUDPIP(int detPos) const {
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::setReceiverUDPIP2(const std::string &udpip, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setReceiverUDPIP2(udpip);
}
// multi
auto r = parallelCall(&slsDetector::setReceiverUDPIP2, udpip);
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::getReceiverUDPIP2(int detPos) const {
// single
if (detPos >= 0) {
return detectors[detPos]->getReceiverUDPIP2();
}
// multi
auto r = serialCall(&slsDetector::getReceiverUDPIP2);
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::setReceiverUDPMAC(const std::string &udpmac, int detPos) {
// single
if (detPos >= 0) {
@ -1526,6 +1593,28 @@ std::string multiSlsDetector::getReceiverUDPMAC(int detPos) const {
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::setReceiverUDPMAC2(const std::string &udpmac, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setReceiverUDPMAC2(udpmac);
}
// multi
auto r = parallelCall(&slsDetector::setReceiverUDPMAC2, udpmac);
return sls::concatenateIfDifferent(r);
}
std::string multiSlsDetector::getReceiverUDPMAC2(int detPos) const {
// single
if (detPos >= 0) {
return detectors[detPos]->getReceiverUDPMAC2();
}
// multi
auto r = serialCall(&slsDetector::getReceiverUDPMAC2);
return sls::concatenateIfDifferent(r);
}
int multiSlsDetector::setReceiverUDPPort(int udpport, int detPos) {
// single
if (detPos >= 0) {
@ -1570,6 +1659,71 @@ int multiSlsDetector::getReceiverUDPPort2(int detPos) const {
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::setNumberofUDPInterfaces(int n, int detPos) {
int previouslyClientStreaming = enableDataStreamingToClient();
int previouslyReceiverStreaming = enableDataStreamingFromReceiver();
// single
int ret = OK;
if (detPos >= 0) {
ret = detectors[detPos]->setNumberofUDPInterfaces(n);
}
// multi
auto r = parallelCall(&slsDetector::setNumberofUDPInterfaces,n);
// redo the zmq sockets
if (previouslyClientStreaming) {
enableDataStreamingToClient(0);
enableDataStreamingToClient(1);
}
if (previouslyReceiverStreaming) {
enableDataStreamingFromReceiver(0);
enableDataStreamingFromReceiver(1);
}
// return single
if (detPos >= 0)
return ret;
// return multi
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::getNumberofUDPInterfaces(int detPos) const {
// single
if (detPos >= 0) {
return detectors[detPos]->getNumberofUDPInterfaces();
}
// multi
auto r = serialCall(&slsDetector::getNumberofUDPInterfaces);
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::selectUDPInterface(int n, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->selectUDPInterface(n);
}
// multi
auto r = parallelCall(&slsDetector::selectUDPInterface,n);
return sls::minusOneIfDifferent(r);
}
int multiSlsDetector::getSelectedUDPInterface(int detPos) const {
// single
if (detPos >= 0) {
return detectors[detPos]->getSelectedUDPInterface();
}
// multi
auto r = serialCall(&slsDetector::getSelectedUDPInterface);
return sls::minusOneIfDifferent(r);
}
void multiSlsDetector::setClientDataStreamingInPort(int i, int detPos) {
if (i >= 0) {
int prev_streaming = enableDataStreamingToClient();
@ -1583,6 +1737,8 @@ void multiSlsDetector::setClientDataStreamingInPort(int i, int detPos) {
// calculate ports individually
int firstPort = i;
int numSockets = (getDetectorTypeAsEnum() == EIGER) ? 2 : 1;
if (getNumberofUDPInterfaces() == 2)
numSockets *= 2;
for (size_t idet = 0; idet < detectors.size(); ++idet) {
auto port = firstPort + (idet * numSockets);
@ -1621,6 +1777,8 @@ void multiSlsDetector::setReceiverDataStreamingOutPort(int i, int detPos) {
// calculate ports individually
int firstPort = i;
int numSockets = (getDetectorTypeAsEnum() == EIGER) ? 2 : 1;
if (getNumberofUDPInterfaces() == 2)
numSockets *= 2;
for (size_t idet = 0; idet < detectors.size(); ++idet) {
auto port = firstPort + (idet * numSockets);
@ -2848,6 +3006,9 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
if (getDetectorTypeAsEnum() == EIGER) {
numSocketsPerDetector = 2;
}
if (getNumberofUDPInterfaces() == 2) {
numSocketsPerDetector = 2;
}
numSockets *= numSocketsPerDetector;
for (size_t iSocket = 0; iSocket < numSockets; ++iSocket) {
@ -2882,6 +3043,9 @@ void multiSlsDetector::readFrameFromReceiver() {
nX *= 2;
gappixelsenable = detectors[0]->enableGapPixels(-1) >= 1 ? true : false;
}
if (getNumberofUDPInterfaces() == 2) {
nY *= 2;
}
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
int numRunning = 0;

View File

@ -318,9 +318,15 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
detector_shm()->receiverUDPPort = DEFAULT_UDP_PORTNO;
detector_shm()->receiverUDPPort2 = DEFAULT_UDP_PORTNO + 1;
sls::strcpy_safe(detector_shm()->receiverUDPIP, "none");
sls::strcpy_safe(detector_shm()->receiverUDPIP2, "none");
sls::strcpy_safe(detector_shm()->receiverUDPMAC, "none");
sls::strcpy_safe(detector_shm()->receiverUDPMAC2, "none");
sls::strcpy_safe(detector_shm()->detectorMAC, DEFAULT_DET_MAC);
sls::strcpy_safe(detector_shm()->detectorMAC2, DEFAULT_DET_MAC2);
sls::strcpy_safe(detector_shm()->detectorIP, DEFAULT_DET_IP);
sls::strcpy_safe(detector_shm()->detectorIP2, DEFAULT_DET_IP2);
detector_shm()->numUDPInterfaces = 1;
detector_shm()->selectedUDPInterface = 1;
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
detector_shm()->tenGigaEnable = 0;
detector_shm()->flippedData[X] = 0;
@ -1010,38 +1016,73 @@ int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector
names.emplace_back("outdir");
names.emplace_back("lock");
// receiver config
names.emplace_back("detectormac");
names.emplace_back("detectorip");
names.emplace_back("zmqport");
names.emplace_back("rx_zmqport");
names.emplace_back("zmqip");
names.emplace_back("rx_zmqip");
names.emplace_back("rx_tcpport");
names.emplace_back("rx_udpport");
names.emplace_back("rx_udpport2");
names.emplace_back("rx_udpip");
names.emplace_back("rx_hostname");
names.emplace_back("r_readfreq");
// detector specific config
switch (detector_shm()->myDetectorType) {
case GOTTHARD:
names.emplace_back("detectormac");
names.emplace_back("detectorip");
names.emplace_back("rx_udpport");
names.emplace_back("rx_udpip");
names.emplace_back("rx_udpmac");
names.emplace_back("rx_hostname");
names.emplace_back("extsig:0");
names.emplace_back("vhighvoltage");
break;
case EIGER:
names.emplace_back("detectormac");
names.emplace_back("detectorip");
names.emplace_back("rx_udpport");
names.emplace_back("rx_udpport2");
names.emplace_back("rx_udpip");
names.emplace_back("rx_udpmac");
names.emplace_back("rx_hostname");
names.emplace_back("vhighvoltage");
names.emplace_back("trimen");
names.emplace_back("iodelay");
names.emplace_back("tengiga");
break;
case JUNGFRAU:
names.emplace_back("detectormac");
names.emplace_back("detectormac2");
names.emplace_back("detectorip");
names.emplace_back("detectorip2");
names.emplace_back("rx_udpport");
names.emplace_back("rx_udpport2");
names.emplace_back("rx_udpip");
names.emplace_back("rx_udpip2");
names.emplace_back("rx_udpmac");
names.emplace_back("rx_udpmac2");
names.emplace_back("rx_hostname");
names.emplace_back("powerchip");
names.emplace_back("vhighvoltage");
break;
case CHIPTESTBOARD:
names.emplace_back("detectormac");
names.emplace_back("detectorip");
names.emplace_back("rx_udpport");
names.emplace_back("rx_udpip");
names.emplace_back("rx_udpmac");
names.emplace_back("rx_hostname");
names.emplace_back("vhighvoltage");
break;
case MOENCH:
names.emplace_back("detectormac");
names.emplace_back("detectorip");
names.emplace_back("rx_udpport");
names.emplace_back("rx_udpip");
names.emplace_back("rx_udpmac");
names.emplace_back("rx_hostname");
names.emplace_back("powerchip");
names.emplace_back("vhighvoltage");
break;
@ -1050,6 +1091,10 @@ int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector
std::to_string(detector_shm()->myDetectorType));
}
names.emplace_back("r_readfreq");
names.emplace_back("rx_udpsocksize");
names.emplace_back("rx_realudpsocksize");
auto cmd = slsDetectorCommand(m);
for (auto &name : names) {
char *args[] = {(char *)name.c_str()};
@ -1516,7 +1561,7 @@ int slsDetector::configureMAC() {
int fnum = F_CONFIGURE_MAC;
int ret = FAIL;
const size_t array_size = 50;
const size_t n_args = 9;
const size_t n_args = 14;
const size_t n_retvals = 2;
char args[n_args][array_size] = {};
char retvals[n_retvals][array_size] = {};
@ -1538,59 +1583,108 @@ int slsDetector::configureMAC() {
if (sls::ConvertInternetAddresstoIpString(result, detector_shm()->receiverUDPIP,
MAX_STR_LENGTH)) {
sls::strcpy_safe(detector_shm()->receiverUDPIP, "none");
throw RuntimeError("configureMAC: Error. Receiver UDP IP Address not set");
}
}
}
}
// rx_udpip and rx_udpmac is none
if ((!strcmp(detector_shm()->receiverUDPIP, "none")) ||
(!strcmp(detector_shm()->receiverUDPMAC, "none"))) {
throw RuntimeError("configureMAC: Error. IP/MAC Addresses not set");
// rx_udpmac is none
if (!strcmp(detector_shm()->receiverUDPMAC, "none")) {
throw RuntimeError("configureMAC: Error. Receiver UDP MAC Addresses not set");
}
FILE_LOG(logDEBUG1) << "rx_hostname and rx_udpip is valid ";
FILE_LOG(logDEBUG1) << "rx_hostname and rx_udpmac are valid ";
// jungfrau 2 interfaces
// validate for the second interface
if (detector_shm()->numUDPInterfaces == 2) {
// copy from udpip (done here as well if udpconnection avoided (no slsrxr)
if (!strcmp(detector_shm()->receiverUDPIP2, "none")) {
sls::strcpy_safe(detector_shm()->receiverUDPIP2, detector_shm()->receiverUDPIP);
}
// rx_udpmac2 (udpip2 will be copied from udpip if empty)
if (!strcmp(detector_shm()->receiverUDPMAC2, "none")) {
throw RuntimeError("configureMAC: Error. Receiver UDP MAC Addresses 2 not set");
}
FILE_LOG(logDEBUG1) << "rx_udpmac2 are valid ";
}
// copy to args
sls::strcpy_safe(args[0], detector_shm()->receiverUDPIP);
sls::strcpy_safe(args[1], detector_shm()->receiverUDPMAC);
snprintf(args[2], array_size, "%x", detector_shm()->receiverUDPPort);
sls::strcpy_safe(args[3], detector_shm()->detectorMAC);
sls::strcpy_safe(args[4], detector_shm()->detectorIP);
snprintf(args[0], array_size, "%x", detector_shm()->receiverUDPPort);
sls::strcpy_safe(args[1], detector_shm()->receiverUDPIP);
sls::strcpy_safe(args[2], detector_shm()->receiverUDPMAC);
sls::strcpy_safe(args[3], detector_shm()->detectorIP);
sls::strcpy_safe(args[4], detector_shm()->detectorMAC);
snprintf(args[5], array_size, "%x", detector_shm()->receiverUDPPort2);
sls::strcpy_safe(args[6], detector_shm()->receiverUDPIP2);
sls::strcpy_safe(args[7], detector_shm()->receiverUDPMAC2);
sls::strcpy_safe(args[8], detector_shm()->detectorIP2);
sls::strcpy_safe(args[9], detector_shm()->detectorMAC2);
// number of interfaces and which one
snprintf(args[10], array_size, "%x", detector_shm()->numUDPInterfaces);
snprintf(args[11], array_size, "%x", detector_shm()->selectedUDPInterface);
// 2d positions to detector to put into udp header
{
int pos[3] = {0, 0, 0};
int max = detector_shm()->multiSize[1];
int pos[2] = {0, 0};
int max = detector_shm()->multiSize[1] * (detector_shm()->numUDPInterfaces);
// row
pos[0] = (detId % max);
// col for horiz. udp ports
pos[1] = (detId / max) * ((detector_shm()->myDetectorType == EIGER) ? 2 : 1);
// pos[2] (z is reserved)
FILE_LOG(logDEBUG1) << "Detector [" << detId << "] - (" << pos[0] << "," << pos[1] << ")";
snprintf(args[6], array_size, "%x", pos[0]);
snprintf(args[7], array_size, "%x", pos[1]);
snprintf(args[8], array_size, "%x", pos[2]);
snprintf(args[12], array_size, "%x", pos[0]);
snprintf(args[13], array_size, "%x", pos[1]);
}
FILE_LOG(logDEBUG1) << "receiver udp port:" << std::dec << args[0] << "-";
// converting receiverUDPIP to string hex
sls::strcpy_safe(args[0], sls::stringIpToHex(args[0]).c_str());
FILE_LOG(logDEBUG1) << "receiver udp ip:" << args[0] << "-";
sls::strcpy_safe(args[1], sls::stringIpToHex(args[1]).c_str());
FILE_LOG(logDEBUG1) << "receiver udp ip:" << args[1] << "-";
// MAC already in hex removing :
sls::removeChar(args[1], ':');
FILE_LOG(logDEBUG1) << "receiver udp mac:" << args[1] << "-";
FILE_LOG(logDEBUG1) << "receiver udp port:" << args[2] << "-";
// MAC already in hex removing :
sls::removeChar(args[3], ':');
FILE_LOG(logDEBUG1) << "detector udp mac:" << args[3] << "-";
sls::removeChar(args[2], ':');
FILE_LOG(logDEBUG1) << "receiver udp mac:" << args[2] << "-";
// converting detectorIP to string hex
sls::strcpy_safe(args[4], sls::stringIpToHex(args[4]).c_str());
FILE_LOG(logDEBUG1) << "detecotor udp ip:" << args[4] << "-";
sls::strcpy_safe(args[3], sls::stringIpToHex(args[3]).c_str());
FILE_LOG(logDEBUG1) << "detecotor udp ip:" << args[3] << "-";
// MAC already in hex removing :
sls::removeChar(args[4], ':');
FILE_LOG(logDEBUG1) << "detector udp mac:" << args[4] << "-";
FILE_LOG(logDEBUG1) << "receiver udp port2:" << std::dec << args[5] << "-";
if (!strcmp(args[6], "none")) {
sprintf(args[6], "%d", 0);
} else {
sls::strcpy_safe(args[6], sls::stringIpToHex(args[6]).c_str());
}
FILE_LOG(logDEBUG1) << "receiver udp ip2:" << args[6] << "-";
// MAC already in hex removing :
sls::removeChar(args[7], ':');
FILE_LOG(logDEBUG1) << "receiver udp mac2:" << args[7] << "-";
// converting detectorIP to string hex
if (!strcmp(args[8], "none")) {
sprintf(args[8], "%d", 0);
} else {
sls::strcpy_safe(args[8], sls::stringIpToHex(args[8]).c_str());
}
FILE_LOG(logDEBUG1) << "detecotor udp ip2:" << args[8] << "-";
// MAC already in hex removing :
sls::removeChar(args[9], ':');
FILE_LOG(logDEBUG1) << "detector udp mac2:" << args[9] << "-";
FILE_LOG(logDEBUG1) << "number of udp interfaces:" << std::dec << args[10] << "-";
FILE_LOG(logDEBUG1) << "selected udp interface:" << std::dec << args[11] << "-";
FILE_LOG(logDEBUG1) << "row:" << args[12] << "-";
FILE_LOG(logDEBUG1) << "col:" << args[13] << "-";
FILE_LOG(logDEBUG1) << "receiver udp port2:" << args[5] << "-";
FILE_LOG(logDEBUG1) << "row:" << args[6] << "-";
FILE_LOG(logDEBUG1) << "col:" << args[7] << "-";
FILE_LOG(logDEBUG1) << "reserved:" << args[8] << "-";
// send to server
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
@ -2012,7 +2106,31 @@ std::string slsDetector::setDetectorMAC(const std::string &detectorMAC) {
return std::string(detector_shm()->detectorMAC);
}
std::string slsDetector::getDetectorMAC() { return std::string(detector_shm()->detectorMAC); }
std::string slsDetector::getDetectorMAC() {
return std::string(detector_shm()->detectorMAC);
}
std::string slsDetector::setDetectorMAC2(const std::string &detectorMAC) {
// invalid format
if ((detectorMAC.length() != 17) || (detectorMAC[2] != ':') || (detectorMAC[5] != ':') ||
(detectorMAC[8] != ':') || (detectorMAC[11] != ':') || (detectorMAC[14] != ':')) {
throw RuntimeError("server MAC Address 2 should be in xx:xx:xx:xx:xx:xx format");
}
// valid format
else {
sls::strcpy_safe(detector_shm()->detectorMAC2, detectorMAC.c_str());
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed";
}
}
return std::string(detector_shm()->detectorMAC2);
}
std::string slsDetector::getDetectorMAC2() {
return std::string(detector_shm()->detectorMAC2);
}
std::string slsDetector::setDetectorIP(const std::string &detectorIP) {
struct sockaddr_in sa;
@ -2033,7 +2151,32 @@ std::string slsDetector::setDetectorIP(const std::string &detectorIP) {
return std::string(detector_shm()->detectorIP);
}
std::string slsDetector::getDetectorIP() const { return std::string(detector_shm()->detectorIP); }
std::string slsDetector::getDetectorIP() const {
return std::string(detector_shm()->detectorIP);
}
std::string slsDetector::setDetectorIP2(const std::string &detectorIP) {
struct sockaddr_in sa;
if (detectorIP.length() && detectorIP.length() < 16) {
int result = inet_pton(AF_INET, detectorIP.c_str(), &(sa.sin_addr));
if (result == 0) {
throw RuntimeError(
"setDetectorIP: IP Address 2 should be VALID and in xxx.xxx.xxx.xxx format");
} else {
sls::strcpy_safe(detector_shm()->detectorIP2, detectorIP.c_str());
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed";
}
}
}
return std::string(detector_shm()->detectorIP2);
}
std::string slsDetector::getDetectorIP2() const {
return std::string(detector_shm()->detectorIP2);
}
std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
FILE_LOG(logDEBUG1) << "Setting up Receiver with " << receiverIP;
@ -2095,6 +2238,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
setDetectorId();
setDetectorHostname();
setUDPConnection();
setReceiverUDPSocketBufferSize(0);
setFilePath(detector_shm()->receiver_filePath);
setFileName(detector_shm()->receiver_fileName);
setFileIndex(detector_shm()->receiver_fileIndex);
@ -2183,6 +2327,29 @@ std::string slsDetector::getReceiverUDPIP() const {
return std::string(detector_shm()->receiverUDPIP);
}
std::string slsDetector::setReceiverUDPIP2(const std::string &udpip) {
struct sockaddr_in sa;
if (udpip.length() && udpip.length() < 16) {
int result = inet_pton(AF_INET, udpip.c_str(), &(sa.sin_addr));
if (result == 0) {
throw ReceiverError(
"setReceiverUDPIP: UDP IP Address 2 should be VALID and in xxx.xxx.xxx.xxx format");
} else {
sls::strcpy_safe(detector_shm()->receiverUDPIP2, udpip.c_str());
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed";
}
}
}
return std::string(detector_shm()->receiverUDPIP2);
}
std::string slsDetector::getReceiverUDPIP2() const {
return std::string(detector_shm()->receiverUDPIP2);
}
std::string slsDetector::setReceiverUDPMAC(const std::string &udpmac) {
// invalid format
if ((udpmac.length() != 17) || (udpmac[2] != ':') || (udpmac[5] != ':') || (udpmac[8] != ':') ||
@ -2206,6 +2373,29 @@ std::string slsDetector::getReceiverUDPMAC() const {
return std::string(detector_shm()->receiverUDPMAC);
}
std::string slsDetector::setReceiverUDPMAC2(const std::string &udpmac) {
// invalid format
if ((udpmac.length() != 17) || (udpmac[2] != ':') || (udpmac[5] != ':') || (udpmac[8] != ':') ||
(udpmac[11] != ':') || (udpmac[14] != ':')) {
throw ReceiverError(
"setReceiverUDPMAC: udp MAC Address 2 should be in xx:xx:xx:xx:xx:xx format");
}
// valid format
else {
sls::strcpy_safe(detector_shm()->receiverUDPMAC2, udpmac.c_str());
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
}
// not doing setUDPConnection as rx_udpmac will get replaced,(must use configuremac)
sls::strcpy_safe(detector_shm()->receiverUDPMAC2, udpmac.c_str());
}
return std::string(detector_shm()->receiverUDPMAC2);
}
std::string slsDetector::getReceiverUDPMAC2() const {
return std::string(detector_shm()->receiverUDPMAC2);
}
int slsDetector::setReceiverUDPPort(int udpport) {
detector_shm()->receiverUDPPort = udpport;
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
@ -2216,12 +2406,11 @@ int slsDetector::setReceiverUDPPort(int udpport) {
return detector_shm()->receiverUDPPort;
}
int slsDetector::getReceiverUDPPort() const { return detector_shm()->receiverUDPPort; }
int slsDetector::getReceiverUDPPort() const {
return detector_shm()->receiverUDPPort;
}
int slsDetector::setReceiverUDPPort2(int udpport) {
if (detector_shm()->myDetectorType != EIGER) {
return setReceiverUDPPort(udpport);
}
detector_shm()->receiverUDPPort2 = udpport;
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
@ -2231,7 +2420,43 @@ int slsDetector::setReceiverUDPPort2(int udpport) {
return detector_shm()->receiverUDPPort2;
}
int slsDetector::getReceiverUDPPort2() const { return detector_shm()->receiverUDPPort2; }
int slsDetector::getReceiverUDPPort2() const {
return detector_shm()->receiverUDPPort2;
}
int slsDetector::setNumberofUDPInterfaces(int n) {
if (detector_shm()->myDetectorType != JUNGFRAU) {
throw RuntimeError("Cannot choose number of interfaces for this detector");
}
detector_shm()->numUDPInterfaces = (n > 1 ? 2 : 1);
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed";
}
return detector_shm()->numUDPInterfaces;
}
int slsDetector::getNumberofUDPInterfaces() const {
return detector_shm()->numUDPInterfaces;
}
int slsDetector::selectUDPInterface(int n) {
if (detector_shm()->myDetectorType != JUNGFRAU) {
throw RuntimeError("Cannot select an interface for this detector");
}
detector_shm()->selectedUDPInterface = (n > 1 ? 2 : 1);
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed";
}
return detector_shm()->selectedUDPInterface;
}
int slsDetector::getSelectedUDPInterface() const {
return detector_shm()->selectedUDPInterface;
}
void slsDetector::setClientStreamingPort(int port) { detector_shm()->zmqport = port; }
@ -2511,8 +2736,8 @@ int64_t slsDetector::getReceiverRealUDPSocketBufferSize() {
int slsDetector::setUDPConnection() {
int fnum = F_SETUP_RECEIVER_UDP;
int ret = FAIL;
char args[3][MAX_STR_LENGTH] = {{}, {}, {}};
char retvals[MAX_STR_LENGTH] = {};
char args[6][MAX_STR_LENGTH] = {{}, {}, {}, {}, {}, {}};
char retvals[2][MAX_STR_LENGTH] = {{}, {}};
FILE_LOG(logDEBUG1) << "Setting UDP Connection";
// called before set up
@ -2536,15 +2761,32 @@ int slsDetector::setUDPConnection() {
if (sls::ConvertInternetAddresstoIpString(result, detector_shm()->receiverUDPIP,
MAX_STR_LENGTH)) {
sls::strcpy_safe(detector_shm()->receiverUDPIP, "none");
throw RuntimeError("setUDPConnection: Error. Receiver UDP IP Address not set");
}
}
}
}
// jungfrau 2 interfaces or (1 interface and 2nd interface), copy udpip if udpip2 empty
if (detector_shm()->numUDPInterfaces == 2 || detector_shm()->selectedUDPInterface == 2) {
// copy from udpip
if (!strcmp(detector_shm()->receiverUDPIP2, "none")) {
sls::strcpy_safe(detector_shm()->receiverUDPIP2, detector_shm()->receiverUDPIP);
}
}
// copy arguments to args[][]
sls::strcpy_safe(args[0], detector_shm()->receiverUDPIP);
snprintf(args[1], sizeof(args[2]), "%d", detector_shm()->receiverUDPPort);
snprintf(args[2], sizeof(args[2]), "%d", detector_shm()->receiverUDPPort2);
snprintf(args[0], sizeof(args[0]), "%d", detector_shm()->numUDPInterfaces);
snprintf(args[1], sizeof(args[1]), "%d", detector_shm()->selectedUDPInterface);
sls::strcpy_safe(args[2], detector_shm()->receiverUDPIP);
sls::strcpy_safe(args[3], detector_shm()->receiverUDPIP2);
snprintf(args[4], sizeof(args[4]), "%d", detector_shm()->receiverUDPPort);
snprintf(args[5], sizeof(args[5]), "%d", detector_shm()->receiverUDPPort2);
FILE_LOG(logDEBUG1) << "Receiver Number of UDP Interfaces: " << detector_shm()->numUDPInterfaces;
FILE_LOG(logDEBUG1) << "Receiver Selected Interface: " << detector_shm()->selectedUDPInterface;
FILE_LOG(logDEBUG1) << "Receiver udp ip address: " << detector_shm()->receiverUDPIP;
FILE_LOG(logDEBUG1) << "Receiver udp ip address2: " << detector_shm()->receiverUDPIP2;
FILE_LOG(logDEBUG1) << "Receiver udp port: " << detector_shm()->receiverUDPPort;
FILE_LOG(logDEBUG1) << "Receiver udp port2: " << detector_shm()->receiverUDPPort2;
@ -2552,16 +2794,23 @@ int slsDetector::setUDPConnection() {
auto receiver =
ReceiverSocket(detector_shm()->receiver_hostname, detector_shm()->receiverTCPPort);
ret = receiver.sendCommandThenRead(fnum, args, sizeof(args), retvals, sizeof(retvals));
FILE_LOG(logDEBUG1) << "Receiver UDP MAC returned : " << retvals;
memset(detector_shm()->receiverUDPMAC, 0, MAX_STR_LENGTH);
sls::strcpy_safe(detector_shm()->receiverUDPMAC, retvals);
if (strlen(retvals[0])) {
FILE_LOG(logDEBUG1) << "Receiver UDP MAC returned : " << retvals[0];
memset(detector_shm()->receiverUDPMAC, 0, MAX_STR_LENGTH);
sls::strcpy_safe(detector_shm()->receiverUDPMAC, retvals[0]);
}
if (strlen(retvals[1])) {
FILE_LOG(logDEBUG1) << "Receiver UDP MAC2 returned : " << retvals[1];
memset(detector_shm()->receiverUDPMAC2, 0, MAX_STR_LENGTH);
sls::strcpy_safe(detector_shm()->receiverUDPMAC2, retvals[1]);
}
if (ret == FORCE_UPDATE) {
receiver.close();
ret = updateCachedReceiverVariables();
}
// configure detector with udp details
if (configureMAC() == FAIL) {
setReceiverOnline(OFFLINE_FLAG); // FIXME: Needed??
setReceiverOnline(OFFLINE_FLAG);
}
} else {
throw ReceiverError("setUDPConnection: Receiver is OFFLINE");
@ -3516,10 +3765,15 @@ int64_t slsDetector::getRateCorrection() {
void slsDetector::printReceiverConfiguration(TLogLevel level) {
FILE_LOG(level) << "#Detector " << detId << ":\n Receiver Hostname:\t" << getReceiverHostname()
<< "\nDetector UDP IP (Source):\t\t" << getDetectorIP()
<< "\nDetector UDP MAC:\t\t" << getDetectorMAC() << "\nReceiver UDP IP:\t"
<< getReceiverUDPIP() << "\nReceiver UDP MAC:\t" << getReceiverUDPMAC()
<< "\nReceiver UDP Port:\t" << getReceiverUDPPort() << "\nReceiver UDP Port2:\t"
<< getReceiverUDPPort2();
<< "\nDetector UDP IP2 (Source):\t\t" << getDetectorIP2()
<< "\nDetector UDP MAC:\t\t" << getDetectorMAC()
<< "\nDetector UDP MAC2:\t\t" << getDetectorMAC2()
<< "\nReceiver UDP IP:\t" << getReceiverUDPIP()
<< "\nReceiver UDP IP2:\t" << getReceiverUDPIP2()
<< "\nReceiver UDP MAC:\t" << getReceiverUDPMAC()
<< "\nReceiver UDP MAC2:\t" << getReceiverUDPMAC2()
<< "\nReceiver UDP Port:\t" << getReceiverUDPPort()
<< "\nReceiver UDP Port2:\t"<< getReceiverUDPPort2();
}
int slsDetector::setReceiverOnline(int value) {

View File

@ -1535,6 +1535,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncName = "rx_hostname"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>rx_udpip [ip]</b> sets/gets the ip address of the receiver UDP interface where the data from the detector will be streamed to. Normally used for single detectors (Can be multi-detector). Used if different from eth0. \c Returns \c (string)
*/
@ -1542,6 +1543,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>rx_udpip2 [ip]</b> sets/gets the ip address of the second receiver UDP interface where the data from the bottom half module of the detector will be streamed to. Normally used for single detectors (Can be multi-detector). Used if different from eth0. JUNGFRAU only. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "rx_udpip2"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>rx_udpmac [mac]</b> sets/gets the mac address of the receiver UDP interface where the data from the detector will be streamed to. Normally used for single detectors (Can be multi-detector). \c Returns \c (string)
*/
@ -1549,6 +1557,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>rx_udpmac2 [mac]</b> sets/gets the mac address of the second receiver UDP interface where the data from the bottom half module of the detector will be streamed to. Normally used for single detectors (Can be multi-detector). JUNGFRAU only.\c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "rx_udpmac2"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>rx_udpport [port]</b> sets/gets the port of the receiver UDP interface where the data from the detector will be streamed to. Use single-detector command. \c Returns \c (int)
*/
@ -1557,7 +1572,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page network
- <b>rx_udpport2 [port]</b> sets/gets the second port of the receiver UDP interface where the data from the second half of the detector will be streamed to. Use single-detector command. Used for EIGER only. \c Returns \c (int)
- <b>rx_udpport2 [port]</b> sets/gets the second port of the receiver UDP interface where the data from the second half of the detector will be streamed to. Use single-detector command. Used for EIGERand JUNGFRAU only. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "rx_udpport2"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
@ -1585,12 +1600,40 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page network
- <b>detectorip [ip]</b> sets/gets the ip address of the detector UDP interface from where the detector will stream data. Use single-detector command. Keep in same subnet as rx_udpip (if rx_udpip specified). \c Returns \c (string)
- <b>detectormac2 [mac]</b> sets/gets the mac address of the second half of the detector UDP interface from where the bottom half module of the detector will stream data. Use single-detector command. Normally unused. JUNGFRAU only. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "detectormac2"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>detectorip [ip]</b> sets/gets the ip address of the detector UDP interface from where the bottom half of the detector will stream data. Use single-detector command. Keep in same subnet as rx_udpip (if rx_udpip specified). \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "detectorip"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>detectorip2 [ip]</b> sets/gets the ip address of the second half of the detector UDP interface from where the bottom half of the detector will stream data. Use single-detector command. Keep in same subnet as rx_udpip2 (if rx_udpip2 specified). JUNGFRAU only. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "detectorip2"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>numinterfaces [n]</b> sets/gets the number of interfaces used to stream out from the detector. Options: 1, 2. JUNGFRAU only. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "numinterfaces"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>selinterface [n]</b> sets/gets the 1st or the 2nd interface to use to stream data out of the detector. Options: 1, 2. Effective only when \c numinterfaces is 1. JUNGFRAU only. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "selinterface"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>txndelay_left [delay]</b> sets/gets the transmission delay of first packet in an image being streamed out from the detector's left UDP port. Use single-detector command. Used for EIGER only. \c Returns \c (int)
*/
@ -1606,7 +1649,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page network
- <b>txndelay_frame [delay]</b> sets/gets the transmission frame period of entire frame being streamed out from the detector for both ports. Use single-detector command. Used for EIGER only. \c Returns \c (int)
- <b>txndelay_frame [delay]</b> sets/gets the transmission frame period of entire frame being streamed out from the detector for both ports. Use single-detector command. Used for EIGER and JUNGFRAU only. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "txndelay_frame"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
@ -2789,11 +2832,21 @@ std::string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int
myDet->setDetectorMAC(args[1], detPos);
}
return myDet->getDetectorMAC(detPos);
} else if (cmd == "detectormac2") {
if (action == PUT_ACTION) {
myDet->setDetectorMAC2(args[1], detPos);
}
return myDet->getDetectorMAC2(detPos);
} else if (cmd == "detectorip") {
if (action == PUT_ACTION) {
myDet->setDetectorIP(args[1], detPos);
}
return myDet->getDetectorIP(detPos);
if (action == PUT_ACTION) {
myDet->setDetectorIP(args[1], detPos);
}
return myDet->getDetectorIP(detPos);
} else if (cmd == "detectorip2") {
if (action == PUT_ACTION) {
myDet->setDetectorIP2(args[1], detPos);
}
return myDet->getDetectorIP2(detPos);
} else if (cmd == "rx_hostname") {
if (action == PUT_ACTION) {
myDet->setReceiverHostname(args[1], detPos);
@ -2804,11 +2857,21 @@ std::string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int
myDet->setReceiverUDPIP(args[1], detPos);
}
return myDet->getReceiverUDPIP(detPos);
} else if (cmd == "rx_udpip2") {
if (action == PUT_ACTION) {
myDet->setReceiverUDPIP2(args[1], detPos);
}
return myDet->getReceiverUDPIP(detPos);
} else if (cmd == "rx_udpmac") {
if (action == PUT_ACTION) {
if (action == PUT_ACTION) {
myDet->setReceiverUDPMAC(args[1], detPos);
}
return myDet->getReceiverUDPMAC(detPos);
} else if (cmd == "rx_udpmac2") {
if (action == PUT_ACTION) {
myDet->setReceiverUDPMAC2(args[1], detPos);
}
return myDet->getReceiverUDPMAC(detPos);
} else if (cmd == "rx_udpport") {
if (action == PUT_ACTION) {
if (!(sscanf(args[1], "%d", &i))) {
@ -2827,6 +2890,24 @@ std::string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int
}
sprintf(ans, "%d", myDet->getReceiverUDPPort2(detPos));
return ans;
} else if (cmd == "numinterfaces") {
if (action == PUT_ACTION) {
if (!(sscanf(args[1], "%d", &i))) {
return ("cannot parse argument") + std::string(args[1]);
}
myDet->setNumberofUDPInterfaces(i, detPos);
}
sprintf(ans, "%d", myDet->getNumberofUDPInterfaces(detPos));
return ans;
} else if (cmd == "selinterface") {
if (action == PUT_ACTION) {
if (!(sscanf(args[1], "%d", &i))) {
return ("cannot parse argument") + std::string(args[1]);
}
myDet->selectUDPInterface(i, detPos);
}
sprintf(ans, "%d", myDet->getSelectedUDPInterface(detPos));
return ans;
} else if (cmd == "rx_udpsocksize") {
if (action == PUT_ACTION) {
int64_t ival = -1;
@ -2921,12 +3002,18 @@ std::string slsDetectorCommand::helpNetworkParameter(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "detectormac mac \n sets detector mac to mac" << std::endl;
os << "detectormac2 mac \n sets detector mac of 2nd udp interface to mac. Jungfrau only" << std::endl;
os << "detectorip ip \n sets detector ip to ip" << std::endl;
os << "detectorip2 ip \n sets detector ip of 2nd udp interface to ip. Jungfrau only" << std::endl;
os << "rx_hostname name \n sets receiver ip/hostname to name" << std::endl;
os << "rx_udpip ip \n sets receiver udp ip to ip" << std::endl;
os << "rx_udpip2 ip \n sets receiver udp ip of 2nd udp interface to ip. Jungfrau only" << std::endl;
os << "rx_udpmac mac \n sets receiver udp mac to mac" << std::endl;
os << "rx_udpmac2 mac \n sets receiver udp mac of 2nd udp interface to mac. Jungfrau only." << std::endl;
os << "rx_udpport port \n sets receiver udp port to port" << std::endl;
os << "rx_udpport2 port \n sets receiver udp port to port. For Eiger, it is the second half module and for other detectors, same as rx_udpport" << std::endl;
os << "rx_udpport2 port \n sets receiver udp port to port. For Eiger and Jungfrau, it is the second half module and for other detectors, same as rx_udpport" << std::endl;
os << "numinterfaces n \n sets the number of interfaces to n used to stream out from the detector. Options: 1, 2. JUNGFRAU only. " << std::endl;
os << "selinterface n \n sets the 1st or the 2nd interface to use to stream data out of the detector. Options: 1, 2. Effective only when numinterfaces is 1. JUNGFRAU only. " << std::endl;
os << "txndelay_left port \n sets detector transmission delay of the left port" << std::endl;
os << "txndelay_right port \n sets detector transmission delay of the right port" << std::endl;
os << "txndelay_frame port \n sets detector transmission delay of the entire frame" << std::endl;
@ -2955,11 +3042,18 @@ std::string slsDetectorCommand::helpNetworkParameter(int action) {
}
if (action == GET_ACTION || action == HELP_ACTION) {
os << "detectormac \n gets detector mac " << std::endl;
os << "detectormac2 \n gets detector mac of 2nd udp interface. Jungfrau only" << std::endl;
os << "detectorip \n gets detector ip " << std::endl;
os << "detectorip2 \n gets detector ip of 2nd udp interface. Jungfrau only" << std::endl;
os << "rx_hostname \n gets receiver ip " << std::endl;
os << "rx_udpmac \n gets receiver udp mac " << std::endl;
os << "rx_udpmac2 \n gets receiver udp mac of 2nd udp interface. Jungfrau only" << std::endl;
os << "rx_udpip \n gets receiver udp mac " << std::endl;
os << "rx_udpip2 \n gets receiver udp mac of 2nd udp interface. Jungfrau only" << std::endl;
os << "rx_udpport \n gets receiver udp port " << std::endl;
os << "rx_udpport2 \n gets receiver udp port. For Eiger, it is the second half module and for other detectors, same as rx_udpport" << std::endl;
os << "rx_udpport2 \n gets receiver udp port of 2nd udp interface. For Eiger and Jungfrau, it is the second half module and for other detectors, same as rx_udpport" << std::endl;
os << "numinterfaces \n gets the number of interfaces to n used to stream out from the detector. Options: 1, 2. JUNGFRAU only. " << std::endl;
os << "selinterface \n gets the interface selected to use to stream data out of the detector. Options: 1, 2. Effective only when numinterfaces is 1. JUNGFRAU only. " << std::endl;
os << "txndelay_left \n gets detector transmission delay of the left port" << std::endl;
os << "txndelay_right \n gets detector transmission delay of the right port" << std::endl;
os << "txndelay_frame \n gets detector transmission delay of the entire frame" << std::endl;

View File

@ -217,6 +217,14 @@ public:
cprintf(RED,"setImageSize is a generic function that should be overloaded by a derived class\n");
};
/**
* set number of interfaces (jungfrau)
* @param number of interfaces
*/
virtual void SetNumberofInterfaces(const int n) {
cprintf(RED,"SetNumberofInterfaces is a generic function that should be overloaded by a derived class\n");
}
/**
* Print all variables
*/
@ -508,14 +516,38 @@ class JungfrauData : public GeneralData {
dataSize = 8192;
packetSize = headerSizeinPacket + dataSize;
packetsPerFrame = 128;
imageSize = dataSize*packetsPerFrame;
imageSize = dataSize * packetsPerFrame;
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
defaultFifoDepth = 2500;
standardheader = true;
defaultUdpSocketBufferSize = (2000 * 1024 * 1024);
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
};
/**
* set number of interfaces (jungfrau)
* @param number of interfaces
*/
void SetNumberofInterfaces(const int n) {
// 2 interfaces
if (n == 2) {
nPixelsY = 256;
packetsPerFrame = 64;
imageSize = dataSize * packetsPerFrame;
threadsPerReceiver = 2;
defaultUdpSocketBufferSize = (500 * 1024 * 1024);
}
// 1 interface
else {
nPixelsY = 512;
packetsPerFrame = 128;
imageSize = dataSize * packetsPerFrame;
threadsPerReceiver = 1;
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
}
}
};

View File

@ -163,17 +163,29 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
uint32_t getUDPPortNumber() const;
/**
* Get Second UDP Port Number (eiger specific)
* Get Second UDP Port Number (eiger/jungfrau specific)
* @return second udp port number
*/
uint32_t getUDPPortNumber2() const;
/**
* Get Ehernet Interface
* @ethernet interface. eg. eth0 or "" if listening to all
* @return ethernet interface. eg. eth0 or "" if listening to all
*/
std::string getEthernetInterface() const;
/**
* Get Ehernet Interface 2 (jungfrau specific)
* @return ethernet interface 2. eg. eth0 or "" if listening to all
*/
std::string getEthernetInterface2() const;
/**
* Get number of UDP Interfaces (jungfrau specific)
* @return number of udp interfaces. Options (1-2)
*/
int getNumberofUDPInterfaces() const;
//***acquisition parameters***
/**
@ -422,7 +434,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
void setUDPPortNumber(const uint32_t i);
/**
* Set Second UDP Port Number (eiger specific)
* Set Second UDP Port Number (eiger/jungfrau specific)
* @return second udp port number
*/
void setUDPPortNumber2(const uint32_t i);
@ -433,6 +445,19 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
*/
void setEthernetInterface(const char* c);
/**
* Set second Ethernet Interface to listen to (jungfrau specific)
* @param c second ethernet inerface eg. eth0 (max of 1000 characters)
*/
void setEthernetInterface2(const char* c);
/**
* Set number of UDP Interfaces (jungfrau specific)
* @param n number of udp interfaces. Options (1-2)
* @return OK or FAIL for fifo structure creation
*/
int setNumberofUDPInterfaces(const int n);
/** (not saved in client shared memory)
* Set UDP Socket Buffer Size
* @param s UDP Socket Buffer Size
@ -591,9 +616,9 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
/**
* Set detector position id and construct filewriter
* @param i position id
* @param id position id
*/
void setDetectorPositionId(const int i);
void setDetectorPositionId(const int id);
//***acquisition functions***
/**
@ -800,8 +825,10 @@ private:
bool silentMode;
//***connection parameters***
/** Number of UDP Interfaces */
int numUDPInterfaces;
/** Ethernet Interface */
char eth[MAX_STR_LENGTH];
char eth[MAX_NUMBER_OF_LISTENING_THREADS][MAX_STR_LENGTH];
/** Server UDP Port Number*/
uint32_t udpPortNum[MAX_NUMBER_OF_LISTENING_THREADS];
/** udp socket buffer size */

View File

@ -81,8 +81,9 @@ void slsReceiverImplementation::InitializeMembers() {
silentMode = false;
//***connection parameters***
strcpy(eth,"");
numUDPInterfaces = 1;
for(int i=0;i<MAX_NUMBER_OF_LISTENING_THREADS;i++) {
strcpy(eth[i], "");
udpPortNum[i] = DEFAULT_UDP_PORTNO + i;
}
udpSocketBufferSize = 0;
@ -268,7 +269,17 @@ uint32_t slsReceiverImplementation::getUDPPortNumber2() const{
std::string slsReceiverImplementation::getEthernetInterface() const{
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
return std::string(eth);
return std::string(eth[0]);
}
std::string slsReceiverImplementation::getEthernetInterface2() const{
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
return std::string(eth[1]);
}
int slsReceiverImplementation::getNumberofUDPInterfaces() const{
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
return numUDPInterfaces;
}
@ -402,10 +413,14 @@ void slsReceiverImplementation::setDetectorHostname(const char *c) {
void slsReceiverImplementation::setMultiDetectorSize(const int* size) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
std::string log_message = "Detector Size: (";
std::string log_message = "Detector Size (ports): (";
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
if (myDetectorType == EIGER && (!i))
numDet[i] = size[i]*2;
// x dir (colums) each udp port
if (myDetectorType == EIGER && i == X)
numDet[i] = size[i] * 2;
// y dir (rows) each udp port
else if (numUDPInterfaces == 2 && i == Y)
numDet[i] = size[i] * 2;
else
numDet[i] = size[i];
log_message += std::to_string(numDet[i]);
@ -606,14 +621,116 @@ void slsReceiverImplementation::setUDPPortNumber2(const uint32_t i) {
void slsReceiverImplementation::setEthernetInterface(const char* c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
strcpy(eth, c);
FILE_LOG(logINFO) << "Ethernet Interface: " << eth;
strcpy(eth[0], c);
FILE_LOG(logINFO) << "Ethernet Interface: " << eth[0];
}
void slsReceiverImplementation::setEthernetInterface2(const char* c) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
strcpy(eth[1], c);
FILE_LOG(logINFO) << "Ethernet Interface 2: " << eth[1];
}
int slsReceiverImplementation::setNumberofUDPInterfaces(const int n) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (numUDPInterfaces != n) {
// reduce number of detectors in y dir (rows) if it had 2 interfaces before
if (numUDPInterfaces == 2)
numDet[Y] /= 2;
numUDPInterfaces = n;
// clear all threads and fifos
listener.clear();
dataProcessor.clear();
dataStreamer.clear();
fifo.clear();
// set local variables
generalData->SetNumberofInterfaces(n);
numThreads = generalData->threadsPerReceiver;
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
// fifo
if (SetupFifoStructure() == FAIL)
return FAIL;
//create threads
for ( int i = 0; i < numThreads; ++i ) {
// listener and dataprocessor threads
try {
auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>(i, myDetectorType, fifo_ptr, &status,
&udpPortNum[i], eth[i], &numberOfFrames, &dynamicRange,
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
&frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode));
listener[i]->SetGeneralData(generalData);
dataProcessor.push_back(sls::make_unique<DataProcessor>(i, myDetectorType, fifo_ptr, &fileFormatType,
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode));
dataProcessor[i]->SetGeneralData(generalData);
}
catch (...) {
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
listener.clear();
dataProcessor.clear();
return FAIL;
}
// streamer threads
if (dataStreamEnable) {
try {
dataStreamer.push_back(sls::make_unique<DataStreamer>(i, fifo[i].get(), &dynamicRange,
&roi, &fileIndex, flippedData, additionalJsonHeader));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
} catch(...) {
FILE_LOG(logERROR) << "Could not create datastreamer threads (index:" << i << ")";
if (dataStreamEnable) {
dataStreamer.clear();
dataStreamEnable = false;
}
return FAIL;
}
}
}
SetThreadPriorities();
// update (from 1 to 2 interface) & also for printout
setMultiDetectorSize(numDet);
// update row and column in dataprocessor
setDetectorPositionId(detID);
// test socket buffer size with current set up
if (setUDPSocketBufferSize(0) == FAIL) {
return FAIL;
}
}
FILE_LOG(logINFO) << "Number of Interfaces: " << numUDPInterfaces;
return OK;
}
int slsReceiverImplementation::setUDPSocketBufferSize(const int64_t s) {
if (listener.size())
return listener[0]->CreateDummySocketForUDPSocketBufferSize(s);
return FAIL;
int64_t size = (s == 0) ? udpSocketBufferSize : s;
size_t listSize = listener.size();
if ((int)listSize != numUDPInterfaces)
return FAIL;
for (unsigned int i = 0; i < listSize; ++i) {
if (listener[i]->CreateDummySocketForUDPSocketBufferSize(size) == FAIL)
return FAIL;
}
return OK;
}
@ -940,7 +1057,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
try {
auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>(i, myDetectorType, fifo_ptr, &status,
&udpPortNum[i], eth, &numberOfFrames, &dynamicRange,
&udpPortNum[i], eth[i], &numberOfFrames, &dynamicRange,
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
&frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode));
dataProcessor.push_back(sls::make_unique<DataProcessor>(i, myDetectorType, fifo_ptr, &fileFormatType,
@ -964,9 +1081,6 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
it->SetGeneralData(generalData);
SetThreadPriorities();
// check udp socket buffer size
setUDPSocketBufferSize(udpSocketBufferSize);
FILE_LOG(logDEBUG) << " Detector type set to " << detectorTypeToString(d);
return OK;
}
@ -974,9 +1088,9 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
void slsReceiverImplementation::setDetectorPositionId(const int i) {
void slsReceiverImplementation::setDetectorPositionId(const int id) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
detID = i;
detID = id;
FILE_LOG(logINFO) << "Detector Position Id:" << detID;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
dataProcessor[i]->SetupFileWriter(fileWriteEnable, (int*)numDet,
@ -987,7 +1101,7 @@ void slsReceiverImplementation::setDetectorPositionId(const int i) {
for (unsigned int i = 0; i < listener.size(); ++i) {
uint16_t row = 0, col = 0;
row = detID % numDet[1]; // row
row = (detID % numDet[1]) * ((numUDPInterfaces == 2) ? 2 : 1); // row
col = (detID / numDet[1]) * ((myDetectorType == EIGER) ? 2 : 1) + i; // col for horiz. udp ports
listener[i]->SetHardCodedPosition(row, col);
}
@ -1112,6 +1226,7 @@ void slsReceiverImplementation::stopReceiver() {
int64_t missingpackets = numberOfFrames*generalData->packetsPerFrame-listener[i]->GetPacketsCaught();
TLogLevel lev = (((int64_t)missingpackets) > 0) ? logINFORED : logINFOGREEN;
FILE_LOG(lev) <<
// udp port number could be the second if selected interface is 2 for jungfrau
"Summary of Port " << udpPortNum[i] <<
"\n\tMissing Packets\t\t: " << missingpackets <<
"\n\tComplete Frames\t\t: " << dataProcessor[i]->GetNumFramesCaught() <<
@ -1328,11 +1443,15 @@ void slsReceiverImplementation::ResetParametersforNewMeasurement() {
int slsReceiverImplementation::CreateUDPSockets() {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
bool error = false;
for (unsigned int i = 0; i < listener.size(); ++i)
for (unsigned int i = 0; i < listener.size(); ++i) {
if (listener[i]->CreateUDPSockets() == FAIL) {
error = true;
break;
}
}
if (error) {
shutDownUDPSockets();
return FAIL;

View File

@ -710,8 +710,8 @@ int slsReceiverTCPIPInterface::set_roi() {
int slsReceiverTCPIPInterface::setup_udp(){
ret = OK;
memset(mess, 0, sizeof(mess));
char args[3][MAX_STR_LENGTH] = {{""}, {""}, {""}};
char retvals[MAX_STR_LENGTH] = {""};
char args[6][MAX_STR_LENGTH] = {{""}, {""}, {""}, {""}, {""}, {""}};
char retvals[2][MAX_STR_LENGTH] = {{""}, {""}};
// get args, return if socket crashed, ret is fail if receiver is not null
if (interface->Server_ReceiveArg(ret, mess, args, sizeof(args), true, receiver) == FAIL)
@ -722,48 +722,108 @@ int slsReceiverTCPIPInterface::setup_udp(){
// only set
// verify if receiver is unlocked and idle
if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) {
//set up udp port
int udpport=-1,udpport2=-1;
sscanf(args[1],"%d",&udpport);
sscanf(args[2],"%d",&udpport2);
receiver->setUDPPortNumber(udpport);
if (myDetectorType == EIGER)
receiver->setUDPPortNumber2(udpport2);
//setup udpip
//get ethernet interface or IP to listen to
FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0];
std::string temp = genericSocket::ipToName(args[0]);
//setup interfaces count
int numInterfaces = atoi(args[0]) > 1 ? 2 : 1;
int selInterface = atoi(args[1]) > 1 ? 2 : 1;
char* ip1 = args[2];
char* ip2 = args[3];
uint32_t port1 = atoi(args[4]);
uint32_t port2 = atoi(args[5]);
// using the 2nd interface only
if (numInterfaces == 1 && selInterface == 2) {
ip1 = ip2;
port1 = port2;
}
// 1st interface
receiver->setUDPPortNumber(port1);
FILE_LOG(logINFO) << "Receiver UDP IP: " << ip1;
// get eth
std::string temp = genericSocket::ipToName(ip1);
if (temp == "none"){
ret = FAIL;
strcpy(mess, "Failed to get ethernet interface or IP\n");
strcpy(mess, "Failed to get ethernet interface or IP \n");
FILE_LOG(logERROR) << mess;
}
else {
char eth[MAX_STR_LENGTH];
memset(eth,0,sizeof(eth));
strcpy(eth,temp.c_str());
if (strchr(eth,'.') != nullptr) {
strcpy(eth,"");
} else {
char eth[MAX_STR_LENGTH] = {""};
memset(eth, 0, MAX_STR_LENGTH);
strcpy(eth, temp.c_str());
// if there is a dot in eth name
if (strchr(eth, '.') != nullptr) {
strcpy(eth, "");
ret = FAIL;
strcpy(mess, "Failed to get ethernet interface\n");
sprintf(mess, "Failed to get ethernet interface from IP. Got %s\n", temp.c_str());
FILE_LOG(logERROR) << mess;
}
receiver->setEthernetInterface(eth);
//get mac address from ethernet interface
if (ret != FAIL)
//get mac address
if (ret != FAIL) {
temp = genericSocket::nameToMac(eth);
if (temp=="00:00:00:00:00:00") {
ret = FAIL;
strcpy(mess,"failed to get mac adddress to listen to\n");
FILE_LOG(logERROR) << mess;
} else {
// using the 2nd interface only
if (numInterfaces == 1 && selInterface == 2) {
strcpy(retvals[1],temp.c_str());
FILE_LOG(logINFO) << "Receiver MAC Address: " << retvals[1];
}
else {
strcpy(retvals[0],temp.c_str());
FILE_LOG(logINFO) << "Receiver MAC Address: " << retvals[0];
}
}
}
}
if ((temp=="00:00:00:00:00:00") || (ret == FAIL)){
// 2nd interface
if (numInterfaces == 2) {
receiver->setUDPPortNumber2(port2);
FILE_LOG(logINFO) << "Receiver UDP IP 2: " << ip2;
// get eth
std::string temp = genericSocket::ipToName(ip2);
if (temp == "none"){
ret = FAIL;
strcpy(mess,"failed to get mac adddress to listen to\n");
strcpy(mess, "Failed to get 2nd ethernet interface or IP \n");
FILE_LOG(logERROR) << mess;
} else {
char eth[MAX_STR_LENGTH] = {""};
memset(eth, 0, MAX_STR_LENGTH);
strcpy(eth, temp.c_str());
// if there is a dot in eth name
if (strchr(eth, '.') != nullptr) {
strcpy(eth, "");
ret = FAIL;
sprintf(mess, "Failed to get 2nd ethernet interface from IP. Got %s\n", temp.c_str());
FILE_LOG(logERROR) << mess;
}
receiver->setEthernetInterface2(eth);
//get mac address
if (ret != FAIL) {
temp = genericSocket::nameToMac(eth);
if (temp=="00:00:00:00:00:00") {
ret = FAIL;
strcpy(mess,"failed to get 2nd mac adddress to listen to\n");
FILE_LOG(logERROR) << mess;
} else {
strcpy(retvals[1],temp.c_str());
FILE_LOG(logINFO) << "Receiver MAC Address 2: " << retvals[1];
}
}
}
else {
strcpy(retvals,temp.c_str());
FILE_LOG(logINFO) << "Receiver MAC Address: " << retvals;
}
}
// set the number of udp interfaces (changes number of threads and many others)
if (receiver->setNumberofUDPInterfaces(numInterfaces) == FAIL) {
ret = FAIL;
sprintf(mess, "Failed to set number of interfaces\n");
FILE_LOG(logERROR) << mess;
}
}
}
@ -1752,7 +1812,8 @@ int slsReceiverTCPIPInterface::set_udp_socket_buffer_size() {
}
// get
retval = receiver->getUDPSocketBufferSize();
validate(index, retval, std::string("set udp socket buffer size (No CAP_NET_ADMIN privileges?)"), DEC);
if (index != 0)
validate(index, retval, std::string("set udp socket buffer size (No CAP_NET_ADMIN privileges?)"), DEC);
FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval;
}
return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess);

View File

@ -52,7 +52,9 @@ typedef int int32_t;
#define GET_FLAG -1
#define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee"
#define DEFAULT_DET_IP "129.129.202.46"
#define DEFAULT_DET_IP "129.129.202.45"
#define DEFAULT_DET_MAC2 "00:aa:bb:cc:dd:ff"
#define DEFAULT_DET_IP2 "129.129.202.46"
/** default maximum string length */
#define MAX_STR_LENGTH 1000