-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from DiamondLightSource/event-loop
Enable controller initialisation on main event loop
- Loading branch information
Showing
13 changed files
with
358 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,13 @@ | ||
from softioc import asyncio_dispatcher, softioc | ||
from softioc import softioc | ||
|
||
from fastcs.backend import Backend | ||
from fastcs.mapping import Mapping | ||
from fastcs.controller import Controller | ||
|
||
|
||
class AsyncioBackend: | ||
def __init__(self, mapping: Mapping): | ||
self._mapping = mapping | ||
|
||
def run_interactive_session(self): | ||
# Create an asyncio dispatcher; the event loop is now running | ||
dispatcher = asyncio_dispatcher.AsyncioDispatcher() | ||
|
||
backend = Backend(self._mapping, dispatcher.loop) | ||
|
||
backend.link_process_tasks() | ||
backend.run_initial_tasks() | ||
backend.start_scan_tasks() | ||
class AsyncioBackend(Backend): | ||
def __init__(self, controller: Controller): # noqa: F821 | ||
super().__init__(controller) | ||
|
||
def _run(self): | ||
# Run the interactive shell | ||
global_variables = globals() | ||
global_variables.update( | ||
{ | ||
"dispatcher": dispatcher, | ||
"mapping": self._mapping, | ||
"controller": self._mapping.controller, | ||
} | ||
) | ||
softioc.interactive_ioc(globals()) | ||
softioc.interactive_ioc(self._context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
from fastcs.mapping import Mapping | ||
from fastcs.backend import Backend | ||
from fastcs.controller import Controller | ||
|
||
from .docs import EpicsDocs, EpicsDocsOptions | ||
from .gui import EpicsGUI, EpicsGUIOptions | ||
from .ioc import EpicsIOC | ||
from .ioc import EpicsIOC, EpicsIOCOptions | ||
|
||
|
||
class EpicsBackend: | ||
def __init__(self, mapping: Mapping, pv_prefix: str = "MY-DEVICE-PREFIX"): | ||
self._mapping = mapping | ||
class EpicsBackend(Backend): | ||
def __init__(self, controller: Controller, pv_prefix: str = "MY-DEVICE-PREFIX"): | ||
super().__init__(controller) | ||
|
||
self._pv_prefix = pv_prefix | ||
self._ioc = EpicsIOC(pv_prefix, self._mapping) | ||
|
||
def create_docs(self, options: EpicsDocsOptions | None = None) -> None: | ||
docs = EpicsDocs(self._mapping) | ||
docs.create_docs(options) | ||
EpicsDocs(self._mapping).create_docs(options) | ||
|
||
def create_gui(self, options: EpicsGUIOptions | None = None) -> None: | ||
gui = EpicsGUI(self._mapping, self._pv_prefix) | ||
gui.create_gui(options) | ||
EpicsGUI(self._mapping, self._pv_prefix).create_gui(options) | ||
|
||
def get_ioc(self) -> EpicsIOC: | ||
return EpicsIOC(self._mapping, self._pv_prefix) | ||
def _run(self, options: EpicsIOCOptions | None = None): | ||
self._ioc.run(self._dispatcher, self._context, options) |
Oops, something went wrong.