tango_frame package

class AutoDispatchClient(config=None)[source]

Bases: object

Reconstruct a Python device API over a TANGO connection.

device_class defines the local Python interface. The remote TANGO device may be generated by this framework or independently implemented, as long as its commands and attributes match that interface.

Parameters:

config (Config | None)

config: Config | None = None
device_class: Type[Any] | None = None
property tango_config: Config

Return the TANGO connection configuration.

Returns:

Configuration used by this reconstructed client.

class AutoDispatchDevice(cl, name)[source]

Bases: Device

Expose an ordinary Python device class as a TANGO device server.

Subclasses set device_class to the transport-independent Python class. Public methods become TANGO commands and public properties become TANGO attributes.

TangoClassClass

alias of AutoDispatchDeviceClass

TangoClassName = 'AutoDispatchDevice'
delete_device()[source]

Release the wrapped Python device object when available.

Return type:

None

device_class: Type[Any] | None = None
excluded_commands: Set[str] = {}
init_device()[source]

Create the local Python device object when TANGO initializes it.

Raises:

RuntimeError – If no Python device class has been configured.

Return type:

None

initialize_dynamic_attributes()[source]

Install TANGO commands and attributes from the Python class.

Raises:

RuntimeError – If no Python device class has been configured.

Return type:

None

run_device_server(device_class, args=None)[source]

Run a PyTango device server class.

The helper does not force database-less operation. Normal TANGO database startup arguments can therefore be supplied by the application. -nodb remains an application-level option for local tests only.

Parameters:
  • device_class (Type[Any]) – PyTango Device subclass to run.

  • args (Sequence[str] | None) – Optional argument sequence passed to tango.server.run.

Return type:

None

Submodules

tango_frame.auto_dispatch module

Automatic adaptation between ordinary Python classes and TANGO devices.

class AutoDispatchClient(config=None)[source]

Bases: object

Reconstruct a Python device API over a TANGO connection.

device_class defines the local Python interface. The remote TANGO device may be generated by this framework or independently implemented, as long as its commands and attributes match that interface.

Parameters:

config (Config | None)

config: Config | None = None
device_class: Type[Any] | None = None
property tango_config: Config

Return the TANGO connection configuration.

Returns:

Configuration used by this reconstructed client.

class AutoDispatchDevice(cl, name)[source]

Bases: Device

Expose an ordinary Python device class as a TANGO device server.

Subclasses set device_class to the transport-independent Python class. Public methods become TANGO commands and public properties become TANGO attributes.

TangoClassClass

alias of AutoDispatchDeviceClass

TangoClassName = 'AutoDispatchDevice'
delete_device()[source]

Release the wrapped Python device object when available.

Return type:

None

device_class: Type[Any] | None = None
excluded_commands: Set[str] = {}
init_device()[source]

Create the local Python device object when TANGO initializes it.

Raises:

RuntimeError – If no Python device class has been configured.

Return type:

None

initialize_dynamic_attributes()[source]

Install TANGO commands and attributes from the Python class.

Raises:

RuntimeError – If no Python device class has been configured.

Return type:

None

tango_frame.client module

Client-side adapters for native and reconstructed TANGO devices.

class DeviceProxy(config)[source]

Bases: object

Framework proxy for a native TANGO device.

This class does not reconstruct a Python device class. It creates the native PyTango DeviceProxy from Config and transparently delegates the normal TANGO client API to it.

Parameters:

config (Config) – TANGO connection configuration.

property config: Config

Return the framework connection configuration.

Returns:

TANGO connection configuration used by this proxy.

property native_proxy: DeviceProxy

Return the underlying native PyTango proxy.

Returns:

Native tango.DeviceProxy instance.

class TangoTransport(config)[source]

Bases: object

Transport used by AutoDispatchClient for reconstructed Python APIs.

Parameters:

config (Config) – TANGO connection configuration.

command(name, value=None)[source]

Execute a TANGO command.

Parameters:
  • name (str) – TANGO command name.

  • value (Any) – Optional command input value.

Returns:

Command result returned by PyTango.

Return type:

Any

ping()[source]

Ping the remote TANGO device.

Returns:

Round-trip time reported by PyTango in microseconds.

Return type:

int

property proxy: DeviceProxy

Return the underlying native PyTango proxy.

Returns:

Native tango.DeviceProxy instance.

read_attribute(name)[source]

Read a TANGO attribute value.

Parameters:

name (str) – TANGO attribute name.

Returns:

Attribute value.

Return type:

Any

write_attribute(name, value)[source]

Write a TANGO attribute value.

Parameters:
  • name (str) – TANGO attribute name.

  • value (Any) – Value written to the attribute.

Return type:

None

tango_frame.codec module

JSON codec used when a Python call cannot use a native TANGO type.

pack_call(args, kwargs)[source]

Serialize positional and keyword arguments into one TANGO string.

Parameters:
  • args (Tuple[Any, ...]) – Positional call arguments.

  • kwargs (Dict[str, Any]) – Keyword call arguments.

Returns:

Compact JSON payload.

