KML generation in there but not tested
This commit is contained in:
parent
627b820b6e
commit
ac0b796d1d
@ -36,15 +36,15 @@ class modes_output_sql(modes_parse.modes_parse):
|
|||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.db.close()
|
self.db.close()
|
||||||
|
|
||||||
def output(self, message):
|
def insert(self, message):
|
||||||
query = self.make_query(message)
|
query = self.make_insert_query(message)
|
||||||
if query is not None:
|
if query is not None:
|
||||||
c = self.db.cursor()
|
c = self.db.cursor()
|
||||||
c.execute(query)
|
c.execute(query)
|
||||||
c.close()
|
c.close()
|
||||||
self.db.commit() #not sure if i have to do this
|
self.db.commit() #not sure if i have to do this
|
||||||
|
|
||||||
def make_query(self, message):
|
def make_insert_query(self, message):
|
||||||
#assembles a SQL query tailored to our database
|
#assembles a SQL query tailored to our database
|
||||||
#this version ignores anything that isn't Type 17 for now, because we just don't care
|
#this version ignores anything that isn't Type 17 for now, because we just don't care
|
||||||
[msgtype, shortdata, longdata, parity, ecc, reference] = message.split()
|
[msgtype, shortdata, longdata, parity, ecc, reference] = message.split()
|
||||||
@ -98,9 +98,6 @@ class modes_output_sql(modes_parse.modes_parse):
|
|||||||
[velocity, heading, vert_spd] = self.parseBDS09_1(shortdata, longdata, parity, ecc)
|
[velocity, heading, vert_spd] = self.parseBDS09_1(shortdata, longdata, parity, ecc)
|
||||||
retstr = "INSERT INTO vectors (icao, seen, speed, heading, vertical) VALUES (" + "%i" % icao24 + ", datetime('now'), " + "%.0f" % velocity + ", " + "%.0f" % heading + ", " + "%.0f" % vert_spd + ")";
|
retstr = "INSERT INTO vectors (icao, seen, speed, heading, vertical) VALUES (" + "%i" % icao24 + ", datetime('now'), " + "%.0f" % velocity + ", " + "%.0f" % heading + ", " + "%.0f" % vert_spd + ")";
|
||||||
|
|
||||||
else:
|
|
||||||
print "debug (modes_sql): unknown subtype %i with data %x %x %x" % (subtype, shortdata, longdata, parity,)
|
|
||||||
|
|
||||||
return retstr
|
return retstr
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from gnuradio import gr, gru, optfir, eng_notation, blks2, air
|
|||||||
from gnuradio import uhd
|
from gnuradio import uhd
|
||||||
from gnuradio.eng_option import eng_option
|
from gnuradio.eng_option import eng_option
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import time, os, sys
|
import time, os, sys, threading
|
||||||
from string import split, join
|
from string import split, join
|
||||||
from usrpm import usrp_dbid
|
from usrpm import usrp_dbid
|
||||||
from modes_print import modes_output_print
|
from modes_print import modes_output_print
|
||||||
@ -23,9 +23,7 @@ class top_block_runner(_threading.Thread):
|
|||||||
self.tb.run()
|
self.tb.run()
|
||||||
self.done = True
|
self.done = True
|
||||||
|
|
||||||
|
|
||||||
class adsb_rx_block (gr.top_block):
|
class adsb_rx_block (gr.top_block):
|
||||||
|
|
||||||
def __init__(self, options, args, queue):
|
def __init__(self, options, args, queue):
|
||||||
gr.top_block.__init__(self)
|
gr.top_block.__init__(self)
|
||||||
|
|
||||||
@ -101,8 +99,8 @@ if __name__ == '__main__':
|
|||||||
help="set DBSRX baseband bandwidth in Hz [default=%default]")
|
help="set DBSRX baseband bandwidth in Hz [default=%default]")
|
||||||
parser.add_option("-F","--filename", type="string", default=None,
|
parser.add_option("-F","--filename", type="string", default=None,
|
||||||
help="read data from file instead of USRP")
|
help="read data from file instead of USRP")
|
||||||
parser.add_option("-D","--database", action="store_true", default=False,
|
parser.add_option("-K","--kml", type="string", default=None,
|
||||||
help="send to database instead of printing to screen")
|
help="filename for Google Earth KML output")
|
||||||
parser.add_option("-P","--sbs1", action="store_true", default=False,
|
parser.add_option("-P","--sbs1", action="store_true", default=False,
|
||||||
help="open an SBS-1-compatible server on port 30003")
|
help="open an SBS-1-compatible server on port 30003")
|
||||||
parser.add_option("-n","--no-print", action="store_true", default=False,
|
parser.add_option("-n","--no-print", action="store_true", default=False,
|
||||||
@ -115,8 +113,11 @@ if __name__ == '__main__':
|
|||||||
outputs = [] #registry of plugin output functions
|
outputs = [] #registry of plugin output functions
|
||||||
updates = [] #registry of plugin update functions
|
updates = [] #registry of plugin update functions
|
||||||
|
|
||||||
if options.database is True:
|
if options.kml is not None:
|
||||||
outputs.append(modes_output_sql().output)
|
sqlport = modes_output_sql()
|
||||||
|
outputs.append(sqlport.insert)
|
||||||
|
#also we spawn a thread to run every 30 seconds (or whatever) to generate KML
|
||||||
|
kmlgen = modes_kml(sqlport.db, options.kml) #this is a thread
|
||||||
|
|
||||||
if options.sbs1 is True:
|
if options.sbs1 is True:
|
||||||
sbs1port = modes_output_sbs1()
|
sbs1port = modes_output_sbs1()
|
||||||
@ -153,4 +154,6 @@ if __name__ == '__main__':
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
fg.stop()
|
fg.stop()
|
||||||
runner = None
|
runner = None
|
||||||
|
if kmlgen is not None: #this breaks your nice output registry scheme
|
||||||
|
kmlgen = None
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user