Subrack subpackage

This subpackage implements subrack functionality for the MCCS.

class FanMode(value)

Python enumerated type for FanMode attribute.

MANUAL = 0

Tango Device accepts commands from all clients.

class MccsSubrack(*args, **kwargs)

A Tango device for monitor and control of the PSI-Low subrack.

class InitCommand(*args, **kwargs)

Initialisation command class for this base device.

do(*args, **kwargs)

Initialise the attributes of this MccsSubrack.

Parameters:
  • args (Any) – additional positional arguments; unused here

  • kwargs (Any) – additional keyword arguments; unused here

Return type:

tuple[ResultCode, str]

Returns:

a resultcode, message tuple

PowerDownTpms()

Power down all TPMs.

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

PowerOffTpm(argin)

Power down a TPM.

Parameters:

argin (int) – the logical id of the TPM to power down

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

PowerOnTpm(argin)

Power up a TPM.

Parameters:

argin (int) – the logical id of the TPM to power up

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

PowerUpTpms()

Power up all TPMs.

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

SetPowerSupplyFanSpeed(argin)

Set the selected power supply fan speed.

Parameters:

argin (str) –

json dictionary with mandatory keywords

  • power_supply_id (int) power supply id from 1 to 2

  • speed_percent - (float) fan speed in percent

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

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

SetSubrackFanMode(argin)

Set the selected subrack backplane fan mode.

Parameters:

argin (str) –

json dictionary with mandatory keywords

  • fan_id (int) fan id from 1 to 4

  • mode - (int) mode: 1=MANUAL, 2=AUTO

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

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

SetSubrackFanSpeed(argin)

Set the selected subrack backplane fan speed.

Parameters:

argin (str) –

json dictionary with mandatory keywords

  • subrack_fan_id (int) fan id from 1 to 4

  • speed_percent - (float) fan speed in percent

Return type:

tuple[list[ResultCode], list[Optional[str]]]

Returns:

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

__init__(*args, **kwargs)

Initialise this device object.

Parameters:
  • args (Any) – positional args to the init

  • kwargs (Any) – keyword args to the init

backplaneTemperatures()

Handle a Tango attribute read of the subrack backplane temperature.

Two values are returned, respectively for the first (bays 1-4) and second (bays 5-8) halves of the backplane.

Return type:

list[float]

Returns:

the backplane temperatures. When communication with the subrack is not established, this returns an empty list.

boardCurrent()

Handle a Tango attribute read of subrack management board current.

Total current provided by the two power supplies.

Return type:

list[float]

Returns:

total board current, in a list of length 1. When communication with the subrack is not established, this returns an empty list.

boardTemperatures()

Handle a Tango attribute read of the subrack board temperature.

Two values are returned.

Return type:

list[float]

Returns:

the board temperatures. When communication with the subrack is not established, this returns an empty list.

create_component_manager()

Create and return a component manager for this device.

Return type:

SubrackComponentManager

Returns:

a component manager for this device.

healthModelParams(argin)

Set the params for health transition rules.

Parameters:

argin (str) – JSON-string of dictionary of health states

Return type:

None

init_command_objects()

Initialise the command handlers for this device.

Return type:

None

init_device()

Initialise the device.

This is overridden here to change the Tango serialisation model.

Return type:

None

powerSupplyCurrents()

Handle a Tango attribute read of the power supply currents.

Return type:

list[float]

Returns:

the power supply currents. When communication with the subrack is not established, this returns an empty list.

powerSupplyFanSpeeds()

Handle a Tango attribute read of the power supply fan speeds.

Values expressed in percent of maximum.

Return type:

list[float]

Returns:

the power supply fan speeds. When communication with the subrack is not established, this returns an empty list.

powerSupplyPowers()

Handle a Tango attribute read of the power supply powers.

Return type:

list[float]

Returns:

the power supply powers. When communication with the subrack is not established, this returns an empty list.

powerSupplyVoltages()

Handle a Tango attribute read of the power supply voltages.

Return type:

list[float]

