From 13fa5c0f2edf36abd38b71bca9ddaf44259b6c91 Mon Sep 17 00:00:00 2001 From: chrin Date: Fri, 13 Dec 2024 15:33:26 +0100 Subject: [PATCH] added scale_factor for CAQLabel --- pvwidgets.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pvwidgets.py b/pvwidgets.py index 8e8718c..6d6194b 100644 --- a/pvwidgets.py +++ b/pvwidgets.py @@ -163,13 +163,17 @@ class CAQLabel(QLabel, PVGateway): def __init__(self, parent=None, pv_name: str = "", monitor_callback=None, pv_within_daq_group: bool = False, color_mode=None, show_units: bool = False, prefix: str = "", suffix: str = "", - notify_freq_hz: int = 0, precision: int = 0): + notify_freq_hz: int = 0, precision: int = 0, + scale_factor: float = 1): super().__init__(parent, pv_name, monitor_callback, pv_within_daq_group, color_mode, show_units, prefix, suffix, connect_callback=self.py_connect_callback, notify_freq_hz=notify_freq_hz, precision=precision) + + self.scale_factor = scale_factor + self.is_initialize_complete() self.configure_widget() @@ -185,12 +189,16 @@ class CAQLabel(QLabel, PVGateway): @Slot(object, str, int) def receive_daq_update(self, daq_pvd, daq_mode, daq_state): + if self.scale_factor != 1: + daq_pvd.value[0] = daq_pvd.value[0] * self.scale_factor PVGateway.receive_daq_update(self, daq_pvd, daq_mode, daq_state) @Slot(str, int, int) @Slot(int, int, int) @Slot(float, int, int) def receive_monitor_update(self, value, status, alarm_severity): + if self.scale_factor != 1: + value = value * self.scale_factor PVGateway.receive_monitor_update(self, value, status, alarm_severity) @Slot(int, str, int)