Skip to content

Commit

Permalink
Merge branch 'mx_bluesky_640_fixes_from_beamline_testing' into 1.36.1a
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram committed Nov 28, 2024
2 parents 94e38cd + 1a81448 commit 787d041
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/dodal/devices/dcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@ def __init__(
Array1D[np.uint64],
initial_value=reflection_array,
)
self.crystal_metadata_d_spacing = epics_signal_r(float, "DSPACING:RBV")
self.crystal_metadata_d_spacing = epics_signal_r(
float, prefix + "DSPACING:RBV"
)
super().__init__(name)
4 changes: 2 additions & 2 deletions src/dodal/devices/oav/oav_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ class ZoomController(StandardReadable):
"""

def __init__(self, prefix: str, name: str = "") -> None:
super().__init__(name=name)
self.percentage = epics_signal_rw(float, f"{prefix}ZOOMPOSCMD")

# Level is the string description of the zoom level e.g. "1.0x" or "1.0"
self.level = epics_signal_rw(str, f"{prefix}MP:SELECT")
super().__init__(name=name)

async def _get_allowed_zoom_levels(self) -> list:
zoom_levels = await self.level.describe()
return zoom_levels["level"]["choices"] # type: ignore
return zoom_levels[self.level.name]["choices"] # type: ignore

@AsyncStatus.wrap
async def set(self, level_to_set: str):
Expand Down
4 changes: 2 additions & 2 deletions src/dodal/devices/oav/pin_image_recognition/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def __init__(self, prefix: str, name: str = ""):
Tip, name="triggered_tip"
)
self.triggered_top_edge, self._top_edge_setter = soft_signal_r_and_setter(
Array1D[np.uint32], name="triggered_top_edge"
Array1D[np.int32], name="triggered_top_edge"
)
self.triggered_bottom_edge, self._bottom_edge_setter = soft_signal_r_and_setter(
Array1D[np.uint32], name="triggered_bottom_edge"
Array1D[np.int32], name="triggered_bottom_edge"
)
self.array_data = epics_signal_r(Array1D[np.uint8], f"pva://{prefix}PVA:ARRAY")

Expand Down
6 changes: 2 additions & 4 deletions system_tests/test_oav_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ def test_grid_overlay(RE: RunEngine):
RE(take_snapshot_with_grid(oav, snapshot_filename, snapshot_directory))


@pytest.mark.skip(reason="No OAV in S03")
@pytest.mark.s03
async def test_get_zoom_levels():
my_zoom_controller = ZoomController("BL03S-EA-OAV-01:FZOOM:", name="test_zoom")
my_zoom_controller = ZoomController("BL03I-EA-OAV-01:FZOOM:", name="test_zoom")
await my_zoom_controller.connect()
description = await my_zoom_controller.level.describe()
assert description["zoom_controller-level"]["choices"][0] == "1.0x" # type: ignore
assert "1.0x" in await my_zoom_controller._get_allowed_zoom_levels()
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import numpy as np
from ophyd_async.core import set_mock_value

from dodal.devices.oav.pin_image_recognition import MxSampleDetect, PinTipDetection
from dodal.devices.oav.pin_image_recognition.utils import SampleLocation
from dodal.devices.oav.pin_image_recognition import (
MxSampleDetect,
PinTipDetection,
)
from dodal.devices.oav.pin_image_recognition.utils import NONE_VALUE, SampleLocation

EVENT_LOOP = asyncio.new_event_loop()

Expand Down Expand Up @@ -93,7 +96,10 @@ async def test_given_valid_data_reading_then_used_to_find_location():
device = await _get_pin_tip_detection_device()
image_array = np.array([1, 2, 3])
test_sample_location = SampleLocation(
100, 200, np.array([1, 2, 3]), np.array([4, 5, 6])
100,
200,
top_edge := np.array([NONE_VALUE, 1, 2, 3]),
bottom_edge := np.array([NONE_VALUE, 4, 5, 6]),
)
set_mock_value(device.array_data, image_array)

Expand All @@ -109,12 +115,8 @@ async def test_given_valid_data_reading_then_used_to_find_location():
process_call = mock_process_array.call_args[0][0]
assert np.array_equal(process_call, image_array)
assert np.all(location[TRIGGERED_TIP_READING]["value"] == (100, 200))
assert np.all(
location[TRIGGERED_TOP_EDGE_READING]["value"] == np.array([1, 2, 3])
)
assert np.all(
location[TRIGGERED_BOTTOM_EDGE_READING]["value"] == np.array([4, 5, 6])
)
assert np.all(location[TRIGGERED_TOP_EDGE_READING]["value"] == top_edge)
assert np.all(location[TRIGGERED_BOTTOM_EDGE_READING]["value"] == bottom_edge)
assert location[TRIGGERED_TIP_READING]["timestamp"] > 0


Expand Down
4 changes: 2 additions & 2 deletions tests/devices/unit_tests/oav/test_oav.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@


async def test_zoom_controller():
zoom_controller = ZoomController("", "fake zoom controller")
zoom_controller = ZoomController("", "zoom_controller")
await zoom_controller.connect(mock=True)
zoom_controller.level.describe = AsyncMock(
return_value={"level": {"choices": ["1.0x", "3.0x"]}}
return_value={"zoom_controller-level": {"choices": ["1.0x", "3.0x"]}}
)
status = zoom_controller.set("3.0x")
await status
Expand Down

0 comments on commit 787d041

Please sign in to comment.