ctb adc fix, update detector fix, acq error fix

This commit is contained in:
maliakal_d 2019-02-06 18:50:50 +01:00
parent 3f43767d38
commit 140996fae6
5 changed files with 103 additions and 145 deletions

View File

@ -1339,16 +1339,19 @@ int getADC(enum ADCINDEX ind){
case V_PWR_B:
case V_PWR_C:
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);
case I_PWR_IO:
case I_PWR_A:
case I_PWR_B:
case I_PWR_C:
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));
// slow adcs
case SLOW_ADC_TEMP:
FILE_LOG(logDEBUG1, ("Reading Slow ADC Temperature\n"));
return AD7689_GetTemperature();
case SLOW_ADC0:
case SLOW_ADC1:
@ -1358,6 +1361,7 @@ int getADC(enum ADCINDEX ind){
case SLOW_ADC5:
case SLOW_ADC6:
case SLOW_ADC7:
FILE_LOG(logDEBUG1, ("Reading Slow ADC Channel %d\n", (int)ind - SLOW_ADC0));
return AD7689_GetChannel((int)ind - SLOW_ADC0);
default:
FILE_LOG(logERROR, ("Adc Index %d not defined \n", (int)ind));

View File

@ -990,6 +990,7 @@ int get_adc(int file_des) {
default:
#ifdef CHIPTESTBOARDD
if (ind >= SLOW_ADC0 && ind <= SLOW_ADC_TEMP) {
serverAdcIndex = ind;
break;
}
#endif
@ -1001,7 +1002,7 @@ int get_adc(int file_des) {
if (ret == OK) {
FILE_LOG(logDEBUG1, ("Getting ADC %d\n", serverAdcIndex));
retval = getADC(serverAdcIndex);
FILE_LOG(logDEBUG1, ("ADC(%d): %d\n", retval));
FILE_LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval));
}
#endif
@ -1515,7 +1516,7 @@ int set_timer(int file_des) {
#ifdef EIGERD
int64_t subexptime = 0;
#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
if ((tns == -1) || (Server_VerifyLock() == OK)) {
@ -1523,7 +1524,7 @@ int set_timer(int file_des) {
// check index
switch (ind) {
case FRAME_NUMBER:
#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD)
#if ((!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)))
case ACQUISITION_TIME:
#endif
case FRAME_PERIOD:
@ -1576,6 +1577,7 @@ int set_timer(int file_des) {
}
// validate
if (ret != FAIL) {
char vtimerName[50] = {0};
sprintf(vtimerName, "set %s", timerName);
#ifdef EIGERD
@ -1615,6 +1617,7 @@ int set_timer(int file_des) {
}
#endif
}
}
if (ret != FAIL) {
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);
if (n < 0) return printSocketReadError();
#ifndef CHIPTESTBOARDD
i64 = setTimer(ACQUISITION_TIME,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
#endif
#ifdef EIGERD
i64 = setTimer(SUBFRAME_ACQUISITION_TIME,GET_FLAG);

View File

@ -1050,8 +1050,10 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[FRAME_NUMBER] = i64;
if (thisDetector->myDetectorType != CHIPTESTBOARD) {
n += client.receiveData(&i64, sizeof(i64));
thisDetector->timerValue[ACQUISITION_TIME] = i64;
}
if (thisDetector->myDetectorType == EIGER) {
n += client.receiveData(&i64, sizeof(i64));

View File

@ -4006,66 +4006,12 @@ std::string slsDetectorCommand::cmdADC(int narg, char *args[], int action, int d
else if (action == PUT_ACTION)
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) {
// printf("chiptestboard!\n");
adc=(dacIndex)(idac+1000);
if (idac < (SLOW_ADC0 - 1000) || idac > (SLOW_ADC_TEMP - 1000))
return (std::string ("cannot set adc, must be between ") + std::to_string(SLOW_ADC0 - 1000) +
std::string (" and ") + std::to_string(SLOW_ADC_TEMP - 1000));
adc=(dacIndex)(idac+SLOW_ADC0);
if (idac < 0 || idac > SLOW_ADC_TEMP - SLOW_ADC0)
return (std::string ("cannot set adc, must be between ") + std::to_string(0) +
std::string (" and ") + std::to_string(SLOW_ADC_TEMP - SLOW_ADC0));
} else if (cmd=="temp_adc")
adc=TEMPERATURE_ADC;
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));
//if ((adc == TEMPERATURE_ADC) || (adc == TEMPERATURE_FPGA))
if (adc<=100)
if (adc<=100 || adc == SLOW_ADC_TEMP)
strcat(answer,"°C");
else
strcat(answer,"mV");

View File

@ -51,6 +51,7 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
//get error message
receiveData(mess, sizeof(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
if (strstr(mess, "Unrecognized Function") != nullptr)