create separate subscription for bookmarks

This commit is contained in:
Jakob Ketterl 2020-12-30 18:45:13 +01:00
parent 68fcb8522e
commit b85d801121

View File

@ -132,7 +132,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
self.dsp = None self.dsp = None
self.sdr = None self.sdr = None
self.configSub = None self.configSubs = []
self.connectionProperties = {} self.connectionProperties = {}
try: try:
@ -231,9 +231,8 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
self.stopDsp() self.stopDsp()
if self.configSub is not None: while self.configSubs:
self.configSub.cancel() self.configSubs.pop().cancel()
self.configSub = None
if self.sdr is not None: if self.sdr is not None:
self.sdr.removeClient(self) self.sdr.removeClient(self)
@ -260,25 +259,26 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
config = configProps.__dict__() config = configProps.__dict__()
else: else:
config = changes config = changes
if changes is None or "start_freq" in changes or "center_freq" in changes: if changes is None or "start_freq" in changes or "center_freq" in changes:
config["start_offset_freq"] = configProps["start_freq"] - configProps["center_freq"] config["start_offset_freq"] = configProps["start_freq"] - configProps["center_freq"]
if changes is None or "profile_id" in changes: if changes is None or "profile_id" in changes:
config["sdr_id"] = self.sdr.getId() config["sdr_id"] = self.sdr.getId()
self.write_config(config) self.write_config(config)
# TODO make a separate subscription for this def sendBookmarks(changes=None):
if changes is None or "center_freq" in changes or "samp_rate" in changes: cf = configProps["center_freq"]
cf = configProps["center_freq"] srh = configProps["samp_rate"] / 2
srh = configProps["samp_rate"] / 2 frequencyRange = (cf - srh, cf + srh)
frequencyRange = (cf - srh, cf + srh) self.write_dial_frequencies(Bandplan.getSharedInstance().collectDialFrequencies(frequencyRange))
self.write_dial_frequendies(Bandplan.getSharedInstance().collectDialFrequencies(frequencyRange)) bookmarks = [b.__dict__() for b in Bookmarks.getSharedInstance().getBookmarks(frequencyRange)]
bookmarks = [b.__dict__() for b in Bookmarks.getSharedInstance().getBookmarks(frequencyRange)] self.write_bookmarks(bookmarks)
self.write_bookmarks(bookmarks)
self.configSub = configProps.wire(sendConfig) self.configSubs.append(configProps.wire(sendConfig))
self.configSubs.append(stack.filter("center_freq", "samp_rate").wire(sendBookmarks))
# send initial config # send initial config
sendConfig() sendConfig()
sendBookmarks()
self.__sendProfiles() self.__sendProfiles()
self.sdr.addSpectrumClient(self) self.sdr.addSpectrumClient(self)
@ -374,7 +374,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
def write_wsjt_message(self, message): def write_wsjt_message(self, message):
self.send({"type": "wsjt_message", "value": message}) self.send({"type": "wsjt_message", "value": message})
def write_dial_frequendies(self, frequencies): def write_dial_frequencies(self, frequencies):
self.send({"type": "dial_frequencies", "value": frequencies}) self.send({"type": "dial_frequencies", "value": frequencies})
def write_bookmarks(self, bookmarks): def write_bookmarks(self, bookmarks):