diff --git a/tangostationcontrol/tangostationcontrol/common/configuration.py b/tangostationcontrol/tangostationcontrol/common/configuration.py index 0c9ef868b516d9b233e5e0dac4de6656d5f4c3bf..2458d99e08c405ba7bbe99975da651e1da4446d1 100644 --- a/tangostationcontrol/tangostationcontrol/common/configuration.py +++ b/tangostationcontrol/tangostationcontrol/common/configuration.py @@ -26,26 +26,25 @@ def get_db_data(db, tangodb_timeout:int = 10000): # Create empty dictionaries to be populated devices_dict = {} server_dict = {} - # Query TangoDb with built-in function for devices data - _, raw_result = dbproxy.command_inout("DbMySqlSelect", DEVICE_PROPERTIES_QUERY) - # Remodel the query result - device_property_result = query_to_tuples(raw_result, 3) + # Populate devices dictionary from query data + device_property_result = query_tangodb(dbproxy, DEVICE_PROPERTIES_QUERY, 3) devices_dict = add_to_devices_dict(devices_dict, device_property_result) - # Query TangoDb with built-in function for attributes data - _, raw_result = dbproxy.command_inout("DbMySqlSelect", ATTRS_PROPERTIES_QUERY) - # Remodel the query result - attrs_property_result = query_to_tuples(raw_result, 4) + # Populate devices dictionary from query data + attrs_property_result = query_tangodb(dbproxy, ATTRS_PROPERTIES_QUERY, 4) devices_dict = add_to_attrs_dict(devices_dict, attrs_property_result) - # Query TangoDb with built-in function for server data - _, raw_result = dbproxy.command_inout("DbMySqlSelect", SERVER_QUERY) - # Remodel the query result - server_result = query_to_tuples(raw_result, 3) + # Populate server dictionary from query data and merge it with devices dict + server_result = query_tangodb(dbproxy, SERVER_QUERY, 3) server_dict = add_to_server_dict(server_dict, devices_dict, server_result) return {"servers" : server_dict} +def query_tangodb(dbproxy: DeviceProxy, sql_query: str, num_cols: int): + """ Query TangoDb with a built-in function and return data as tuples """ + _, raw_result = dbproxy.command_inout("DbMySqlSelect", sql_query) + return query_to_tuples(raw_result, num_cols) + def add_to_devices_dict(devices_dict:dict, result:list): """ Populate a devices dictionary with the following structure: 'device_name': { 'properties' : { 'property_name': ['property_value'] } } diff --git a/tangostationcontrol/tangostationcontrol/devices/boot.py b/tangostationcontrol/tangostationcontrol/devices/boot.py index 7c312f8a2f3df247eb6beb36c503396416393e55..7a411e728bac13cbec9adcbb0845b385b6a2520f 100644 --- a/tangostationcontrol/tangostationcontrol/devices/boot.py +++ b/tangostationcontrol/tangostationcontrol/devices/boot.py @@ -240,6 +240,7 @@ class Boot(lofar_device): dtype='DevVarStringArray', mandatory=False, default_value=["STAT/Docker/1", # Docker controls the device containers, so it goes before anything else + "STAT/Configuration/1", # Configuration device loads and update station configuration "STAT/PSOC/1", # PSOC boot early to detect power delivery failure as fast as possible "STAT/PCON/1", # PCON boot early because it is responsible for power delivery. "STAT/APSPU/1", # APS Power Units control other hardware we want to initialise @@ -256,7 +257,6 @@ class Boot(lofar_device): "STAT/TileBeam/1", # Accesses AntennaField "STAT/DigitalBeam/1", # Accessed SDP and Beamlet "STAT/TemperatureManager/1", - "STAT/Configuration/1", ], )