Tracking lifecycle
This document describes the sequence of events that take place while an aircraft is tracked.
New and updated sightings
Airtrack maintains basic information in memory about all aircraft it receives messages about. This is required as filters need up to date information to perform their function.
This section mostly involves maintaining this information.
When a message is received from an aircraft which was not in view before the following steps are taken:
-
Create an in-memory
Sightingobject referencing the aircrafts hex ICAO. This object is in memory, and contains aStateproto message, and a list ofProjectObservationsfor each project following this aircraft. TheProjectObservationstructure contains per-project information about the sighting. -
Update the aircraft
Stateobject with information from the current message. This means that airtrack contains some minimal information about every aircraft in view. However, information is stored only if there is at least one project following the aircraft.
Project tracking
Airtrack has the project concept to help organize aircraft tracking. We might have multiple projects because we are interested in different things, or want some behaviours enabled for certain aircraft but not others.
A project may define a filter to focus it’s tracking to certain aircraft.
If a filter is set, it will be evaluated. If the expression returns true, the project will begin to track - or continue to track - the
aircraft (otherwise, the message will be ignored).
If no project filter is set, the project will track every aircraft.
This section describes the action taken by a project with no filter, or a project whose filter evaluated
to true.
-
Ensure the
Sightingobject contains theaircraftdatabase record. If it’s not set yet (the first time a project has worked on thisSighting), we search for theaircraftby it’s hex ICAO, or insert theaircraftrecord if it didn’t exist. -
If the
Sightingobject doesn’t have aProjectObservationfor our project yet (the first time this project has worked on thisSighting), we create asightingrecord in the database associating our project with theaircraftrecord. Thesightingrecord is attached to theProjectObservationallowing the project to associate tracking information with it’ssightingin the database. This is referred to opening a sighting. -
Compare our
ProjectObservationcopy of data with theStateobject, to see if any data has been changed. In this phase, we check for enabled features, and save any relevant flight information to our database. It can also result in some event notifications being triggered. If so, and the project has subscribed to these events, an email job is created and queued for delivery. Documentation for eachfeaturecan be found here, and documentation forevent_notificationscan be found here
Closing a sighting
The tracker looks for aircraft which haven’t sent any messages for a configurable timeout.
This may be due to bad ADS-B coverage, or because the aircraft has landed and powered off. The
resulting action (invoking handleLostAircraft) is also triggered when the software receives the
shutdown signal.
Every 5 seconds, airtrack will inspect each Sighting and it’s ProjectObservation list.
If the Sighting has some subscribed projects, we check if sighting_timeout has elapsed since
the ProjectObservation last message time for each project. If so, the projects sighting will
be closed, invoking handleLostAircraft.
If there are no subscribed projects, we check if sighting_timeout has elapsed since the
Sighting last message time. If so, they are deleted from the internal Sighting map.