Skip to content

Decouple interlocks from shutter#2033

Open
EmsArnold wants to merge 4 commits intomainfrom
2024_decouple_interlock_from_shutter
Open

Decouple interlocks from shutter#2033
EmsArnold wants to merge 4 commits intomainfrom
2024_decouple_interlock_from_shutter

Conversation

@EmsArnold
Copy link
Copy Markdown
Contributor

@EmsArnold EmsArnold commented Apr 28, 2026

Fixes #2024

Interlocks should be decoupled from hutch shutters. This moves all potentially useful interlocks into interlocks.py.

Instructions to reviewer on how to test:

  1. Check naming of interlocks
  2. Confirm relevant beamlines connect (i03, i15_1, i19_optics, i24)

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}

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.11%. Comparing base (0beeb31) to head (1e73829).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2033   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files         327      327           
  Lines       12814    12819    +5     
=======================================
+ Hits        12701    12706    +5     
  Misses        113      113           

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

@EmsArnold EmsArnold force-pushed the 2024_decouple_interlock_from_shutter branch 2 times, most recently from c37d1d6 to 4eff941 Compare April 29, 2026 07:24
@EmsArnold EmsArnold marked this pull request as ready for review April 29, 2026 08:38
@EmsArnold EmsArnold requested a review from a team as a code owner April 29, 2026 08:38
Copy link
Copy Markdown
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.

Looks good to me, thanks. Might be worth a second pair of eyes from @DiamondLightSource/developers-mx-daq given it changes their beamlines a little too.

@DominicOram DominicOram changed the title 2024 decouple interlock from shutter Decouple interlocks from shutter Apr 29, 2026
@EmsArnold EmsArnold force-pushed the 2024_decouple_interlock_from_shutter branch from 4eff941 to 1e73829 Compare May 6, 2026 07:02
failed and the shutter cannot be operated. Disarmed status applies only to fast
shutters.
"""
return (status == PLCInterlockState.OK) | (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it seems counterintuitive here to have an OR

a) usually something safety related will only say yes after a compound AND
( I mean that's basic / fundamental / vital )

b) the implication is that this one piece of code
is maybe covering two types of hardware and doesn't know which hardware type ( sub-genre whatever )
it is representing so has to go and ask OR type questions to cover all bases

In a situation where we are using a bit of OO
this is exactly where I'd expect one child / grandchild class to cover each hardware type in a 1:1 mapping even if it were only to override this one method

Software people will throw up their hands in horrror
but really the world should not revolve around the axis of software convenience
IMHO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From my understanding, OK is when the valve/shutter is open AND the interlocks are all okay, whereas Run Ilks OK is when the interlocks are all okay and thus the valve/shutter can be operated. The only enum specific to a device is actually Failed, which is only used for fast valves.

I think this is then a third option c) the idea is to check whether the device is safe to operate (open or closed), whereas the enum is specific to either opening or closing? I suppose the fix then would be to check if something is open and can be closed, or closed and can be opened?

@EmsArnold
Copy link
Copy Markdown
Contributor Author

@CoePaul mentioned offline:

I take that as a sign that my wondering about names like PSSInterlock
or IntPLCSomething are ill-positioned in time and scope

I thought camel case was all like

PssInterlock
and
IntPlcSomething

acronyms were supposed to be only capital on the first letter
a constant bug bear in GDA is how much UDCSomething there is when it should have been
UdcSomething ... are we really repeating that inconsistency-for-the-heck-of-it in dodal ?

I wasn't aware of the history, but am happy to change if that's the convention we're keeping to. It seems to go against pep8, so we may want think about adding this decision (and the reasoning) to the dodal style guide.

@DominicOram
Copy link
Copy Markdown
Contributor

It seems to go against pep8, so we may want think about adding this decision (and the reasoning) to the dodal style guide.

I would strongly advocate for maintaining the PEP8 rules and having acronyms as all caps. This also matches the style of the standard library e.g. HTTPStatus or BytesIO

@EmsArnold
Copy link
Copy Markdown
Contributor Author

A further note that this change will require any plans which reference HutchInterlock to be renamed to PSSInterlock, and any which reference BaseHutchInterlock to be renamed to BaseInterlock

It looks like HutchInterlock pops up a few times in mx-bluesky

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.

Interlocks should be de-coupled from hutch shutters

3 participants