diff --git a/python/scripts/compare_with_commandline.py b/python/scripts/compare_with_commandline.py index 3a584252c..d4d68fab6 100644 --- a/python/scripts/compare_with_commandline.py +++ b/python/scripts/compare_with_commandline.py @@ -14,7 +14,6 @@ pycmd = dir(Detector) # dacs are in general not included in the python commands and we expect to # set them from the specialized class or using an enum dacs = [ - 'adcvpp', 'iodelay', 'list', 'rxb_lb', diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 50d5c1af8..8509579b6 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1585,6 +1585,14 @@ class Detector { */ void setVoltage(defs::dacIndex index, int value, Positions pos = {}); + /** + * [CTB][Moench] Options: [0- 4] or [1V, 1.14V, 1.33V, 1.6V, 2V] + */ + Result getADCVpp(bool mV = false, Positions pos = {}) const; + + /** [CTB][Moench] */ + void setADCVpp(int value, bool mV = false, Positions pos = {}); + /** [CTB][Moench] */ Result getADCEnableMask(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 1d44072ce..968550d39 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -2556,6 +2556,51 @@ std::string CmdProxy::Samples(int action) { } /* CTB Specific */ +std::string CmdProxy::AdcVpp(int action) { + std::ostringstream os; + os << cmd << ' '; + + if (action == defs::HELP_ACTION) { + os << "[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of " + "ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V. " + "\n\tAdvanced User function!\n" + << '\n'; + return os.str(); + } + + if (action == defs::GET_ACTION) { + bool mV = false; + + if (args.size() == 1) { + if ((args[0] != "mv") && (args[0] != "mV")) { + throw RuntimeError("Unknown argument " + args[0] + + ". Did you mean mV?"); + } + mV = true; + } else if (args.size() > 1) { + WrongNumberOfParameters(1); + } + auto t = det->getADCVpp(mV, std::vector{det_id}); + os << OutString(t) << (mV ? " mV\n" : "\n"); + } else if (action == defs::PUT_ACTION) { + bool mV = false; + if (args.size() == 2) { + if ((args[1] != "mv") && (args[1] != "mV")) { + throw RuntimeError("Unknown argument " + args[1] + + ". Did you mean mV?"); + } + mV = true; + } else if (args.size() > 2 || args.size() < 1) { + WrongNumberOfParameters(1); + } + det->setADCVpp(StringTo(args[1]), mV, + std::vector{det_id}); + os << args[1] << (mV ? " mV\n" : "\n"); + } else { + throw RuntimeError("Unknown action"); + } + return os.str(); +} std::string CmdProxy::SlowAdc(int action) { std::ostringstream os; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 350de34d4..93cc2b039 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -666,7 +666,6 @@ class CmdProxy { {"vb_cs", "dac"}, {"vb_opa_fd", "dac"}, {"vcom_adc2", "dac"}, - {"adcvpp", "dac"}, {"vb_ds", "dac"}, {"vb_comp", "dac"}, {"vb_pixbuf", "dac"}, @@ -1018,6 +1017,7 @@ class CmdProxy { {"dsamples", &CmdProxy::dsamples}, {"romode", &CmdProxy::romode}, {"dbitclk", &CmdProxy::dbitclk}, + {"adcvpp", &CmdProxy::AdcVpp}, {"v_a", &CmdProxy::v_a}, {"v_b", &CmdProxy::v_b}, {"v_c", &CmdProxy::v_c}, @@ -1190,6 +1190,7 @@ class CmdProxy { /* CTB/ Moench Specific */ std::string Samples(int action); /* CTB Specific */ + std::string AdcVpp(int action); std::string SlowAdc(int action); std::string ReceiverDbitList(int action); std::string DigitalIODelay(int action); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index e90426434..ffa780f0f 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1999,6 +1999,14 @@ void Detector::setVoltage(defs::dacIndex index, int value, Positions pos) { pimpl->Parallel(&Module::setDAC, pos, value, index, true); } +Result Detector::getADCVpp(bool mV, Positions pos) const { + return pimpl->Parallel(&Module::getDAC, pos, defs::ADC_VPP, mV); +} + +void Detector::setADCVpp(int value, bool mV, Positions pos) { + pimpl->Parallel(&Module::setDAC, pos, value, defs::ADC_VPP, mV); +} + Result Detector::getADCEnableMask(Positions pos) const { return pimpl->Parallel(&Module::getADCEnableMask, pos); } diff --git a/slsDetectorSoftware/src/HelpDacs.h b/slsDetectorSoftware/src/HelpDacs.h index 73fbad429..f5eb3e9b1 100644 --- a/slsDetectorSoftware/src/HelpDacs.h +++ b/slsDetectorSoftware/src/HelpDacs.h @@ -253,12 +253,6 @@ std::string GetHelpDac(std::string dac) { "[dac or mV value][(optional unit) mV] \n\t[Gotthard2] Dac for " "common mode voltage of ADC DAC bank 2."); } - if (dac == "adcvpp") { - return std::string( - "[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of " - "ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V. " - "\n\tAdvanced User function! "); - } if (dac == "vb_ds") { return std::string( "[dac or mV value][(optional unit) mV] \n\t[Jungfrau] Dac for ??"); diff --git a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp index 5f9402b5b..5bbe38e1e 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp @@ -108,7 +108,7 @@ TEST_CASE("adcvpp", "[.cmd]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) { - auto prev_val = det.getDAC(defs::ADC_VPP, false); + auto prev_val = det.getADCVpp(false); { std::ostringstream oss; proxy.Call("adcvpp", {"1"}, -1, PUT, oss); @@ -125,7 +125,7 @@ TEST_CASE("adcvpp", "[.cmd]") { REQUIRE(oss.str() == "dac adcvpp 1140 mV\n"); } for (int i = 0; i != det.size(); ++i) { - det.setDAC(defs::ADC_VPP, prev_val[i], false, {i}); + det.setADCVpp(prev_val[i], false, {i}); } } else { REQUIRE_THROWS(proxy.Call("dac adcvpp", {}, -1, GET)); diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index 04fda1dde..f8d5accdd 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -490,8 +490,6 @@ std::string ToString(const defs::dacIndex s) { return std::string("vipre_cds"); case defs::IBIAS_SFP: return std::string("ibias_sfp"); - case defs::ADC_VPP: - return std::string("adcvpp"); case defs::TRIMBIT_SCAN: return std::string("trimbits"); case defs::HIGH_VOLTAGE: @@ -953,8 +951,6 @@ template <> defs::dacIndex StringTo(const std::string &s) { return defs::VIPRE_CDS; if (s == "ibias_sfp") return defs::IBIAS_SFP; - if (s == "adcvpp") - return defs::ADC_VPP; if (s == "trimbits") return defs::TRIMBIT_SCAN; if (s == "highvoltage")