use information from the mode registry to set up services
This commit is contained in:
parent
a3fd931931
commit
bee6ddc843
@ -656,6 +656,9 @@ class dsp(object):
|
|||||||
def get_operating_freq(self):
|
def get_operating_freq(self):
|
||||||
return self.center_freq + self.offset_freq
|
return self.center_freq + self.offset_freq
|
||||||
|
|
||||||
|
def set_bandpass(self, bandpass):
|
||||||
|
self.set_bpf(bandpass.low_cut, bandpass.high_cut)
|
||||||
|
|
||||||
def set_bpf(self, low_cut, high_cut):
|
def set_bpf(self, low_cut, high_cut):
|
||||||
self.low_cut = low_cut
|
self.low_cut = low_cut
|
||||||
self.high_cut = high_cut
|
self.high_cut = high_cut
|
||||||
|
@ -24,6 +24,12 @@ class Mode(object):
|
|||||||
def is_service(self):
|
def is_service(self):
|
||||||
return self.service
|
return self.service
|
||||||
|
|
||||||
|
def get_bandpass(self):
|
||||||
|
return self.bandpass
|
||||||
|
|
||||||
|
def get_modulation(self):
|
||||||
|
return self.modulation
|
||||||
|
|
||||||
|
|
||||||
class AnalogMode(Mode):
|
class AnalogMode(Mode):
|
||||||
pass
|
pass
|
||||||
@ -36,6 +42,14 @@ class DigitalMode(Mode):
|
|||||||
super().__init__(modulation, name, bandpass, requirements, service, squelch)
|
super().__init__(modulation, name, bandpass, requirements, service, squelch)
|
||||||
self.underlying = underlying
|
self.underlying = underlying
|
||||||
|
|
||||||
|
def get_bandpass(self):
|
||||||
|
if self.bandpass is not None:
|
||||||
|
return self.bandpass
|
||||||
|
return Modes.findByModulation(self.underlying[0]).get_bandpass()
|
||||||
|
|
||||||
|
def get_modulation(self):
|
||||||
|
return Modes.findByModulation(self.underlying[0]).get_modulation()
|
||||||
|
|
||||||
|
|
||||||
class Modes(object):
|
class Modes(object):
|
||||||
mappings = [
|
mappings = [
|
||||||
|
@ -155,18 +155,15 @@ class ServiceHandler(SdrSourceEventClient):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
for group in groups:
|
for group in groups:
|
||||||
frequencies = sorted([f["frequency"] for f in group])
|
cf = self.get_center_frequency(group)
|
||||||
min = frequencies[0]
|
bw = self.get_bandwidth(group)
|
||||||
max = frequencies[-1]
|
logger.debug(bw)
|
||||||
cf = (min + max) / 2
|
|
||||||
bw = max - min
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"group center frequency: {0}, bandwidth: {1}".format(cf, bw)
|
"group center frequency: {0}, bandwidth: {1}".format(cf, bw)
|
||||||
)
|
)
|
||||||
resampler_props = PropertyLayer()
|
resampler_props = PropertyLayer()
|
||||||
resampler_props["center_freq"] = cf
|
resampler_props["center_freq"] = cf
|
||||||
# TODO the + 24000 is a temporary fix since the resampling optimizer does not account for required bandwidths
|
resampler_props["samp_rate"] = bw
|
||||||
resampler_props["samp_rate"] = bw + 24000
|
|
||||||
resampler = Resampler(resampler_props, self.source)
|
resampler = Resampler(resampler_props, self.source)
|
||||||
resampler.start()
|
resampler.start()
|
||||||
|
|
||||||
@ -180,6 +177,23 @@ class ServiceHandler(SdrSourceEventClient):
|
|||||||
# resampler goes in after the services since it must not be shutdown as long as the services are still running
|
# resampler goes in after the services since it must not be shutdown as long as the services are still running
|
||||||
self.services.append(resampler)
|
self.services.append(resampler)
|
||||||
|
|
||||||
|
def get_min_max(self, group):
|
||||||
|
frequencies = sorted(group, key=lambda f: f["frequency"])
|
||||||
|
lowest = frequencies[0]
|
||||||
|
min = lowest["frequency"] + Modes.findByModulation(lowest["mode"]).get_bandpass().low_cut
|
||||||
|
highest = frequencies[-1]
|
||||||
|
max = highest["frequency"] + Modes.findByModulation(highest["mode"]).get_bandpass().high_cut
|
||||||
|
return min, max
|
||||||
|
|
||||||
|
def get_center_frequency(self, group):
|
||||||
|
min, max = self.get_min_max(group)
|
||||||
|
return (min + max) / 2
|
||||||
|
|
||||||
|
def get_bandwidth(self, group):
|
||||||
|
minFreq, maxFreq = self.get_min_max(group)
|
||||||
|
# minimum bandwidth for a resampler: 25kHz
|
||||||
|
return max(maxFreq - minFreq, 25000)
|
||||||
|
|
||||||
def optimizeResampling(self, freqs, bandwidth):
|
def optimizeResampling(self, freqs, bandwidth):
|
||||||
freqs = sorted(freqs, key=lambda f: f["frequency"])
|
freqs = sorted(freqs, key=lambda f: f["frequency"])
|
||||||
distances = [
|
distances = [
|
||||||
@ -203,12 +217,10 @@ class ServiceHandler(SdrSourceEventClient):
|
|||||||
previous = split
|
previous = split
|
||||||
groups.append([f for f in freqs if previous < f["frequency"]])
|
groups.append([f for f in freqs if previous < f["frequency"]])
|
||||||
|
|
||||||
def get_bandwitdh(group):
|
def get_total_bandwidth(group):
|
||||||
freqs = sorted([f["frequency"] for f in group])
|
return bandwidth + len(group) * self.get_bandwidth(group)
|
||||||
# the group will process the full BW once, plus the reduced BW once for each group member
|
|
||||||
return bandwidth + len(group) * (freqs[-1] - freqs[0] + 24000)
|
|
||||||
|
|
||||||
total_bandwidth = sum([get_bandwitdh(group) for group in groups])
|
total_bandwidth = sum([get_total_bandwidth(group) for group in groups])
|
||||||
return {
|
return {
|
||||||
"num_splits": num_splits,
|
"num_splits": num_splits,
|
||||||
"total_bandwidth": total_bandwidth,
|
"total_bandwidth": total_bandwidth,
|
||||||
@ -250,16 +262,9 @@ class ServiceHandler(SdrSourceEventClient):
|
|||||||
center_freq = source.getProps()["center_freq"]
|
center_freq = source.getProps()["center_freq"]
|
||||||
d.set_offset_freq(frequency - center_freq)
|
d.set_offset_freq(frequency - center_freq)
|
||||||
d.set_center_freq(center_freq)
|
d.set_center_freq(center_freq)
|
||||||
if mode == "packet":
|
modeObject = Modes.findByModulation(mode)
|
||||||
d.set_demodulator("nfm")
|
d.set_demodulator(modeObject.get_modulation())
|
||||||
d.set_bpf(-6250, 6250)
|
d.set_bandpass(modeObject.get_bandpass())
|
||||||
elif mode == "wspr":
|
|
||||||
d.set_demodulator("usb")
|
|
||||||
# WSPR only samples between 1400 and 1600 Hz
|
|
||||||
d.set_bpf(1350, 1650)
|
|
||||||
else:
|
|
||||||
d.set_demodulator("usb")
|
|
||||||
d.set_bpf(0, 3000)
|
|
||||||
d.set_secondary_demodulator(mode)
|
d.set_secondary_demodulator(mode)
|
||||||
d.set_audio_compression("none")
|
d.set_audio_compression("none")
|
||||||
d.set_samp_rate(source.getProps()["samp_rate"])
|
d.set_samp_rate(source.getProps()["samp_rate"])
|
||||||
|
Loading…
Reference in New Issue
Block a user