Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fec152b
add energy_controller
Relm-Arrowny Oct 6, 2025
422bad7
fix pol tests
Relm-Arrowny Oct 6, 2025
4c299b1
fix linear_arbitrary_angle
Relm-Arrowny Oct 7, 2025
e38ada0
add the rest of the look up table test
Relm-Arrowny Oct 7, 2025
03e4b78
created i10Apple2
Relm-Arrowny Oct 7, 2025
de13287
Id energy and polarisation not longer has controller
Relm-Arrowny Oct 7, 2025
1ffe1e5
add all the device back
Relm-Arrowny Oct 7, 2025
013742a
change to use id energy set
Relm-Arrowny Oct 7, 2025
30a6600
fixed energy set
Relm-Arrowny Oct 7, 2025
d669df0
added missing test
Relm-Arrowny Oct 7, 2025
47caaf6
Merge branch 'main' into 1606-make-generic-energy-device
Relm-Arrowny Oct 7, 2025
ec76ef6
add laa to i10 config
Relm-Arrowny Oct 7, 2025
a6e6260
Merge branch '1606-make-generic-energy-device' of github.com:DiamondL…
Relm-Arrowny Oct 7, 2025
241aec6
correct tests
Relm-Arrowny Oct 7, 2025
f59fe79
fix docstring
Relm-Arrowny Oct 7, 2025
a8af32b
More docstring correction
Relm-Arrowny Oct 7, 2025
0dc54fe
make beamEnergy generic
Relm-Arrowny Oct 7, 2025
b868e60
tidy up
Relm-Arrowny Oct 7, 2025
cfd01d3
docstring correction
Relm-Arrowny Oct 7, 2025
93e734e
correct docstring
Relm-Arrowny Oct 7, 2025
795e225
add typing
Relm-Arrowny Oct 7, 2025
fc6d69c
make use of energy_to_motor
Relm-Arrowny Oct 9, 2025
3c38420
fix beamEnergy dostring
Relm-Arrowny Oct 9, 2025
80b539f
rename offset with id_energy_offset
Relm-Arrowny Oct 9, 2025
e614518
add energy readable to idEnergy
Relm-Arrowny Oct 9, 2025
af92351
change _energy to soft_signal_r_and_setter
Relm-Arrowny Oct 9, 2025
d785970
make polarisation Locatable
Relm-Arrowny Oct 9, 2025
5c39241
rename idEnergy to InsertionDeviceEnergy
Relm-Arrowny Oct 9, 2025
0d6fa20
rename IdPolarisation to InsertionDevicePolarisation
Relm-Arrowny Oct 9, 2025
2c9133a
create placeholder apple2 class for k07
Oct 10, 2025
778e73a
Merge branch 'main' into create_k07_apple2_id
Villtord Oct 13, 2025
3bbac20
fix ruff
Oct 13, 2025
f1f7de9
Merge branch 'main' into create_k07_apple2_id
Villtord Oct 23, 2025
458f597
roll back pgm change
Oct 23, 2025
f0bd998
Merge branches 'create_k07_apple2_id' and 'create_k07_apple2_id' of s…
Oct 23, 2025
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
61 changes: 60 additions & 1 deletion src/dodal/beamlines/k07.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
device_factory,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.devices.apple2_undulator import (
Apple2,
InsertionDeviceEnergy,
InsertionDevicePolarisation,
UndulatorGap,
UndulatorPhaseAxes,
)
from dodal.devices.k07 import K07Apple2Controller
from dodal.devices.pgm import PGM
from dodal.devices.synchrotron import Synchrotron
from dodal.log import set_beamline as set_log_beamline
Expand All @@ -28,4 +36,55 @@ class Grating(StrictEnum):
# Grating does not exist yet - this class is a placeholder for when it does
@device_factory(skip=True)
def pgm() -> PGM:
return PGM(prefix=f"{PREFIX.beamline_prefix}-OP-PGM-01:", grating=Grating)
return PGM(
prefix=f"{PREFIX.beamline_prefix}-OP-PGM-01:",
grating=Grating,
)