Return type:

str

pack_value(value)[source]

Serialize a non-native Python value.

Parameters:

value (Any) – Python value to serialize.

Returns:

Compact JSON payload.

Return type:

str

unpack_call(payload)[source]

Deserialize a call payload.

Parameters:

payload (str) – JSON call payload.

Returns:

Tuple containing positional arguments and keyword arguments.

Return type:

Tuple[Tuple[Any, …], Dict[str, Any]]

unpack_value(payload)[source]

Deserialize a non-native Python value.

Parameters:

payload (str) – JSON payload.

Returns:

Restored Python value.

Return type:

Any

tango_frame.config module

Configuration objects for TANGO client connections.

class Config(device_name, tango_host=None, database=True)[source]

Bases: object

Store the connection settings for a TANGO device.

Normal operation uses the TANGO database namespace. A database-less connection is supported only for local tests and requires tango_host.

Parameters:
  • device_name (str) – TANGO device name in domain/family/member form, or a device alias when a database is used.

  • tango_host (str | None) – TANGO database endpoint in host:port form. If omitted for a database connection, PyTango resolves the device using the process TANGO_HOST configuration.

  • database (bool) – Whether the normal TANGO database namespace is used.

device_url()[source]

Return the device identifier passed to native tango.DeviceProxy.

Returns:

Device name, alias, or a fully qualified TANGO URL.

Return type:

str

tango_frame.introspection module

Introspection helpers for ordinary Python device classes.

class MethodSpec(name, signature)[source]

Bases: NamedTuple

Describe one public Python method.

Parameters:
name

Public method name.

Type:

str

signature

Method signature without the instance self parameter.

Type:

inspect.Signature

name: str

Alias for field number 0

signature: Signature

Alias for field number 1

class PropertySpec(name, descriptor, annotation, writable)[source]

Bases: NamedTuple

Describe one public Python property.

Parameters:
name

Public property name.

Type:

str

descriptor

Original Python property descriptor.

Type:

property

annotation

Getter return annotation used for TANGO type mapping.

Type:

Any

writable

Whether the property has a setter.

Type:

bool

annotation: Any

Alias for field number 2

descriptor: property

Alias for field number 1

name: str

Alias for field number 0

writable: bool

Alias for field number 3

public_methods(device_class)[source]

Return public callable methods declared by a device class.

Parameters:

device_class (Type[Any]) – Ordinary Python device class to inspect.

Returns:

Public method specifications.

Return type:

List[MethodSpec]

public_properties(device_class)[source]

Return public properties declared by a device class.

Parameters:

device_class (Type[Any]) – Ordinary Python device class to inspect.

Returns:

Public property specifications.

Return type:

List[PropertySpec]

tango_frame.server module

Helpers for starting TANGO device servers.

run_device_server(device_class, args=None)[source]

Run a PyTango device server class.

The helper does not force database-less operation. Normal TANGO database startup arguments can therefore be supplied by the application. -nodb remains an application-level option for local tests only.

Parameters:
  • device_class (Type[Any]) – PyTango Device subclass to run.

  • args (Sequence[str] | None) – Optional argument sequence passed to tango.server.run.

Return type:

None

tango_frame.type_mapping module

Map Python 3.7 type annotations onto PyTango value types.

input_type(signature)[source]

Determine the TANGO command input type for a Python signature.

Parameters:

signature (Signature) – Python method signature without self.

Returns:

Native PyTango type, str for encoded input, or None for void.

Return type:

Any | None

is_void(annotation)[source]

Return whether an annotation represents no return value.

Parameters:

annotation (Any) – Python return annotation.

Returns:

True for None or NoneType.

Return type:

bool

output_type(signature)[source]

Determine the TANGO command output type for a Python signature.

Parameters:

signature (Signature) – Python method signature without self.

Returns:

Native PyTango type, str for encoded output, or None for void.

Return type:

Any | None

tango_array_type(annotation)[source]

Map a homogeneous list annotation to a PyTango spectrum type.

Parameters:

annotation (Any) – Python type annotation.

Returns:

PyTango high-level spectrum type, or None when unsupported.

Return type:

Any | None

tango_scalar_type(annotation)[source]

Map a scalar Python annotation to a PyTango high-level type.

Parameters:

annotation (Any) – Python type annotation.

Returns:

PyTango-compatible scalar type, or None when unsupported.

Return type:

Any | None

tango_value_type(annotation)[source]

Map a supported Python annotation to a PyTango value type.

Parameters:

annotation (Any) – Python type annotation.

Returns:

PyTango-compatible type, or None when JSON fallback is required.

Return type:

Any | None

uses_encoded_input(signature)[source]

Return whether a call requires the JSON input envelope.

Parameters:

signature (Signature) – Python method signature without self.

Returns:

True when the input cannot be represented by one native TANGO value.

Return type:

bool

uses_encoded_output(signature)[source]

Return whether a return value requires JSON encoding.

Parameters:

signature (Signature) – Python method signature without self.

Returns:

True when the return type has no native TANGO representation.

Return type:

bool