Skip to content

Conversation

noemifrisina
Copy link
Collaborator

@noemifrisina noemifrisina commented Sep 5, 2025

Fixes #1504

  • Adds a device to control the pinhole and collimator stages on I19-2 and safely move the apertures in or out. To avoid collisions, when moving to one of the apertures the pinhole stages should be moved before the collimator stages and viceversa when moving to the OUT position. It should be noted that the OUT move will only move the x motors on both stages.
  • Adds a couple of small devices to handle the MAPT configuration which holds the motor positions in controls. It's built to be usable by both hutches.

Instructions to reviewer on how to test:

  1. Run dodal connect i19-2
  2. Run tests

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

Copy link

codecov bot commented Sep 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.80%. Comparing base (b3036eb) to head (8f3ab0c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1508      +/-   ##
==========================================
+ Coverage   98.79%   98.80%   +0.01%     
==========================================
  Files         260      262       +2     
  Lines        9464     9558      +94     
==========================================
+ Hits         9350     9444      +94     
  Misses        114      114              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@noemifrisina noemifrisina mentioned this pull request Sep 3, 2025
12 tasks
@noemifrisina noemifrisina marked this pull request as ready for review October 2, 2025 16:35
@noemifrisina noemifrisina requested a review from a team as a code owner October 2, 2025 16:35
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.

Good work, thanks. Love the docs and tests. Couple of small comments



@device_factory()
def pincol() -> PinholeCollimatorControl:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I would call this something more descriptive, in a world of autocomplete being descriptive is more important than being concise. e.g. pinhole_and_collimator

from ophyd_async.epics.core import epics_signal_r, epics_signal_rw, epics_signal_x


class MAPTConfigurationTable(StandardReadable):
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 MAPT mean? Can you add to the docstring?

LOGGER.debug(f"Moving motors to {aperture_positions}")

# First move Pinhole motors,
LOGGER.debug("Move pinhole stage in")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
LOGGER.debug("Move pinhole stage in")
LOGGER.debug("Moving pinhole stage in")

self.pinhole.y.set(aperture_positions.pinhole_y),
)
# Then move Collimator motors
LOGGER.debug("Move pinhole stage in")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should:

Suggested change
LOGGER.debug("Move pinhole stage in")
LOGGER.debug("Moving collimator stage in")

_CONFIG = "-OP-PCOL-01:"


class PinColRequest(StrictEnum):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: This isn't being used in ophyd-async so can just be an Enum not a StrictEnum



class PinColRequest(StrictEnum):
"""Aperture request IN positions."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: It's not just in positions

# NOTE. Using subset enum because from the OUT positions should only be used by
# the beamline scientists from the synoptic. Another option will be needed in the
# device for OUT position.
class PinColPosition(SubsetEnum):
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 I would change this to _PinColPosition so a user is not tempted use it in the set

Comment on lines +89 to +91
self.pinhole = XYStage(f"{prefix}{pin_infix}")
self.collimator = XYStage(f"{prefix}{col_infix}")
self.mapt = PinColConfiguration(
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 would make all these private so a user isn't tempted to get round the collision detection bit

def _get_aperture_size(self, ap_request: str) -> int:
return int(ap_request.strip("um"))

async def get_motor_positions_for_requested_aperture(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: This should be private



def test_pincol_created_without_errors():
pincol = PinholeCollimatorControl("", "test_pincol")
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 this might be trying to make a real one? I would just reuse the pincol fixture here

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.

Create a device to control the pinhole and collimator stages on I19-2
2 participants