updates on servers (mainly virtual): indices, dbit clock not allowed for moench anymore

This commit is contained in:
maliakal_d 2020-03-31 16:54:35 +02:00
parent 03af145ee8
commit f2dd146e56
14 changed files with 625 additions and 578 deletions

View File

@ -1386,12 +1386,6 @@ int getADC(enum ADCINDEX ind){
int setHighVoltage(int val){ int setHighVoltage(int val){
#ifdef VIRTUAL
if (val >= 0)
highvoltage = val;
return highvoltage;
#endif
// setting hv // setting hv
if (val >= 0) { if (val >= 0) {
LOG(logINFO, ("Setting High voltage: %d V\n", val)); LOG(logINFO, ("Setting High voltage: %d V\n", val));
@ -1400,7 +1394,7 @@ int setHighVoltage(int val){
// switch to external high voltage // switch to external high voltage
bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_MSK)); bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_MSK));
MAX1932_Set(val); MAX1932_Set(&val);
// switch on internal high voltage, if set // switch on internal high voltage, if set
if (val > 0) if (val > 0)

View File

@ -388,7 +388,6 @@ void setupDetector() {
} }
#ifndef VIRTUAL
// pll defines // pll defines
ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, PLL_RESET_REG, PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ); ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, PLL_RESET_REG, PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ);
ALTERA_PLL_C10_ResetPLL(READOUT_PLL); ALTERA_PLL_C10_ResetPLL(READOUT_PLL);
@ -399,7 +398,6 @@ void setupDetector() {
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC); LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC);
// on chip dacs // on chip dacs
ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME); ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME);
#endif
setTimingSource(DEFAULT_TIMING_SOURCE); setTimingSource(DEFAULT_TIMING_SOURCE);
// Default values // Default values

View File

@ -921,16 +921,10 @@ int getADC(enum ADCINDEX ind){
int setHighVoltage(int val){ int setHighVoltage(int val){
#ifdef VIRTUAL
if (val >= 0)
highvoltage = val;
return highvoltage;
#endif
// setting hv // setting hv
if (val >= 0) { if (val >= 0) {
LOG(logINFO, ("Setting High voltage: %d V", val)); LOG(logINFO, ("Setting High voltage: %d V", val));
MAX1932_Set(val); MAX1932_Set(&val);
highvoltage = val; highvoltage = val;
} }
return highvoltage; return highvoltage;

View File

@ -1049,12 +1049,6 @@ void setVLimit(int l) {
int setHighVoltage(int val){ int setHighVoltage(int val){
#ifdef VIRTUAL
if (val >= 0)
highvoltage = val;
return highvoltage;
#endif
// setting hv // setting hv
if (val >= 0) { if (val >= 0) {
LOG(logINFO, ("Setting High voltage: %d V\n", val)); LOG(logINFO, ("Setting High voltage: %d V\n", val));
@ -1063,7 +1057,7 @@ int setHighVoltage(int val){
// switch to external high voltage // switch to external high voltage
bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_MSK)); bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_MSK));
MAX1932_Set(val); MAX1932_Set(&val);
// switch on internal high voltage, if set // switch on internal high voltage, if set
if (val > 0) if (val > 0)

View File

@ -349,7 +349,6 @@ void setupDetector() {
} }
} }
#ifndef VIRTUAL
// pll defines // pll defines
ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, PLL_RESET_REG, PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ); ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, PLL_RESET_REG, PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ);
ALTERA_PLL_C10_ResetPLL(READOUT_PLL); ALTERA_PLL_C10_ResetPLL(READOUT_PLL);
@ -358,7 +357,6 @@ void setupDetector() {
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME); DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
//dac //dac
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC); LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC);
#endif
resetCore(); resetCore();
resetPeripheral(); resetPeripheral();

View File

@ -21,11 +21,11 @@ void MAX1932_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t d
void MAX1932_Disable(); void MAX1932_Disable();
/** /**
* Set value * Set value (value is updated to correct range)
* @param val value to set * @param val pointer to value to set
* @return OK or FAIL * @return OK or FAIL
*/ */
int MAX1932_Set (int val) ; int MAX1932_Set (int* val) ;

