-
Notifications
You must be signed in to change notification settings - Fork 37
Description
The declarative approach does not currently supports sub devices:
The below gives the following error:
class SomeSubDevice(StandardReadable, EpicsDevice):
signal_r_1: A[SignalR[int], Fmt.HINTED_SIGNAL]
signal_r_2: A[SignalR[Array1D[np.float64]], Fmt.CHILD]
config_signal: A[SignalR[Array1D[np.float64]], Fmt.CONFIG_SIGNAL]
enum_signal: A[SignalR[Sequence[SomeEnum]], Fmt.CHILD]
class SomeDevice(StandardReadable, EpicsDevice):
signal_r_1: A[SignalR[int], Fmt.CHILD]
signal_r_2: A[SignalR[Array1D[np.float64]], Fmt.UNCACHED_SIGNAL]
signal_rw_1: A[SignalRW[bool], Fmt.CHILD]
signal_rw_1: A[SignalRW[bool], Fmt.CHILD]
sub_device_1: A[SomeSubDevice, Fmt.CHILD]
sub_device_2: SomeSubDevice File "/home/a5497/Code/bluesky_nexus/venv/lib/python3.12/site-packages/ophyd_async/epics/core/_epics_connector.py", line 70, in create_children_from_annotations
list(self.filler.create_devices_from_annotations())
File "/home/a5497/Code/bluesky_nexus/venv/lib/python3.12/site-packages/ophyd_async/core/_device_filler.py", line 231, in create_devices_from_annotations
device = child_type(connector=connector)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: EpicsDevice.__init__() got an unexpected keyword argument 'connector'
because all ophyd-async device annotations (whether explicitly given a StandardReadableFormat or not) are assumed to be signals:
A Device is added here:
ophyd-async/src/ophyd_async/core/_device_filler.py
Lines 166 to 167 in f96a9fa
| else: | |
| self._uncreated_devices[name] = origin |
and then attempted to be connected to as if it were a signal here:
| device = child_type(connector=connector) |
Suggestion
1 (Preferred)
We allow these devices to be connected to as if they were signals. The subdevice can only be specified declaritavely if it takes default values for this kind of device, in this case the PvSuffix for prefix and name from the annotation key.
2
We add logic here so that only signals, or DeviceVector of signals are connected to in this way.