ctb and moench, exptime connects to set pattern wait time with level 0

This commit is contained in:
2019-03-06 15:17:54 +01:00
parent abc7a9bd2f
commit 0765b330f1
6 changed files with 62 additions and 33 deletions

View File

@ -544,6 +544,7 @@ void setupDetector() {
//Initialization of acquistion parameters
setTimer(SAMPLES, DEFAULT_NUM_SAMPLES); // update databytes and allocate ram
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
@ -909,6 +910,16 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
FILE_LOG(logINFO, ("\tGetting #frames: %lld\n", (long long int)retval));
break;
case ACQUISITION_TIME:
if(val >= 0){
FILE_LOG(logINFO, ("Setting exptime (pattern wait time level 0): %lldns\n",(long long int)val));
val *= (1E-3 * clkDivider[RUN_CLK]);
setPatternWaitTime(0, val);
}
retval = setPatternWaitTime(0, -1) / (1E-3 * clkDivider[RUN_CLK]);
FILE_LOG(logINFO, ("\tGetting exptime (pattern wait time level 0): %lldns\n", (long long int)retval));
break;
case FRAME_PERIOD:
if(val >= 0){
FILE_LOG(logINFO, ("Setting period: %lldns\n",(long long int)val));
@ -1022,11 +1033,18 @@ int validateTimer(enum timerIndex ind, int64_t val, int64_t retval) {
// convert back to timer
val = (val) / (1E-3 * clkDivider[ADC_CLK]);
if (val != retval) {
FILE_LOG(logERROR, ("Could not validate timer %d. Set %lld, got %lld\n",
(long long unsigned int)val, (long long unsigned int)retval));
return FAIL;
}
break;
case ACQUISITION_TIME:
// convert to freq
val *= (1E-3 * clkDivider[RUN_CLK]);
// convert back to timer
val = (val) / (1E-3 * clkDivider[RUN_CLK]);
if (val != retval) {
return FAIL;
}
break;
default:
break;
}

View File

@ -53,6 +53,7 @@ enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9,
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_NUM_SAMPLES (1)
#define DEFAULT_NUM_FRAMES (100 * 1000 * 1000)
#define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) //ns
#define DEFAULT_DELAY (0)

View File

@ -526,6 +526,7 @@ void setupDetector() {
//Initialization of acquistion parameters
setTimer(SAMPLES, DEFAULT_NUM_SAMPLES); // update databytes and allocate ram
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
setTimer(FRAME_PERIOD, DEFAULT_PERIOD);
setTimer(DELAY_AFTER_TRIGGER, DEFAULT_DELAY);
@ -837,19 +838,20 @@ int64_t setTimer(enum timerIndex ind, int64_t val) {
FILE_LOG(logINFO, ("\tGetting #frames: %lld\n", (long long int)retval));
break;
case ACQUISITION_TIME:
if(val >= 0){
FILE_LOG(logINFO, ("Setting exptime (pattern wait time level 0): %lldns\n",(long long int)val));
val *= (1E-3 * clkDivider[RUN_CLK]);
setPatternWaitTime(0, val);
}
retval = setPatternWaitTime(0, -1) / (1E-3 * clkDivider[RUN_CLK]);
FILE_LOG(logINFO, ("\tGetting exptime (pattern wait time level 0): %lldns\n", (long long int)retval));
break;
case FRAME_PERIOD:
if(val >= 0){
FILE_LOG(logINFO, ("Setting period: %lldns\n",(long long int)val));
val *= (1E-3 * clkDivider[ADC_CLK]);
// make period odd
//FIXME to be tested
/*if (val % 2 == 0) { //fIXME: period is even here, not other way round?
FILE_LOG(logINFO, ("\tPeriod %lld not even, adding 1\n", (long long int)val));
++val;
FILE_LOG(logINFO, ("\tNew Period:%lld\n", (long long int)val))
} else {
FILE_LOG(logINFO, ("\tPeriod already even:%lld\n", (long long int)val))
}*/
}
retval = set64BitReg(val, PERIOD_LSB_REG, PERIOD_MSB_REG )/ (1E-3 * clkDivider[ADC_CLK]);
FILE_LOG(logINFO, ("\tGetting period: %lldns\n", (long long int)retval));
@ -959,11 +961,18 @@ int validateTimer(enum timerIndex ind, int64_t val, int64_t retval) {
// convert back to timer
val = (val) / (1E-3 * clkDivider[ADC_CLK]);
if (val != retval) {
FILE_LOG(logERROR, ("Could not validate timer %d. Set %lld, got %lld\n",
(long long unsigned int)val, (long long unsigned int)retval));
return FAIL;
}
break;
case ACQUISITION_TIME:
// convert to freq
val *= (1E-3 * clkDivider[RUN_CLK]);
// convert back to timer
val = (val) / (1E-3 * clkDivider[RUN_CLK]);
if (val != retval) {
return FAIL;
}
break;
default:
break;
}
@ -971,6 +980,7 @@ int validateTimer(enum timerIndex ind, int64_t val, int64_t retval) {
}
/* parameters - settings */
enum detectorSettings getSettings() {
return UNDEFINED;

View File

@ -41,6 +41,7 @@ enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7};
/** Default Parameters */
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_NUM_SAMPLES (1)
#define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_FRAMES (100 * 1000 * 1000)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) //ns

View File

@ -1533,9 +1533,7 @@ int set_timer(int file_des) {
// check index
switch (ind) {
case FRAME_NUMBER:
#if ((!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)))
case ACQUISITION_TIME:
#endif
case FRAME_PERIOD:
case CYCLES_NUMBER:
case SAMPLES:
@ -2115,36 +2113,41 @@ int send_update(int file_des) {
n = sendData(file_des,lastClientIP,sizeof(lastClientIP),OTHER);
if (n < 0) return printSocketReadError();
// dr
i32 = setDynamicRange(GET_FLAG);
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
// databytes
i32 = calculateDataBytes();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
// settings
#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARDD)
i32 = (int)getSettings();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
// threshold energy
#ifdef EIGERD
i32 = getThresholdEnergy(GET_FLAG);
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
// #frames
i64 = setTimer(FRAME_NUMBER,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARDD)
// exptime
i64 = setTimer(ACQUISITION_TIME,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
#endif
// subexptime, subdeadtime
#ifdef EIGERD
i64 = setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
@ -2155,16 +2158,19 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError();
#endif
// period
i64 = setTimer(FRAME_PERIOD,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
// delay
#ifndef EIGERD
i64 = setTimer(DELAY_AFTER_TRIGGER,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
#endif
// #storage cell, storage_cell_delay
#ifdef JUNGFRAUD
i64 = setTimer(STORAGE_CELL_NUMBER,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
@ -2175,16 +2181,19 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError();
#endif
// #cycles
i64 = setTimer(CYCLES_NUMBER,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
// readout flags
#if defined(EIGERD) || defined(CHIPTESTBOARDD)
i32 = setReadOutFlags(GET_READOUT_FLAGS);
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
// #samples
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
i64 = setTimer(SAMPLES,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);

View File

@ -1062,10 +1062,8 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
thisDetector->timerValue[FRAME_NUMBER] = i64;
// exptime
if ((thisDetector->myDetectorType != CHIPTESTBOARD) && (thisDetector->myDetectorType != MOENCH)) {
n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[ACQUISITION_TIME] = i64;
}
n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[ACQUISITION_TIME] = i64;
// subexptime, subdeadtime
if (thisDetector->myDetectorType == EIGER) {
@ -2449,20 +2447,12 @@ std::string slsDetector::setReceiver(const std::string &receiverIP) {
overwriteFile(thisDetector->receiver_overWriteEnable);
setTimer(FRAME_PERIOD, thisDetector->timerValue[FRAME_PERIOD]);
setTimer(FRAME_NUMBER, thisDetector->timerValue[FRAME_NUMBER]);
setTimer(ACQUISITION_TIME, thisDetector->timerValue[ACQUISITION_TIME]);
// detector specific
switch(thisDetector->myDetectorType) {
case GOTTHARD:
setTimer(ACQUISITION_TIME, thisDetector->timerValue[ACQUISITION_TIME]);
break;
case JUNGFRAU:
setTimer(ACQUISITION_TIME, thisDetector->timerValue[ACQUISITION_TIME]);
break;
case EIGER:
setTimer(ACQUISITION_TIME, thisDetector->timerValue[ACQUISITION_TIME]);
setTimer(SUBFRAME_ACQUISITION_TIME, thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]);
setTimer(SUBFRAME_DEADTIME, thisDetector->timerValue[SUBFRAME_DEADTIME]);
setDynamicRange(thisDetector->dynamicRange);
@ -2472,19 +2462,19 @@ std::string slsDetector::setReceiver(const std::string &receiverIP) {
enableGapPixels(thisDetector->gappixels);
enableTenGigabitEthernet(thisDetector->tenGigaEnable);
setReadOutFlags(GET_READOUT_FLAGS);
break;
case CHIPTESTBOARD:
setTimer(SAMPLES, thisDetector->timerValue[SAMPLES]);
enableTenGigabitEthernet(thisDetector->tenGigaEnable);
setReadOutFlags(GET_READOUT_FLAGS);
break;
case MOENCH:
setTimer(SAMPLES, thisDetector->timerValue[SAMPLES]);
enableTenGigabitEthernet(thisDetector->tenGigaEnable);
break;
default:
break;
}