View File

@ -42,9 +42,7 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
LOG(logDEBUG2, ("\t]\n")); LOG(logDEBUG2, ("\t]\n"));
} }
#ifdef VIRTUAL #ifndef VIRTUAL
return OK;
#endif
int fd=open(fname, O_RDWR); int fd=open(fname, O_RDWR);
if (fd == -1) { if (fd == -1) {
LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index)); LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index));
@ -66,6 +64,7 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
return FAIL; return FAIL;
} }
close(fd); close(fd);
#endif
return OK; return OK;
} }

View File

@ -36,6 +36,7 @@ int DAC6571_Set (int val) {
LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue)); LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue));
#ifndef VIRTUAL
//open file //open file
FILE* fd=fopen(DAC6571_DriverFileName,"w"); FILE* fd=fopen(DAC6571_DriverFileName,"w");
if (fd==NULL) { if (fd==NULL) {
@ -45,6 +46,7 @@ int DAC6571_Set (int val) {
//convert to string, add 0 and write to file //convert to string, add 0 and write to file
fprintf(fd, "%d\n", dacvalue); fprintf(fd, "%d\n", dacvalue);
fclose(fd); fclose(fd);
#endif
return OK; return OK;
} }

View File

@ -72,6 +72,8 @@ int LTC2620_D_SetDACValue (int dacnum, int val, int mV, char* dacname, int* dacv
if ( (*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) { if ( (*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) {
LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n",dacnum, dacname, *dacval, dacmV)); LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n",dacnum, dacname, *dacval, dacmV));
#ifndef VIRTUAL
char fname[MAX_STR_LENGTH]; char fname[MAX_STR_LENGTH];
strcpy(fname, LTC2620_D_DriverFileName); strcpy(fname, LTC2620_D_DriverFileName);
char temp[20]; char temp[20];
@ -89,6 +91,8 @@ int LTC2620_D_SetDACValue (int dacnum, int val, int mV, char* dacname, int* dacv
//convert to string, add 0 and write to file //convert to string, add 0 and write to file
fprintf(fd, "%d\n", *dacval); fprintf(fd, "%d\n", *dacval);
fclose(fd); fclose(fd);
#endif
} }
return OK; return OK;
} }

View File

@ -43,33 +43,33 @@ void MAX1932_Disable() {
& ~(MAX1932_DigMask)); & ~(MAX1932_DigMask));
} }
int MAX1932_Set (int val) { int MAX1932_Set (int* val) {
LOG(logDEBUG1, ("Setting high voltage to %d\n", val)); LOG(logDEBUG1, ("Setting high voltage to %d\n", *val));
if (val < 0) if (*val < 0)
return FAIL; return FAIL;
int dacvalue = 0; int dacvalue = 0;
// limit values (normally < 60 => 0 (off)) // limit values (normally < 60 => 0 (off))
if (val < MAX1932_MinVoltage) { if (*val < MAX1932_MinVoltage) {
dacvalue = MAX1932_POWER_OFF_DAC_VAL; dacvalue = MAX1932_POWER_OFF_DAC_VAL;
val = 0; *val = 0;
} }
// limit values (normally > 200 => 0x1 (max)) // limit values (normally > 200 => 0x1 (max))
else if (val > MAX1932_MaxVoltage) { else if (*val > MAX1932_MaxVoltage) {
dacvalue = MAX1932_MAX_DAC_VAL; dacvalue = MAX1932_MAX_DAC_VAL;
val = MAX1932_MaxVoltage; *val = MAX1932_MaxVoltage;
} }
// convert value // convert value
else { else {
// no failure in conversion as limits handled (range from 0x1 to 0xFF) // no failure in conversion as limits handled (range from 0x1 to 0xFF)
ConvertToDifferentRange(MAX1932_MinVoltage, MAX1932_MaxVoltage, ConvertToDifferentRange(MAX1932_MinVoltage, MAX1932_MaxVoltage,
MAX1932_MIN_DAC_VAL, MAX1932_MAX_DAC_VAL, MAX1932_MIN_DAC_VAL, MAX1932_MAX_DAC_VAL,
val, &dacvalue); *val, &dacvalue);
dacvalue &= MAX1932_HV_DATA_MSK; dacvalue &= MAX1932_HV_DATA_MSK;
} }
LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue)); LOG(logINFO, ("\t%dV (dacval %d)\n", *val, dacvalue));
serializeToSPI(MAX1932_Reg, dacvalue, MAX1932_CsMask, MAX1932_HV_NUMBITS, serializeToSPI(MAX1932_Reg, dacvalue, MAX1932_CsMask, MAX1932_HV_NUMBITS,
MAX1932_ClkMask, MAX1932_DigMask, MAX1932_DigOffset, 0); MAX1932_ClkMask, MAX1932_DigMask, MAX1932_DigOffset, 0);
return OK; return OK;

