SKA Device

A generic base Tango device for SKA.

It provides a few generic attributes/properties, configures logging and also deals with some of the shortcomings of tango.server.Device.

class ska_tango_base.ska_device.SKADevice[source]

A generic base device for SKA.

LoggingLevelDefault

Device property.

Default logging level at device startup. See LoggingLevel

LoggingTargetsDefault

Device property.

Default logging targets at device startup. See the project readme for details.

init_device() None[source]

Initialise the tango device after startup.

Subclasses that have no need to override the default implementation of state management may leave init_device() alone. Override the do() method on the nested class InitCommand instead.

set_logging_level(value: LoggingLevel) None[source]

Set the logging level for the device.

Both the Python logger and the Tango logger are updated.

Parameters:

value – Logging level for logger

Raises:

LoggingLevelError – for invalid value

set_logging_targets(targets: list[str]) None[source]

Set the additional logging targets for the device.

Note that this excludes the handlers provided by the ska_ser_logging library defaults.

Parameters:

targets – Logging targets for logger

buildState() str

Read the Build State of the device.

Returns:

the build state of the device

_build_state: str

Value returned by the buildState attribute.

Should be set by subclasses during device initialisation.

Typically this will include the name of the python package, the version number of that package and a brief description of that package.

versionId() str

Read the Version Id of the device.

Returns:

the version id of the device

_version_id: str

Value returned by the versionId attribute.

Should be set by subclasses during device initialisation.

Must be of the form "<major>.<minor>.<patch>".

__init__(*args: Any, **kwargs: Any) None

Initialise object.

allow_internal_threads() Iterator[None]

Allow internal threads to run without allowing new Tango requests.

This is intended to be used from a Tango client request thread to allow internal threads to acquire the Tango monitor, without allowing another Tango request to start.

This is used in the following two places in ska-tango-base:

1. During delete_device() to allow background threads to cleanup gracefully and be joined.

If we allow other threads to run during init_device() or delete_device(), a client could initiate a new request on our device as the Tango client thread is able to grab the device lock. This should be avoided because the device is only partially initialised. This method avoids this issue by arranging for Tango client threads to be disallowed from grabbing the Tango monitor, while still allowing other internal threads to acquire the monitor.

2. At the start of every request to allow the signal bus thread to catch up.

This ensures that Tango clients get a sequentially consistent view of the Tango device. That is, if they call a command which modifies the value of an attribute then read that attribute, they will see the updated value, even if the attribute is using the signal bus (e.g. via attribute_from_signal).

always_executed_hook() None

Stall incoming request if we are only allowing internal threads.

delete_device() None

Delete the device.

device_exported_hook() None

Set up device once device and server have been exported.

This hook can be used to subscribe to events, even if to devices in the same device server, such as a self subscription.

Note, the Tango device monitor lock is not held while this hook is called.

loggingLevel(value: LoggingLevel) None

Set the logging level for the device.

Both the Python logger and the Tango logger are updated.

Parameters:

value – Logging level for logger

loggingTargets(value: list[str]) None

Set the additional logging targets for the device.

Note that this excludes the handlers provided by the ska_ser_logging library defaults.

Parameters:

value – Logging targets for logger

GetVersionInfo() list[str]

Return the version information of the device.

To modify behaviour for this command, modify the do() method of the command class.

Returns:

The device class name and its package information.