Live data display works.

This commit is contained in:
Nick Foster
2012-07-03 19:21:42 -07:00
parent 113c23b634
commit a853077bc2
4 changed files with 43 additions and 23 deletions
+1 -1
View File
@@ -199,7 +199,7 @@ if __name__ == '__main__':
updates.append(sbs1port.add_pending_conns) updates.append(sbs1port.add_pending_conns)
if options.no_print is not True: if options.no_print is not True:
outputs.append(air_modes.modes_output_print(my_position).parse) outputs.append(air_modes.modes_output_print(my_position).output)
if options.multiplayer is not None: if options.multiplayer is not None:
[fghost, fgport] = options.multiplayer.split(':') [fghost, fgport] = options.multiplayer.split(':')
+5 -2
View File
@@ -60,15 +60,18 @@ class modes_output_print(modes_parse.modes_parse):
output += self.print20(data, ecc) output += self.print20(data, ecc)
else: else:
output += "No handler for message type %i from %x (but it's in modes_parse)" % (msgtype, ecc) output += "No handler for message type %i from %x (but it's in modes_parse)" % (msgtype, ecc)
print output return output
except NoHandlerError as e: except NoHandlerError as e:
output += "No handler for message type %s from %x" % (e.msgtype, ecc) output += "No handler for message type %s from %x" % (e.msgtype, ecc)
print output return output
except MetricAltError: except MetricAltError:
pass pass
except CPRNoPositionError: except CPRNoPositionError:
pass pass
def output(self, msg):
print self.parse(msg)
def print0(self, shortdata, ecc): def print0(self, shortdata, ecc):
[vs, cc, sl, ri, altitude] = self.parse0(shortdata) [vs, cc, sl, ri, altitude] = self.parse0(shortdata)
+5 -5
View File
@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>877</width>
<height>618</height> <height>618</height>
</rect> </rect>
</property> </property>
@@ -419,12 +419,12 @@
<rect> <rect>
<x>130</x> <x>130</x>
<y>220</y> <y>220</y>
<width>651</width> <width>741</width>
<height>301</height> <height>301</height>
</rect> </rect>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="dashboard"> <widget class="QWidget" name="dashboard">
<attribute name="title"> <attribute name="title">
@@ -721,7 +721,7 @@
<rect> <rect>
<x>5</x> <x>5</x>
<y>11</y> <y>11</y>
<width>631</width> <width>721</width>
<height>251</height> <height>251</height>
</rect> </rect>
</property> </property>
@@ -835,7 +835,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>877</width>
<height>25</height> <height>25</height>
</rect> </rect>
</property> </property>
+31 -14
View File
@@ -5,6 +5,7 @@ from PyQt4 import QtCore,QtGui
from gnuradio import gr, gru, optfir, eng_notation, blks2 from gnuradio import gr, gru, optfir, eng_notation, blks2
import gnuradio.gr.gr_threading as _threading import gnuradio.gr.gr_threading as _threading
import air_modes import air_modes
from air_modes.modes_exceptions import *
from test import Ui_MainWindow from test import Ui_MainWindow
import csv import csv
@@ -114,16 +115,17 @@ class mainwindow(QtGui.QMainWindow):
self.runner = None self.runner = None
if self.kmlgen is not None: if self.kmlgen is not None:
self.kmlgen.done = True self.kmlgen.done = True
#TODO FIXME KMLGEN NEEDS SELFDESTRUCT #TODO FIXME need a way to kill kmlgen safely without delay
#self.kmlgen.join()
#self.kmlgen = None #self.kmlgen = None
self.ui.button_start.setText("Start") self.ui.button_start.setText("Start")
else: #we aren't already running, let's get this party started else: #we aren't already running, let's get this party started
options = {} options = {}
options["source"] = self.ui.combo_source.currentText() options["source"] = str(self.ui.combo_source.currentText())
options["rate"] = int(self.ui.combo_rate.currentIndex()) options["rate"] = int(self.ui.combo_rate.currentIndex())
options["antenna"] = self.ui.combo_ant.currentText() options["antenna"] = str(self.ui.combo_ant.currentText())
options["gain"] = float(self.ui.line_gain.text()) options["gain"] = float(self.ui.line_gain.text())
options["threshold"] = float(self.ui.line_threshold.text()) options["threshold"] = float(self.ui.line_threshold.text())
options["filename"] = str(self.ui.line_inputfile.text()) options["filename"] = str(self.ui.line_inputfile.text())
@@ -162,6 +164,8 @@ class mainwindow(QtGui.QMainWindow):
self.outputs.append(rawport.output) self.outputs.append(rawport.output)
self.updates.append(rawport.add_pending_conns) self.updates.append(rawport.add_pending_conns)
self.livedata = air_modes.modes_output_print(my_position)
#add output for live data box #add output for live data box
self.outputs.append(self.output_live_data) self.outputs.append(self.output_live_data)
@@ -170,7 +174,9 @@ class mainwindow(QtGui.QMainWindow):
self.ui.button_start.setText("Stop") #modify button text self.ui.button_start.setText("Stop") #modify button text
def output_live_data(self, msg): def output_live_data(self, msg):
self.ui.text_livedata.append(msg) msgstr = self.livedata.parse(msg)
if msgstr is not None:
self.ui.text_livedata.append(msgstr)
class output_handler(threading.Thread): class output_handler(threading.Thread):
@@ -195,7 +201,7 @@ class output_handler(threading.Thread):
except ADSBError: except ADSBError:
pass pass
time.sleep(0.3) time.sleep(0.1)
self.done = True self.done = True
@@ -219,8 +225,9 @@ class adsb_rx_block (gr.top_block):
gr.top_block.__init__(self) gr.top_block.__init__(self)
self.options = options self.options = options
rate = int(options["rate"]) rate = options["rate"]
use_resampler = False use_resampler = False
freq = 1090e6
if options["source"] == "UHD device": if options["source"] == "UHD device":
from gnuradio import uhd from gnuradio import uhd
@@ -229,24 +236,30 @@ class adsb_rx_block (gr.top_block):
self.u.set_time_now(time_spec) self.u.set_time_now(time_spec)
self.u.set_antenna(options["antenna"]) self.u.set_antenna(options["antenna"])
self.u.set_samp_rate(rate) self.u.set_samp_rate(rate)
self.u.set_gain(options["gain"]) rate = self.u.get_samp_rate()
self.u.set_gain(int(options["gain"]))
self.u.set_center_freq(freq, 0)
elif options["source"] == "RTL-SDR": elif options["source"] == "RTL-SDR":
import osmosdr import osmosdr
self.u = osmosdr.source_c() self.u = osmosdr.source_c()
self.u.set_sample_rate(2.4e6) #fixed for RTL dongles self.u.set_sample_rate(2.4e6) #fixed for RTL dongles
rate = int(4e6)
self.u.set_gain_mode(0) #manual gain mode self.u.set_gain_mode(0) #manual gain mode
self.u.set_gain(options["gain"]) self.u.set_gain(int(options["gain"]))
self.u.set_center_freq(freq, 0)
use_resampler = True use_resampler = True
elif options["source"] == "File": elif options["source"] == "File":
self.u = gr.file_source(gr.sizeof_gr_complex, options["filename"]) self.u = gr.file_source(gr.sizeof_gr_complex, options["filename"])
else:
raise NotImplementedError
self.demod = gr.complex_to_mag() self.demod = gr.complex_to_mag()
self.avg = gr.moving_average_ff(100, 1.0/100, 400) self.avg = gr.moving_average_ff(100, 1.0/100, 400)
self.preamble = air_modes.modes_preamble(rate, options["threshold"]) self.preamble = air_modes.modes_preamble(int(rate), float(options["threshold"]))
self.slicer = air_modes.modes_slicer(rate, queue) self.slicer = air_modes.modes_slicer(int(rate), queue)
if use_resampler: if use_resampler:
self.lpfiltcoeffs = gr.firdes.low_pass(1, 5*2.4e6, 1.2e6, 300e3) self.lpfiltcoeffs = gr.firdes.low_pass(1, 5*2.4e6, 1.2e6, 300e3)
@@ -258,11 +271,15 @@ class adsb_rx_block (gr.top_block):
self.connect(self.demod, self.avg) self.connect(self.demod, self.avg)
self.connect(self.demod, (self.preamble, 0)) self.connect(self.demod, (self.preamble, 0))
self.connect(self.avg, (self.preamble, 1)) self.connect(self.avg, (self.preamble, 1))
self.connect((self.preamble, 0), (self.slicer, 0)) self.connect(self.preamble, self.slicer)
def tune(self, freq): class wat_block(gr.top_block):
result = self.u.set_center_freq(freq, 0) def __init__(self, options, queue):
return result gr.top_block.__init__(self)
self.src = gr.file_source(gr.sizeof_gr_complex, options["filename"])
self.sink = gr.null_sink(gr.sizeof_gr_complex)
self.connect(self.src, self.sink)
if __name__ == '__main__': if __name__ == '__main__':
app = QtGui.QApplication(sys.argv) app = QtGui.QApplication(sys.argv)