Skip to content

Conversation

@jacob720
Copy link
Contributor

@jacob720 jacob720 commented Dec 17, 2025

Fixes DiamondLightSource/mx-bluesky#1525

Instead of waiting on the pin sensor, the robot waits on the smargon disable PV to be low. This makes the robot logic more robust as before the robot could block the sensor and cause false positives (thinking a pin is loaded when it is not). This should also help make the robot load plans in mx-bluesky more generic (see DiamondLightSource/mx-bluesky#1478).

Instructions to reviewer on how to test:

  1. Do thing x
  2. Confirm thing y happens

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}

@jacob720 jacob720 requested a review from a team as a code owner December 17, 2025 11:30
@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.12%. Comparing base (f919ae5) to head (061b2e4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1791   +/-   ##
=======================================
  Coverage   99.12%   99.12%           
=======================================
  Files         282      282           
  Lines       10683    10688    +5     
=======================================
+ Hits        10589    10594    +5     
  Misses         94       94           

☔ 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.

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.

Thanks, some comments in the code

Comment on lines +127 to +129
async def smargon_status_or_error(
self, expected_state: SmargonStatus = SmargonStatus.ENABLED
):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: I think this taking enable as default is no longer that clear, I would change it to just no default

Comment on lines +93 to +95
self.smargon_enabled = epics_signal_r(
SmargonStatus, prefix + "ROBOT_OP_16_BITS.B8"
)
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's going to confuse someone one day that we call this smargon_enabled but the synoptic calls it Cryojet Retract Request. Particularly as there's no reason this robot couldn't be used on a beamline with a different gonio to a smargon. I think a more generic name like beamline_enabled and a comment like "We assume that a robot action is finished, and that we are safe to proceed once the cryoject retract request is complete"

Copy link
Contributor

Choose a reason for hiding this comment

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

Must: I think the logic is also inverted. When this is high the smargon is disabled. So the name should be something like beamline_disabled

Copy link
Contributor

Choose a reason for hiding this comment

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

Must: If you run dodal connect i03 you will see this fails. This is because a StrictEnum only works when the PV is an enum type with the same enum names. In this case the PV is a binary 0/1 with no mapping:

(.venv) [ffv81422@ws455 dodal]$ caget BL03I-MO-ROBOT-01:ROBOT_OP_16_BITS.B8
BL03I-MO-ROBOT-01:ROBOT_OP_16_BITS.B8 0
(.venv) [ffv81422@ws455 dodal]$ caget -d31 BL03I-MO-ROBOT-01:ROBOT_OP_16_BITS.B8
BL03I-MO-ROBOT-01:ROBOT_OP_16_BITS.B8
    Native data type: DBF_CHAR
    Request type:     DBR_CTRL_ENUM
    Element count:    1
    Value:            Enum Index Overflow (0)
    Status:           NO_ALARM
    Severity:         NO_ALARM
    Enums:            ( 0)

There actually doesn't seem to be a great way to do this, see bluesky/ophyd-async#1168. So I think we will have to leave it as an int for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could: Also, I don't think this PV needs to be in the readables, its unlikely a user will need to read it

Comment on lines 207 to +212
await self.unload.trigger(timeout=self.LOAD_TIMEOUT)
await wait_for_value(self.program_running, False, self.NOT_BUSY_TIMEOUT)
await wait_for(
self.smargon_status_or_error(SmargonStatus.ENABLED),
timeout=self.LOAD_TIMEOUT + self.NOT_BUSY_TIMEOUT,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: I actually think there might be a race condition in here from before where the trigger may not yet have started a program running. I think to be safer we can just use exactly the same code as the load e.g. wait for disable then enable. In fact we can probably then reuse some of the code between the two

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.

Hyperion: Stop hyperion if no pin was loaded

3 participants