Power mode hardware module (ska_low_mccs.hardware.power_mode_hardware)

This module implements classes for MCCS hardware for which the power mode can be managed; i.e. we can turn it on and off.

class BasePowerModeHardwareDriver(is_connectible)[source]

A mixin that adds an abstract on() method and an abstract power_mode property to the abstract HardwareDriver class.

check_power_mode(power_mode, error=None)[source]

Helper method to check that the hardware power mode is what it is expected to be, and raise a suitable error if it is not.

Parameters
  • power_mode (PowerMode) – the expected power mode

  • error (str) – the error message for the exception to be raise if not connected

Raises

ValueError – if the power mode is not what it is expected to be

on()[source]

Turn me on.

Raises

NotImplementedError – if this method is not implemented by a subclass

property power_mode

Return the power mode of the hardware.

Raises

NotImplementedError – if this method is not implemented by a subclass

class BasePowerModeHardwareSimulator(is_connectible=True, fail_connect=False, power_mode=<PowerMode.UNKNOWN: 0>)[source]

A mixin that add an on() method and power_mode property to a HardwareSimulator.

__init__(is_connectible=True, fail_connect=False, power_mode=<PowerMode.UNKNOWN: 0>)[source]

Initialise a new instance.

Parameters
  • is_connectible (bool) – whether it ought to be possible, initially, to connect to the hardware being simulated. For example, if the hardware we are simulating is not yet powered on, then we would not expect to be able to connect to it, and failure to do so would not be an error.

  • fail_connect (bool) – whether this simulator should initially simulate failure to connect to the hardware

  • power_mode (PowerMode) – the initial power_mode of the simulated hardware. For example, if set to ON, then this simulator will simulate connecting to hardware and finding it to be already powered on.

on()[source]

Turn me on.

property power_mode

Return the power mode of the simulated hardware.

Returns

the power mode of the simulated hardware

Return type

bool

class BasePowerModeHardwareManager(hardware_factory, health_evaluator)[source]

A base class for HardwareManager mixins.

Add an on() method and a power_mode property.

__init__(hardware_factory, health_evaluator)[source]

Initialise a new instance.

Parameters
on()[source]

Turn the hardware on.

Returns

whether successful, or None if there was nothing to do.

Return type

bool or None

property power_mode

Whether the hardware is on or not.

Returns

whether the hardware is on or not

Return type

bool

class OnOffHardwareDriver(is_connectible)[source]

A mixin that adds an abstract off() method to a hardware driver.

off()[source]

Turn the hardware off.

Raises

NotImplementedError – if this method is not implemented by a subclass

class OnOffHardwareManager(hardware_factory, health_evaluator)[source]

A HardwareManager mixin that adds an off() method.

off()[source]

Turn the hardware off.

Returns

whether successful, or None if there was nothing to do

Return type

bool or None

class OnOffHardwareSimulator(is_connectible=True, fail_connect=False, power_mode=<PowerMode.UNKNOWN: 0>)[source]

A mixin that provides a software-simulation implementation of the off() method.

off()[source]

Turn me off.

class OnStandbyHardwareDriver(is_connectible)[source]

A mixin that adds an abstract standby() method to a hardware driver.

standby()[source]

Put the hardware into low-power standby mode.

Raises

NotImplementedError – if this method is not implemented by a subclass

class OnStandbyHardwareSimulator(is_connectible=True, fail_connect=False, power_mode=<PowerMode.UNKNOWN: 0>)[source]

A mixin that provides a software-simulation implementation of the standby() method.

standby()[source]

Put me into low-power standby mode.

class OnStandbyHardwareManager(hardware_factory, health_evaluator)[source]

A HardwareManager mixin that adds an standby() method.

standby()[source]

Put the hardware into low-power standby mode.

Returns

whether successful, or None if there was nothing to do

Return type

bool or None

class OnStandbyOffHardwareDriver(is_connectible)[source]

A syntactic-sugar mixin that combines the OnOffHardwareDriver mixin with the OnStandbyHardwareDriver mixin, thus yielding a mixin that adds both off() and standby() abstract methods to a hardware driver.

class OnStandbyOffHardwareSimulator(is_connectible=True, fail_connect=False, power_mode=<PowerMode.UNKNOWN: 0>)[source]

A syntactic-sugar mixin that combines the OnOffHardwareSimulator mixin with the OnStandbyHardwareSimulator mixin, thus yielding a mixin that implements both standby() and off() methods of the OnStandbyOffHardwareDriver class.

class OnStandbyOffHardwareManager(hardware_factory, health_evaluator)[source]

A syntactic sugar HardwareManager mixin that combines both OnOffHardwareManager and OnStandbyHardwareManager, thus providing both off() and standby() methods.

class PowerMode[source]

Enumerated type for hardware power mode.

OFF = 1

The hardware is turned off.

ON = 3

The hardware is turned on. This does not imply that the hardware is currently in use.

STANDBY = 2

The hardware is in a low-power standby mode.

UNKNOWN = 0

The power mode of the hardware is unknown.