diff --git a/src/fastcs/backends/epics/backend.py b/src/fastcs/backends/epics/backend.py index 20373183..b02ec9ed 100644 --- a/src/fastcs/backends/epics/backend.py +++ b/src/fastcs/backends/epics/backend.py @@ -7,11 +7,16 @@ class EpicsBackend(Backend): - def __init__(self, controller: Controller, pv_prefix: str = "MY-DEVICE-PREFIX"): + def __init__( + self, + controller: Controller, + pv_prefix: str = "MY-DEVICE-PREFIX", + options: EpicsIOCOptions | None = None, + ): super().__init__(controller) self._pv_prefix = pv_prefix - self._ioc = EpicsIOC(pv_prefix, self._mapping) + self._ioc = EpicsIOC(pv_prefix, self._mapping, options=options) def create_docs(self, options: EpicsDocsOptions | None = None) -> None: EpicsDocs(self._mapping).create_docs(options) @@ -19,5 +24,5 @@ def create_docs(self, options: EpicsDocsOptions | None = None) -> None: def create_gui(self, options: EpicsGUIOptions | None = None) -> None: EpicsGUI(self._mapping, self._pv_prefix).create_gui(options) - def _run(self, options: EpicsIOCOptions | None = None): - self._ioc.run(self._dispatcher, self._context, options) + def _run(self): + self._ioc.run(self._dispatcher, self._context) diff --git a/src/fastcs/backends/epics/ioc.py b/src/fastcs/backends/epics/ioc.py index 7aa0e892..65493895 100644 --- a/src/fastcs/backends/epics/ioc.py +++ b/src/fastcs/backends/epics/ioc.py @@ -28,7 +28,10 @@ class EpicsIOCOptions: class EpicsIOC: - def __init__(self, pv_prefix: str, mapping: Mapping): + def __init__( + self, pv_prefix: str, mapping: Mapping, options: EpicsIOCOptions | None = None + ): + self.options = options or EpicsIOCOptions() _add_pvi_info(f"{pv_prefix}:PVI") _add_sub_controller_pvi_info(pv_prefix, mapping.controller) @@ -39,15 +42,12 @@ def run( self, dispatcher: AsyncioDispatcher, context: dict[str, Any], - options: EpicsIOCOptions | None = None, ) -> None: - if options is None: - options = EpicsIOCOptions() - builder.LoadDatabase() softioc.iocInit(dispatcher) - softioc.interactive_ioc(context) + if self.options.terminal: + softioc.interactive_ioc(context) def _add_pvi_info( @@ -218,6 +218,7 @@ async def async_write_display(value: T): record = _get_output_record( f"{pv_prefix}:{pv_name}", attribute, on_update=on_update ) + _add_attr_pvi_info(record, pv_prefix, attr_name, "w") attribute.set_write_display_callback(async_write_display)