parse metadata on the server side

This commit is contained in:
Jakob Ketterl 2019-05-30 16:12:13 +02:00
parent 05f6fff8f6
commit 14f932eea8
3 changed files with 11 additions and 8 deletions

View File

@ -1309,13 +1309,7 @@ function on_ws_recv(evt)
} }
} }
function update_metadata(stringData) { function update_metadata(meta) {
var meta = {};
stringData.split(";").forEach(function(s) {
var item = s.split(":");
meta[item[0]] = item[1];
});
var update = function(_, el) { var update = function(_, el) {
el.innerHTML = ""; el.innerHTML = "";
}; };

7
owrx/meta.py Normal file
View File

@ -0,0 +1,7 @@
class MetaParser(object):
def __init__(self, handler):
self.handler = handler
def parse(self, meta):
fields = meta.split(";")
dict = {v[0] : "".join(v[1:]) for v in map(lambda x: x.split(":"), fields)}
self.handler.write_metadata(dict)

View File

@ -1,6 +1,7 @@
import subprocess import subprocess
from owrx.config import PropertyManager from owrx.config import PropertyManager
from owrx.feature import FeatureDetector, UnknownFeatureException from owrx.feature import FeatureDetector, UnknownFeatureException
from owrx.meta import MetaParser
import threading import threading
import csdr import csdr
import time import time
@ -334,6 +335,7 @@ class DspManager(csdr.output):
def __init__(self, handler, sdrSource): def __init__(self, handler, sdrSource):
self.handler = handler self.handler = handler
self.sdrSource = sdrSource self.sdrSource = sdrSource
self.metaParser = MetaParser(self.handler)
self.localProps = self.sdrSource.getProps().collect( self.localProps = self.sdrSource.getProps().collect(
"audio_compression", "fft_compression", "digimodes_fft_size", "csdr_dynamic_bufsize", "audio_compression", "fft_compression", "digimodes_fft_size", "csdr_dynamic_bufsize",
@ -403,7 +405,7 @@ class DspManager(csdr.output):
"smeter": self.handler.write_s_meter_level, "smeter": self.handler.write_s_meter_level,
"secondary_fft": self.handler.write_secondary_fft, "secondary_fft": self.handler.write_secondary_fft,
"secondary_demod": self.handler.write_secondary_demod, "secondary_demod": self.handler.write_secondary_demod,
"meta": self.handler.write_metadata "meta": self.metaParser.parse
} }
write = writers[t] write = writers[t]