gotthard2: disentangled burst mode #frames, exptime, period from start of acquisition, order dependent now for debugging

This commit is contained in:
maliakal_d 2020-02-04 12:23:58 +01:00
parent c4559fadb3
commit d3dc9a7690
5 changed files with 52 additions and 101 deletions

View File

@ -47,9 +47,6 @@ int injectedChannelsIncrement = 0;
int vetoReference[NCHIP][NCHAN]; int vetoReference[NCHIP][NCHAN];
uint8_t adcConfiguration[NCHIP][NADC]; uint8_t adcConfiguration[NCHIP][NADC];
int burstMode = BURST_INTERNAL; int burstMode = BURST_INTERNAL;
int64_t exptime_ns = 0;
int64_t period_ns = 0;
int64_t nframes = 0;
int detPos[2] = {}; int detPos[2] = {};
int isInitCheckDone() { int isInitCheckDone() {
@ -353,9 +350,6 @@ void setupDetector() {
injectedChannelsOffset = 0; injectedChannelsOffset = 0;
injectedChannelsIncrement = 0; injectedChannelsIncrement = 0;
burstMode = BURST_INTERNAL; burstMode = BURST_INTERNAL;
exptime_ns = 0;
period_ns = 0;
nframes = 0;
{ {
int i, j; int i, j;
for (i = 0; i < NUM_CLOCKS; ++i) { for (i = 0; i < NUM_CLOCKS; ++i) {
@ -732,12 +726,23 @@ int setDynamicRange(int dr){
void setNumFrames(int64_t val) { void setNumFrames(int64_t val) {
if (val > 0) { if (val > 0) {
FILE_LOG(logINFO, ("Setting number of frames %lld [local]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting number of frames %lld [local]\n", (long long int)val));
nframes = val; // continuous mode
if (burstMode != BURST_OFF) {
setNumFramesCont(val);
setNumFramesBurst(1);
} else {
setNumFramesBurst(val);
setNumFramesCont(1);
}
} }
} }
int64_t getNumFrames() { int64_t getNumFrames() {
return nframes; if (burstMode != BURST_OFF) {
return getNumFramesCont();
} else {
return getNumFramesBurst();
}
} }
void setNumTriggers(int64_t val) { void setNumTriggers(int64_t val) {
@ -757,12 +762,16 @@ int setExpTime(int64_t val) {
return FAIL; return FAIL;
} }
FILE_LOG(logINFO, ("Setting exptime %lld ns [local]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting exptime %lld ns [local]\n", (long long int)val));
exptime_ns = val; // continuous mode
return OK; if (burstMode != BURST_OFF) {
return setExptimeCont(val);
} else {
return setExptimeBurst(val);
}
} }
int64_t getExpTime() { int64_t getExpTime() {
return exptime_ns; return getExptimeBoth();
} }
int setPeriod(int64_t val) { int setPeriod(int64_t val) {
@ -771,12 +780,22 @@ int setPeriod(int64_t val) {
return FAIL; return FAIL;
} }
FILE_LOG(logINFO, ("Setting period %lld ns [local]\n", (long long int)val)); FILE_LOG(logINFO, ("Setting period %lld ns [local]\n", (long long int)val));
period_ns = val; // continuous mode
return OK; if (burstMode != BURST_OFF) {
setPeriodBurst(0);
return setPeriodCont(val);
} else {
setPeriodCont(0);
return setPeriodBurst(val);
}
} }
int64_t getPeriod() { int64_t getPeriod() {
return period_ns; if (burstMode != BURST_OFF) {
return getPeriodCont();
} else {
return getPeriodBurst();
}
} }
void setNumFramesBurst(int64_t val) { void setNumFramesBurst(int64_t val) {
@ -1829,84 +1848,21 @@ enum burstMode getBurstMode() {
int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK; int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK;
switch (runmode) { switch (runmode) {
case ASIC_CONFIG_RUN_MODE_CONT_VAL: case ASIC_CONFIG_RUN_MODE_CONT_VAL:
return BURST_OFF; burstMode = BURST_OFF;
case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL: case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL:
return BURST_INTERNAL; burstMode = BURST_INTERNAL;
case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL: case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL:
return BURST_EXTERNAL; burstMode = BURST_EXTERNAL;
default: default:
FILE_LOG(logERROR, ("Unknown run mode read from FPGA %d\n", runmode)); FILE_LOG(logERROR, ("Unknown run mode read from FPGA %d\n", runmode));
return -1; return -1;
} }
return burstMode;
} }
/* aquisition */ /* aquisition */
int updateAcquisitionRegisters(char* mess) {
// burst mode
if (burstMode != BURST_OFF) {
// validate #frames in burst mode
if (nframes > MAX_FRAMES_IN_BURST_MODE) {
sprintf(mess, "Could not start acquisition because number of frames %lld must be <= %d in burst mode.\n", (long long unsigned int)nframes, MAX_FRAMES_IN_BURST_MODE);
FILE_LOG(logERROR,(mess));
return FAIL;
}
setNumFramesBurst(nframes);
// exptime
if (setExptimeBurst(exptime_ns) == FAIL) {
sprintf(mess, "Could not start acquisition because exptime could not be set in burst mode. Set %lld ns, got %lld ns.\n", (long long unsigned int)exptime_ns, getExptimeBoth());
FILE_LOG(logERROR,(mess));
return FAIL;
}
// period
if (setPeriodBurst(period_ns) == FAIL) {
sprintf(mess, "Could not start acquisition because period could not be set in burst mode. Set %lld ns, got %lld ns.\n", (long long unsigned int)period_ns, getPeriodBurst());
FILE_LOG(logERROR,(mess));
return FAIL;
}
// set continuous values to default (exptime same register)
FILE_LOG(logINFO, ("Setting continuous mode registers to defaults\n"));
// frames
setNumFramesCont(1);
// period
if (setPeriodCont(0) == FAIL) {
sprintf(mess, "Could not start acquisition because period could not be set in continuous mode. Set 0 ns, got %lld ns.\n", getPeriodCont());
FILE_LOG(logERROR,(mess));
return FAIL;
}
}
// continuous
else {
// frames
setNumFramesCont(nframes);
// exptime
if (setExptimeCont(exptime_ns) == FAIL) {
sprintf(mess, "Could not start acquisition because exptime could not be set in continuous mode. Set %lld ns, got %lld ns.\n", (long long unsigned int)exptime_ns, getExptimeBoth());
FILE_LOG(logERROR,(mess));
return FAIL;
}
// period
if (setPeriodCont(period_ns) == FAIL) {
sprintf(mess, "Could not start acquisition because period could not be set in continuous mode. Set %lld ns, got %lld ns.\n", (long long unsigned int)period_ns, getPeriodCont());
FILE_LOG(logERROR,(mess));
return FAIL;
}
// set burst values to default (exptime same register)
FILE_LOG(logINFO, ("Setting burst mode registers to defaults\n"));
setNumFramesBurst(1);
// period
if (setPeriodBurst(0) == FAIL) {
sprintf(mess, "Could not start acquisition because period could not be set in burst mode. Set 0 ns, got %lld ns.\n", getPeriodBurst());
FILE_LOG(logERROR,(mess));
return FAIL;
}
}
return OK;
}
int startStateMachine(){ int startStateMachine(){
#ifdef VIRTUAL #ifdef VIRTUAL
// create udp socket // create udp socket

View File

@ -508,9 +508,6 @@ int setTransmissionDelayRight(int value);
// aquisition // aquisition
#ifdef GOTTHARD2D
int updateAcquisitionRegisters(char* mess);
#endif
#ifdef EIGERD #ifdef EIGERD
int prepareAcquisition(); int prepareAcquisition();
#endif #endif

View File

@ -1769,12 +1769,6 @@ int start_acquisition(int file_des) {
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
} }
else else
#endif
#ifdef GOTTHARD2D
if (updateAcquisitionRegisters(mess) == FAIL) {
ret = FAIL;
}
else
#endif #endif
if (configured == FAIL) { if (configured == FAIL) {
ret = FAIL; ret = FAIL;
@ -1905,12 +1899,6 @@ int start_and_read_all(int file_des) {
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
} }
else else
#endif
#ifdef GOTTHARD2D
if (updateAcquisitionRegisters(mess) == FAIL) {
ret = FAIL;
}
else
#endif #endif
if (configured == FAIL) { if (configured == FAIL) {
ret = FAIL; ret = FAIL;
@ -1977,11 +1965,21 @@ int set_num_frames(int file_des) {
// only set // only set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
#ifdef GOTTHARD2D
// validate #frames in burst mode
if (getBurstMode() != BURST_OFF && arg > MAX_FRAMES_IN_BURST_MODE) {
ret = FAIL;
sprintf(mess, "Could not set number of frames %lld. Must be <= %d in burst mode.\n", (long long unsigned int)arg, MAX_FRAMES_IN_BURST_MODE);
FILE_LOG(logERROR,(mess));
}
#endif
if (ret == OK) {
setNumFrames(arg); setNumFrames(arg);
int64_t retval = getNumFrames(); int64_t retval = getNumFrames();
FILE_LOG(logDEBUG1, ("retval num frames %lld\n", (long long int)retval)); FILE_LOG(logDEBUG1, ("retval num frames %lld\n", (long long int)retval));
validate64(arg, retval, "set number of frames", DEC); validate64(arg, retval, "set number of frames", DEC);
} }
}
return Server_SendResult(file_des, INT64, UPDATE, NULL, 0); return Server_SendResult(file_des, INT64, UPDATE, NULL, 0);
} }

View File

@ -1011,7 +1011,7 @@ class CmdProxy {
INTEGER_COMMAND_NOID(frames, getNumberOfFrames, setNumberOfFrames, INTEGER_COMMAND_NOID(frames, getNumberOfFrames, setNumberOfFrames,
std::stol, std::stol,
"[n_frames]\n\tNumber of frames per aquire. In trigger mode, number of frames per trigger." "[n_frames]\n\tNumber of frames per aquire. In trigger mode, number of frames per trigger."
"\n\t[Gotthard2] Burst mode has a maximum of 2720 frames. Frames number for both modes are uploaded to detector just before acquisition starts"); "\n\t[Gotthard2] Burst mode has a maximum of 2720 frames.");
INTEGER_COMMAND_NOID(triggers, getNumberOfTriggers, setNumberOfTriggers, INTEGER_COMMAND_NOID(triggers, getNumberOfTriggers, setNumberOfTriggers,
std::stol, std::stol,