Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/fastcs/transports/epics/ca/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions tests/transports/epics/ca/test_softioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down