send a new config message when config properties haven been changed

This commit is contained in:
Jakob Ketterl 2019-05-07 18:47:03 +02:00
parent 9fc77c2804
commit 35930f79f1
2 changed files with 20 additions and 7 deletions

View File

@ -9,7 +9,10 @@ class Property(object):
def setValue(self, value):
self.value = value
for c in self.callbacks:
try:
c(self.value)
except Exception as e:
print(e)
return self
def wire(self, callback):
self.callbacks.append(callback)
@ -38,7 +41,10 @@ class PropertyManager(object):
self.properties[name] = prop
def fireCallbacks(value):
for c in self.callbacks:
try:
c(name, value)
except Exception as e:
print(e)
prop.wire(fireCallbacks)
return self

View File

@ -80,17 +80,24 @@ class WebSocketMessageHandler(object):
if (message[:16] == "SERVER DE CLIENT"):
# maybe put some more info in there? nothing to store yet.
self.handshake = "completed"
print("client connection intitialized")
self.client = OpenWebRxClient(conn)
config_keys = ["waterfall_colors", "waterfall_min_level", "waterfall_max_level",
"waterfall_auto_level_margin", "shown_center_freq", "samp_rate", "fft_size", "fft_fps",
"audio_compression", "fft_compression", "max_clients", "start_mod",
"client_audio_buffer_size"]
config = dict((key, pm.getPropertyValue(key)) for key in config_keys)
config["start_offset_freq"] = pm.getPropertyValue("start_freq") - pm.getPropertyValue("center_freq")
"client_audio_buffer_size", "start_freq", "center_freq"]
configProps = pm.collect(*config_keys)
def sendConfig(key, value):
config = dict((key, configProps[key]) for key in config_keys)
config["start_offset_freq"] = configProps["start_freq"] - configProps["center_freq"]
self.client.write_config(config)
print("client connection intitialized")
configProps.wire(sendConfig)
sendConfig(None, None)
receiver_keys = ["receiver_name", "receiver_location", "receiver_qra", "receiver_asl", "receiver_gps",
"photo_title", "photo_desc"]