Add back in the SBS1 interface
This commit is contained in:
parent
d2a6f40bbd
commit
94af9fac48
@ -80,10 +80,10 @@ def main():
|
||||
fgout = air_modes.output_flightgear(my_position, fghost, int(fgport))
|
||||
relay.subscribe("dl_data", fgout.output)
|
||||
|
||||
# if options.sbs1 is True:
|
||||
# sbs1port = air_modes.output_sbs1(my_position, 30003)
|
||||
# relay.subscribe("dl_data", sbs1port.output)
|
||||
#updates.append(sbs1port.add_pending_conns) #TODO FIXME
|
||||
if options.sbs1 is True:
|
||||
sbs1port = air_modes.output_sbs1(my_position, 30003)
|
||||
relay.subscribe("dl_data", sbs1port.output)
|
||||
|
||||
tb.run()
|
||||
tb.cleanup()
|
||||
|
||||
|
@ -25,6 +25,27 @@ from string import split, join
|
||||
import air_modes
|
||||
from datetime import *
|
||||
from air_modes.exceptions import *
|
||||
import threading
|
||||
|
||||
class dumb_task_runner(threading.Thread):
|
||||
def __init__(self, task, interval):
|
||||
threading.Thread.__init__(self)
|
||||
self._task = task
|
||||
self._interval = interval
|
||||
self.shutdown = threading.Event()
|
||||
self.finished = threading.Event()
|
||||
self.setDaemon(True)
|
||||
self.start()
|
||||
|
||||
def run(self):
|
||||
while not self.shutdown.is_set():
|
||||
self._task()
|
||||
time.sleep(self._interval)
|
||||
self.finished.set()
|
||||
|
||||
def close(self):
|
||||
self.shutdown.set()
|
||||
self.finished.wait(self._interval)
|
||||
|
||||
class output_sbs1(air_modes.parse):
|
||||
def __init__(self, mypos, port):
|
||||
@ -38,6 +59,9 @@ class output_sbs1(air_modes.parse):
|
||||
self._aircraft_id_map = {} # dictionary of icao24 to aircraft IDs
|
||||
self._aircraft_id_count = 0 # Current Aircraft ID count
|
||||
|
||||
#spawn thread to add new connections as they come in
|
||||
self._runner = dumb_task_runner(self.add_pending_conns, 0.1)
|
||||
|
||||
def __del__(self):
|
||||
self._s.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user