mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-13 17:58:43 +01:00
Merge pull request #275 from slsdetectorgroup/j5resetdacs
Jungfrau features: 5. resetdacs
This commit is contained in:
@@ -18,7 +18,8 @@ Checks: '*,
|
|||||||
-google-readability-todo,
|
-google-readability-todo,
|
||||||
-google-readability-braces-around-statements,
|
-google-readability-braces-around-statements,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-readability-isolate-declaration'
|
-readability-isolate-declaration,
|
||||||
|
-llvmlibc-*'
|
||||||
|
|
||||||
HeaderFilterRegex: \.h
|
HeaderFilterRegex: \.h
|
||||||
AnalyzeTemporaryDtors: false
|
AnalyzeTemporaryDtors: false
|
||||||
|
|||||||
@@ -354,9 +354,28 @@ void init_det(py::module &m) {
|
|||||||
py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getDacList", (std::vector<defs::dacIndex>(Detector::*)() const) &
|
.def("getDacList", (std::vector<defs::dacIndex>(Detector::*)() const) &
|
||||||
Detector::getDacList)
|
Detector::getDacList)
|
||||||
.def("setDefaultDacs",
|
.def("getDefaultDac",
|
||||||
(void (Detector::*)(sls::Positions)) & Detector::setDefaultDacs,
|
(Result<int>(Detector::*)(defs::dacIndex, sls::Positions)) &
|
||||||
py::arg() = Positions{})
|
Detector::getDefaultDac,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("setDefaultDac",
|
||||||
|
(void (Detector::*)(defs::dacIndex, int, sls::Positions)) &
|
||||||
|
Detector::setDefaultDac,
|
||||||
|
py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getDefaultDac",
|
||||||
|
(Result<int>(Detector::*)(defs::dacIndex, defs::detectorSettings,
|
||||||
|
sls::Positions)) &
|
||||||
|
Detector::getDefaultDac,
|
||||||
|
py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
|
.def("setDefaultDac",
|
||||||
|
(void (Detector::*)(defs::dacIndex, int, defs::detectorSettings,
|
||||||
|
sls::Positions)) &
|
||||||
|
Detector::setDefaultDac,
|
||||||
|
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
|
.def("resetToDefaultDacs",
|
||||||
|
(void (Detector::*)(const bool, sls::Positions)) &
|
||||||
|
Detector::resetToDefaultDacs,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getDAC",
|
.def("getDAC",
|
||||||
(Result<int>(Detector::*)(defs::dacIndex, bool, sls::Positions)
|
(Result<int>(Detector::*)(defs::dacIndex, bool, sls::Positions)
|
||||||
const) &
|
const) &
|
||||||
@@ -923,6 +942,10 @@ void init_det(py::module &m) {
|
|||||||
sls::Positions)) &
|
sls::Positions)) &
|
||||||
Detector::setDataStream,
|
Detector::setDataStream,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getChipVersion",
|
||||||
|
(Result<double>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getChipVersion,
|
||||||
|
py::arg() = Positions{})
|
||||||
.def("getThresholdTemperature",
|
.def("getThresholdTemperature",
|
||||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getThresholdTemperature,
|
Detector::getThresholdTemperature,
|
||||||
@@ -947,10 +970,6 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(sls::Positions)) &
|
(void (Detector::*)(sls::Positions)) &
|
||||||
Detector::resetTemperatureEvent,
|
Detector::resetTemperatureEvent,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("getChipVersion",
|
|
||||||
(Result<double>(Detector::*)(sls::Positions) const) &
|
|
||||||
Detector::getChipVersion,
|
|
||||||
py::arg() = Positions{})
|
|
||||||
.def("getAutoCompDisable",
|
.def("getAutoCompDisable",
|
||||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getAutoCompDisable,
|
Detector::getAutoCompDisable,
|
||||||
|
|||||||
@@ -686,7 +686,7 @@ void allocateDetectorStructureMemory() {
|
|||||||
void setupDetector() {
|
void setupDetector() {
|
||||||
|
|
||||||
allocateDetectorStructureMemory();
|
allocateDetectorStructureMemory();
|
||||||
setDefaultDacs();
|
resetToDefaultDacs(0);
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
sharedMemory_setStatus(IDLE);
|
sharedMemory_setStatus(IDLE);
|
||||||
#endif
|
#endif
|
||||||
@@ -748,7 +748,15 @@ void setupDetector() {
|
|||||||
LOG(logDEBUG1, ("Setup detector done\n\n"));
|
LOG(logDEBUG1, ("Setup detector done\n\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int setDefaultDacs() {
|
int resetToDefaultDacs(int hardReset) {
|
||||||
|
// reset defaults to hardcoded defaults
|
||||||
|
if (hardReset) {
|
||||||
|
const int vals[] = DEFAULT_DAC_VALS;
|
||||||
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
defaultDacValues[i] = vals[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// reset dacs to defaults
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ int highvoltage = 0;
|
|||||||
int dacValues[NDAC] = {};
|
int dacValues[NDAC] = {};
|
||||||
int onChipdacValues[ONCHIP_NDAC][NCHIP] = {};
|
int onChipdacValues[ONCHIP_NDAC][NCHIP] = {};
|
||||||
int defaultDacValues[NDAC] = {};
|
int defaultDacValues[NDAC] = {};
|
||||||
|
int hardCodedDefaultDacValues[NDAC] = {};
|
||||||
int defaultOnChipdacValues[ONCHIP_NDAC][NCHIP] = {};
|
int defaultOnChipdacValues[ONCHIP_NDAC][NCHIP] = {};
|
||||||
int injectedChannelsOffset = 0;
|
int injectedChannelsOffset = 0;
|
||||||
int injectedChannelsIncrement = 0;
|
int injectedChannelsIncrement = 0;
|
||||||
@@ -393,6 +394,7 @@ void setupDetector() {
|
|||||||
memset(dacValues, 0, sizeof(dacValues));
|
memset(dacValues, 0, sizeof(dacValues));
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
defaultDacValues[i] = -1;
|
defaultDacValues[i] = -1;
|
||||||
|
hardCodedDefaultDacValues[i] = -1;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < ONCHIP_NDAC; ++i) {
|
for (int i = 0; i < ONCHIP_NDAC; ++i) {
|
||||||
for (int j = 0; j < NCHIP; ++j) {
|
for (int j = 0; j < NCHIP; ++j) {
|
||||||
@@ -481,7 +483,14 @@ void setupDetector() {
|
|||||||
setCurrentSource(DEFAULT_CURRENT_SOURCE);
|
setCurrentSource(DEFAULT_CURRENT_SOURCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int setDefaultDacs() {
|
int resetToDefaultDacs(int hardReset) {
|
||||||
|
// reset defaults to hardcoded defaults
|
||||||
|
if (hardReset) {
|
||||||
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
defaultDacValues[i] = hardCodedDefaultDacValues[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// reset dacs to defaults
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
@@ -831,6 +840,7 @@ int readConfigFile() {
|
|||||||
|
|
||||||
// set default dac variables
|
// set default dac variables
|
||||||
defaultDacValues[idac] = value;
|
defaultDacValues[idac] = value;
|
||||||
|
hardCodedDefaultDacValues[idac] = value;
|
||||||
|
|
||||||
// set dac
|
// set dac
|
||||||
setDAC(idac, value, 0);
|
setDAC(idac, value, 0);
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ void setupDetector() {
|
|||||||
DAC_MAX_MV);
|
DAC_MAX_MV);
|
||||||
LTC2620_Disable();
|
LTC2620_Disable();
|
||||||
LTC2620_Configure();
|
LTC2620_Configure();
|
||||||
setDefaultDacs();
|
resetToDefaultDacs(0);
|
||||||
|
|
||||||
// temp
|
// temp
|
||||||
bus_w(TEMP_SPI_IN_REG, TEMP_SPI_IN_IDLE_MSK);
|
bus_w(TEMP_SPI_IN_REG, TEMP_SPI_IN_IDLE_MSK);
|
||||||
@@ -434,7 +434,15 @@ void setupDetector() {
|
|||||||
setDelayAfterTrigger(DEFAULT_DELAY);
|
setDelayAfterTrigger(DEFAULT_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int setDefaultDacs() {
|
int resetToDefaultDacs(int hardReset) {
|
||||||
|
// reset defaults to hardcoded defaults
|
||||||
|
if (hardReset) {
|
||||||
|
const int vals[] = DEFAULT_DAC_VALS;
|
||||||
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
defaultDacValues[i] = vals[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// reset dacs to defaults
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ void setupDetector() {
|
|||||||
DAC_MAX_MV);
|
DAC_MAX_MV);
|
||||||
LTC2620_Disable();
|
LTC2620_Disable();
|
||||||
LTC2620_Configure();
|
LTC2620_Configure();
|
||||||
setDefaultDacs();
|
resetToDefaultDacs(0);
|
||||||
|
|
||||||
// altera pll
|
// altera pll
|
||||||
ALTERA_PLL_SetDefines(
|
ALTERA_PLL_SetDefines(
|
||||||
@@ -470,18 +470,60 @@ void setupDetector() {
|
|||||||
setTemperatureEvent(0);
|
setTemperatureEvent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int setDefaultDacs() {
|
int resetToDefaultDacs(int hardReset) {
|
||||||
int ret = OK;
|
LOG(logINFOBLUE, ("Resetting %s to Default Dac values\n",
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
(hardReset == 1 ? "hard" : "")));
|
||||||
|
|
||||||
|
// reset defaults to hardcoded defaults
|
||||||
|
if (hardReset) {
|
||||||
|
const int vals[] = DEFAULT_DAC_VALS;
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
defaultDacValues[i] = vals[i];
|
||||||
if (dacValues[i] != defaultDacValues[i]) {
|
}
|
||||||
ret = FAIL;
|
const int vals_G0[] = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
|
||||||
|
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||||
|
defaultDacValue_G0[i] = vals_G0[i];
|
||||||
|
}
|
||||||
|
const int vals_HG0[] = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
|
||||||
|
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||||
|
defaultDacValue_HG0[i] = vals_HG0[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remember settings
|
||||||
|
enum detectorSettings oldSettings = thisSettings;
|
||||||
|
|
||||||
|
// reset dacs to defaults
|
||||||
|
const int specialDacs[] = SPECIALDACINDEX;
|
||||||
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
int value = defaultDacValues[i];
|
||||||
|
|
||||||
|
for (int j = 0; j < NSPECIALDACS; ++j) {
|
||||||
|
// special dac: replace default value
|
||||||
|
if (specialDacs[j] == i) {
|
||||||
|
switch (oldSettings) {
|
||||||
|
case DYNAMICGAIN:
|
||||||
|
value = defaultDacValue_G0[j];
|
||||||
|
break;
|
||||||
|
case DYNAMICHG0:
|
||||||
|
value = defaultDacValue_HG0[j];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set to defualt
|
||||||
|
setDAC((enum DACINDEX)i, value, 0);
|
||||||
|
if (dacValues[i] != value) {
|
||||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||||
defaultDacValues[i], dacValues[i]));
|
value, dacValues[i]));
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
||||||
@@ -999,7 +1041,7 @@ 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[] = {defaultDacValue_G0, defaultDacValue_HG0};
|
int *specialDacValues[] = {defaultDacValue_G0, defaultDacValue_HG0};
|
||||||
int settList[NUMSETTINGS] = {DYNAMICGAIN, DYNAMICHG0};
|
int settList[] = {DYNAMICGAIN, DYNAMICHG0};
|
||||||
enum detectorSettings sett = UNDEFINED;
|
enum detectorSettings sett = UNDEFINED;
|
||||||
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
||||||
|
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ void setupDetector() {
|
|||||||
DAC_MAX_MV); // has to be before setvchip
|
DAC_MAX_MV); // has to be before setvchip
|
||||||
LTC2620_Disable();
|
LTC2620_Disable();
|
||||||
LTC2620_Configure();
|
LTC2620_Configure();
|
||||||
setDefaultDacs();
|
resetToDefaultDacs(0);
|
||||||
|
|
||||||
// altera pll
|
// altera pll
|
||||||
ALTERA_PLL_SetDefines(PLL_CNTRL_REG, PLL_PARAM_REG,
|
ALTERA_PLL_SetDefines(PLL_CNTRL_REG, PLL_PARAM_REG,
|
||||||
@@ -614,7 +614,15 @@ void updateDataBytes() {
|
|||||||
dataBytes = analogDataBytes;
|
dataBytes = analogDataBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int setDefaultDacs() {
|
int resetToDefaultDacs(int hardReset) {
|
||||||
|
// reset defaults to hardcoded defaults
|
||||||
|
if (hardReset) {
|
||||||
|
const int vals[] = DEFAULT_DAC_VALS;
|
||||||
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
defaultDacValues[i] = vals[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// reset dacs to defaults
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pthread_t pthread_virtual_tid;
|
|||||||
int64_t virtual_currentFrameNumber = 2;
|
int64_t virtual_currentFrameNumber = 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum detectorSettings thisSettings;
|
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||||
sls_detector_module *detectorModules = NULL;
|
sls_detector_module *detectorModules = NULL;
|
||||||
int *detectorChans = NULL;
|
int *detectorChans = NULL;
|
||||||
int *detectorDacs = NULL;
|
int *detectorDacs = NULL;
|
||||||
@@ -450,7 +450,7 @@ void setupDetector() {
|
|||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
|
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
|
||||||
setDefaultDacs();
|
resetToDefaultDacs(0);
|
||||||
setASICDefaults();
|
setASICDefaults();
|
||||||
setADIFDefaults();
|
setADIFDefaults();
|
||||||
|
|
||||||
@@ -527,20 +527,67 @@ void setupDetector() {
|
|||||||
setAllTrimbits(DEFAULT_TRIMBIT_VALUE);
|
setAllTrimbits(DEFAULT_TRIMBIT_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int setDefaultDacs() {
|
int resetToDefaultDacs(int hardReset) {
|
||||||
int ret = OK;
|
LOG(logINFOBLUE, ("Resetting %s to Default Dac values\n",
|
||||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
(hardReset == 1 ? "hard" : "")));
|
||||||
{
|
|
||||||
|
// reset defaults to hardcoded defaults
|
||||||
|
if (hardReset) {
|
||||||
|
const int vals[] = DEFAULT_DAC_VALS;
|
||||||
for (int i = 0; i < NDAC; ++i) {
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
setDAC((enum DACINDEX)i, defaultDacValues[i], 0);
|
defaultDacValues[i] = vals[i];
|
||||||
if (detectorDacs[i] != defaultDacValues[i]) {
|
}
|
||||||
ret = FAIL;
|
const int vals_standard[] = SPECIAL_DEFAULT_STANDARD_DAC_VALS;
|
||||||
|
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||||
|
defaultDacValue_standard[i] = vals_standard[i];
|
||||||
|
}
|
||||||
|
const int vals_fast[] = SPECIAL_DEFAULT_FAST_DAC_VALS;
|
||||||
|
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||||
|
defaultDacValue_fast[i] = vals_fast[i];
|
||||||
|
}
|
||||||
|
const int vals_highgain[] = SPECIAL_DEFAULT_HIGHGAIN_DAC_VALS;
|
||||||
|
for (int i = 0; i < NSPECIALDACS; ++i) {
|
||||||
|
defaultDacValue_highgain[i] = vals_highgain[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remember settings
|
||||||
|
enum detectorSettings oldSettings = thisSettings;
|
||||||
|
|
||||||
|
// reset dacs to defaults
|
||||||
|
const int specialDacs[] = SPECIALDACINDEX;
|
||||||
|
for (int i = 0; i < NDAC; ++i) {
|
||||||
|
int value = defaultDacValues[i];
|
||||||
|
|
||||||
|
for (int j = 0; j < NSPECIALDACS; ++j) {
|
||||||
|
// special dac: replace default value
|
||||||
|
if (specialDacs[j] == i) {
|
||||||
|
switch (oldSettings) {
|
||||||
|
case STANDARD:
|
||||||
|
value = defaultDacValue_standard[j];
|
||||||
|
break;
|
||||||
|
case FAST:
|
||||||
|
value = defaultDacValue_fast[j];
|
||||||
|
break;
|
||||||
|
case HIGHGAIN:
|
||||||
|
value = defaultDacValue_highgain[j];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set to defualt
|
||||||
|
setDAC((enum DACINDEX)i, value, 0);
|
||||||
|
if (detectorDacs[i] != value) {
|
||||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n", i,
|
||||||
defaultDacValues[i], detectorDacs[i]));
|
value, detectorDacs[i]));
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return OK;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett,
|
||||||
@@ -1321,7 +1368,7 @@ void validateSettings() {
|
|||||||
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
|
||||||
int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast,
|
int *specialDacValues[] = {defaultDacValue_standard, defaultDacValue_fast,
|
||||||
defaultDacValue_highgain};
|
defaultDacValue_highgain};
|
||||||
int settList[NUMSETTINGS] = {STANDARD, FAST, HIGHGAIN};
|
int settList[] = {STANDARD, FAST, HIGHGAIN};
|
||||||
|
|
||||||
enum detectorSettings sett = UNDEFINED;
|
enum detectorSettings sett = UNDEFINED;
|
||||||
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ void updateDataBytes();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CHIPTESTBOARDD
|
#ifndef CHIPTESTBOARDD
|
||||||
int setDefaultDacs();
|
int resetToDefaultDacs(int hardReset);
|
||||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval);
|
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval);
|
||||||
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value);
|
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ int reconfigure_udp(int);
|
|||||||
int validate_udp_configuration(int);
|
int validate_udp_configuration(int);
|
||||||
int get_bursts_left(int);
|
int get_bursts_left(int);
|
||||||
int start_readout(int);
|
int start_readout(int);
|
||||||
int set_default_dacs(int);
|
int reset_to_default_dacs(int);
|
||||||
int is_virtual(int);
|
int is_virtual(int);
|
||||||
int get_pattern(int);
|
int get_pattern(int);
|
||||||
int load_default_pattern(int);
|
int load_default_pattern(int);
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ void function_table() {
|
|||||||
flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration;
|
flist[F_VALIDATE_UDP_CONFIG] = &validate_udp_configuration;
|
||||||
flist[F_GET_BURSTS_LEFT] = &get_bursts_left;
|
flist[F_GET_BURSTS_LEFT] = &get_bursts_left;
|
||||||
flist[F_START_READOUT] = &start_readout;
|
flist[F_START_READOUT] = &start_readout;
|
||||||
flist[F_SET_DEFAULT_DACS] = &set_default_dacs;
|
flist[F_RESET_TO_DEFAULT_DACS] = &reset_to_default_dacs;
|
||||||
flist[F_IS_VIRTUAL] = &is_virtual;
|
flist[F_IS_VIRTUAL] = &is_virtual;
|
||||||
flist[F_GET_PATTERN] = &get_pattern;
|
flist[F_GET_PATTERN] = &get_pattern;
|
||||||
flist[F_LOAD_DEFAULT_PATTERN] = &load_default_pattern;
|
flist[F_LOAD_DEFAULT_PATTERN] = &load_default_pattern;
|
||||||
@@ -1627,7 +1627,7 @@ int set_settings(int file_des) {
|
|||||||
validate(&ret, mess, (int)isett, (int)retval, "set settings", DEC);
|
validate(&ret, mess, (int)isett, (int)retval, "set settings", DEC);
|
||||||
#ifdef GOTTHARDD
|
#ifdef GOTTHARDD
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
ret = setDefaultDacs();
|
ret = resetToDefaultDacs(0);
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
strcpy(mess, "Could change settings, but could not set to "
|
strcpy(mess, "Could change settings, but could not set to "
|
||||||
"default dacs\n");
|
"default dacs\n");
|
||||||
@@ -8090,17 +8090,22 @@ int start_readout(int file_des) {
|
|||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_default_dacs(int file_des) {
|
int reset_to_default_dacs(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int arg = -1;
|
||||||
|
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||||
|
return printSocketReadError();
|
||||||
|
LOG(logDEBUG1, ("Resetting dacs to defaults (hard reset: %d)\n", arg));
|
||||||
|
|
||||||
#ifdef CHIPTESTBOARDD
|
#ifdef CHIPTESTBOARDD
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (setDefaultDacs() == FAIL) {
|
if (resetToDefaultDacs(arg) == FAIL) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
strcpy(mess, "Could not set default dacs");
|
sprintf(mess, "Could not %s reset default dacs",
|
||||||
|
(arg == 1 ? "hard" : ""));
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,8 +427,10 @@ class Detector {
|
|||||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||||
defs::detectorSettings sett, Positions pos = {});
|
defs::detectorSettings sett, Positions pos = {});
|
||||||
|
|
||||||
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3] */
|
/** [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Mythen3]
|
||||||
void setDefaultDacs(Positions pos = {});
|
reset to defaults, hardReset will reset to hardcoded defaults on on-board
|
||||||
|
server */
|
||||||
|
void resetToDefaultDacs(const bool hardReset, Positions pos = {});
|
||||||
|
|
||||||
Result<int> getDAC(defs::dacIndex index, bool mV = false,
|
Result<int> getDAC(defs::dacIndex index, bool mV = false,
|
||||||
Positions pos = {}) const;
|
Positions pos = {}) const;
|
||||||
|
|||||||
@@ -1095,6 +1095,37 @@ std::string CmdProxy::DacValues(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CmdProxy::ResetDacs(int action) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << cmd << ' ';
|
||||||
|
if (action == defs::HELP_ACTION) {
|
||||||
|
os << "[(optional) hard] "
|
||||||
|
"\n\t[Eiger][Jungfrau][Gotthard][Moench][Gotthard2]["
|
||||||
|
"Mythen3]Reset dac values to the defaults. A 'hard' optional "
|
||||||
|
"reset will reset the dacs to the hardcoded defaults in on-board "
|
||||||
|
"detector server."
|
||||||
|
<< '\n';
|
||||||
|
} else if (action == defs::GET_ACTION) {
|
||||||
|
throw sls::RuntimeError("Cannot get");
|
||||||
|
} else if (action == defs::PUT_ACTION) {
|
||||||
|
bool hardReset = false;
|
||||||
|
if (args.size() == 1) {
|
||||||
|
if (args[0] != "hard") {
|
||||||
|
throw sls::RuntimeError("Unknown argument " + args[0] +
|
||||||
|
". Did you mean hard?");
|
||||||
|
}
|
||||||
|
hardReset = true;
|
||||||
|
} else if (args.size() > 1) {
|
||||||
|
WrongNumberOfParameters(1);
|
||||||
|
}
|
||||||
|
det->resetToDefaultDacs(hardReset, std::vector<int>{det_id});
|
||||||
|
os << "successful\n";
|
||||||
|
} else {
|
||||||
|
throw sls::RuntimeError("Unknown action");
|
||||||
|
}
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
std::string CmdProxy::DefaultDac(int action) {
|
std::string CmdProxy::DefaultDac(int action) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
@@ -1111,10 +1142,12 @@ std::string CmdProxy::DefaultDac(int action) {
|
|||||||
if (args.size() == 2) {
|
if (args.size() == 2) {
|
||||||
auto t = det->getDefaultDac(
|
auto t = det->getDefaultDac(
|
||||||
StringTo<defs::dacIndex>(args[0]),
|
StringTo<defs::dacIndex>(args[0]),
|
||||||
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]));
|
sls::StringTo<slsDetectorDefs::detectorSettings>(args[1]),
|
||||||
|
std::vector<int>{det_id});
|
||||||
os << args[0] << ' ' << args[1] << ' ' << OutString(t) << '\n';
|
os << args[0] << ' ' << args[1] << ' ' << OutString(t) << '\n';
|
||||||
} else {
|
} else {
|
||||||
auto t = det->getDefaultDac(StringTo<defs::dacIndex>(args[0]));
|
auto t = det->getDefaultDac(StringTo<defs::dacIndex>(args[0]),
|
||||||
|
std::vector<int>{det_id});
|
||||||
os << args[0] << ' ' << OutString(t) << '\n';
|
os << args[0] << ' ' << OutString(t) << '\n';
|
||||||
}
|
}
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
@@ -1125,7 +1158,8 @@ std::string CmdProxy::DefaultDac(int action) {
|
|||||||
if (args.size() == 3) {
|
if (args.size() == 3) {
|
||||||
det->setDefaultDac(
|
det->setDefaultDac(
|
||||||
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
|
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
|
||||||
sls::StringTo<slsDetectorDefs::detectorSettings>(args[2]));
|
sls::StringTo<slsDetectorDefs::detectorSettings>(args[2]),
|
||||||
|
std::vector<int>{det_id});
|
||||||
os << args[0] << ' ' << args[2] << ' ' << args[1] << '\n';
|
os << args[0] << ' ' << args[2] << ' ' << args[1] << '\n';
|
||||||
} else {
|
} else {
|
||||||
det->setDefaultDac(StringTo<defs::dacIndex>(args[0]),
|
det->setDefaultDac(StringTo<defs::dacIndex>(args[0]),
|
||||||
|
|||||||
@@ -671,6 +671,8 @@ class CmdProxy {
|
|||||||
{"vipre_cds", "dac"},
|
{"vipre_cds", "dac"},
|
||||||
{"ibias_sfp", "dac"},
|
{"ibias_sfp", "dac"},
|
||||||
|
|
||||||
|
{"defaultdacs", "resetdacs"},
|
||||||
|
|
||||||
/* acquisition */
|
/* acquisition */
|
||||||
{"busy", "clearbusy"},
|
{"busy", "clearbusy"},
|
||||||
{"receiver", "rx_status"},
|
{"receiver", "rx_status"},
|
||||||
@@ -816,7 +818,7 @@ class CmdProxy {
|
|||||||
{"dac", &CmdProxy::Dac},
|
{"dac", &CmdProxy::Dac},
|
||||||
{"daclist", &CmdProxy::daclist},
|
{"daclist", &CmdProxy::daclist},
|
||||||
{"dacvalues", &CmdProxy::DacValues},
|
{"dacvalues", &CmdProxy::DacValues},
|
||||||
{"defaultdacs", &CmdProxy::defaultdacs},
|
{"resetdacs", &CmdProxy::ResetDacs},
|
||||||
{"defaultdac", &CmdProxy::DefaultDac},
|
{"defaultdac", &CmdProxy::DefaultDac},
|
||||||
|
|
||||||
/* on chip dacs */
|
/* on chip dacs */
|
||||||
@@ -1095,6 +1097,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 ResetDacs(int action);
|
||||||
std::string DefaultDac(int action);
|
std::string DefaultDac(int action);
|
||||||
/* acquisition */
|
/* acquisition */
|
||||||
std::string ReceiverStatus(int action);
|
std::string ReceiverStatus(int action);
|
||||||
@@ -1383,10 +1386,6 @@ class CmdProxy {
|
|||||||
daclist, getDacList,
|
daclist, getDacList,
|
||||||
"\n\tGets the list of commands for every dac for this detector.");
|
"\n\tGets the list of commands for every dac for this detector.");
|
||||||
|
|
||||||
EXECUTE_SET_COMMAND(defaultdacs, setDefaultDacs,
|
|
||||||
"\n\t[Eiger][Jungfrau][Gotthard][Moench][Gotthard2]["
|
|
||||||
"Mythen3]Sets default dacs on to the detector.");
|
|
||||||
|
|
||||||
/* on chip dacs */
|
/* on chip dacs */
|
||||||
INTEGER_USER_IND_COMMAND(
|
INTEGER_USER_IND_COMMAND(
|
||||||
vchip_comp_fe, getOnChipDAC, setOnChipDAC, StringTo<int>,
|
vchip_comp_fe, getOnChipDAC, setOnChipDAC, StringTo<int>,
|
||||||
|
|||||||
@@ -650,8 +650,8 @@ void Detector::setDefaultDac(defs::dacIndex index, int defaultValue,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Detector::setDefaultDacs(Positions pos) {
|
void Detector::resetToDefaultDacs(const bool hardReset, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setDefaultDacs, pos);
|
pimpl->Parallel(&Module::resetToDefaultDacs, pos, hardReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getDAC(defs::dacIndex index, bool mV,
|
Result<int> Detector::getDAC(defs::dacIndex index, bool mV,
|
||||||
|
|||||||
@@ -629,7 +629,10 @@ void Module::setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
|||||||
return sendToDetector(F_SET_DEFAULT_DAC, args, nullptr);
|
return sendToDetector(F_SET_DEFAULT_DAC, args, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setDefaultDacs() { sendToDetector(F_SET_DEFAULT_DACS); }
|
void Module::resetToDefaultDacs(const bool hardReset) {
|
||||||
|
sendToDetector(F_RESET_TO_DEFAULT_DACS, static_cast<int>(hardReset),
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void Module::setDAC(int val, dacIndex index, bool mV) {
|
void Module::setDAC(int val, dacIndex index, bool mV) {
|
||||||
int args[]{static_cast<int>(index), static_cast<int>(mV), val};
|
int args[]{static_cast<int>(index), static_cast<int>(mV), val};
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
slsDetectorDefs::detectorSettings sett);
|
slsDetectorDefs::detectorSettings sett);
|
||||||
void setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
void setDefaultDac(slsDetectorDefs::dacIndex index, int defaultValue,
|
||||||
defs::detectorSettings sett);
|
defs::detectorSettings sett);
|
||||||
void setDefaultDacs();
|
void resetToDefaultDacs(const bool hardReset);
|
||||||
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);
|
||||||
bool getPowerChip() const;
|
bool getPowerChip() const;
|
||||||
|
|||||||
@@ -227,6 +227,12 @@ TEST_CASE("settings", "[.cmd]") {
|
|||||||
REQUIRE_THROWS(proxy.Call("settings", {it}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("settings", {it}, -1, PUT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
if (prev_val[i] != defs::UNDEFINED &&
|
||||||
|
prev_val[i] != defs::UNINITIALIZED) {
|
||||||
|
det.setSettings(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("threshold", "[.cmd]") {
|
TEST_CASE("threshold", "[.cmd]") {
|
||||||
@@ -1466,16 +1472,25 @@ TEST_CASE("defaultdac", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("defaultdacs", "[.cmd]") {
|
TEST_CASE("resetdacs", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type != defs::CHIPTESTBOARD) {
|
if (det_type != defs::CHIPTESTBOARD) {
|
||||||
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, GET));
|
auto prev_val = det.getSettings();
|
||||||
REQUIRE_NOTHROW(proxy.Call("defaultdacs", {}, -1, PUT));
|
|
||||||
|
REQUIRE_THROWS(proxy.Call("resetdacs", {}, -1, GET));
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("resetdacs", {}, -1, PUT));
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("resetdacs", {"hard"}, -1, PUT));
|
||||||
|
|
||||||
|
// settings should not change especially for jungfrau and m3
|
||||||
|
auto next_val = det.getSettings();
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
REQUIRE(prev_val[i] == next_val[i]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("resetdacs", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("defaultdacs", {}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("resetdacs", {}, -1, PUT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ enum detFuncs {
|
|||||||
F_VALIDATE_UDP_CONFIG,
|
F_VALIDATE_UDP_CONFIG,
|
||||||
F_GET_BURSTS_LEFT,
|
F_GET_BURSTS_LEFT,
|
||||||
F_START_READOUT,
|
F_START_READOUT,
|
||||||
F_SET_DEFAULT_DACS,
|
F_RESET_TO_DEFAULT_DACS,
|
||||||
F_IS_VIRTUAL,
|
F_IS_VIRTUAL,
|
||||||
F_GET_PATTERN,
|
F_GET_PATTERN,
|
||||||
F_LOAD_DEFAULT_PATTERN,
|
F_LOAD_DEFAULT_PATTERN,
|
||||||
@@ -555,7 +555,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_VALIDATE_UDP_CONFIG: return "F_VALIDATE_UDP_CONFIG";
|
case F_VALIDATE_UDP_CONFIG: return "F_VALIDATE_UDP_CONFIG";
|
||||||
case F_GET_BURSTS_LEFT: return "F_GET_BURSTS_LEFT";
|
case F_GET_BURSTS_LEFT: return "F_GET_BURSTS_LEFT";
|
||||||
case F_START_READOUT: return "F_START_READOUT";
|
case F_START_READOUT: return "F_START_READOUT";
|
||||||
case F_SET_DEFAULT_DACS: return "F_SET_DEFAULT_DACS";
|
case F_RESET_TO_DEFAULT_DACS: return "F_RESET_TO_DEFAULT_DACS";
|
||||||
case F_IS_VIRTUAL: return "F_IS_VIRTUAL";
|
case F_IS_VIRTUAL: return "F_IS_VIRTUAL";
|
||||||
case F_GET_PATTERN: return "F_GET_PATTERN";
|
case F_GET_PATTERN: return "F_GET_PATTERN";
|
||||||
case F_LOAD_DEFAULT_PATTERN: return "F_LOAD_DEFAULT_PATTERN";
|
case F_LOAD_DEFAULT_PATTERN: return "F_LOAD_DEFAULT_PATTERN";
|
||||||
|
|||||||
Reference in New Issue
Block a user