# Insertion device objects


# Insertion device gap and phase do not exist yet - these classes are placeholders for when they do
@device_factory(skip=True)
def id_gap() -> UndulatorGap:
return UndulatorGap(
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
)


@device_factory(skip=True)
def id_phase() -> UndulatorPhaseAxes:
return UndulatorPhaseAxes(
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
top_outer="RPQ1",
top_inner="RPQ2",
btm_inner="RPQ3",
btm_outer="RPQ4",
)


# Insertion device raw does not exist yet - this class is a placeholder for when it does
@device_factory(skip=True)
def id() -> Apple2:
return Apple2(
id_gap=id_gap(),
id_phase=id_phase(),
)


# Insertion device controller does not exist yet - this class is a placeholder for when it does
@device_factory(skip=True)
def id_controller() -> K07Apple2Controller:
return K07Apple2Controller(apple2=id())


# Insertion device energy does not exist yet - this class is a placeholder for when it does
@device_factory(skip=True)
def id_energy() -> InsertionDeviceEnergy:
return InsertionDeviceEnergy(id_controller=id_controller())


@device_factory(skip=True)
def id_polarisation() -> InsertionDevicePolarisation:
return InsertionDevicePolarisation(id_controller=id_controller())
3 changes: 3 additions & 0 deletions src/dodal/devices/k07/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .insertion_device import K07Apple2Controller

__all__ = ["K07Apple2Controller"]
23 changes: 23 additions & 0 deletions src/dodal/devices/k07/insertion_device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from dodal.devices.apple2_undulator import Apple2, Apple2Controller


# Inversion device on K07 does not exist yet - this class is a placeholder for when it does
class K07Apple2Controller(Apple2Controller):
"""K07 insertion device controller"""

def __init__(
self,
apple2: Apple2,
name: str = "",
) -> None:
super().__init__(
apple2=apple2,
energy_to_motor_converter=lambda energy, pol: (0.0, 0.0),
name=name,
)

async def _set_motors_from_energy(self, value: float) -> None:
"""
Set the undulator motors for a given energy and polarisation.
"""
pass
Empty file added tests/devices/k07/__init__.py
Empty file.
58 changes: 58 additions & 0 deletions tests/devices/k07/test_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from unittest.mock import MagicMock

import pytest
from ophyd_async.core import init_devices

from dodal.devices.apple2_undulator import (
Apple2,
InsertionDeviceEnergy,
UndulatorGap,
UndulatorPhaseAxes,
)
from dodal.devices.k07 import K07Apple2Controller


@pytest.fixture
async def id_gap() -> UndulatorGap:
async with init_devices(mock=True):
return UndulatorGap(prefix="TEST-MO-SERVC-01:")


@pytest.fixture
async def id_phase() -> UndulatorPhaseAxes:
async with init_devices(mock=True):
return UndulatorPhaseAxes(
prefix="TEST-MO-SERVC-01:",
top_outer="RPQ1",
top_inner="RPQ2",
btm_inner="RPQ3",
btm_outer="RPQ4",
)


@pytest.fixture
async def id(
id_gap: UndulatorGap,
id_phase: UndulatorPhaseAxes,
) -> Apple2:
async with init_devices(mock=True):
return Apple2(id_gap=id_gap, id_phase=id_phase)


@pytest.fixture
async def id_controller(id: Apple2) -> K07Apple2Controller:
async with init_devices(mock=True):
return K07Apple2Controller(apple2=id)


# Insertion device controller does not exist yet - this class is a placeholder for when it does
async def test_id_controller_set_energy(id_controller: K07Apple2Controller) -> None:
async with init_devices(mock=True):
id_energy = InsertionDeviceEnergy(id_controller=id_controller)
assert id_energy is not None
id_controller._set_motors_from_energy = MagicMock(
side_effect=id_controller._set_motors_from_energy
)
await id_energy.set(500.0)
id_controller._set_motors_from_energy.assert_called_once_with(500.0)
assert await id_controller.energy.get_value() == 500.0