Skip to content

Latest commit

Β 

History

History
102 lines (66 loc) Β· 2.93 KB

File metadata and controls

102 lines (66 loc) Β· 2.93 KB

tango-pyaml

Bridge between Tango Controls and PyAML

Overview

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.

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

pip install tango-pyaml

Requirements

For development and testing:

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.

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}]")

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:

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