Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set undulator gap after XBPM is stable #726

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ def _move_and_rotation(
params: RotationScan,
oav_params: OAVParameters,
):
if params.demand_energy_ev:
yield from bps.abs_set(
composite.undulator, params.demand_energy_ev / 1000, wait=True
)
motor_time_to_speed = yield from bps.rd(composite.smargon.omega.acceleration_time)
max_vel = yield from bps.rd(composite.smargon.omega.max_velocity)
motion_values = calculate_motion_profile(params, motor_time_to_speed, max_vel)
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def fake_create_rotation_devices(
xbpm_feedback: XBPMFeedback,
):
set_mock_value(smargon.omega.max_velocity, 131)

undulator.set = MagicMock(return_value=NullStatus())
return RotationScanComposite(
attenuator=attenuator,
backlight=backlight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,20 @@ def test_rotation_scan_correctly_triggers_zocalo_callback(
mock_zocalo_interactor.return_value.run_start.assert_called_once()


def test_rotation_scan_set_undulator_gap_after_xbpm_stable(
rotation_scan_simulated_messages,
test_rotation_params: RotationScan,
):
msgs = assert_message_and_return_remaining(
rotation_scan_simulated_messages,
lambda msg: msg.command == "trigger" and msg.obj.name == "xbpm_feedback",
)

msgs = assert_message_and_return_remaining(
msgs, lambda msg: msg.command == "set" and msg.obj.name == "undulator"
)


def test_rotation_scan_fails_with_exception_when_no_beamstop(
sim_run_engine: RunEngineSimulator,
fake_create_rotation_devices: RotationScanComposite,
Expand Down
Loading