mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-03-10 02:37:59 +01:00
fix(positioner-box): Test to fix handling of none integer values for precision
This commit is contained in:
@@ -138,7 +138,7 @@ class PositionerBoxBase(BECWidget, CompactPopupWidget):
|
||||
signals = msg_content.get("signals", {})
|
||||
# pylint: disable=protected-access
|
||||
hinted_signals = self.dev[device]._hints
|
||||
precision = self.dev[device].precision
|
||||
precision = getattr(self.dev[device], "precision", None)
|
||||
|
||||
spinner = ui_components["spinner"]
|
||||
position_indicator = ui_components["position_indicator"]
|
||||
@@ -178,11 +178,19 @@ class PositionerBoxBase(BECWidget, CompactPopupWidget):
|
||||
spinner.setVisible(False)
|
||||
|
||||
if readback_val is not None:
|
||||
readback.setText(f"{readback_val:.{precision}f}")
|
||||
if not isinstance(precision, bool) and isinstance(precision, int):
|
||||
text = f"{readback_val:.{precision}f}"
|
||||
else:
|
||||
text = str(readback_val)
|
||||
readback.setText(text)
|
||||
position_emit(readback_val)
|
||||
|
||||
if setpoint_val is not None:
|
||||
setpoint.setText(f"{setpoint_val:.{precision}f}")
|
||||
if not isinstance(precision, bool) and isinstance(precision, int):
|
||||
text = f"{setpoint_val:.{precision}f}"
|
||||
else:
|
||||
text = str(setpoint_val)
|
||||
setpoint.setText(text)
|
||||
|
||||
limits = self.dev[device].limits
|
||||
limit_update(limits)
|
||||
@@ -205,10 +213,13 @@ class PositionerBoxBase(BECWidget, CompactPopupWidget):
|
||||
ui["readback"].setToolTip(f"{device} readback")
|
||||
ui["setpoint"].setToolTip(f"{device} setpoint")
|
||||
ui["step_size"].setToolTip(f"Step size for {device}")
|
||||
precision = self.dev[device].precision
|
||||
if precision is not None:
|
||||
precision = getattr(self.dev[device], "precision", None)
|
||||
if not isinstance(precision, bool) and isinstance(precision, int):
|
||||
ui["step_size"].setDecimals(precision)
|
||||
ui["step_size"].setValue(10**-precision * 10)
|
||||
else: # Default to 8 decimals if precision is not specified
|
||||
ui["step_size"].setDecimals(8)
|
||||
ui["step_size"].setValue(10**-8 * 10)
|
||||
|
||||
def _swap_readback_signal_connection(self, slot, old_device, new_device):
|
||||
self.bec_dispatcher.disconnect_slot(slot, MessageEndpoints.device_readback(old_device))
|
||||
|
||||
@@ -45,7 +45,11 @@ class PositionerGroupBox(QGroupBox):
|
||||
|
||||
def _on_position_update(self, pos: float):
|
||||
self.position_update.emit(pos)
|
||||
self.widget.label = f"%.{self.widget.dev[self.widget.device].precision}f" % pos
|
||||
precision = getattr(self.widget.dev[self.widget.device], "precision", None)
|
||||
if not isinstance(precision, bool) and isinstance(precision, int):
|
||||
self.widget.label = f"{pos:.{precision}f}"
|
||||
else:
|
||||
self.widget.label = f"{pos}"
|
||||
|
||||
def close(self):
|
||||
self.widget.close()
|
||||
|
||||
Reference in New Issue
Block a user