Merge branch 'cpr' into az_map
This commit is contained in:
commit
cadbf0eaaa
@ -48,8 +48,8 @@ class mainwindow(QtGui.QMainWindow):
|
||||
#should round to actual achieved gain
|
||||
self.ui.line_gain.insert("30")
|
||||
|
||||
#default to 3dB
|
||||
self.ui.line_threshold.insert("3")
|
||||
#default to 5dB
|
||||
self.ui.line_threshold.insert("5")
|
||||
|
||||
self.ui.prog_rssi.setMinimum(-40)
|
||||
self.ui.prog_rssi.setMaximum(0)
|
||||
|
@ -151,7 +151,7 @@ if __name__ == '__main__':
|
||||
help="set RF gain", metavar="dB")
|
||||
parser.add_option("-r", "--rate", type="eng_float", default=4000000,
|
||||
help="set ADC sample rate [default=%default]")
|
||||
parser.add_option("-T", "--threshold", type="eng_float", default=3.0,
|
||||
parser.add_option("-T", "--threshold", type="eng_float", default=5.0,
|
||||
help="set pulse detection threshold above noise in dB [default=%default]")
|
||||
parser.add_option("-a","--output-all", action="store_true", default=False,
|
||||
help="output all frames")
|
||||
|
@ -45,7 +45,7 @@ air_modes_preamble::air_modes_preamble(int channel_rate, float threshold_db) :
|
||||
d_samples_per_symbol = d_samples_per_chip * 2;
|
||||
d_check_width = 120 * d_samples_per_symbol; //only search to this far from the end of the stream buffer
|
||||
d_threshold_db = threshold_db;
|
||||
d_threshold = powf(10., threshold_db/10.); //the level that the sample must be above the moving average in order to qualify as a pulse
|
||||
d_threshold = powf(10., threshold_db/20.); //the level that the sample must be above the moving average in order to qualify as a pulse
|
||||
d_secs_per_sample = 1.0 / channel_rate;
|
||||
set_output_multiple(1+d_check_width*2);
|
||||
|
||||
|
@ -65,8 +65,8 @@ static slice_result_t slicer(const float bit0, const float bit1, const float ref
|
||||
slice_result_t result;
|
||||
|
||||
//3dB limits for bit slicing and confidence measurement
|
||||
float highlimit=ref*2;
|
||||
float lowlimit=ref*0.5;
|
||||
float highlimit=ref*1.414;
|
||||
float lowlimit=ref*0.707;
|
||||
|
||||
bool firstchip_inref = ((bit0 > lowlimit) && (bit0 < highlimit));
|
||||
bool secondchip_inref = ((bit1 > lowlimit) && (bit1 < highlimit));
|
||||
|
@ -172,7 +172,6 @@ def range_bearing(loc_a, loc_b):
|
||||
class cpr_decoder:
|
||||
def __init__(self, my_location):
|
||||
self.my_location = my_location
|
||||
self.lkplist = {}
|
||||
self.evenlist = {}
|
||||
self.oddlist = {}
|
||||
|
||||
@ -180,9 +179,9 @@ class cpr_decoder:
|
||||
self.my_location = new_location
|
||||
|
||||
def weed_poslists(self):
|
||||
for poslist in [self.lkplist, self.evenlist, self.oddlist]:
|
||||
for poslist in [self.evenlist, self.oddlist]:
|
||||
for key, item in poslist.items():
|
||||
if time.time() - item[2] > 900:
|
||||
if time.time() - item[2] > 10:
|
||||
del poslist[key]
|
||||
|
||||
def decode(self, icao24, encoded_lat, encoded_lon, cpr_format, surface):
|
||||
@ -194,30 +193,14 @@ class cpr_decoder:
|
||||
|
||||
[decoded_lat, decoded_lon] = [None, None]
|
||||
|
||||
#okay, let's traverse the lists and weed out those entries that are older than 15 minutes, as they're unlikely to be useful.
|
||||
#okay, let's traverse the lists and weed out those entries that are older than 10 seconds
|
||||
self.weed_poslists()
|
||||
|
||||
if icao24 in self.lkplist:
|
||||
#do emitter-centered local decoding
|
||||
[decoded_lat, decoded_lon] = cpr_resolve_local(self.lkplist[icao24][0:2], [encoded_lat, encoded_lon], cpr_format, surface)
|
||||
self.lkplist[icao24] = [decoded_lat, decoded_lon, time.time()] #update the local position for next time
|
||||
|
||||
elif (icao24 in self.evenlist) \
|
||||
and (icao24 in self.oddlist) \
|
||||
and (abs(self.evenlist[icao24][2] - self.oddlist[icao24][2]) < 10) \
|
||||
and (surface == 0):
|
||||
if (icao24 in self.evenlist) \
|
||||
and (icao24 in self.oddlist):
|
||||
newer = (self.oddlist[icao24][2] - self.evenlist[icao24][2]) > 0 #figure out which report is newer
|
||||
[decoded_lat, decoded_lon] = cpr_resolve_global(self.evenlist[icao24][0:2], self.oddlist[icao24][0:2], newer, surface) #do a global decode
|
||||
self.lkplist[icao24] = [decoded_lat, decoded_lon, time.time()]
|
||||
|
||||
#so we really can't guarantee that local decoding will work unless you are POSITIVE that you can't hear more than 180nm out.
|
||||
#this will USUALLY work, but you can't guarantee it!
|
||||
#elif surface == 1 and self.my_location is not None:
|
||||
# [local_lat, local_lon] = cpr_resolve_local(self.my_location, [encoded_lat, encoded_lon], cpr_format, surface) #try local decoding
|
||||
# [rnge, bearing] = range_bearing(self.my_location, [local_lat, local_lon])
|
||||
# if rnge < validrange: #if the local decoding can be guaranteed valid
|
||||
# self.lkplist[icao24] = [local_lat, local_lon, time.time()] #update the local position for next time
|
||||
# [decoded_lat, decoded_lon] = [local_lat, local_lon]
|
||||
else:
|
||||
raise CPRNoPositionError
|
||||
|
||||
|
@ -69,7 +69,9 @@ class output_print(air_modes.parse):
|
||||
pass
|
||||
|
||||
def output(self, msg):
|
||||
print self.parse(msg)
|
||||
parsed = self.parse(msg)
|
||||
if parsed is not None:
|
||||
print self.parse(msg)
|
||||
|
||||
def print0(self, shortdata, ecc):
|
||||
[vs, cc, sl, ri, altitude] = self.parse0(shortdata)
|
||||
|
Loading…
Reference in New Issue
Block a user