-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Create AttributeVector class similar to ControllerVector, but storing a set of Attribute by non-contiguous index. This will map onto DeviceVector[Signal] in ophyd-async. In contract to ControllerVector in that it does not implement Attribute, it is purely a Mapping[int, Attribute] for convenience.
As AttributeVector is not Attribute, there will have to be a BaseController.add_attribute_vector and add a case for it in __setattr__. Then the creation of the Controller_API should unpack these into the flat list of Attribute for transports to use.
AttributeVector should be generic on and Attribute_T, which can be AttrR, AttrW, or AttrRW (not Attribute), so that vector[0] returns the specific type. I think it won't be possible for the type checker to infer the DataType of the Attribute, though. This isn't possible:
class AttributeVector(Generic[Attribute_T, DataType_T]):
def __getitem__(self, key: int) -> Attribute_T[DataType_T]:
...
it could only do this:
class AttributeVector(Generic[DataType_T]):
def __getitem__(self, key: int) -> Attribute[DataType_T]:
...
and then you can't match on AttrR etc., you have to match on Attribute(access_mode="r").