Skip to content
1 change: 1 addition & 0 deletions src/ibex_bluesky_core/devices/dae/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def __init__(self, prefix: str, name: str = "DAE") -> None:
self.number_of_periods: DaeCheckingSignal[int] = DaeCheckingSignal(
int, f"{dae_prefix}NUMPERIODS"
)
self.max_periods: SignalR[int] = epics_signal_r(int, f"{dae_prefix}NUMPERIODS:MAX")

self.dae_settings = DaeSettings(dae_prefix)
self.period_settings = DaePeriodSettings(dae_prefix)
Expand Down
5 changes: 3 additions & 2 deletions src/ibex_bluesky_core/plans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ def adaptive_scan( # noqa: PLR0913, PLR0917

"""
yield from ensure_connected(dae, block) # type: ignore
if periods:
max_periods = yield from bps.rd(dae.max_periods)
yield from bps.mv(dae.number_of_periods, max_periods)

yield from call_qt_aware(plt.close, "all")
_, ax = yield from call_qt_aware(plt.subplots)

yield from bps.mv(dae.number_of_periods, 100)

icc = _set_up_fields_and_icc(block, dae, model, periods, save_run, ax)

@icc
Expand Down
25 changes: 24 additions & 1 deletion tests/plans/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from ophyd_async.plan_stubs import ensure_connected
from ophyd_async.sim import SimMotor
from ophyd_async.testing import callback_on_mock_put, set_mock_value
from ophyd_async.testing import callback_on_mock_put, get_mock_put, set_mock_value

from ibex_bluesky_core.devices.block import BlockMot, BlockR, BlockRw
from ibex_bluesky_core.devices.simpledae import (
Expand Down Expand Up @@ -138,6 +138,29 @@ def test_scan_does_relative_scan_when_relative_true(RE, dae, block):
assert count == bp_scan.call_args[1]["num"]


def test_adaptive_scan_with_periods_sets_max_periods(RE, dae, block):
expected = 50
set_mock_value(dae.max_periods, expected)
with (
patch("ibex_bluesky_core.plans.bp.adaptive_scan"),
patch("ibex_bluesky_core.plans.ensure_connected"),
):
RE(
adaptive_scan(
dae,
block,
1,
2,
3,
4,
5,
periods=True,
model=Gaussian().fit(),
)
)
get_mock_put(dae.number_of_periods.signal).assert_called_with(expected, wait=True)


def test_adaptive_scan_does_normal_scan_when_relative_false(RE, dae, block):
start = 0
stop = 2
Expand Down