Azimuth map working.
This commit is contained in:
parent
dfb48dbe8d
commit
cd2cfec730
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -24,7 +24,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@ -234,10 +234,6 @@
|
||||
<string>Filename</string>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>line_inputfile</zorder>
|
||||
<zorder>label_13</zorder>
|
||||
<zorder>combo_rate</zorder>
|
||||
<zorder>label_27</zorder>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -847,6 +843,21 @@
|
||||
<string>Data browser</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="azimuth_tab">
|
||||
<attribute name="title">
|
||||
<string>Azimuth map</string>
|
||||
</attribute>
|
||||
<widget class="az_map" name="azimuth_map" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>245</width>
|
||||
<height>245</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="livedatatab">
|
||||
<attribute name="title">
|
||||
<string>Live data</string>
|
||||
@ -971,6 +982,12 @@
|
||||
<extends>QWidget</extends>
|
||||
<header>qwt_dial.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>az_map</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">air_modes/az_map</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
Reference in New Issue
Block a user