Remove common.py dependancy
git-svn-id: http://op25.osmocom.org/svn/trunk@209 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
parent
b62611a791
commit
5cefd5466b
|
@ -22,7 +22,7 @@
|
||||||
# 02110-1301, USA.
|
# 02110-1301, USA.
|
||||||
|
|
||||||
import cPickle
|
import cPickle
|
||||||
import common
|
import math
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
@ -545,14 +545,14 @@ class p25_rx_block (stdgui2.std_top_block):
|
||||||
def set_channel_offset(self, offset_hz):
|
def set_channel_offset(self, offset_hz):
|
||||||
self.channel_offset = -offset_hz
|
self.channel_offset = -offset_hz
|
||||||
self.channel_filter.set_center_freq(self.channel_offset)
|
self.channel_filter.set_center_freq(self.channel_offset)
|
||||||
self.frame.SetStatusText("%s: %s"%(self.spectrum_plotter.x_label, common.eng_format(offset_hz, self.spectrum_plotter.x_units)), 1)
|
self.frame.SetStatusText("%s: %s"%(self.spectrum_plotter.x_label, self.eng_format(offset_hz, self.spectrum_plotter.x_units)), 1)
|
||||||
|
|
||||||
|
|
||||||
# Set the RF squelch threshold level
|
# Set the RF squelch threshold level
|
||||||
#
|
#
|
||||||
def set_squelch_threshold(self, squelch_db):
|
def set_squelch_threshold(self, squelch_db):
|
||||||
self.squelch.set_threshold(squelch_db)
|
self.squelch.set_threshold(squelch_db)
|
||||||
self.frame.SetStatusText("%s: %s"%(self.spectrum_plotter.y_label, common.eng_format(squelch_db, self.spectrum_plotter.y_units)), 2)
|
self.frame.SetStatusText("%s: %s"%(self.spectrum_plotter.y_label, self.eng_format(squelch_db, self.spectrum_plotter.y_units)), 2)
|
||||||
|
|
||||||
|
|
||||||
# A snapshot of important fields in current traffic
|
# A snapshot of important fields in current traffic
|
||||||
|
@ -729,6 +729,35 @@ def info(object, spacing=10):
|
||||||
f = (lambda s: " ".join(s.split()))
|
f = (lambda s: " ".join(s.split()))
|
||||||
print "\n".join(["%s %s" % (method.ljust(spacing), f(str(getattr(object, method).__doc__))) for method in methods])
|
print "\n".join(["%s %s" % (method.ljust(spacing), f(str(getattr(object, method).__doc__))) for method in methods])
|
||||||
|
|
||||||
|
# This stuff is from common.py
|
||||||
|
#
|
||||||
|
def eng_format(num, units=''):
|
||||||
|
coeff, exp, prefix = get_si_components(num)
|
||||||
|
if -3 <= exp < 3: return '%g'%num
|
||||||
|
return '%g%s%s%s'%(coeff, units and ' ' or '', prefix, units)
|
||||||
|
|
||||||
|
def get_si_components(num):
|
||||||
|
num = float(num)
|
||||||
|
exp = get_exp(num)
|
||||||
|
exp -= exp%3
|
||||||
|
exp = min(max(exp, -24), 24)
|
||||||
|
prefix = {
|
||||||
|
24: 'Y', 21: 'Z',
|
||||||
|
18: 'E', 15: 'P',
|
||||||
|
12: 'T', 9: 'G',
|
||||||
|
6: 'M', 3: 'k',
|
||||||
|
0: '',
|
||||||
|
-3: 'm', -6: 'u',
|
||||||
|
-9: 'n', -12: 'p',
|
||||||
|
-15: 'f', -18: 'a',
|
||||||
|
-21: 'z', -24: 'y',
|
||||||
|
}[exp]
|
||||||
|
coeff = num/10**exp
|
||||||
|
return coeff, exp, prefix
|
||||||
|
|
||||||
|
def get_exp(num):
|
||||||
|
if num==0: return 0
|
||||||
|
return int(math.floor(math.log10(abs(num))))
|
||||||
|
|
||||||
# Start the receiver
|
# Start the receiver
|
||||||
#
|
#
|
||||||
|
|
Reference in New Issue