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

I24: get the beam centre from the #55

Merged
merged 19 commits into from
Nov 8, 2023
Merged

Conversation

noemifrisina
Copy link
Contributor

Fixes #42

Instead of using hard coded values that need to be updated manually, get the beam centre from display.configurations in GDA using dodal devices.

Link to dodal PR: PR220

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #55 (8d5e51f) into main (2936edd) will increase coverage by 0.68%.
The diff coverage is 73.68%.

@@            Coverage Diff             @@
##             main      #55      +/-   ##
==========================================
+ Coverage   46.88%   47.56%   +0.68%     
==========================================
  Files          19       19              
  Lines        3242     3267      +25     
==========================================
+ Hits         1520     1554      +34     
+ Misses       1722     1713       -9     
Files Coverage Δ
src/mx_bluesky/I24/serial/parameters/constants.py 100.00% <100.00%> (ø)
...esky/I24/serial/fixed_target/i24ssx_moveonclick.py 43.29% <72.22%> (+29.78%) ⬆️

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@noemifrisina noemifrisina requested review from Tom-Willemsen and DominicOram and removed request for Tom-Willemsen October 30, 2023 14:41
Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on DiamondLightSource/dodal#220 (review). I also think that the tests are testing slightly the wrong things. We don't need tests that confirm OAVParameters is reading the files and doing the calculations correctly, it's up to dodal to test that. We instead should mock out the function on OAVParamaters to give us a specific beam position and test that the ellipse gets drawn in the right place and the move on click gets calculated correctly.

# Register clicks and move chip stages
def onMouse(event, x, y, flags, param):
if event == cv.EVENT_LBUTTONUP:
beamX, beamY = get_beam_centre_from_oav()
if event == cv.EVENT_LBUTTONUP: # cv.EVENT_LBUTTONUP is an int! (=4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: What does this comment mean? I'm not sure what it adds?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To the code nothing, a note from trying to test this I forgot to remove

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, great to see things incrementally getting cleaner and better tested. Some comments in code.

# Create a video caputure from OAV1
cap = cv.VideoCapture("http://bl24i-di-serv-01.diamond.ac.uk:8080/OAV1.mjpg.mjpg")
cap = cv.VideoCapture(oav1)
# cap = cv.VideoCapture("http://bl24i-di-serv-01.diamond.ac.uk:8080/OAV1.mjpg.mjpg")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: Can you remove commented out code please?

Comment on lines 33 to 44
@patch("mx_bluesky.I24.serial.fixed_target.i24ssx_moveonclick.caput")
@patch("mx_bluesky.I24.serial.fixed_target.i24ssx_moveonclick.get_beam_centre_from_oav")
def test_onMouse__gets_beam_position_and_sends_correct_str(fake_beam_pos, fake_caput):
fake_beam_pos.side_effect = [(15, 10)]
onMouse(cv.EVENT_LBUTTONUP, 0, 0, "", "")
assert fake_caput.call_count == 2
fake_caput.assert_has_calls(
[
call(ANY, "#1J:-90"),
call(ANY, "#2J:60"),
]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: I think it would be good to parametrize this into (beam_pos, expected_J1, expected_J2) and have half a dozen or so values

Comment on lines 70 to 80
def test_get_beam_centre(
zoom_level,
expected_beamX,
expected_beamY,
fake_oav: OAV,
mock_oavparams: OAVParameters,
):
fake_oav.zoom_controller.level.sim_put(zoom_level)
beamX, beamY = _get_beam_centre(fake_oav, mock_oavparams)
assert beamX == expected_beamX
assert beamY == expected_beamY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: I think we can remove this test, dodal is doing it for us. With it removed we can then remove mock_oavparams and all the configs in conftest

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@DominicOram DominicOram merged commit 9a36e6d into main Nov 8, 2023
16 checks passed
@DominicOram DominicOram deleted the 42_beam_center_from_file branch November 8, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I24 ssx: get the beam centre from file
2 participants