Bridge between Tango Controls and PyAML
tango-pyaml
is a Python bridge between the Tango control system and the PyAML abstraction layer for control systems. It provides a set of classes that allow Tango attributes and devices to be accessed and controlled using PyAML concepts.
This library is part of the Python Accelerator Middle Layer (PyAML) ecosystem.
- ✅ Read and write Tango attributes via a unified PyAML interface
- 🔁 Support for read-only and read/write attributes
- 📊 Grouped attribute operations using
tango.Group
- 💥 Exception mapping from Tango exceptions to PyAML exceptions
- 🧹 Designed to integrate seamlessly with PyAML
ControlSystem
components - 🧪 Mocked devices for unit testing without Tango runtime
pip install tango-pyaml
For development and testing:
pip install tango-pyaml[dev]
This is an example of an explicit call to a Tango attribute using PyAML. For more details about implicit declaration and broader configuration options, please refer to the PyAML documentation.
Configuration file attribute.yaml
:
attribute: "sys/tg_test/1/float_scalar"
unit: "A"
Python code:
from tango.pyaml.attribute import Attribute
from tango.pyaml.tango_attribute import ConfigModel
import yaml
with open("attribute.yaml") as f:
cfg_dict = yaml.safe_load(f)
cfg = ConfigModel(**cfg_dict)
attr = Attribute(cfg)
attr.set(10.0)
value = attr.get()
readback = attr.readback()
print(f"Value: {value}, Readback: {readback.value} [{readback.quality}]")
Attribute
— Read/write access to a Tango attributeAttributeReadOnly
— Read-only attribute wrapperAttributeList
— Manage a group of attributes from multiple devicesTangoControlSystem
— Adapter to configure global Tango control system context
Tests rely on mocked Tango devices and attributes using unittest.mock
. To run tests:
pytest
tango.pyaml.attribute
– Main attribute interfacetango.pyaml.attribute_read_only
– Read-only attribute implementationtango.pyaml.attribute_list
– Attribute groups withtango.Group
tango.pyaml.tango_attribute
– Base class wrapping attribute logicmocked_device_proxy.py
– In-memory mock for TangoDeviceProxy
andAttributeProxy
This project is licensed under the MIT License.