GUI working again w/new parser setup. Live print isn't working due to use of print instead of return.
This commit is contained in:
parent
12c09ba1df
commit
fbe3c464fb
@ -25,6 +25,7 @@ from PyQt4 import QtCore,QtGui
|
||||
from PyQt4.Qwt5 import Qwt
|
||||
from gnuradio import gr, gru, optfir, eng_notation, blks2
|
||||
from gnuradio.eng_option import eng_option
|
||||
from gnuradio.gr.pubsub import pubsub
|
||||
import air_modes
|
||||
from air_modes.exceptions import *
|
||||
from air_modes.modes_rx_ui import Ui_MainWindow
|
||||
@ -254,14 +255,17 @@ class mainwindow(QtGui.QMainWindow):
|
||||
options.tcp = int(self.ui.line_rawport.text())
|
||||
|
||||
self._radio = air_modes.modes_radio(options, self.context)
|
||||
self._publisher = pubsub()
|
||||
self._relay.subscribe("dl_data", air_modes.make_parser(self._publisher))
|
||||
|
||||
try:
|
||||
my_position = [float(self.ui.line_my_lat.text()), float(self.ui.line_my_lon.text())]
|
||||
except:
|
||||
my_position = None
|
||||
|
||||
self.datamodelout = dashboard_output(my_position, self.datamodel)
|
||||
self._relay.subscribe("dl_data", self.datamodelout.output)
|
||||
self._cpr_dec = air_modes.cpr_decoder(my_position)
|
||||
|
||||
self.datamodelout = dashboard_output(self._cpr_dec, self.datamodel, self._publisher)
|
||||
|
||||
self.lock = threading.Lock() #grab a lock to ensure sql and kml don't step on each other
|
||||
|
||||
@ -272,27 +276,24 @@ class mainwindow(QtGui.QMainWindow):
|
||||
|
||||
if self.ui.check_sbs1.checkState():
|
||||
sbs1port = int(self.ui.line_sbs1port.text())
|
||||
sbs1out = air_modes.output_sbs1(my_position, sbs1port)
|
||||
self._relay.subscribe("dl_data", sbs1.output)
|
||||
sbs1out = air_modes.output_sbs1(self._cpr_dec, sbs1port, self._publisher)
|
||||
|
||||
if self.ui.check_fgfs.checkState():
|
||||
fghost = "127.0.0.1" #TODO FIXME
|
||||
fgport = self.ui.line_fgfsport.text()
|
||||
fgout = air_modes.output_flightgear(my_position, fghost, int(fgport))
|
||||
self._relay.subscribe("dl_data", fgout.output)
|
||||
fgout = air_modes.output_flightgear(self._cpr_dec, fghost, int(fgport), self._publisher)
|
||||
|
||||
#add azimuth map output and hook it up
|
||||
if my_position is not None:
|
||||
self.az_map_output = air_modes.az_map_output(my_position, self.az_model)
|
||||
self._relay.subscribe("dl_data", self.az_map_output.output)
|
||||
self.az_map_output = air_modes.az_map_output(self._cpr_dec, self.az_model, self._publisher)
|
||||
#self._relay.subscribe("dl_data", self.az_map_output.output)
|
||||
|
||||
self.livedata = air_modes.output_print(my_position)
|
||||
self.livedata = air_modes.output_print(self._cpr_dec, self._publisher)
|
||||
#add output for live data box
|
||||
self._relay.subscribe("dl_data", self.output_live_data)
|
||||
#self._relay.subscribe("dl_data", self.output_live_data)
|
||||
|
||||
#create SQL database for KML and dashboard displays
|
||||
self.dbwriter = air_modes.output_sql(my_position, self.dbname, self.lock)
|
||||
self._relay.subscribe("dl_data", self.dbwriter.insert) #now the db will update itself
|
||||
self.dbwriter = air_modes.output_sql(self._cpr_dec, self.dbname, self.lock, self._publisher)
|
||||
|
||||
#output to update reports/sec widget
|
||||
self._relay.subscribe("dl_data", self.increment_reportspersec)
|
||||
|
@ -173,7 +173,7 @@ class az_map_output:
|
||||
def __init__(self, cprdec, model, pub):
|
||||
self._cpr = cprdec
|
||||
self.model = model
|
||||
pub.subscribe("type17_dl", output)
|
||||
pub.subscribe("type17_dl", self.output)
|
||||
|
||||
def output(self, msg):
|
||||
try:
|
||||
|
@ -29,7 +29,7 @@ class ParserError(ADSBError):
|
||||
pass
|
||||
|
||||
class NoHandlerError(ADSBError):
|
||||
def __init__(self, msgtype):
|
||||
def __init__(self, msgtype=None):
|
||||
self.msgtype = msgtype
|
||||
|
||||
class MlatNonConvergeError(ADSBError):
|
||||
|
@ -141,34 +141,31 @@ class dashboard_data_model(QtCore.QAbstractTableModel):
|
||||
self.endRemoveRows()
|
||||
self.lock.release()
|
||||
|
||||
class dashboard_output(air_modes.parse):
|
||||
def __init__(self, mypos, model):
|
||||
air_modes.parse.__init__(self, mypos)
|
||||
class dashboard_output:
|
||||
def __init__(self, cprdec, model, pub):
|
||||
self.model = model
|
||||
self._cpr = cprdec
|
||||
pub.subscribe("modes_dl", self.output)
|
||||
def output(self, msg):
|
||||
[data, ecc, reference, timestamp] = msg.split()
|
||||
try:
|
||||
data = air_modes.modes_reply(long(data, 16))
|
||||
ecc = long(ecc, 16)
|
||||
rssi = 10.*math.log10(float(reference))
|
||||
msgtype = data["df"]
|
||||
msgtype = msg.data["df"]
|
||||
now = time.time()
|
||||
newrow = {"rssi": rssi, "seen": now}
|
||||
newrow = {"rssi": msg.rssi, "seen": now}
|
||||
if msgtype in [0, 4, 20]:
|
||||
newrow["altitude"] = air_modes.altitude.decode_alt(data["ac"], True)
|
||||
newrow["icao"] = ecc
|
||||
newrow["altitude"] = air_modes.altitude.decode_alt(msg.data["ac"], True)
|
||||
newrow["icao"] = msg.ecc
|
||||
self.model.addRecord(newrow)
|
||||
|
||||
elif msgtype == 17:
|
||||
icao = data["aa"]
|
||||
icao = msg.data["aa"]
|
||||
newrow["icao"] = icao
|
||||
subtype = data["ftc"]
|
||||
subtype = msg.data["ftc"]
|
||||
if subtype == 4:
|
||||
(ident, actype) = self.parseBDS08(data)
|
||||
(ident, actype) = air_modes.parseBDS08(msg.data)
|
||||
newrow["ident"] = ident
|
||||
newrow["type"] = actype
|
||||
elif 5 <= subtype <= 8:
|
||||
(ground_track, decoded_lat, decoded_lon, rnge, bearing) = self.parseBDS06(data)
|
||||
(ground_track, decoded_lat, decoded_lon, rnge, bearing) = air_modes.parseBDS06(msg.data, self._cpr)
|
||||
newrow["heading"] = ground_track
|
||||
newrow["latitude"] = decoded_lat
|
||||
newrow["longitude"] = decoded_lon
|
||||
@ -177,7 +174,7 @@ class dashboard_output(air_modes.parse):
|
||||
newrow["range"] = rnge
|
||||
newrow["bearing"] = bearing
|
||||
elif 9 <= subtype <= 18:
|
||||
(altitude, decoded_lat, decoded_lon, rnge, bearing) = self.parseBDS05(data)
|
||||
(altitude, decoded_lat, decoded_lon, rnge, bearing) = air_modes.parseBDS05(msg.data, self._cpr)
|
||||
newrow["altitude"] = altitude
|
||||
newrow["latitude"] = decoded_lat
|
||||
newrow["longitude"] = decoded_lon
|
||||
@ -185,14 +182,14 @@ class dashboard_output(air_modes.parse):
|
||||
newrow["range"] = rnge
|
||||
newrow["bearing"] = bearing
|
||||
elif subtype == 19:
|
||||
subsubtype = data["sub"]
|
||||
subsubtype = msg.data["sub"]
|
||||
velocity = None
|
||||
heading = None
|
||||
vert_spd = None
|
||||
if subsubtype == 0:
|
||||
(velocity, heading, vert_spd) = self.parseBDS09_0(data)
|
||||
(velocity, heading, vert_spd) = air_modes.parseBDS09_0(msg.data)
|
||||
elif 1 <= subsubtype <= 2:
|
||||
(velocity, heading, vert_spd) = self.parseBDS09_1(data)
|
||||
(velocity, heading, vert_spd) = air_modes.parseBDS09_1(msg.data)
|
||||
newrow["speed"] = velocity
|
||||
newrow["heading"] = heading
|
||||
newrow["vertical"] = vert_spd
|
||||
|
@ -54,7 +54,8 @@ class output_sql:
|
||||
c.execute(query)
|
||||
query = """CREATE TABLE IF NOT EXISTS "ident" (
|
||||
"icao" INTEGER PRIMARY KEY NOT NULL,
|
||||
"ident" TEXT NOT NULL
|
||||
"ident" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL
|
||||
);"""
|
||||
c.execute(query)
|
||||
c.close()
|
||||
|
@ -69,8 +69,10 @@ class stamp:
|
||||
ipart = self.secs + other.secs
|
||||
fpart = self.frac_secs + other.frac_secs
|
||||
return stamp(ipart, fpart)
|
||||
elif isinstance(other, float) or isinstance(other, int):
|
||||
return float(self) + other
|
||||
elif isinstance(other, float):
|
||||
return self + stamp(0, other)
|
||||
elif isinstance(other, int):
|
||||
return self + stamp(other, 0)
|
||||
else:
|
||||
raise TypeError
|
||||
|
||||
@ -79,8 +81,10 @@ class stamp:
|
||||
ipart = self.secs - other.secs
|
||||
fpart = self.frac_secs - other.frac_secs
|
||||
return stamp(ipart, fpart)
|
||||
elif isinstance(other, float) or isinstance(other, int):
|
||||
return float(self) - other
|
||||
elif isinstance(other, float):
|
||||
return self - stamp(0, other)
|
||||
elif isinstance(other, int):
|
||||
return self - stamp(other, 0)
|
||||
else:
|
||||
raise TypeError
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user