diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 3a37a967b..42fd78da8 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 9546086c8..e01dd8b4b 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -47,9 +47,6 @@ int injectedChannelsIncrement = 0; int vetoReference[NCHIP][NCHAN]; uint8_t adcConfiguration[NCHIP][NADC]; int burstMode = BURST_INTERNAL; -int64_t exptime_ns = 0; -int64_t period_ns = 0; -int64_t nframes = 0; int detPos[2] = {}; int isInitCheckDone() { @@ -353,9 +350,6 @@ void setupDetector() { injectedChannelsOffset = 0; injectedChannelsIncrement = 0; burstMode = BURST_INTERNAL; - exptime_ns = 0; - period_ns = 0; - nframes = 0; { int i, j; for (i = 0; i < NUM_CLOCKS; ++i) { @@ -732,12 +726,23 @@ int setDynamicRange(int dr){ void setNumFrames(int64_t val) { if (val > 0) { 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() { - return nframes; + if (burstMode != BURST_OFF) { + return getNumFramesCont(); + } else { + return getNumFramesBurst(); + } } void setNumTriggers(int64_t val) { @@ -757,12 +762,16 @@ int setExpTime(int64_t val) { return FAIL; } FILE_LOG(logINFO, ("Setting exptime %lld ns [local]\n", (long long int)val)); - exptime_ns = val; - return OK; + // continuous mode + if (burstMode != BURST_OFF) { + return setExptimeCont(val); + } else { + return setExptimeBurst(val); + } } int64_t getExpTime() { - return exptime_ns; + return getExptimeBoth(); } int setPeriod(int64_t val) { @@ -771,12 +780,22 @@ int setPeriod(int64_t val) { return FAIL; } FILE_LOG(logINFO, ("Setting period %lld ns [local]\n", (long long int)val)); - period_ns = val; - return OK; + // continuous mode + if (burstMode != BURST_OFF) { + setPeriodBurst(0); + return setPeriodCont(val); + } else { + setPeriodCont(0); + return setPeriodBurst(val); + } } int64_t getPeriod() { - return period_ns; + if (burstMode != BURST_OFF) { + return getPeriodCont(); + } else { + return getPeriodBurst(); + } } void setNumFramesBurst(int64_t val) { @@ -1829,84 +1848,21 @@ enum burstMode getBurstMode() { int runmode = bus_r (addr) & ASIC_CONFIG_RUN_MODE_MSK; switch (runmode) { case ASIC_CONFIG_RUN_MODE_CONT_VAL: - return BURST_OFF; + burstMode = BURST_OFF; case ASIC_CONFIG_RUN_MODE_INT_BURST_VAL: - return BURST_INTERNAL; + burstMode = BURST_INTERNAL; case ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL: - return BURST_EXTERNAL; + burstMode = BURST_EXTERNAL; default: FILE_LOG(logERROR, ("Unknown run mode read from FPGA %d\n", runmode)); return -1; } + return burstMode; } /* 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(){ #ifdef VIRTUAL // create udp socket diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 99e088789..44e5cb609 100755 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -508,9 +508,6 @@ int setTransmissionDelayRight(int value); // aquisition -#ifdef GOTTHARD2D -int updateAcquisitionRegisters(char* mess); -#endif #ifdef EIGERD int prepareAcquisition(); #endif diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index eca17f564..dbb16d36c 100755 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -1769,12 +1769,6 @@ int start_acquisition(int file_des) { FILE_LOG(logERROR,(mess)); } else -#endif -#ifdef GOTTHARD2D - if (updateAcquisitionRegisters(mess) == FAIL) { - ret = FAIL; - } - else #endif if (configured == FAIL) { ret = FAIL; @@ -1905,12 +1899,6 @@ int start_and_read_all(int file_des) { FILE_LOG(logERROR,(mess)); } else -#endif -#ifdef GOTTHARD2D - if (updateAcquisitionRegisters(mess) == FAIL) { - ret = FAIL; - } - else #endif if (configured == FAIL) { ret = FAIL; @@ -1977,10 +1965,20 @@ int set_num_frames(int file_des) { // only set if (Server_VerifyLock() == OK) { - setNumFrames(arg); - int64_t retval = getNumFrames(); - FILE_LOG(logDEBUG1, ("retval num frames %lld\n", (long long int)retval)); - validate64(arg, retval, "set number of frames", DEC); +#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); + int64_t retval = getNumFrames(); + FILE_LOG(logDEBUG1, ("retval num frames %lld\n", (long long int)retval)); + validate64(arg, retval, "set number of frames", DEC); + } } return Server_SendResult(file_des, INT64, UPDATE, NULL, 0); } diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 12a7d1c18..56e96984e 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1011,7 +1011,7 @@ class CmdProxy { INTEGER_COMMAND_NOID(frames, getNumberOfFrames, setNumberOfFrames, std::stol, "[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, std::stol,