mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
ctb adc fix, update detector fix, acq error fix
This commit is contained in:
parent
3f43767d38
commit
140996fae6
@ -1339,16 +1339,19 @@ int getADC(enum ADCINDEX ind){
|
|||||||
case V_PWR_B:
|
case V_PWR_B:
|
||||||
case V_PWR_C:
|
case V_PWR_C:
|
||||||
case V_PWR_D:
|
case V_PWR_D:
|
||||||
|
FILE_LOG(logDEBUG1, ("Reading I2C Voltage for device Id: %d\n", (int)ind));
|
||||||
return INA226_ReadVoltage(I2C_POWER_VIO_DEVICE_ID + (int)ind);
|
return INA226_ReadVoltage(I2C_POWER_VIO_DEVICE_ID + (int)ind);
|
||||||
case I_PWR_IO:
|
case I_PWR_IO:
|
||||||
case I_PWR_A:
|
case I_PWR_A:
|
||||||
case I_PWR_B:
|
case I_PWR_B:
|
||||||
case I_PWR_C:
|
case I_PWR_C:
|
||||||
case I_PWR_D:
|
case I_PWR_D:
|
||||||
|
FILE_LOG(logDEBUG1, ("Reading I2C Current for device Id: %d\n", (int)ind));
|
||||||
return INA226_ReadCurrent(I2C_POWER_VIO_DEVICE_ID + (int)(ind - I_PWR_IO));
|
return INA226_ReadCurrent(I2C_POWER_VIO_DEVICE_ID + (int)(ind - I_PWR_IO));
|
||||||
|
|
||||||
// slow adcs
|
// slow adcs
|
||||||
case SLOW_ADC_TEMP:
|
case SLOW_ADC_TEMP:
|
||||||
|
FILE_LOG(logDEBUG1, ("Reading Slow ADC Temperature\n"));
|
||||||
return AD7689_GetTemperature();
|
return AD7689_GetTemperature();
|
||||||
case SLOW_ADC0:
|
case SLOW_ADC0:
|
||||||
case SLOW_ADC1:
|
case SLOW_ADC1:
|
||||||
@ -1358,6 +1361,7 @@ int getADC(enum ADCINDEX ind){
|
|||||||
case SLOW_ADC5:
|
case SLOW_ADC5:
|
||||||
case SLOW_ADC6:
|
case SLOW_ADC6:
|
||||||
case SLOW_ADC7:
|
case SLOW_ADC7:
|
||||||
|
FILE_LOG(logDEBUG1, ("Reading Slow ADC Channel %d\n", (int)ind - SLOW_ADC0));
|
||||||
return AD7689_GetChannel((int)ind - SLOW_ADC0);
|
return AD7689_GetChannel((int)ind - SLOW_ADC0);
|
||||||
default:
|
default:
|
||||||
FILE_LOG(logERROR, ("Adc Index %d not defined \n", (int)ind));
|
FILE_LOG(logERROR, ("Adc Index %d not defined \n", (int)ind));
|
||||||
|
@ -990,6 +990,7 @@ int get_adc(int file_des) {
|
|||||||
default:
|
default:
|
||||||
#ifdef CHIPTESTBOARDD
|
#ifdef CHIPTESTBOARDD
|
||||||
if (ind >= SLOW_ADC0 && ind <= SLOW_ADC_TEMP) {
|
if (ind >= SLOW_ADC0 && ind <= SLOW_ADC_TEMP) {
|
||||||
|
serverAdcIndex = ind;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1001,7 +1002,7 @@ int get_adc(int file_des) {
|
|||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
FILE_LOG(logDEBUG1, ("Getting ADC %d\n", serverAdcIndex));
|
FILE_LOG(logDEBUG1, ("Getting ADC %d\n", serverAdcIndex));
|
||||||
retval = getADC(serverAdcIndex);
|
retval = getADC(serverAdcIndex);
|
||||||
FILE_LOG(logDEBUG1, ("ADC(%d): %d\n", retval));
|
FILE_LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1515,105 +1516,107 @@ int set_timer(int file_des) {
|
|||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
int64_t subexptime = 0;
|
int64_t subexptime = 0;
|
||||||
#endif
|
#endif
|
||||||
FILE_LOG(logDEBUG1, ("Setting timer %s(%d) to %lld ns\n", ind, timerName, tns));
|
FILE_LOG(logDEBUG1, ("Setting timer %s(%d) to %lld ns\n", timerName, (int)ind, tns));
|
||||||
|
|
||||||
// set & get
|
// set & get
|
||||||
if ((tns == -1) || (Server_VerifyLock() == OK)) {
|
if ((tns == -1) || (Server_VerifyLock() == OK)) {
|
||||||
|
|
||||||
// check index
|
// check index
|
||||||
switch (ind) {
|
switch (ind) {
|
||||||
case FRAME_NUMBER:
|
case FRAME_NUMBER:
|
||||||
#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
|
#if ((!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)))
|
||||||
case ACQUISITION_TIME:
|
case ACQUISITION_TIME:
|
||||||
#endif
|
#endif
|
||||||
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)
|
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||||
case DELAY_AFTER_TRIGGER:
|
case DELAY_AFTER_TRIGGER:
|
||||||
#endif
|
#endif
|
||||||
retval = setTimer(ind, tns);
|
retval = setTimer(ind, tns);
|
||||||
break;
|
break;
|
||||||
#ifdef JUNGFRAUD
|
#ifdef JUNGFRAUD
|
||||||
case STORAGE_CELL_NUMBER:
|
case STORAGE_CELL_NUMBER:
|
||||||
if (tns > MAX_STORAGE_CELL_VAL) {
|
if (tns > MAX_STORAGE_CELL_VAL) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
strcpy(mess,"Max Storage cell number should not exceed 15\n");
|
strcpy(mess,"Max Storage cell number should not exceed 15\n");
|
||||||
FILE_LOG(logERROR,(mess));
|
FILE_LOG(logERROR,(mess));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
retval = setTimer(ind,tns);
|
retval = setTimer(ind,tns);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
case SUBFRAME_ACQUISITION_TIME:
|
case SUBFRAME_ACQUISITION_TIME:
|
||||||
if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ) {
|
if (tns > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n");
|
strcpy(mess,"Sub Frame exposure time should not exceed 5.368 seconds\n");
|
||||||
FILE_LOG(logERROR,(mess));
|
FILE_LOG(logERROR,(mess));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
retval = setTimer(ind,tns);
|
retval = setTimer(ind,tns);
|
||||||
break;
|
break;
|
||||||
case SUBFRAME_DEADTIME:
|
case SUBFRAME_DEADTIME:
|
||||||
subexptime = setTimer(SUBFRAME_ACQUISITION_TIME, -1);
|
subexptime = setTimer(SUBFRAME_ACQUISITION_TIME, -1);
|
||||||
if ((tns + subexptime) > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ) {
|
if ((tns + subexptime) > ((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) ) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,"Sub Frame Period should not exceed 5.368 seconds. "
|
sprintf(mess,"Sub Frame Period should not exceed 5.368 seconds. "
|
||||||
"So sub frame dead time should not exceed %lfu seconds "
|
"So sub frame dead time should not exceed %lfu seconds "
|
||||||
"(subexptime = %lf seconds)\n",
|
"(subexptime = %lf seconds)\n",
|
||||||
((((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) - subexptime)/1E9),
|
((((int64_t)MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS*10) - subexptime)/1E9),
|
||||||
(subexptime/1E9));
|
(subexptime/1E9));
|
||||||
FILE_LOG(logERROR,(mess));
|
FILE_LOG(logERROR,(mess));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
retval = setTimer(ind,tns);
|
retval = setTimer(ind,tns);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
modeNotImplemented(timerName, (int)ind);
|
modeNotImplemented(timerName, (int)ind);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
char vtimerName[50] = {0};
|
if (ret != FAIL) {
|
||||||
sprintf(vtimerName, "set %s", timerName);
|
char vtimerName[50] = {0};
|
||||||
|
sprintf(vtimerName, "set %s", timerName);
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
validate64(tns, retval, vtimerName, DEC); // copied to server, not read from detector register
|
validate64(tns, retval, vtimerName, DEC); // copied to server, not read from detector register
|
||||||
#else
|
#else
|
||||||
switch(ind) {
|
switch(ind) {
|
||||||
case FRAME_NUMBER:
|
case FRAME_NUMBER:
|
||||||
case CYCLES_NUMBER:
|
case CYCLES_NUMBER:
|
||||||
case STORAGE_CELL_NUMBER:
|
case STORAGE_CELL_NUMBER:
|
||||||
validate64(tns, retval, vtimerName, DEC); // no conversion, so all good
|
validate64(tns, retval, vtimerName, DEC); // no conversion, so all good
|
||||||
break;
|
break;
|
||||||
case SAMPLES:
|
case SAMPLES:
|
||||||
if (retval == -1) {
|
if (retval == -1) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
retval = setTimer(ind, -1);
|
retval = setTimer(ind, -1);
|
||||||
sprintf(mess, "Could not set samples to %lld. Could not allocate RAM\n",
|
sprintf(mess, "Could not set samples to %lld. Could not allocate RAM\n",
|
||||||
(long long unsigned int)tns);
|
(long long unsigned int)tns);
|
||||||
FILE_LOG(logERROR,(mess));
|
FILE_LOG(logERROR,(mess));
|
||||||
} else
|
} else
|
||||||
validate64(tns, retval, vtimerName, DEC); // no conversion, so all good
|
validate64(tns, retval, vtimerName, DEC); // no conversion, so all good
|
||||||
case ACQUISITION_TIME:
|
case ACQUISITION_TIME:
|
||||||
case FRAME_PERIOD:
|
case FRAME_PERIOD:
|
||||||
case DELAY_AFTER_TRIGGER:
|
case DELAY_AFTER_TRIGGER:
|
||||||
case SUBFRAME_ACQUISITION_TIME:
|
case SUBFRAME_ACQUISITION_TIME:
|
||||||
case SUBFRAME_DEADTIME:
|
case SUBFRAME_DEADTIME:
|
||||||
// losing precision due to conversion to clock (also gotthard master delay is different)
|
// losing precision due to conversion to clock (also gotthard master delay is different)
|
||||||
if (validateTimer(ind, tns, retval) == FAIL) {
|
if (validateTimer(ind, tns, retval) == FAIL) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess, "Could not %s. Set %lld, but read %lld\n", vtimerName,
|
sprintf(mess, "Could not %s. Set %lld, but read %lld\n", vtimerName,
|
||||||
(long long unsigned int)tns, (long long unsigned int)retval);
|
(long long unsigned int)tns, (long long unsigned int)retval);
|
||||||
FILE_LOG(logERROR,(mess));
|
FILE_LOG(logERROR,(mess));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ret != FAIL) {
|
if (ret != FAIL) {
|
||||||
FILE_LOG(logDEBUG1, ("Timer index %d: %lld\n", ind, retval));
|
FILE_LOG(logDEBUG1, ("Timer index %d: %lld\n", ind, retval));
|
||||||
@ -2104,9 +2107,11 @@ 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
|
||||||
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();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
i64 = setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG);
|
i64 = setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG);
|
||||||
|
@ -1050,8 +1050,10 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
|
|||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.receiveData(&i64, sizeof(i64));
|
||||||
thisDetector->timerValue[FRAME_NUMBER] = i64;
|
thisDetector->timerValue[FRAME_NUMBER] = i64;
|
||||||
|
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
if (thisDetector->myDetectorType != CHIPTESTBOARD) {
|
||||||
thisDetector->timerValue[ACQUISITION_TIME] = i64;
|
n += client.receiveData(&i64, sizeof(i64));
|
||||||
|
thisDetector->timerValue[ACQUISITION_TIME] = i64;
|
||||||
|
}
|
||||||
|
|
||||||
if (thisDetector->myDetectorType == EIGER) {
|
if (thisDetector->myDetectorType == EIGER) {
|
||||||
n += client.receiveData(&i64, sizeof(i64));
|
n += client.receiveData(&i64, sizeof(i64));
|
||||||
|
@ -4006,66 +4006,12 @@ std::string slsDetectorCommand::cmdADC(int narg, char *args[], int action, int d
|
|||||||
else if (action == PUT_ACTION)
|
else if (action == PUT_ACTION)
|
||||||
return std::string("cannot set ") + cmd;
|
return std::string("cannot set ") + cmd;
|
||||||
|
|
||||||
if (sscanf(args[0], "adc:%d", &idac) == 1) {
|
|
||||||
// printf("chiptestboard!\n");
|
|
||||||
adc = (dacIndex)(idac + 1000);
|
|
||||||
} else if (cmd == "temp_adc")
|
|
||||||
adc = TEMPERATURE_ADC;
|
|
||||||
else if (cmd == "temp_fpga")
|
|
||||||
adc = TEMPERATURE_FPGA;
|
|
||||||
else if (cmd == "temp_fpgaext")
|
|
||||||
adc = TEMPERATURE_FPGAEXT;
|
|
||||||
else if (cmd == "temp_10ge")
|
|
||||||
adc = TEMPERATURE_10GE;
|
|
||||||
else if (cmd == "temp_dcdc")
|
|
||||||
adc = TEMPERATURE_DCDC;
|
|
||||||
else if (cmd == "temp_sodl")
|
|
||||||
adc = TEMPERATURE_SODL;
|
|
||||||
else if (cmd == "temp_sodr")
|
|
||||||
adc = TEMPERATURE_SODR;
|
|
||||||
else if (cmd == "temp_fpgafl")
|
|
||||||
adc = TEMPERATURE_FPGA2;
|
|
||||||
else if (cmd == "temp_fpgafr")
|
|
||||||
adc = TEMPERATURE_FPGA3;
|
|
||||||
else if (cmd == "i_a")
|
|
||||||
adc = I_POWER_A;
|
|
||||||
else if (cmd == "i_b")
|
|
||||||
adc = I_POWER_B;
|
|
||||||
else if (cmd == "i_c")
|
|
||||||
adc = I_POWER_C;
|
|
||||||
else if (cmd == "i_d")
|
|
||||||
adc = I_POWER_D;
|
|
||||||
else if (cmd == "vm_a")
|
|
||||||
adc = V_POWER_A;
|
|
||||||
else if (cmd == "vm_b")
|
|
||||||
adc = V_POWER_B;
|
|
||||||
else if (cmd == "vm_c")
|
|
||||||
adc = V_POWER_C;
|
|
||||||
else if (cmd == "vm_d")
|
|
||||||
adc = V_POWER_D;
|
|
||||||
else if (cmd == "vm_io")
|
|
||||||
adc = V_POWER_IO;
|
|
||||||
else if (cmd == "i_io")
|
|
||||||
adc = I_POWER_IO;
|
|
||||||
else
|
|
||||||
return std::string("cannot decode adc ") + cmd;
|
|
||||||
|
|
||||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
|
||||||
if (myDet->getDetectorTypeAsEnum(detPos) == EIGER || myDet->getDetectorTypeAsEnum(detPos) == JUNGFRAU) {
|
|
||||||
int val = myDet->getADC(adc, detPos);
|
|
||||||
if (val == -1)
|
|
||||||
sprintf(answer, "%d", val);
|
|
||||||
else
|
|
||||||
sprintf(answer, "%.2f", (double)val / 1000.000);
|
|
||||||
} else
|
|
||||||
sprintf(answer, "%d", myDet->getADC(adc, detPos));
|
|
||||||
|
|
||||||
if (sscanf(args[0],"adc:%d",&idac)==1) {
|
if (sscanf(args[0],"adc:%d",&idac)==1) {
|
||||||
// printf("chiptestboard!\n");
|
// printf("chiptestboard!\n");
|
||||||
adc=(dacIndex)(idac+1000);
|
adc=(dacIndex)(idac+SLOW_ADC0);
|
||||||
if (idac < (SLOW_ADC0 - 1000) || idac > (SLOW_ADC_TEMP - 1000))
|
if (idac < 0 || idac > SLOW_ADC_TEMP - SLOW_ADC0)
|
||||||
return (std::string ("cannot set adc, must be between ") + std::to_string(SLOW_ADC0 - 1000) +
|
return (std::string ("cannot set adc, must be between ") + std::to_string(0) +
|
||||||
std::string (" and ") + std::to_string(SLOW_ADC_TEMP - 1000));
|
std::string (" and ") + std::to_string(SLOW_ADC_TEMP - SLOW_ADC0));
|
||||||
} else if (cmd=="temp_adc")
|
} else if (cmd=="temp_adc")
|
||||||
adc=TEMPERATURE_ADC;
|
adc=TEMPERATURE_ADC;
|
||||||
else if (cmd=="temp_fpga")
|
else if (cmd=="temp_fpga")
|
||||||
@ -4118,7 +4064,7 @@ std::string slsDetectorCommand::cmdADC(int narg, char *args[], int action, int d
|
|||||||
else sprintf(answer,"%d",myDet->getADC(adc, detPos));
|
else sprintf(answer,"%d",myDet->getADC(adc, detPos));
|
||||||
|
|
||||||
//if ((adc == TEMPERATURE_ADC) || (adc == TEMPERATURE_FPGA))
|
//if ((adc == TEMPERATURE_ADC) || (adc == TEMPERATURE_FPGA))
|
||||||
if (adc<=100)
|
if (adc<=100 || adc == SLOW_ADC_TEMP)
|
||||||
strcat(answer,"°C");
|
strcat(answer,"°C");
|
||||||
else
|
else
|
||||||
strcat(answer,"mV");
|
strcat(answer,"mV");
|
||||||
|
@ -51,6 +51,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
|||||||
//get error message
|
//get error message
|
||||||
receiveData(mess, sizeof(mess));
|
receiveData(mess, sizeof(mess));
|
||||||
// cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
// cprintf(RED, "%s %d returned error: %s", type.c_str(), index, mess);
|
||||||
|
cprintf(RED, "returned error: %s", mess);
|
||||||
|
|
||||||
// unrecognized function, do not ask for retval
|
// unrecognized function, do not ask for retval
|
||||||
if (strstr(mess, "Unrecognized Function") != nullptr)
|
if (strstr(mess, "Unrecognized Function") != nullptr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user