From d4e11e56ea93ddd9f7ffe54f1e9aa3af72f8acdc Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 14 Aug 2020 15:47:19 +0200 Subject: [PATCH] added drlist and timinglist, moved daclist and settingslist from cmdprozy.cpp to .h --- slsDetectorSoftware/include/Detector.h | 6 +++ slsDetectorSoftware/src/CmdProxy.cpp | 39 ------------------- slsDetectorSoftware/src/CmdProxy.h | 42 +++++++++++++++++++-- slsDetectorSoftware/src/Detector.cpp | 27 +++++++++++++ slsDetectorSoftware/tests/test-CmdProxy.cpp | 14 +++++++ 5 files changed, 85 insertions(+), 43 deletions(-) diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 88612a329..ccd1641a3 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -215,6 +215,9 @@ class Detector { */ void setDynamicRange(int value); + /** list of possible dynamic ranges for this detector */ + std::vector getDynamicRangeList() const; + Result getTimingMode(Positions pos = {}) const; /** @@ -225,6 +228,9 @@ class Detector { */ void setTimingMode(defs::timingMode value, Positions pos = {}); + /** list of possible timing modes for this detector */ + std::vector getTimingModeList() const; + /** [Eiger][Jungfrau] */ Result getSpeed(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 61430bdef..ccbeb4dfb 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -332,25 +332,6 @@ std::string CmdProxy::DetectorSize(int action) { return os.str(); } -std::string CmdProxy::SettingsList(int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == defs::HELP_ACTION) { - os << "\n\tList of settings implemented for this detector" << '\n'; - } else if (action == defs::GET_ACTION) { - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->getSettingsList(); - os << ToString(t) << "\n"; - } else if (action == defs::PUT_ACTION) { - throw sls::RuntimeError("Cannot put"); - } else { - throw sls::RuntimeError("Unknown action"); - } - return os.str(); -} - std::string CmdProxy::GapPixels(int action) { std::ostringstream os; os << cmd << ' '; @@ -921,26 +902,6 @@ std::string CmdProxy::Dac(int action) { return os.str(); } -std::string CmdProxy::DacList(int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == defs::HELP_ACTION) { - os << "\n\tGets the list of commands for every dac for this detector." - << '\n'; - } else if (action == defs::GET_ACTION) { - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->getDacList(); - os << ToString(t) << '\n'; - } else if (action == defs::PUT_ACTION) { - throw sls::RuntimeError("Cannot put"); - } else { - throw sls::RuntimeError("Unknown action"); - } - return os.str(); -} - std::string CmdProxy::DacValues(int action) { std::ostringstream os; os << cmd << ' '; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index f1619cc50..22e976eb6 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -414,6 +414,27 @@ return os.str(); \ } +/** get only no id (vector, not result) */ +#define GET_COMMAND_NOID(CMDNAME, GETFCN, HLPSTR) \ + std::string CMDNAME(const int action) { \ + std::ostringstream os; \ + os << cmd << ' '; \ + if (action == slsDetectorDefs::HELP_ACTION) \ + os << HLPSTR << '\n'; \ + else if (action == slsDetectorDefs::GET_ACTION) { \ + if (!args.empty()) { \ + WrongNumberOfParameters(0); \ + } \ + auto t = det->GETFCN(); \ + os << sls::ToString(t) << '\n'; \ + } else if (action == slsDetectorDefs::PUT_ACTION) { \ + throw sls::RuntimeError("Cannot put"); \ + } else { \ + throw sls::RuntimeError("Unknown action"); \ + } \ + return os.str(); \ + } + /** get only hex*/ #define GET_COMMAND_HEX(CMDNAME, GETFCN, HLPSTR) \ std::string CMDNAME(const int action) { \ @@ -627,7 +648,7 @@ class CmdProxy { {"detectornumber", &CmdProxy::detectornumber}, {"type", &CmdProxy::type}, {"detsize", &CmdProxy::DetectorSize}, - {"settingslist", &CmdProxy::SettingsList}, + {"settingslist", &CmdProxy::settingslist}, {"settings", &CmdProxy::settings}, {"trimbits", &CmdProxy::trimbits}, {"trimval", &CmdProxy::trimval}, @@ -645,7 +666,9 @@ class CmdProxy { {"delayl", &CmdProxy::delayl}, {"periodl", &CmdProxy::periodl}, {"dr", &CmdProxy::DynamicRange}, + {"drlist", &CmdProxy::drlist}, {"timing", &CmdProxy::timing}, + {"timinglist", &CmdProxy::timinglist}, {"speed", &CmdProxy::Speed}, {"adcphase", &CmdProxy::Adcphase}, {"maxadcphaseshift", &CmdProxy::maxadcphaseshift}, @@ -737,7 +760,7 @@ class CmdProxy { {"ibias_sfp", &CmdProxy::ibias_sfp}, {"dac", &CmdProxy::Dac}, - {"daclist", &CmdProxy::DacList}, + {"daclist", &CmdProxy::daclist}, {"dacvalues", &CmdProxy::DacValues}, /* on chip dacs */ @@ -994,7 +1017,6 @@ class CmdProxy { std::string PackageVersion(int action); std::string ClientVersion(int action); std::string DetectorSize(int action); - std::string SettingsList(int action); std::string GapPixels(int action); /* acquisition parameters */ std::string Acquire(int action); @@ -1011,7 +1033,6 @@ class CmdProxy { /** temperature */ /* dacs */ std::string Dac(int action); - std::string DacList(int action); std::string DacValues(int action); /* acquisition */ std::string ReceiverStatus(int action); @@ -1103,6 +1124,9 @@ class CmdProxy { GET_COMMAND(type, getDetectorType, "\n\tSerial number or MAC of detector (hex)."); + GET_COMMAND_NOID(settingslist, getSettingsList, + "\n\tList of settings implemented for this detector."); + INTEGER_COMMAND(settings, getSettings, setSettings, sls::StringTo, "[standard, fast, highgain, dynamicgain, lowgain, " @@ -1172,6 +1196,9 @@ class CmdProxy { " Period left for current frame." "\n\t[Gotthard2] only in continuous mode."); + GET_COMMAND_NOID(drlist, getDynamicRangeList, + "\n\tGets the list of dynamic ranges for this detector."); + INTEGER_COMMAND(timing, getTimingMode, setTimingMode, sls::StringTo, "[auto|trigger|gating|burst_trigger]\n\tTiming Mode of " @@ -1180,6 +1207,9 @@ class CmdProxy { "[auto|trigger|gating|trigger_gating]\n\t[Eiger] " "[auto|trigger|gating|burst_trigger]"); + GET_COMMAND_NOID(timinglist, getTimingModeList, + "\n\tGets the list of timing modes for this detector."); + GET_COMMAND(maxadcphaseshift, getMaxADCPhaseShift, "\n\t[Jungfrau][CTB][Moench] Absolute maximum Phase shift of " "ADC clock."); @@ -1510,6 +1540,10 @@ class CmdProxy { DAC_COMMAND(ibias_sfp, getDAC, setDAC, defs::IBIAS_SFP, "[dac or mv value][(optional unit) mv] \n\t[Moench] Dac for 7"); + GET_COMMAND_NOID( + daclist, getDacList, + "\n\tGets the list of commands for every dac for this detector."); + /* on chip dacs */ INTEGER_USER_IND_COMMAND( vchip_comp_fe, getOnChipDAC, setOnChipDAC, StringTo, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 2f153125b..80117ef01 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -285,6 +285,17 @@ void Detector::setDynamicRange(int value) { updateRxRateCorrections(); } +std::vector Detector::getDynamicRangeList() const { + switch (getDetectorType().squash()) { + case defs::EIGER: + return std::vector{4, 8, 16, 32}; + case defs::MYTHEN3: + return std::vector{8, 16, 32}; + default: + return std::vector{16}; + } +} + Result Detector::getTimingMode(Positions pos) const { return pimpl->Parallel(&Module::getTimingMode, pos); } @@ -293,6 +304,22 @@ void Detector::setTimingMode(defs::timingMode value, Positions pos) { pimpl->Parallel(&Module::setTimingMode, pos, value); } +std::vector Detector::getTimingModeList() const { + switch (getDetectorType().squash()) { + case defs::EIGER: + return std::vector{defs::AUTO_TIMING, + defs::TRIGGER_EXPOSURE, + defs::GATED, defs::BURST_TRIGGER}; + case defs::MYTHEN3: + return std::vector{defs::AUTO_TIMING, + defs::TRIGGER_EXPOSURE, + defs::GATED, defs::TRIGGER_GATED}; + default: + return std::vector{defs::AUTO_TIMING, + defs::TRIGGER_EXPOSURE}; + } +} + Result Detector::getSpeed(Positions pos) const { auto res = pimpl->Parallel(&Module::getClockDivider, pos, defs::RUN_CLOCK); Result speedResult(res.size()); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index c75a36746..f2ad5bd28 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -493,6 +493,13 @@ TEST_CASE("dr", "[.cmd][.new]") { } } +TEST_CASE("drlist", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_NOTHROW(proxy.Call("drlist", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("drlist", {}, -1, PUT)); +} + TEST_CASE("timing", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); @@ -555,6 +562,13 @@ TEST_CASE("timing", "[.cmd][.new]") { } } +TEST_CASE("timinglist", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_NOTHROW(proxy.Call("timinglist", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("timinglist", {}, -1, PUT)); +} + TEST_CASE("speed", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det);