Merge pull request #295 from slsdetectorgroup/modid

Modid
This commit is contained in:
Dhanya Thattil 2021-09-09 17:58:03 +02:00 committed by GitHub
commit 9d4d667df1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 249 additions and 227 deletions

View File

@ -73,7 +73,8 @@ vetoalg
vetostream vetostream
serialnumber (put) serialnumber (put)
dbitpipeline dbitpipeline
readnlines->partialread readnlines->readnrows
serialnumber->moduleid
setting number of udp interfaces from 1 to 2, didnt get image in gui setting number of udp interfaces from 1 to 2, didnt get image in gui

View File

@ -73,9 +73,6 @@ void init_det(py::module &m) {
(Result<int>(Detector::*)(sls::Positions) const) & (Result<int>(Detector::*)(sls::Positions) const) &
Detector::getModuleId, Detector::getModuleId,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setModuleId",
(void (Detector::*)(int, sls::Positions)) & Detector::setModuleId,
py::arg(), py::arg() = Positions{})
.def("getReceiverVersion", .def("getReceiverVersion",
(Result<int64_t>(Detector::*)(sls::Positions) const) & (Result<int64_t>(Detector::*)(sls::Positions) const) &
Detector::getReceiverVersion, Detector::getReceiverVersion,

View File

@ -127,44 +127,14 @@ int Beb_SetHeaderData(uint64_t src_mac, uint32_t src_ip, uint16_t src_port,
uint32_t src_lsb = ((src_mac >> 0) & BIT32_MASK); uint32_t src_lsb = ((src_mac >> 0) & BIT32_MASK);
memcpy(&(udp_header.src_mac[0]), &src_msb, sizeof(src_msb)); memcpy(&(udp_header.src_mac[0]), &src_msb, sizeof(src_msb));
memcpy(&(udp_header.src_mac[2]), &src_lsb, sizeof(src_lsb)); memcpy(&(udp_header.src_mac[2]), &src_lsb, sizeof(src_lsb));
for (int i = 0; i < 6; ++i) {
LOG(logDEBUG1,
("src mac[%d]: %02x\n", i, (uint8_t *)udp_header.src_mac[i]));
}
memcpy(&(udp_header.src_ip[0]), &src_ip, sizeof(udp_header.src_ip)); memcpy(&(udp_header.src_ip[0]), &src_ip, sizeof(udp_header.src_ip));
for (int i = 0; i < 4; ++i) {
LOG(logDEBUG1,
("src ip[%d]: %02x\n", i, (uint8_t *)udp_header.src_ip[i]));
}
memcpy(&(udp_header.src_port[0]), &src_port, sizeof(udp_header.src_port)); memcpy(&(udp_header.src_port[0]), &src_port, sizeof(udp_header.src_port));
for (int i = 0; i < 2; ++i) {
LOG(logDEBUG1,
("src port[%d]: %02x\n", i, (uint8_t *)udp_header.src_port[i]));
}
uint32_t dst_msb = ((dst_mac >> 16) & BIT32_MASK); uint32_t dst_msb = ((dst_mac >> 16) & BIT32_MASK);
uint16_t dst_lsb = ((dst_mac >> 0) & BIT16_MASK); uint16_t dst_lsb = ((dst_mac >> 0) & BIT16_MASK);
memcpy(&(udp_header.dst_mac[0]), &dst_msb, sizeof(dst_msb)); memcpy(&(udp_header.dst_mac[0]), &dst_msb, sizeof(dst_msb));
memcpy(&(udp_header.dst_mac[4]), &dst_lsb, sizeof(dst_lsb)); memcpy(&(udp_header.dst_mac[4]), &dst_lsb, sizeof(dst_lsb));
for (int i = 0; i < 6; ++i) {
LOG(logDEBUG1,
("dst mac[%d]: %02x\n", i, (uint8_t *)udp_header.dst_mac[i]));
}
memcpy(&(udp_header.dst_ip[0]), &dst_ip, sizeof(udp_header.dst_ip)); memcpy(&(udp_header.dst_ip[0]), &dst_ip, sizeof(udp_header.dst_ip));
for (int i = 0; i < 4; ++i) { memcpy(&(udp_header.dst_port[0]), &dst_port, sizeof(udp_header.dst_port));
LOG(logDEBUG1,
("dst ip[%d]: %02x\n", i, (uint8_t *)udp_header.dst_ip[i]));
}
memcpy(&(udp_header.dst_port[0]), &dst_port,
sizeof(udp_header.dst_port));
for (int i = 0; i < 2; ++i) {
LOG(logDEBUG1,
("dst port[%d]: %02x\n", i, (uint8_t *)udp_header.dst_port[i]));
}
Beb_AdjustIPChecksum(&udp_header); Beb_AdjustIPChecksum(&udp_header);
@ -1022,18 +992,19 @@ int Beb_GetBebFPGATemp() {
return temperature; return temperature;
} }
void Beb_SetDetectorNumber(uint32_t detid) { int Beb_SetModuleId(uint32_t detid) {
if (!Beb_activated) if (!Beb_activated)
return; return OK;
uint32_t swapid = Beb_swap_uint16(detid); uint32_t swapid = Beb_swap_uint16(detid);
// LOG(logINFO, "detector id %d swapped %d\n", detid, swapid)); // LOG(logINFO, "detector id %d swapped %d\n", detid, swapid));
u_int32_t *csp0base = 0; u_int32_t *csp0base = 0;
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR); int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR);
if (fd < 0) { if (fd < 0) {
LOG(logERROR, ("Set Detector ID FAIL\n")); LOG(logERROR, ("Set module id FAIL\n"));
return; return FAIL;
} else { } else {
// left
uint32_t value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST); uint32_t value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
value &= UDP_HEADER_X_MSK; // to keep previous x value value &= UDP_HEADER_X_MSK; // to keep previous x value
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST,
@ -1042,8 +1013,11 @@ void Beb_SetDetectorNumber(uint32_t detid) {
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST); value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
if ((value & UDP_HEADER_ID_MSK) != if ((value & UDP_HEADER_ID_MSK) !=
((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) { ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
LOG(logERROR, ("Set Detector ID FAIL\n")); LOG(logERROR, ("Set module id FAIL\n"));
Beb_close(fd, csp0base);
return FAIL;
} }
// right
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST); value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
value &= UDP_HEADER_X_MSK; // to keep previous x value value &= UDP_HEADER_X_MSK; // to keep previous x value
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST,
@ -1052,11 +1026,14 @@ void Beb_SetDetectorNumber(uint32_t detid) {
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST); value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
if ((value & UDP_HEADER_ID_MSK) != if ((value & UDP_HEADER_ID_MSK) !=
((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) { ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
LOG(logERROR, ("Set Detector ID FAIL\n")); LOG(logERROR, ("Set module id FAIL\n"));
Beb_close(fd, csp0base);
return FAIL;
} }
Beb_close(fd, csp0base); Beb_close(fd, csp0base);
} }
LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid)); LOG(logINFO, ("Module id %d set in UDP Header\n\n", detid));
return OK;
} }
int Beb_SetQuad(int value) { int Beb_SetQuad(int value) {

View File

@ -42,14 +42,14 @@ int Beb_StopAcquisition();
int Beb_RequestNImages(int ten_gig, unsigned int nimages, int Beb_RequestNImages(int ten_gig, unsigned int nimages,
int test_just_send_out_packets_no_wait); int test_just_send_out_packets_no_wait);
int Beb_GetBebFPGATemp(); int Beb_GetBebFPGATemp();
void Beb_SetDetectorNumber(uint32_t detid); int Beb_SetModuleId(uint32_t detid);
int Beb_SetQuad(int value); int Beb_SetQuad(int value);
int Beb_GetQuad(); int Beb_GetQuad();
int *Beb_GetDetectorPosition(); int *Beb_GetDetectorPosition();
int Beb_SetDetectorPosition(int pos[]); int Beb_SetDetectorPosition(int pos[]);
int Beb_SetNextFrameNumber(uint64_t value); int Beb_SetNextFrameNumber(uint64_t value);
int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable); int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable);
void Beb_SetPartialReadout(int value); void Beb_SetReadNRows(int value);
int Beb_GetNumberofDestinations(int *retval); int Beb_GetNumberofDestinations(int *retval);
int Beb_SetNumberofDestinations(int value); int Beb_SetNumberofDestinations(int value);

