From 8939e236222e1e08b51f0bd1328beba22bbd2999 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 1 Mar 2019 15:26:38 +0100 Subject: [PATCH] jungfrau feature:storagecell_delay added --- .../jungfrauDetectorServer/RegisterDefs.h | 1 + .../jungfrauDetectorServer/gitInfo.txt | 8 +++--- .../jungfrauDetectorServer/gitInfoJungfrau.h | 6 ++--- .../slsDetectorFunctionList.c | 13 +++++++++ .../slsDetectorServer_defs.h | 2 ++ .../slsDetectorServer_funcs.c | 24 ++++++++++++++++- .../slsDetector/slsDetector.cpp | 10 +++++++ .../slsDetector/slsDetectorCommand.cpp | 27 ++++++++++++++++--- slsSupportLib/include/sls_detector_defs.h | 1 + 9 files changed, 81 insertions(+), 11 deletions(-) diff --git a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h index 1862e68ca..dfd19ed63 100644 --- a/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h @@ -411,6 +411,7 @@ #define ASIC_CTRL_DS_TMR_MSK (0x000000FF << ASIC_CTRL_DS_TMR_OFST) #define ASIC_CTRL_DS_TMR_VAL ((0x1F << ASIC_CTRL_DS_TMR_OFST) & ASIC_CTRL_DS_TMR_MSK) // tET = (ET + 1) * 25ns (increase timeout range between 2 consecutive storage cells) +#define ASIC_CTRL_EXPSRE_TMR_STEPS (25) #define ASIC_CTRL_EXPSRE_TMR_OFST (16) #define ASIC_CTRL_EXPSRE_TMR_MSK (0x0000FFFF << ASIC_CTRL_EXPSRE_TMR_OFST) diff --git a/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt b/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt index 47087a574..6a7478df2 100644 --- a/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt +++ b/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt @@ -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: 4b9e41e23b0671478ce0c9beae7a8342e9b2d204 -Revision: 23 +Repsitory UUID: 93192c6e84a34ad3416f99b95e58356b609f61c6 +Revision: 24 Branch: refactor Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4252 -Last Changed Date: 2019-01-15 10:22:16.000000002 +0100 ./RegisterDefs.h +Last Changed Rev: 4370 +Last Changed Date: 2019-03-01 15:23:53.000000002 +0100 ./RegisterDefs.h diff --git a/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h b/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h index c426ffd04..f505e414f 100644 --- a/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h +++ b/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "4b9e41e23b0671478ce0c9beae7a8342e9b2d204" +#define GITREPUUID "93192c6e84a34ad3416f99b95e58356b609f61c6" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4252 -#define GITDATE 0x20190115 +#define GITREV 0x4370 +#define GITDATE 0x20190301 #define GITBRANCH "refactor" diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index d0944e7ec..f7f689026 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -436,6 +436,7 @@ void setupDetector() { setTimer(FRAME_PERIOD, DEFAULT_PERIOD); setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY); setTimer(STORAGE_CELL_NUMBER, DEFAULT_NUM_STRG_CLLS); + setTimer(STORAGE_CELL_DELAY, DEFAULT_STRG_CLL_DLY); selectStoragecellStart(DEFAULT_STRG_CLL_STRT); /*setClockDivider(HALF_SPEED); depends if all the previous stuff works*/ setTiming(DEFAULT_TIMING_MODE); @@ -610,6 +611,18 @@ int64_t setTimer(enum timerIndex ind, int64_t val) { FILE_LOG(logDEBUG1, ("Getting #storage cells: %lld\n", (long long int)retval)); break; + case STORAGE_CELL_DELAY: + if(val >= 0){ + FILE_LOG(logINFO, ("Setting storage cell delay: %lldns\n", (long long int)val)); + val *= (1E-3 * CLK_RUN); + bus_w(ASIC_CTRL_REG, (bus_r(ASIC_CTRL_REG) & ~ASIC_CTRL_EXPSRE_TMR_MSK) | + ((val << ASIC_CTRL_EXPSRE_TMR_OFST) & ASIC_CTRL_EXPSRE_TMR_MSK)); + } + + retval = ((bus_r(ASIC_CTRL_REG) & ASIC_CTRL_EXPSRE_TMR_MSK) >> ASIC_CTRL_EXPSRE_TMR_OFST); + FILE_LOG(logDEBUG1, ("Getting storage cell delay: %lldns\n", (long long int)retval)); + break; + default: FILE_LOG(logERROR, ("Timer Index not implemented for this detector: %d\n", ind)); break; diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h index 9d829a0fa..73e14684c 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h @@ -65,6 +65,7 @@ enum NETWORKINDEX { TXN_FRAME }; #define DEFAULT_TMP_THRSHLD (65*1000) //milli degree Celsius #define DEFAULT_NUM_STRG_CLLS (0) #define DEFAULT_STRG_CLL_STRT (0xf) +#define DEFAULT_STRG_CLL_DLY (0) #define HIGHVOLTAGE_MIN (60) #define HIGHVOLTAGE_MAX (200) @@ -75,6 +76,7 @@ enum NETWORKINDEX { TXN_FRAME }; #define MAX_TIMESLOT_VAL (0x1F) #define MAX_THRESHOLD_TEMP_VAL (127999) //millidegrees #define MAX_STORAGE_CELL_VAL (15) //0xF +#define MAX_STORAGE_CELL_DLY_NS_VAL ((ASIC_CTRL_EXPSRE_TMR_MSK >> ASIC_CTRL_EXPSRE_TMR_OFST) * ASIC_CTRL_EXPSRE_TMR_STEPS) #define ACQ_TIME_MIN_CLOCK (2) #define SAMPLE_ADC_HALF_SPEED (SAMPLE_DECMT_FACTOR_2_VAL + SAMPLE_DGTL_SAMPLE_0_VAL + SAMPLE_ADC_DECMT_FACTOR_0_VAL + SAMPLE_ADC_SAMPLE_0_VAL) /* 0x1000 */ diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c index 50ae300e5..3c1601616 100755 --- a/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c @@ -128,10 +128,11 @@ const char* getTimerName(enum timerIndex ind) { case MEASUREMENTS_NUMBER: return "measurements_number"; case FRAMES_FROM_START: return "frames_from_start"; case FRAMES_FROM_START_PG: return "frames_from_start_pg"; - case SAMPLES: return "samples"; + case SAMPLES: return "samples"; case SUBFRAME_ACQUISITION_TIME: return "subframe_acquisition_time"; case SUBFRAME_DEADTIME: return "subframe_deadtime"; case STORAGE_CELL_NUMBER: return "storage_cell_number"; + case STORAGE_CELL_DELAY: return "storage_cell_delay"; default: return "unknown_timer"; } } @@ -1553,6 +1554,16 @@ int set_timer(int file_des) { } retval = setTimer(ind,tns); break; + + case STORAGE_CELL_DELAY: + if (tns > MAX_STORAGE_CELL_DLY_NS_VAL) { + ret = FAIL; + sprintf(mess,"Max Storage cell delay value should not exceed %d ns\n", MAX_STORAGE_CELL_DLY_NS_VAL); + FILE_LOG(logERROR,(mess)); + break; + } + retval = setTimer(ind,tns); + break; #endif #ifdef EIGERD case SUBFRAME_ACQUISITION_TIME: @@ -1611,6 +1622,7 @@ int set_timer(int file_des) { case DELAY_AFTER_TRIGGER: case SUBFRAME_ACQUISITION_TIME: case SUBFRAME_DEADTIME: + case STORAGE_CELL_DELAY: // losing precision due to conversion to clock (also gotthard master delay is different) if (validateTimer(ind, tns, retval) == FAIL) { ret = FAIL; @@ -2152,6 +2164,16 @@ int send_update(int file_des) { if (n < 0) return printSocketReadError(); #endif +#ifdef JUNGFRAUD + i64 = setTimer(STORAGE_CELL_NUMBER,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); + if (n < 0) return printSocketReadError(); + + i64 = setTimer(STORAGE_CELL_DELAY,GET_FLAG); + n = sendData(file_des,&i64,sizeof(i64),INT64); + if (n < 0) return printSocketReadError(); +#endif + i64 = setTimer(CYCLES_NUMBER,GET_FLAG); n = sendData(file_des,&i64,sizeof(i64),INT64); if (n < 0) return printSocketReadError(); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 57f857330..577218beb 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -1086,6 +1086,16 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) { thisDetector->timerValue[DELAY_AFTER_TRIGGER] = i64; } + if (thisDetector->myDetectorType == JUNGFRAU) { + // storage cell + n += client.receiveData(&i64, sizeof(i64)); + thisDetector->timerValue[STORAGE_CELL_NUMBER] = i64; + + // storage cell delay + n += client.receiveData(&i64, sizeof(i64)); + thisDetector->timerValue[STORAGE_CELL_DELAY] = i64; + } + // cycles n += client.receiveData(&i64, sizeof(i64)); thisDetector->timerValue[CYCLES_NUMBER] = i64; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index a25614f9a..226c3ab4b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -608,6 +608,20 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer; ++i; + /*! \page timing + - storagecell_start [i] sets/gets the storage cell that stores the first acquisition of the series. Default is 15(0xf).. For very advanced users only! For JUNGFRAU only. Range: 0-15. \c Returns \c (int) + */ + descrToFuncMap[i].m_pFuncName = "storagecell_start"; // + descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer; + ++i; + + /*! \page timing + - storagecell_delay [i] sets/gets additional time between 2 storage cells. For very advanced users only! For JUNGFRAU only. Range: 0-1638375 ns (resolution of 25ns). \c Returns \c (int) + */ + descrToFuncMap[i].m_pFuncName = "storagecell_delay"; // + descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer; + ++i; + /* read only timers */ /*! \page timing @@ -4299,6 +4313,8 @@ std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int index = SAMPLES; else if (cmd == "storagecells") index = STORAGE_CELL_NUMBER; + else if (cmd == "storagecell_delay") + index = STORAGE_CELL_DELAY; else if (cmd == "storagecell_start") { myDet->setOnline(ONLINE_FLAG, detPos); if (action == PUT_ACTION) { @@ -4317,9 +4333,11 @@ std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int ; //printf("value:%0.9lf\n",val); else return std::string("cannot scan timer value ") + std::string(args[1]); + + // timer if (index == ACQUISITION_TIME || index == SUBFRAME_ACQUISITION_TIME || index == FRAME_PERIOD || index == DELAY_AFTER_TRIGGER || - index == SUBFRAME_DEADTIME) { + index == SUBFRAME_DEADTIME || index == STORAGE_CELL_DELAY) { // +0.5 for precision of eg.0.0000325 t = (val * 1E9 + 0.5); } else @@ -4331,8 +4349,9 @@ std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int ret = myDet->setTimer(index, t, detPos); - if ((ret != -1) && (index == ACQUISITION_TIME || index == SUBFRAME_ACQUISITION_TIME || index == FRAME_PERIOD || index == DELAY_AFTER_TRIGGER || - index == SUBFRAME_DEADTIME)) { + if ((ret != -1) && (index == ACQUISITION_TIME || index == SUBFRAME_ACQUISITION_TIME || + index == FRAME_PERIOD || index == DELAY_AFTER_TRIGGER || + index == SUBFRAME_DEADTIME || index == STORAGE_CELL_DELAY)) { rval = (double)ret * 1E-9; sprintf(answer, "%0.9f", rval); } else @@ -4354,6 +4373,7 @@ std::string slsDetectorCommand::helpTimer(int action) { os << "samples t \t sets the number of samples expected from the jctb" << std::endl; os << "storagecells t \t sets number of storage cells per acquisition. For very advanced users only! For JUNGFRAU only. Range: 0-15. The #images = #frames * #cycles * (#storagecells+1)." << std::endl; os << "storagecell_start t \t sets the storage cell that stores the first acquisition of the series. Default is 15(0xf). For very advanced users only! For JUNGFRAU only. Range: 0-15." << std::endl; + os << "storagecell_delay t \t sets additional time to t between 2 storage cells. For very advanced users only! For JUNGFRAU only. Range: 0-1638375 ns (resolution of 25ns).. " << std::endl; os << "subdeadtime t \t sets sub frame dead time in s. Subperiod is set in the detector = subexptime + subdeadtime. This value is normally a constant in the config file. Used in EIGER only in 32 bit mode. " << std::endl; os << std::endl; } @@ -4368,6 +4388,7 @@ std::string slsDetectorCommand::helpTimer(int action) { os << "samples \t gets the number of samples expected from the jctb" << std::endl; os << "storagecells \t gets number of storage cells per acquisition.For JUNGFRAU only." << std::endl; os << "storagecell_start \t gets the storage cell that stores the first acquisition of the series." << std::endl; + os << "storagecell_delay \tgets additional time between 2 storage cells. " << std::endl; os << "subperiod \t gets sub frame dead time in s. Used in EIGER in 32 bit only." << std::endl; os << std::endl; } diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 45ebcdd75..e9175388b 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -123,6 +123,7 @@ public: SUBFRAME_DEADTIME, /**< subframe deadtime */ MEASURED_PERIOD, /**< measured period */ MEASURED_SUBPERIOD, /**< measured subperiod */ + STORAGE_CELL_DELAY, /**< storage cell delay */ MAX_TIMERS };