mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
Merge pull request #274 from slsdetectorgroup/j4defaultdacs
Jungfrau features: 4. defaultdacs
This commit is contained in:
commit
770ce80473
Binary file not shown.
Binary file not shown.
@ -93,6 +93,7 @@ int eiger_virtual_interrupt_subframe = 0;
|
|||||||
int eiger_virtual_left_datastream = 1;
|
int eiger_virtual_left_datastream = 1;
|
||||||
int eiger_virtual_right_datastream = 1;
|
int eiger_virtual_right_datastream = 1;
|
||||||
#endif
|
#endif
|
||||||
|
int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
|
||||||
|
|
||||||
int isInitCheckDone() { return initCheckDone; }
|
int isInitCheckDone() { return initCheckDone; }
|
||||||
|
|
||||||
@ -750,18 +751,42 @@ void setupDetector() {
|
|||||||
int setDefaultDacs() {
|
int setDefaultDacs() {
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||||
if ((detectorModules)->dacs[i] != defaultvals[i]) {
|
if ((detectorModules)->dacs[i] != defaultDacValues[i]) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||||
defaultvals[i], (detectorModules)->dacs[i]));
|
defaultDacValues[i], (detectorModules)->dacs[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/* advanced read/write reg */
|
/* advanced read/write reg */
|
||||||
int writeRegister(uint32_t offset, uint32_t data) {
|
int writeRegister(uint32_t offset, uint32_t data) {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
|
Binary file not shown.
@ -515,6 +515,31 @@ int setDefaultDacs() {
|
|||||||
return ret;
|
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() {
|
int readConfigFile() {
|
||||||
|
|
||||||
if (initError == FAIL) {
|
if (initError == FAIL) {
|
||||||
|
Binary file not shown.
@ -45,6 +45,7 @@ int detPos[2] = {};
|
|||||||
|
|
||||||
int detectorFirstServer = 1;
|
int detectorFirstServer = 1;
|
||||||
int dacValues[NDAC] = {};
|
int dacValues[NDAC] = {};
|
||||||
|
int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
|
||||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||||
enum externalSignalFlag signalMode = 0;
|
enum externalSignalFlag signalMode = 0;
|
||||||
|
|
||||||
@ -436,18 +437,42 @@ void setupDetector() {
|
|||||||
int setDefaultDacs() {
|
int setDefaultDacs() {
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||||
if (dacValues[i] != defaultvals[i]) {
|
if (dacValues[i] != defaultDacValues[i]) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||||
defaultvals[i], dacValues[i]));
|
defaultDacValues[i], dacValues[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
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) {
|
uint32_t writeRegister16And32(uint32_t offset, uint32_t data) {
|
||||||
if (((offset << MEM_MAP_SHIFT) == CONTROL_REG) ||
|
if (((offset << MEM_MAP_SHIFT) == CONTROL_REG) ||
|
||||||
((offset << MEM_MAP_SHIFT) == FIFO_DATA_REG)) {
|
((offset << MEM_MAP_SHIFT) == FIFO_DATA_REG)) {
|
||||||
|
Binary file not shown.
@ -43,6 +43,9 @@ int virtual_image_test_mode = 0;
|
|||||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||||
int highvoltage = 0;
|
int highvoltage = 0;
|
||||||
int dacValues[NDAC] = {};
|
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] = {};
|
int32_t clkPhase[NUM_CLOCKS] = {};
|
||||||
int detPos[4] = {};
|
int detPos[4] = {};
|
||||||
int chipVersion = 10; // (1.0)
|
int chipVersion = 10; // (1.0)
|
||||||
@ -470,18 +473,88 @@ void setupDetector() {
|
|||||||
int setDefaultDacs() {
|
int setDefaultDacs() {
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||||
if (dacValues[i] != defaultvals[i]) {
|
if (dacValues[i] != defaultDacValues[i]) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||||
defaultvals[i], dacValues[i]));
|
defaultDacValues[i], dacValues[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
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() {
|
int readConfigFile() {
|
||||||
|
|
||||||
if (initError == FAIL) {
|
if (initError == FAIL) {
|
||||||
@ -884,8 +957,6 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
|||||||
if (sett == UNINITIALIZED)
|
if (sett == UNINITIALIZED)
|
||||||
return thisSettings;
|
return thisSettings;
|
||||||
|
|
||||||
int G0DacVals[] = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
|
|
||||||
int HG0DacVals[] = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
|
|
||||||
int *dacVals = NULL;
|
int *dacVals = NULL;
|
||||||
// set settings
|
// set settings
|
||||||
switch (sett) {
|
switch (sett) {
|
||||||
@ -893,14 +964,14 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
|||||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||||
LOG(logINFO,
|
LOG(logINFO,
|
||||||
("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
|
("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
|
||||||
dacVals = G0DacVals;
|
dacVals = defaultDacValue_G0;
|
||||||
break;
|
break;
|
||||||
case DYNAMICHG0:
|
case DYNAMICHG0:
|
||||||
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
|
||||||
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL);
|
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",
|
LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n",
|
||||||
bus_r(DAQ_REG)));
|
bus_r(DAQ_REG)));
|
||||||
dacVals = HG0DacVals;
|
dacVals = defaultDacValue_HG0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
@ -927,26 +998,25 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
|||||||
void validateSettings() {
|
void validateSettings() {
|
||||||
// if any special dac value is changed individually => undefined
|
// if any special dac value is changed individually => undefined
|
||||||
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||||
int specialDacValues[NUMSETTINGS][NSPECIALDACS] = {
|
int *specialDacValues[] = {defaultDacValue_G0, defaultDacValue_HG0};
|
||||||
SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS,
|
|
||||||
SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS};
|
|
||||||
int settList[NUMSETTINGS] = {DYNAMICGAIN, DYNAMICHG0};
|
int settList[NUMSETTINGS] = {DYNAMICGAIN, DYNAMICHG0};
|
||||||
|
|
||||||
enum detectorSettings sett = UNDEFINED;
|
enum detectorSettings sett = UNDEFINED;
|
||||||
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
||||||
// dont overwrite if settings is correct
|
|
||||||
if (sett != UNDEFINED) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// assume it matches current setting in list
|
// assume it matches current setting in list
|
||||||
sett = settList[isett];
|
sett = settList[isett];
|
||||||
for (int ival = 0; ival < NSPECIALDACS; ++ival) {
|
// if one value does not match, = undefined
|
||||||
// if one value does not match, undefined
|
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||||
if (getDAC(specialDacs[ival], 0) != specialDacValues[isett][ival]) {
|
if (getDAC(specialDacs[i], 0) != specialDacValues[isett][i]) {
|
||||||
sett = UNDEFINED;
|
sett = UNDEFINED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// all values matchd a setting
|
||||||
|
if (sett != UNDEFINED) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// update settings
|
// update settings
|
||||||
if (thisSettings != sett) {
|
if (thisSettings != sett) {
|
||||||
|
Binary file not shown.
@ -61,6 +61,7 @@ uint8_t adcEnableMask_10g = 0;
|
|||||||
int32_t clkPhase[NUM_CLOCKS] = {};
|
int32_t clkPhase[NUM_CLOCKS] = {};
|
||||||
uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200};
|
uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200};
|
||||||
int dacValues[NDAC] = {};
|
int dacValues[NDAC] = {};
|
||||||
|
int defaultDacValues[NDAC] = DEFAULT_DAC_VALS;
|
||||||
// software limit that depends on the current chip on the ctb
|
// software limit that depends on the current chip on the ctb
|
||||||
int vLimit = 0;
|
int vLimit = 0;
|
||||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||||
@ -616,17 +617,40 @@ void updateDataBytes() {
|
|||||||
int setDefaultDacs() {
|
int setDefaultDacs() {
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||||
if (dacValues[i] != defaultvals[i]) {
|
if (dacValues[i] != defaultDacValues[i]) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||||
defaultvals[i], dacValues[i]));
|
defaultDacValues[i], dacValues[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
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) */
|
/* firmware functions (resets) */
|
||||||
|
|
||||||
|
Binary file not shown.
@ -47,6 +47,10 @@ sls_detector_module *detectorModules = NULL;
|
|||||||
int *detectorChans = NULL;
|
int *detectorChans = NULL;
|
||||||
int *detectorDacs = NULL;
|
int *detectorDacs = NULL;
|
||||||
int *channelMask = 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] = {};
|
int32_t clkPhase[NUM_CLOCKS] = {};
|
||||||
uint32_t clkDivider[NUM_CLOCKS] = {};
|
uint32_t clkDivider[NUM_CLOCKS] = {};
|
||||||
@ -527,19 +531,98 @@ int setDefaultDacs() {
|
|||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
{
|
{
|
||||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
setDAC((enum DACINDEX)i, defaultvals[i], 0);
|
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
||||||
if (detectorDacs[i] != defaultvals[i]) {
|
if (detectorDacs[i] != defaultDacValues[i]) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||||
defaultvals[i], detectorDacs[i]));
|
defaultDacValues[i], detectorDacs[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
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() {
|
void setASICDefaults() {
|
||||||
uint32_t val = bus_r(ASIC_EXP_STATUS_REG);
|
uint32_t val = bus_r(ASIC_EXP_STATUS_REG);
|
||||||
val &= (~ASIC_EXP_STAT_STO_LNGTH_MSK);
|
val &= (~ASIC_EXP_STAT_STO_LNGTH_MSK);
|
||||||
@ -1201,24 +1284,19 @@ int getAllTrimbits() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum detectorSettings setSettings(enum detectorSettings sett) {
|
enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||||
|
int *dacVals = NULL;
|
||||||
switch (sett) {
|
switch (sett) {
|
||||||
case STANDARD:
|
case STANDARD:
|
||||||
LOG(logINFOBLUE, ("Setting to standard settings\n"));
|
LOG(logINFOBLUE, ("Setting to standard settings\n"));
|
||||||
thisSettings = sett;
|
dacVals = defaultDacValue_standard;
|
||||||
setDAC(M_VRPREAMP, DEFAULT_STANDARD_VRPREAMP, 0);
|
|
||||||
setDAC(M_VRSHAPER, DEFAULT_STANDARD_VRSHAPER, 0);
|
|
||||||
break;
|
break;
|
||||||
case FAST:
|
case FAST:
|
||||||
LOG(logINFOBLUE, ("Setting to fast settings\n"));
|
LOG(logINFOBLUE, ("Setting to fast settings\n"));
|
||||||
thisSettings = sett;
|
dacVals = defaultDacValue_fast;
|
||||||
setDAC(M_VRPREAMP, DEFAULT_FAST_VRPREAMP, 0);
|
|
||||||
setDAC(M_VRSHAPER, DEFAULT_FAST_VRSHAPER, 0);
|
|
||||||
break;
|
break;
|
||||||
case HIGHGAIN:
|
case HIGHGAIN:
|
||||||
LOG(logINFOBLUE, ("Setting to high gain settings\n"));
|
LOG(logINFOBLUE, ("Setting to high gain settings\n"));
|
||||||
thisSettings = sett;
|
dacVals = defaultDacValue_highgain;
|
||||||
setDAC(M_VRPREAMP, DEFAULT_HIGHGAIN_VRPREAMP, 0);
|
|
||||||
setDAC(M_VRSHAPER, DEFAULT_HIGHGAIN_VRSHAPER, 0);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG(logERROR,
|
LOG(logERROR,
|
||||||
@ -1226,34 +1304,54 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
|||||||
return thisSettings;
|
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));
|
LOG(logINFO, ("Settings: %d\n", thisSettings));
|
||||||
return thisSettings;
|
return thisSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateSettings() {
|
void validateSettings() {
|
||||||
if (detectorDacs[M_VRPREAMP] == DEFAULT_STANDARD_VRPREAMP &&
|
// if any special dac value is changed individually => undefined
|
||||||
detectorDacs[M_VRSHAPER] == DEFAULT_STANDARD_VRSHAPER) {
|
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||||
if (thisSettings != STANDARD) {
|
int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast,
|
||||||
thisSettings = STANDARD;
|
defaultDacValue_highgain};
|
||||||
LOG(logINFOBLUE, ("Validated Settings changed to standard!\n"));
|
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"));
|
|
||||||
}
|
}
|
||||||
} else if (detectorDacs[M_VRPREAMP] == DEFAULT_HIGHGAIN_VRPREAMP &&
|
|
||||||
detectorDacs[M_VRSHAPER] == DEFAULT_HIGHGAIN_VRSHAPER) {
|
// all values matchd a setting
|
||||||
if (thisSettings != HIGHGAIN) {
|
if (sett != UNDEFINED) {
|
||||||
thisSettings = HIGHGAIN;
|
break;
|
||||||
LOG(logINFOBLUE, ("Validated Settings changed to highgain!\n"));
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
thisSettings = UNDEFINED;
|
// update settings
|
||||||
LOG(logWARNING,
|
if (thisSettings != sett) {
|
||||||
("Settings set to undefined [vrpreamp: %d, vrshaper: %d]\n",
|
LOG(logINFOBLUE,
|
||||||
detectorDacs[M_VRPREAMP], detectorDacs[M_VRSHAPER]));
|
("Validated settings to %s (%d)\n",
|
||||||
|
(sett == STANDARD
|
||||||
|
? "standard"
|
||||||
|
: (sett == FAST
|
||||||
|
? "fast"
|
||||||
|
: (sett == HIGHGAIN ? "highgain" : "undefined"))),
|
||||||
|
sett));
|
||||||
|
thisSettings = sett;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1335,9 +1433,12 @@ void setGeneralDAC(enum DACINDEX ind, int val, int mV) {
|
|||||||
detectorDacs[ind] = dacval;
|
detectorDacs[ind] = dacval;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ind == M_VRPREAMP || ind == M_VRSHAPER) {
|
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||||
|
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||||
|
if ((int)ind == specialDacs[i]) {
|
||||||
validateSettings();
|
validateSettings();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getDAC(enum DACINDEX ind, int mV) {
|
int getDAC(enum DACINDEX ind, int mV) {
|
||||||
|
@ -42,13 +42,6 @@
|
|||||||
#define DEFAULT_TRIMBIT_VALUE (0)
|
#define DEFAULT_TRIMBIT_VALUE (0)
|
||||||
#define DEFAULT_COUNTER_DISABLED_VTH_VAL (2800)
|
#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_C0 (10) //(100000000) // rdo_clk, 100 MHz
|
||||||
#define DEFAULT_READOUT_C1 (10) //(100000000) // smp sample clk (x2), 100 MHz
|
#define DEFAULT_READOUT_C1 (10) //(100000000) // smp sample clk (x2), 100 MHz
|
||||||
#define DEFAULT_SYSTEM_C0 (10) //(100000000) // run_clk, 100 MHz
|
#define DEFAULT_SYSTEM_C0 (10) //(100000000) // run_clk, 100 MHz
|
||||||
@ -118,6 +111,17 @@ enum DACINDEX {
|
|||||||
2800, /* vTrim */ \
|
2800, /* vTrim */ \
|
||||||
800 /* VdcSh */ \
|
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 {
|
enum CLKINDEX {
|
||||||
READOUT_C0,
|
READOUT_C0,
|
||||||
READOUT_C1,
|
READOUT_C1,
|
||||||
|
@ -118,6 +118,8 @@ void updateDataBytes();
|
|||||||
|
|
||||||
#ifndef CHIPTESTBOARDD
|
#ifndef CHIPTESTBOARDD
|
||||||
int setDefaultDacs();
|
int setDefaultDacs();
|
||||||
|
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval);
|
||||||
|
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value);
|
||||||
#endif
|
#endif
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
void setASICDefaults();
|
void setASICDefaults();
|
||||||
|
@ -40,6 +40,7 @@ int get_adc(int);
|
|||||||
int write_register(int);
|
int write_register(int);
|
||||||
int read_register(int);
|
int read_register(int);
|
||||||
int set_module(int);
|
int set_module(int);
|
||||||
|
void validate_settings(enum detectorSettings sett);
|
||||||
int set_settings(int);
|
int set_settings(int);
|
||||||
int get_threshold_energy(int);
|
int get_threshold_energy(int);
|
||||||
int acquire(int blocking, int file_des);
|
int acquire(int blocking, int file_des);
|
||||||
@ -254,3 +255,5 @@ int set_veto_stream(int);
|
|||||||
int get_veto_algorithm(int);
|
int get_veto_algorithm(int);
|
||||||
int set_veto_algorithm(int);
|
int set_veto_algorithm(int);
|
||||||
int get_chip_version(int);
|
int get_chip_version(int);
|
||||||
|
int get_default_dac(int);
|
||||||
|
int set_default_dac(int);
|
||||||
|
@ -380,6 +380,8 @@ void function_table() {
|
|||||||
flist[F_GET_VETO_ALGORITHM] = &get_veto_algorithm;
|
flist[F_GET_VETO_ALGORITHM] = &get_veto_algorithm;
|
||||||
flist[F_SET_VETO_ALGORITHM] = &set_veto_algorithm;
|
flist[F_SET_VETO_ALGORITHM] = &set_veto_algorithm;
|
||||||
flist[F_GET_CHIP_VERSION] = &get_chip_version;
|
flist[F_GET_CHIP_VERSION] = &get_chip_version;
|
||||||
|
flist[F_GET_DEFAULT_DAC] = &get_default_dac;
|
||||||
|
flist[F_SET_DEFAULT_DAC] = &set_default_dac;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||||
@ -749,8 +751,6 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
|||||||
case IB_TESTC:
|
case IB_TESTC:
|
||||||
serverDacIndex = G_IB_TESTC;
|
serverDacIndex = G_IB_TESTC;
|
||||||
break;
|
break;
|
||||||
case HIGH_VOLTAGE:
|
|
||||||
break;
|
|
||||||
#elif EIGERD
|
#elif EIGERD
|
||||||
case VTHRESHOLD:
|
case VTHRESHOLD:
|
||||||
serverDacIndex = E_VTHRESHOLD;
|
serverDacIndex = E_VTHRESHOLD;
|
||||||
@ -803,13 +803,7 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
|||||||
case VISHAPER:
|
case VISHAPER:
|
||||||
serverDacIndex = E_VISHAPER;
|
serverDacIndex = E_VISHAPER;
|
||||||
break;
|
break;
|
||||||
case HIGH_VOLTAGE:
|
|
||||||
case IO_DELAY:
|
|
||||||
break;
|
|
||||||
#elif CHIPTESTBOARDD
|
#elif CHIPTESTBOARDD
|
||||||
case ADC_VPP:
|
|
||||||
case HIGH_VOLTAGE:
|
|
||||||
break;
|
|
||||||
case V_POWER_A:
|
case V_POWER_A:
|
||||||
serverDacIndex = D_PWR_A;
|
serverDacIndex = D_PWR_A;
|
||||||
break;
|
break;
|
||||||
@ -828,8 +822,6 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
|||||||
case V_POWER_CHIP:
|
case V_POWER_CHIP:
|
||||||
serverDacIndex = D_PWR_CHIP;
|
serverDacIndex = D_PWR_CHIP;
|
||||||
break;
|
break;
|
||||||
case V_LIMIT:
|
|
||||||
break;
|
|
||||||
#elif MOENCHD
|
#elif MOENCHD
|
||||||
case VBP_COLBUF:
|
case VBP_COLBUF:
|
||||||
serverDacIndex = MO_VBP_COLBUF;
|
serverDacIndex = MO_VBP_COLBUF;
|
||||||
@ -855,14 +847,7 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
|||||||
case IBIAS_SFP:
|
case IBIAS_SFP:
|
||||||
serverDacIndex = MO_IBIAS_SFP;
|
serverDacIndex = MO_IBIAS_SFP;
|
||||||
break;
|
break;
|
||||||
case ADC_VPP:
|
|
||||||
case HIGH_VOLTAGE:
|
|
||||||
case V_LIMIT:
|
|
||||||
break;
|
|
||||||
|
|
||||||
#elif MYTHEN3D
|
#elif MYTHEN3D
|
||||||
case HIGH_VOLTAGE:
|
|
||||||
break;
|
|
||||||
case VCASSH:
|
case VCASSH:
|
||||||
serverDacIndex = M_VCASSH;
|
serverDacIndex = M_VCASSH;
|
||||||
break;
|
break;
|
||||||
@ -1004,11 +989,29 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
|||||||
|
|
||||||
int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
enum DACINDEX serverDacIndex = getDACIndex(ind);
|
enum DACINDEX serverDacIndex = 0;
|
||||||
|
|
||||||
if (ret == OK) {
|
// valid enums
|
||||||
|
switch (ind) {
|
||||||
|
case HIGH_VOLTAGE:
|
||||||
|
#ifdef EIGERD
|
||||||
|
case IO_DELAY:
|
||||||
|
#elif CHIPTESTBOARDD
|
||||||
|
case ADC_VPP:
|
||||||
|
case V_LIMIT:
|
||||||
|
#elif MOENCHD
|
||||||
|
case ADC_VPP:
|
||||||
|
case V_LIMIT:
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
serverDacIndex = getDACIndex(ind);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ret == FAIL) {
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
switch (ind) {
|
switch (ind) {
|
||||||
|
|
||||||
// adc vpp
|
// adc vpp
|
||||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||||
case ADC_VPP:
|
case ADC_VPP:
|
||||||
@ -1043,7 +1046,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
|||||||
retval = setHighVoltage(val);
|
retval = setHighVoltage(val);
|
||||||
LOG(logDEBUG1, ("High Voltage: %d\n", retval));
|
LOG(logDEBUG1, ("High Voltage: %d\n", retval));
|
||||||
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
|
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || \
|
||||||
defined(GOTTHARD2D) || defined(MYTHEN3D)
|
defined(GOTTHARD2D) || defined(MYTHEN3D)
|
||||||
validate(&ret, mess, val, retval, "set high voltage", DEC);
|
validate(&ret, mess, val, retval, "set high voltage", DEC);
|
||||||
#endif
|
#endif
|
||||||
#ifdef GOTTHARDD
|
#ifdef GOTTHARDD
|
||||||
@ -1237,7 +1240,6 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1531,28 +1533,12 @@ int set_module(int file_des) {
|
|||||||
else if (Server_VerifyLock() == OK) {
|
else if (Server_VerifyLock() == OK) {
|
||||||
// check index
|
// check index
|
||||||
|
|
||||||
#if !(defined(EIGERD) || defined(MYTHEN3D))
|
#ifndef EIGERD
|
||||||
// TODO! Check if this is used for any detector
|
validate_settings((enum detectorSettings)(module.reg));
|
||||||
switch (module.reg) {
|
|
||||||
#ifdef JUNGFRAUD
|
|
||||||
case DYNAMICGAIN:
|
|
||||||
case DYNAMICHG0:
|
|
||||||
#elif GOTTHARDD
|
|
||||||
case DYNAMICGAIN:
|
|
||||||
case HIGHGAIN:
|
|
||||||
case LOWGAIN:
|
|
||||||
case MEDIUMGAIN:
|
|
||||||
case VERYHIGHGAIN:
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
modeNotImplemented("Settings", (int)module.reg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
ret = setModule(module, mess);
|
ret = setModule(module, mess);
|
||||||
enum detectorSettings retval = getSettings();
|
enum detectorSettings retval = getSettings();
|
||||||
#if !(defined(EIGERD) || defined(MYTHEN3D))
|
#ifndef EIGERD
|
||||||
validate(&ret, mess, module.reg, (int)retval, "set module (settings)",
|
validate(&ret, mess, module.reg, (int)retval, "set module (settings)",
|
||||||
DEC);
|
DEC);
|
||||||
#endif
|
#endif
|
||||||
@ -1565,27 +1551,12 @@ int set_module(int file_des) {
|
|||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_settings(int file_des) {
|
void validate_settings(enum detectorSettings sett) {
|
||||||
ret = OK;
|
|
||||||
memset(mess, 0, sizeof(mess));
|
|
||||||
enum detectorSettings isett = STANDARD;
|
|
||||||
enum detectorSettings retval = STANDARD;
|
|
||||||
|
|
||||||
if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0)
|
|
||||||
return printSocketReadError();
|
|
||||||
|
|
||||||
#ifdef CHIPTESTBOARDD
|
|
||||||
functionNotImplemented();
|
|
||||||
#else
|
|
||||||
LOG(logDEBUG1, ("Setting settings %d\n", isett));
|
|
||||||
|
|
||||||
// set & get
|
|
||||||
if (((int)isett == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
|
||||||
|
|
||||||
if ((int)isett != GET_FLAG) {
|
|
||||||
// check index
|
// check index
|
||||||
switch (isett) {
|
switch (sett) {
|
||||||
#ifdef JUNGFRAUD
|
#ifdef EIGERD
|
||||||
|
case STANDARD:
|
||||||
|
#elif JUNGFRAUD
|
||||||
case DYNAMICGAIN:
|
case DYNAMICGAIN:
|
||||||
case DYNAMICHG0:
|
case DYNAMICHG0:
|
||||||
#elif GOTTHARDD
|
#elif GOTTHARDD
|
||||||
@ -1614,16 +1585,37 @@ int set_settings(int file_des) {
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (myDetectorType == EIGER) {
|
modeNotImplemented("Settings Index", (int)sett);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_settings(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
enum detectorSettings isett = STANDARD;
|
||||||
|
enum detectorSettings retval = STANDARD;
|
||||||
|
|
||||||
|
if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
|
||||||
|
#ifdef CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
LOG(logDEBUG1, ("Setting settings %d\n", isett));
|
||||||
|
|
||||||
|
// set & get
|
||||||
|
if (((int)isett == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
||||||
|
|
||||||
|
if ((int)isett != GET_FLAG) {
|
||||||
|
#ifdef EIGERD
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess, "Cannot set settings via SET_SETTINGS, use "
|
sprintf(mess, "Cannot set settings via SET_SETTINGS, use "
|
||||||
"SET_MODULE\n");
|
"SET_MODULE\n");
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
} else
|
#else
|
||||||
modeNotImplemented("Settings Index", (int)isett);
|
validate_settings(isett);
|
||||||
break;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
setSettings(isett);
|
setSettings(isett);
|
||||||
}
|
}
|
||||||
@ -7653,6 +7645,7 @@ int set_scan(int file_des) {
|
|||||||
}
|
}
|
||||||
// dac scan
|
// dac scan
|
||||||
else {
|
else {
|
||||||
|
// validate index
|
||||||
getDACIndex(index);
|
getDACIndex(index);
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
LOG(logINFOBLUE, ("Dac [%d] scan enabled\n", index));
|
LOG(logINFOBLUE, ("Dac [%d] scan enabled\n", index));
|
||||||
@ -8448,3 +8441,95 @@ int get_chip_version(int file_des) {
|
|||||||
LOG(logDEBUG1, ("chip version retval: %d\n", retval));
|
LOG(logDEBUG1, ("chip version retval: %d\n", retval));
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_default_dac(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int args[2] = {-1, -1};
|
||||||
|
int retval = -1;
|
||||||
|
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
|
||||||
|
enum dacIndex dacindex = args[0];
|
||||||
|
enum detectorSettings sett = args[1];
|
||||||
|
LOG(logDEBUG1,
|
||||||
|
("Getting default dac [dacindex:%d, settings: %d]\n", dacindex, sett));
|
||||||
|
|
||||||
|
#ifdef CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
enum DACINDEX idac = getDACIndex(dacindex);
|
||||||
|
if (ret == OK) {
|
||||||
|
// to allow for default dacs (without settings)
|
||||||
|
if (sett != UNDEFINED) {
|
||||||
|
validate_settings(sett);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
ret = getDefaultDac(idac, sett, &retval);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
sprintf(mess, "Could not get default dac %d %s\n", (int)idac,
|
||||||
|
(sett != UNDEFINED ? "for this setting" : ""));
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
LOG(logDEBUG1,
|
||||||
|
("default dac retval [dacindex:%d, setting:%d]: %u\n",
|
||||||
|
(int)dacindex, (int)sett, retval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_default_dac(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
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)dacindex, (int)sett, value));
|
||||||
|
|
||||||
|
#ifdef CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
enum DACINDEX idac = getDACIndex(dacindex);
|
||||||
|
if (ret == OK) {
|
||||||
|
// to allow for default dacs (without settings)
|
||||||
|
if (sett != UNDEFINED) {
|
||||||
|
validate_settings(sett);
|
||||||
|
}
|
||||||
|
if (ret == OK) {
|
||||||
|
ret = setDefaultDac(idac, sett, value);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
sprintf(mess, "Could not set default dac %d %s\n",
|
||||||
|
(int)idac,
|
||||||
|
(sett != UNDEFINED ? "for this setting" : ""));
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
int retval = -1;
|
||||||
|
ret = getDefaultDac(idac, sett, &retval);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
sprintf(mess, "Could not get default dac %d %s\n",
|
||||||
|
(int)idac,
|
||||||
|
(sett != UNDEFINED ? "for this setting" : ""));
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
LOG(logDEBUG1, ("default dac retval [dacindex:%d, "
|
||||||
|
"setting:%d]: %u\n",
|
||||||
|
(int)dacindex, (int)sett, retval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
@ -412,6 +412,21 @@ class Detector {
|
|||||||
/** gets list of dac enums for this detector */
|
/** gets list of dac enums for this detector */
|
||||||
std::vector<defs::dacIndex> getDacList() const;
|
std::vector<defs::dacIndex> getDacList() const;
|
||||||
|
|
||||||
|
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||||
|
Result<int> getDefaultDac(defs::dacIndex index, Positions pos = {});
|
||||||
|
|
||||||
|
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||||
|
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
|
/** [Jungfrau][Mythen3] */
|
||||||
|
Result<int> getDefaultDac(defs::dacIndex index, defs::detectorSettings sett,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
|
/** [Jungfrau][Mythen3] */
|
||||||
|
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
|
defs::detectorSettings sett, Positions pos = {});
|
||||||
|
|
||||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
||||||
void setDefaultDacs(Positions pos = {});
|
void setDefaultDacs(Positions pos = {});
|
||||||
|
|
||||||
@ -1778,7 +1793,6 @@ class Detector {
|
|||||||
std::vector<int> getPortNumbers(int start_port);
|
std::vector<int> getPortNumbers(int start_port);
|
||||||
void updateRxRateCorrections();
|
void updateRxRateCorrections();
|
||||||
void setNumberofUDPInterfaces_(int n, Positions pos);
|
void setNumberofUDPInterfaces_(int n, Positions pos);
|
||||||
Result<int> getNumberofUDPInterfaces_(Positions pos) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -1095,6 +1095,48 @@ std::string CmdProxy::DacValues(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CmdProxy::DefaultDac(int action) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << cmd << ' ';
|
||||||
|
if (action == defs::HELP_ACTION) {
|
||||||
|
os << "[dac name][value][(optional)setting]\n\tSets the default for "
|
||||||
|
"that dac to this value.\n\t[Jungfrau][Mythen3] When settings is "
|
||||||
|
"provided, it sets the default value only for that setting"
|
||||||
|
<< '\n';
|
||||||
|
} else if (action == defs::GET_ACTION) {
|
||||||
|
if (args.size() < 1) {
|
||||||
|
WrongNumberOfParameters(1);
|
||||||
|
}
|
||||||
|
// optional settings
|
||||||
|
if (args.size() == 2) {
|
||||||
|
auto t = det->getDefaultDac(
|
||||||
|
StringTo<defs::dacIndex>(args[0]),
|
||||||
|
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]));
|
||||||
|
os << args[0] << ' ' << args[1] << ' ' << OutString(t) << '\n';
|
||||||
|
} else {
|
||||||
|
auto t = det->getDefaultDac(StringTo<defs::dacIndex>(args[0]));
|
||||||
|
os << args[0] << ' ' << OutString(t) << '\n';
|
||||||
|
}
|
||||||
|
} else if (action == defs::PUT_ACTION) {
|
||||||
|
if (args.size() < 2) {
|
||||||
|
WrongNumberOfParameters(2);
|
||||||
|
}
|
||||||
|
// optional settings
|
||||||
|
if (args.size() == 3) {
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw sls::RuntimeError("Unknown action");
|
||||||
|
}
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
/* acquisition */
|
/* acquisition */
|
||||||
|
|
||||||
std::string CmdProxy::ReceiverStatus(int action) {
|
std::string CmdProxy::ReceiverStatus(int action) {
|
||||||
|
@ -817,6 +817,7 @@ class CmdProxy {
|
|||||||
{"daclist", &CmdProxy::daclist},
|
{"daclist", &CmdProxy::daclist},
|
||||||
{"dacvalues", &CmdProxy::DacValues},
|
{"dacvalues", &CmdProxy::DacValues},
|
||||||
{"defaultdacs", &CmdProxy::defaultdacs},
|
{"defaultdacs", &CmdProxy::defaultdacs},
|
||||||
|
{"defaultdac", &CmdProxy::DefaultDac},
|
||||||
|
|
||||||
/* on chip dacs */
|
/* on chip dacs */
|
||||||
{"vchip_comp_fe", &CmdProxy::vchip_comp_fe},
|
{"vchip_comp_fe", &CmdProxy::vchip_comp_fe},
|
||||||
@ -1094,6 +1095,7 @@ class CmdProxy {
|
|||||||
/* dacs */
|
/* dacs */
|
||||||
std::string Dac(int action);
|
std::string Dac(int action);
|
||||||
std::string DacValues(int action);
|
std::string DacValues(int action);
|
||||||
|
std::string DefaultDac(int action);
|
||||||
/* acquisition */
|
/* acquisition */
|
||||||
std::string ReceiverStatus(int action);
|
std::string ReceiverStatus(int action);
|
||||||
std::string DetectorStatus(int action);
|
std::string DetectorStatus(int action);
|
||||||
|
@ -620,6 +620,36 @@ std::vector<defs::dacIndex> Detector::getDacList() const {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<int> Detector::getDefaultDac(defs::dacIndex index, Positions pos) {
|
||||||
|
return pimpl->getDefaultDac(index, defs::UNDEFINED, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
|
Positions pos) {
|
||||||
|
pimpl->setDefaultDac(index, defaultValue, defs::UNDEFINED, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<int> Detector::getDefaultDac(defs::dacIndex index,
|
||||||
|
defs::detectorSettings sett,
|
||||||
|
Positions pos) {
|
||||||
|
if (sett == defs::UNDEFINED) {
|
||||||
|
throw RuntimeError("Invalid settings given for default dac");
|
||||||
|
}
|
||||||
|
return pimpl->getDefaultDac(index, sett, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
|
defs::detectorSettings sett, Positions pos) {
|
||||||
|
if (sett == defs::UNDEFINED) {
|
||||||
|
throw RuntimeError("Invalid settings given for default dac");
|
||||||
|
}
|
||||||
|
pimpl->setDefaultDac(index, defaultValue, sett, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Detector::setDefaultDacs(Positions pos) {
|
void Detector::setDefaultDacs(Positions pos) {
|
||||||
pimpl->Parallel(&Module::setDefaultDacs, pos);
|
pimpl->Parallel(&Module::setDefaultDacs, pos);
|
||||||
}
|
}
|
||||||
@ -753,7 +783,7 @@ Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
|
|||||||
"Cannot set number of udp interfaces for this detector.");
|
"Cannot set number of udp interfaces for this detector.");
|
||||||
}
|
}
|
||||||
// also called by vetostream (for gotthard2)
|
// also called by vetostream (for gotthard2)
|
||||||
return getNumberofUDPInterfaces_(pos);
|
return pimpl->getNumberofUDPInterfaces(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
|
void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
|
||||||
@ -765,10 +795,6 @@ void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
|
|||||||
setNumberofUDPInterfaces_(n, pos);
|
setNumberofUDPInterfaces_(n, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getNumberofUDPInterfaces_(Positions pos) const {
|
|
||||||
return pimpl->Parallel(&Module::getNumberofUDPInterfaces, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
|
void Detector::setNumberofUDPInterfaces_(int n, Positions pos) {
|
||||||
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
bool previouslyClientStreaming = pimpl->getDataStreamingToClient();
|
||||||
bool useReceiver = getUseReceiverFlag().squash(false);
|
bool useReceiver = getUseReceiverFlag().squash(false);
|
||||||
@ -1584,7 +1610,7 @@ Result<defs::ethernetInterface> Detector::getVetoStream(Positions pos) const {
|
|||||||
// 3gbe
|
// 3gbe
|
||||||
auto r3 = pimpl->Parallel(&Module::getVetoStream, pos);
|
auto r3 = pimpl->Parallel(&Module::getVetoStream, pos);
|
||||||
// 10gbe (debugging interface) opens 2nd udp interface in receiver
|
// 10gbe (debugging interface) opens 2nd udp interface in receiver
|
||||||
auto r10 = getNumberofUDPInterfaces_(pos);
|
auto r10 = pimpl->getNumberofUDPInterfaces(pos);
|
||||||
|
|
||||||
Result<defs::ethernetInterface> res(r3.size());
|
Result<defs::ethernetInterface> res(r3.size());
|
||||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||||
@ -1604,7 +1630,7 @@ void Detector::setVetoStream(defs::ethernetInterface interface, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setVetoStream, pos, i3gbe);
|
pimpl->Parallel(&Module::setVetoStream, pos, i3gbe);
|
||||||
|
|
||||||
// 10gbe (debugging interface) opens 2nd udp interface in receiver
|
// 10gbe (debugging interface) opens 2nd udp interface in receiver
|
||||||
int old_numinterfaces = getNumberofUDPInterfaces_(pos).tsquash(
|
int old_numinterfaces = pimpl->getNumberofUDPInterfaces(pos).tsquash(
|
||||||
"retrieved inconsistent number of udp interfaces");
|
"retrieved inconsistent number of udp interfaces");
|
||||||
int numinterfaces = (((interface & defs::ethernetInterface::I10GBE) ==
|
int numinterfaces = (((interface & defs::ethernetInterface::I10GBE) ==
|
||||||
defs::ethernetInterface::I10GBE)
|
defs::ethernetInterface::I10GBE)
|
||||||
@ -2169,7 +2195,7 @@ std::vector<int> Detector::getPortNumbers(int start_port) {
|
|||||||
break;
|
break;
|
||||||
case defs::JUNGFRAU:
|
case defs::JUNGFRAU:
|
||||||
case defs::GOTTHARD2:
|
case defs::GOTTHARD2:
|
||||||
if (getNumberofUDPInterfaces_({}).squash() == 2) {
|
if (pimpl->getNumberofUDPInterfaces({}).squash() == 2) {
|
||||||
num_sockets_per_detector *= 2;
|
num_sockets_per_detector *= 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1369,4 +1369,19 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sls::Result<int> DetectorImpl::getNumberofUDPInterfaces(Positions pos) const {
|
||||||
|
return Parallel(&Module::getNumberofUDPInterfaces, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
sls::Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index,
|
||||||
|
defs::detectorSettings sett,
|
||||||
|
Positions pos) {
|
||||||
|
return Parallel(&Module::getDefaultDac, pos, index, sett);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DetectorImpl::setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
|
defs::detectorSettings sett, Positions pos) {
|
||||||
|
Parallel(&Module::setDefaultDac, pos, index, defaultValue, sett);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
@ -291,6 +291,14 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
std::vector<char> readProgrammingFile(const std::string &fname);
|
std::vector<char> readProgrammingFile(const std::string &fname);
|
||||||
|
|
||||||
|
sls::Result<int> getNumberofUDPInterfaces(Positions pos) const;
|
||||||
|
void setNumberofUDPInterfaces(int n, Positions pos);
|
||||||
|
sls::Result<int> getDefaultDac(defs::dacIndex index,
|
||||||
|
defs::detectorSettings sett,
|
||||||
|
Positions pos = {});
|
||||||
|
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
|
defs::detectorSettings sett, Positions pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Creates/open shared memory, initializes detector structure and members
|
* Creates/open shared memory, initializes detector structure and members
|
||||||
|
@ -618,6 +618,16 @@ int Module::getDAC(dacIndex index, bool mV) const {
|
|||||||
int args[]{static_cast<int>(index), static_cast<int>(mV), GET_FLAG};
|
int args[]{static_cast<int>(index), static_cast<int>(mV), GET_FLAG};
|
||||||
return sendToDetector<int>(F_SET_DAC, args);
|
return sendToDetector<int>(F_SET_DAC, args);
|
||||||
}
|
}
|
||||||
|
int Module::getDefaultDac(slsDetectorDefs::dacIndex index,
|
||||||
|
slsDetectorDefs::detectorSettings sett) {
|
||||||
|
int args[]{static_cast<int>(index), static_cast<int>(sett)};
|
||||||
|
return sendToDetector<int>(F_GET_DEFAULT_DAC, args);
|
||||||
|
}
|
||||||
|
void Module::setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
||||||
|
defs::detectorSettings sett) {
|
||||||
|
int args[]{static_cast<int>(index), static_cast<int>(sett), defaultValue};
|
||||||
|
return sendToDetector(F_SET_DEFAULT_DAC, args, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void Module::setDefaultDacs() { sendToDetector(F_SET_DEFAULT_DACS); }
|
void Module::setDefaultDacs() { sendToDetector(F_SET_DEFAULT_DACS); }
|
||||||
|
|
||||||
|
@ -148,7 +148,10 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
int getMaxClockPhaseShift(int clkIndex) const;
|
int getMaxClockPhaseShift(int clkIndex) const;
|
||||||
int getClockFrequency(int clkIndex) const;
|
int getClockFrequency(int clkIndex) const;
|
||||||
void setClockFrequency(int clkIndex, int value);
|
void setClockFrequency(int clkIndex, int value);
|
||||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
int getDefaultDac(slsDetectorDefs::dacIndex index,
|
||||||
|
slsDetectorDefs::detectorSettings sett);
|
||||||
|
void setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
||||||
|
defs::detectorSettings sett);
|
||||||
void setDefaultDacs();
|
void setDefaultDacs();
|
||||||
int getDAC(dacIndex index, bool mV) const;
|
int getDAC(dacIndex index, bool mV) const;
|
||||||
void setDAC(int val, dacIndex index, bool mV);
|
void setDAC(int val, dacIndex index, bool mV);
|
||||||
|
@ -1407,6 +1407,65 @@ TEST_CASE("dacvalues", "[.cmd]") {
|
|||||||
REQUIRE_THROWS(proxy.Call("dacvalues", {}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("dacvalues", {}, -1, PUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("defaultdac", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
if (det_type != defs::CHIPTESTBOARD) {
|
||||||
|
REQUIRE_THROWS(proxy.Call("defaultdac", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("defaultdac", {"blabla"}, -1, PUT));
|
||||||
|
auto daclist = det.getDacList();
|
||||||
|
for (auto it : daclist) {
|
||||||
|
auto dacname = sls::ToString(it);
|
||||||
|
auto prev_val = det.getDefaultDac(it);
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("defaultdac", {dacname, "1000"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
|
||||||
|
std::string(" 1000\n"));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("defaultdac", {dacname}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == std::string("defaultdac ") + dacname +
|
||||||
|
std::string(" 1000\n"));
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setDefaultDac(it, prev_val[i], {i});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (det_type == defs::JUNGFRAU) {
|
||||||
|
std::vector<defs::dacIndex> daclist = {defs::VB_COMP, defs::VREF_DS,
|
||||||
|
defs::VREF_COMP};
|
||||||
|
for (auto it : daclist) {
|
||||||
|
auto dacname = sls::ToString(it);
|
||||||
|
auto prev_val = det.getDefaultDac(it, defs::DYNAMICGAIN);
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("defaultdac", {dacname, "1000", "dynamicgain"}, -1,
|
||||||
|
PUT, oss);
|
||||||
|
REQUIRE(oss.str() ==
|
||||||
|
std::string("defaultdac ") + dacname +
|
||||||
|
std::string(" dynamicgain 1000\n"));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
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});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("defaultdac", {}, -1, GET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("defaultdacs", "[.cmd]") {
|
TEST_CASE("defaultdacs", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
|
@ -231,6 +231,8 @@ enum detFuncs {
|
|||||||
F_GET_VETO_ALGORITHM,
|
F_GET_VETO_ALGORITHM,
|
||||||
F_SET_VETO_ALGORITHM,
|
F_SET_VETO_ALGORITHM,
|
||||||
F_GET_CHIP_VERSION,
|
F_GET_CHIP_VERSION,
|
||||||
|
F_GET_DEFAULT_DAC,
|
||||||
|
F_SET_DEFAULT_DAC,
|
||||||
|
|
||||||
NUM_DET_FUNCTIONS,
|
NUM_DET_FUNCTIONS,
|
||||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||||
@ -568,6 +570,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_GET_VETO_ALGORITHM: return "F_GET_VETO_ALGORITHM";
|
case F_GET_VETO_ALGORITHM: return "F_GET_VETO_ALGORITHM";
|
||||||
case F_SET_VETO_ALGORITHM: return "F_SET_VETO_ALGORITHM";
|
case F_SET_VETO_ALGORITHM: return "F_SET_VETO_ALGORITHM";
|
||||||
case F_GET_CHIP_VERSION: return "F_GET_CHIP_VERSION";
|
case F_GET_CHIP_VERSION: return "F_GET_CHIP_VERSION";
|
||||||
|
case F_GET_DEFAULT_DAC: return "F_GET_DEFAULT_DAC";
|
||||||
|
case F_SET_DEFAULT_DAC: return "F_SET_DEFAULT_DAC";
|
||||||
|
|
||||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
#define APILIB 0x210225
|
#define APILIB 0x210225
|
||||||
#define APIRECEIVER 0x210225
|
#define APIRECEIVER 0x210225
|
||||||
#define APIGUI 0x210225
|
#define APIGUI 0x210225
|
||||||
#define APICTB 0x210727
|
#define APICTB 0x210729
|
||||||
#define APIGOTTHARD 0x210727
|
#define APIGOTTHARD 0x210729
|
||||||
#define APIGOTTHARD2 0x210727
|
#define APIGOTTHARD2 0x210729
|
||||||
#define APIMYTHEN3 0x210727
|
|
||||||
#define APIMOENCH 0x210727
|
|
||||||
#define APIEIGER 0x210727
|
|
||||||
#define APIJUNGFRAU 0x210729
|
#define APIJUNGFRAU 0x210729
|
||||||
|
#define APIMYTHEN3 0x210729
|
||||||
|
#define APIMOENCH 0x210729
|
||||||
|
#define APIEIGER 0x210729
|
||||||
|
Loading…
x
Reference in New Issue
Block a user