combine waterfall_[min|max]_level into a single config
This commit is contained in:
@ -2,7 +2,7 @@ from owrx.property import PropertyLayer
|
||||
|
||||
|
||||
defaultConfig = PropertyLayer(
|
||||
version=4,
|
||||
version=5,
|
||||
max_clients=20,
|
||||
receiver_name="[Callsign]",
|
||||
receiver_location="Budapest, Hungary",
|
||||
@ -23,8 +23,7 @@ defaultConfig = PropertyLayer(
|
||||
digital_voice_dmr_id_lookup=True,
|
||||
# sdrs=...
|
||||
waterfall_scheme="GoogleTurboWaterfall",
|
||||
waterfall_min_level=-88,
|
||||
waterfall_max_level=-20,
|
||||
waterfall_levels=PropertyLayer(min=-88, max=-20),
|
||||
waterfall_auto_level_margin=PropertyLayer(min=3, max=10, min_range=50),
|
||||
frequency_display_precision=4,
|
||||
squelch_auto_margin=10,
|
||||
|
@ -59,3 +59,6 @@ class DynamicConfig(PropertyLayer):
|
||||
|
||||
def __dict__(self):
|
||||
return {k: v for k, v in super().__dict__().items() if v is not DynamicConfig._deleted}
|
||||
|
||||
def keys(self):
|
||||
return [k for k in super().keys() if self.__contains__(k)]
|
||||
|
@ -41,7 +41,6 @@ class ConfigMigratorVersion2(ConfigMigrator):
|
||||
|
||||
|
||||
class ConfigMigratorVersion3(ConfigMigrator):
|
||||
|
||||
def migrate(self, config):
|
||||
# inline import due to circular dependencies
|
||||
from owrx.waterfall import WaterfallOptions
|
||||
@ -61,12 +60,42 @@ class ConfigMigratorVersion3(ConfigMigrator):
|
||||
config["version"] = 4
|
||||
|
||||
|
||||
class ConfigMigratorVersion4(ConfigMigrator):
|
||||
def _replaceWaterfallLevels(self, instance):
|
||||
if (
|
||||
"waterfall_min_level" in instance
|
||||
and "waterfall_max_level" in instance
|
||||
and not "waterfall_levels" in instance
|
||||
):
|
||||
instance["waterfall_levels"] = {
|
||||
"min": instance["waterfall_min_level"],
|
||||
"max": instance["waterfall_max_level"],
|
||||
}
|
||||
del instance["waterfall_min_level"]
|
||||
del instance["waterfall_max_level"]
|
||||
|
||||
def migrate(self, config):
|
||||
# migrate root level
|
||||
self._replaceWaterfallLevels(config)
|
||||
if "sdrs" in config:
|
||||
for device in config["sdrs"].__dict__().values():
|
||||
# migrate device level
|
||||
self._replaceWaterfallLevels(device)
|
||||
if "profiles" in device:
|
||||
for profile in device["profiles"].__dict__().values():
|
||||
# migrate profile level
|
||||
self._replaceWaterfallLevels(profile)
|
||||
|
||||
config["version"] = 5
|
||||
|
||||
|
||||
class Migrator(object):
|
||||
currentVersion = 4
|
||||
currentVersion = 5
|
||||
migrators = {
|
||||
1: ConfigMigratorVersion1(),
|
||||
2: ConfigMigratorVersion2(),
|
||||
3: ConfigMigratorVersion3(),
|
||||
4: ConfigMigratorVersion4(),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
Reference in New Issue
Block a user