Skip to content

Commit

Permalink
Update AdSim devices and configuration to use ophyd-async (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph authored Dec 3, 2024
1 parent d5722b3 commit e880833
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 267 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ reportMissingImports = false # Ignore missing stubs in imported modules
asyncio_mode = "auto"
markers = [
"s03: marks tests as requiring the s03 simulator running (deselect with '-m \"not s03\"')",
"adsim: marks tests as requiring the containerised AreaDetector simulator running (deselect with '-m \"not adsim\"')",
"skip_in_pycharm: marks test as not working in pycharm testrunner",
]
addopts = """
Expand Down Expand Up @@ -150,7 +151,7 @@ allowlist_externals =
sphinx-build
sphinx-autobuild
commands =
tests: pytest -m 'not s03' --cov=dodal --cov-report term --cov-report xml:cov.xml {posargs}
tests: pytest -m 'not (s03 or adsim)' --cov=dodal --cov-report term --cov-report xml:cov.xml {posargs}
type-checking: pyright src tests {posargs}
pre-commit: pre-commit run --all-files --show-diff-on-failure {posargs}
docs: sphinx-{posargs:build -E} -T docs build/html
Expand Down
17 changes: 0 additions & 17 deletions src/dodal/adsim.py

This file was deleted.

1 change: 1 addition & 0 deletions src/dodal/beamlines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"p47": "training_rig",
"p48": "training_rig",
"p49": "training_rig",
"t01": "adsim",
}


Expand Down
75 changes: 75 additions & 0 deletions src/dodal/beamlines/adsim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from pathlib import Path

from ophyd_async.epics.adsimdetector import SimDetector

from dodal.common.beamlines.beamline_utils import (
device_factory,
get_path_provider,
set_path_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.visit import LocalDirectoryServiceClient, StaticVisitPathProvider
from dodal.devices.adsim import SimStage
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import BeamlinePrefix

BL = "adsim"
PREFIX = BeamlinePrefix("t01")
set_log_beamline(BL)
set_utils_beamline(BL)

set_path_provider(
StaticVisitPathProvider(
BL,
Path("/tmp"),
client=LocalDirectoryServiceClient(),
)
)

"""
Beamline module for use with the simulated AreaDetector and motors.
These devices are simulated at the EPICS level, enabling testing of
dodal and ophyd-async against what appear to be "real" signals.
Usage Example
-------------
Start the simulated beamline by following the epics-containers tutorial at
https://epics-containers.github.io/main/tutorials/launch_example.html
And ensure that the signals are visible:
```sh
export EPICS_CA_ADDR_LIST=127.0.0.1
```
How to use the devices in a plan:
In an ipython terminal run:
```python
from bluesky.run_engine import RunEngine
from dodal.beamlines.adsim import det, stage
from dodal.plans import count
RE = RunEngine()
d = det(connect_immediately=True)
s = stage(connect_immediately=True)
RE(count([d], num=10))
```
"""


@device_factory()
def stage() -> SimStage:
return SimStage(f"{PREFIX.beamline_prefix}-MO-SIMC-01:")


@device_factory()
def det() -> SimDetector:
return SimDetector(
f"{PREFIX.beamline_prefix}-DI-CAM-01:",
path_provider=get_path_provider(),
drv_suffix="DET:",
hdf_suffix="HDF:",
)
20 changes: 10 additions & 10 deletions src/dodal/devices/adsim.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from ophyd import Component, EpicsMotor, MotorBundle
from ophyd_async.core import StandardReadable
from ophyd_async.epics.motor import Motor


class SimStage(MotorBundle):
"""
ADSIM EPICS motors
"""
class SimStage(StandardReadable):
"""Simulated Sample Stage for use with the containerised simulated beamline
https://github.com/epics-containers/example-services"""

x = Component(EpicsMotor, "M1")
y = Component(EpicsMotor, "M2")
z = Component(EpicsMotor, "M3")
theta = Component(EpicsMotor, "M4")
load = Component(EpicsMotor, "M5")
def __init__(self, prefix: str, name: str = "sim"):
with self.add_children_as_readables():
self.x = Motor(prefix + "M1")
self.y = Motor(prefix + "M2")
super().__init__(name=name)
10 changes: 0 additions & 10 deletions src/dodal/devices/areadetector/__init__.py

This file was deleted.

101 changes: 0 additions & 101 deletions src/dodal/devices/areadetector/adaravis.py

This file was deleted.

47 changes: 0 additions & 47 deletions src/dodal/devices/areadetector/adsim.py

This file was deleted.

81 changes: 0 additions & 81 deletions src/dodal/devices/areadetector/adutils.py

This file was deleted.

Loading

0 comments on commit e880833

Please sign in to comment.