Skip to content

Commit

Permalink
Tidy up again
Browse files Browse the repository at this point in the history
  • Loading branch information
noemifrisina committed Sep 3, 2024
1 parent 80442d1 commit 01b8c36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def _get_beam_centre(oav: OAV):
return oav.parameters.beam_centre_i, oav.parameters.beam_centre_j


def _calculate_zoom_calibrator(oav: OAV, RE: RunEngine):
def _calculate_zoom_calibrator(oav: OAV):
"""Set the scale for the zoom calibrator for the pmac moves."""
currentzoom = RE(bps.rd(oav.zoom_controller.percentage)).plan_result # type: ignore
currentzoom = yield from bps.rd(oav.zoom_controller.percentage)
zoomcalibrator = 1.547 - (0.03 * currentzoom) + (0.0001634 * currentzoom**2)
return zoomcalibrator

Expand All @@ -51,7 +51,7 @@ def onMouse(event, x, y, flags, param):
oav = param[2]
beamX, beamY = _get_beam_centre(oav)
logger.info(f"Clicked X and Y {x} {y}")
zoomcalibrator = _calculate_zoom_calibrator(oav, RE)
zoomcalibrator = RE(_calculate_zoom_calibrator(oav)).plan_result # type: ignore
xmove = -1 * (beamX - x) * zoomcalibrator
ymove = -1 * (beamY - y) * zoomcalibrator
logger.info(f"Moving X and Y {xmove} {ymove}")
Expand All @@ -68,7 +68,6 @@ def update_ui(oav, frame):
cv.ellipse(
frame, (beamX, beamY), (12, 8), 0.0, 0.0, 360, (0, 255, 255), thickness=2
)
# putText(frame,'text',bottomLeftCornerOfText, font, fontScale, fontColor, thickness, lineType)
cv.putText(
frame,
"Key bindings",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest.mock import ANY, MagicMock, call, patch

import bluesky.plan_stubs as bps
import cv2 as cv
import pytest
from dodal.devices.i24.pmac import PMAC
Expand Down Expand Up @@ -49,7 +50,12 @@ def test_onMouse_gets_beam_position_and_sends_correct_str(
pmac: PMAC,
RE,
):
fake_zoom_calibrator.side_effect = [ZOOMCALIBRATOR]
# fake_zoom_calibrator.return_value = ZOOMCALIBRATOR
def fake_generator(value):
yield from bps.null()
return value

fake_zoom_calibrator.side_effect = [fake_generator(ZOOMCALIBRATOR)]
fake_get_beam_pos.side_effect = [beam_position]
fake_oav: OAV = MagicMock(spec=OAV)
onMouse(cv.EVENT_LBUTTONUP, 0, 0, "", param=[RE, pmac, fake_oav])
Expand Down

0 comments on commit 01b8c36

Please sign in to comment.