Returns:

the power supply voltages. When communication with the subrack is not established, this returns an empty list.

subrackFanModes()

Handle a Tango attribute read of the subrack fan modes.

Return type:

list[int]

Returns:

the subrack fan modes. When communication with the subrack is not established, this returns an empty list.

subrackFanSpeeds()

Handle a Tango attribute read of the subrack fan speeds, in RPM.

Return type:

list[float]

Returns:

the subrack fan speeds. When communication with the subrack is not established, this returns an empty list.

subrackFanSpeedsPercent()

Handle a Tango attribute read of the subrack fan speeds, in percent.

This is the commanded setpoint; the relation between this level and the actual RPMs is not linear. Subrack speed is managed automatically by the controller, by default (see subrack_fan_mode).

Commanded speed is the same for fans 1-2 and 3-4.

Return type:

list[float]

Returns:

the subrack fan speed setpoints in percent. When communication with the subrack is not established, this returns an empty list.

tpm1PowerState()

Handle a Tango attribute read of the power state of TPM 1.

Return type:

PowerState

Returns:

the power state of TPM 1.

tpm2PowerState()

Handle a Tango attribute read of the power state of TPM 2.

Return type:

PowerState

Returns:

the power state of TPM 2.

tpm3PowerState()

Handle a Tango attribute read of the power state of TPM 3.

Return type:

PowerState

Returns:

the power state of TPM 3.

tpm4PowerState()

Handle a Tango attribute read of the power state of TPM 4.

Return type:

PowerState

Returns:

the power state of TPM 4.

tpm5PowerState()

Handle a Tango attribute read of the power state of TPM 5.

Return type:

PowerState

Returns:

the power state of TPM 5.

tpm6PowerState()

Handle a Tango attribute read of the power state of TPM 6.

Return type:

PowerState

Returns:

the power state of TPM 6.

tpm7PowerState()

Handle a Tango attribute read of the power state of TPM 7.

Return type:

PowerState

Returns:

the power state of TPM 7.

tpm8PowerState()

Handle a Tango attribute read of the power state of TPM 8.

Return type:

PowerState

Returns:

the power state of TPM 8.

tpmCount()

Handle a Tango attribute read of TPM count.

Return type:

int

Returns:

the number of TPMs present in the subrack. When communication with the subrack is not established, this returns 0.

tpmCurrents()

Handle a Tango attribute read of the TPM currents.

Return type:

list[float]

Returns:

the TPM currents. When communication with the subrack is not established, this returns an empty list.

tpmPowers()

Handle a Tango attribute read of the TPM powers.

Return type:

list[float]

Returns:

the TPM powers. When communication with the subrack is not established, this returns an empty list.

tpmPresent()

Handle a Tango attribute read of which TPMs are present in the subrack.

Return type:

list[bool]

Returns:

whether a TPM is present in each bay. When communication with the subrack is not established, this returns an empty list.

tpmVoltages()

Handle a Tango attribute read of the TPM voltages.

Return type:

list[float]

Returns:

the TPM voltages

class SubrackComponentManager(subrack_ip, subrack_port, logger, communication_state_changed_callback, component_state_changed_callback, update_rate=5.0, _driver=None, _initial_power_state=ska_control_model.PowerState.ON, _initial_fail=False)

A component manager for an subrack (simulator or driver) and its power supply.

__init__(subrack_ip, subrack_port, logger, communication_state_changed_callback, component_state_changed_callback, update_rate=5.0, _driver=None, _initial_power_state=ska_control_model.PowerState.ON, _initial_fail=False)

Initialise a new instance.

