Added debugging code to print chains and their individual objects.

This commit is contained in:
Marat Fayzullin 2024-05-05 12:01:21 -04:00
parent bd4352f6f5
commit fa73cf11e1
3 changed files with 45 additions and 1 deletions

View File

@ -3,6 +3,10 @@ from pycsdr.modules import Buffer
from pycsdr.types import Format
from typing import Union, Callable, Optional
import logging
logger = logging.getLogger(__name__)
class Chain(Module):
def __init__(self, workers):
@ -145,3 +149,14 @@ class Chain(Module):
return self.workers[-1].getOutputFormat()
else:
raise BufferError("getOutputFormat on empty chain")
def printWorkers(self, prefix: str = ""):
logger.debug("{0}{1}".format(prefix, self))
for w in self.workers:
if isinstance(w, Chain):
w.printWorkers(prefix + " ")
else:
logger.debug("{0} {1}".format(prefix, w))
def __str__(self):
return "{0}({1} workers)".format(type(self).__name__, len(self.workers))

View File

@ -77,6 +77,14 @@ class Decimator(Chain):
self.inputRate = inputRate
self._reconfigure()
def __str__(self):
decimation, fraction = self._getDecimation(self.outputRate)
transition = 0.15 * (self.outputRate / float(self.inputRate))
cutoff = 0.5 * decimation / (self.inputRate / self.outputRate)
return "{0}(decimation {1} * {2}, transition {3}, cutoff {4})".format(
type(self).__name__, decimation, fraction, transition, cutoff
)
class Selector(Chain):
def __init__(self, inputRate: int, outputRate: int, withSquelch: bool = True):
@ -177,10 +185,21 @@ class Selector(Chain):
self.decimation.setInputRate(inputRate)
self._updateShift()
def __str__(self):
return "{0}({1} => offset {2} => bandpass {3}..{4} => {5})".format(
type(self).__name__,
self.inputRate,
self.frequencyOffset,
self.bandpassCutoffs[0],
self.bandpassCutoffs[1],
self.outputRate
)
class SecondarySelector(Chain):
def __init__(self, sampleRate: int, bandwidth: float):
self.sampleRate = sampleRate
self.bandwidth = bandwidth
self.frequencyOffset = 0
self.shift = Shift(0.0)
cutoffRate = bandwidth / sampleRate
@ -196,6 +215,16 @@ class SecondarySelector(Chain):
return
self.shift.setRate(-offset / self.sampleRate)
def __str__(self):
return "{0}({1} => offset {2} => bandpass {3}..{4} => {5})".format(
type(self).__name__,
self.sampleRate,
self.frequencyOffset,
-self.bandwidth,
self.bandwidth,
self.sampleRate
)
class SelectorError(Exception):
pass

View File

@ -1,5 +1,5 @@
from distutils.version import LooseVersion
_versionstring = "1.2.57"
_versionstring = "1.2.58"
looseversion = LooseVersion(_versionstring)
openwebrx_version = "v{0}".format(looseversion)