Skip to content

Commit

Permalink
Merge branch 'main' into 442-switch-from-typeddict-to-row-wise-numpy-…
Browse files Browse the repository at this point in the history
…structured-data-for-tables
  • Loading branch information
evalott100 committed Sep 11, 2024
2 parents 49a047b + 81a6dbb commit 02c89b9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
9 changes: 5 additions & 4 deletions src/ophyd_async/epics/adsimdetector/_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ class SimDetector(StandardDetector):

def __init__(
self,
drv: adcore.ADBaseIO,
hdf: adcore.NDFileHDFIO,
prefix: str,
path_provider: PathProvider,
drv_suffix="cam1:",
hdf_suffix="HDF1:",
name: str = "",
config_sigs: Sequence[SignalR] = (),
):
self.drv = drv
self.hdf = hdf
self.drv = adcore.ADBaseIO(prefix + drv_suffix)
self.hdf = adcore.NDFileHDFIO(prefix + hdf_suffix)

super().__init__(
SimController(self.drv),
Expand Down
10 changes: 4 additions & 6 deletions tests/core/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
StaticFilenameProvider,
StaticPathProvider,
)
from ophyd_async.epics import adcore, adsimdetector
from ophyd_async.epics import adsimdetector
from ophyd_async.sim.demo import SimMotor


Expand All @@ -18,11 +18,9 @@ async def make_detector(prefix: str, name: str, tmp_path: Path):
dp = StaticPathProvider(fp, tmp_path)

async with DeviceCollector(mock=True):
drv = adcore.ADBaseIO(f"{prefix}DRV:")
hdf = adcore.NDFileHDFIO(f"{prefix}HDF:")
det = adsimdetector.SimDetector(
drv, hdf, dp, config_sigs=[drv.acquire_time, drv.acquire], name=name
)
det = adsimdetector.SimDetector(prefix, dp, name=name)

det._config_sigs = [det.drv.acquire_time, det.drv.acquire]

return det

Expand Down
25 changes: 10 additions & 15 deletions tests/epics/adsimdetector/test_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ async def make_detector(prefix: str, name: str, tmp_path: Path):
dp = StaticPathProvider(fp, tmp_path)

async with DeviceCollector(mock=True):
drv = adcore.ADBaseIO(f"{prefix}DRV:", name="drv")
hdf = adcore.NDFileHDFIO(f"{prefix}HDF:")
det = adsimdetector.SimDetector(
drv, hdf, dp, config_sigs=[drv.acquire_time, drv.acquire], name=name
)
det = adsimdetector.SimDetector(prefix, dp, name=name)
det._config_sigs = [det.drv.acquire_time, det.drv.acquire]

def _set_full_file_name(val, *args, **kwargs):
set_mock_value(hdf.full_file_name, str(tmp_path / val))
set_mock_value(det.hdf.full_file_name, str(tmp_path / val))

callback_on_mock_put(hdf.file_name, _set_full_file_name)
callback_on_mock_put(det.hdf.file_name, _set_full_file_name)

return det

Expand All @@ -60,7 +57,7 @@ def count_sim(dets: List[StandardDetector], times: int = 1):
for det in dets:
yield from bps.trigger(det, wait=False, group="wait_for_trigger")

yield from bps.sleep(0.1)
yield from bps.sleep(0.2)
[
set_mock_value(
cast(adcore.ADHDFWriter, det.writer).hdf.num_captured,
Expand Down Expand Up @@ -284,13 +281,13 @@ async def test_read_and_describe_detector(single_detector: StandardDetector):
read = await single_detector.read_configuration()
assert describe == {
"test-drv-acquire_time": {
"source": "mock+ca://TEST:DRV:AcquireTime_RBV",
"source": "mock+ca://TEST:cam1:AcquireTime_RBV",
"dtype": "number",
"dtype_numpy": "<f8",
"shape": [],
},
"test-drv-acquire": {
"source": "mock+ca://TEST:DRV:Acquire_RBV",
"source": "mock+ca://TEST:cam1:Acquire_RBV",
"dtype": "boolean",
"dtype_numpy": "|b1",
"shape": [],
Expand Down Expand Up @@ -332,20 +329,18 @@ async def test_detector_with_unnamed_or_disconnected_config_sigs(
RE, static_filename_provider: StaticFilenameProvider, tmp_path: Path
):
dp = StaticPathProvider(static_filename_provider, tmp_path)
drv = adcore.ADBaseIO("FOO:DRV:")

some_other_driver = adcore.ADBaseIO("TEST")

async with DeviceCollector(mock=True):
hdf = adcore.NDFileHDFIO("FOO:HDF:")
det = adsimdetector.SimDetector(
drv,
hdf,
"FOO:",
dp,
config_sigs=[some_other_driver.acquire_time, drv.acquire],
name="foo",
)

det._config_sigs = [some_other_driver.acquire_time, det.drv.acquire]

with pytest.raises(Exception) as exc:
RE(count_sim([det], times=1))

Expand Down

0 comments on commit 02c89b9

Please sign in to comment.