Skip to content

Commit 4cebaf9

Browse files
committed
pass ioc options to EpicsIOC.__init__ instead of run
A
1 parent d1fc038 commit 4cebaf9

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/fastcs/backends/epics/backend.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@
77

88

99
class EpicsBackend(Backend):
10-
def __init__(self, controller: Controller, pv_prefix: str = "MY-DEVICE-PREFIX"):
10+
def __init__(
11+
self,
12+
controller: Controller,
13+
pv_prefix: str = "MY-DEVICE-PREFIX",
14+
options: EpicsIOCOptions | None = None,
15+
):
1116
super().__init__(controller)
1217

1318
self._pv_prefix = pv_prefix
14-
self._ioc = EpicsIOC(pv_prefix, self._mapping)
19+
self._ioc = EpicsIOC(pv_prefix, self._mapping, options=options)
1520

1621
def create_docs(self, options: EpicsDocsOptions | None = None) -> None:
1722
EpicsDocs(self._mapping).create_docs(options)
1823

1924
def create_gui(self, options: EpicsGUIOptions | None = None) -> None:
2025
EpicsGUI(self._mapping, self._pv_prefix).create_gui(options)
2126

22-
def _run(self, options: EpicsIOCOptions | None = None):
23-
self._ioc.run(self._dispatcher, self._context, options)
27+
def _run(self):
28+
self._ioc.run(self._dispatcher, self._context)

src/fastcs/backends/epics/ioc.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ class EpicsIOCOptions:
2828

2929

3030
class EpicsIOC:
31-
def __init__(self, pv_prefix: str, mapping: Mapping):
31+
def __init__(
32+
self, pv_prefix: str, mapping: Mapping, options: EpicsIOCOptions | None = None
33+
):
34+
self.options = options or EpicsIOCOptions()
3235
_add_pvi_info(f"{pv_prefix}:PVI")
3336
_add_sub_controller_pvi_info(pv_prefix, mapping.controller)
3437

@@ -39,15 +42,12 @@ def run(
3942
self,
4043
dispatcher: AsyncioDispatcher,
4144
context: dict[str, Any],
42-
options: EpicsIOCOptions | None = None,
4345
) -> None:
44-
if options is None:
45-
options = EpicsIOCOptions()
46-
4746
builder.LoadDatabase()
4847
softioc.iocInit(dispatcher)
4948

50-
softioc.interactive_ioc(context)
49+
if self.options.terminal:
50+
softioc.interactive_ioc(context)
5151

5252

5353
def _add_pvi_info(
@@ -218,6 +218,7 @@ async def async_write_display(value: T):
218218
record = _get_output_record(
219219
f"{pv_prefix}:{pv_name}", attribute, on_update=on_update
220220
)
221+
221222
_add_attr_pvi_info(record, pv_prefix, attr_name, "w")
222223

223224
attribute.set_write_display_callback(async_write_display)

0 commit comments

Comments
 (0)