Parameters:
  • subrack_ip (str) – the IP address of the subrack

  • subrack_port (int) – the subrack port

  • logger (Logger) – a logger for this object to use

  • communication_state_changed_callback (Callable[[CommunicationStatus], None]) – callback to be called when the status of the communications channel between the component manager and its component changes

  • component_state_changed_callback (Callable[..., None]) – callback to be called when the component state 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).

  • _driver (Optional[SubrackDriver]) – for testing only, we can inject a driver rather then letting the component manager create its own. If provided, this overrides driver-specific arguments such as the IP and port.

  • _initial_power_state (PowerState) – for testing only, we can set the initial power state of the simulated subrack power supply. If not provided, the default is ON, since all our current facilities with a real hardware subrack do not yet allow it to be powered on and off.

  • _initial_fail (bool) – for testing only, we can set the simulated subrack power supply to fail.

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

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

class SubrackData

This class contain data/facts about a subrack that are needed by multiple classes.

For example, the fact that a subrack contains 8 TPM bays is something that a subrack driver may need to know, a subrack Tango device may need to know, and a subrack simulator certainly needs to know. So rather than store this fact in three separate places, we store it here.

MAX_SUBRACK_FAN_SPEED = 8000.0

The maximum fan speed for the subrack.

TPM_BAY_COUNT = 8

The number of TPM bays (some bays may be empty)

class SubrackDriver(host, port, logger, communication_state_callback, component_state_callback, update_rate=5.0)

A component manager for the PSI-Low subrack.

__init__(host, port, logger, communication_state_callback, component_state_callback, update_rate=5.0)

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).

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:

ConnectionError – if an error is raised from the lower layer

Return type:

HttpPollResponse

Returns:

responses to queries in this poll

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

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

class SubrackHealthModel(component_state_changed_callback, thresholds=None)

A health model for a subrack.

__init__(component_state_changed_callback, thresholds=None)

Initialise a new instance.

Parameters:
  • component_state_changed_callback (HealthChangedCallbackProtocol) – callback to be called whenever there is a change to this this health model’s evaluated health state.

  • thresholds (Optional[dict[str, Any]]) – Thresholds for the subrack device.

evaluate_health()

Compute overall health of the subrack.

The overall health is based on the fault and communication status of the subrack overall, together with the health of the tpms that it manages.

This implementation simply sets the health of the subrack to the health of its least healthy component.

Return type:

HealthState

Returns:

an overall health of the subrack

update_data(new_states)

Update this health model with state relevant to evaluating health.

Parameters:

new_states (dict) – New states of the data points.

Return type:

None

class SubrackSimulator(**kwargs)

A simple simulator of a subrack management board web server.

class AttributeMetadataType

Type for attribute metadata dictionary.

__init__(**kwargs)

Initialise a new instance.

Parameters:

kwargs (Any) – initial values, different from the defaults, that the simulator should take.

Raises:

AttributeError – if kwargs refer to an non-existent attribute.

execute_command(name, argument)

Execute a command on the subrack hardware/simulator.

It works by checking for a method named f”_{name}”; that is, if the command name is “turn_on_tpms”, then it checks for a method named “_turn_on_tpms”. If it finds such a method, it calls it with the provided argument, and returns the return value.

Otherwise, it checks for a method named f”_async_{name}; for example, “_async_turn_on_tpms”. If it finds such a method, it simulates a long running command by returning “STARTED”, then letting a little time pass, then invoking the method.

Parameters:
  • name (str) – name of the command to execute.

  • argument (Optional[Any]) – argument to the command.

Return type:

Any

Returns:

the return value. For synchronous commands, this is the returned value of the fully executed command. For asynchronous commands, this is the string “STARTED” or “FAILED”.

Raises:

AttributeError – if the command method does not exist in the simulator.

get_attribute(name)

Return the value of a simulator attribute.

Parameters:

name (str) – name of the simulator attribute to be returned.

Return type:

Any

Returns:

the value of the attribute

set_attribute(name, value)

Set the value of a simulator attribute.

Parameters:
  • name (str) – name of the simulator attribute to be set.

  • value (Any) – new values for the simulator attribute

Return type:

Any

Returns:

the new values for the attribute

simulate_attribute(name, values)

Simulate a change in attribute value.

Parameters:
  • name (str) – name of the simulator attribute to be set.

  • values (Any) – new values for the simulator attribute

Return type:

Any

Returns:

the new values for the attribute