Flightgear plugin modified for new parser interface.
This commit is contained in:
parent
9563972591
commit
f8f08ecd37
@ -98,8 +98,7 @@ def main():
|
|||||||
|
|
||||||
if options.multiplayer is not None:
|
if options.multiplayer is not None:
|
||||||
[fghost, fgport] = options.multiplayer.split(':')
|
[fghost, fgport] = options.multiplayer.split(':')
|
||||||
fgout = air_modes.output_flightgear(my_position, fghost, int(fgport))
|
fgout = air_modes.output_flightgear(cpr_dec, fghost, int(fgport), publisher)
|
||||||
relay.subscribe("dl_data", fgout.output)
|
|
||||||
|
|
||||||
if options.sbs1 is True:
|
if options.sbs1 is True:
|
||||||
sbs1port = air_modes.output_sbs1(cpr_dec, 30003, publisher)
|
sbs1port = air_modes.output_sbs1(cpr_dec, 30003, publisher)
|
||||||
|
@ -14,49 +14,48 @@ from Quaternion import Quat
|
|||||||
import numpy
|
import numpy
|
||||||
from air_modes.exceptions import *
|
from air_modes.exceptions import *
|
||||||
|
|
||||||
class output_flightgear(air_modes.parse):
|
class output_flightgear:
|
||||||
def __init__(self, localpos, hostname, port):
|
def __init__(self, cprdec, hostname, port, pub):
|
||||||
air_modes.parse.__init__(self, localpos)
|
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
self.port = port
|
self.port = port
|
||||||
self.localpos = localpos
|
self.localpos = localpos
|
||||||
self.positions = {}
|
self.positions = {}
|
||||||
self.velocities = {}
|
self.velocities = {}
|
||||||
self.callsigns = {}
|
self.callsigns = {}
|
||||||
|
self._cpr = cprdec
|
||||||
|
|
||||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
self.sock.connect((self.hostname, self.port))
|
self.sock.connect((self.hostname, self.port))
|
||||||
|
pub.subscribe("type17_dl", output)
|
||||||
|
|
||||||
def output(self, message):
|
def output(self, msg):
|
||||||
[data, ecc, reference, timestamp] = message.split()
|
|
||||||
data = air_modes.modes_reply(long(data, 16))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
msgtype = data["df"]
|
msgtype = msg.data["df"]
|
||||||
if msgtype == 17: #ADS-B report
|
if msgtype == 17: #ADS-B report
|
||||||
icao24 = data["aa"]
|
icao24 = msg.data["aa"]
|
||||||
bdsreg = data["me"].get_type()
|
bdsreg = msg.data["me"].get_type()
|
||||||
if bdsreg == 0x08: #ident packet
|
if bdsreg == 0x08: #ident packet
|
||||||
(ident, actype) = self.parseBDS08(data)
|
(ident, actype) = air_modes.parseBDS08(data)
|
||||||
#select model based on actype
|
#select model based on actype
|
||||||
self.callsigns[icao24] = [ident, actype]
|
self.callsigns[icao24] = [ident, actype]
|
||||||
|
|
||||||
elif bdsreg == 0x06: #BDS0,6 pos
|
elif bdsreg == 0x06: #BDS0,6 pos
|
||||||
[ground_track, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS06(data)
|
[ground_track, decoded_lat, decoded_lon, rnge, bearing] = air_modes.parseBDS06(data, self._cpr)
|
||||||
self.positions[icao24] = [decoded_lat, decoded_lon, 0]
|
self.positions[icao24] = [decoded_lat, decoded_lon, 0]
|
||||||
self.update(icao24)
|
self.update(icao24)
|
||||||
|
|
||||||
elif bdsreg == 0x05: #BDS0,5 pos
|
elif bdsreg == 0x05: #BDS0,5 pos
|
||||||
[altitude, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS05(data)
|
[altitude, decoded_lat, decoded_lon, rnge, bearing] = air_modes.parseBDS05(data, self._cpr)
|
||||||
self.positions[icao24] = [decoded_lat, decoded_lon, altitude]
|
self.positions[icao24] = [decoded_lat, decoded_lon, altitude]
|
||||||
self.update(icao24)
|
self.update(icao24)
|
||||||
|
|
||||||
elif bdsreg == 0x09: #velocity
|
elif bdsreg == 0x09: #velocity
|
||||||
subtype = data["bds09"].get_type()
|
subtype = data["bds09"].get_type()
|
||||||
if subtype == 0:
|
if subtype == 0:
|
||||||
[velocity, heading, vert_spd, turnrate] = self.parseBDS09_0(data)
|
[velocity, heading, vert_spd, turnrate] = air_modes.parseBDS09_0(data)
|
||||||
elif subtype == 1:
|
elif subtype == 1:
|
||||||
[velocity, heading, vert_spd] = self.parseBDS09_1(data)
|
[velocity, heading, vert_spd] = air_modes.parseBDS09_1(data)
|
||||||
turnrate = 0
|
turnrate = 0
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user