|
| 1 | +from typing import cast |
| 2 | + |
| 3 | +from softioc.asyncio_dispatcher import AsyncioDispatcher |
| 4 | + |
1 | 5 | from fastcs.backend import Backend |
2 | 6 | from fastcs.controller import Controller |
3 | 7 |
|
4 | | -from .docs import EpicsDocs, EpicsDocsOptions |
5 | | -from .gui import EpicsGUI, EpicsGUIOptions |
6 | | -from .ioc import EpicsIOC, EpicsIOCOptions |
| 8 | +from .docs import EpicsDocs |
| 9 | +from .gui import EpicsGUI |
| 10 | +from .ioc import EpicsIOC |
| 11 | +from .options import EpicsOptions |
7 | 12 |
|
8 | 13 |
|
9 | 14 | class EpicsBackend(Backend): |
10 | | - def __init__(self, controller: Controller, pv_prefix: str = "MY-DEVICE-PREFIX"): |
| 15 | + def __init__( |
| 16 | + self, controller: Controller, options: EpicsOptions | None = None |
| 17 | + ) -> None: |
11 | 18 | super().__init__(controller) |
12 | 19 |
|
13 | | - self._pv_prefix = pv_prefix |
14 | | - self._ioc = EpicsIOC(pv_prefix, self._mapping) |
| 20 | + if options is None: |
| 21 | + self.options = EpicsOptions() |
| 22 | + else: |
| 23 | + self.options = options |
| 24 | + |
| 25 | + self._pv_prefix = self.options.ioc.pv_prefix |
| 26 | + self._ioc = EpicsIOC(self.options.ioc.pv_prefix, self._mapping) |
15 | 27 |
|
16 | | - def create_docs(self, options: EpicsDocsOptions | None = None) -> None: |
17 | | - EpicsDocs(self._mapping).create_docs(options) |
| 28 | + def _create_docs(self) -> None: |
| 29 | + EpicsDocs(self._mapping).create_docs(self.options.docs) |
18 | 30 |
|
19 | | - def create_gui(self, options: EpicsGUIOptions | None = None) -> None: |
20 | | - EpicsGUI(self._mapping, self._pv_prefix).create_gui(options) |
| 31 | + def _create_gui(self) -> None: |
| 32 | + EpicsGUI(self._mapping, self._pv_prefix).create_gui(self.options.gui) |
21 | 33 |
|
22 | | - def _run(self, options: EpicsIOCOptions | None = None): |
23 | | - self._ioc.run(self._dispatcher, self._context, options) |
| 34 | + def _run(self): |
| 35 | + self._ioc.run( |
| 36 | + cast(AsyncioDispatcher, self._dispatcher), self._context, self.options.ioc |
| 37 | + ) |
0 commit comments