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 usecommunication_state_callback (
Callable
[[CommunicationStatus
],None
]) – callback to be called when the status of the communications channel between the component manager and its component changesdatabase_host (
str
) – the database hostdatabase_port (
int
) – the database portdatabase_name (
str
) – the database namedatabase_admin_user (
str
) – the database admin userdatabase_admin_password (
str
) – the database admin passwordtimeout (
float
) – the timeout for database operationsconnection_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:
- Raises:
RuntimeError – if there are repeated connection issues with the database
- Return type:
- Returns:
a calibration solution from the database.
- store_solution(solution, frequency_channel, outside_temperature)
Store the provided solution in the database.
- Parameters:
- 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.