Renamed everything in python/ for consistent namespace
This commit is contained in:
parent
5442cba206
commit
3163fca47a
@ -25,9 +25,9 @@ from PyQt4.Qwt5 import Qwt
|
||||
from gnuradio import gr, gru, optfir, eng_notation, blks2
|
||||
import gnuradio.gr.gr_threading as _threading
|
||||
import air_modes
|
||||
from air_modes.modes_exceptions import *
|
||||
from air_modes.exceptions import *
|
||||
from air_modes.modes_rx_ui import Ui_MainWindow
|
||||
from air_modes.modes_gui_model import *
|
||||
from air_modes.gui_model import *
|
||||
import sqlite3
|
||||
|
||||
class mainwindow(QtGui.QMainWindow):
|
||||
@ -254,32 +254,32 @@ class mainwindow(QtGui.QMainWindow):
|
||||
#output options to populate outputs, updates
|
||||
if self.ui.check_kml.checkState():
|
||||
#we spawn a thread to run every 30 seconds (or whatever) to generate KML
|
||||
self.kmlgen = air_modes.modes_kml(self.ui.line_kmlfilename.text(), self.dbname, my_position) #create a KML generating thread
|
||||
self.kmlgen = air_modes.output_kml(self.ui.line_kmlfilename.text(), self.dbname, my_position) #create a KML generating thread
|
||||
|
||||
if self.ui.check_sbs1.checkState():
|
||||
sbs1port = int(self.ui.line_sbs1port.text())
|
||||
sbs1out = air_modes.modes_output_sbs1(my_position, sbs1port)
|
||||
sbs1out = air_modes.output_sbs1(my_position, sbs1port)
|
||||
self.outputs.append(sbs1out.output)
|
||||
self.updates.append(sbs1out.add_pending_conns)
|
||||
|
||||
if self.ui.check_fgfs.checkState():
|
||||
fghost = "127.0.0.1" #TODO FIXME
|
||||
fgport = self.ui.line_fgfsport.currentText()
|
||||
fgout = air_modes.modes_flightgear(my_position, fghost, int(fgport))
|
||||
fgout = air_modes.output_flightgear(my_position, fghost, int(fgport))
|
||||
self.outputs.append(fgout.output)
|
||||
|
||||
if self.ui.check_raw.checkState():
|
||||
rawport = air_modes.modes_raw_server(int(self.ui.line_raw.text()))
|
||||
rawport = air_modes.raw_server(int(self.ui.line_raw.text()))
|
||||
self.outputs.append(rawport.output)
|
||||
self.updates.append(rawport.add_pending_conns)
|
||||
|
||||
self.livedata = air_modes.modes_output_print(my_position)
|
||||
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
|
||||
self.dbwriter = air_modes.modes_output_sql(my_position, self.dbname)
|
||||
self.dbwriter = air_modes.output_sql(my_position, self.dbname)
|
||||
self.outputs.append(self.dbwriter.output) #now the db will update itself
|
||||
|
||||
#output to update reports/sec widget
|
||||
|
@ -29,7 +29,7 @@ from string import split, join
|
||||
import air_modes
|
||||
import gnuradio.gr.gr_threading as _threading
|
||||
import csv
|
||||
from air_modes.modes_exceptions import *
|
||||
from air_modes.exceptions import *
|
||||
|
||||
class top_block_runner(_threading.Thread):
|
||||
def __init__(self, tb):
|
||||
@ -184,7 +184,7 @@ if __name__ == '__main__':
|
||||
updates = [] #registry of plugin update functions
|
||||
|
||||
if options.raw is True:
|
||||
rawport = air_modes.modes_raw_server(9988) #port
|
||||
rawport = air_modes.raw_server(9988) #port
|
||||
outputs.append(rawport.output)
|
||||
outputs.append(printraw)
|
||||
updates.append(rawport.add_pending_conns)
|
||||
@ -192,21 +192,21 @@ if __name__ == '__main__':
|
||||
if options.kml is not None:
|
||||
#we spawn a thread to run every 30 seconds (or whatever) to generate KML
|
||||
dbname = 'adsb.db'
|
||||
sqldb = air_modes.modes_output_sql(my_position, dbname) #input into the db
|
||||
kmlgen = air_modes.modes_kml(options.kml, dbname, my_position) #create a KML generating thread to read from the db
|
||||
sqldb = air_modes.output_sql(my_position, dbname) #input into the db
|
||||
kmlgen = air_modes.output_kml(options.kml, dbname, my_position) #create a KML generating thread to read from the db
|
||||
outputs.append(sqldb.output)
|
||||
|
||||
if options.sbs1 is True:
|
||||
sbs1port = air_modes.modes_output_sbs1(my_position, 30003)
|
||||
sbs1port = air_modes.output_sbs1(my_position, 30003)
|
||||
outputs.append(sbs1port.output)
|
||||
updates.append(sbs1port.add_pending_conns)
|
||||
|
||||
if options.no_print is not True:
|
||||
outputs.append(air_modes.modes_output_print(my_position).output)
|
||||
outputs.append(air_modes.output_print(my_position).output)
|
||||
|
||||
if options.multiplayer is not None:
|
||||
[fghost, fgport] = options.multiplayer.split(':')
|
||||
fgout = air_modes.modes_flightgear(my_position, fghost, int(fgport))
|
||||
fgout = air_modes.output_flightgear(my_position, fghost, int(fgport))
|
||||
outputs.append(fgout.output)
|
||||
|
||||
fg = adsb_rx_block(options, args, queue)
|
||||
|
@ -34,15 +34,15 @@ GR_PYTHON_INSTALL(
|
||||
altitude.py
|
||||
cpr.py
|
||||
mlat.py
|
||||
modes_exceptions.py
|
||||
modes_flightgear.py
|
||||
modes_gui_model.py
|
||||
modes_kml.py
|
||||
modes_parse.py
|
||||
modes_print.py
|
||||
modes_raw_server.py
|
||||
modes_sbs1.py
|
||||
modes_sql.py
|
||||
exceptions.py
|
||||
flightgear.py
|
||||
gui_model.py
|
||||
kml.py
|
||||
parse.py
|
||||
msprint.py
|
||||
raw_server.py
|
||||
sbs1.py
|
||||
sql.py
|
||||
Quaternion.py
|
||||
DESTINATION ${GR_PYTHON_DIR}/air_modes
|
||||
)
|
||||
|
@ -51,15 +51,16 @@ from air_modes_swig import *
|
||||
|
||||
# import any pure python here
|
||||
#
|
||||
from modes_print import modes_output_print
|
||||
from modes_sql import modes_output_sql
|
||||
from modes_sbs1 import modes_output_sbs1
|
||||
from modes_kml import modes_kml
|
||||
from modes_raw_server import modes_raw_server
|
||||
from modes_exceptions import *
|
||||
from parse import parse,modes_reply
|
||||
from msprint import output_print
|
||||
from sql import output_sql
|
||||
from sbs1 import output_sbs1
|
||||
from kml import output_kml
|
||||
from raw_server import raw_server
|
||||
from exceptions import *
|
||||
#this is try/excepted in case the user doesn't have numpy installed
|
||||
try:
|
||||
from modes_flightgear import modes_flightgear
|
||||
from flightgear import output_flightgear
|
||||
from Quaternion import *
|
||||
except ImportError:
|
||||
print "gr-air-modes warning: numpy+scipy not installed, FlightGear interface not supported"
|
||||
|
@ -23,7 +23,7 @@
|
||||
# For reference into the methodology used to decode altitude,
|
||||
# see RTCA DO-181D p.42
|
||||
|
||||
from modes_exceptions import *
|
||||
from air_modes.exceptions import *
|
||||
|
||||
def decode_alt(alt, bit13):
|
||||
mbit = alt & 0x0040
|
||||
|
@ -21,7 +21,7 @@
|
||||
#
|
||||
|
||||
import math, time
|
||||
from modes_exceptions import *
|
||||
from air_modes.exceptions import *
|
||||
#this implements CPR position decoding and encoding.
|
||||
#the decoder is implemented as a class, cpr_decoder, which keeps state for local decoding.
|
||||
#the encoder is cpr_encode([lat, lon], type (even=0, odd=1), and surface (0 for surface, 1 for airborne))
|
||||
|
@ -5,17 +5,18 @@
|
||||
|
||||
import struct
|
||||
import socket
|
||||
from air_modes import mlat, modes_parse
|
||||
import air_modes
|
||||
from air_modes import mlat
|
||||
import sqlite3
|
||||
import string, threading, math, time
|
||||
from air_modes.modes_sql import modes_output_sql
|
||||
from air_modes.sql import output_sql
|
||||
from Quaternion import Quat
|
||||
import numpy
|
||||
from modes_exceptions import *
|
||||
from air_modes.exceptions import *
|
||||
|
||||
class modes_flightgear(modes_parse.modes_parse):
|
||||
class output_flightgear(air_modes.parse):
|
||||
def __init__(self, localpos, hostname, port):
|
||||
modes_parse.modes_parse.__init__(self, localpos)
|
||||
air_modes.parse.__init__(self, localpos)
|
||||
self.hostname = hostname
|
||||
self.port = port
|
||||
self.localpos = localpos
|
||||
@ -28,7 +29,7 @@ class modes_flightgear(modes_parse.modes_parse):
|
||||
|
||||
def output(self, message):
|
||||
[data, ecc, reference, timestamp] = message.split()
|
||||
data = modes_parse.modes_reply(long(data, 16))
|
||||
data = air_modes.modes_reply(long(data, 16))
|
||||
|
||||
try:
|
||||
msgtype = data["df"]
|
||||
@ -204,7 +205,7 @@ if __name__ == '__main__':
|
||||
localpos = [37.409066,-122.077836]
|
||||
hostname = "localhost"
|
||||
port = 5000
|
||||
fgout = modes_flightgear(localpos, hostname, port)
|
||||
fgout = output_flightgear(localpos, hostname, port)
|
||||
|
||||
for line in iof:
|
||||
timetosend = float(line.split()[6])
|
@ -140,13 +140,13 @@ class dashboard_data_model(QtCore.QAbstractTableModel):
|
||||
self.endRemoveRows()
|
||||
self.lock.release()
|
||||
|
||||
class dashboard_output(air_modes.modes_parse.modes_parse):
|
||||
class dashboard_output(air_modes.parse):
|
||||
def __init__(self, mypos, model):
|
||||
air_modes.modes_parse.modes_parse.__init__(self, mypos)
|
||||
air_modes.parse.__init__(self, mypos)
|
||||
self.model = model
|
||||
def output(self, msg):
|
||||
[data, ecc, reference, timestamp] = msg.split()
|
||||
data = air_modes.modes_parse.modes_reply(long(data, 16))
|
||||
data = air_modes.modes_reply(long(data, 16))
|
||||
ecc = long(ecc, 16)
|
||||
rssi = 10.*math.log10(float(reference))
|
||||
msgtype = data["df"]
|
@ -22,7 +22,7 @@
|
||||
import sqlite3
|
||||
import string, math, threading, time
|
||||
|
||||
class modes_kml(threading.Thread):
|
||||
class output_kml(threading.Thread):
|
||||
def __init__(self, filename, dbname, localpos, timeout=5):
|
||||
threading.Thread.__init__(self)
|
||||
self._dbname = dbname
|
@ -1,71 +0,0 @@
|
||||
|
||||
#so, not to be a dick or anything, but this thing could be entirely
|
||||
#replaced with a clever SQL join or just a separate SQL table flattened
|
||||
#in modes_sql and designed specifically for this. you can keep the older
|
||||
#ones, too. this would let you access indices by column name, too. bonus.
|
||||
#you wouldn't get the nice hierarchical tree view, though. what does that lose you?
|
||||
#you'd need a different datamodel for the tree view, that's all.
|
||||
class modes_datamodel(QtCore.QAbstractItemModel):
|
||||
def __init__(self, db):
|
||||
QtCore.QAbstractItemModel.__init__(self)
|
||||
self.db = db
|
||||
|
||||
def rowCount(self, parent=QtCore.QModelIndex()):
|
||||
icaoquery = "select count(distinct icao) from positions"
|
||||
query = QtSql.QSqlQuery()
|
||||
query.exec_(icaoquery)
|
||||
query.next()
|
||||
return query.value(0).toInt()[0]
|
||||
|
||||
def columnCount(self, parent=QtCore.QModelIndex()):
|
||||
return 5
|
||||
|
||||
#for future use
|
||||
def flags(self, index):
|
||||
return QtCore.QAbstractItemModel.flags(self, index)
|
||||
|
||||
def data(self, index, role=QtCore.Qt.DisplayRole):
|
||||
if not index.isValid():
|
||||
return QtCore.QVariant()
|
||||
if index.row() >= self.rowCount():
|
||||
return QtCore.QVariant()
|
||||
if role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:
|
||||
#get ICAO of current index
|
||||
query = QtSql.QSqlQuery()
|
||||
#TODO: limit this to aircraft seen in last 600 seconds? or make a spinbox for this limit.
|
||||
icaoquery = "select distinct icao from positions order by icao limit %i,1" % index.row()
|
||||
query.exec_(icaoquery)
|
||||
query.next()
|
||||
icao = query.value(0).toInt()[0]
|
||||
#TODO figure out how to grab multiple records in one query and return them all?
|
||||
if index.column() == 0: #ICAO
|
||||
return "%06x" % icao
|
||||
elif index.column() == 1: #last seen
|
||||
seenquery = "select seen from positions where icao = %i order by seen desc limit 1" % icao
|
||||
query.exec_(seenquery)
|
||||
return "" if query.next() is False else query.value(0).toString()
|
||||
elif index.column() == 2: #ident
|
||||
identquery = "select ident from ident where icao = %i" % icao
|
||||
query.exec_(identquery)
|
||||
return "" if query.next() is False else query.value(0).toString()
|
||||
elif index.column() == 3: #altitude
|
||||
querystr = "select alt from positions where icao = %i order by seen desc limit 1" % icao
|
||||
query.exec_(querystr)
|
||||
return "" if query.next() is False else "%i" % query.value(0).toInt()[0]
|
||||
elif index.column() == 4: #latitude
|
||||
querystr = "select lat from positions where icao = %i order by seen desc limit 1" % icao
|
||||
query.exec_(querystr)
|
||||
return "" if query.next() is False else "%.6f" % query.value(0).toFloat()[0]
|
||||
elif index.column() == 5: #longitude
|
||||
querystr = "select lon from positions where icao = %i order by seen desc limit 1" % icao
|
||||
query.exec_(querystr)
|
||||
return "" if query.next() is False else "%.6f" % query.value(0).toFloat()[0]
|
||||
|
||||
else:
|
||||
return QtCore.QVariant()
|
||||
|
||||
def index(self, row, column, parent=QtCore.QModelIndex()):
|
||||
return self.createIndex(row, column)
|
||||
|
||||
def parent(self, child):
|
||||
return QtCore.QModelIndex()
|
@ -21,13 +21,13 @@
|
||||
|
||||
import time, os, sys
|
||||
from string import split, join
|
||||
import modes_parse
|
||||
from modes_exceptions import *
|
||||
import air_modes
|
||||
from air_modes.exceptions import *
|
||||
import math
|
||||
|
||||
class modes_output_print(modes_parse.modes_parse):
|
||||
class output_print(air_modes.parse):
|
||||
def __init__(self, mypos):
|
||||
modes_parse.modes_parse.__init__(self, mypos)
|
||||
air_modes.parse.__init__(self, mypos)
|
||||
|
||||
def parse(self, message):
|
||||
[data, ecc, reference, timestamp] = message.split()
|
||||
@ -44,7 +44,7 @@ class modes_output_print(modes_parse.modes_parse):
|
||||
output = "(%.0f %.10f) " % (refdb, timestamp);
|
||||
|
||||
try:
|
||||
data = modes_parse.modes_reply(long(data, 16))
|
||||
data = air_modes.modes_reply(long(data, 16))
|
||||
msgtype = data["df"]
|
||||
if msgtype == 0:
|
||||
output += self.print0(data, ecc)
|
@ -22,9 +22,9 @@
|
||||
import time, os, sys
|
||||
from string import split, join
|
||||
from altitude import decode_alt
|
||||
import cpr
|
||||
import math
|
||||
from modes_exceptions import *
|
||||
from air_modes.exceptions import *
|
||||
from air_modes import cpr
|
||||
|
||||
#this implements a packet class which can retrieve its own fields.
|
||||
class data_field:
|
||||
@ -213,7 +213,7 @@ class modes_reply(data_field):
|
||||
def get_type(self):
|
||||
return self.get_bits(1,5)
|
||||
|
||||
class modes_parse:
|
||||
class parse:
|
||||
def __init__(self, mypos):
|
||||
self.my_location = mypos
|
||||
self.cpr = cpr.cpr_decoder(self.my_location)
|
@ -24,7 +24,7 @@ import time, os, sys, socket
|
||||
from string import split, join
|
||||
from datetime import *
|
||||
|
||||
class modes_raw_server:
|
||||
class raw_server:
|
||||
def __init__(self, port):
|
||||
self._s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self._s.bind(('', port))
|
@ -22,13 +22,13 @@
|
||||
|
||||
import time, os, sys, socket
|
||||
from string import split, join
|
||||
import modes_parse
|
||||
import air_modes
|
||||
from datetime import *
|
||||
from modes_exceptions import *
|
||||
from air_modes.exceptions import *
|
||||
|
||||
class modes_output_sbs1(modes_parse.modes_parse):
|
||||
class output_sbs1(air_modes.parse):
|
||||
def __init__(self, mypos, port):
|
||||
modes_parse.modes_parse.__init__(self, mypos)
|
||||
air_modes.parse.__init__(self, mypos)
|
||||
self._s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self._s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self._s.bind(('', port))
|
||||
@ -106,7 +106,7 @@ class modes_output_sbs1(modes_parse.modes_parse):
|
||||
|
||||
[data, ecc, reference, timestamp] = message.split()
|
||||
|
||||
data = modes_parse.modes_reply(long(data, 16))
|
||||
data = air_modes.modes_reply(long(data, 16))
|
||||
ecc = long(ecc, 16)
|
||||
msgtype = data["df"]
|
||||
outmsg = None
|
@ -21,13 +21,13 @@
|
||||
|
||||
import time, os, sys
|
||||
from string import split, join
|
||||
import modes_parse
|
||||
import air_modes
|
||||
import sqlite3
|
||||
from modes_exceptions import *
|
||||
from air_modes.exceptions import *
|
||||
|
||||
class modes_output_sql(modes_parse.modes_parse):
|
||||
class output_sql(air_modes.parse):
|
||||
def __init__(self, mypos, filename):
|
||||
modes_parse.modes_parse.__init__(self, mypos)
|
||||
air_modes.parse.__init__(self, mypos)
|
||||
#create the database
|
||||
self.filename = filename
|
||||
self.db = sqlite3.connect(filename)
|
||||
@ -85,7 +85,7 @@ class modes_output_sql(modes_parse.modes_parse):
|
||||
#this version ignores anything that isn't Type 17 for now, because we just don't care
|
||||
[data, ecc, reference, timestamp] = message.split()
|
||||
|
||||
data = modes_parse.modes_reply(long(data, 16))
|
||||
data = air_modes.modes_reply(long(data, 16))
|
||||
ecc = long(ecc, 16)
|
||||
# reference = float(reference)
|
||||
|
Loading…
Reference in New Issue
Block a user