tango.pyaml.multi_attribute#

Aggregated access to several scalar Tango attributes.

MultiAttribute is the Tango implementation of the pyAML DeviceAccessList aggregator: reads and writes on the managed Attribute objects are issued asynchronously and collected afterwards.

Classes

MultiAttribute([attributes, name, unit, range])

Aggregate several scalar Tango attributes into one vector access.

MultiAttributeConfig(*[, attributes, name, ...])

Configuration model for a list of Tango attributes.

class tango.pyaml.multi_attribute.MultiAttribute(attributes=None, name='', unit='', range=None)#

Bases: DeviceAccessList, DynamicValidation

Aggregate several scalar Tango attributes into one vector access.

Each managed item is an Attribute. Items can be created from the attributes paths at construction time or appended later with add_devices(); the latter is how get_aggregator() uses this class.

Parameters:
  • attributes (list of str, optional) – List of Tango attribute paths. Default is an empty list.

  • name (str, optional) – Group name.

  • unit (str, optional) – Unit shared by all attributes.

  • range (tuple(min, max), optional) – Range of valid values applied to every attribute. Use null for -∞ or +∞.

_attributes#

Tango attribute paths given at construction time.

Type:

list of str

_name#

Group name.

Type:

str

_unit#

Unit shared by all attributes.

Type:

str

_range#

Range applied to every attribute built from _attributes.

Type:

tuple of (float or None, float or None) or None

_items#

Managed attributes, in order.

Type:

list of Attribute

len()#

Return the number of managed attributes.

get_device_at(index)#

Return the managed attribute at a given position.

add_devices(devices)#

Append one or several attributes to the aggregate.

set(value)#

Write one value per attribute, asynchronously.

set_and_wait(value)#

Not implemented.

get()#

Return the last written value of every attribute.

readback()#

Return the readback value of every attribute.

get_range()#

Return the valid ranges of all attributes.

check_device_availability()#

Check whether every managed device is reachable.

unit()#

Return the unit shared by the attributes.

Notes

Reads and writes are issued with the PyTango asynchronous API (read_attribute_asynch / write_attribute_asynch) on every item first, and the replies are then collected in order. The reply timeout is the one of DeviceFactory.

add_devices(devices)#

Append one or several attributes to the aggregate.

Parameters:

devices (DeviceAccess or list of DeviceAccess) – Attribute(s) to append. Each one must be an instance of Attribute.

Raises:

pyaml.PyAMLException – If any device is not an Attribute.

check_device_availability()#

Check whether every managed device is reachable.

Returns:

boolTrue if all devices answer, False at the first unreachable one (or if there is no item).

Return type:

bool

get()#

Return the last written value of every attribute.

For writable attributes the Tango w_value (setpoint) is returned; for read-only ones the readback value is used instead.

Returns:

numpy.ndarray of float – Setpoints, one per managed attribute, in order.

Return type:

NDArray[float64]

get_device_at(index)#

Return the managed attribute at a given position.

Parameters:

index (int) – Zero-based position in the aggregate.

Returns:

DeviceAccess – The Attribute at index.

Return type:

DeviceAccess

get_range()#

Return the valid ranges of all attributes.

Returns:

list of float or None – Flattened [min0, max0, min1, max1, ...] list, one pair per managed attribute, where an unbounded limit is None.

Return type:

list[float]

len()#

Return the number of managed attributes.

Returns:

int – Number of items.

Return type:

int

readback()#

Return the readback value of every attribute.

Returns:

numpy.ndarray of float – Readback values, one per managed attribute, in order.

Return type:

array

set(value)#

Write one value per attribute, asynchronously.

All writes are issued first, then every reply is awaited so that the call returns once all devices acknowledged the write.

Parameters:

value (numpy.ndarray of float) – Values to write, one per managed attribute, in order.

Raises:

pyaml.PyAMLException – If the size of value does not match the number of items.

set_and_wait(value)#

Not implemented.

Parameters:

value (numpy.ndarray of float) – Values to write, one per managed attribute.

Raises:

NotImplementedError – Always.

unit()#

Return the unit shared by the attributes.

Returns:

str – Unit string.

Return type:

str

class tango.pyaml.multi_attribute.MultiAttributeConfig(*, attributes=[], name='', unit='', range=None)#

Bases: BaseModel

Configuration model for a list of Tango attributes.

attributes#

List of Tango attribute paths.

Type:

list of str

name#

Group name.

Type:

str, optional

unit#

Unit of the attributes.

Type:

str, optional

range#

Range of valid values. Use null for -∞ or +∞.

Type:

tuple(min, max), optional

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].