https://github.com/python-accelerator-middle-layer/tango-pyaml
PyAML interface to the TANGO control system
https://github.com/python-accelerator-middle-layer/tango-pyaml
Last synced: 6 months ago
JSON representation
PyAML interface to the TANGO control system
- Host: GitHub
- URL: https://github.com/python-accelerator-middle-layer/tango-pyaml
- Owner: python-accelerator-middle-layer
- License: apache-2.0
- Created: 2025-07-01T09:31:29.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-16T16:52:35.000Z (6 months ago)
- Last Synced: 2026-01-17T05:28:54.740Z (6 months ago)
- Language: Python
- Size: 94.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tango-pyaml
**Bridge between **[**Tango Controls**](https://www.tango-controls.org/)** and PyAML**
## Overview
`tango-pyaml` is a Python bridge between the [Tango control system](https://www.tango-controls.org/) and the [PyAML](https://github.com/python-accelerator-middle-layer/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.
## Features
- โ
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
## Installation
```bash
pip install tango-pyaml
```
## Requirements
- Python >= 3.9
- [PyTango](https://pytango.readthedocs.io/en/latest/) >= 9.5.1
- [PyAML](https://github.com/python-accelerator-middle-layer/pyaml)
- [pydantic](https://docs.pydantic.dev/) >= 2.0
For development and testing:
```bash
pip install tango-pyaml[dev]
```
## Usage Example
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](https://github.com/python-accelerator-middle-layer/pyaml).
Configuration file `attribute.yaml`:
```yaml
attribute: "sys/tg_test/1/float_scalar"
unit: "A"
```
Python code:
```python
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}]")
```
## Available Classes
- `Attribute` โ Read/write access to a Tango attribute
- `AttributeReadOnly` โ Read-only attribute wrapper
- `AttributeList` โ Manage a group of attributes from multiple devices
- `TangoControlSystem` โ Adapter to configure global Tango control system context
## Testing
Tests rely on mocked Tango devices and attributes using `unittest.mock`. To run tests:
```bash
pytest
```
## Project Structure
- `tango.pyaml.attribute` โ Main attribute interface
- `tango.pyaml.attribute_read_only` โ Read-only attribute implementation
- `tango.pyaml.attribute_list` โ Attribute groups with `tango.Group`
- `tango.pyaml.tango_attribute` โ Base class wrapping attribute logic
- `mocked_device_proxy.py` โ In-memory mock for Tango `DeviceProxy` and `AttributeProxy`
## License
This project is licensed under the MIT License.
## Links
- ๐งบ [Repository](https://github.com/python-accelerator-middle-layer/tango-pyaml)