Fix FlightGear and SBS1 outputs.
This commit is contained in:
parent
27e0f87361
commit
42bf16ffc4
@ -18,7 +18,6 @@ class output_flightgear:
|
||||
def __init__(self, cprdec, hostname, port, pub):
|
||||
self.hostname = hostname
|
||||
self.port = port
|
||||
self.localpos = localpos
|
||||
self.positions = {}
|
||||
self.velocities = {}
|
||||
self.callsigns = {}
|
||||
@ -26,42 +25,41 @@ class output_flightgear:
|
||||
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.sock.connect((self.hostname, self.port))
|
||||
pub.subscribe("type17_dl", output)
|
||||
pub.subscribe("type17_dl", self.output)
|
||||
|
||||
def output(self, msg):
|
||||
|
||||
try:
|
||||
msgtype = msg.data["df"]
|
||||
if msgtype == 17: #ADS-B report
|
||||
icao24 = msg.data["aa"]
|
||||
bdsreg = msg.data["me"].get_type()
|
||||
if bdsreg == 0x08: #ident packet
|
||||
(ident, actype) = air_modes.parseBDS08(data)
|
||||
(ident, actype) = air_modes.parseBDS08(msg.data)
|
||||
#select model based on actype
|
||||
self.callsigns[icao24] = [ident, actype]
|
||||
|
||||
|
||||
elif bdsreg == 0x06: #BDS0,6 pos
|
||||
[ground_track, decoded_lat, decoded_lon, rnge, bearing] = air_modes.parseBDS06(data, self._cpr)
|
||||
[ground_track, decoded_lat, decoded_lon, rnge, bearing] = air_modes.parseBDS06(msg.data, self._cpr)
|
||||
self.positions[icao24] = [decoded_lat, decoded_lon, 0]
|
||||
self.update(icao24)
|
||||
|
||||
elif bdsreg == 0x05: #BDS0,5 pos
|
||||
[altitude, decoded_lat, decoded_lon, rnge, bearing] = air_modes.parseBDS05(data, self._cpr)
|
||||
[altitude, decoded_lat, decoded_lon, rnge, bearing] = air_modes.parseBDS05(msg.data, self._cpr)
|
||||
self.positions[icao24] = [decoded_lat, decoded_lon, altitude]
|
||||
self.update(icao24)
|
||||
|
||||
elif bdsreg == 0x09: #velocity
|
||||
subtype = data["bds09"].get_type()
|
||||
subtype = msg.data["bds09"].get_type()
|
||||
if subtype == 0:
|
||||
[velocity, heading, vert_spd, turnrate] = air_modes.parseBDS09_0(data)
|
||||
[velocity, heading, vert_spd, turnrate] = air_modes.parseBDS09_0(msg.data)
|
||||
elif subtype == 1:
|
||||
[velocity, heading, vert_spd] = air_modes.parseBDS09_1(data)
|
||||
[velocity, heading, vert_spd] = air_modes.parseBDS09_1(msg.data)
|
||||
turnrate = 0
|
||||
else:
|
||||
return
|
||||
|
||||
self.velocities[icao24] = [velocity, heading, vert_spd, turnrate]
|
||||
|
||||
|
||||
except ADSBError:
|
||||
pass
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
import time, os, sys, socket
|
||||
from string import split, join
|
||||
import air_modes
|
||||
from datetime import *
|
||||
import datetime
|
||||
from air_modes.exceptions import *
|
||||
import threading
|
||||
|
||||
@ -63,7 +63,7 @@ class output_sbs1:
|
||||
#it could be cleaner if there were separate output_* fns
|
||||
#but this works
|
||||
for i in (0, 4, 5, 11, 17):
|
||||
pub.subscribe("type%i_dl" % i, output)
|
||||
pub.subscribe("type%i_dl" % i, self.output)
|
||||
|
||||
#spawn thread to add new connections as they come in
|
||||
self._runner = dumb_task_runner(self.add_pending_conns, 0.1)
|
||||
@ -111,7 +111,7 @@ class output_sbs1:
|
||||
pass
|
||||
|
||||
def current_time(self):
|
||||
timenow = datetime.now()
|
||||
timenow = datetime.datetime.now()
|
||||
return [timenow.strftime("%Y/%m/%d"), timenow.strftime("%H:%M:%S.%f")[0:-3]]
|
||||
|
||||
def decode_fs(self, fs):
|
||||
@ -154,7 +154,7 @@ class output_sbs1:
|
||||
[datestr, timestr] = self.current_time()
|
||||
aircraft_id = self.get_aircraft_id(ecc)
|
||||
retstr = "MSG,7,0,%i,%06X,%i,%s,%s,%s,%s,,%s,,,,,,,,,," % (aircraft_id, ecc, aircraft_id+100, datestr, timestr, datestr, timestr, air_modes.decode_alt(shortdata["ac"], True))
|
||||
if vs:
|
||||
if shortdata["vs"]:
|
||||
retstr += "1\r\n"
|
||||
else:
|
||||
retstr += "0\r\n"
|
||||
@ -174,7 +174,7 @@ class output_sbs1:
|
||||
|
||||
def pp11(self, shortdata, ecc):
|
||||
[datestr, timestr] = self.current_time()
|
||||
aircraft_id = self.get_aircraft_id(icao24)
|
||||
aircraft_id = self.get_aircraft_id(shortdata["aa"])
|
||||
return "MSG,8,0,%i,%06X,%i,%s,%s,%s,%s,,,,,,,,,,,,\r\n" % (aircraft_id, shortdata["aa"], aircraft_id+100, datestr, timestr, datestr, timestr)
|
||||
|
||||
def pp17(self, data):
|
||||
|
Loading…
Reference in New Issue
Block a user