View File

@ -100,3 +100,4 @@ install(TARGETS eigerDetectorServerSlaveBottom_virtual
configure_file(config_eiger.txt ${CMAKE_BINARY_DIR}/bin/config_eiger.txt COPYONLY) configure_file(config_eiger.txt ${CMAKE_BINARY_DIR}/bin/config_eiger.txt COPYONLY)
configure_file(detid_eiger.txt ${CMAKE_BINARY_DIR}/bin/detid_eiger.txt COPYONLY)

View File

@ -57,7 +57,7 @@ void Feb_Control_FebControl() {
malloc(Feb_Control_trimbit_size * sizeof(int)); malloc(Feb_Control_trimbit_size * sizeof(int));
} }
int Feb_Control_Init(int master, int normal, int module_num) { int Feb_Control_Init(int master, int normal) {
Feb_Control_master = master; Feb_Control_master = master;
Feb_Control_normal = normal; Feb_Control_normal = normal;
Feb_Interface_SetAddress(Feb_Control_rightAddress, Feb_Control_leftAddress); Feb_Interface_SetAddress(Feb_Control_rightAddress, Feb_Control_leftAddress);

View File

@ -6,7 +6,7 @@
// setup // setup
void Feb_Control_activate(int activate); void Feb_Control_activate(int activate);
void Feb_Control_FebControl(); void Feb_Control_FebControl();
int Feb_Control_Init(int master, int normal, int module_num); int Feb_Control_Init(int master, int normal);
int Feb_Control_OpenSerialCommunication(); int Feb_Control_OpenSerialCommunication();
void Feb_Control_CloseSerialCommunication(); void Feb_Control_CloseSerialCommunication();
int Feb_Control_CheckSetup(); int Feb_Control_CheckSetup();

View File

@ -34,6 +34,7 @@ $(PROGS): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR) mv $(PROGS) $(DESTDIR)
cp config_eiger.txt $(DESTDIR) cp config_eiger.txt $(DESTDIR)
cp detid.txt $(DESTDIR)
hv9m_blackfin_server:9mhvserial_bf.c hv9m_blackfin_server:9mhvserial_bf.c

View File

@ -0,0 +1 @@
beb001

View File

@ -0,0 +1 @@
beb001

View File

@ -46,9 +46,6 @@ unsigned int nimages_per_request = 1;
int top = 0; int top = 0;
int master = 0; int master = 0;
int normal = 0; int normal = 0;
#ifndef VIRTUAL
uint32_t detid = 0;
#endif
int eiger_highvoltage = 0; int eiger_highvoltage = 0;
int eiger_theo_highvoltage = 0; int eiger_theo_highvoltage = 0;
@ -222,25 +219,8 @@ u_int64_t getFirmwareAPIVersion() {
#endif #endif
} }
void readDetectorNumber() { int getModuleId(int *ret, char *mess) {
#ifndef VIRTUAL return getModuleIdInFile(ret, mess, ID_FILE);
char output[255];
FILE *sysFile = popen(IDFILECOMMAND, "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
sscanf(output, "%u", &detid);
if (isControlServer) {
LOG(logINFOBLUE, ("Detector ID: %u\n", detid));
}
#endif
}
u_int32_t getDetectorNumber() {
#ifdef VIRTUAL
return 0;
#else
return detid;
#endif
} }
u_int64_t getDetectorMAC() { u_int64_t getDetectorMAC() {
@ -322,7 +302,14 @@ u_int32_t getDetectorIP() {
void initControlServer() { void initControlServer() {
LOG(logINFOBLUE, ("Configuring Control server\n")); LOG(logINFOBLUE, ("Configuring Control server\n"));
if (!updateFlag && initError == OK) { if (!updateFlag && initError == OK) {
readDetectorNumber(); #ifndef VIRTUAL
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
#else
getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
#endif
if (initError == FAIL) {
return;
}
getModuleConfiguration(); getModuleConfiguration();
#ifndef VIRTUAL #ifndef VIRTUAL
sharedMemory_lockLocalLink(); sharedMemory_lockLocalLink();
@ -330,7 +317,7 @@ void initControlServer() {
Feb_Interface_FebInterface(); Feb_Interface_FebInterface();
Feb_Control_FebControl(); Feb_Control_FebControl();
// same addresses for top and bottom // same addresses for top and bottom
if (!Feb_Control_Init(master, normal, getDetectorNumber())) { if (!Feb_Control_Init(master, normal)) {
initError = FAIL; initError = FAIL;
sprintf(initErrorMessage, "Could not intitalize feb control\n"); sprintf(initErrorMessage, "Could not intitalize feb control\n");
LOG(logERROR, (initErrorMessage)); LOG(logERROR, (initErrorMessage));
@ -355,7 +342,7 @@ void initControlServer() {
LOG(logDEBUG1, ("Control server: FEB Initialization done\n")); LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
Beb_SetTopVariable(top); Beb_SetTopVariable(top);
Beb_Beb(); Beb_Beb();
Beb_SetDetectorNumber(getDetectorNumber()); Beb_SetModuleId(modid);
LOG(logDEBUG1, ("Control server: BEB Initialization done\n")); LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
#endif #endif
// also reads config file and deactivates // also reads config file and deactivates
@ -376,14 +363,13 @@ void initStopServer() {
usleep(WAIT_STOP_SERVER_START); usleep(WAIT_STOP_SERVER_START);
LOG(logINFOBLUE, ("Configuring Stop server\n")); LOG(logINFOBLUE, ("Configuring Stop server\n"));
// exit(-1); // exit(-1);
readDetectorNumber();
getModuleConfiguration(); getModuleConfiguration();
sharedMemory_lockLocalLink(); sharedMemory_lockLocalLink();
Feb_Control_SetMasterVariable(master); Feb_Control_SetMasterVariable(master);
Feb_Interface_FebInterface(); Feb_Interface_FebInterface();
Feb_Control_FebControl(); Feb_Control_FebControl();
// same addresses for top and bottom // same addresses for top and bottom
Feb_Control_Init(master, normal, getDetectorNumber()); Feb_Control_Init(master, normal);
sharedMemory_unlockLocalLink(); sharedMemory_unlockLocalLink();
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n")); LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
#endif #endif

View File

@ -2,7 +2,13 @@
#include "sls/sls_detector_defs.h" #include "sls/sls_detector_defs.h"
#define REQUIRED_FIRMWARE_VERSION (27) #define REQUIRED_FIRMWARE_VERSION (27)
#define IDFILECOMMAND "more /home/root/executables/detid.txt" // virtual ones renamed for consistency
// real ones keep previous name for compatibility (already in production)
#ifdef VIRTUAL
#define ID_FILE "detid_eiger.txt"
#else
#define ID_FILE "detid.txt"
#endif
#define CONFIG_FILE ("config_eiger.txt") #define CONFIG_FILE ("config_eiger.txt")
#define WAIT_STOP_SERVER_START (1 * 1000 * 1000) #define WAIT_STOP_SERVER_START (1 * 1000 * 1000)

View File

@ -40,3 +40,4 @@ install(TARGETS gotthard2DetectorServer_virtual
) )
configure_file(config_gotthard2.txt ${CMAKE_BINARY_DIR}/bin/config_gotthard2.txt COPYONLY) configure_file(config_gotthard2.txt ${CMAKE_BINARY_DIR}/bin/config_gotthard2.txt COPYONLY)
configure_file(detid_gotthard2.txt ${CMAKE_BINARY_DIR}/bin/detid_gotthard2.txt COPYONLY)

View File

@ -33,6 +33,7 @@ $(PROGS): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR) mv $(PROGS) $(DESTDIR)
cp config_gotthard2.txt $(DESTDIR) cp config_gotthard2.txt $(DESTDIR)
cp detid_gotthard2.txt $(DESTDIR)
rm $(main_src)*.o rm $(main_src)*.o
clean: clean:

View File

@ -127,7 +127,6 @@
#define MOD_ID_OFST (0) #define MOD_ID_OFST (0)
#define MOD_ID_MSK (0x0000FFFF << MOD_ID_OFST) #define MOD_ID_MSK (0x0000FFFF << MOD_ID_OFST)
#define MOD_MAX_VAL (0xFFFF)
/* ASIC registers --------------------------------------------------*/ /* ASIC registers --------------------------------------------------*/

View File

@ -0,0 +1 @@
1234

View File

@ -287,15 +287,15 @@ u_int32_t getDetectorNumber() {
return bus_r(MCB_SERIAL_NO_REG); return bus_r(MCB_SERIAL_NO_REG);
} }
int getModuleId() { return ((bus_r(MOD_ID_REG) & MOD_ID_MSK) >> MOD_ID_OFST); } int getModuleId(int *ret, char *mess) {
return ((bus_r(MOD_ID_REG) & ~MOD_ID_MSK) >> MOD_ID_OFST);
void setModuleId(int arg) {
LOG(logINFOBLUE, ("Setting Module Id to 0x%x\n", arg));
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) | ((arg << MOD_ID_OFST) & MOD_ID_MSK));
} }
int getMaxModuleId() { return MOD_MAX_VAL; } void setModuleId(int modid) {
LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid))
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK);
bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
}
u_int64_t getDetectorMAC() { u_int64_t getDetectorMAC() {
#ifdef VIRTUAL #ifdef VIRTUAL
@ -419,7 +419,6 @@ void setupDetector() {
sharedMemory_setStatus(IDLE); sharedMemory_setStatus(IDLE);
setupUDPCommParameters(); setupUDPCommParameters();
#endif #endif
// pll defines // pll defines
ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL,
PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_REG, PLL_RESET_READOUT_MSK,
@ -477,6 +476,14 @@ void setupDetector() {
if (readConfigFile() == FAIL) { if (readConfigFile() == FAIL) {
return; return;
} }
// set module id in register
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
if (initError == FAIL) {
return;
}
setModuleId(modid);
setBurstMode(DEFAULT_BURST_MODE); setBurstMode(DEFAULT_BURST_MODE);
setFilterResistor(DEFAULT_FILTER_RESISTOR); setFilterResistor(DEFAULT_FILTER_RESISTOR);
setCDSGain(DEFAILT_CDS_GAIN); setCDSGain(DEFAILT_CDS_GAIN);

View File

@ -3,6 +3,7 @@
#define REQRD_FRMWRE_VRSN (0x210527) #define REQRD_FRMWRE_VRSN (0x210527)
#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020" #define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020"
#define ID_FILE "detid_gotthard2.txt"
#define CTRL_SRVR_INIT_TIME_US (300 * 1000) #define CTRL_SRVR_INIT_TIME_US (300 * 1000)

View File

@ -42,3 +42,4 @@ install(TARGETS mythen3DetectorServer_virtual
) )
configure_file(DefaultPattern_mythen3.txt ${CMAKE_BINARY_DIR}/bin/DefaultPattern_mythen3.txt COPYONLY) configure_file(DefaultPattern_mythen3.txt ${CMAKE_BINARY_DIR}/bin/DefaultPattern_mythen3.txt COPYONLY)
configure_file(detid_mythen3.txt ${CMAKE_BINARY_DIR}/bin/detid_mythen3.txt COPYONLY)

View File

@ -34,6 +34,7 @@ $(PROGS): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR) mv $(PROGS) $(DESTDIR)
cp DefaultPattern_mythen3.txt $(DESTDIR) cp DefaultPattern_mythen3.txt $(DESTDIR)
cp detid_mythen3.txt $(DESTDIR)
rm $(main_src)*.o rm $(main_src)*.o
clean: clean:

View File

@ -0,0 +1 @@
1234

View File

@ -274,28 +274,17 @@ u_int16_t getHardwareVersionNumber() {
MCB_SERIAL_NO_VRSN_OFST); MCB_SERIAL_NO_VRSN_OFST);
} }
void readDetectorNumber() { u_int32_t getDetectorNumber() {
#ifndef VIRTUAL #ifdef VIRTUAL
if (initError == FAIL) { return 0;
return;
}
FILE *fd = fopen(ID_FILE, "r");
if (fd == NULL) {
sprintf(initErrorMessage, "No %s file found.\n", ID_FILE);
LOG(logERROR, ("%s\n\n", initErrorMessage));
initError = FAIL;
return;
}
char output[255];
fgets(output, sizeof(output), fd);
sscanf(output, "%u", &detID);
if (isControlServer) {
LOG(logINFOBLUE, ("Detector ID: %u\n", detID));
}
#endif #endif
return bus_r(MCB_SERIAL_NO_REG);
} }
u_int32_t getDetectorNumber() { return detID; }
int getModuleId(int *ret, char *mess) {
return getModuleIdInFile(ret, mess, ID_FILE);
}
u_int64_t getDetectorMAC() { u_int64_t getDetectorMAC() {
#ifdef VIRTUAL #ifdef VIRTUAL
@ -455,6 +444,14 @@ void setupDetector() {
setASICDefaults(); setASICDefaults();
setADIFDefaults(); setADIFDefaults();
// set module id in register
getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
if (initError == FAIL) {
return;
}
// until firmware is done
// setModuleId(modid);
// set trigger flow for m3 (for all timing modes) // set trigger flow for m3 (for all timing modes)
bus_w(FLOW_TRIGGER_REG, bus_r(FLOW_TRIGGER_REG) | FLOW_TRIGGER_MSK); bus_w(FLOW_TRIGGER_REG, bus_r(FLOW_TRIGGER_REG) | FLOW_TRIGGER_MSK);
@ -481,7 +478,7 @@ void setupDetector() {
#ifdef VIRTUAL #ifdef VIRTUAL
enableTenGigabitEthernet(0); enableTenGigabitEthernet(0);
#endif #endif
readDetectorNumber(); getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
if (initError == FAIL) { if (initError == FAIL) {
return; return;
} }

View File

@ -28,3 +28,6 @@ void validate(int *ret, char *mess, int arg, int retval, char *modename,
enum numberMode nummode); enum numberMode nummode);
void validate64(int *ret, char *mess, int64_t arg, int64_t retval, void validate64(int *ret, char *mess, int64_t arg, int64_t retval,
char *modename, enum numberMode nummode); char *modename, enum numberMode nummode);
int getModuleIdInFile(int *ret, char *mess, char *fileName);
int setModuleIdInFile(char *mess, int arg, char *fileName);

View File

@ -90,14 +90,14 @@ u_int16_t getHardwareSerialNumber();
int isHardwareVersion2(); int isHardwareVersion2();
int getChipVersion(); int getChipVersion();
#endif #endif
#if defined(EIGERD) || defined(MYTHEN3D) #ifndef EIGERD
void readDetectorNumber();
#endif
u_int32_t getDetectorNumber(); u_int32_t getDetectorNumber();
#endif
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D)
int getModuleId(int *ret, char *mess);
#endif
#ifdef GOTTHARD2D #ifdef GOTTHARD2D
int getModuleId(); void setModuleId(int modid);
void setModuleId(int arg);
int getMaxModuleId();
#endif #endif
u_int64_t getDetectorMAC(); u_int64_t getDetectorMAC();
u_int32_t getDetectorIP(); u_int32_t getDetectorIP();

View File

@ -268,7 +268,6 @@ int get_adc_pipeline(int);
int set_dbit_pipeline(int); int set_dbit_pipeline(int);
int get_dbit_pipeline(int); int get_dbit_pipeline(int);
int get_module_id(int); int get_module_id(int);
int set_module_id(int);
int get_dest_udp_list(int); int get_dest_udp_list(int);
int set_dest_udp_list(int); int set_dest_udp_list(int);
int get_num_dest_list(int); int get_num_dest_list(int);

View File

@ -7,9 +7,6 @@
#include <string.h> #include <string.h>
#include <unistd.h> // readlink #include <unistd.h> // readlink
extern int ret;
extern char mess[MAX_STR_LENGTH];
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
int outputMax, int inputValue, int *outputValue) { int outputMax, int inputValue, int *outputValue) {
LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n", LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
@ -103,3 +100,81 @@ void validate64(int *ret, char *mess, int64_t arg, int64_t retval,
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} }
} }
int getModuleIdInFile(int *ret, char *mess, char *fileName) {
const int fileNameSize = 128;
char fname[fileNameSize];
if (getAbsPath(fname, fileNameSize, fileName) == FAIL) {
*ret = FAIL;
strcpy(mess, "Could not find detid file\n");
LOG(logERROR, ("%s\n\n", mess));
return -1;
}
// open id file
FILE *fd = fopen(fname, "r");
if (fd == NULL) {
*ret = FAIL;
strcpy(mess, "Could not find detid file\n");
LOG(logERROR, ("%s\n\n", mess));
return -1;
}
LOG(logDEBUG1, ("Reading det id file %s\n", fileName));
// read line
const size_t len = 256;
char line[len];
memset(line, 0, len);
if (NULL == fgets(line, len, fd)) {
*ret = FAIL;
strcpy(mess, "Could not find detid file\n");
LOG(logERROR, ("%s\n\n", mess));
return -1;
}
// read id
int retval = 0;
if (sscanf(line, "%x", &retval) != 1) {
*ret = FAIL;
sprintf(mess,
"Could not scan det id from on-board server "
"id file. Line:[%s].\n",
line);
LOG(logERROR, ("%s\n\n", mess));
return -1;
}
LOG(logINFOBLUE, ("Module Id: 0x%x (File)\n", retval));
return retval;
}
int setModuleIdInFile(char *mess, int arg, char *fileName) {
LOG(logINFOBLUE, ("Setting Module Id: 0x%x (File)\n", arg));
const int fileNameSize = 128;
char fname[fileNameSize];
if (getAbsPath(fname, fileNameSize, fileName) == FAIL) {
strcpy(mess, "Could not find detid file\n");
LOG(logERROR, (mess));
return FAIL;
}
// open id file
FILE *fd = fopen(fname, "r");
if (fd == NULL) {
strcpy(mess, "Could not find detid file\n");
LOG(logERROR, (mess));
return FAIL;
}
LOG(logDEBUG1, ("Writing det id to file %s\n", fileName));
// write id
const size_t len = 256;
char line[len];
memset(line, 0, len);
sprintf(line, "%x", arg);
if (EOF == fputs(line, fd)) {
strcpy(mess, "Could not write to detid file\n");
LOG(logERROR, (mess));
return FAIL;
}
return OK;
}

View File

@ -404,7 +404,6 @@ void function_table() {
flist[F_SET_DBIT_PIPELINE] = &set_dbit_pipeline; flist[F_SET_DBIT_PIPELINE] = &set_dbit_pipeline;
flist[F_GET_DBIT_PIPELINE] = &get_dbit_pipeline; flist[F_GET_DBIT_PIPELINE] = &get_dbit_pipeline;
flist[F_GET_MODULE_ID] = &get_module_id; flist[F_GET_MODULE_ID] = &get_module_id;
flist[F_SET_MODULE_ID] = &set_module_id;
flist[F_GET_DEST_UDP_LIST] = &get_dest_udp_list; flist[F_GET_DEST_UDP_LIST] = &get_dest_udp_list;
flist[F_SET_DEST_UDP_LIST] = &set_dest_udp_list; flist[F_SET_DEST_UDP_LIST] = &set_dest_udp_list;
flist[F_GET_NUM_DEST_UDP] = &get_num_dest_list; flist[F_GET_NUM_DEST_UDP] = &get_num_dest_list;
@ -684,8 +683,12 @@ int get_serial_number(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int64_t retval = -1; int64_t retval = -1;
#ifdef EIGERD
functionNotImplemented();
#else
retval = getDetectorNumber(); retval = getDetectorNumber();
LOG(logDEBUG1, ("detector number retval: 0x%llx\n", (long long int)retval)); LOG(logDEBUG1, ("detector number retval: 0x%llx\n", (long long int)retval));
#endif
return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
} }
@ -9016,40 +9019,13 @@ int get_module_id(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
int retval = -1; int retval = -1;
#ifndef GOTTHARD2D #if !(defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D))
functionNotImplemented(); functionNotImplemented();
#else #else
retval = getModuleId(); retval = getModuleId(&ret, mess);
#endif
LOG(logDEBUG1, ("module id retval: 0x%x\n", retval)); LOG(logDEBUG1, ("module id retval: 0x%x\n", retval));
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_module_id(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Setting module id to 0x%x\n", arg));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
if (arg > getMaxModuleId()) {
ret = FAIL;
sprintf(mess, "Could not set module id. Max value: 0x%x\n",
getMaxModuleId());
LOG(logERROR, (mess));
} else {
setModuleId(arg);
int retval = getModuleId();
LOG(logDEBUG1, ("retval module id: %d\n", retval));
validate(&ret, mess, arg, retval, "set module id", DEC);
}
#endif #endif
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
} }
int get_dest_udp_list(int file_des) { int get_dest_udp_list(int file_des) {

View File

@ -78,15 +78,12 @@ class Detector {
Result<int64_t> getDetectorServerVersion(Positions pos = {}) const; Result<int64_t> getDetectorServerVersion(Positions pos = {}) const;
/* [Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench] */
Result<int64_t> getSerialNumber(Positions pos = {}) const; Result<int64_t> getSerialNumber(Positions pos = {}) const;
/** [Gotthard2] */ /** [Eiger][Gotthard2][Mythen3] 6 bit value (ideally unique) that is streamed out in the UDP header of the detector.*/
Result<int> getModuleId(Positions pos = {}) const; Result<int> getModuleId(Positions pos = {}) const;
/** [Gotthard2] 6 bit value (ideally unique) that is "
"streamed out1 in the UDP header of the detector. Default is 0. */
void setModuleId(const int value, Positions pos = {});
Result<int64_t> getReceiverVersion(Positions pos = {}) const; Result<int64_t> getReceiverVersion(Positions pos = {}) const;
/** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2, /** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2,

View File

@ -1200,12 +1200,13 @@ class CmdProxy {
"\n\tReceiver version in format [0xYYMMDD]."); "\n\tReceiver version in format [0xYYMMDD].");
GET_COMMAND_HEX(serialnumber, getSerialNumber, GET_COMMAND_HEX(serialnumber, getSerialNumber,
"\n\tSerial number of detector."); "\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]"
"Serial number of detector.");
INTEGER_COMMAND_HEX( GET_COMMAND_HEX(
moduleid, getModuleId, setModuleId, StringTo<int>, moduleid, getModuleId,
"[value]\n\t[Gotthard2] 16 bit value (ideally unique) that is " "\n\t[Gotthard2][Eiger][Mythen3] 16 bit value (ideally unique) "
"streamed out in the UDP header of the detector. Default is 0."); "that is streamed out in the UDP header of the detector. Picked up from a file on the module.");
GET_COMMAND(type, getDetectorType, GET_COMMAND(type, getDetectorType,
"\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, " "\n\tReturns detector type. Can be Eiger, Jungfrau, Gotthard, "

View File

@ -123,10 +123,6 @@ Result<int> Detector::getModuleId(Positions pos) const {
return pimpl->Parallel(&Module::getModuleId, pos); return pimpl->Parallel(&Module::getModuleId, pos);
} }
void Detector::setModuleId(const int value, Positions pos) {
pimpl->Parallel(&Module::setModuleId, pos, value);
}
Result<int64_t> Detector::getReceiverVersion(Positions pos) const { Result<int64_t> Detector::getReceiverVersion(Positions pos) const {
return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos); return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos);
} }

View File

@ -25,8 +25,8 @@
namespace sls { namespace sls {
// creating new shm // creating new shm
Module::Module(detectorType type, int det_id, int module_id, bool verify) Module::Module(detectorType type, int det_id, int module_index, bool verify)
: moduleId(module_id), shm(det_id, module_id) { : moduleIndex(module_index), shm(det_id, module_index) {
// ensure shared memory was not created before // ensure shared memory was not created before
if (shm.IsExisting()) { if (shm.IsExisting()) {
@ -40,8 +40,8 @@ Module::Module(detectorType type, int det_id, int module_id, bool verify)
} }
// opening existing shm // opening existing shm
Module::Module(int det_id, int module_id, bool verify) Module::Module(int det_id, int module_index, bool verify)
: moduleId(module_id), shm(det_id, module_id) { : moduleIndex(module_index), shm(det_id, module_index) {
// getDetectorType From shm will check if existing // getDetectorType From shm will check if existing
detectorType type = getDetectorTypeFromShm(det_id, verify); detectorType type = getDetectorTypeFromShm(det_id, verify);
@ -96,10 +96,6 @@ int64_t Module::getSerialNumber() const {
int Module::getModuleId() const { return sendToDetector<int>(F_GET_MODULE_ID); } int Module::getModuleId() const { return sendToDetector<int>(F_GET_MODULE_ID); }
void Module::setModuleId(const int value) {
return sendToDetector(F_SET_MODULE_ID, value, nullptr);
}
int64_t Module::getReceiverSoftwareVersion() const { int64_t Module::getReceiverSoftwareVersion() const {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
return sendToReceiver<int64_t>(F_GET_RECEIVER_VERSION); return sendToReceiver<int64_t>(F_GET_RECEIVER_VERSION);
@ -142,7 +138,7 @@ slsDetectorDefs::xy Module::getNumberOfChannels() const {
void Module::updateNumberOfDetector(slsDetectorDefs::xy det) { void Module::updateNumberOfDetector(slsDetectorDefs::xy det) {
shm()->numberOfDetector = det; shm()->numberOfDetector = det;
int args[2] = {shm()->numberOfDetector.y, moduleId}; int args[2] = {shm()->numberOfDetector.y, moduleIndex};
sendToDetector(F_SET_POSITION, args, nullptr); sendToDetector(F_SET_POSITION, args, nullptr);
} }
@ -416,14 +412,14 @@ void Module::loadSettingsFile(const std::string &fname) {
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) { if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
std::ostringstream ostfn; std::ostringstream ostfn;
ostfn << fname; ostfn << fname;
int serialNumberWidth = 3; int moduleIdWidth = 3;
if (shm()->myDetectorType == MYTHEN3) { if (shm()->myDetectorType == MYTHEN3) {
serialNumberWidth = 4; moduleIdWidth = 4;
} }
if ((fname.find(".sn") == std::string::npos) && if ((fname.find(".sn") == std::string::npos) &&
(fname.find(".trim") == std::string::npos)) { (fname.find(".trim") == std::string::npos)) {
ostfn << ".sn" << std::setfill('0') << std::setw(serialNumberWidth) ostfn << ".sn" << std::setfill('0') << std::setw(moduleIdWidth)
<< std::dec << getSerialNumber(); << std::dec << getModuleId();
} }
auto myMod = readSettingsFile(ostfn.str()); auto myMod = readSettingsFile(ostfn.str());
setModule(myMod); setModule(myMod);
@ -823,13 +819,13 @@ std::vector<uint64_t> Module::getNumMissingPackets() const {
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort); auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_GET_NUM_MISSING_PACKETS); client.Send(F_GET_NUM_MISSING_PACKETS);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) + throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} else { } else {
auto nports = client.Receive<int>(); auto nports = client.Receive<int>();
std::vector<uint64_t> retval(nports); std::vector<uint64_t> retval(nports);
client.Receive(retval); client.Receive(retval);
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleId << ": " LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex << ": "
<< sls::ToString(retval); << sls::ToString(retval);
return retval; return retval;
} }
@ -997,7 +993,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU); sls::MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval); sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
LOG(logINFO) << "Setting destination udp mac of detector " << moduleId LOG(logINFO) << "Setting destination udp mac of detector " << moduleIndex
<< " to " << retval; << " to " << retval;
sendToDetector(F_SET_DEST_UDP_MAC, retval, nullptr); sendToDetector(F_SET_DEST_UDP_MAC, retval, nullptr);
} }
@ -1017,7 +1013,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU); sls::MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval); sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
LOG(logINFO) << "Setting destination udp mac2 of detector " << moduleId LOG(logINFO) << "Setting destination udp mac2 of detector " << moduleIndex
<< " to " << retval; << " to " << retval;
sendToDetector(F_SET_DEST_UDP_MAC2, retval, nullptr); sendToDetector(F_SET_DEST_UDP_MAC2, retval, nullptr);
} }
@ -1075,7 +1071,7 @@ void Module::validateUDPConfiguration() {
std::string Module::printReceiverConfiguration() { std::string Module::printReceiverConfiguration() {
std::ostringstream os; std::ostringstream os;
os << "\n\nDetector " << moduleId << "\nReceiver Hostname:\t" os << "\n\nDetector " << moduleIndex << "\nReceiver Hostname:\t"
<< getReceiverHostname(); << getReceiverHostname();
if (shm()->myDetectorType == JUNGFRAU) { if (shm()->myDetectorType == JUNGFRAU) {
@ -1189,7 +1185,7 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
retval.detType = shm()->myDetectorType; retval.detType = shm()->myDetectorType;
retval.numberOfDetector.x = shm()->numberOfDetector.x; retval.numberOfDetector.x = shm()->numberOfDetector.x;
retval.numberOfDetector.y = shm()->numberOfDetector.y; retval.numberOfDetector.y = shm()->numberOfDetector.y;
retval.moduleId = moduleId; retval.moduleIndex = moduleIndex;
memset(retval.hostname, 0, sizeof(retval.hostname)); memset(retval.hostname, 0, sizeof(retval.hostname));
strcpy_safe(retval.hostname, shm()->hostname); strcpy_safe(retval.hostname, shm()->hostname);
@ -1199,13 +1195,13 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
if (retval.udp_dstmac == 0 && retvals[0] != 0) { if (retval.udp_dstmac == 0 && retvals[0] != 0) {
LOG(logINFO) << "Setting destination udp mac of " LOG(logINFO) << "Setting destination udp mac of "
"detector " "detector "
<< moduleId << " to " << retvals[0]; << moduleIndex << " to " << retvals[0];
sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr); sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr);
} }
if (retval.udp_dstmac2 == 0 && retvals[1] != 0) { if (retval.udp_dstmac2 == 0 && retvals[1] != 0) {
LOG(logINFO) << "Setting destination udp mac2 of " LOG(logINFO) << "Setting destination udp mac2 of "
"detector " "detector "
<< moduleId << " to " << retvals[1]; << moduleIndex << " to " << retvals[1];
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr); sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
} }
@ -1521,7 +1517,7 @@ void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
receiver.Send(static_cast<int>(t.size())); receiver.Send(static_cast<int>(t.size()));
receiver.Send(t); receiver.Send(t);
if (receiver.Receive<int>() == FAIL) { if (receiver.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) + throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + receiver.readErrorMessage()); " returned error: " + receiver.readErrorMessage());
} }
} }
@ -1786,7 +1782,7 @@ void Module::sendVetoPhoton(const int chipIndex,
client.Send(gainIndices); client.Send(gainIndices);
client.Send(values); client.Send(values);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
} }
@ -1798,7 +1794,7 @@ void Module::getVetoPhoton(const int chipIndex,
client.Send(F_GET_VETO_PHOTON); client.Send(F_GET_VETO_PHOTON);
client.Send(chipIndex); client.Send(chipIndex);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
@ -2033,7 +2029,7 @@ void Module::getBadChannels(const std::string &fname) const {
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_GET_BAD_CHANNELS); client.Send(F_GET_BAD_CHANNELS);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
// receive badchannels // receive badchannels
@ -2090,7 +2086,7 @@ void Module::setBadChannels(const std::string &fname) {
client.Send(badchannels); client.Send(badchannels);
} }
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
} }
@ -2404,7 +2400,7 @@ std::map<std::string, std::string> Module::getAdditionalJsonHeader() const {
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort); auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
client.Send(F_GET_ADDITIONAL_JSON_HEADER); client.Send(F_GET_ADDITIONAL_JSON_HEADER);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) + throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} else { } else {
auto size = client.Receive<int>(); auto size = client.Receive<int>();
@ -2453,7 +2449,7 @@ void Module::setAdditionalJsonHeader(
client.Send(&buff[0], buff.size()); client.Send(&buff[0], buff.size());
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Receiver " + std::to_string(moduleId) + throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
} }
@ -3007,7 +3003,7 @@ slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
shm.OpenSharedMemory(); shm.OpenSharedMemory();
if (verify && shm()->shmversion != SLS_SHMVERSION) { if (verify && shm()->shmversion != SLS_SHMVERSION) {
std::ostringstream ss; std::ostringstream ss;
ss << "Single shared memory (" << det_id << "-" << moduleId ss << "Single shared memory (" << det_id << "-" << moduleIndex
<< ":)version mismatch (expected 0x" << std::hex << SLS_SHMVERSION << ":)version mismatch (expected 0x" << std::hex << SLS_SHMVERSION
<< " but got 0x" << shm()->shmversion << ")" << std::dec << " but got 0x" << shm()->shmversion << ")" << std::dec
<< ". Clear Shared memory to continue."; << ". Clear Shared memory to continue.";
@ -3018,7 +3014,7 @@ slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
} }
void Module::initSharedMemory(detectorType type, int det_id, bool verify) { void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
shm = SharedMemory<sharedSlsDetector>(det_id, moduleId); shm = SharedMemory<sharedSlsDetector>(det_id, moduleIndex);
if (!shm.IsExisting()) { if (!shm.IsExisting()) {
shm.CreateSharedMemory(); shm.CreateSharedMemory();
initializeDetectorStructure(type); initializeDetectorStructure(type);
@ -3026,7 +3022,7 @@ void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
shm.OpenSharedMemory(); shm.OpenSharedMemory();
if (verify && shm()->shmversion != SLS_SHMVERSION) { if (verify && shm()->shmversion != SLS_SHMVERSION) {
std::ostringstream ss; std::ostringstream ss;
ss << "Single shared memory (" << det_id << "-" << moduleId ss << "Single shared memory (" << det_id << "-" << moduleIndex
<< ":) version mismatch (expected 0x" << std::hex << ":) version mismatch (expected 0x" << std::hex
<< SLS_SHMVERSION << " but got 0x" << shm()->shmversion << ")" << SLS_SHMVERSION << " but got 0x" << shm()->shmversion << ")"
<< std::dec << ". Clear Shared memory to continue."; << std::dec << ". Clear Shared memory to continue.";
@ -3048,7 +3044,7 @@ void Module::initializeDetectorStructure(detectorType type) {
shm()->rxTCPPort = DEFAULT_PORTNO + 2; shm()->rxTCPPort = DEFAULT_PORTNO + 2;
shm()->useReceiverFlag = false; shm()->useReceiverFlag = false;
shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO + shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO +
(moduleId * ((shm()->myDetectorType == EIGER) ? 2 : 1)); (moduleIndex * ((shm()->myDetectorType == EIGER) ? 2 : 1));
shm()->zmqip = IpAddr{}; shm()->zmqip = IpAddr{};
shm()->numUDPInterfaces = 1; shm()->numUDPInterfaces = 1;
shm()->stoppedFlag = false; shm()->stoppedFlag = false;
@ -3161,7 +3157,7 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
client.Send(F_SET_MODULE); client.Send(F_SET_MODULE);
sendModule(&module, client); sendModule(&module, client);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
throw RuntimeError("Detector " + std::to_string(moduleId) + throw RuntimeError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage()); " returned error: " + client.readErrorMessage());
} }
} }
@ -3174,7 +3170,7 @@ void Module::updateReceiverStreamingIP() {
if (ip == 0) { if (ip == 0) {
ip = HostnameToIp(shm()->rxHostname); ip = HostnameToIp(shm()->rxHostname);
} }
LOG(logINFO) << "Setting default receiver " << moduleId LOG(logINFO) << "Setting default receiver " << moduleIndex
<< " streaming zmq ip to " << ip; << " streaming zmq ip to " << ip;
} }
setReceiverStreamingIP(ip); setReceiverStreamingIP(ip);
@ -3325,12 +3321,12 @@ std::string Module::getTrimbitFilename(detectorSettings s, int e_eV) {
throw RuntimeError( throw RuntimeError(
"Settings or trimbit files not defined for this detector."); "Settings or trimbit files not defined for this detector.");
} }
int serialNumberWidth = 3; int moduleIdWidth = 3;
if (shm()->myDetectorType == MYTHEN3) { if (shm()->myDetectorType == MYTHEN3) {
serialNumberWidth = 4; moduleIdWidth = 4;
} }
ostfn << std::setfill('0') << std::setw(serialNumberWidth) << std::dec ostfn << std::setfill('0') << std::setw(moduleIdWidth) << std::dec
<< getSerialNumber() << std::setbase(10); << getModuleId() << std::setbase(10);
return ostfn.str(); return ostfn.str();
} }
@ -3412,20 +3408,20 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
uint64_t filesize = buffer.size(); uint64_t filesize = buffer.size();
// send program from memory to detector // send program from memory to detector
LOG(logINFO) << "Sending programming binary (from pof) to detector " LOG(logINFO) << "Sending programming binary (from pof) to detector "
<< moduleId << " (" << shm()->hostname << ")"; << moduleIndex << " (" << shm()->hostname << ")";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_PROGRAM_FPGA); client.Send(F_PROGRAM_FPGA);
client.Send(filesize); client.Send(filesize);
// error in detector at opening file pointer to flash // error in detector at opening file pointer to flash
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
// erasing flash // erasing flash
LOG(logINFO) << "Erasing Flash for detector " << moduleId << " (" LOG(logINFO) << "Erasing Flash for detector " << moduleIndex << " ("
<< shm()->hostname << ")"; << shm()->hostname << ")";
printf("%d%%\r", 0); printf("%d%%\r", 0);
std::cout << std::flush; std::cout << std::flush;
@ -3443,7 +3439,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
std::cout << std::flush; std::cout << std::flush;
} }
printf("\n"); printf("\n");
LOG(logINFO) << "Writing to Flash to detector " << moduleId << " (" LOG(logINFO) << "Writing to Flash to detector " << moduleIndex << " ("
<< shm()->hostname << ")"; << shm()->hostname << ")";
printf("%d%%\r", 0); printf("%d%%\r", 0);
std::cout << std::flush; std::cout << std::flush;
@ -3464,7 +3460,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::cout << '\n'; std::cout << '\n';
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
@ -3483,7 +3479,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
// fpga has picked up from flash successfully // fpga has picked up from flash successfully
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
@ -3494,7 +3490,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
void Module::programFPGAviaNios(std::vector<char> buffer) { void Module::programFPGAviaNios(std::vector<char> buffer) {
LOG(logINFO) << "Sending programming binary (from rbf) to detector " LOG(logINFO) << "Sending programming binary (from rbf) to detector "
<< moduleId << " (" << shm()->hostname << ")"; << moduleIndex << " (" << shm()->hostname << ")";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_PROGRAM_FPGA); client.Send(F_PROGRAM_FPGA);
@ -3502,14 +3498,14 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
client.Send(filesize); client.Send(filesize);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }
client.Send(buffer); client.Send(buffer);
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleId << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
<< " returned error: " << client.readErrorMessage(); << " returned error: " << client.readErrorMessage();
throw RuntimeError(os.str()); throw RuntimeError(os.str());
} }

View File

@ -66,12 +66,12 @@ class Module : public virtual slsDetectorDefs {
/** creating new shared memory /** creating new shared memory
verify is if shared memory version matches existing one */ verify is if shared memory version matches existing one */
explicit Module(detectorType type, int det_id = 0, int module_id = 0, explicit Module(detectorType type, int det_id = 0, int module_index = 0,
bool verify = true); bool verify = true);
/** opening existing shared memory /** opening existing shared memory
verify is if shared memory version matches existing one */ verify is if shared memory version matches existing one */
explicit Module(int det_id = 0, int module_id = 0, bool verify = true); explicit Module(int det_id = 0, int module_index = 0, bool verify = true);
virtual ~Module(); virtual ~Module();
@ -91,7 +91,6 @@ class Module : public virtual slsDetectorDefs {
int64_t getDetectorServerVersion() const; int64_t getDetectorServerVersion() const;
int64_t getSerialNumber() const; int64_t getSerialNumber() const;
int getModuleId() const; int getModuleId() const;
void setModuleId(const int value);
int64_t getReceiverSoftwareVersion() const; int64_t getReceiverSoftwareVersion() const;
static detectorType getTypeFromDetector(const std::string &hostname, static detectorType getTypeFromDetector(const std::string &hostname,
int cport = DEFAULT_PORTNO); int cport = DEFAULT_PORTNO);
@ -747,7 +746,7 @@ class Module : public virtual slsDetectorDefs {
void programFPGAviaBlackfin(std::vector<char> buffer); void programFPGAviaBlackfin(std::vector<char> buffer);
void programFPGAviaNios(std::vector<char> buffer); void programFPGAviaNios(std::vector<char> buffer);
const int moduleId; const int moduleIndex;
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0}; mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
}; };

View File

@ -337,7 +337,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
int msize[2] = {arg.numberOfDetector.x, arg.numberOfDetector.y}; int msize[2] = {arg.numberOfDetector.x, arg.numberOfDetector.y};
impl()->setDetectorSize(msize); impl()->setDetectorSize(msize);
} }
impl()->setModulePositionId(arg.moduleId); impl()->setModulePositionId(arg.moduleIndex);
impl()->setDetectorHostname(arg.hostname); impl()->setDetectorHostname(arg.hostname);
// udp setup // udp setup

View File

@ -500,7 +500,7 @@ typedef struct {
struct rxParameters { struct rxParameters {
detectorType detType{GENERIC}; detectorType detType{GENERIC};
xy numberOfDetector; xy numberOfDetector;
int moduleId{0}; int moduleIndex{0};
char hostname[MAX_STR_LENGTH]; char hostname[MAX_STR_LENGTH];
int udpInterfaces{1}; int udpInterfaces{1};
int udp_dstport{0}; int udp_dstport{0};

View File

@ -244,7 +244,6 @@ enum detFuncs {
F_SET_DBIT_PIPELINE, F_SET_DBIT_PIPELINE,
F_GET_DBIT_PIPELINE, F_GET_DBIT_PIPELINE,
F_GET_MODULE_ID, F_GET_MODULE_ID,
F_SET_MODULE_ID,
F_GET_DEST_UDP_LIST, F_GET_DEST_UDP_LIST,
F_SET_DEST_UDP_LIST, F_SET_DEST_UDP_LIST,
F_GET_NUM_DEST_UDP, F_GET_NUM_DEST_UDP,
@ -602,7 +601,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_DBIT_PIPELINE: return "F_SET_DBIT_PIPELINE"; case F_SET_DBIT_PIPELINE: return "F_SET_DBIT_PIPELINE";
case F_GET_DBIT_PIPELINE: return "F_GET_DBIT_PIPELINE"; case F_GET_DBIT_PIPELINE: return "F_GET_DBIT_PIPELINE";
case F_GET_MODULE_ID: return "F_GET_MODULE_ID"; case F_GET_MODULE_ID: return "F_GET_MODULE_ID";
case F_SET_MODULE_ID: return "F_SET_MODULE_ID";
case F_GET_DEST_UDP_LIST: return "F_GET_DEST_UDP_LIST"; case F_GET_DEST_UDP_LIST: return "F_GET_DEST_UDP_LIST";
case F_SET_DEST_UDP_LIST: return "F_SET_DEST_UDP_LIST"; case F_SET_DEST_UDP_LIST: return "F_SET_DEST_UDP_LIST";
case F_GET_NUM_DEST_UDP: return "F_GET_NUM_DEST_UDP"; case F_GET_NUM_DEST_UDP: return "F_GET_NUM_DEST_UDP";

View File

@ -4,10 +4,11 @@
#define APIRECEIVER 0x210831 #define APIRECEIVER 0x210831
#define APIGUI 0x210819 #define APIGUI 0x210819
#define APICTB 0x210907
#define APIGOTTHARD 0x210907 #define APICTB 0x210909
#define APIGOTTHARD2 0x210907 #define APIGOTTHARD 0x210909
#define APIJUNGFRAU 0x210907 #define APIGOTTHARD2 0x210909
#define APIMYTHEN3 0x210907 #define APIJUNGFRAU 0x210909
#define APIMOENCH 0x210907 #define APIMYTHEN3 0x210909
#define APIEIGER 0x210907 #define APIMOENCH 0x210909
#define APIEIGER 0x210909

View File

@ -28,7 +28,7 @@ std::string ToString(const slsDetectorDefs::rxParameters &r) {
oss << '[' << "detType:" << r.detType << std::endl oss << '[' << "detType:" << r.detType << std::endl
<< "numberOfDetector.x:" << r.numberOfDetector.x << std::endl << "numberOfDetector.x:" << r.numberOfDetector.x << std::endl
<< "numberOfDetector.y:" << r.numberOfDetector.y << std::endl << "numberOfDetector.y:" << r.numberOfDetector.y << std::endl
<< "moduleId:" << r.moduleId << std::endl << "moduleIndex:" << r.moduleIndex << std::endl
<< "hostname:" << r.hostname << std::endl << "hostname:" << r.hostname << std::endl
<< "udpInterfaces:" << r.udpInterfaces << std::endl << "udpInterfaces:" << r.udpInterfaces << std::endl
<< "udp_dstport:" << r.udp_dstport << std::endl << "udp_dstport:" << r.udp_dstport << std::endl