jungfrau: special settings and configure chip if powered on (1.1 chip)

This commit is contained in:
maliakal_d 2021-07-28 13:34:32 +02:00
parent 41bbe4e3cf
commit f8b14c694d
4 changed files with 45 additions and 13 deletions

View File

@ -883,18 +883,21 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
if (sett == UNINITIALIZED)
return thisSettings;
int *specialDacValues[] = 0;
// set settings
switch (sett) {
case DYNAMICGAIN:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
LOG(logINFO,
("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
specialDacValues = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
break;
case DYNAMICHG0:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL);
LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n",
bus_r(DAQ_REG)));
specialDacValues = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
break;
/*
case FIXGAIN1:
@ -930,6 +933,17 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
thisSettings = sett;
// set special dacs to defined values
int *specialDacs[] = {SPECIALDACINDEX};
for (int i = 0; i < NSPECIALDACS; ++i) {
setDAC(specialDacs[i], specialDacValues[i], 0);
}
// if chip 1.1, and power chip on, configure chip
if (getChipVersion() == 11 && powerChip(-1)) {
configureChip();
}
return getSettings();
}

View File

@ -63,9 +63,10 @@ enum DACINDEX {
420 /* J_VREF_COMP */ \
};
#define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VB_COMP, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS {};
#define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VB_COMP, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS {1000, 500, 400};
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS {1500, 550, 450};
enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };

View File

@ -1201,8 +1201,7 @@ class CmdProxy {
"verylowgain, g1_hg, g1_lg, g2_hc_hg, g2_hc_lg, "
"g2_lc_hg, g2_lc_lg, g4_hg, g4_lg]"
"\n\t Detector Settings"
"\n\t[Jungfrau] - [dynamicgain | dynamichg0 | fixgain1 | "
"fixgain2 | forceswitchg1 | forceswitchg2]"
"\n\t[Jungfrau] - [dynamicgain | dynamichg0]"
"\n\t[Gotthard] - [dynamicgain | highgain | lowgain | "
"mediumgain | veryhighgain]"
"\n\t[Gotthard2] - [dynamicgain | fixgain1 | fixgain2]"

View File

@ -142,15 +142,34 @@ TEST_CASE("settings", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
std::vector<std::string> allSett;
allSett.push_back("standard");
allSett.push_back("fast");
allSett.push_back("highgain");
allSett.push_back("dynamicgain");
allSett.push_back("lowgain");
allSett.push_back("mediumgain");
allSett.push_back("veryhighgain");
allSett.push_back("dynamichg0");
allSett.push_back("fixgain1");
allSett.push_back("fixgain2");
allSett.push_back("verylowgain");
allSett.push_back("g1_hg");
allSett.push_back("g1_lg");
allSett.push_back("g2_hc_hg");
allSett.push_back("g2_hc_lg");
allSett.push_back("g2_lc_hg");
allSett.push_back("g2_lc_lg");
allSett.push_back("g4_hg");
allSett.push_back("g4_lg");
allSett.push_back("forceswitchg1");
allSett.push_back("forceswitchg2");
std::vector<std::string> sett;
switch (det_type) {
case defs::JUNGFRAU:
sett.push_back("dynamicgain");
sett.push_back("dynamichg0");
sett.push_back("fixgain1");
sett.push_back("fixgain2");
sett.push_back("forceswitchg1");
sett.push_back("forceswitchg2");
break;
case defs::GOTTHARD:
sett.push_back("highgain");
@ -203,10 +222,9 @@ TEST_CASE("settings", "[.cmd]") {
REQUIRE(oss.str() == "settings " + it + "\n");
}
}
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});
for (auto &it : allSett) {
if (std::find(sett.begin(), sett.end(), it) == sett.end()) {
REQUIRE_THROWS(proxy.Call("settings", {it}, -1, PUT));
}
}
}