Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1819 +/- ##
==========================================
- Coverage 99.14% 99.12% -0.03%
==========================================
Files 304 305 +1
Lines 11509 11571 +62
==========================================
+ Hits 11411 11470 +59
- Misses 98 101 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e249c69 to
0e63853
Compare
olliesilvester
left a comment
There was a problem hiding this comment.
Thanks, left some comments which are mostly trying to make it easier to read.
| moved in / out (scintillator only has motion in the y, z axes). | ||
|
|
||
| ```{raw} html | ||
| :file: ../images/scintillator-motion.svg |
There was a problem hiding this comment.
Nice diagram, but it's hard to see if using dark mode on browser. Could you put it over a white background instead of a transparent background?
Could: Add an 'x' annotation for the x axis and label the scintillator, aperture and scatterguard
There was a problem hiding this comment.
Discussed in person: I think we should remove the parts of this diagram which aren't necessary to understand the collision risk, eg the block to the left of the scatterguard. Also I think the scintillator should be moved +1 in in the x direction
| scintillator_move_miniap_x: float | ||
| scintillator_move_sg_x: float |
There was a problem hiding this comment.
nit: sg_x may not mean scatterguard to a new person - maybe just add a comment?
| return | ||
| case _: | ||
| raise ValueError( | ||
| f"Scintillator cannot be moved due to beamstop position {position}, must be in either in DATA_COLLECTION or OUT_OF_BEAM position." |
There was a problem hiding this comment.
Our scintillator and aperture scatterguard devices are currently in the "common device" section of dodal. Are we sure that the collision checks here are valid for a generic beamline? Maybe @DominicOram has some idea?
| return | ||
| case _: | ||
| raise ValueError( | ||
| f"Scintillator cannot be moved due to beamstop position {position}, must be in either in DATA_COLLECTION or OUT_OF_BEAM position." |
There was a problem hiding this comment.
Our scintillator and aperture scatterguard devices are currently in the "common device" section of dodal. Are we sure that the collision checks here are valid for a generic beamline? Maybe @DominicOram has some idea?
There was a problem hiding this comment.
They are probably specific to phase 1 beamlines but then I suspect 90% of this device is specific to phase 1 beamlines. I think this true for many of the devices in this common section and the plan was to generally keep them there until we were sure they were specific and then move them. If we want to do that now I think it probably makes sense to make a new issue that's goes through them all
There was a problem hiding this comment.
OK, we can leave it in common with a comment that it's likely MX specific. Then when someone else wants to use a scintillator we can write down the differences and try and make a common scint. Same for other MX devices in common
| scintillator_move_miniap_x: float | ||
| scintillator_move_sg_x: float |
There was a problem hiding this comment.
nit: sg_x may not mean scatterguard to a new person - maybe just a comment?
nit: Names of these variables are a bit unclear to me. Something like miniap_x_pos_for_safe_scint_move maybe?
| @@ -373,3 +389,9 @@ async def prepare(self, value: ApertureValue): | |||
| ) | |||
| else: | |||
| await self.selected_aperture.set(value) | |||
|
|
|||
| def get_scin_move_position(self) -> dict[Motor, float]: | |||
There was a problem hiding this comment.
Can you add a comment to say these are the ap + sg positions which make it safe to move the scint out? Variable name changes in https://github.com/DiamondLightSource/dodal/pull/1819/changes#r2708606396 might do the same job
src/dodal/devices/scintillator.py
Outdated
| case _: | ||
| raise ValueError(f"Cannot set scintillator to position {position}") | ||
|
|
||
| async def do_with_ap_sg_in_safe_pos(self, func): |
There was a problem hiding this comment.
Docstring would be good here, I think the function name is a bit confusing. We are:
- Saving the current ap_sg positions
- Moving the ap_sg to positions which make it safe to move the scint
- Moving the scint
- Moving ap_sg back
src/dodal/devices/scintillator.py
Outdated
|
|
||
| await self._check_beamstop_position() | ||
|
|
||
| async def move_to_new_position(): |
There was a problem hiding this comment.
I might have missed something but I can't see why this needs to be an inner function which is passed to do_with_ap_sg_in_safe_pos? I think this can just be an outer class method, which takes position as a parameter, so the code only ever defines it once
There was a problem hiding this comment.
Not sure if it's really a saving in terms of number of times it's defined - I don't think it incurs much additional overhead.
I've moved it anyway, not sure if it's an improvement
| ApertureValue.PARKED, | ||
| ], | ||
| ) | ||
| async def test_restore_ap_sg_from_scin_move_position( |
There was a problem hiding this comment.
Not sure I understand the asserts in this test. isn't it just checking that the "safe for scintillator" positions are unchanged after moving the ap_sg?
There was a problem hiding this comment.
I will rename this test, originally there was more logic in the aperture-scatterguard, but I moved it
3771af8 to
d09522c
Compare
olliesilvester
left a comment
There was a problem hiding this comment.
Please can you just adjust the diagram to as we discussed in person, other comments are optional
src/dodal/devices/scintillator.py
Outdated
| await self.z_mm.set(self._scintillator_in_yz_mm[1]) | ||
| await self.y_mm.set(self._scintillator_in_yz_mm[0]) | ||
|
|
||
| async def do_with_aperture_scatterguard_in_safe_pos(self, func): |
There was a problem hiding this comment.
nit: Are there any other functions we'd ever supply to this other than _move_to_new_position? If no, might be better to be less general with the word func, eg scintillator_move_func
| ], | ||
| ) | ||
| async def test_restore_ap_sg_from_scin_move_position( | ||
| async def test_get_scin_move_position_returns_expected( |
There was a problem hiding this comment.
This test is still a bit confusing. Unless I'm misreading, it looks like there's extra stuff that isn't needed. Canwe just have
async def test_get_scin_move_position_returns_expected(
aperture_in_medium_pos: ApertureScatterguard,
ap_sg_configuration: ApertureScatterguardConfiguration,
run_engine: RunEngine,
):
ap_sg = aperture_in_medium_pos
positions = ap_sg.get_scin_move_position()
assert (
positions[ap_sg.aperture.x] == ap_sg_configuration.scintillator_move_aperture_x
)
assert (
positions[ap_sg.scatterguard.x]
== ap_sg_configuration.scintillator_move_scatterguard_x
)
?
|
I've just had another thought about this. I thought in general we should avoid the case where doing a move at the device level causes another device to move, doing this at the plan level might be better. I won't block the PR on this decision, but this is what I'd opt for |
Co-authored-by: olliesilvester <122091460+olliesilvester@users.noreply.github.com>
I think normally I'd agree with you, however since the scintillator safe move position isn't a single well-defined position, exposing it in the aperture-scatterguard device public interface so that the scintillator could check that when it was requested to move it was safe to do so would be awkward. If someone adds the scintillator to a beamline later on, supplies the additional devices in the constructor without knowing what it does, is that any more likely than someone writing a plan that just calls an unguarded set() on the scintillator? Both would result in a collision. |
…illator_safe_move
…ets to still operate conditional on valid device positioning
Fixes
See also mx-bluesky PR
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}