View File

@ -5804,9 +5804,11 @@ int set_clock_frequency(int file_des) {
case ADC_CLOCK: case ADC_CLOCK:
c = ADC_CLK; c = ADC_CLK;
break; break;
#ifdef CHIPTESTBOARDD
case DBIT_CLOCK: case DBIT_CLOCK:
c = DBIT_CLK; c = DBIT_CLK;
break; break;
#endif
case RUN_CLOCK: case RUN_CLOCK:
c = RUN_CLK; c = RUN_CLK;
break; break;
@ -5860,9 +5862,11 @@ int get_clock_frequency(int file_des) {
case ADC_CLOCK: case ADC_CLOCK:
c = ADC_CLK; c = ADC_CLK;
break; break;
#ifdef CHIPTESTBOARDD
case DBIT_CLOCK: case DBIT_CLOCK:
c = DBIT_CLK; c = DBIT_CLK;
break; break;
#endif
case RUN_CLOCK: case RUN_CLOCK:
c = RUN_CLK; c = RUN_CLK;
break; break;
@ -5916,14 +5920,14 @@ int set_clock_phase(int file_des) {
c = ADC_CLK; c = ADC_CLK;
break; break;
#endif #endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD) #if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
case DBIT_CLOCK: case DBIT_CLOCK:
c = DBIT_CLK; c = DBIT_CLK;
break; break;
#endif #endif
default: default:
#if defined(GOTTHARD2D) || defined(MYTHEN3D) #if defined(GOTTHARD2D) || defined(MYTHEN3D)
if (c < NUM_CLOCKS) { if (ind < NUM_CLOCKS) {
c = (enum CLKINDEX)ind; c = (enum CLKINDEX)ind;
break; break;
} }
@ -5995,7 +5999,7 @@ int get_clock_phase(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0) if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError(); return printSocketReadError();
LOG(logDEBUG1, ("Getting clock (%d) phase %s \n", args[0], (args[1] == 0 ? "" : "in degrees"))); LOG(logINFOBLUE, ("Getting clock (%d) phase %s \n", args[0], (args[1] == 0 ? "" : "in degrees")));
#if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(JUNGFRAUD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D) #if !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && !defined(JUNGFRAUD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D)
functionNotImplemented(); functionNotImplemented();
@ -6009,14 +6013,17 @@ int get_clock_phase(int file_des) {
case ADC_CLOCK: case ADC_CLOCK:
c = ADC_CLK; c = ADC_CLK;
break; break;
#endif
#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
case DBIT_CLOCK: case DBIT_CLOCK:
c = DBIT_CLK; c = DBIT_CLK;
break; break;
#endif #endif
default: default:
#if defined(GOTTHARD2D) || defined(MYTHEN3D) #if defined(GOTTHARD2D) || defined(MYTHEN3D)
if (c < NUM_CLOCKS) { if (ind < NUM_CLOCKS) {
c = (enum CLKINDEX)ind; c = (enum CLKINDEX)ind;
LOG(logINFOBLUE, ("NUMclocks:%d c:%d\n", NUM_CLOCKS, c));
break; break;
} }
#endif #endif
@ -6053,13 +6060,15 @@ int get_max_clock_phase_shift(int file_des) {
case ADC_CLOCK: case ADC_CLOCK:
c = ADC_CLK; c = ADC_CLK;
break; break;
#endif
#if defined(CHIPTESTBOARDD) || defined(JUNGFRAUD)
case DBIT_CLOCK: case DBIT_CLOCK:
c = DBIT_CLK; c = DBIT_CLK;
break; break;
#endif #endif
default: default:
#if defined(GOTTHARD2D) || defined(MYTHEN3D) #if defined(GOTTHARD2D) || defined(MYTHEN3D)
if (c < NUM_CLOCKS) { if (arg < NUM_CLOCKS) {
c = (enum CLKINDEX)arg; c = (enum CLKINDEX)arg;
break; break;
} }
@ -6104,7 +6113,7 @@ int set_clock_divider(int file_des) {
default: default:
// any clock index // any clock index
#if defined(GOTTHARD2D) || defined(MYTHEN3D) #if defined(GOTTHARD2D) || defined(MYTHEN3D)
if (c < NUM_CLOCKS) { if (ind < NUM_CLOCKS) {
c = (enum CLKINDEX)ind; c = (enum CLKINDEX)ind;
break; break;
} }
@ -6187,7 +6196,7 @@ int get_clock_divider(int file_des) {
#endif #endif
default: default:
#if defined(GOTTHARD2D) || defined(MYTHEN3D) #if defined(GOTTHARD2D) || defined(MYTHEN3D)
if (c < NUM_CLOCKS) { if (arg < NUM_CLOCKS) {
c = (enum CLKINDEX)arg; c = (enum CLKINDEX)arg;
break; break;
} }
@ -6272,9 +6281,11 @@ int get_pipeline(int file_des) {
case ADC_CLOCK: case ADC_CLOCK:
c = ADC_CLK; c = ADC_CLK;
break; break;
#ifdef CHIPTESTBOARDD
case DBIT_CLOCK: case DBIT_CLOCK:
c = DBIT_CLK; c = DBIT_CLK;
break; break;
#endif
default: default:
modeNotImplemented("clock index (pipeline get)", arg); modeNotImplemented("clock index (pipeline get)", arg);
break; break;

View File

@ -402,37 +402,45 @@ std::string CmdProxy::Adcphase(int action) {
"resets adcphase and sets it to previous values.\n\t[Gotthard] " "resets adcphase and sets it to previous values.\n\t[Gotthard] "
"Relative phase shift" "Relative phase shift"
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) {
Result<int> t;
if (args.empty()) {
t = det->getADCPhase({det_id});
os << OutString(t) << '\n';
} else if (args.size() == 1) {
if (args[0] != "deg") {
throw sls::RuntimeError("Unknown adcphase argument " + args[0] +
". Did you mean deg?");
}
t = det->getADCPhaseInDegrees({det_id});
os << OutString(t) << " deg\n";
} else {
WrongNumberOfParameters(0);
}
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
det->setADCPhase(StringTo<int>(args[0]), {det_id});
os << args.front() << '\n';
} else if (args.size() == 2) {
if (args[1] != "deg") {
throw sls::RuntimeError("Unknown adcphase 2nd argument " +
args[1] + ". Did you mean deg?");
}
det->setADCPhaseInDegrees(StringTo<int>(args[0]), {det_id});
os << args[0] << args[1] << '\n';
} else {
WrongNumberOfParameters(1);
}
} else { } else {
throw sls::RuntimeError("Unknown action"); auto det_type = det->getDetectorType().squash(defs::GENERIC);
if (det_type == defs::EIGER ||
det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2) {
throw sls::RuntimeError("adcphase not implemented for this detector");
}
if (action == defs::GET_ACTION) {
Result<int> t;
if (args.empty()) {
t = det->getADCPhase({det_id});
os << OutString(t) << '\n';
} else if (args.size() == 1) {
if (args[0] != "deg") {
throw sls::RuntimeError("Unknown adcphase argument " + args[0] +
". Did you mean deg? ");
}
t = det->getADCPhaseInDegrees({det_id});
os << OutString(t) << " deg\n";
} else {
WrongNumberOfParameters(0);
}
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
det->setADCPhase(StringTo<int>(args[0]), {det_id} );
os << args.front() << '\n';
} else if (args.size() == 2) {
if (args[1] != "deg") {
throw sls::RuntimeError("Unknown adcphase 2nd argument " +
args[1] + ". Did you mean deg?");
}
det->setADCPhaseInDegrees(StringTo<int>(args[0]) , {det_id});
os << args[0] << " " << args[1] << '\n';
} else {
WrongNumberOfParameters(1);
}
} else {
throw sls::RuntimeError("Unknown action");
}
} }
return os.str(); return os.str();
} }
@ -446,37 +454,45 @@ std::string CmdProxy::Dbitphase(int action) {
"shift in degrees. \n\t[Ctb]Changing dbitclk also resets dbitphase and " "shift in degrees. \n\t[Ctb]Changing dbitclk also resets dbitphase and "
"sets to previous values." "sets to previous values."
<< '\n'; << '\n';
} else if (action == defs::GET_ACTION) {
Result<int> t;
if (args.empty()) {
t = det->getDBITPhase({det_id});
os << OutString(t) << '\n';
} else if (args.size() == 1) {
if (args[0] != "deg") {
throw sls::RuntimeError("Unknown dbitphase argument " +
args[0] + ". Did you mean deg?");
}
t = det->getDBITPhaseInDegrees({det_id});
os << OutString(t) << " deg\n";
} else {
WrongNumberOfParameters(0);
}
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
det->setDBITPhase(StringTo<int>(args[0]), {det_id});
os << args.front() << '\n';
} else if (args.size() == 2) {
if (args[1] != "deg") {
throw sls::RuntimeError("Unknown dbitphase 2nd argument " +
args[1] + ". Did you mean deg?");
}
det->setDBITPhaseInDegrees(StringTo<int>(args[0]), {det_id});
os << args[0] << args[1] << '\n';
} else {
WrongNumberOfParameters(1);
}
} else { } else {
throw sls::RuntimeError("Unknown action"); auto det_type = det->getDetectorType().squash(defs::GENERIC);
if (det_type == defs::EIGER ||
det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2) {
throw sls::RuntimeError("dbitphase not implemented for this detector");
}
if (action == defs::GET_ACTION) {
Result<int> t;
if (args.empty()) {
t = det->getDBITPhase({det_id});
os << OutString(t) << '\n';
} else if (args.size() == 1) {
if (args[0] != "deg") {
throw sls::RuntimeError("Unknown dbitphase argument " +
args[0] + ". Did you mean deg? ");
}
t = det->getDBITPhaseInDegrees({det_id});
os << OutString(t) << " deg\n";
} else {
WrongNumberOfParameters(0);
}
} else if (action == defs::PUT_ACTION) {
if (args.size() == 1) {
det->setDBITPhase(StringTo<int>(args[0]), {det_id});
os << args.front() << '\n';
} else if (args.size() == 2) {
if (args[1] != "deg") {
throw sls::RuntimeError("Unknown dbitphase 2nd argument " +
args[1] + ". Did you mean deg? ");
}
det->setDBITPhaseInDegrees(StringTo<int>(args[0]), {det_id} );
os << args[0] << " " << args[1] << '\n';
} else {
WrongNumberOfParameters(1);
}
} else {
throw sls::RuntimeError("Unknown action");
}
} }
return os.str(); return os.str();
} }
@ -538,7 +554,7 @@ std::string CmdProxy::ClockPhase(int action) {
} }
auto t = auto t =
det->getClockPhaseinDegrees(StringTo<int>(args[0]), {det_id}); det->getClockPhaseinDegrees(StringTo<int>(args[0]), {det_id});
os << OutString(t) << '\n'; os << OutString(t) << " deg\n";
} else { } else {
WrongNumberOfParameters(1); WrongNumberOfParameters(1);
} }
@ -554,7 +570,7 @@ std::string CmdProxy::ClockPhase(int action) {
} }
det->setClockPhaseinDegrees(StringTo<int>(args[0]), det->setClockPhaseinDegrees(StringTo<int>(args[0]),
StringTo<int>(args[1]), {det_id}); StringTo<int>(args[1]), {det_id});
os << args[1] << '\n'; os << args[1] << " " << args[2] << '\n';
} else { } else {
WrongNumberOfParameters(1); WrongNumberOfParameters(1);
} }

