Skip to content

Add enz-locum device for use in b01-1 - #2235

Merged
tomkane-dls merged 10 commits into
mainfrom
enz-locum
Oct 19, 2026
Merged

tomkane-dls merged 10 commits into
mainfrom
enz-locum

Conversation

@tomkane-dls

Copy link
Copy Markdown
Contributor
  • Create new RGBDiodes device in b01-1 devices
  • Use this with correct prefixes for the pandabox and enz locum on b01-1

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.29%. Comparing base (74113d3) to head (fb3d605).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2235   +/-   ##
=======================================
  Coverage   99.29%   99.29%           
=======================================
  Files         369      371    +2     
  Lines       14519    14583   +64     
=======================================
+ Hits        14416    14480   +64     
  Misses        103      103           

☔ View full report in Codecov by Harness.
📢 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.

@tomkane-dls
tomkane-dls marked this pull request as ready for review October 13, 2026 14:19
@tomkane-dls
tomkane-dls requested a review from a team as a code owner October 13, 2026 14:19
gain_readback (SignalR): The measuring range the amplifier is actually on.
"""

def __init__(

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.

This implementation seems very tied to our use on b01-1. Is it likely for others to use this amplifier in the future for something else, and if so, is it worth creating a base amplifier device which is more generic, and adding our specific RGB channels on top?

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.

Abigail looked in to using a current amplifier device which already exists in dodal, and then modifying it to our needs, but after some discussion it seemed vast;y over complicated for what we wanted to use it for.

Honestly, given we are using the enz locum in combination with the pandabox device for capture, i really dont know how useful it would actually be to make this more generic. Maybe @shihab-dls has a better idea on this?

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.

@tomkane-dls I still agree that the generic device that already exists is too complex for our use case, and that a custom device is needed. Splitting the concerns of this device is probably still okay; as a middle ground we could do:

class RGBDiodes(StandardReadable):
    """RGB channels read through a PandA"""

    def __init__(
        self,
        panda_prefix: str,
        amplifier_prefix: str,
        red_channel: int = 5,
        green_channel: int = 6,
        blue_channel: int = 7,
        name: str = "",
    ) -> None:
        with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL):
            self.red = epics_signal_r(int, f"{panda_prefix}{red_channel}")
            self.green = epics_signal_r(int, f"{panda_prefix}{green_channel}")
            self.blue = epics_signal_r(int, f"{panda_prefix}{blue_channel}")
        with self.add_children_as_readables(StandardReadableFormat.CHILD):
            self.amplifier = Amplifier(amplifier_prefix)
        super().__init__(name=name)

That way we have the Amplfier device (or whatever better name) for others to use, and we just compose it into our beamline specific RGBDiodes device. Similarly, you could just do inheritance, but either way @EmsArnold suggested splitting of the device could be good if you foresee another enz locum being commissioned somewhere else.

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.

Very happy to make this a little more generic, i'll give it a go. No real idea on how used enz locums actually are

@tomkane-dls tomkane-dls changed the title Add diodes/enz-locum device for use in b01-1 Add enz-locum device for use in b01-1 Oct 15, 2026
@tomkane-dls
tomkane-dls requested a review from coretl October 15, 2026 16:25
@tomkane-dls

Copy link
Copy Markdown
Contributor Author
  • Now there is a generic EnzLocum amplifier device under current_amplifiers. Claude used the template file and the other amplifiers as examples to create the Enum classes.
  • RGBDiodes is still created in ViSR's area using the enz locum in the way @shihab-dls suggested

@shihab-dls shihab-dls left a comment

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.

Looks good! I just left a few nits on the tests. Not urgent, so approving anyways.

Comment on lines +23 to +30
assert locum.range.source == "mock+ca://LOCUM:SETRANGE"
assert locum.range_readback.source == "mock+ca://LOCUM:MRREADBACK"
assert locum.range_max.source == "mock+ca://LOCUM:RANGEMAX"
assert locum.autorange.source == "mock+ca://LOCUM:AUTO"
assert locum.bias_source.source == "mock+ca://LOCUM:SETBIASV"
assert locum.bias_source_readback.source == "mock+ca://LOCUM:BIASV"
assert locum.integration_window.source == "mock+ca://LOCUM:SETWINDOW"
assert locum.integration_window_readback.source == "mock+ca://LOCUM:WINDOW"

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.

nit: I wouldn't hard code any generic checks on specific signals like this, as we'd have to amend this test when a signal is added or removed. Instead I'd do something like this:

Suggested change
assert locum.range.source == "mock+ca://LOCUM:SETRANGE"
assert locum.range_readback.source == "mock+ca://LOCUM:MRREADBACK"
assert locum.range_max.source == "mock+ca://LOCUM:RANGEMAX"
assert locum.autorange.source == "mock+ca://LOCUM:AUTO"
assert locum.bias_source.source == "mock+ca://LOCUM:SETBIASV"
assert locum.bias_source_readback.source == "mock+ca://LOCUM:BIASV"
assert locum.integration_window.source == "mock+ca://LOCUM:SETWINDOW"
assert locum.integration_window_readback.source == "mock+ca://LOCUM:WINDOW"
signals = [signal for _, signal in locum.children() if isinstance(signal, Signal)]
assert all(
signal.source.split("://", 1)[-1].startswith("LOCUM") for signal in signals
)

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.

Okay great, done. Also asserting whether there are signals at all

Comment on lines +23 to +26
assert diodes.red.source == "mock+ca://PANDA:FmcIn:Val5"
assert diodes.green.source == "mock+ca://PANDA:FmcIn:Val4"
assert diodes.blue.source == "mock+ca://PANDA:FmcIn:Val7"
assert diodes.amplifier.range.source == "mock+ca://LOCUM:SETRANGE"

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.

nit: I would just assert that the amplifier was called with the amplified_prefix LOCUM:, as checking the amplifiers signals use this prefix is covered by test_locum_uses_prefix_for_pvs.

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.

Okay added a new test - test_diodes_create_amplifier_with_its_prefix

Comment on lines +33 to +35
async def test_locum_set_range(locum: EnzLocum) -> None:
await locum.range.set(EnzLocumRange.RANGE_10NA)
assert await locum.range.get_value() == EnzLocumRange.RANGE_10NA

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.

should: I'm not sure this test is required; if this test is meant to be checking if the signal range exists, then I would do something like:

    assert type(locum.range) is SignalRW
    assert locum.range.datatype is EnzLocumRange

otherwise I would just delete the test

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.

removed

@tomkane-dls
tomkane-dls enabled auto-merge (squash) October 19, 2026 12:44
@tomkane-dls
tomkane-dls merged commit f0c45d3 into main Oct 19, 2026
10 checks passed
@tomkane-dls
tomkane-dls deleted the enz-locum branch October 19, 2026 12:58
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.

3 participants