-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update AdSim devices and configuration to use ophyd-async (#405)
- Loading branch information
1 parent
d5722b3
commit e880833
Showing
10 changed files
with
271 additions
and
267 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
"p47": "training_rig", | ||
"p48": "training_rig", | ||
"p49": "training_rig", | ||
"t01": "adsim", | ||
} | ||
|
||
|
||
|
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 |
---|---|---|
@@ -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:", | ||
) |
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,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) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.