Calibration Store Database Connection

This module implements the connection to the calibration database.

class CalibrationStoreDatabaseConnection(logger, communication_state_callback, database_host, database_port, database_name, database_admin_user, database_admin_password, timeout=10, connection_max_tries=5)

A connection to a postgres database for the calibration store.

__init__(logger, communication_state_callback, database_host, database_port, database_name, database_admin_user, database_admin_password, timeout=10, connection_max_tries=5)

Initialise a new instance of a database connection.

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

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

  • database_host (str) – the database host

  • database_port (int) – the database port

  • database_name (str) – the database name

  • database_admin_user (str) – the database admin user

  • database_admin_password (str) – the database admin password

  • timeout (float) – the timeout for database operations

  • connection_max_tries (int) – the maximum number of attempts to connect to the database

get_solution(frequency_channel, outside_temperature)

Get a solution for the provided frequency and outside temperature.

This at present will return the most recently stored solution for the inputs.

Parameters:
  • frequency_channel (int) – the frequency channel of the desired solution.

  • outside_temperature (float) – the outside temperature of the desired solution.

Raises:

RuntimeError – if there are repeated connection issues with the database

Return type:

list[float]

Returns:

a calibration solution from the database.

store_solution(solution, frequency_channel, outside_temperature)

Store the provided solution in the database.

Parameters:
  • solution (list[float]) – the solution to store

  • frequency_channel (int) – the frequency channel that the solution is for

  • outside_temperature (float) – the outside temperature that the solution is for

Raises:

RuntimeError – if there are repeated connection issues witht the database

Return type:

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

Returns:

tuple of result code and message.

verify_database_connection()

Verify that connection to the database can be established.

Return type:

None