bluesky / ophyd-async

Hardware abstraction for bluesky written using asyncio
https://blueskyproject.io/ophyd-async
BSD 3-Clause "New" or "Revised" License
8 stars 23 forks source link

Create helper for mbb(i/o)Direct records #322

Open DominicOram opened 3 months ago

DominicOram commented 3 months ago

An mbb(i/o)Direct record has the fields B0...BF (see https://epics.anl.gov/EpicsDocumentation/AppDevManuals/RecordRef/Recordref-26.html). It is probably quite likely that people will want to alias these into individual signals. e.g. In the Attenuator in dodal for the DEC_TO_BIN PV we have:

        self.calculated_filter_states: DeviceVector[SignalR[bool]] = DeviceVector(
            {
                int(digit, 16): epics_signal_r(int, f"{prefix}DEC_TO_BIN.B{digit}")
                for digit in string.hexdigits
                if digit.isupper()
            }
        )

This is quite a bit of boilerplate that is potentially useful in a generic way e.g. it would be nice if in dodal we could do something like:

from ophyd_async.epics import mbbRecord
self.calculated_filter_states: mbbRecord = mbbRecord(f"{prefix}DEC_TO_BIN")

to achieve the same result.

coretl commented 1 month ago

I suggest:

# in ophyd_async.epics.signal
def epics_mbb_direct_r(pv: str) -> DeviceVector[SignalR[bool]]:
    return DeviceVector(
            {
                i: epics_signal_r(bool, f"{pv}.B{i:X}")
                for i in range(16)
            }
        )
DominicOram commented 1 month ago

I believe I tried bools, which would be the better solution, and they failed to connect

coretl commented 1 month ago

I believe I tried bools, which would be the better solution, and they failed to connect

We should fix that too then...