mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
default dacs done
This commit is contained in:
parent
0665209389
commit
a9663abc50
@ -93,7 +93,7 @@ int eiger_virtual_interrupt_subframe = 0;
|
||||
int eiger_virtual_left_datastream = 1;
|
||||
int eiger_virtual_right_datastream = 1;
|
||||
#endif
|
||||
int defaultDacVals[NDAC] = DEFAULT_DAC_VALS;
|
||||
int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
|
||||
|
||||
int isInitCheckDone() { return initCheckDone; }
|
||||
|
||||
@ -752,11 +752,11 @@ int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultDacVals[i], 0);
|
||||
if ((detectorModules)->dacs[i] != defaultDacVals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||
if ((detectorModules)->dacs[i] != defaultDacValues[i]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultDacVals[i], (detectorModules)->dacs[i]));
|
||||
defaultDacValues[i], (detectorModules)->dacs[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -767,9 +767,9 @@ int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
||||
if (sett != UNDEFINED) {
|
||||
return FAIL;
|
||||
}
|
||||
if (index < E_VSVP || index > E_VISHAPER)
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
*retval = defaultDacVals[index];
|
||||
*retval = defaultDacValues[index];
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -777,9 +777,13 @@ int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) {
|
||||
if (sett != UNDEFINED) {
|
||||
return FAIL;
|
||||
}
|
||||
if (index < E_VSVP || index > E_VISHAPER)
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
defaultDacVals[index] = value;
|
||||
|
||||
char *dac_names[] = {DAC_NAMES};
|
||||
LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index,
|
||||
dac_names[index], value));
|
||||
defaultDacValues[index] = value;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1017,8 +1021,8 @@ int64_t getSubExpTime() {
|
||||
}
|
||||
|
||||
int setSubDeadTime(int64_t val) {
|
||||
logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
||||
#ifndef TUAL
|
||||
LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
sharedMemory_lockLocalLink();
|
||||
// get subexptime
|
||||
int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
|
||||
|
@ -515,6 +515,31 @@ int setDefaultDacs() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
||||
int *retval) {
|
||||
if (sett != UNDEFINED) {
|
||||
return FAIL;
|
||||
}
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
*retval = defaultDacValues[index];
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) {
|
||||
if (sett != UNDEFINED) {
|
||||
return FAIL;
|
||||
}
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
|
||||
char *dac_names[] = {DAC_NAMES};
|
||||
LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index,
|
||||
dac_names[index], value));
|
||||
defaultDacValues[index] = value;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int readConfigFile() {
|
||||
|
||||
if (initError == FAIL) {
|
||||
|
@ -45,6 +45,7 @@ int detPos[2] = {};
|
||||
|
||||
int detectorFirstServer = 1;
|
||||
int dacValues[NDAC] = {};
|
||||
int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
|
||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||
enum externalSignalFlag signalMode = 0;
|
||||
|
||||
@ -436,18 +437,42 @@ void setupDetector() {
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||
if (dacValues[i] != defaultDacValues[i]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], dacValues[i]));
|
||||
defaultDacValues[i], dacValues[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
||||
int *retval) {
|
||||
if (sett != UNDEFINED) {
|
||||
return FAIL;
|
||||
}
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
*retval = defaultDacValues[index];
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) {
|
||||
if (sett != UNDEFINED) {
|
||||
return FAIL;
|
||||
}
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
|
||||
char *dac_names[] = {DAC_NAMES};
|
||||
LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index,
|
||||
dac_names[index], value));
|
||||
defaultDacValues[index] = value;
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t writeRegister16And32(uint32_t offset, uint32_t data) {
|
||||
if (((offset << MEM_MAP_SHIFT) == CONTROL_REG) ||
|
||||
((offset << MEM_MAP_SHIFT) == FIFO_DATA_REG)) {
|
||||
|
@ -43,6 +43,9 @@ int virtual_image_test_mode = 0;
|
||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||
int highvoltage = 0;
|
||||
int dacValues[NDAC] = {};
|
||||
int defaultDacValues[] = DEFAULT_DAC_VALS;
|
||||
int defaultDacValue_G0[] = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
|
||||
int defaultDacValue_HG0[] = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
|
||||
int32_t clkPhase[NUM_CLOCKS] = {};
|
||||
int detPos[4] = {};
|
||||
int chipVersion = 10; // (1.0)
|
||||
@ -470,18 +473,88 @@ void setupDetector() {
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||
if (dacValues[i] != defaultDacValues[i]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], dacValues[i]));
|
||||
defaultDacValues[i], dacValues[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
||||
int *retval) {
|
||||
|
||||
// settings only for special dacs
|
||||
if (sett != UNDEFINED) {
|
||||
const int specialDacs[] = SPECIALDACINDEX;
|
||||
// find special dac index
|
||||
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||
if ((int)index == specialDacs[i]) {
|
||||
switch (sett) {
|
||||
case DYNAMICGAIN:
|
||||
*retval = defaultDacValue_G0[i];
|
||||
return OK;
|
||||
case DYNAMICHG0:
|
||||
*retval = defaultDacValue_HG0[i];
|
||||
return OK;
|
||||
// unknown settings
|
||||
default:
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// not a special dac
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
*retval = defaultDacValues[index];
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) {
|
||||
char *dac_names[] = {DAC_NAMES};
|
||||
|
||||
// settings only for special dacs
|
||||
if (sett != UNDEFINED) {
|
||||
const int specialDacs[] = SPECIALDACINDEX;
|
||||
// find special dac index
|
||||
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||
if ((int)index == specialDacs[i]) {
|
||||
switch (sett) {
|
||||
case DYNAMICGAIN:
|
||||
LOG(logINFO,
|
||||
("Setting Default Dac [%d - %s, dynamicgain]: %d\n",
|
||||
(int)index, dac_names[index], value));
|
||||
defaultDacValue_G0[i] = value;
|
||||
return OK;
|
||||
case DYNAMICHG0:
|
||||
LOG(logINFO,
|
||||
("Setting Default Dac [%d - %s, dynamichg0]: %d\n",
|
||||
(int)index, dac_names[index], value));
|
||||
defaultDacValue_HG0[i] = value;
|
||||
return OK;
|
||||
// unknown settings
|
||||
default:
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// not a special dac
|
||||
return FAIL;
|
||||
}
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index,
|
||||
dac_names[index], value));
|
||||
defaultDacValues[index] = value;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int readConfigFile() {
|
||||
|
||||
if (initError == FAIL) {
|
||||
@ -884,8 +957,6 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
if (sett == UNINITIALIZED)
|
||||
return thisSettings;
|
||||
|
||||
int G0DacVals[] = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
|
||||
int HG0DacVals[] = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
|
||||
int *dacVals = NULL;
|
||||
// set settings
|
||||
switch (sett) {
|
||||
@ -893,14 +964,14 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
LOG(logINFO,
|
||||
("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
|
||||
dacVals = G0DacVals;
|
||||
dacVals = defaultDacValue_G0;
|
||||
break;
|
||||
case DYNAMICHG0:
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL);
|
||||
LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n",
|
||||
bus_r(DAQ_REG)));
|
||||
dacVals = HG0DacVals;
|
||||
dacVals = defaultDacValue_HG0;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
@ -927,26 +998,25 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
void validateSettings() {
|
||||
// if any special dac value is changed individually => undefined
|
||||
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||
int specialDacValues[NUMSETTINGS][NSPECIALDACS] = {
|
||||
SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS,
|
||||
SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS};
|
||||
int settList[NUMSETTINGS] = {DYNAMICGAIN, DYNAMICHG0};
|
||||
int *specialDacValues[] = {defaultDacValue_G0, defaultDacValue_HG0};
|
||||
int settList[NUMSETTINGS] = {DYNAMICGAIN, DYNAMICHG0};
|
||||
enum detectorSettings sett = UNDEFINED;
|
||||
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
||||
|
||||
enum detectorSettings sett = UNDEFINED;
|
||||
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
||||
// dont overwrite if settings is correct
|
||||
if (sett != UNDEFINED) {
|
||||
break;
|
||||
}
|
||||
// assume it matches current setting in list
|
||||
sett = settList[isett];
|
||||
for (int ival = 0; ival < NSPECIALDACS; ++ival) {
|
||||
// if one value does not match, undefined
|
||||
if (getDAC(specialDacs[ival], 0) != specialDacValues[isett][ival]) {
|
||||
sett = UNDEFINED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// assume it matches current setting in list
|
||||
sett = settList[isett];
|
||||
// if one value does not match, = undefined
|
||||
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||
if (getDAC(specialDacs[i], 0) != specialDacValues[isett][i]) {
|
||||
sett = UNDEFINED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// all values matchd a setting
|
||||
if (sett != UNDEFINED) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// update settings
|
||||
if (thisSettings != sett) {
|
||||
|
@ -61,6 +61,7 @@ uint8_t adcEnableMask_10g = 0;
|
||||
int32_t clkPhase[NUM_CLOCKS] = {};
|
||||
uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200};
|
||||
int dacValues[NDAC] = {};
|
||||
int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
|
||||
// software limit that depends on the current chip on the ctb
|
||||
int vLimit = 0;
|
||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||
@ -616,17 +617,40 @@ void updateDataBytes() {
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if (dacValues[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||
if (dacValues[i] != defaultDacValues[i]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], dacValues[i]));
|
||||
defaultDacValues[i], dacValues[i]));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
||||
int *retval) {
|
||||
if (sett != UNDEFINED) {
|
||||
return FAIL;
|
||||
}
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
*retval = defaultDacValues[index];
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) {
|
||||
if (sett != UNDEFINED) {
|
||||
return FAIL;
|
||||
}
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
|
||||
char *dac_names[] = {DAC_NAMES};
|
||||
LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index,
|
||||
dac_names[index], value));
|
||||
defaultDacValues[index] = value;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* firmware functions (resets) */
|
||||
|
||||
|
@ -47,6 +47,10 @@ sls_detector_module *detectorModules = NULL;
|
||||
int *detectorChans = NULL;
|
||||
int *detectorDacs = NULL;
|
||||
int *channelMask = NULL;
|
||||
int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
|
||||
int defaultDacValue_standard[] = SPECIAL_DEFAULT_STANDARD_DAC_VALS;
|
||||
int defaultDacValue_fast[] = SPECIAL_DEFAULT_FAST_DAC_VALS;
|
||||
int defaultDacValue_highgain[] = SPECIAL_DEFAULT_HIGHGAIN_DAC_VALS;
|
||||
|
||||
int32_t clkPhase[NUM_CLOCKS] = {};
|
||||
uint32_t clkDivider[NUM_CLOCKS] = {};
|
||||
@ -527,19 +531,98 @@ int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for (int i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
||||
if (detectorDacs[i] != defaultvals[i]) {
|
||||
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||
if (detectorDacs[i] != defaultDacValues[i]) {
|
||||
ret = FAIL;
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||
defaultvals[i], detectorDacs[i]));
|
||||
defaultDacValues[i], detectorDacs[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
||||
int *retval) {
|
||||
|
||||
// settings only for special dacs
|
||||
if (sett != UNDEFINED) {
|
||||
const int specialDacs[] = SPECIALDACINDEX;
|
||||
// find special dac index
|
||||
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||
if ((int)index == specialDacs[i]) {
|
||||
switch (sett) {
|
||||
case STANDARD:
|
||||
*retval = defaultDacValue_standard[i];
|
||||
return OK;
|
||||
case FAST:
|
||||
*retval = defaultDacValue_fast[i];
|
||||
return OK;
|
||||
case HIGHGAIN:
|
||||
*retval = defaultDacValue_highgain[i];
|
||||
return OK;
|
||||
// unknown settings
|
||||
default:
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// not a special dac
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
*retval = defaultDacValues[index];
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value) {
|
||||
char *dac_names[] = {DAC_NAMES};
|
||||
|
||||
// settings only for special dacs
|
||||
if (sett != UNDEFINED) {
|
||||
const int specialDacs[] = SPECIALDACINDEX;
|
||||
// find special dac index
|
||||
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||
if ((int)index == specialDacs[i]) {
|
||||
switch (sett) {
|
||||
case STANDARD:
|
||||
LOG(logINFO,
|
||||
("Setting Default Dac [%d - %s, standard]: %d\n",
|
||||
(int)index, dac_names[index], value));
|
||||
defaultDacValue_standard[i] = value;
|
||||
return OK;
|
||||
case FAST:
|
||||
LOG(logINFO, ("Setting Default Dac [%d - %s, fast]: %d\n",
|
||||
(int)index, dac_names[index], value));
|
||||
defaultDacValue_fast[i] = value;
|
||||
return OK;
|
||||
case HIGHGAIN:
|
||||
LOG(logINFO,
|
||||
("Setting Default Dac [%d - %s, highgain]: %d\n",
|
||||
(int)index, dac_names[index], value));
|
||||
defaultDacValue_highgain[i] = value;
|
||||
return OK;
|
||||
// unknown settings
|
||||
default:
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// not a special dac
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (index < 0 || index >= NDAC)
|
||||
return FAIL;
|
||||
LOG(logINFO, ("Setting Default Dac [%d - %s]: %d\n", (int)index,
|
||||
dac_names[index], value));
|
||||
defaultDacValues[index] = value;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void setASICDefaults() {
|
||||
uint32_t val = bus_r(ASIC_EXP_STATUS_REG);
|
||||
val &= (~ASIC_EXP_STAT_STO_LNGTH_MSK);
|
||||
@ -1201,24 +1284,19 @@ int getAllTrimbits() {
|
||||
}
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
int *dacVals = NULL;
|
||||
switch (sett) {
|
||||
case STANDARD:
|
||||
LOG(logINFOBLUE, ("Setting to standard settings\n"));
|
||||
thisSettings = sett;
|
||||
setDAC(M_VRPREAMP, DEFAULT_STANDARD_VRPREAMP, 0);
|
||||
setDAC(M_VRSHAPER, DEFAULT_STANDARD_VRSHAPER, 0);
|
||||
dacVals = defaultDacValue_standard;
|
||||
break;
|
||||
case FAST:
|
||||
LOG(logINFOBLUE, ("Setting to fast settings\n"));
|
||||
thisSettings = sett;
|
||||
setDAC(M_VRPREAMP, DEFAULT_FAST_VRPREAMP, 0);
|
||||
setDAC(M_VRSHAPER, DEFAULT_FAST_VRSHAPER, 0);
|
||||
dacVals = defaultDacValue_fast;
|
||||
break;
|
||||
case HIGHGAIN:
|
||||
LOG(logINFOBLUE, ("Setting to high gain settings\n"));
|
||||
thisSettings = sett;
|
||||
setDAC(M_VRPREAMP, DEFAULT_HIGHGAIN_VRPREAMP, 0);
|
||||
setDAC(M_VRSHAPER, DEFAULT_HIGHGAIN_VRSHAPER, 0);
|
||||
dacVals = defaultDacValue_highgain;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
@ -1226,34 +1304,54 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
return thisSettings;
|
||||
}
|
||||
|
||||
thisSettings = sett;
|
||||
|
||||
// set special dacs
|
||||
const int specialDacs[] = SPECIALDACINDEX;
|
||||
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||
setDAC(specialDacs[i], dacVals[i], 0);
|
||||
}
|
||||
|
||||
LOG(logINFO, ("Settings: %d\n", thisSettings));
|
||||
return thisSettings;
|
||||
}
|
||||
|
||||
void validateSettings() {
|
||||
if (detectorDacs[M_VRPREAMP] == DEFAULT_STANDARD_VRPREAMP &&
|
||||
detectorDacs[M_VRSHAPER] == DEFAULT_STANDARD_VRSHAPER) {
|
||||
if (thisSettings != STANDARD) {
|
||||
thisSettings = STANDARD;
|
||||
LOG(logINFOBLUE, ("Validated Settings changed to standard!\n"));
|
||||
// if any special dac value is changed individually => undefined
|
||||
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||
int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast,
|
||||
defaultDacValue_highgain};
|
||||
int settList[NUMSETTINGS] = {STANDARD, FAST, HIGHGAIN};
|
||||
|
||||
enum detectorSettings sett = UNDEFINED;
|
||||
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
||||
|
||||
// assume it matches current setting in list
|
||||
sett = settList[isett];
|
||||
// if one value does not match, = undefined
|
||||
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||
if (getDAC(specialDacs[i], 0) != specialDacValues[isett][i]) {
|
||||
sett = UNDEFINED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (detectorDacs[M_VRPREAMP] == DEFAULT_FAST_VRPREAMP &&
|
||||
detectorDacs[M_VRSHAPER] == DEFAULT_FAST_VRSHAPER) {
|
||||
if (thisSettings != FAST) {
|
||||
thisSettings = FAST;
|
||||
LOG(logINFOBLUE, ("Validated Settings changed to fast!\n"));
|
||||
|
||||
// all values matchd a setting
|
||||
if (sett != UNDEFINED) {
|
||||
break;
|
||||
}
|
||||
} else if (detectorDacs[M_VRPREAMP] == DEFAULT_HIGHGAIN_VRPREAMP &&
|
||||
detectorDacs[M_VRSHAPER] == DEFAULT_HIGHGAIN_VRSHAPER) {
|
||||
if (thisSettings != HIGHGAIN) {
|
||||
thisSettings = HIGHGAIN;
|
||||
LOG(logINFOBLUE, ("Validated Settings changed to highgain!\n"));
|
||||
}
|
||||
} else {
|
||||
thisSettings = UNDEFINED;
|
||||
LOG(logWARNING,
|
||||
("Settings set to undefined [vrpreamp: %d, vrshaper: %d]\n",
|
||||
detectorDacs[M_VRPREAMP], detectorDacs[M_VRSHAPER]));
|
||||
}
|
||||
// update settings
|
||||
if (thisSettings != sett) {
|
||||
LOG(logINFOBLUE,
|
||||
("Validated settings to %s (%d)\n",
|
||||
(sett == STANDARD
|
||||
? "standard"
|
||||
: (sett == FAST
|
||||
? "fast"
|
||||
: (sett == HIGHGAIN ? "highgain" : "undefined"))),
|
||||
sett));
|
||||
thisSettings = sett;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1335,8 +1433,11 @@ void setGeneralDAC(enum DACINDEX ind, int val, int mV) {
|
||||
detectorDacs[ind] = dacval;
|
||||
}
|
||||
#endif
|
||||
if (ind == M_VRPREAMP || ind == M_VRSHAPER) {
|
||||
validateSettings();
|
||||
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||
if ((int)ind == specialDacs[i]) {
|
||||
validateSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,13 +42,6 @@
|
||||
#define DEFAULT_TRIMBIT_VALUE (0)
|
||||
#define DEFAULT_COUNTER_DISABLED_VTH_VAL (2800)
|
||||
|
||||
#define DEFAULT_STANDARD_VRPREAMP (1100)
|
||||
#define DEFAULT_FAST_VRPREAMP (300)
|
||||
#define DEFAULT_HIGHGAIN_VRPREAMP (1300)
|
||||
#define DEFAULT_STANDARD_VRSHAPER (1280)
|
||||
#define DEFAULT_FAST_VRSHAPER (1500)
|
||||
#define DEFAULT_HIGHGAIN_VRSHAPER (1100)
|
||||
|
||||
#define DEFAULT_READOUT_C0 (10) //(100000000) // rdo_clk, 100 MHz
|
||||
#define DEFAULT_READOUT_C1 (10) //(100000000) // smp sample clk (x2), 100 MHz
|
||||
#define DEFAULT_SYSTEM_C0 (10) //(100000000) // run_clk, 100 MHz
|
||||
@ -118,6 +111,17 @@ enum DACINDEX {
|
||||
2800, /* vTrim */ \
|
||||
800 /* VdcSh */ \
|
||||
};
|
||||
|
||||
#define NUMSETTINGS (3)
|
||||
#define NSPECIALDACS (2)
|
||||
#define SPECIALDACINDEX {M_VRPREAMP, M_VRSHAPER};
|
||||
#define SPECIAL_DEFAULT_STANDARD_DAC_VALS \
|
||||
{ 1100, 1280 }
|
||||
#define SPECIAL_DEFAULT_FAST_DAC_VALS \
|
||||
{ 300, 1500 }
|
||||
#define SPECIAL_DEFAULT_HIGHGAIN_DAC_VALS \
|
||||
{ 1300, 1100 }
|
||||
|
||||
enum CLKINDEX {
|
||||
READOUT_C0,
|
||||
READOUT_C1,
|
||||
|
@ -989,6 +989,9 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
||||
|
||||
int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
||||
int retval = -1;
|
||||
enum DACINDEX serverDacIndex = 0;
|
||||
|
||||
// valid enums
|
||||
switch (ind) {
|
||||
case HIGH_VOLTAGE:
|
||||
#ifdef EIGERD
|
||||
@ -1002,245 +1005,241 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Dac Index", (int)ind);
|
||||
serverDacIndex = getDACIndex(ind);
|
||||
break;
|
||||
}
|
||||
if (ret == FAIL) {
|
||||
return retval;
|
||||
}
|
||||
enum DACINDEX serverDacIndex = getDACIndex(ind);
|
||||
if (ret == FAIL) {
|
||||
return retval;
|
||||
}
|
||||
switch (ind) {
|
||||
// adc vpp
|
||||
switch (ind) {
|
||||
// adc vpp
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
case ADC_VPP:
|
||||
// set
|
||||
if (val >= 0) {
|
||||
ret = AD9257_SetVrefVoltage(val, mV);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set Adc Vpp. Please set a "
|
||||
"proper value\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
case ADC_VPP:
|
||||
// set
|
||||
if (val >= 0) {
|
||||
ret = AD9257_SetVrefVoltage(val, mV);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set Adc Vpp. Please set a "
|
||||
"proper value\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
retval = AD9257_GetVrefVoltage(mV);
|
||||
LOG(logDEBUG1,
|
||||
("Adc Vpp retval: %d %s\n", retval, (mV ? "mV" : "mode")));
|
||||
// cannot validate (its just a variable and mv gives different
|
||||
// value)
|
||||
break;
|
||||
}
|
||||
retval = AD9257_GetVrefVoltage(mV);
|
||||
LOG(logDEBUG1,
|
||||
("Adc Vpp retval: %d %s\n", retval, (mV ? "mV" : "mode")));
|
||||
// cannot validate (its just a variable and mv gives different
|
||||
// value)
|
||||
break;
|
||||
#endif
|
||||
|
||||
// io delay
|
||||
// io delay
|
||||
#ifdef EIGERD
|
||||
case IO_DELAY:
|
||||
retval = setIODelay(val);
|
||||
LOG(logDEBUG1, ("IODelay: %d\n", retval));
|
||||
validate(&ret, mess, val, retval, "set iodelay", DEC);
|
||||
break;
|
||||
case IO_DELAY:
|
||||
retval = setIODelay(val);
|
||||
LOG(logDEBUG1, ("IODelay: %d\n", retval));
|
||||
validate(&ret, mess, val, retval, "set iodelay", DEC);
|
||||
break;
|
||||
#endif
|
||||
|
||||
// high voltage
|
||||
case HIGH_VOLTAGE:
|
||||
retval = setHighVoltage(val);
|
||||
LOG(logDEBUG1, ("High Voltage: %d\n", retval));
|
||||
// high voltage
|
||||
case HIGH_VOLTAGE:
|
||||
retval = setHighVoltage(val);
|
||||
LOG(logDEBUG1, ("High Voltage: %d\n", retval));
|
||||
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
|
||||
defined(GOTTHARD2D) || defined(MYTHEN3D)
|
||||
validate(&ret, mess, val, retval, "set high voltage", DEC);
|
||||
defined(GOTTHARD2D) || defined(MYTHEN3D)
|
||||
validate(&ret, mess, val, retval, "set high voltage", DEC);
|
||||
#endif
|
||||
#ifdef GOTTHARDD
|
||||
if (retval == -1) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Invalid Voltage. Valid values are 0, 90, "
|
||||
"110, 120, 150, 180, 200\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
validate(&ret, mess, val, retval, "set high voltage", DEC);
|
||||
if (retval == -1) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Invalid Voltage. Valid values are 0, 90, "
|
||||
"110, 120, 150, 180, 200\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
validate(&ret, mess, val, retval, "set high voltage", DEC);
|
||||
#elif EIGERD
|
||||
if ((retval != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval < 0)) {
|
||||
ret = FAIL;
|
||||
if (retval == -1)
|
||||
sprintf(mess,
|
||||
"Setting high voltage failed. Bad value %d. "
|
||||
"The range is from 0 to 200 V.\n",
|
||||
val);
|
||||
else if (retval == -2)
|
||||
strcpy(mess, "Setting high voltage failed. "
|
||||
"Serial/i2c communication failed.\n");
|
||||
else if (retval == -3)
|
||||
strcpy(mess, "Getting high voltage failed. "
|
||||
"Serial/i2c communication failed.\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
if ((retval != SLAVE_HIGH_VOLTAGE_READ_VAL) && (retval < 0)) {
|
||||
ret = FAIL;
|
||||
if (retval == -1)
|
||||
sprintf(mess,
|
||||
"Setting high voltage failed. Bad value %d. "
|
||||
"The range is from 0 to 200 V.\n",
|
||||
val);
|
||||
else if (retval == -2)
|
||||
strcpy(mess, "Setting high voltage failed. "
|
||||
"Serial/i2c communication failed.\n");
|
||||
else if (retval == -3)
|
||||
strcpy(mess, "Getting high voltage failed. "
|
||||
"Serial/i2c communication failed.\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
// power, vlimit
|
||||
// power, vlimit
|
||||
#ifdef CHIPTESTBOARDD
|
||||
case V_POWER_A:
|
||||
case V_POWER_B:
|
||||
case V_POWER_C:
|
||||
case V_POWER_D:
|
||||
case V_POWER_IO:
|
||||
if (val != GET_FLAG) {
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set power. Power regulator %d "
|
||||
"should be in mV and not dac units.\n",
|
||||
ind);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (checkVLimitCompliant(val) == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set power. Power regulator %d "
|
||||
"exceeds voltage limit %d.\n",
|
||||
ind, getVLimit());
|
||||
LOG(logERROR, (mess));
|
||||
} else if (!isPowerValid(serverDacIndex, val)) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set power. Power regulator %d "
|
||||
"should be between %d and %d mV\n",
|
||||
ind,
|
||||
(serverDacIndex == D_PWR_IO ? VIO_MIN_MV
|
||||
: POWER_RGLTR_MIN),
|
||||
(VCHIP_MAX_MV - VCHIP_POWER_INCRMNT));
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
setPower(serverDacIndex, val);
|
||||
}
|
||||
}
|
||||
retval = getPower(serverDacIndex);
|
||||
LOG(logDEBUG1, ("Power regulator(%d): %d\n", ind, retval));
|
||||
validate(&ret, mess, val, retval, "set power regulator", DEC);
|
||||
break;
|
||||
|
||||
case V_POWER_CHIP:
|
||||
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");
|
||||
LOG(logERROR, (mess));
|
||||
/* restrict users from setting vchip
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not set Vchip. Should be in mV and
|
||||
not dac units.\n"); LOG(logERROR,(mess)); } else if
|
||||
(!isVchipValid(val)) { ret = FAIL; sprintf(mess,"Could not
|
||||
set Vchip. Should be between %d and %d mV\n", VCHIP_MIN_MV,
|
||||
VCHIP_MAX_MV); LOG(logERROR,(mess)); } else { setVchip(val);
|
||||
}
|
||||
*/
|
||||
}
|
||||
retval = getVchip();
|
||||
LOG(logDEBUG1, ("Vchip: %d\n", retval));
|
||||
if (ret == OK && val != GET_FLAG && val != -100 && retval != val) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set vchip. Set %d, but read %d\n", val,
|
||||
retval);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
case V_LIMIT:
|
||||
if (val >= 0) {
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set power. VLimit should be in "
|
||||
"mV and not dac units.\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
setVLimit(val);
|
||||
}
|
||||
}
|
||||
retval = getVLimit();
|
||||
LOG(logDEBUG1, ("VLimit: %d\n", retval));
|
||||
validate(&ret, mess, val, retval, "set vlimit", DEC);
|
||||
break;
|
||||
#endif
|
||||
// dacs
|
||||
default:
|
||||
if (mV && val > DAC_MAX_MV) {
|
||||
case V_POWER_A:
|
||||
case V_POWER_B:
|
||||
case V_POWER_C:
|
||||
case V_POWER_D:
|
||||
case V_POWER_IO:
|
||||
if (val != GET_FLAG) {
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set dac %d to value %d. Allowed limits "
|
||||
"(0 - %d mV).\n",
|
||||
ind, val, DAC_MAX_MV);
|
||||
"Could not set power. Power regulator %d "
|
||||
"should be in mV and not dac units.\n",
|
||||
ind);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (!mV && val > getMaxDacSteps()) {
|
||||
} else if (checkVLimitCompliant(val) == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set dac %d to value %d. Allowed limits "
|
||||
"(0 - %d dac units).\n",
|
||||
ind, val, getMaxDacSteps());
|
||||
"Could not set power. Power regulator %d "
|
||||
"exceeds voltage limit %d.\n",
|
||||
ind, getVLimit());
|
||||
LOG(logERROR, (mess));
|
||||
} else if (!isPowerValid(serverDacIndex, val)) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set power. Power regulator %d "
|
||||
"should be between %d and %d mV\n",
|
||||
ind,
|
||||
(serverDacIndex == D_PWR_IO ? VIO_MIN_MV
|
||||
: POWER_RGLTR_MIN),
|
||||
(VCHIP_MAX_MV - VCHIP_POWER_INCRMNT));
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
if ((val != GET_FLAG && mV &&
|
||||
checkVLimitCompliant(val) == FAIL) ||
|
||||
(val != GET_FLAG && !mV &&
|
||||
checkVLimitDacCompliant(val) == FAIL)) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set dac %d to value %d. "
|
||||
"Exceeds voltage limit %d.\n",
|
||||
ind, (mV ? val : dacToVoltage(val)), getVLimit());
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
#endif
|
||||
setDAC(serverDacIndex, val, mV);
|
||||
retval = getDAC(serverDacIndex, mV);
|
||||
setPower(serverDacIndex, val);
|
||||
}
|
||||
#ifdef EIGERD
|
||||
if (val != GET_FLAG && getSettings() != UNDEFINED) {
|
||||
// changing dac changes settings to undefined
|
||||
switch (serverDacIndex) {
|
||||
case E_VCMP_LL:
|
||||
case E_VCMP_LR:
|
||||
case E_VCMP_RL:
|
||||
case E_VCMP_RR:
|
||||
case E_VRPREAMP:
|
||||
case E_VCP:
|
||||
setSettings(UNDEFINED);
|
||||
LOG(logERROR, ("Settings has been changed "
|
||||
"to undefined (changed specific dacs)\n"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// check
|
||||
if (ret == OK) {
|
||||
if ((abs(retval - val) <= 5) || val == GET_FLAG) {
|
||||
ret = OK;
|
||||
} else {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Setting dac %d : wrote %d but read %d\n",
|
||||
serverDacIndex, val, retval);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
LOG(logDEBUG1, ("Dac (%d): %d %s\n\n", serverDacIndex, retval,
|
||||
(mV ? "mV" : "dac units")));
|
||||
#ifdef MYTHEN3D
|
||||
// changed for setsettings (direct),
|
||||
// custom trimbit file (setmodule with myMod.reg as -1),
|
||||
// change of dac (direct)
|
||||
if (val != GET_FLAG && ret == OK) {
|
||||
for (int i = 0; i < NCOUNTERS; ++i) {
|
||||
setThresholdEnergy(i, -1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
retval = getPower(serverDacIndex);
|
||||
LOG(logDEBUG1, ("Power regulator(%d): %d\n", ind, retval));
|
||||
validate(&ret, mess, val, retval, "set power regulator", DEC);
|
||||
break;
|
||||
|
||||
case V_POWER_CHIP:
|
||||
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");
|
||||
LOG(logERROR, (mess));
|
||||
/* restrict users from setting vchip
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not set Vchip. Should be in mV and
|
||||
not dac units.\n"); LOG(logERROR,(mess)); } else if
|
||||
(!isVchipValid(val)) { ret = FAIL; sprintf(mess,"Could not
|
||||
set Vchip. Should be between %d and %d mV\n", VCHIP_MIN_MV,
|
||||
VCHIP_MAX_MV); LOG(logERROR,(mess)); } else { setVchip(val);
|
||||
}
|
||||
*/
|
||||
}
|
||||
retval = getVchip();
|
||||
LOG(logDEBUG1, ("Vchip: %d\n", retval));
|
||||
if (ret == OK && val != GET_FLAG && val != -100 && retval != val) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set vchip. Set %d, but read %d\n", val,
|
||||
retval);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
case V_LIMIT:
|
||||
if (val >= 0) {
|
||||
if (!mV) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not set power. VLimit should be in "
|
||||
"mV and not dac units.\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
setVLimit(val);
|
||||
}
|
||||
}
|
||||
retval = getVLimit();
|
||||
LOG(logDEBUG1, ("VLimit: %d\n", retval));
|
||||
validate(&ret, mess, val, retval, "set vlimit", DEC);
|
||||
break;
|
||||
#endif
|
||||
// dacs
|
||||
default:
|
||||
if (mV && val > DAC_MAX_MV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set dac %d to value %d. Allowed limits "
|
||||
"(0 - %d mV).\n",
|
||||
ind, val, DAC_MAX_MV);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (!mV && val > getMaxDacSteps()) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set dac %d to value %d. Allowed limits "
|
||||
"(0 - %d dac units).\n",
|
||||
ind, val, getMaxDacSteps());
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
if ((val != GET_FLAG && mV &&
|
||||
checkVLimitCompliant(val) == FAIL) ||
|
||||
(val != GET_FLAG && !mV &&
|
||||
checkVLimitDacCompliant(val) == FAIL)) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set dac %d to value %d. "
|
||||
"Exceeds voltage limit %d.\n",
|
||||
ind, (mV ? val : dacToVoltage(val)), getVLimit());
|
||||
LOG(logERROR, (mess));
|
||||
} else
|
||||
#endif
|
||||
setDAC(serverDacIndex, val, mV);
|
||||
retval = getDAC(serverDacIndex, mV);
|
||||
}
|
||||
#ifdef EIGERD
|
||||
if (val != GET_FLAG && getSettings() != UNDEFINED) {
|
||||
// changing dac changes settings to undefined
|
||||
switch (serverDacIndex) {
|
||||
case E_VCMP_LL:
|
||||
case E_VCMP_LR:
|
||||
case E_VCMP_RL:
|
||||
case E_VCMP_RR:
|
||||
case E_VRPREAMP:
|
||||
case E_VCP:
|
||||
setSettings(UNDEFINED);
|
||||
LOG(logERROR, ("Settings has been changed "
|
||||
"to undefined (changed specific dacs)\n"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// check
|
||||
if (ret == OK) {
|
||||
if ((abs(retval - val) <= 5) || val == GET_FLAG) {
|
||||
ret = OK;
|
||||
} else {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Setting dac %d : wrote %d but read %d\n",
|
||||
serverDacIndex, val, retval);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
LOG(logDEBUG1, ("Dac (%d): %d %s\n\n", serverDacIndex, retval,
|
||||
(mV ? "mV" : "dac units")));
|
||||
#ifdef MYTHEN3D
|
||||
// changed for setsettings (direct),
|
||||
// custom trimbit file (setmodule with myMod.reg as -1),
|
||||
// change of dac (direct)
|
||||
if (val != GET_FLAG && ret == OK) {
|
||||
for (int i = 0; i < NCOUNTERS; ++i) {
|
||||
setThresholdEnergy(i, -1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -1554,7 +1553,7 @@ int set_module(int file_des) {
|
||||
|
||||
void validate_settings(enum detectorSettings sett) {
|
||||
// check index
|
||||
switch (isett) {
|
||||
switch (sett) {
|
||||
#ifdef EIGERD
|
||||
case STANDARD:
|
||||
#elif JUNGFRAUD
|
||||
@ -1586,7 +1585,7 @@ void validate_settings(enum detectorSettings sett) {
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
NotImplemented("Settings Index", (int)isett);
|
||||
modeNotImplemented("Settings Index", (int)sett);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1613,7 +1612,7 @@ int set_settings(int file_des) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Cannot set settings via SET_SETTINGS, use "
|
||||
"SET_MODULE\n");
|
||||
logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
#else
|
||||
validate_settings(isett);
|
||||
#endif
|
||||
@ -8460,9 +8459,12 @@ int get_default_dac(int file_des) {
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
enum DACINDEX idac = getDACIndex(index);
|
||||
enum DACINDEX idac = getDACIndex(dacindex);
|
||||
if (ret == OK) {
|
||||
validate_settings(sett);
|
||||
// to allow for default dacs (without settings)
|
||||
if (sett != UNDEFINED) {
|
||||
validate_settings(sett);
|
||||
}
|
||||
if (ret == OK) {
|
||||
ret = getDefaultDac(idac, sett, &retval);
|
||||
if (ret == FAIL) {
|
||||
@ -8472,7 +8474,7 @@ int get_default_dac(int file_des) {
|
||||
} else {
|
||||
LOG(logDEBUG1,
|
||||
("default dac retval [dacindex:%d, setting:%d]: %u\n",
|
||||
(int)dacIndex, (int)sett, retval));
|
||||
(int)dacindex, (int)sett, retval));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8483,14 +8485,14 @@ int get_default_dac(int file_des) {
|
||||
int set_default_dac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int args[2] = {-1, -1};
|
||||
int args[3] = {-1, -1, -1};
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
|
||||
enum dacIndex dacindex = args[0];
|
||||
enum detectorSettings sett = args[1];
|
||||
int value = args[2] LOG(
|
||||
logDEBUG1, ("Setting default dac [dacindex: %d, settings: %d] to %d\n",
|
||||
int value = args[2];
|
||||
LOG(logDEBUG1, ("Setting default dac [dacindex: %d, settings: %d] to %d\n",
|
||||
(int)dacindex, (int)sett, value));
|
||||
|
||||
#ifdef CHIPTESTBOARDD
|
||||
@ -8498,9 +8500,12 @@ int set_default_dac(int file_des) {
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
enum DACINDEX idac = getDACIndex(index);
|
||||
enum DACINDEX idac = getDACIndex(dacindex);
|
||||
if (ret == OK) {
|
||||
validate_settings(sett);
|
||||
// to allow for default dacs (without settings)
|
||||
if (sett != UNDEFINED) {
|
||||
validate_settings(sett);
|
||||
}
|
||||
if (ret == OK) {
|
||||
ret = setDefaultDac(idac, sett, value);
|
||||
if (ret == FAIL) {
|
||||
@ -8519,7 +8524,7 @@ int set_default_dac(int file_des) {
|
||||
} else {
|
||||
LOG(logDEBUG1, ("default dac retval [dacindex:%d, "
|
||||
"setting:%d]: %u\n",
|
||||
(int)dacIndex, (int)sett, retval));
|
||||
(int)dacindex, (int)sett, retval));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1112,7 +1112,7 @@ std::string CmdProxy::DefaultDac(int action) {
|
||||
auto t = det->getDefaultDac(
|
||||
StringTo<defs::dacIndex>(args[0]),
|
||||
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]));
|
||||
os << ToString(args) << ' ' << OutString(t) << '\n';
|
||||
os << args[0] << ' ' << args[1] << ' ' << OutString(t) << '\n';
|
||||
} else {
|
||||
auto t = det->getDefaultDac(StringTo<defs::dacIndex>(args[0]));
|
||||
os << args[0] << ' ' << OutString(t) << '\n';
|
||||
@ -1126,11 +1126,12 @@ std::string CmdProxy::DefaultDac(int action) {
|
||||
det->setDefaultDac(
|
||||
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
|
||||
sls::StringTo<slsDetectorDefs::detectorSettings>(args[2]));
|
||||
os << args[0] << ' ' << args[2] << ' ' << args[1] << '\n';
|
||||
} else {
|
||||
det->setDefaultDac(StringTo<defs::dacIndex>(args[0]),
|
||||
StringTo<int>(args[1]));
|
||||
os << args[0] << ' ' << args[1] << '\n';
|
||||
}
|
||||
os << ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
|
@ -1421,8 +1421,8 @@ TEST_CASE("defaultdac", "[.cmd]") {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("defaultdac", {dacname, "1000"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("defaultdac [") + dacname +
|
||||
std::string(", 1000]\n"));
|
||||
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
|
||||
std::string(" 1000\n"));
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -1444,14 +1444,17 @@ TEST_CASE("defaultdac", "[.cmd]") {
|
||||
std::ostringstream oss;
|
||||
proxy.Call("defaultdac", {dacname, "1000", "dynamicgain"}, -1,
|
||||
PUT, oss);
|
||||
REQUIRE(oss.str() == std::string("defaultdac [") + dacname +
|
||||
std::string(", dynamicgain, 1000]\n"));
|
||||
REQUIRE(oss.str() ==
|
||||
std::string("defaultdac ") + dacname +
|
||||
std::string(" dynamicgain 1000\n"));
|
||||
}
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("defaultdac", {dacname}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == std::string("defaultdac [") + dacname +
|
||||
std::string(", dynamicgain] 1000\n"));
|
||||
proxy.Call("defaultdac", {dacname, "dynamicgain"}, -1, GET,
|
||||
oss);
|
||||
REQUIRE(oss.str() ==
|
||||
std::string("defaultdac ") + dacname +
|
||||
std::string(" dynamicgain 1000\n"));
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDefaultDac(it, prev_val[i], defs::DYNAMICGAIN, {i});
|
||||
|
Loading…
x
Reference in New Issue
Block a user