From 98ddf4f981bcf747715efe7f88c3f2d0e9a9eeb2 Mon Sep 17 00:00:00 2001 From: Jacob Williamson Date: Fri, 13 Feb 2026 15:43:27 +0000 Subject: [PATCH] Pass attribute instead of datatype into _get_read_widget --- src/fastcs/transports/epics/gui.py | 13 ++++++++----- src/fastcs/transports/epics/pva/gui.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/fastcs/transports/epics/gui.py b/src/fastcs/transports/epics/gui.py index 9bc47f7b..d4ce6e3e 100644 --- a/src/fastcs/transports/epics/gui.py +++ b/src/fastcs/transports/epics/gui.py @@ -57,8 +57,8 @@ def _get_pv(self, attr_path: list[str], name: str): ) return f"{attr_prefix}:{snake_to_pascal(name)}" - def _get_read_widget(self, fastcs_datatype: DataType) -> ReadWidgetUnion | None: - match fastcs_datatype: + def _get_read_widget(self, attribute: Attribute) -> ReadWidgetUnion | None: + match attribute.datatype: case Bool(): return LED() case Int(): @@ -71,7 +71,10 @@ def _get_read_widget(self, fastcs_datatype: DataType) -> ReadWidgetUnion | None: return TextRead(format=TextFormat.string) case Waveform() as waveform: if len(waveform.shape) > 1: - logger.warning("EPICS CA transport only supports 1D waveforms") + logger.warning( + "EPICS CA transport only supports 1D waveforms," + + f"{attribute} is a {waveform.shape} waveform" + ) return None return ArrayTrace(axis="x") @@ -102,7 +105,7 @@ def _get_attribute_component( name = snake_to_pascal(name) match attribute: case AttrRW(): - read_widget = self._get_read_widget(attribute.datatype) + read_widget = self._get_read_widget(attribute) write_widget = self._get_write_widget(attribute.datatype) if write_widget is None or read_widget is None: return None @@ -115,7 +118,7 @@ def _get_attribute_component( read_widget=read_widget, ) case AttrR(): - read_widget = self._get_read_widget(attribute.datatype) + read_widget = self._get_read_widget(attribute) if read_widget is None: return None return SignalR( diff --git a/src/fastcs/transports/epics/pva/gui.py b/src/fastcs/transports/epics/pva/gui.py index b305b981..e0d4f2cc 100644 --- a/src/fastcs/transports/epics/pva/gui.py +++ b/src/fastcs/transports/epics/pva/gui.py @@ -8,6 +8,8 @@ WriteWidgetUnion, ) +from fastcs.attributes.attr_r import AttrR +from fastcs.attributes.attribute import Attribute from fastcs.datatypes import Bool, DataType, Table, Waveform, numpy_to_fastcs_datatype from fastcs.transports.epics.gui import EpicsGUI @@ -20,17 +22,18 @@ class PvaEpicsGUI(EpicsGUI): def _get_pv(self, attr_path: list[str], name: str): return f"pva://{super()._get_pv(attr_path, name)}" - def _get_read_widget(self, fastcs_datatype: DataType) -> ReadWidgetUnion | None: - match fastcs_datatype: + def _get_read_widget(self, attribute: Attribute) -> ReadWidgetUnion | None: + match attribute.datatype: case Table(): fastcs_datatypes = [ numpy_to_fastcs_datatype(datatype) - for _, datatype in fastcs_datatype.structured_dtype + for _, datatype in attribute.datatype.structured_dtype ] base_get_read_widget = super()._get_read_widget widgets = [ - base_get_read_widget(datatype) for datatype in fastcs_datatypes + base_get_read_widget(AttrR(datatype)) + for datatype in fastcs_datatypes ] return TableRead(widgets=widgets) # type: ignore @@ -39,7 +42,7 @@ def _get_read_widget(self, fastcs_datatype: DataType) -> ReadWidgetUnion | None: height=height, width=width, color_map=ImageColorMap.GRAY ) case _: - return super()._get_read_widget(fastcs_datatype) + return super()._get_read_widget(attribute) def _get_write_widget(self, fastcs_datatype: DataType) -> WriteWidgetUnion | None: match fastcs_datatype: