Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1084 from DiamondLightSource/dodal_298
Browse files Browse the repository at this point in the history
add unstage for zocalo
  • Loading branch information
DominicOram committed Jan 22, 2024
2 parents c7f4392 + d1e2d97 commit 67d8612
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install_requires =
xarray
doct
databroker
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@7af305b068475c474ee670fa63cce288a9665575
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@9129f255066131bf7ca5d1a19d4e19b91eb77263
pydantic<2.0 # See https://github.com/DiamondLightSource/hyperion/issues/774
scipy
zmq
Expand Down
16 changes: 12 additions & 4 deletions src/hyperion/experiment_plans/flyscan_xray_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
from dodal.devices.undulator import Undulator
from dodal.devices.xbpm_feedback import XBPMFeedback
from dodal.devices.zebra import Zebra
from dodal.devices.zocalo import (
from dodal.devices.zocalo.zocalo_results import (
ZOCALO_READING_PLAN_NAME,
ZOCALO_STAGE_GROUP,
ZocaloResults,
get_processing_result,
)
Expand Down Expand Up @@ -148,6 +149,10 @@ def wait_for_gridscan_valid(fgs_motors: FastGridScan, timeout=0.5):
def tidy_up_plans(fgs_composite: FlyScanXRayCentreComposite):
LOGGER.info("Tidying up Zebra")
yield from set_zebra_shutter_to_manual(fgs_composite.zebra)
LOGGER.info("Tidying up Zocalo")
yield from bps.unstage(
fgs_composite.zocalo
) # make sure we don't consume any other results


@bpp.set_run_key_decorator(GRIDSCAN_MAIN_PLAN)
Expand All @@ -159,7 +164,6 @@ def run_gridscan(
"plan_name": GRIDSCAN_MAIN_PLAN,
},
):
yield from bps.stage(fgs_composite.zocalo) # clear any stale processing results
sample_motors = fgs_composite.sample_motors

# Currently gridscan only works for omega 0, see #
Expand Down Expand Up @@ -194,7 +198,6 @@ def run_gridscan(
else_plan=lambda: (yield from bps.unstage(fgs_composite.eiger)),
)
def do_fgs():
yield from bps.wait() # Wait for all moves to complete
# Check topup gate
dwell_time_in_s = parameters.experiment_params.dwell_time_ms / 1000.0
total_exposure = (
Expand All @@ -206,6 +209,9 @@ def do_fgs():
30.0,
)
yield from bps.kickoff(fgs_motors)
yield from bps.wait(
ZOCALO_STAGE_GROUP
) # Make sure ZocaloResults queue is clear and ready to accept our new data
yield from bps.complete(fgs_motors, wait=True)

LOGGER.info("Waiting for arming to finish")
Expand Down Expand Up @@ -239,7 +245,9 @@ def run_gridscan_and_move(
yield from setup_zebra_for_gridscan(fgs_composite.zebra)

LOGGER.info("Starting grid scan")

yield from bps.stage(
fgs_composite.zocalo, group=ZOCALO_STAGE_GROUP
) # connect to zocalo and make sure the queue is clear
yield from run_gridscan(fgs_composite, parameters)

LOGGER.info("Grid scan finished, getting results.")
Expand Down
11 changes: 10 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,14 @@ def fake_create_rotation_devices(
)


@pytest.fixture
def zocalo(done_status):
zoc = i03.zocalo(fake_with_ophyd_sim=True)
zoc.stage = MagicMock(return_value=done_status)
zoc.unstage = MagicMock(return_value=done_status)
return zoc


@pytest.fixture
def fake_fgs_composite(
smargon: Smargon,
Expand All @@ -414,6 +422,7 @@ def fake_fgs_composite(
attenuator,
xbpm_feedback,
aperture_scatterguard,
zocalo,
):
fake_composite = FlyScanXRayCentreComposite(
aperture_scatterguard=aperture_scatterguard,
Expand All @@ -429,7 +438,7 @@ def fake_fgs_composite(
synchrotron=i03.synchrotron(fake_with_ophyd_sim=True),
xbpm_feedback=xbpm_feedback,
zebra=i03.zebra(fake_with_ophyd_sim=True),
zocalo=i03.zocalo(),
zocalo=zocalo,
)

fake_composite.eiger.stage = MagicMock(return_value=done_status)
Expand Down

0 comments on commit 67d8612

Please sign in to comment.