2019-12-27 23:26:45 +00:00
|
|
|
from .direct import DirectSource
|
2019-12-21 19:58:28 +00:00
|
|
|
from . import SdrSource
|
|
|
|
import subprocess
|
|
|
|
import threading
|
|
|
|
import os
|
|
|
|
import socket
|
|
|
|
import time
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2019-12-27 23:26:45 +00:00
|
|
|
class Resampler(DirectSource):
|
|
|
|
def onPropertyChange(self, name, value):
|
|
|
|
logger.warning("Resampler is unable to handle property change ({0} changed to {1})".format(name, value))
|
|
|
|
|
2019-12-21 19:58:28 +00:00
|
|
|
def __init__(self, props, port, sdr):
|
|
|
|
sdrProps = sdr.getProps()
|
|
|
|
self.shift = (sdrProps["center_freq"] - props["center_freq"]) / sdrProps["samp_rate"]
|
|
|
|
self.decimation = int(float(sdrProps["samp_rate"]) / props["samp_rate"])
|
|
|
|
if_samp_rate = sdrProps["samp_rate"] / self.decimation
|
|
|
|
self.transition_bw = 0.15 * (if_samp_rate / float(sdrProps["samp_rate"]))
|
|
|
|
props["samp_rate"] = if_samp_rate
|
|
|
|
|
|
|
|
self.sdr = sdr
|
|
|
|
super().__init__(None, props, port)
|
|
|
|
|
2019-12-27 23:26:45 +00:00
|
|
|
def getCommand(self):
|
|
|
|
return [
|
2019-12-21 19:58:28 +00:00
|
|
|
"nc -v 127.0.0.1 {nc_port}".format(nc_port=self.sdr.getPort()),
|
|
|
|
"csdr shift_addition_cc {shift}".format(shift=self.shift),
|
|
|
|
"csdr fir_decimate_cc {decimation} {ddc_transition_bw} HAMMING".format(
|
|
|
|
decimation=self.decimation, ddc_transition_bw=self.transition_bw
|
|
|
|
),
|
2019-12-28 15:44:45 +00:00
|
|
|
] + self.getNmuxCommand()
|
2019-12-21 19:58:28 +00:00
|
|
|
|
|
|
|
def activateProfile(self, profile_id=None):
|
2019-12-27 23:26:45 +00:00
|
|
|
logger.warning("Resampler does not support setting profiles")
|
2019-12-21 19:58:28 +00:00
|
|
|
pass
|