diff --git a/apps/modes_gui b/apps/modes_gui index 4a75772..4ef1005 100755 --- a/apps/modes_gui +++ b/apps/modes_gui @@ -85,6 +85,9 @@ class mainwindow(QtGui.QMainWindow): self.ui.list_aircraft.setModel(self.datamodel) self.ui.list_aircraft.setModelColumn(0) + self.az_model = air_modes.az_map_model(None) + self.ui.azimuth_map.setModel(self.az_model) + #set up dashboard views self.icaodelegate = ICAOViewDelegate() self.ui.list_aircraft.setItemDelegate(self.icaodelegate) @@ -276,9 +279,13 @@ class mainwindow(QtGui.QMainWindow): self.outputs.append(rawport.output) self.updates.append(rawport.add_pending_conns) + #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.outputs.append(self.az_map_output.output) + self.livedata = air_modes.output_print(my_position) #add output for live data box - #TODO: this doesn't handle large volumes of data well; i get segfaults. self.outputs.append(self.output_live_data) #create SQL database for KML and dashboard displays @@ -291,7 +298,7 @@ class mainwindow(QtGui.QMainWindow): #create output handler thread self.output_handler = output_handler(self.outputs, self.updates, self.queue) - + self.ui.button_start.setText("Stop") def on_quit(self): diff --git a/python/__init__.py b/python/__init__.py index 045e4c7..f678ba1 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -58,6 +58,7 @@ from sbs1 import output_sbs1 from kml import output_kml from raw_server import raw_server from exceptions import * +from az_map import * #this is try/excepted in case the user doesn't have numpy installed try: from flightgear import output_flightgear diff --git a/python/az_map.py b/python/az_map.py index dd2baaf..4f84fd5 100755 --- a/python/az_map.py +++ b/python/az_map.py @@ -25,6 +25,7 @@ from PyQt4 import QtCore, QtGui import threading import math +import air_modes # model has max range vs. azimuth in n-degree increments @@ -76,8 +77,8 @@ class az_map_model(QtCore.QObject): # the azimuth map widget class az_map(QtGui.QWidget): - maxrange = 450 - ringsize = 100 + maxrange = 45 + ringsize = 10 bgcolor = QtCore.Qt.black ringpen = QtGui.QPen(QtGui.QColor(0, 96, 127, 255), 1.3) rangepen = QtGui.QPen(QtGui.QColor(255, 255, 0, 255), 1.0) @@ -139,6 +140,34 @@ class az_map(QtGui.QWidget): painter.drawEllipse(QtCore.QRectF(-diameter / 2.0, -diameter / 2.0, diameter, diameter)) +class az_map_output(air_modes.parse): + def __init__(self, mypos, model): + air_modes.parse.__init__(self, mypos) + self.model = model + def output(self, msg): + [data, ecc, reference, timestamp] = msg.split() + data = air_modes.modes_reply(long(data, 16)) + ecc = long(ecc, 16) + rssi = 10.*math.log10(float(reference)) + msgtype = data["df"] + now = time.time() + + if msgtype == 17: + icao = data["aa"] + subtype = data["ftc"] + distance, altitude, bearing = [0,0,0] + if 5 <= subtype <= 8: + (ground_track, decoded_lat, decoded_lon, distance, bearing) = self.parseBDS06(data) + altitude = 0 + elif 9 <= subtype <= 18: + (altitude, decoded_lat, decoded_lon, distance, bearing) = self.parseBDS05(data) + + self.model.addRecord(bearing, altitude, distance) + + +############################## +# Test stuff +############################## import random, time class model_updater(threading.Thread): @@ -151,8 +180,11 @@ class model_updater(threading.Thread): def run(self): for i in range(az_map_model.npoints): - self.model.addRecord(i*360./az_map_model.npoints, 30000, random.randint(0,400)) time.sleep(0.1) + if(self.model): + self.model.addRecord(i*360./az_map_model.npoints, 30000, random.randint(0,400)) + else: + self.stop() class Window(QtGui.QWidget): def __init__(self): diff --git a/res/modes_rx.ui b/res/modes_rx.ui index b54b2d5..849ebd7 100644 --- a/res/modes_rx.ui +++ b/res/modes_rx.ui @@ -24,7 +24,7 @@ - 1 + 3 @@ -234,10 +234,6 @@ Filename - line_inputfile - label_13 - combo_rate - label_27 @@ -847,6 +843,21 @@ Data browser + + + Azimuth map + + + + + 10 + 10 + 245 + 245 + + + + Live data @@ -971,6 +982,12 @@ QWidget
qwt_dial.h
+ + az_map + QWidget +
air_modes/az_map
+ 1 +