1212
1313class MultiAttribute (DeviceAccessList ):
1414 def __init__ (self ):
15- super (). __init__ ()
15+ self . _items = []
1616
1717 def add_devices (self , devices : DeviceAccess | list [DeviceAccess ]):
1818 if isinstance (devices , list ):
@@ -23,54 +23,54 @@ def add_devices(self, devices: DeviceAccess | list[DeviceAccess]):
2323 (tango.pyaml.attribute) but got
2424 ({ device .__class__ .__name__ } )"""
2525 )
26- super () .extend (devices )
26+ self . _items .extend (devices )
2727 else :
2828 if not isinstance (devices , Attribute ):
2929 raise pyaml .PyAMLException (
3030 f"""Device must be an instance of Attribute
3131 (tango.pyaml.attribute) but got
3232 ({ devices .__class__ .__name__ } )"""
3333 )
34- super () .append (devices )
34+ self . _items .append (devices )
3535
36- def get_devices (self ) -> DeviceAccess | list [ DeviceAccess ] :
37- if len (self ) == 1 :
38- return self [ 0 ]
39- else :
40- return self
36+ def len (self ) -> int :
37+ return len (self . _items )
38+
39+ def get_device_at ( self , index : int ) -> DeviceAccess :
40+ return self . _items [ index ]
4141
4242 def set (self , value : npt .NDArray [np .float64 ]):
4343 print (f"MultiAttribute.set({ len (value )} values)" )
4444 global LAST_NB_WRITTEN
4545 LAST_NB_WRITTEN += len (value )
46- for idx , a in enumerate (self ):
46+ for idx , a in enumerate (self . _items ):
4747 a .set (value [idx ])
4848
4949 def set_and_wait (self , value : npt .NDArray [np .float64 ]):
5050 pass
5151
5252 def get (self ) -> npt .NDArray [np .float64 ]:
53- print (f"MultiAttribute.get({ len (self )} values)" )
54- return np .array ([a .get () for a in self ])
53+ print (f"MultiAttribute.get({ len (self . _items )} values)" )
54+ return np .array ([a .get () for a in self . _items ])
5555
5656 def readback (self ) -> np .array :
5757 return np .array ([])
5858
5959 def unit (self ) -> list [str ]:
60- return [a .unit () for a in self ]
60+ return [a .unit () for a in self . _items ]
6161
6262 def get_last_nb_written (self ) -> int :
6363 return self .__last_nb_written
6464
6565 def get_range (self ) -> list [float ]:
6666 attr_range : list [float ] = []
67- for device in self :
67+ for device in self . _items :
6868 attr_range .extend (device .get_range ())
6969 return attr_range
7070
7171 def check_device_availability (self ) -> bool :
7272 available = False
73- for device in self :
73+ for device in self . _items :
7474 available = device .check_device_availability ()
7575 if not available :
7676 break
0 commit comments