send bookmarks to client

This commit is contained in:
Jakob Ketterl 2019-09-28 00:53:58 +02:00
parent 00febdf255
commit cc98c94b2b
3 changed files with 70 additions and 0 deletions

21
bookmarks.json Normal file
View File

@ -0,0 +1,21 @@
[{
"name": "DB0ZU",
"frequency": 145725000,
"modulation": "nfm"
},{
"name": "DB0ZM",
"frequency": 145750000,
"modulation": "nfm"
},{
"name": "DB0EL",
"frequency": 439275000,
"modulation": "nfm"
},{
"name": "DB0NJ",
"frequency": 438775000,
"modulation": "nfm"
},{
"name": "DB0NJ",
"frequency": 439437500,
"modulation": "dmr"
}]

43
owrx/bookmarks.py Normal file
View File

@ -0,0 +1,43 @@
import json
class Bookmark(object):
def __init__(self, j):
self.name = j["name"]
self.frequency = j["frequency"]
self.modulation = j["modulation"]
def getName(self):
return self.name
def getFrequency(self):
return self.frequency
def getModulation(self):
return self.modulation
def __dict__(self):
return {
"name": self.getName(),
"frequency": self.getFrequency(),
"modulation": self.getModulation(),
}
class Bookmarks(object):
sharedInstance = None
@staticmethod
def getSharedInstance():
if Bookmarks.sharedInstance is None:
Bookmarks.sharedInstance = Bookmarks()
return Bookmarks.sharedInstance
def __init__(self):
f = open("bookmarks.json", "r")
bookmarks_json = json.load(f)
f.close()
self.bookmarks = [Bookmark(d) for d in bookmarks_json]
def getBookmarks(self, range):
(lo, hi) = range
return [b for b in self.bookmarks if lo <= b.getFrequency() <= hi]

View File

@ -3,6 +3,7 @@ from owrx.source import DspManager, CpuUsageThread, SdrService, ClientRegistry
from owrx.feature import FeatureDetector from owrx.feature import FeatureDetector
from owrx.version import openwebrx_version from owrx.version import openwebrx_version
from owrx.bands import Bandplan from owrx.bands import Bandplan
from owrx.bookmarks import Bookmarks
from owrx.map import Map from owrx.map import Map
from multiprocessing import Queue from multiprocessing import Queue
import json import json
@ -168,6 +169,8 @@ class OpenWebRxReceiverClient(Client):
srh = configProps["samp_rate"] / 2 srh = configProps["samp_rate"] / 2
frequencyRange = (cf - srh, cf + srh) frequencyRange = (cf - srh, cf + srh)
self.write_dial_frequendies(Bandplan.getSharedInstance().collectDialFrequencies(frequencyRange)) self.write_dial_frequendies(Bandplan.getSharedInstance().collectDialFrequencies(frequencyRange))
bookmarks = [b.__dict__() for b in Bookmarks.getSharedInstance().getBookmarks(frequencyRange)]
self.write_bookmarks(bookmarks)
self.configSub = configProps.wire(sendConfig) self.configSub = configProps.wire(sendConfig)
sendConfig(None, None) sendConfig(None, None)
@ -254,6 +257,9 @@ class OpenWebRxReceiverClient(Client):
def write_dial_frequendies(self, frequencies): def write_dial_frequendies(self, frequencies):
self.send({"type": "dial_frequencies", "value": frequencies}) self.send({"type": "dial_frequencies", "value": frequencies})
def write_bookmarks(self, bookmarks):
self.send({"type": "bookmarks", "value": bookmarks})
def write_aprs_data(self, data): def write_aprs_data(self, data):
self.send({"type": "aprs_data", "value": data}) self.send({"type": "aprs_data", "value": data})