ctb server bug fixes:update client, get period left, getid(api and serial number), restrict setting vchip, allow write adc

This commit is contained in:
2019-02-21 09:37:49 +01:00
parent 09546a8632
commit a4f1b7670f
3 changed files with 54 additions and 21 deletions

View File

@ -970,6 +970,11 @@ int64_t getTimeLeft(enum timerIndex ind){
FILE_LOG(logINFO, ("Getting number of frames left: %lld\n",(long long int)retval)); FILE_LOG(logINFO, ("Getting number of frames left: %lld\n",(long long int)retval));
break; break;
case FRAME_PERIOD:
retval = get64BitReg(PERIOD_LEFT_LSB_REG, PERIOD_LEFT_MSB_REG) / (1E-3 * clkDivider[ADC_CLK]);
FILE_LOG(logINFO, ("Getting period left: %lldns\n", (long long int)retval));
break;
case DELAY_AFTER_TRIGGER: case DELAY_AFTER_TRIGGER:
retval = get64BitReg(DELAY_LEFT_LSB_REG, DELAY_LEFT_MSB_REG) / (1E-3 * clkDivider[ADC_CLK]); retval = get64BitReg(DELAY_LEFT_LSB_REG, DELAY_LEFT_MSB_REG) / (1E-3 * clkDivider[ADC_CLK]);
FILE_LOG(logINFO, ("Getting delay left: %lldns\n", (long long int)retval)); FILE_LOG(logINFO, ("Getting delay left: %lldns\n", (long long int)retval));

View File

@ -501,7 +501,7 @@ int get_id(int file_des) {
// get // get
switch (arg) { switch (arg) {
#if defined(EIGERD) || defined(JUNGFRAUD) #ifndef GOTTHARDD
case SOFTWARE_FIRMWARE_API_VERSION: case SOFTWARE_FIRMWARE_API_VERSION:
case DETECTOR_SERIAL_NUMBER: case DETECTOR_SERIAL_NUMBER:
#endif #endif
@ -818,6 +818,10 @@ int set_dac(int file_des) {
case V_POWER_CHIP: case V_POWER_CHIP:
if (val >= 0) { if (val >= 0) {
ret = FAIL;
sprintf(mess,"Can not set Vchip. Can only be set automatically in the background (+200mV from highest power regulator voltage).\n");
FILE_LOG(logERROR,(mess));
/* restrict users from setting vchip
if (!mV) { if (!mV) {
ret = FAIL; ret = FAIL;
sprintf(mess,"Could not set Vchip. Should be in mV and not dac units.\n"); sprintf(mess,"Could not set Vchip. Should be in mV and not dac units.\n");
@ -829,6 +833,7 @@ int set_dac(int file_des) {
} else { } else {
setVchip(val); setVchip(val);
} }
*/
} }
retval = getVchip(); retval = getVchip();
FILE_LOG(logDEBUG1, ("Vchip: %d\n", retval)); FILE_LOG(logDEBUG1, ("Vchip: %d\n", retval));
@ -1551,7 +1556,7 @@ int set_timer(int file_des) {
case FRAME_PERIOD: case FRAME_PERIOD:
case CYCLES_NUMBER: case CYCLES_NUMBER:
case SAMPLES: case SAMPLES:
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) #ifndef EIGERD
case DELAY_AFTER_TRIGGER: case DELAY_AFTER_TRIGGER:
#endif #endif
retval = setTimer(ind, tns); retval = setTimer(ind, tns);
@ -1696,6 +1701,7 @@ int get_time_left(int file_des) {
case ACTUAL_TIME: case ACTUAL_TIME:
case MEASUREMENT_TIME: case MEASUREMENT_TIME:
case FRAME_NUMBER: case FRAME_NUMBER:
case FRAME_PERIOD:
case DELAY_AFTER_TRIGGER: case DELAY_AFTER_TRIGGER:
case CYCLES_NUMBER: case CYCLES_NUMBER:
#elif MOENCHD #elif MOENCHD
@ -1704,6 +1710,7 @@ int get_time_left(int file_des) {
case ACTUAL_TIME: case ACTUAL_TIME:
case MEASUREMENT_TIME: case MEASUREMENT_TIME:
case FRAME_NUMBER: case FRAME_NUMBER:
case FRAME_PERIOD:
case DELAY_AFTER_TRIGGER: case DELAY_AFTER_TRIGGER:
case CYCLES_NUMBER: case CYCLES_NUMBER:
#endif #endif
@ -1796,7 +1803,7 @@ int set_readout_flags(int file_des) {
return printSocketReadError(); return printSocketReadError();
FILE_LOG(logDEBUG1, ("Setting readout flags to %d\n", arg)); FILE_LOG(logDEBUG1, ("Setting readout flags to %d\n", arg));
#if (!defined(EIGERD)) && (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) #if defined(JUNGFRAUD) || defined(GOTTHARDD)
functionNotImplemented(); functionNotImplemented();
#else #else
// set & get // set & get
@ -1874,7 +1881,7 @@ int set_roi(int file_des) {
} }
} }
#if !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) #if defined(JUNGFRAUD) || defined(EIGERD)
functionNotImplemented(); functionNotImplemented();
#else #else
// set & get // set & get
@ -2120,9 +2127,11 @@ int send_update(int file_des) {
n = sendData(file_des,&i32,sizeof(i32),INT32); n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARDD)
i32 = (int)getSettings(); i32 = (int)getSettings();
n = sendData(file_des,&i32,sizeof(i32),INT32); n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
#endif
#ifdef EIGERD #ifdef EIGERD
i32 = getThresholdEnergy(GET_FLAG); i32 = getThresholdEnergy(GET_FLAG);
@ -2134,7 +2143,7 @@ int send_update(int file_des) {
n = sendData(file_des,&i64,sizeof(i64),INT64); n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
#ifndef CHIPTESTBOARDD #if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARDD)
i64 = setTimer(ACQUISITION_TIME,GET_FLAG); i64 = setTimer(ACQUISITION_TIME,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64); n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
@ -2164,16 +2173,18 @@ int send_update(int file_des) {
n = sendData(file_des,&i64,sizeof(i64),INT64); n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
#ifdef CHIPTESTBOARDD #if defined(EIGERD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
i64 = setTimer(SAMPLES,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
i32 = setReadOutFlags(GET_READOUT_FLAGS); i32 = setReadOutFlags(GET_READOUT_FLAGS);
n = sendData(file_des,&i32,sizeof(i32),INT32); n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
#endif #endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
i64 = setTimer(SAMPLES,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
#endif
if (lockStatus == 0) { if (lockStatus == 0) {
strcpy(lastClientIP,thisClientIP); strcpy(lastClientIP,thisClientIP);
} }
@ -2731,7 +2742,7 @@ int write_adc_register(int file_des) {
#ifndef VIRTUAL #ifndef VIRTUAL
// only set // only set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
#ifdef JUNGFRAUD #if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
AD9257_Set(addr, val); AD9257_Set(addr, val);
#elif GOTTHARDD #elif GOTTHARDD
if (getBoardRevision() == 1) { if (getBoardRevision() == 1) {
@ -2995,7 +3006,7 @@ int program_fpga(int file_des) {
ret = OK; ret = OK;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
#if (!defined(JUNGFRAUD)) && (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) #if defined(EIGERD) || defined(GOTTHARDD)
//to receive any arguments //to receive any arguments
int n = 1; int n = 1;
while (n > 0) while (n > 0)
@ -3121,7 +3132,7 @@ int reset_fpga(int file_des) {
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
FILE_LOG(logDEBUG1, ("Reset FPGA\n")); FILE_LOG(logDEBUG1, ("Reset FPGA\n"));
#if (!defined(JUNGFRAUD)) && (!defined(MOENCHD)) && (!defined(CHIPTESTBOARDD)) #if defined(EIGERD) || defined(GOTTHARDD)
functionNotImplemented(); functionNotImplemented();
#else #else
// only set // only set

View File

@ -1033,28 +1033,37 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
n += client.receiveData(lastClientIP, sizeof(lastClientIP)); n += client.receiveData(lastClientIP, sizeof(lastClientIP));
FILE_LOG(logDEBUG1) << "Updating detector last modified by " << lastClientIP; FILE_LOG(logDEBUG1) << "Updating detector last modified by " << lastClientIP;
// dr
n += client.receiveData(&i32, sizeof(i32)); n += client.receiveData(&i32, sizeof(i32));
thisDetector->dynamicRange = i32; thisDetector->dynamicRange = i32;
// databytes
n += client.receiveData(&i32, sizeof(i32)); n += client.receiveData(&i32, sizeof(i32));
thisDetector->dataBytes = i32; thisDetector->dataBytes = i32;
n += client.receiveData(&i32, sizeof(i32)); // settings
thisDetector->currentSettings = (detectorSettings)i32; if ((thisDetector->myDetectorType != CHIPTESTBOARD) && (thisDetector->myDetectorType != MOENCH)) {
n += client.receiveData(&i32, sizeof(i32));
thisDetector->currentSettings = (detectorSettings)i32;
}
// threshold
if (thisDetector->myDetectorType == EIGER) { if (thisDetector->myDetectorType == EIGER) {
n += client.receiveData(&i32, sizeof(i32)); n += client.receiveData(&i32, sizeof(i32));
thisDetector->currentThresholdEV = i32; thisDetector->currentThresholdEV = i32;
} }
// frame number
n += client.receiveData(&i64, sizeof(i64)); n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[FRAME_NUMBER] = i64; thisDetector->timerValue[FRAME_NUMBER] = i64;
if (thisDetector->myDetectorType != CHIPTESTBOARD) { // exptime
if ((thisDetector->myDetectorType != CHIPTESTBOARD) && (thisDetector->myDetectorType != MOENCH)) {
n += client.receiveData(&i64, sizeof(i64)); n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[ACQUISITION_TIME] = i64; thisDetector->timerValue[ACQUISITION_TIME] = i64;
} }
// subexptime, subdeadtime
if (thisDetector->myDetectorType == EIGER) { if (thisDetector->myDetectorType == EIGER) {
n += client.receiveData(&i64, sizeof(i64)); n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME] = i64; thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME] = i64;
@ -1063,29 +1072,37 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
thisDetector->timerValue[SUBFRAME_DEADTIME] = i64; thisDetector->timerValue[SUBFRAME_DEADTIME] = i64;
} }
// period
n += client.receiveData(&i64, sizeof(i64)); n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[FRAME_PERIOD] = i64; thisDetector->timerValue[FRAME_PERIOD] = i64;
// delay
if (thisDetector->myDetectorType != EIGER) { if (thisDetector->myDetectorType != EIGER) {
n += client.receiveData(&i64, sizeof(i64)); n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[DELAY_AFTER_TRIGGER] = i64; thisDetector->timerValue[DELAY_AFTER_TRIGGER] = i64;
} }
// cycles
n += client.receiveData(&i64, sizeof(i64)); n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[CYCLES_NUMBER] = i64; thisDetector->timerValue[CYCLES_NUMBER] = i64;
if (thisDetector->myDetectorType == CHIPTESTBOARD) { // readout flags
if (thisDetector->myDetectorType == EIGER ||
thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
n += client.receiveData(&i32, sizeof(i32));
thisDetector->roFlags = (readOutFlags)i32;
}
// samples
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
n += client.receiveData(&i64, sizeof(i64)); n += client.receiveData(&i64, sizeof(i64));
if (i64 >= 0) { if (i64 >= 0) {
thisDetector->timerValue[SAMPLES] = i64; thisDetector->timerValue[SAMPLES] = i64;
} }
n += client.receiveData(&i32, sizeof(i32));
thisDetector->roFlags = (readOutFlags)i32;
getTotalNumberOfChannels(); getTotalNumberOfChannels();
} }
if (!n) { if (!n) {
FILE_LOG(logERROR) << "Could not update detector, received 0 bytes"; FILE_LOG(logERROR) << "Could not update detector, received 0 bytes";
} }