Future Powered Interface

Base interfaces for SKA Tango devices.

class ska_tango_base.future._powered_interface.PoweredOpStateEmitMixin[source]

Bases: _BaseOpStateEmitMixin

A mixin class for a SKA powered device or its component manager.

It provides helper methods for managing the Operational State of the device.

component_off() None[source]

Update device operational state to off.

component_standby() None[source]

Update device operational state to standby.

component_on() None[source]

Update device operational state to on.

_update_op_state(**kwargs: Unpack[PoweredOpStateInput]) None[source]

Emit a change in operational state.

This is a helper method for use by subclasses.

Parameters:

kwargs – key/values for state.

class ska_tango_base.future._powered_interface.PoweredInterface[source]

Bases: PoweredOpStateEmitMixin, BaseInterface

Provides the Tango interface for an SKA device that controls a powered component.

This class extends BaseInterface with support for power state transitions (ON, OFF, STANDBY) driven by the component under control. It is up to subclasses to override various abstract methods to provide the appropriate behaviour and set the Operational State as appropriate, except for the initial state that is set in init_device().

The Operational State of an SKA Tango device is exposed as the built-in Tango device state via set_state(). Subclasses are not expected to call set_state() themselves. Instead, the state is driven automatically by calling _update_op_state() with a power keyword argument (a PowerState value), which will additionally ensure that change and archive events are sent.

The Operational State of the PoweredInterface only supports a subset of the DevState enumeration, with the following interpretations:

  • INIT: The device is initialising. Mandatory initial state for all devices.

  • ON: The system under control is powered on. Mandatory default state if the device is operational.

  • OFF: The system under control is powered off. Optional.

  • STANDBY: The system under control is in low-power standby mode. Optional.

  • FAULT: The system under control is in fault. Optional.

PoweredInterface also provides the signals _admin_mode, _commanded_state and _health_state as well as the corresponding Tango attributes adminMode, commandedState and healthState, as well as healthInfo.

The adminMode Tango attribute is writable and should not be set by subclasses of this interface.

The commandedState should be set by subclasses as appropriate, using the corresponding signal.

The healthState and healthInfo read-only attributes should be set by subclasses by calling report_health().

This interface also provides optional state transition commands Off(), Standby(), On() as well as implementations of the is_Off_allowed(), is_Standby_allowed() and is_On_allowed() methods which respect the Operational State machine.

Subclasses can provide an implementation for these commands by overriding the execute_Off(), execute_Standby() and execute_On() methods.

_commanded_state: CommandedStateSignal

Signal for the commanded Operational State of the device.

Write to this signal whenever a command is executed which will result in a state transition.

commandedState: attribute_from_signal

Attribute for the last commanded Operating State of the device.

This should be set by subclasses of this interface by writing to _commanded_state.

init_device() None[source]

Initialise the tango device after startup.

Subclasses overriding init_device() must call init_completed() once initialisation has finished.

Example

class MyDevice(PoweredInterface):
    def init_device(self) -> None:
        super().init_device()
        ...
        self.init_completed()
is_commandedState_allowed(request_type: AttReqType) bool[source]

Check if the commandedState can be read currently.

This can be overridden by subclasses to restrict when clients can access the attribute.

read_commandedState() str | tuple[str, float, AttrQuality][source]

Read the commanded state of the device.

Subclasses can override this to change the behaviour of the commandedState attribute.

is_Standby_allowed(request_type: LRCReqType | None = None) bool[source]

Return whether the Standby() command may be called currently.

This method can be overridden by subclasses to change when this command is allowed.

Returns:

whether the command may be called in the current device state

execute_Standby() tuple[list[ResultCode], list[str]][source]

Execute the standard Standby command.

This method must be overridden by a subclass to enable the Tango command, otherwise the command will not be part of the device interface. The submit_lrc_task() decorator can be used to make Standby a long running command.

If implemented, this command should put the device in standby mode and result in the operational state transitioning to STANDBY. The command should not return until the transition has occurred.

Returns:

A tuple containing a return code and a string message indicating status or a command ID. The message is for information purpose only.

is_Off_allowed(request_type: LRCReqType | None = None) bool[source]

Return whether the Off() command may be called currently.

This method can be overridden by subclasses to change when this command is allowed.

Returns:

whether the command may be called in the current device state

execute_Off() tuple[list[ResultCode], list[str]][source]

Execute the standard Off command.

This method must be overridden by a subclass to enable the Tango command, otherwise the command will not be part of the device interface. The submit_lrc_task() decorator can be used to make Off a long running command.

If implemented, this command should turn the device off and result in the operational state transitioning to OFF. The command should not return until the transition has occurred.

Returns:

A tuple containing a return code and a string message indicating status or a command ID. The message is for information purpose only.

is_On_allowed(request_type: LRCReqType | None = None) bool[source]

Return whether the On() command may be called currently.

This method can be overridden by subclasses to change when this command is allowed.

Returns:

whether the command may be called in the current device state

execute_On() tuple[list[ResultCode], list[str]][source]

Execute the standard On command.

This method must be overridden by a subclass to enable the Tango command, otherwise the command will not be part of the device interface. The submit_lrc_task() decorator can be used to make On a long running command.

If implemented, this command should turn the device on and result in the operational state transitioning to ON. The command should not return until the transition has occurred.

Returns:

A tuple containing a return code and a string message indicating status or a command ID. The message is for information purpose only.

On() tuple[list[ResultCode], list[str]][source]

Turn the device on.

Subclasses should override the execute_On() method to change the behaviour of this command.

Returns:

A tuple containing a return code and a string message indicating status or a command ID. The message is for information purpose only.

Standby() tuple[list[ResultCode], list[str]][source]

Put the device into standby mode.

Subclasses should override the execute_Standby() method to change the behaviour of this command.

Returns:

A tuple containing a return code and a string message indicating status or a command ID. The message is for information purpose only.

Off() tuple[list[ResultCode], list[str]][source]

Turn the device off.

Subclasses should override the execute_Off() method to change the behaviour of this command.

Returns:

A tuple containing a return code and a string message indicating status or a command ID. The message is for information purpose only.