Cleaned up the print module, minor changes to parse and FGFS module. Untested.
This commit is contained in:
parent
067556cbdd
commit
cf8f429900
@ -51,16 +51,15 @@ class modes_flightgear(modes_parse.modes_parse):
|
||||
self.update(icao24)
|
||||
|
||||
elif subtype == 19: #velocity
|
||||
pass #FIXME TODO BDS0,9
|
||||
# subsubtype = (longdata >> 48) & 0x07
|
||||
# if subsubtype == 0:
|
||||
# [velocity, heading, vert_spd, turnrate] = self.parseBDS09_0(data)
|
||||
# elif subsubtype == 1:
|
||||
# [velocity, heading, vert_spd] = self.parseBDS09_1(data)
|
||||
# turnrate = 0
|
||||
# else:
|
||||
# return
|
||||
# self.velocities[icao24] = [velocity, heading, vert_spd, turnrate]
|
||||
subsubtype = data["me"]["bds09"]["sub"]
|
||||
if subsubtype == 0:
|
||||
[velocity, heading, vert_spd, turnrate] = self.parseBDS09_0(data)
|
||||
elif 1 <= subsubtype <= 2:
|
||||
[velocity, heading, vert_spd] = self.parseBDS09_1(data)
|
||||
turnrate = 0
|
||||
else:
|
||||
return
|
||||
self.velocities[icao24] = [velocity, heading, vert_spd, turnrate]
|
||||
|
||||
except ADSBError:
|
||||
pass
|
||||
|
@ -156,6 +156,8 @@ class me_reply(data_field):
|
||||
return 0x05
|
||||
elif ftc == 19:
|
||||
return 0x09
|
||||
elif ftc == 28:
|
||||
return 0x61
|
||||
else:
|
||||
return NoHandlerError
|
||||
|
||||
@ -212,7 +214,7 @@ class modes_parse:
|
||||
return [data["aa"], interrogator, data["ca"]]
|
||||
|
||||
categories = [["NO INFO", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED"],\
|
||||
["NO INFO", "SURFACE EMERGENCY VEHICLE", "SURFACE SERVICE VEHICLE", "FIXED OBSTRUCTION", "RESERVED", "RESERVED", "RESERVED"],\
|
||||
["NO INFO", "SURFACE EMERGENCY VEHICLE", "SURFACE SERVICE VEHICLE", "FIXED OBSTRUCTION", "CLUSTER OBSTRUCTION", "LINE OBSTRUCTION", "RESERVED"],\
|
||||
["NO INFO", "GLIDER", "BALLOON/BLIMP", "PARACHUTE", "ULTRALIGHT", "RESERVED", "UAV", "SPACECRAFT"],\
|
||||
["NO INFO", "LIGHT", "SMALL", "LARGE", "LARGE HIGH VORTEX", "HEAVY", "HIGH PERFORMANCE", "ROTORCRAFT"]]
|
||||
|
||||
@ -323,28 +325,33 @@ class modes_parse:
|
||||
|
||||
return [velocity, heading, vert_spd]
|
||||
|
||||
def parse20(self, shortdata, longdata):
|
||||
[fs, dr, um, alt] = self.parse4(shortdata)
|
||||
#BDS defines TCAS reply type and is the first 8 bits
|
||||
#BDS1 is first four, BDS2 is bits 5-8
|
||||
bds1 = longdata_bits(longdata, 33, 4)
|
||||
bds2 = longdata_bits(longdata, 37, 4)
|
||||
#bds2 != 0 defines extended TCAS capabilities, not in spec
|
||||
return [fs, dr, um, alt, bds1, bds2]
|
||||
def parseBDS62(self, data):
|
||||
eps_strings = ["NO EMERGENCY", "GENERAL EMERGENCY", "LIFEGUARD/MEDICAL", "FUEL EMERGENCY",
|
||||
"NO COMMUNICATIONS", "UNLAWFUL INTERFERENCE", "RESERVED", "RESERVED"]
|
||||
return eps_strings[data["me"]["eps"]]
|
||||
|
||||
def parseMB_commB(self, longdata): #bds1, bds2 == 0
|
||||
raise NoHandlerError
|
||||
# def parse20(self, shortdata, longdata):
|
||||
# [fs, dr, um, alt] = self.parse4(shortdata)
|
||||
# #BDS defines TCAS reply type and is the first 8 bits
|
||||
# #BDS1 is first four, BDS2 is bits 5-8
|
||||
# bds1 = longdata_bits(longdata, 33, 4)
|
||||
# bds2 = longdata_bits(longdata, 37, 4)
|
||||
# #bds2 != 0 defines extended TCAS capabilities, not in spec
|
||||
# return [fs, dr, um, alt, bds1, bds2]
|
||||
|
||||
def parseMB_caps(self, longdata): #bds1 == 1, bds2 == 0
|
||||
#cfs, acs, bcs
|
||||
raise NoHandlerError
|
||||
# def parseMB_commB(self, longdata): #bds1, bds2 == 0
|
||||
# raise NoHandlerError
|
||||
|
||||
def parseMB_id(self, longdata): #bds1 == 2, bds2 == 0
|
||||
msg = ""
|
||||
for i in range(0, 8):
|
||||
msg += self.charmap( longdata >> (42-6*i) & 0x3F)
|
||||
return (msg)
|
||||
# def parseMB_caps(self, longdata): #bds1 == 1, bds2 == 0
|
||||
# #cfs, acs, bcs
|
||||
# raise NoHandlerError
|
||||
|
||||
def parseMB_TCASRA(self, longdata): #bds1 == 3, bds2 == 0
|
||||
# def parseMB_id(self, longdata): #bds1 == 2, bds2 == 0
|
||||
# msg = ""
|
||||
# for i in range(0, 8):
|
||||
# msg += self.charmap( longdata >> (42-6*i) & 0x3F)
|
||||
# return (msg)
|
||||
|
||||
# def parseMB_TCASRA(self, longdata): #bds1 == 3, bds2 == 0
|
||||
#ara[41-54],rac[55-58],rat[59],mte[60],tti[61-62],tida[63-75],tidr[76-82],tidb[83-88]
|
||||
raise NoHandlerError
|
||||
# raise NoHandlerError
|
||||
|
@ -57,10 +57,10 @@ class modes_output_print(modes_parse.modes_parse):
|
||||
elif msgtype == 17:
|
||||
output += self.print17(data)
|
||||
else:
|
||||
output += "No handler for message type " + str(msgtype) + (" from %x" % ecc) + " (but it's in modes_parse)"
|
||||
output += "No handler for message type %i from %x (but it's in modes_parse)" % (msgtype, ecc)
|
||||
print output
|
||||
except NoHandlerError as e:
|
||||
output += "No handler for message type " + str(e.msgtype) + " from %x" % ecc
|
||||
output += "No handler for message type %i from %x" % (msgtype, ecc)
|
||||
print output
|
||||
except MetricAltError:
|
||||
pass
|
||||
@ -70,15 +70,23 @@ class modes_output_print(modes_parse.modes_parse):
|
||||
def print0(self, shortdata, ecc):
|
||||
[vs, cc, sl, ri, altitude] = self.parse0(shortdata)
|
||||
|
||||
retstr = "Type 0 (short A-A surveillance) from " + "%x" % ecc + " at " + str(altitude) + "ft"
|
||||
retstr = "Type 0 (short A-A surveillance) from %x at %ift" % (ecc, altitude)
|
||||
# the ri values below 9 are used for other things. might want to print those someday.
|
||||
if ri == 9:
|
||||
retstr = retstr + " (speed <75kt)"
|
||||
if ri == 0:
|
||||
retstr += " (No TCAS)"
|
||||
elif ri == 2:
|
||||
retstr += " (TCAS resolution inhibited)"
|
||||
elif ri == 3:
|
||||
retstr += " (Vertical TCAS resolution only)"
|
||||
elif ri == 4:
|
||||
retstr += " (Full TCAS resolution)"
|
||||
elif ri == 9:
|
||||
retstr += " (speed <75kt)"
|
||||
elif ri > 9:
|
||||
retstr = retstr + " (speed " + str(75 * (1 << (ri-10))) + "-" + str(75 * (1 << (ri-9))) + "kt)"
|
||||
retstr += " (speed %i-%ikt)" % (75 * (1 << (ri-10)), 75 * (1 << (ri-9)))
|
||||
|
||||
if vs is True:
|
||||
retstr = retstr + " (aircraft is on the ground)"
|
||||
retstr += " (aircraft is on the ground)"
|
||||
|
||||
return retstr
|
||||
|
||||
@ -86,43 +94,42 @@ class modes_output_print(modes_parse.modes_parse):
|
||||
|
||||
[fs, dr, um, altitude] = self.parse4(shortdata)
|
||||
|
||||
retstr = "Type 4 (short surveillance altitude reply) from " + "%x" % ecc + " at " + str(altitude) + "ft"
|
||||
retstr = "Type 4 (short surveillance altitude reply) from %x at %ift" % (ecc, altitude)
|
||||
|
||||
if fs == 1:
|
||||
retstr = retstr + " (aircraft is on the ground)"
|
||||
retstr += " (aircraft is on the ground)"
|
||||
elif fs == 2:
|
||||
retstr = retstr + " (AIRBORNE ALERT)"
|
||||
retstr += " (AIRBORNE ALERT)"
|
||||
elif fs == 3:
|
||||
retstr = retstr + " (GROUND ALERT)"
|
||||
retstr += " (GROUND ALERT)"
|
||||
elif fs == 4:
|
||||
retstr = retstr + " (SPI ALERT)"
|
||||
retstr += " (SPI ALERT)"
|
||||
elif fs == 5:
|
||||
retstr = retstr + " (SPI)"
|
||||
retstr += " (SPI)"
|
||||
|
||||
return retstr
|
||||
|
||||
def print5(self, shortdata, ecc):
|
||||
[fs, dr, um, ident] = self.parse5(shortdata)
|
||||
|
||||
retstr = "Type 5 (short surveillance ident reply) from " + "%x" % ecc + " with ident " + str(ident)
|
||||
retstr = "Type 5 (short surveillance ident reply) from %x with ident %i" % (ecc, ident)
|
||||
|
||||
if fs == 1:
|
||||
retstr = retstr + " (aircraft is on the ground)"
|
||||
retstr += " (aircraft is on the ground)"
|
||||
elif fs == 2:
|
||||
retstr = retstr + " (AIRBORNE ALERT)"
|
||||
retstr += " (AIRBORNE ALERT)"
|
||||
elif fs == 3:
|
||||
retstr = retstr + " (GROUND ALERT)"
|
||||
retstr += " (GROUND ALERT)"
|
||||
elif fs == 4:
|
||||
retstr = retstr + " (SPI ALERT)"
|
||||
retstr += " (SPI ALERT)"
|
||||
elif fs == 5:
|
||||
retstr = retstr + " (SPI)"
|
||||
retstr += " (SPI)"
|
||||
|
||||
return retstr
|
||||
|
||||
def print11(self, data, ecc):
|
||||
[icao24, interrogator, ca] = self.parse11(data, ecc)
|
||||
|
||||
retstr = "Type 11 (all call reply) from " + "%x" % icao24 + " in reply to interrogator " + str(interrogator)
|
||||
retstr = "Type 11 (all call reply) from %x in reply to interrogator %i" % (icao24, interrogator)
|
||||
return retstr
|
||||
|
||||
def print17(self, data):
|
||||
@ -133,35 +140,37 @@ class modes_output_print(modes_parse.modes_parse):
|
||||
|
||||
if 1 <= subtype <= 4:
|
||||
(msg, typestring) = self.parseBDS08(data)
|
||||
retstr = "Type 17 subtype 04 (ident) from " + "%x" % icao24 + " of type " + typestring + " with ident " + msg
|
||||
retstr = "Type 17 subtype 04 (ident) from %x type %s ident %s" % (icao24, typestring, msg)
|
||||
|
||||
elif subtype >= 5 and subtype <= 8:
|
||||
[altitude, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS06(data)
|
||||
retstr = "Type 17 subtype 06 (surface report) from " + "%x" % icao24 + " at (" + "%.6f" % decoded_lat + ", " + "%.6f" % decoded_lon + ")"
|
||||
retstr = "Type 17 subtype 06 (surface report) from %x at (%.6f, %.6f)" % (icao24, decoded_lat, decoded_lon)
|
||||
if rnge is not None and bearing is not None:
|
||||
retstr += " (" + "%.2f" % rnge + " @ " + "%.0f" % bearing + ")"
|
||||
retstr += " (%.2f @ %.0f)" % (rnge, bearing)
|
||||
|
||||
elif subtype >= 9 and subtype <= 18:
|
||||
[altitude, decoded_lat, decoded_lon, rnge, bearing] = self.parseBDS05(data)
|
||||
retstr = "Type 17 subtype 05 (position report) from " + "%x" % icao24 + " at (" + "%.6f" % decoded_lat + ", " + "%.6f" % decoded_lon + ")"
|
||||
retstr = "Type 17 subtype 05 (position report) from %x at (%.6f, %.6f)" % (icao24, decoded_lat, decoded_lon)
|
||||
if rnge is not None and bearing is not None:
|
||||
retstr += " (" + "%.2f" % rnge + " @ " + "%.0f" % bearing + ")"
|
||||
retstr += " at " + str(altitude) + "ft"
|
||||
|
||||
elif subtype == 19:
|
||||
retstr = "Fix BDS0,9, dickhead"
|
||||
# subsubtype = (longdata >> 48) & 0x07
|
||||
# if subsubtype == 0:
|
||||
# [velocity, heading, vert_spd] = self.parseBDS09_0(shortdata, longdata)
|
||||
# retstr = "Type 17 subtype 09-0 (track report) from " + "%x" % icao24 + " with velocity " + "%.0f" % velocity + "kt heading " + "%.0f" % heading + " VS " + "%.0f" % vert_spd
|
||||
subsubtype = data["me"]["bds09"]["sub"]
|
||||
if subsubtype == 0:
|
||||
[velocity, heading, vert_spd] = self.parseBDS09_0(data)
|
||||
retstr = "Type 17 subtype 09-0 (track report) from %x with velocity %.0fkt heading %.0f VS %.0f" % (icao24, velocity, heading, vert_spd)
|
||||
elif 1 <= subsubtype <= 2:
|
||||
[velocity, heading, vert_spd] = self.parseBDS09_1(data)
|
||||
retstr = "Type 17 subtype 09-%i (track report) from %x with velocity %.0fkt heading %.0f VS %.0f" % (subsubtype, icao24, velocity, heading, vert_spd)
|
||||
else:
|
||||
retstr = "Type 17 subtype 09-%i from %x not implemented" % (subsubtype, icao24)
|
||||
|
||||
# elif subsubtype == 1:
|
||||
# [velocity, heading, vert_spd] = self.parseBDS09_1(shortdata, longdata)
|
||||
# retstr = "Type 17 subtype 09-1 (track report) from " + "%x" % icao24 + " with velocity " + "%.0f" % velocity + "kt heading " + "%.0f" % heading + " VS " + "%.0f" % vert_spd
|
||||
|
||||
# else:
|
||||
# retstr = "Type 17 subtype 09-%i" % (subsubtype) + " not implemented"
|
||||
elif subtype == 28:
|
||||
emerg_str = self.parseBDS62(data)
|
||||
retstr = "Type 17 subtype 28 (emergency) from %x type %s" % (icao24, emerg_str)
|
||||
|
||||
else:
|
||||
retstr = "Type 17 subtype " + str(subtype) + " not implemented"
|
||||
retstr = "Type 17 subtype %i from %x not implemented" % (subtype, icao24)
|
||||
|
||||
return retstr
|
||||
|
Loading…
Reference in New Issue
Block a user