Subrack Driver

This module provides for monitoring and control of an SPS subrack.

exception HttpError

Exception class for HttpErrors.

exception RequestError

Exception class for RequestExceptions.

class SubrackDriver(host, port, logger, communication_state_callback, component_state_callback, update_rate=5.0, command_update_rate=20.0, _subrack_client=None)

A component manager for an SPS subrack.

__init__(host, port, logger, communication_state_callback, component_state_callback, update_rate=5.0, command_update_rate=20.0, _subrack_client=None)

Initialise a new instance.

Parameters:
  • host (str) – the host name or IP address of the subrack management board.

  • port (int) – the port of the subrack management board.

  • logger (Logger) – a logger for this component manager to use for logging

  • communication_state_callback (Callable) – callback to be called when the status of communications between the component manager and its component changes.

  • component_state_callback (Callable) – callback to be called when the state of the component changes.

  • update_rate (float) – how often updates to attribute values should be provided. This is not necessarily the same as the rate at which the instrument is polled. For example, the instrument may be polled every 0.1 seconds, thus ensuring that any invoked commands or writes will be executed promptly. However, if the update_rate is 5.0, then routine reads of instrument values will only occur every 50th poll (i.e. every 5 seconds).

  • command_update_rate (float) – similar to update_rate but for polled commands.

  • _subrack_client (Optional[Any]) – an optional subrack client to use.

get_health_status(task_callback=None)

Read all the monitoring points available in health status.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

get_request()

Return the reads, writes and commands to be executed in the next poll.

Return type:

HttpPollRequest

Returns:

reads, writes and commands to be executed in the next poll.

off(task_callback=None)

Turn the component off.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Raises:

NotImplementedError – because this command is not yet implemented

Return type:

tuple[TaskStatus, str]

on(task_callback=None)

Turn the component on.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Raises:

NotImplementedError – because this command is not yet implemented

Return type:

tuple[TaskStatus, str]

poll(poll_request)

Poll the hardware.

Connect to the hardware, write any values that are to be written, and then read all values.

Parameters:

poll_request (HttpPollRequest) – specification of the reads and writes to be performed in this poll.

Raises:
  • RequestError – When the client returns HardwareClientResponseStatusCodes.REQUEST_EXCEPTION

  • HttpError – When the client returns HardwareClientResponseStatusCodes.HTTP_ERROR

  • ValueError – When the client returns an unknown HardwareClientResponseStatusCodes.

Return type:

HttpPollResponse

Returns:

responses to queries in this poll

poll_failed(exception)

Override parent to set PowerState.UNKNOWN when polling fails.

This is a bug fix that should be upstreamed to ska-tango-base - see MR https://gitlab.com/ska-telescope/ska-tango-base/-/merge_requests/133

Parameters:

exception (Exception) – the exception that was raised by a recent poll attempt.

Return type:

None

poll_succeeded(poll_response)

Handle the receipt of new polling values.

This is a hook called by the poller when values have been read during a poll.

Parameters:

poll_response (HttpPollResponse) – response to the pool, including any values read.

Return type:

None

polling_stopped()

Respond to polling having stopped.

This is a hook called by the poller when it stops polling.

Return type:

None

power_pdu_port_off(port_number, task_callback=None)

Turn a pdu port off.

Parameters:
  • port_number (int) – (one-based) number of the pdu port to turn off.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

power_pdu_port_on(port_number, task_callback=None)

Turn a pdu port on.

Parameters:
  • port_number (int) – (one-based) number of the pdu port to turn on.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

read_health_status()

Read all the monitoring points available in health status.

Return type:

dict

Returns:

the task status and a human-readable status message

reset(task_callback=None)

Reset the component (from fault state).

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Raises:

NotImplementedError – because this command is not yet implemented

Return type:

tuple[TaskStatus, str]

set_power_supply_fan_speed(fan_number, speed, task_callback=None)

Set the target speed of a power supply fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • speed (float) – speed setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

set_subrack_fan_mode(fan_number, mode, task_callback=None)

Set the target speed mode of a subrack fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • mode (FanMode) – speed mode setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

set_subrack_fan_speed(fan_number, speed, task_callback=None)

Set the target speed of a subrack fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • speed (float) – speed setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

standby(task_callback=None)

Put the component into low-power standby mode.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Raises:

NotImplementedError – because this command is not yet implemented

Return type:

tuple[TaskStatus, str]

turn_off_tpm(tpm_number, task_callback=None)

Turn a TPM off.

Parameters:
  • tpm_number (int) – (one-based) number of the TPM to turn off.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

turn_off_tpms(task_callback=None)

Turn all TPMs off.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

turn_on_tpm(tpm_number, task_callback=None)

Turn a TPM on.

Parameters:
  • tpm_number (int) – (one-based) number of the TPM to turn on.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

turn_on_tpms(task_callback=None)

Turn all TPMs on.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

tuple[TaskStatus, str]

Returns:

the task status and a human-readable status message

write_attribute(**kwargs)

Update subrack attribute value(s).

This doesn’t actually immediately write to the subrack. It only stores the details of the requested write where it will be picked up by the next iteration of the polling loop.

Parameters:

kwargs (Any) – keyword arguments specifying attributes to be written along with their corresponding value.

Return type:

None