From 2a9cf2f99575e7ea8054edfb5da93f64e1c2ba72 Mon Sep 17 00:00:00 2001 From: Gary Yendell Date: Fri, 30 Jan 2026 17:29:15 +0000 Subject: [PATCH] Skip 2D+ Waveforms in EPICS CA Transport Update other related checks to use logger.warning --- src/fastcs/transports/epics/ca/ioc.py | 16 +++++++++++++--- tests/transports/epics/ca/test_softioc.py | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/fastcs/transports/epics/ca/ioc.py b/src/fastcs/transports/epics/ca/ioc.py index 7df4cd836..fbaaa993f 100644 --- a/src/fastcs/transports/epics/ca/ioc.py +++ b/src/fastcs/transports/epics/ca/ioc.py @@ -8,6 +8,7 @@ from fastcs.attributes import AttrR, AttrRW, AttrW from fastcs.datatypes import DataType, DType_T +from fastcs.datatypes.waveform import Waveform from fastcs.logging import bind_logger from fastcs.methods import Command from fastcs.tracer import Tracer @@ -131,12 +132,21 @@ def _create_and_link_attribute_pvs( pv_prefix = controller_pv_prefix(root_pv_prefix, controller_api) for attr_name, attribute in controller_api.attributes.items(): - pv_name = snake_to_pascal(attr_name) + if ( + isinstance(attribute.datatype, Waveform) + and len(attribute.datatype.shape) != 1 + ): + logger.warning( + "Only 1D Waveform attributes are supported in EPICS CA transport", + attribute=attribute, + ) + continue + pv_name = snake_to_pascal(attr_name) full_pv_name_length = len(f"{pv_prefix}:{pv_name}") if full_pv_name_length > EPICS_MAX_NAME_LENGTH: attribute.enabled = False - print( + logger.warning( f"Not creating PV for {attr_name} for controller" f" {controller_api.path} as full name would exceed" f" {EPICS_MAX_NAME_LENGTH} characters" @@ -146,7 +156,7 @@ def _create_and_link_attribute_pvs( match attribute: case AttrRW(): if full_pv_name_length > (EPICS_MAX_NAME_LENGTH - 4): - print( + logger.warning( f"Not creating PVs for {attr_name} as _RBV PV" f" name would exceed {EPICS_MAX_NAME_LENGTH}" " characters" diff --git a/tests/transports/epics/ca/test_softioc.py b/tests/transports/epics/ca/test_softioc.py index d9eb3b1e5..27a53e25d 100644 --- a/tests/transports/epics/ca/test_softioc.py +++ b/tests/transports/epics/ca/test_softioc.py @@ -536,6 +536,26 @@ def test_long_pv_names_discarded(mocker: MockerFixture): ) +def test_non_1d_waveforms_discarded(mocker: MockerFixture): + api = ControllerAPI( + attributes={ + "waveform_0d": AttrR(Waveform(np.int32, shape=())), + "waveform_1d": AttrR(Waveform(np.int32, shape=(10,))), + "waveform_2d": AttrR(Waveform(np.int32, shape=(10, 2))), + "waveform_3d": AttrR(Waveform(np.int32, shape=(10, 2, 3))), + } + ) + + create_mock = mocker.patch( + "fastcs.transports.epics.ca.ioc._create_and_link_read_pv" + ) + EpicsCAIOC("DEVICE", api) + + create_mock.assert_called_once_with( + "DEVICE", "Waveform1d", "waveform_1d", api.attributes["waveform_1d"] + ) + + def test_update_datatype(mocker: MockerFixture): builder = mocker.patch("fastcs.transports.epics.ca.util.builder")