View File

@ -87,89 +87,6 @@ TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmd][.dacs]") {
} }
} }
TEST_CASE("clkfreq", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(proxy.Call("clkfreq", {"0", "2"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("clkfreq", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("clkfreq", {"7"}, -1, GET));
auto value = det.getClockFrequency(0).squash(-1);
std::ostringstream oss_set, oss_get;
proxy.Call("clkfreq", {"0"}, -1, GET, oss_get);
REQUIRE(oss_get.str() == "clkfreq " + std::to_string(value) + "\n");
} else {
REQUIRE_THROWS(proxy.Call("clkfreq", {"0"}, -1, GET));
}
}
TEST_CASE("clkphase", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(proxy.Call("clkphase", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("clkphase", {"7"}, -1, GET));
REQUIRE_THROWS(proxy.Call("clkphase", {"4"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("clkphase", {"7", "4"}, -1, PUT));
auto previous = det.getClockFrequency(0).squash(-1);
auto previous_string = std::to_string(previous);
std::ostringstream oss_set, oss_get, oss_get2;
proxy.Call("clkfreq", {"0", previous_string}, -1, PUT, oss_set);
REQUIRE(oss_set.str() == "clkfreq" + previous_string + "\n");
proxy.Call("clkfreq", {"0"}, -1, GET, oss_get);
REQUIRE(oss_get.str() == "clkfreq " + previous_string + "\n");
REQUIRE_NOTHROW(proxy.Call("clkphase", {"0", "deg"}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("clkphase", {"0"}, -1, GET));
}
}
TEST_CASE("clkdiv", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(proxy.Call("clkdiv", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("clkdiv", {"7"}, -1, GET));
REQUIRE_THROWS(proxy.Call("clkdiv", {"7", "4"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("clkdiv", {"7", "4"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("clkdiv", {"0", "1"}, -1, PUT));
auto previous = det.getClockDivider(0).squash(-1);
auto previous_string = std::to_string(previous);
std::ostringstream oss_set, oss_get;
proxy.Call("clkdiv", {"0", previous_string}, -1, PUT, oss_set);
REQUIRE(oss_set.str() == "clkdiv" + previous_string + "\n");
proxy.Call("clkdiv", {"0"}, -1, GET, oss_get);
REQUIRE(oss_get.str() == "clkdiv " + previous_string + "\n");
} else {
REQUIRE_THROWS(proxy.Call("clkdiv", {"0"}, -1, GET));
}
}
TEST_CASE("maxclkphaseshift", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
REQUIRE_THROWS(proxy.Call("maxclkphaseshift", {"0", "2"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("maxclkphaseshift", {}, -1, GET));
REQUIRE_THROWS(proxy.Call("maxclkphaseshift", {"7"}, -1, GET));
auto value = det.getMaxClockPhaseShift(0).squash(-1);
std::ostringstream oss_set, oss_get;
proxy.Call("maxclkphaseshift", {"0"}, -1, GET, oss_get);
REQUIRE(oss_get.str() ==
"maxclkphaseshift " + std::to_string(value) + "\n");
} else {
REQUIRE_THROWS(proxy.Call("maxclkphaseshift", {"0"}, -1, GET));
}
}
TEST_CASE("counters", "[.cmd]") { TEST_CASE("counters", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);

File diff suppressed because it is too large Load Diff