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

632 get flux from pv #785

Merged
merged 7 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ install_requires =
xarray
doct
databroker
dodal @ git+https://github.com/DiamondLightSource/python-dodal.git@3106d1f2e4f97bde92720d115c8fbb827ad374b1
dodal @ git+https://github.com/DiamondLightSource/python-dodal.git@b78af4a9927e3b525cbb15cabaae0271cbc06fa0
pydantic<2.0 # See https://github.com/DiamondLightSource/python-artemis/issues/774


Expand Down
6 changes: 6 additions & 0 deletions src/artemis/experiment_plans/fast_grid_scan_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Backlight,
EigerDetector,
FastGridScan,
Flux,
S4SlitGaps,
Smargon,
Synchrotron,
Expand Down Expand Up @@ -54,6 +55,7 @@ class FGSComposite:
backlight: Backlight
eiger: EigerDetector
fast_grid_scan: FastGridScan
flux: Flux
s4_slit_gaps: S4SlitGaps
sample_motors: Smargon
synchrotron: Synchrotron
Expand All @@ -74,6 +76,7 @@ def __init__(
wait_for_connection=False, fake_with_ophyd_sim=fake, params=detector_params
)
self.fast_grid_scan = i03.fast_grid_scan(fake_with_ophyd_sim=fake)
self.flux = i03.flux(fake_with_ophyd_sim=fake)
self.s4_slit_gaps = i03.s4_slit_gaps(fake_with_ophyd_sim=fake)
self.sample_motors = i03.smargon(fake_with_ophyd_sim=fake)
self.undulator = i03.undulator(fake_with_ophyd_sim=fake)
Expand Down Expand Up @@ -128,6 +131,7 @@ def read_hardware_for_ispyb(
undulator: Undulator,
synchrotron: Synchrotron,
s4_slit_gaps: S4SlitGaps,
flux: Flux,
):
artemis.log.LOGGER.info(
"Reading status of beamline parameters for ispyb deposition."
Expand All @@ -139,6 +143,7 @@ def read_hardware_for_ispyb(
yield from bps.read(synchrotron.machine_status.synchrotron_mode)
yield from bps.read(s4_slit_gaps.xgap)
yield from bps.read(s4_slit_gaps.ygap)
yield from bps.read(flux.flux_reading)
yield from bps.save()


Expand Down Expand Up @@ -208,6 +213,7 @@ def run_gridscan(
fgs_composite.undulator,
fgs_composite.synchrotron,
fgs_composite.s4_slit_gaps,
fgs_composite.flux,
)

fgs_motors = fgs_composite.fast_grid_scan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,24 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices(
fake_fgs_composite.s4_slit_gaps.xgap.user_readback.sim_put(xgap_test_value)
fake_fgs_composite.s4_slit_gaps.ygap.user_readback.sim_put(ygap_test_value)

flux_test_value = 10.0
fake_fgs_composite.flux.flux_reading.sim_put(flux_test_value)

test_ispyb_callback = FGSISPyBHandlerCallback(test_fgs_params)
test_ispyb_callback.ispyb = MagicMock()
RE.subscribe(test_ispyb_callback)

def standalone_read_hardware_for_ispyb(und, syn, slits):
def standalone_read_hardware_for_ispyb(und, syn, slits, fl):
yield from bps.open_run()
yield from read_hardware_for_ispyb(und, syn, slits)
yield from read_hardware_for_ispyb(und, syn, slits, fl)
yield from bps.close_run()

RE(
standalone_read_hardware_for_ispyb(
fake_fgs_composite.undulator,
fake_fgs_composite.synchrotron,
fake_fgs_composite.s4_slit_gaps,
fake_fgs_composite.flux,
)
)
params = test_ispyb_callback.params
Expand Down
2 changes: 1 addition & 1 deletion src/artemis/external_interaction/ispyb/ispyb_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def _parse_position(
return np.array(position)

transmission: float
flux: float
wavelength: float
beam_size_x: float
beam_size_y: float
Expand All @@ -80,6 +79,7 @@ def _parse_position(
sample_barcode: Optional[str] = None

# Optional from GDA as populated by Ophyd
flux: Optional[float] = None
undulator_gap: Optional[float] = None
synchrotron_mode: Optional[str] = None
slit_gap_size_x: Optional[float] = None
Expand Down
3 changes: 3 additions & 0 deletions src/artemis/system_tests/test_main_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ def test_cli_args_parse():
assert test_args == ("DEBUG", True, True, True)


@patch("dodal.beamlines.i03.Flux")
@patch("dodal.beamlines.i03.DetectorMotion")
@patch("dodal.beamlines.i03.OAV")
@patch("dodal.beamlines.i03.ApertureScatterguard")
Expand Down Expand Up @@ -327,6 +328,7 @@ def test_when_blueskyrunner_initiated_then_plans_are_setup_and_devices_connected
aperture_scatterguard,
oav,
detector_motion,
flux,
):
type_comparison.return_value = True
BlueskyRunner(MagicMock(), skip_startup_connection=False)
Expand All @@ -341,6 +343,7 @@ def test_when_blueskyrunner_initiated_then_plans_are_setup_and_devices_connected
aperture_scatterguard.return_value.wait_for_connection.assert_called()
oav.return_value.wait_for_connection.assert_called()
detector_motion.return_value.wait_for_connection.assert_called()
flux.return_value.wait_for_connection.assert_called()


@patch("artemis.experiment_plans.fast_grid_scan_plan.EigerDetector")
Expand Down