From 614b5c56d93e5f90cfd1b28bf6dd448fe8604897 Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Thu, 19 Mar 2026 15:10:03 +0100 Subject: [PATCH] change python and pyctbgui to accept and return floating point MHz --- pyctbgui/pyctbgui/ui/acquisition.ui | 32 ++++++++++--- python/slsdet/detector.py | 46 +++++++++++++------ .../slsDetectorServer/src/XILINX_PLL.c | 2 +- 3 files changed, 59 insertions(+), 21 deletions(-) diff --git a/pyctbgui/pyctbgui/ui/acquisition.ui b/pyctbgui/pyctbgui/ui/acquisition.ui index c2d15dff6..ba0eddbaa 100644 --- a/pyctbgui/pyctbgui/ui/acquisition.ui +++ b/pyctbgui/pyctbgui/ui/acquisition.ui @@ -36,7 +36,7 @@ - + 0 @@ -61,11 +61,17 @@ QAbstractSpinBox::UpDownArrows + + 6 + + + 0.100000000000000 + - 1000 + 1000.000000000000000 - 0 + 0.000000000000000 @@ -285,7 +291,7 @@ - + 0 @@ -307,8 +313,14 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 6 + + + 0.100000000000000 + - 1000 + 1000.000000000000000 @@ -375,7 +387,7 @@ - + 0 @@ -397,8 +409,14 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 6 + + + 0.100000000000000 + - 1000 + 1000.000000000000000 diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index ad6e23a3b..2d1c782c3 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -3520,15 +3520,22 @@ class Detector(CppDetectorApi): @element def runclk(self): """ - [Ctb] Sets Run clock frequency in MHz. \n - [Xilinx Ctb] Sets Run clock frequency in kHz. + [Ctb][Xilinx Ctb] Sets Run clock frequency in MHz. \n + Accepts floating point inputs """ - return self.getRUNClock() + freq_hz = element_if_equal(self.getRUNClock()) + if isinstance(freq_hz, list): + return [value / 1e6 for value in freq_hz] + return freq_hz / 1e6 @runclk.setter def runclk(self, freq): - ut.set_using_dict(self.setRUNClock, freq) + if isinstance(freq, dict): + freq_hz = {key: int(round(value * 1e6)) for key, value in freq.items()} + else: + freq_hz = int(round(freq * 1e6)) + ut.set_using_dict(self.setRUNClock, freq_hz) @property @element @@ -3605,15 +3612,21 @@ class Detector(CppDetectorApi): @element def dbitclk(self): """ - [Ctb] Sets clock for latching the digital bits in MHz. \n - [Xilinx Ctb] clock for latching the digital bits in kHz. + [Ctb][Xilinx Ctb] Sets clock for latching the digital bits in MHz. \n + Accepts floating point inputs """ - - return self.getDBITClock() + freq_hz = element_if_equal(self.getDBITClock()) + if isinstance(freq_hz, list): + return [value / 1e6 for value in freq_hz] + return freq_hz / 1e6 @dbitclk.setter def dbitclk(self, value): - ut.set_using_dict(self.setDBITClock, value) + if isinstance(value, dict): + value_hz = {key: int(round(item * 1e6)) for key, item in value.items()} + else: + value_hz = int(round(value * 1e6)) + ut.set_using_dict(self.setDBITClock, value_hz) @property @element @@ -3736,15 +3749,22 @@ class Detector(CppDetectorApi): @element def adcclk(self): """ - [Ctb] Sets ADC clock frequency in MHz. \n - [Xilinx Ctb] Sets ADC clock frequency in kHz. + [Ctb][Xilinx Ctb] Sets ADC clock frequency in MHz. \n + Accepts floating point inputs """ - return self.getADCClock() + freq_hz = element_if_equal(self.getADCClock()) + if isinstance(freq_hz, list): + return [value / 1e6 for value in freq_hz] + return freq_hz / 1e6 @adcclk.setter def adcclk(self, value): - ut.set_using_dict(self.setADCClock, value) + if isinstance(value, dict): + value_hz = {key: int(round(item * 1e6)) for key, item in value.items()} + else: + value_hz = int(round(value * 1e6)) + ut.set_using_dict(self.setADCClock, value_hz) @property @element diff --git a/slsDetectorServers/slsDetectorServer/src/XILINX_PLL.c b/slsDetectorServers/slsDetectorServer/src/XILINX_PLL.c index 57a29f0e2..e6f8a04bb 100644 --- a/slsDetectorServers/slsDetectorServer/src/XILINX_PLL.c +++ b/slsDetectorServers/slsDetectorServer/src/XILINX_PLL.c @@ -71,7 +71,7 @@ // clang-format on -// freq in kHz !! +// freq in Hz !! int XILINX_PLL_setFrequency(uint32_t clk_index, uint32_t freq) { if (clk_index >= XILINX_PLL_NUM_CLKS) { LOG(logERROR, ("XILINX_PLL: Invalid clock index %d\n", clk_index));