NUCp tracking and CPR position sanity checks.

Track NUCp when we compute positions.

Do speed checks when we have an updated position with the same or worse NUCp
before accepting the new position. Don't do speed checks on new postions if
they improve NUCp - assume that the new position is better.

Include NUCp in aircraft.json

Gather stats on reasons for rejecting CPR data due to range/speed check failures.

Expire old positions if we have had no updates for 60 seconds.

Closes #16, closes #17.
This commit is contained in:
Oliver Jowett 2015-02-18 00:12:35 +00:00
parent 38845c2447
commit bfe2cb0336
6 changed files with 164 additions and 42 deletions

13
track.h
View file

@ -56,6 +56,9 @@
/* Maximum age of a tracked aircraft with only 1 message received, in milliseconds */
#define TRACK_AIRCRAFT_ONEHIT_TTL 60000
/* Maximum validity of an aircraft position */
#define TRACK_AIRCRAFT_POSITION_TTL 60000
/* Structure used to describe the state of one tracked aircraft */
struct aircraft {
uint32_t addr; // ICAO address
@ -79,13 +82,19 @@ struct aircraft {
uint64_t fatsv_last_emitted; // time (millis) aircraft was last FA emitted
// Encoded latitude and longitude as extracted by odd and even CPR encoded messages
uint64_t odd_cprtime;
int odd_cprlat;
int odd_cprlon;
unsigned odd_cprnuc;
uint64_t even_cprtime;
int even_cprlat;
int even_cprlon;
uint64_t odd_cprtime;
uint64_t even_cprtime;
unsigned even_cprnuc;
double lat, lon; // Coordinated obtained from CPR encoded data
unsigned pos_nuc; // NUCp of last computed position
int bFlags; // Flags related to valid fields in this structure
struct aircraft *next; // Next aircraft in our linked list