Change in DaqConfigurations API for consistency

This commit is contained in:
Anne de Jong 2021-05-14 11:24:07 +02:00
parent 28e935e93b
commit ee58f19251
4 changed files with 18 additions and 8 deletions

View File

@ -173,9 +173,9 @@ class DeviceInfo {
str << prefFramesPerBlockIndex << "\t";
str << availableInputRanges.size() << "\t";
for(const double& fs: availableInputRanges) {
for(const double& ir: availableInputRanges) {
// WARNING: THIS GOES COMPLETELY WRONG WHEN NAMES contain A TAB!!!
str << fs << "\t";
str << ir << "\t";
}
str << prefInputRangeIndex << "\t";

View File

@ -42,11 +42,11 @@ cdef class DaqConfigurations:
output_config)
@staticmethod
def loadConfigs():
def loadAllConfigs():
"""
Returns a list of currently available configurations
Returns a dictionary of all configurations presets. The dictionary keys
are the names of the configurations
The first configuration is for input, the second for output
"""
with lasp_shelve() as sh:
configs_json = sh.load('daqconfigs', {})
@ -55,6 +55,16 @@ cdef class DaqConfigurations:
configs[name] = DaqConfigurations.from_json(val)
return configs
@staticmethod
def loadConfigs(name: str):
"""
Load a configuration preset, containing input config and output config
"""
with lasp_shelve() as sh:
configs_json = sh.load('daqconfigs', {})
return DaqConfigurations.from_json(configs_json[name])
def saveConfigs(self, name):
with lasp_shelve() as sh:
configs_json = sh.load('daqconfigs', {})
@ -62,7 +72,7 @@ cdef class DaqConfigurations:
sh.store('daqconfigs', configs_json)
@staticmethod
def deleteConfig(name):
def deleteConfigs(name):
with lasp_shelve() as sh:
configs_json = sh.load('daqconfigs', {})
del configs_json[name]

View File

@ -32,7 +32,7 @@ from lasp import AvType, StreamManager, Recording# configureLogging
def main(args):
try:
streammgr = StreamManager()
configs = DaqConfigurations.loadConfigs()
configs = DaqConfigurations.loadAllConfigs()
config_keys = [key for key in configs.keys()]
for i, key in enumerate(config_keys):

View File

@ -31,7 +31,7 @@ if __name__ == '__main__':
multiprocessing.set_start_method('forkserver', force=True)
logging.info(f'Playing frequency {args.freq} [Hz]')
configs = DaqConfigurations.loadConfigs()
configs = DaqConfigurations.loadAllConfigs()
config_keys = [key for key in configs.keys()]
for i, key in enumerate(config_keys):