Skip to content
Merged
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
13 changes: 9 additions & 4 deletions src/fastcs/backends/epics/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@


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)

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)
13 changes: 7 additions & 6 deletions src/fastcs/backends/epics/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
Loading