Repository navigation
Add enz-locum device for use in b01-1 - #2235
Conversation
tomkane-dls
commented
Oct 13, 2026
- Create new RGBDiodes device in b01-1 devices
- Use this with correct prefixes for the pandabox and enz locum on b01-1
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
| gain_readback (SignalR): The measuring range the amplifier is actually on. | ||
| """ | ||
|
|
||
| def __init__( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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
|
shihab-dls
left a comment
There was a problem hiding this comment.
Looks good! I just left a few nits on the tests. Not urgent, so approving anyways.
| 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" |
There was a problem hiding this comment.
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:
| 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 | |
| ) |
There was a problem hiding this comment.
Okay great, done. Also asserting whether there are signals at all
| 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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Okay added a new test - test_diodes_create_amplifier_with_its_prefix
| 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 |
There was a problem hiding this comment.
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 EnzLocumRangeotherwise I would just delete the test
…es device in the plan instead
…stered as a device by blueapi
c9d09ad to
fb3d605
Compare