tidy up
This commit is contained in:
1 parent
9a94dc715d
commit
201dd96883
1 file changed
+8
-9
@@ -79,11 +79,10 @@ class MxTasks(TaskManager[RoleT]):
|
||||
@task
|
||||
def run_optical_centering(self, sample_id: int):
|
||||
"""Naive optical centering: take the loop prediction for the sample camera image and
|
||||
nudge the Smargon so that the prediction's target point sits in the beam. One view only,
|
||||
so the sample is not centred along the beam. Fails if the prediction has no target point.
|
||||
warning: Updates the sample id to whatever you enter even if it's not the real one!"""
|
||||
nudge the Smargon so that the prediction's target point sits in the beam. One view only.
|
||||
Fails if the prediction has no target point."""
|
||||
if self._client.sample_info is None or self._client.sample_info.sample_id != sample_id:
|
||||
self._client.reset_sample_info(sample_id)
|
||||
logger.error("No sample mounted, cannot run optical centring")
|
||||
self._client.scans.mv(self._client.devices.scam_zoom, 400, relative=False).wait()
|
||||
prediction = self._client.optical_prediction
|
||||
prediction.update_latest()
|
||||
@@ -91,17 +90,17 @@ class MxTasks(TaskManager[RoleT]):
|
||||
offset_mm = target_offset_mm(results) if results is not None else None
|
||||
if offset_mm is None:
|
||||
logger.warning("Optical centering: no target point predicted, not moving the sample")
|
||||
return self._optical_centering_done_update(sample_id, success=False)
|
||||
return (
|
||||
StateEndpoints.optical_centering_done(),
|
||||
MXMeasurementSequenceMessage(sample_id=sample_id, success=False),
|
||||
)
|
||||
logger.info(f"Optical centering: nudging the target point to the beam, {offset_mm=}")
|
||||
# same convention as the grid scans: a nudge by v brings the point at v into the beam
|
||||
self._client.devices.smargon.nudge_in_lab_frame(*offset_mm)
|
||||
prediction.update_latest() # the results for the grid strategy describe the centred loop
|
||||
return self._optical_centering_done_update(sample_id, success=True)
|
||||
|
||||
def _optical_centering_done_update(self, sample_id: int, *, success: bool):
|
||||
return (
|
||||
StateEndpoints.optical_centering_done(),
|
||||
MXMeasurementSequenceMessage(sample_id=sample_id, success=success),
|
||||
MXMeasurementSequenceMessage(sample_id=sample_id, success=True),
|
||||
)
|
||||
|
||||
@task
|
||||
|
||||
Reference in new issue
Block a user