Fixed GUI live print and reports/sec widget.
This commit is contained in:
parent
b594fe2799
commit
4174658f0d
@ -179,7 +179,8 @@ class mainwindow(QtGui.QMainWindow):
|
|||||||
try:
|
try:
|
||||||
from gnuradio import uhd
|
from gnuradio import uhd
|
||||||
self.src = uhd.single_usrp_source("", uhd.io_type_t.COMPLEX_FLOAT32, 1)
|
self.src = uhd.single_usrp_source("", uhd.io_type_t.COMPLEX_FLOAT32, 1)
|
||||||
self.rates = [rate.start() for rate in self.src.get_samp_rates() if (rate.start() % 2.e6) == 0]
|
self.rates = [rate.start() for rate in self.src.get_samp_rates()
|
||||||
|
if (rate.start() % 2.e6) == 0 and rate >= 4e6]
|
||||||
self.antennas = self.src.get_antennas()
|
self.antennas = self.src.get_antennas()
|
||||||
self.src = None #deconstruct UHD source for now
|
self.src = None #deconstruct UHD source for now
|
||||||
self.ui.combo_ant.setEnabled(True)
|
self.ui.combo_ant.setEnabled(True)
|
||||||
@ -224,8 +225,9 @@ class mainwindow(QtGui.QMainWindow):
|
|||||||
self.ui.combo_ant.clear()
|
self.ui.combo_ant.clear()
|
||||||
self.ui.combo_ant.addItems(self.antennas)
|
self.ui.combo_ant.addItems(self.antennas)
|
||||||
|
|
||||||
if 4e6 in self.rates:
|
#set up recommended sample rate
|
||||||
self.ui.combo_rate.setCurrentIndex(self.rates.index(4e6))
|
lowest_rate_valid = min(x for x in self.rates if x >= 4e6)
|
||||||
|
self.ui.combo_rate.setCurrentIndex(self.rates.index(lowest_rate_valid))
|
||||||
|
|
||||||
################ action handlers ####################
|
################ action handlers ####################
|
||||||
def on_combo_source_currentIndexChanged(self, index):
|
def on_combo_source_currentIndexChanged(self, index):
|
||||||
@ -302,9 +304,9 @@ class mainwindow(QtGui.QMainWindow):
|
|||||||
self._htmlfile = open("/tmp/mode_s.html", 'wb+')#tempfile.NamedTemporaryFile()
|
self._htmlfile = open("/tmp/mode_s.html", 'wb+')#tempfile.NamedTemporaryFile()
|
||||||
self._jsonfile = tempfile.NamedTemporaryFile()
|
self._jsonfile = tempfile.NamedTemporaryFile()
|
||||||
|
|
||||||
self.livedata = air_modes.output_print(self._cpr_dec, self._publisher)
|
self.livedata = air_modes.output_print(self._cpr_dec,
|
||||||
#add output for live data box
|
self._publisher,
|
||||||
#self._relay.subscribe("dl_data", self.output_live_data)
|
self.live_data_changed_signal.emit)
|
||||||
|
|
||||||
#create SQL database for KML and dashboard displays
|
#create SQL database for KML and dashboard displays
|
||||||
self.dbwriter = air_modes.output_sql(self._cpr_dec, self.dbname, self.lock, self._publisher)
|
self.dbwriter = air_modes.output_sql(self._cpr_dec, self.dbname, self.lock, self._publisher)
|
||||||
@ -322,7 +324,9 @@ class mainwindow(QtGui.QMainWindow):
|
|||||||
|
|
||||||
#output to update reports/sec widget
|
#output to update reports/sec widget
|
||||||
self._relay.subscribe("dl_data", self.increment_reportspersec)
|
self._relay.subscribe("dl_data", self.increment_reportspersec)
|
||||||
#self.updates.append(self.update_reportspersec) #TODO FIXME
|
self._rps_timer = QtCore.QTimer()
|
||||||
|
self._rps_timer.timeout.connect(self.update_reportspersec)
|
||||||
|
self._rps_timer.start(1000)
|
||||||
|
|
||||||
#start the flowgraph
|
#start the flowgraph
|
||||||
self._radio.start()
|
self._radio.start()
|
||||||
@ -336,6 +340,7 @@ class mainwindow(QtGui.QMainWindow):
|
|||||||
self._radio.close()
|
self._radio.close()
|
||||||
self._relay = None
|
self._relay = None
|
||||||
self._radio = None
|
self._radio = None
|
||||||
|
self._rps_timer = None
|
||||||
try:
|
try:
|
||||||
self.kmlgen.done = True
|
self.kmlgen.done = True
|
||||||
#TODO FIXME need a way to kill kmlgen safely without delay
|
#TODO FIXME need a way to kill kmlgen safely without delay
|
||||||
@ -357,14 +362,6 @@ class mainwindow(QtGui.QMainWindow):
|
|||||||
self.ui.text_livedata.append(msgstr)
|
self.ui.text_livedata.append(msgstr)
|
||||||
self.ui.text_livedata.verticalScrollBar().setSliderPosition(self.ui.text_livedata.verticalScrollBar().maximum())
|
self.ui.text_livedata.verticalScrollBar().setSliderPosition(self.ui.text_livedata.verticalScrollBar().maximum())
|
||||||
|
|
||||||
def output_live_data(self, msg):
|
|
||||||
try:
|
|
||||||
msgstr = self.livedata.parse(msg)
|
|
||||||
if msgstr is not None:
|
|
||||||
self.live_data_changed_signal.emit(msgstr)
|
|
||||||
except ADSBError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app = QtGui.QApplication(sys.argv)
|
app = QtGui.QApplication(sys.argv)
|
||||||
window = mainwindow()
|
window = mainwindow()
|
||||||
|
@ -28,9 +28,10 @@ import math
|
|||||||
#TODO get rid of class and convert to functions
|
#TODO get rid of class and convert to functions
|
||||||
#no need for class here
|
#no need for class here
|
||||||
class output_print:
|
class output_print:
|
||||||
def __init__(self, cpr, publisher):
|
def __init__(self, cpr, publisher, callback=None):
|
||||||
self._cpr = cpr
|
self._cpr = cpr
|
||||||
#sub to every function that starts with "print"
|
self._callback = callback
|
||||||
|
#sub to every function that starts with "handle"
|
||||||
self._fns = [int(l[6:]) for l in dir(self) if l.startswith("handle")]
|
self._fns = [int(l[6:]) for l in dir(self) if l.startswith("handle")]
|
||||||
for i in self._fns:
|
for i in self._fns:
|
||||||
publisher.subscribe("type%i_dl" % i, getattr(self, "handle%i" % i))
|
publisher.subscribe("type%i_dl" % i, getattr(self, "handle%i" % i))
|
||||||
@ -41,6 +42,12 @@ class output_print:
|
|||||||
def prefix(msg):
|
def prefix(msg):
|
||||||
return "(%i %.8f) " % (msg.rssi, msg.timestamp)
|
return "(%i %.8f) " % (msg.rssi, msg.timestamp)
|
||||||
|
|
||||||
|
def _print(self, msg):
|
||||||
|
if self._callback is None:
|
||||||
|
print msg
|
||||||
|
else:
|
||||||
|
self._callback(msg)
|
||||||
|
|
||||||
def catch_nohandler(self, msg):
|
def catch_nohandler(self, msg):
|
||||||
if msg.data.get_type() not in self._fns:
|
if msg.data.get_type() not in self._fns:
|
||||||
retstr = output_print.prefix(msg)
|
retstr = output_print.prefix(msg)
|
||||||
@ -49,7 +56,7 @@ class output_print:
|
|||||||
retstr += " from %.6x" % msg.ecc
|
retstr += " from %.6x" % msg.ecc
|
||||||
else:
|
else:
|
||||||
retstr += " from %.6x" % msg.data["aa"]
|
retstr += " from %.6x" % msg.data["aa"]
|
||||||
print retstr
|
self._print(retstr)
|
||||||
|
|
||||||
def handle0(self, msg):
|
def handle0(self, msg):
|
||||||
try:
|
try:
|
||||||
@ -77,7 +84,7 @@ class output_print:
|
|||||||
if msg.data["vs"] is 1:
|
if msg.data["vs"] is 1:
|
||||||
retstr += " (aircraft is on the ground)"
|
retstr += " (aircraft is on the ground)"
|
||||||
|
|
||||||
print retstr
|
self._print(retstr)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fs_text(fs):
|
def fs_text(fs):
|
||||||
@ -101,7 +108,7 @@ class output_print:
|
|||||||
retstr += output_print.fs_text(msg.data["fs"])
|
retstr += output_print.fs_text(msg.data["fs"])
|
||||||
except ADSBError:
|
except ADSBError:
|
||||||
return
|
return
|
||||||
print retstr
|
self._print(retstr)
|
||||||
|
|
||||||
def handle5(self, msg):
|
def handle5(self, msg):
|
||||||
try:
|
try:
|
||||||
@ -110,7 +117,7 @@ class output_print:
|
|||||||
retstr += output_print.fs_text(msg.data["fs"])
|
retstr += output_print.fs_text(msg.data["fs"])
|
||||||
except ADSBError:
|
except ADSBError:
|
||||||
return
|
return
|
||||||
print retstr
|
self._print(retstr)
|
||||||
|
|
||||||
def handle11(self, msg):
|
def handle11(self, msg):
|
||||||
try:
|
try:
|
||||||
@ -118,7 +125,7 @@ class output_print:
|
|||||||
retstr += "Type 11 (all call reply) from %x in reply to interrogator %i with capability level %i" % (msg.data["aa"], msg.ecc & 0xF, msg.data["ca"]+1)
|
retstr += "Type 11 (all call reply) from %x in reply to interrogator %i with capability level %i" % (msg.data["aa"], msg.ecc & 0xF, msg.data["ca"]+1)
|
||||||
except ADSBError:
|
except ADSBError:
|
||||||
return
|
return
|
||||||
print retstr
|
self._print(retstr)
|
||||||
|
|
||||||
#the only one which requires state
|
#the only one which requires state
|
||||||
def handle17(self, msg):
|
def handle17(self, msg):
|
||||||
@ -157,20 +164,20 @@ class output_print:
|
|||||||
[mag_hdg, vel_src, vel, vert_spd, geo_diff] = air_modes.parseBDS09_3(msg.data)
|
[mag_hdg, vel_src, vel, vert_spd, geo_diff] = air_modes.parseBDS09_3(msg.data)
|
||||||
retstr += "Type 17 BDS0,9-%i (air course report) from %x with %s %.0fkt magnetic heading %.0f VS %.0f geo. diff. from baro. alt. %.0fft" \
|
retstr += "Type 17 BDS0,9-%i (air course report) from %x with %s %.0fkt magnetic heading %.0f VS %.0f geo. diff. from baro. alt. %.0fft" \
|
||||||
% (subtype, icao24, vel_src, vel, mag_hdg, vert_spd, geo_diff)
|
% (subtype, icao24, vel_src, vel, mag_hdg, vert_spd, geo_diff)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
retstr += "Type 17 BDS0,9-%i from %x not implemented" % (subtype, icao24)
|
retstr += "Type 17 BDS0,9-%i from %x not implemented" % (subtype, icao24)
|
||||||
|
|
||||||
elif bdsreg == 0x62:
|
elif bdsreg == 0x62:
|
||||||
emerg_str = air_modes.parseBDS62(data)
|
emerg_str = air_modes.parseBDS62(data)
|
||||||
retstr += "Type 17 BDS6,2 (emergency) from %x type %s" % (icao24, emerg_str)
|
retstr += "Type 17 BDS6,2 (emergency) from %x type %s" % (icao24, emerg_str)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
retstr += "Type 17 with FTC=%i from %x not implemented" % (msg.data["ftc"], icao24)
|
retstr += "Type 17 with FTC=%i from %x not implemented" % (msg.data["ftc"], icao24)
|
||||||
except ADSBError:
|
except ADSBError:
|
||||||
return
|
return
|
||||||
|
|
||||||
print retstr
|
self._print(retstr)
|
||||||
|
|
||||||
def printTCAS(self, msg):
|
def printTCAS(self, msg):
|
||||||
msgtype = msg.data["df"]
|
msgtype = msg.data["df"]
|
||||||
@ -222,8 +229,8 @@ class output_print:
|
|||||||
retstr += " at %ift" % air_modes.decode_alt(msg.data["ac"], True)
|
retstr += " at %ift" % air_modes.decode_alt(msg.data["ac"], True)
|
||||||
else:
|
else:
|
||||||
retstr += " ident %x" % air_modes.decode_id(msg.data["id"])
|
retstr += " ident %x" % air_modes.decode_id(msg.data["id"])
|
||||||
|
|
||||||
print retstr
|
self._print(retstr)
|
||||||
|
|
||||||
handle16 = printTCAS
|
handle16 = printTCAS
|
||||||
handle20 = printTCAS
|
handle20 = printTCAS
|
||||||
|
Loading…
Reference in New Issue
Block a user