PowerSwitchDriver

class ska_mid_cbf_mcs.power_switch.power_switch_driver.PowerSwitchDriver(protocol: str, ip: str, login: str, password: str, content_type: str, outlet_list_url: str, outlet_state_url: str, outlet_control_url: str, turn_on_action: str, turn_off_action: str, state_on: str, state_off: str, outlet_schema_file: str, outlet_id_list: List[str], logger: Logger)[source]

Bases: object

A driver for the DLI web power switch.

Parameters:
  • protocol – Connection protocol (HTTP or HTTPS) for the power switch

  • ip – IP address of the power switch

  • login – Login username of the power switch

  • password – Login password for the power switch

  • content_type – The content type in the request header

  • outlet_list_url – A portion of the URL to get the list of outlets

  • outlet_state_url – A portion of the URL to get the outlet state

  • outlet_control_url – A portion of the URL to turn on/off outlet

  • turn_on_action – value to pass to request to turn on an outlet

  • turn_off_action – value to pass to request to turn on an outlet

  • state_on – value of the outlet’s state when on

  • state_off – value of the outlet’s state when off

  • outlet_schema_file – File name for the schema for a list of outlets

  • outlet_id_list – List of Outlet IDs

  • logger – a logger for this object to use

query_timeout_s = 6

Timeout in seconds used when waiting for a reply from the power switch

initialize() None[source]

Initializes any variables needed for further communication with the power switch. Should be called once before any of the other methods.

property num_outlets: int

Get number of outlets present in this power switch.

Returns:

number of outlets

property is_communicating: bool

Returns whether or not the power switch can be communicated with.

Returns:

whether the power switch is communicating

get_outlet_power_mode(outlet: str) PowerMode[source]

Get the power mode of a specific outlet.

Parameters:

outlet – outlet ID

Returns:

power mode of the outlet

Raises:
turn_on_outlet(outlet: str) tuple[ska_tango_base.commands.ResultCode, str][source]

Tell the DLI power switch to turn on a specific outlet.

Parameters:

outlet – outlet ID to turn on

Returns:

a tuple containing a return code and a string message indicating status

Raises:

AssertionError – if outlet ID is out of bounds

turn_off_outlet(outlet: str) tuple[ska_tango_base.commands.ResultCode, str][source]

Tell the DLI power switch to turn off a specific outlet.

Parameters:

outlet – outlet ID to turn off

Returns:

a tuple containing a return code and a string message indicating status

Raises:

AssertionError – if outlet ID is out of bounds

get_outlet_list()[source]

Query the power switch for a list of outlets and get their name and current state.

Returns:

list of all the outlets available in this power switch, or an empty list if there was an error