Add: DaqConfigurations.loadRaw() and saveRaw() for easy accessing of DAQ configuration data

This commit is contained in:
Casper Jansen 2022-10-24 12:05:59 +02:00
parent 6eaf5db691
commit b259580736

View File

@ -29,7 +29,7 @@ class DaqConfigurations:
output_config: DaqConfiguration,
):
"""
Initialize set of DaqConfigurations.
Initialize set of DaqConfigurations.
Args:
duplex_mode: If true, the input configuration is used for output as
@ -92,6 +92,18 @@ class DaqConfigurations:
output_config = DaqConfiguration.fromTOML(config_str[2])
return DaqConfigurations(duplex_mode, input_config, output_config)
@staticmethod
def loadRaw():
"""
Returns configurations presets in the raw form they are stored.
Returns:
all configurations, raw
"""
with lasp_shelve() as sh:
configs_raw = sh.load(f"daqconfigs_v{LASP_VERSION_MAJOR}", {})
return configs_raw
def save(self, name: str):
"""
Save the current set of configurations to the shelve store.
@ -109,6 +121,17 @@ class DaqConfigurations:
configs_str[name] = [self.duplex_mode, input_str, output_str]
sh.store(f"daqconfigs_v{LASP_VERSION_MAJOR}", configs_str)
@staticmethod
def saveRaw(configs_raw):
"""
Save configurations presets, using already formatted data
Arg:
all configurations, raw data format in form they are stored
"""
with lasp_shelve() as sh:
sh.store(f"daqconfigs_v{LASP_VERSION_MAJOR}", configs_raw)
@staticmethod
def delete(name: str):
"""