Jungfraumaster (#518)

* set jungfrau master only from client
* added tests, fixed a bug in ctb and moench (infinite recursion) that will never happen atm
This commit is contained in:
Dhanya Thattil 2022-08-16 09:51:18 +02:00 committed by GitHub
parent 01696ca89b
commit 809b0bdeb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 111 additions and 56 deletions

View File

@ -89,6 +89,7 @@ This document describes the differences between v7.0.0 and v6.x.x
- rx udp socket refactored (maybe resolves getting stuck?)remove check for eiger header and isntead checks for malformed packets for every detector - rx udp socket refactored (maybe resolves getting stuck?)remove check for eiger header and isntead checks for malformed packets for every detector
- jungfrau sw trigger , blocking trigger - jungfrau sw trigger , blocking trigger
-help should not create a new object -help should not create a new object
- jungfrau master
- g2 parallel command - g2 parallel command
2. Resolved Issues 2. Resolved Issues

View File

@ -1479,8 +1479,8 @@ class Detector(CppDetectorApi):
@element @element
def master(self): def master(self):
""" """
[Eiger][Gotthard2] Sets (half) module to master and other(s) to slaves.\n [Eiger][Gotthard2][Jungfrau] Sets (half) module to master and other(s) to slaves.\n
[Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current (half) module is master. [Gotthard][Gotthard2][Mythen3][Eiger][Jungfrau] Gets if the current (half) module is master.
""" """
return self.getMaster() return self.getMaster()

View File

@ -2412,7 +2412,7 @@ int calculateDataBytes() { return dataBytes; }
int getTotalNumberOfChannels() { int getTotalNumberOfChannels() {
int nchanx = 0, nchany = 0; int nchanx = 0, nchany = 0;
getTotalNumberOfChannels(&nchanx, &nchany); getNumberOfChannels(&nchanx, &nchany);
return nchanx * nchany; return nchanx * nchany;
} }

View File

@ -228,6 +228,8 @@
#define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) // only PHY, not DDR3 PLL ,Not used in software #define CONTROL_DDR3_MEM_RST_MSK (0x00000001 << CONTROL_DDR3_MEM_RST_OFST) // only PHY, not DDR3 PLL ,Not used in software
#define CONTROL_ACQ_FIFO_CLR_OFST (14) #define CONTROL_ACQ_FIFO_CLR_OFST (14)
#define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST) #define CONTROL_ACQ_FIFO_CLR_MSK (0x00000001 << CONTROL_ACQ_FIFO_CLR_OFST)
#define CONTROL_MASTER_OFST (15)
#define CONTROL_MASTER_MSK (0x00000001 << CONTROL_MASTER_OFST)
#define CONTROL_STORAGE_CELL_NUM_OFST (16) #define CONTROL_STORAGE_CELL_NUM_OFST (16)
#define CONTROL_STORAGE_CELL_NUM_MSK (0x0000000F << CONTROL_STORAGE_CELL_NUM_OFST) #define CONTROL_STORAGE_CELL_NUM_MSK (0x0000000F << CONTROL_STORAGE_CELL_NUM_OFST)
#define CONTROL_RX_ADDTNL_ENDPTS_NUM_OFST (20) #define CONTROL_RX_ADDTNL_ENDPTS_NUM_OFST (20)

View File

@ -763,6 +763,15 @@ int readConfigFile() {
setChipVersion(version); setChipVersion(version);
} }
// other commands
else {
sprintf(initErrorMessage,
"Could not scan command from on-board server "
"config file. Line:[%s].\n",
line);
break;
}
memset(line, 0, LZ); memset(line, 0, LZ);
} }
fclose(fd); fclose(fd);
@ -1335,6 +1344,42 @@ int setHighVoltage(int val) {
/* parameters - timing, extsig */ /* parameters - timing, extsig */
int setMaster(enum MASTERINDEX m) {
char *master_names[] = {MASTER_NAMES};
LOG(logINFOBLUE, ("Setting up as %s in (%s server)\n", master_names[m],
(isControlServer ? "control" : "stop")));
int retval = -1;
switch (m) {
case OW_MASTER:
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_MASTER_MSK);
isMaster(&retval);
if (retval != 1) {
LOG(logERROR, ("Could not set master\n"));
return FAIL;
}
break;
case OW_SLAVE:
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_MASTER_MSK);
isMaster(&retval);
if (retval != 0) {
LOG(logERROR, ("Could not set slave\n"));
return FAIL;
}
break;
default:
LOG(logERROR, ("Cannot reset to hardware settings from client. Restart "
"detector server.\n"));
return FAIL;
}
return OK;
}
int isMaster(int *retval) {
*retval =
((bus_r(CONTROL_REG) & CONTROL_MASTER_MSK) >> CONTROL_MASTER_OFST);
return OK;
}
void setTiming(enum timingMode arg) { void setTiming(enum timingMode arg) {
switch (arg) { switch (arg) {
case AUTO_TIMING: case AUTO_TIMING:

View File

@ -67,6 +67,9 @@ enum DACINDEX {
420 /* J_VREF_COMP */ \ 420 /* J_VREF_COMP */ \
}; };
enum MASTERINDEX { MASTER_HARDWARE, OW_MASTER, OW_SLAVE };
#define MASTER_NAMES "hardware", "master", "slave"
#define NUMSETTINGS (2) #define NUMSETTINGS (2)
#define NSPECIALDACS (3) #define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP}; #define SPECIALDACINDEX {J_VREF_PRECH, J_VREF_DS, J_VREF_COMP};

View File

@ -2043,7 +2043,7 @@ int calculateDataBytes() { return dataBytes; }
int getTotalNumberOfChannels() { int getTotalNumberOfChannels() {
int nchanx = 0, nchany = 0; int nchanx = 0, nchany = 0;
getTotalNumberOfChannels(&nchanx, &nchany); getNumberOfChannels(&nchanx, &nchany);
return nchanx * nchany; return nchanx * nchany;
} }

View File

@ -385,7 +385,7 @@ int getADC(enum ADCINDEX ind);
int setHighVoltage(int val); int setHighVoltage(int val);
// parameters - timing, extsig // parameters - timing, extsig
#if defined(EIGERD) || defined(GOTTHARD2D) #if defined(EIGERD) || defined(GOTTHARD2D) || defined(JUNGFRAUD)
int setMaster(enum MASTERINDEX m); int setMaster(enum MASTERINDEX m);
#endif #endif
#ifdef EIGERD #ifdef EIGERD
@ -393,7 +393,7 @@ int setTop(enum TOPINDEX t);
int isTop(int *retval); int isTop(int *retval);
#endif #endif
#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) || \ #if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) || \
defined(GOTTHARD2D) defined(GOTTHARD2D) || defined(JUNGFRAUD)
int isMaster(int *retval); int isMaster(int *retval);
#endif #endif

View File

@ -215,8 +215,7 @@ int main(int argc, char *argv[]) {
break; break;
case 'm': case 'm':
#if (defined(MYTHEN3D) || defined(GOTTHARDD) || defined(GOTTHARD2D)) && \ #if !defined(VIRTUAL) && !defined(EIGERD)
!defined(VIRTUAL)
LOG(logERROR, ("Cannot set master via the detector server for this " LOG(logERROR, ("Cannot set master via the detector server for this "
"detector\n")); "detector\n"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View File

@ -1880,55 +1880,57 @@ int acquire(int blocking, int file_des) {
#ifdef EIGERD #ifdef EIGERD
// check for hardware mac and hardware ip // check for hardware mac and hardware ip
if (udpDetails[0].srcmac != getDetectorMAC()) { if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL; ret = FAIL;
uint64_t sourcemac = getDetectorMAC(); uint64_t sourcemac = getDetectorMAC();
char src_mac[MAC_ADDRESS_SIZE]; char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf(mess, sprintf(
mess,
"Invalid udp source mac address for this detector. Must be " "Invalid udp source mac address for this detector. Must be "
"same as hardware detector mac address %s\n", "same as hardware detector mac address %s\n",
src_mac); src_mac);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else if (!enableTenGigabitEthernet(GET_FLAG) && } else if (!enableTenGigabitEthernet(GET_FLAG) &&
(udpDetails[0].srcip != getDetectorIP())) { (udpDetails[0].srcip != getDetectorIP())) {
ret = FAIL; ret = FAIL;
uint32_t sourceip = getDetectorIP(); uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN]; char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip); getIpAddressinString(src_ip, sourceip);
sprintf(mess, sprintf(
mess,
"Invalid udp source ip address for this detector. Must be " "Invalid udp source ip address for this detector. Must be "
"same " "same "
"as hardware detector ip address %s in 1G readout mode \n", "as hardware detector ip address %s in 1G readout mode \n",
src_ip); src_ip);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else } else
#endif #endif
if (configured == FAIL) { if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess));
} else {
memset(scanErrMessage, 0, MAX_STR_LENGTH);
sharedMemory_setScanStop(0);
sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL; ret = FAIL;
strcpy(mess, "Could not start acquisition thread!\n"); strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else { } else {
// only does not wait for non blocking and scan memset(scanErrMessage, 0, MAX_STR_LENGTH);
if (blocking || !scan) { sharedMemory_setScanStop(0);
pthread_join(pthread_tid, NULL); sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL;
strcpy(mess, "Could not start acquisition thread!\n");
LOG(logERROR, (mess));
} else {
// only does not wait for non blocking and scan
if (blocking || !scan) {
pthread_join(pthread_tid, NULL);
}
} }
} }
}
} }
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
} }
@ -8234,7 +8236,7 @@ int get_master(int file_des) {
LOG(logDEBUG1, ("Getting master\n")); LOG(logDEBUG1, ("Getting master\n"));
#if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD) && \ #if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD) && \
!defined(GOTTHARD2D) !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented(); functionNotImplemented();
#else #else
ret = isMaster(&retval); ret = isMaster(&retval);
@ -8255,7 +8257,7 @@ int set_master(int file_des) {
return printSocketReadError(); return printSocketReadError();
LOG(logDEBUG1, ("Setting master: %u\n", (int)arg)); LOG(logDEBUG1, ("Setting master: %u\n", (int)arg));
#if !defined(EIGERD) && !defined(GOTTHARD2D) #if !defined(EIGERD) && !defined(GOTTHARD2D) && !defined(JUNGFRAUD)
functionNotImplemented(); functionNotImplemented();
#else #else
// only set // only set

View File

@ -1298,9 +1298,10 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID_GET( INTEGER_COMMAND_VEC_ID_GET(
master, getMaster, setMaster, StringTo<int>, master, getMaster, setMaster, StringTo<int>,
"[0, 1]\n\t[Eiger][Gotthard2] Sets (half) module to master and " "[0, 1]\n\t[Eiger][Gotthard2][Jungfrau] Sets (half) module to master "
"other(s) to slaves.\n\t[Gotthard][Gotthard2][Mythen3][Eiger] " "and other(s) to "
"Gets if the current (half) module is master."); "slaves.\n\t[Gotthard][Gotthard2][Mythen3][Eiger][Jungfrau] Gets if "
"the current (half) module is master.");
/* acquisition parameters */ /* acquisition parameters */

View File

@ -584,9 +584,11 @@ TEST_CASE("master", "[.cmd]") {
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 || if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) { det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2 ||
det_type == defs::JUNGFRAU) {
REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET)); REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET));
if (det_type == defs::EIGER || det_type == defs::GOTTHARD2) { if (det_type == defs::EIGER || det_type == defs::GOTTHARD2 ||
det_type == defs::JUNGFRAU) {
// get previous master // get previous master
int prevMaster = 0; int prevMaster = 0;
{ {

View File

@ -5,10 +5,10 @@
#define APILIB 0x220609 #define APILIB 0x220609
#define APIRECEIVER 0x220609 #define APIRECEIVER 0x220609
#define APIGUI 0x220609 #define APIGUI 0x220609
#define APICTB 0x220816 #define APICTB 0x220816
#define APIGOTTHARD 0x220816 #define APIGOTTHARD 0x220816
#define APIMYTHEN3 0x220816 #define APIMYTHEN3 0x220816
#define APIMOENCH 0x220816 #define APIMOENCH 0x220816
#define APIEIGER 0x220816 #define APIEIGER 0x220816
#define APIGOTTHARD2 0x220816 #define APIGOTTHARD2 0x220816
#define APIJUNGFRAU 0x220816 #define APIJUNGFRAU 0x220816