|
1 | 1 | import asyncio |
2 | | -import warnings |
3 | 2 | from collections.abc import Callable |
4 | 3 | from types import MethodType |
5 | 4 | from typing import Any, Literal |
|
13 | 12 | from fastcs.datatypes import DataType, T |
14 | 13 | from fastcs.transport.epics.util import ( |
15 | 14 | builder_callable_from_attribute, |
16 | | - get_callable_from_epics_type, |
17 | | - get_callable_to_epics_type, |
| 15 | + cast_from_epics_type, |
| 16 | + cast_to_epics_type, |
18 | 17 | record_metadata_from_attribute, |
19 | 18 | record_metadata_from_datatype, |
20 | 19 | ) |
@@ -154,10 +153,8 @@ def _create_and_link_attribute_pvs(pv_prefix: str, controller: Controller) -> No |
154 | 153 | def _create_and_link_read_pv( |
155 | 154 | pv_prefix: str, pv_name: str, attr_name: str, attribute: AttrR[T] |
156 | 155 | ) -> None: |
157 | | - cast_to_epics_type = get_callable_to_epics_type(attribute.datatype) |
158 | | - |
159 | 156 | async def async_record_set(value: T): |
160 | | - record.set(cast_to_epics_type(value)) |
| 157 | + record.set(cast_to_epics_type(attribute.datatype, value)) |
161 | 158 |
|
162 | 159 | record = _make_record(f"{pv_prefix}:{pv_name}", attribute) |
163 | 160 | _add_attr_pvi_info(record, pv_prefix, attr_name, "r") |
@@ -191,14 +188,13 @@ def datatype_updater(datatype: DataType): |
191 | 188 | def _create_and_link_write_pv( |
192 | 189 | pv_prefix: str, pv_name: str, attr_name: str, attribute: AttrW[T] |
193 | 190 | ) -> None: |
194 | | - cast_from_epics_type = get_callable_from_epics_type(attribute.datatype) |
195 | | - cast_to_epics_type = get_callable_to_epics_type(attribute.datatype) |
196 | | - |
197 | 191 | async def on_update(value): |
198 | | - await attribute.process_without_display_update(cast_from_epics_type(value)) |
| 192 | + await attribute.process_without_display_update( |
| 193 | + cast_from_epics_type(attribute.datatype, value) |
| 194 | + ) |
199 | 195 |
|
200 | 196 | async def async_write_display(value: T): |
201 | | - record.set(cast_to_epics_type(value), process=False) |
| 197 | + record.set(cast_to_epics_type(attribute.datatype, value), process=False) |
202 | 198 |
|
203 | 199 | record = _make_record(f"{pv_prefix}:{pv_name}", attribute, on_update=on_update) |
204 | 200 |
|
|
0 commit comments