You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Create ControllerVector to allow making an array of sub controllers of a given class distinguished by an index #122
In #119, we pair controllers together based on the name of the attribute. If the name of two subcontrollers foo_1/foo_2 or Foo1/Foo2 is the same then they're grouped together in the same pvi group under foo.
Problem
This is assuming too much on the FastCS side. We should instead allow controllers to have a ControllerVector called foo which can be indexed by int (not necessarily contiguous). On the transport, these elements are grouped together under foo.
Required Changes
Add a new ControllerVector which can be passed into register_subcontroller.
We wouldn't be assuming Device:Foo1 and Device:Foo83 should exist as
foo (structure):
d (structure):
v1 Device:Foo1:PVI
v83 Device:Foo83:PVI
Simply because they both have the same end string up to the number. We would have a SubControllerVector in the Device Controller called Foo with entry 1 and 83, and the above structure would be obtained, or if we just register them as controllers like normal we'd have
foo1 (structure):
d Device:Foo1:PVI
foo83 (structure):
d Device:Foo83:PVI
@evalott100 re: our very short discussion as I ran out the door. After our session today, I understand your last comment. Would it make sense to rename this issue something like "Add SubControllerVector to allow grouping multiple instances of a SubController".
Ophyd has a DeviceVector - does it also have a SignalVector? Does PandA have a use case for AttributeVector or just SubControllerVector? I think I might have a use case for it to simplify something in fastcs-odin (parameters from odin with list values that we want to split out into scalar attributes). If you don't need it right now maybe it could be done separately later?
Will close this and write a new issue with these changes (we can discuss if we want to alter these here though).
1
"Add SubControllerVector to allow grouping multiple instances of a SubController".
Sure, I think we should also include the ophyd-async style Controller parsing we were discussing:
All Attributes which are on the controller object as python attributes get added to controller._attributes: dict[str, Attribute]
All Controllers which are on the controller object as python attributes get added to controller._sub_controllers: dict[str, Controller | ControllerVector]
2
I don't really see any need for sub controllers to be their own class SubController? I think we should remove it. A subcontroller is just a controller living in another controller.
3
If you don't need it right now maybe it could be done separately later?
Yep I agree, we should only cover class ControllerVector(dict[int, Controller | ControllerVector]), we could make this a subclass of Controller/BaseController too if it ends up being more convenient, especially if we do decide to get rid of SubController.
If a transport has no interpretation of ControllerVector then it just uses each of the contained Controller values as normal from get_flattened_sub_controllers:
classController(BaseController):
defget_sub_controllers(self) ->dict[str, Controller|ControllerVector]:
returnself._controllersdefget_flattened_sub_controllers(self) ->dict[str, Controller]:
# uses sub_controller.flatten() if sub_controller is a ControllerVector
I think the difference between Controller and SubController is purely philosophical at this point, but there may be some implementation details that we will need to abstract out.
If anything downstream is discriminating based on SubController vs Controller (I can't really see why this would ever be necessary when anything other than the controller you pass into FastCS is a SubController.
changed the title [-]Allow for explicit pairing of SubControllers/Attributes[/-][+]Create ControllerVector to allow making an array of sub controllers of a given class distinguished by an index[/+]on Feb 25, 2025
Activity
GDYendell commentedon Feb 18, 2025
Could you outline how
PviTreewould change if this is done? It is not clear to me from the description.evvaaaa commentedon Feb 19, 2025
We wouldn't be assuming
Device:Foo1andDevice:Foo83should exist asSimply because they both have the same end string up to the number. We would have a
SubControllerVectorin the DeviceControllercalledFoowith entry1and83, and the above structure would be obtained, or if we just register them as controllers like normal we'd haveSame is true for attributes
GDYendell commentedon Feb 20, 2025
@evalott100 re: our very short discussion as I ran out the door. After our session today, I understand your last comment. Would it make sense to rename this issue something like "Add SubControllerVector to allow grouping multiple instances of a SubController".
Ophyd has a
DeviceVector- does it also have aSignalVector? Does PandA have a use case forAttributeVectoror justSubControllerVector? I think I might have a use case for it to simplify something in fastcs-odin (parameters from odin with list values that we want to split out into scalar attributes). If you don't need it right now maybe it could be done separately later?evvaaaa commentedon Feb 21, 2025
Will close this and write a new issue with these changes (we can discuss if we want to alter these here though).
1
Sure, I think we should also include the ophyd-async style Controller parsing we were discussing:
Attributes which are on thecontrollerobject as python attributes get added tocontroller._attributes: dict[str, Attribute]Controllers which are on thecontrollerobject as python attributes get added tocontroller._sub_controllers: dict[str, Controller | ControllerVector]2
I don't really see any need for sub controllers to be their own class
SubController? I think we should remove it. A subcontroller is just a controller living in another controller.3
Yep I agree, we should only cover
class ControllerVector(dict[int, Controller | ControllerVector]), we could make this a subclass ofController/BaseControllertoo if it ends up being more convenient, especially if we do decide to get rid ofSubController.If a transport has no interpretation of
ControllerVectorthen it just uses each of the containedControllervalues as normal fromget_flattened_sub_controllers:GDYendell commentedon Feb 21, 2025
I think the difference between Controller and SubController is purely philosophical at this point, but there may be some implementation details that we will need to abstract out.
evvaaaa commentedon Feb 21, 2025
Other than type hinting I can't see too much that relies on
SubController, other thanSubController.top_level_attribute(being deprecated)SubControllervsController(I can't really see why this would ever be necessary when anything other than the controller you pass intoFastCSis aSubController.[-]Allow for explicit pairing of SubControllers/Attributes[/-][+]Create ControllerVector to allow making an array of sub controllers of a given class distinguished by an index[/+]evvaaaa commentedon Mar 7, 2025
UPDATE
We shouldn't group
Attributes at all, onlySubController. This is incorrect in the current p4p backend.