From a810ddeaf4dbad568f866e27e6174f2357c4885f Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Wed, 18 Mar 2026 15:50:18 +0100 Subject: [PATCH] do the same for dbit and adcclk --- slsDetectorSoftware/include/sls/Detector.h | 14 ++--- slsDetectorSoftware/src/Caller.cpp | 68 ++++++++++++++++------ slsDetectorSoftware/src/Detector.cpp | 8 +-- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index d07cfb360..99edd3cb9 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1613,13 +1613,13 @@ class Detector { /** [CTB] */ void setNumberOfAnalogSamples(int value, Positions pos = {}); - /** [CTB] in MHz, [XCTB] in kHz */ + /** [CTB] in Hz, [XCTB] in Hz */ Result getADCClock(Positions pos = {}) const; - /** [CTB] in MHz, [XCTB] in kHz */ - void setADCClock(int value_in_MHz, Positions pos = {}); + /** [CTB] in Hz, [XCTB] in Hz */ + void setADCClock(int value_in_Hz, Positions pos = {}); - /** [CTB] in MHz, [XCTB] in kHz */ + /** [CTB] in Hz, [XCTB] in Hz */ Result getRUNClock(Positions pos = {}) const; /** [CTB] in Hz, [XCTB] in Hz */ @@ -1692,11 +1692,11 @@ class Detector { */ void setReadoutMode(defs::readoutMode value, Positions pos = {}); - /** [CTB] in MHz, [XCTB] in kHz */ + /** [CTB] in Hz, [XCTB] in Hz */ Result getDBITClock(Positions pos = {}) const; - /** [CTB] in MHz, [XCTB] in kHz */ - void setDBITClock(int value_in_MHz, Positions pos = {}); + /** [CTB] in Hz, [XCTB] in Hz */ + void setDBITClock(int value_in_Hz, Positions pos = {}); /** * [CTB] mV diff --git a/slsDetectorSoftware/src/Caller.cpp b/slsDetectorSoftware/src/Caller.cpp index 6cab6f85a..d0c18da25 100644 --- a/slsDetectorSoftware/src/Caller.cpp +++ b/slsDetectorSoftware/src/Caller.cpp @@ -72,9 +72,7 @@ std::string Caller::adcclk(int action) { std::ostringstream os; // print help if (action == slsDetectorDefs::HELP_ACTION) { - os << R"V0G0N([n_clk in MHz] - [Ctb] ADC clock frequency in MHz. - [xilinx Ctb] ADC clock frequency in kHz. )V0G0N" + os << R"V0G0N([ADC clock frequency] [(optional unit) MHz|kHz|Hz])V0G0N" << std::endl; return os.str(); } @@ -91,15 +89,25 @@ std::string Caller::adcclk(int action) { } else if (action == slsDetectorDefs::PUT_ACTION) { - if (1 && args.size() != 1) { + if (1 && args.size() != 1 && args.size() != 2) { throw RuntimeError("Wrong number of arguments for action PUT"); } if (args.size() == 1) { try { - StringTo(args[0]); + std::string tmp_freq(args[0]); + std::string unit = RemoveUnit(tmp_freq); + StringToHz(tmp_freq, unit); } catch (...) { - throw RuntimeError("Could not convert argument 0 to int"); + throw RuntimeError("Could not convert argument to frequency"); + } + } + + if (args.size() == 2) { + try { + StringToHz(args[0], args[1]); + } catch (...) { + throw RuntimeError("Could not convert arguments to frequency"); } } @@ -121,9 +129,17 @@ std::string Caller::adcclk(int action) { if (action == slsDetectorDefs::PUT_ACTION) { if (args.size() == 1) { - auto arg0 = StringTo(args[0]); - det->setADCClock(arg0, std::vector{det_id}); - os << args.front() << '\n'; + std::string tmp_freq(args[0]); + std::string unit = RemoveUnit(tmp_freq); + auto converted_freq_hz = StringToHz(tmp_freq, unit); + det->setADCClock(converted_freq_hz, std::vector{det_id}); + os << args[0] << '\n'; + } + + if (args.size() == 2) { + auto converted_freq_hz = StringToHz(args[0], args[1]); + det->setADCClock(converted_freq_hz, std::vector{det_id}); + os << args[0] << args[1] << '\n'; } } @@ -2711,9 +2727,7 @@ std::string Caller::dbitclk(int action) { std::ostringstream os; // print help if (action == slsDetectorDefs::HELP_ACTION) { - os << R"V0G0N([n_clk in MHz] - [Ctb] Clock for latching the digital bits in MHz. - [xilinx Ctb] Clock for latching the digital bits in kHz. )V0G0N" + os << R"V0G0N([dbit clock frequency] [(optional unit) MHz|kHz|Hz])V0G0N" << std::endl; return os.str(); } @@ -2730,15 +2744,25 @@ std::string Caller::dbitclk(int action) { } else if (action == slsDetectorDefs::PUT_ACTION) { - if (1 && args.size() != 1) { + if (1 && args.size() != 1 && args.size() != 2) { throw RuntimeError("Wrong number of arguments for action PUT"); } if (args.size() == 1) { try { - StringTo(args[0]); + std::string tmp_freq(args[0]); + std::string unit = RemoveUnit(tmp_freq); + StringToHz(tmp_freq, unit); } catch (...) { - throw RuntimeError("Could not convert argument 0 to int"); + throw RuntimeError("Could not convert argument to frequency"); + } + } + + if (args.size() == 2) { + try { + StringToHz(args[0], args[1]); + } catch (...) { + throw RuntimeError("Could not convert arguments to frequency"); } } @@ -2760,9 +2784,17 @@ std::string Caller::dbitclk(int action) { if (action == slsDetectorDefs::PUT_ACTION) { if (args.size() == 1) { - auto arg0 = StringTo(args[0]); - det->setDBITClock(arg0, std::vector{det_id}); - os << args.front() << '\n'; + std::string tmp_freq(args[0]); + std::string unit = RemoveUnit(tmp_freq); + auto converted_freq_hz = StringToHz(tmp_freq, unit); + det->setDBITClock(converted_freq_hz, std::vector{det_id}); + os << args[0] << '\n'; + } + + if (args.size() == 2) { + auto converted_freq_hz = StringToHz(args[0], args[1]); + det->setDBITClock(converted_freq_hz, std::vector{det_id}); + os << args[0] << args[1] << '\n'; } } diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index b3318fc97..1acafd8d3 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -2148,9 +2148,9 @@ Result Detector::getADCClock(Positions pos) const { return pimpl->Parallel(&Module::getClockFrequency, pos, defs::ADC_CLOCK); } -void Detector::setADCClock(int value_in_MHz, Positions pos) { +void Detector::setADCClock(int value_in_Hz, Positions pos) { pimpl->Parallel(&Module::setClockFrequency, pos, defs::ADC_CLOCK, - value_in_MHz); + value_in_Hz); } Result Detector::getRUNClock(Positions pos) const { @@ -2281,9 +2281,9 @@ Result Detector::getDBITClock(Positions pos) const { return pimpl->Parallel(&Module::getClockFrequency, pos, defs::DBIT_CLOCK); } -void Detector::setDBITClock(int value_in_MHz, Positions pos) { +void Detector::setDBITClock(int value_in_Hz, Positions pos) { pimpl->Parallel(&Module::setClockFrequency, pos, defs::DBIT_CLOCK, - value_in_MHz); + value_in_Hz); } Result Detector::getMeasuredPower(defs::dacIndex index,