Renamed everything in python/ for consistent namespace
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user