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
|
Aggregate several scalar Tango attributes into one vector access. |
|
Configuration model for a list of Tango attributes. |
- class tango.pyaml.multi_attribute.MultiAttribute(attributes=None, name='', unit='', range=None)#
Bases:
DeviceAccessList,DynamicValidationAggregate several scalar Tango attributes into one vector access.
Each managed item is an
Attribute. Items can be created from theattributespaths at construction time or appended later withadd_devices(); the latter is howget_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
- 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 ofDeviceFactory.- 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:
bool –
Trueif all devices answer,Falseat 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 readbackvalueis 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
Attributeatindex.- 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 isNone.- 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
valuedoes 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:
BaseModelConfiguration 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].