Skip to content

Commit

Permalink
Add the horizontal mirror voltages (#834)
Browse files Browse the repository at this point in the history
* Adds the horizontal voltage channels.

Refactor the tests that are testing logic of one channel to be clearer that's what they're doing.
  • Loading branch information
DominicOram authored Oct 21, 2024
1 parent 32d252c commit 4f4a2fc
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 123 deletions.
10 changes: 5 additions & 5 deletions src/dodal/beamlines/i03.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from dodal.devices.eiger import EigerDetector
from dodal.devices.fast_grid_scan import PandAFastGridScan, ZebraFastGridScan
from dodal.devices.flux import Flux
from dodal.devices.focusing_mirror import FocusingMirrorWithStripes, VFMMirrorVoltages
from dodal.devices.focusing_mirror import FocusingMirrorWithStripes, MirrorVoltages
from dodal.devices.motors import XYZPositioner
from dodal.devices.oav.oav_detector import OAV, OAVConfigParams
from dodal.devices.oav.pin_image_recognition import PinTipDetection
Expand Down Expand Up @@ -123,12 +123,12 @@ def vfm(


@skip_device(lambda: BL == "s03")
def vfm_mirror_voltages(
def mirror_voltages(
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
) -> VFMMirrorVoltages:
) -> MirrorVoltages:
return device_instantiation(
device_factory=VFMMirrorVoltages,
name="vfm_mirror_voltages",
device_factory=MirrorVoltages,
name="mirror_voltages",
prefix="-MO-PSU-01:",
wait=wait_for_connection,
fake=fake_with_ophyd_sim,
Expand Down
22 changes: 14 additions & 8 deletions src/dodal/devices/focusing_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MirrorVoltageDemand(str, Enum):
SLEW = "SLEW"


class MirrorVoltageDevice(Device):
class SingleMirrorVoltage(Device):
"""Abstract the bimorph mirror voltage PVs into a single device that can be set asynchronously and returns when
the demanded voltage setpoint is accepted, without blocking the caller as this process can take significant time.
"""
Expand Down Expand Up @@ -105,22 +105,28 @@ async def set(self, value, *args, **kwargs):
await set_status


class VFMMirrorVoltages(StandardReadable):
class MirrorVoltages(StandardReadable):
def __init__(
self, name: str, prefix: str, *args, daq_configuration_path: str, **kwargs
):
self.voltage_lookup_table_path = (
daq_configuration_path + "/json/mirrorFocus.json"
)

with self.add_children_as_readables():
self.voltage_channels = DeviceVector(
{
i - 14: MirrorVoltageDevice(prefix=f"{prefix}BM:V{i}")
for i in range(14, 22)
}
)
self.horizontal_voltages = self._channels_in_range(prefix, 0, 14)
self.vertical_voltages = self._channels_in_range(prefix, 14, 22)

super().__init__(*args, name=name, **kwargs)

def _channels_in_range(self, prefix, start_idx, end_idx):
return DeviceVector(
{
i - start_idx: SingleMirrorVoltage(prefix=f"{prefix}BM:V{i}")
for i in range(start_idx, end_idx)
}
)


class FocusingMirror(StandardReadable):
"""Focusing Mirror"""
Expand Down
9 changes: 0 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
PathProvider,
)

from dodal.beamlines import i03
from dodal.common.beamlines import beamline_utils
from dodal.common.visit import (
DirectoryServiceClient,
Expand Down Expand Up @@ -92,14 +91,6 @@ def pytest_runtest_teardown():
sys.modules["dodal.beamlines.beamline_utils"].clear_devices()


@pytest.fixture
def vfm_mirror_voltages(RE: RunEngine):
voltages = i03.vfm_mirror_voltages(fake_with_ophyd_sim=True)
voltages.voltage_lookup_table_path = "tests/test_data/test_mirror_focus.json"
yield voltages
beamline_utils.clear_devices()


s03_epics_server_port = getenv("S03_EPICS_CA_SERVER_PORT")
s03_epics_repeater_port = getenv("S03_EPICS_CA_REPEATER_PORT")

Expand Down
Loading

0 comments on commit 4f4a2fc

Please sign in to comment.