tracker

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2020 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHistoryInterval - the default time between history
	// updates
	DefaultHistoryInterval = time.Second * 30
	// DefaultHistoryFileCount - the default number of history
	// files to keep
	DefaultHistoryFileCount = 60
)
View Source
const (
	// TrackTxTypes - track ADSB message types (only for BEAST messages)
	TrackTxTypes Feature = "track_tx_types"
	// TrackCallSigns - track current callsign and maintain history
	TrackCallSigns Feature = "track_callsigns"
	// TrackSquawks - track current squawk and maintain history
	TrackSquawks Feature = "track_squawks"
	// TrackKmlLocation - track location history for aircraft
	TrackKmlLocation Feature = "track_kml"
	// TrackTakeoff - (logs only) log when a takeoff begins/ends
	TrackTakeoff Feature = "track_takeoff"
	// GeocodeEndpoints - (logs only) geolocate the source + destination airport
	GeocodeEndpoints Feature = "geocode_endpoints"

	// MapProduced - the notification about a new map
	MapProduced EmailNotification = "map_produced"
	// SpottedInFlight - the notification about an aircraft spotted in air
	SpottedInFlight EmailNotification = "spotted_in_flight"
	// TakeoffFromAirport - the notification about an aircraft that just lifted off
	TakeoffFromAirport EmailNotification = "takeoff_from_airport"
	// TakeoffUnknownAirport - the notification about an aircraft that just lifted off from an unknown airport
	TakeoffUnknownAirport EmailNotification = "takeoff_unknown_airport"
	// TakeoffComplete - the notification about an aircraft that levels off after takeoff
	TakeoffComplete EmailNotification = "takeoff_complete"

	// DefaultSightingReopenInterval - default interval for sighting reopen behavior
	DefaultSightingReopenInterval = time.Minute * 5
)
View Source
const (

	// DefaultNearestAirportMaxAltitude - default max altitude (in ft)
	// for nearest airport
	DefaultNearestAirportMaxAltitude int64 = 1400
	// DefaultNearestAirportMaxDistance - default distance in meters
	// for nearest airport max distance
	DefaultNearestAirportMaxDistance float64 = 3000
	// DefaultOnGroundUpdateThreshold - default value for config option.
	// how many consecutive messages to receive before accepting a new on_ground status
	DefaultOnGroundUpdateThreshold int64 = 6
	// DefaultGeoHashLength - length of geohashes to use when bucketing
	// airlines by region
	DefaultGeoHashLength uint = 4

	// Dump1090MapService - name of the dump1090 map service
	Dump1090MapService = "dump1090"
	// Tar1090MapService - name of the tar1090 map service
	Tar1090MapService = "tar1090"
)
View Source
const (
	// DefaultAdsbxEndpoint - the default URL to use
	DefaultAdsbxEndpoint = "https://adsbexchange.com/api/aircraft/json/"
)

Variables

View Source
var (
	// DefaultMapServices contains the default list of map services to enable
	DefaultMapServices = []string{Dump1090MapService, Tar1090MapService}
)
View Source
var ErrUnknownProject = errors.New("unknown project")

ErrUnknownProject is returned by MapAccess.GetProjectAircraft

Functions

func AirlineCodeFromCallsign

func AirlineCodeFromCallsign(callSign string) (string, bool)

AirlineCodeFromCallsign attempts to extract an airline operator code from a callsign. The returned boolean indicates whether the result is valid. If true, the operator code will be returned

Types

type AdsbxAircraft

type AdsbxAircraft struct {
	PosTime      string `json:"postime"`
	Icao         string `json:"icao"`
	Registration string `json:"reg"`
	Type         string `json:"type"`
	Wtc          string `json:"wtc"`
	Spd          string `json:"spd"`
	Altt         string `json:"altt"`
	Alt          string `json:"alt"`
	Galt         string `json:"galt"`
	Talt         string `json:"talt"`
	Lat          string `json:"lat"`
	Lon          string `json:"lon"`
	Vsit         string `json:"vsit"`
	Vsi          string `json:"vsi"`
	Trkh         string `json:"trkh"`
	Ttrk         string `json:"ttrk"`
	Trak         string `json:"trak"`
	Sqk          string `json:"sqk"`
	Call         string `json:"call"`
	Ground       string `json:"gnd"`
	Trt          string `json:"trt"`
	Pos          string `json:"pos"`
	Mlat         string `json:"mlat"`
	Tisb         string `json:"tisb"`
	Sat          string `json:"sat"`
	Opicao       string `json:"opicao"`
	Country      string `json:"cou"`
}

AdsbxAircraft - structure of an aircraft object

type AdsbxAircraftResponse

type AdsbxAircraftResponse struct {
	Aircraft []AdsbxAircraft `json:"ac"`
	Msg      string          `json:"msg"`
	Total    int64           `json:"total"`
	CTime    int64           `json:"ctime"`
	PTime    int64           `json:"ptime"`
}

AdsbxAircraftResponse - structure containing list of aircraft and some general infomration

type AdsbxProducer

type AdsbxProducer struct {
	// contains filtered or unexported fields
}

AdsbxProducer - See Producer. This type is responsible for polling the ADSB Exchange API using the provided url and apikey. The JSON result is parsed and into messages which are written to the messages channel.

func NewAdsbxProducer

func NewAdsbxProducer(msgs chan *pb.Message, url string, apikey string) *AdsbxProducer

NewAdsbxProducer returns an AdsbxProducer.

func (*AdsbxProducer) GetAdsbx

func (p *AdsbxProducer) GetAdsbx(ctx context.Context, client *http.Client, msgs chan *pb.Message, source *pb.Source) error

GetAdsbx performs a HTTP request to ADSB Exchange and sends messages over the msgs channel.

func (*AdsbxProducer) Name

func (p *AdsbxProducer) Name() string

Name - returns the name for this producer. See Producer.Name()

func (*AdsbxProducer) PanicIfStuck

func (p *AdsbxProducer) PanicIfStuck(stop bool)

PanicIfStuck sets whether the producer should panic if a request takes more than 1 minute to be processed

func (*AdsbxProducer) Start

func (p *AdsbxProducer) Start()

Start starts the producer goroutine, and the readsb periodic update goroutine. See Producer.Start()

func (*AdsbxProducer) Stop

func (p *AdsbxProducer) Stop()

Stop sends the cancel signal to the producer goroutine and blocks until it finishes. See Producer.Stop()

type AircraftMap

type AircraftMap struct {
	// contains filtered or unexported fields
}

AircraftMap is the main service for receiving project+aircraft updates. Implements MapAccess.

func NewAircraftMap

func NewAircraftMap(cfg *config.MapSettings) (*AircraftMap, error)

NewAircraftMap initializes a new AircraftMap using configuration

func (*AircraftMap) GetProjectAircraft

func (m *AircraftMap) GetProjectAircraft(projectName string, f func(int64, []*JSONAircraft) error) error

GetProjectAircraft - Implements MapAccess.GetProjectAircraft.

func (*AircraftMap) RegisterMapService

func (m *AircraftMap) RegisterMapService(services ...MapService) error

RegisterMapService uses the MapService.RegisterRoutes to register each service's routes

func (*AircraftMap) Serve

func (m *AircraftMap) Serve()

Serve launches background services - aircraft Seen / SeenPos updates each second - triggers history updates on registered MapServices every m.historyInterval

func (*AircraftMap) Stop

func (m *AircraftMap) Stop() error

Stop sends the stop signal to coroutines and waits for them to finish

type BeastProducer

type BeastProducer struct {
	// contains filtered or unexported fields
}

BeastProducer - implements Producer. This type represents a connection to a beast server.

func NewBeastProducer

func NewBeastProducer(msgs chan *pb.Message, host string, port uint16, name string) *BeastProducer

NewBeastProducer initializes a new BeastProducer.

func (*BeastProducer) Name

func (p *BeastProducer) Name() string

Name - see Producer.Name()

func (*BeastProducer) Start

func (p *BeastProducer) Start()

Start - see Producer.Start() This function starts the producer goroutine, and the readsb periodic update goroutine.

func (*BeastProducer) Stop

func (p *BeastProducer) Stop()

Stop sends the cancel signal to the producer + trackPeriodicUpdate goroutines and blocks until they finish processing

type EmailNotification

type EmailNotification string

EmailNotification represents an email topic to which the project is subscribed.

func EmailNotificationFromString

func EmailNotificationFromString(n string) (EmailNotification, error)

EmailNotificationFromString parses the EmailNotification type from the provided string

type Feature

type Feature string

Feature represents a tracking capability to use in a project

func FeatureFromString

func FeatureFromString(f string) (Feature, error)

FeatureFromString parses the Feature type from the provided string

type FlightTime

type FlightTime struct {
	StartTime        time.Time
	StartTimeFmt     string
	EndTime          time.Time
	EndTimeFmt       string
	SightingDuration time.Duration
}

FlightTime contains calculated information about the flight time

type GeocodeLocation

type GeocodeLocation struct {
	// contains filtered or unexported fields
}

GeocodeLocation contains the result of a geocode search. If ok is false, the search was unsuccessful and the other fields are empty. If ok is true, the lat,long & address fields will be set.

type JSONAircraft

type JSONAircraft struct {
	sync.RWMutex

	// Hex: the 24-bit ICAO identifier of the aircraft, as 6 hex digits. The identifier may start with '~', this means that the address is a non-ICAO address (e.g. from TIS-B).
	Hex string `json:"hex"`
	// Type: type of underlying message, one of:
	// adsb_icao: messages from a Mode S or ADS-B transponder, using a 24-bit ICAO address
	// adsb_icao_nt: messages from an ADS-B equipped "non-transponder" emitter e.g. a ground vehicle, using a 24-bit ICAO address
	// adsr_icao: rebroadcast of ADS-B messages originally sent via another data link e.g. UAT, using a 24-bit ICAO address
	// tisb_icao: traffic information about a non-ADS-B target identified by a 24-bit ICAO address, e.g. a Mode S target tracked by secondary radar
	// adsb_other: messages from an ADS-B transponder using a non-ICAO address, e.g. anonymized address
	// adsr_other: rebroadcast of ADS-B messages originally sent via another data link e.g. UAT, using a non-ICAO address
	// tisb_other: traffic information about a non-ADS-B target using a non-ICAO address
	// tisb_trackfile: traffic information about a non-ADS-B target using a track/file identifier, typically from primary or Mode A/C radar
	Type string `json:"type,omitempty"`
	// Flight: callsign, the flight name or aircraft registration as 8 chars (2.2.8.2.6)
	Flight string `json:"flight,omitempty"`
	// BarometricAltitude: the aircraft barometric altitude in feet
	BarometricAltitude int64 `json:"alt_baro,omitempty"`
	// GeometricAltitude: geometric (GNSS / INS) altitude in feet referenced to the WGS84 ellipsoid
	GeometricAltitude int64 `json:"alt_geom,omitempty"`
	// GroundSpeed: ground speed in knots
	GroundSpeed float64 `json:"gs,omitempty"`
	// IndicatedAirSpeed: indicated air speed in knots
	IndicatedAirSpeed uint64 `json:"ias,omitempty"`
	// TrueAirSpeed: true air speed in knots
	TrueAirSpeed uint64 `json:"tas,omitempty"`
	// Mach: Mach number
	Mach float64 `json:"mach,omitempty"`
	// Track: true track over ground in degrees (0-359)
	Track float64 `json:"track,omitempty"`
	// TrackRate: Rate of change of track, degrees/second
	TrackRate float64 `json:"track_rate,omitempty"`
	// Roll: Roll, degrees, negative is left roll
	Roll float64 `json:"roll,omitempty"`
	// MagneticHeading: Heading, degrees clockwise from magnetic north
	MagneticHeading float64 `json:"mag_heading,omitempty"`
	// TrueHeading: Heading, degrees clockwise from true north
	TrueHeading float64 `json:"true_heading,omitempty"`
	// BarometricRate: Rate of change of barometric altitude, feet/minute
	BarometricRate int64 `json:"baro_rate,omitempty"`
	// GeometricRate: Rate of change of geometric (GNSS / INS) altitude, feet/minute
	GeometricRate int64 `json:"geom_rate,omitempty"`
	// Squawk: Mode A code (Squawk), encoded as 4 octal digits
	Squawk string `json:"squawk,omitempty"`
	// Emergency: ADS-B emergency/priority status, a superset of the 7x00 squawks (2.2.3.2.7.8.1.1)
	Emergency string `json:"emergency,omitempty"`
	// Category: emitter category to identify particular aircraft or vehicle classes (values A0 - D7) (2.2.3.2.5.2)
	Category string `json:"category,omitempty"`
	// NavQNH: altimeter setting (QFE or QNH/QNE), hPa
	NavQNH float64 `json:"nav_qnh,omitempty"`
	// NavAltitudeMCP: selected altitude from the Mode Control Panel / Flight Control Unit (MCP/FCU) or equivalent equipment
	NavAltitudeMCP int64 `json:"nav_altitude_mcp,omitempty"`
	// NavAltitudeFMS: selected altitude from the Flight Manaagement System (FMS) (2.2.3.2.7.1.3.3)
	NavAltitudeFMS int64 `json:"nav_altitude_fms,omitempty"`
	// NavHeading: selected heading (True or Magnetic is not defined in DO-260B, mostly Magnetic as that is the de facto standard) (2.2.3.2.7.1.3.7)
	NavHeading float64 `json:"nav_heading,omitempty"`
	// NavModes: set of engaged automation modes: 'autopilot', 'vnav', 'althold', 'approach', 'lnav', 'tcas'
	NavModes []string `json:"nav_modes,omitempty"`
	// Latitude: the aircraft position in decimal degrees
	Latitude float64 `json:"lat,omitempty"`
	// Longitude: the aircraft longitude in decimal degrees
	Longitude float64 `json:"lon,omitempty"`
	// Nic: Navigation Integrity Category (2.2.3.2.7.2.6)
	Nic string `json:"nic,omitempty"`
	// RadiusOfContainment: Radius of Containment, meters; a measure of position integrity derived from NIC & supplementary bits. (2.2.3.2.7.2.6, Table 2-69)
	RadiusOfContainment int64 `json:"rc,omitempty"`
	// SeenPos: how long ago (in seconds before "now") the position was last updated
	SeenPos float64 `json:"seen_pos,omitempty"`
	// Version: ADS-B Version Number 0, 1, 2 (3-7 are reserved) (2.2.3.2.7.5)
	Version int64 `json:"version,omitempty"`
	// NicBaro: Navigation Integrity Category for Barometric Altitude (2.2.5.1.35)
	NicBaro uint32 `json:"nic_baro,omitempty"`
	// NacP: Navigation Accuracy for Position (2.2.5.1.35)
	NacP uint32 `json:"nac_p,omitempty"`
	// NacV: Navigation Accuracy for Velocity (2.2.5.1.19)
	NacV uint32 `json:"nac_v,omitempty"`
	// Sil: Source Integity Level (2.2.5.1.40)
	Sil uint32 `json:"sil,omitempty"`
	// SilType: interpretation of SIL: unknown, perhour, persample
	SilType uint32 `json:"sil_type,omitempty"`
	// GVA: Geometric Vertical Accuracy  (2.2.3.2.7.2.8)
	GVA int64 `json:"gva,omitempty"`
	// SDA: System Design Assurance (2.2.3.2.7.2.4.6)
	SDA int64 `json:"sda,omitempty"`

	// Messages: total number of Mode S messages received from this aircraft
	Messages int64 `json:"messages"`
	// Seen: how long ago (in seconds before "now") a message was last received from this aircraft
	Seen int64 `json:"seen"`
	// Rssi: recent average RSSI (signal power), in dbFS; this will always be negative.
	Rssi float64 `json:"rssi"`
	// contains filtered or unexported fields
}

JSONAircraft is a dump1090 aircraft structure

func (*JSONAircraft) UpdateWithState

func (j *JSONAircraft) UpdateWithState(state *pb.State)

UpdateWithState updates JSONAircraft with the latest state

type MapAccess

type MapAccess interface {
	// GetProjectAircraft loads the subset of aircraft in
	// view for this project, and the current message count
	// and []*JSONAircraft is passed to the provided closure.
	// The aircraft are locked for the lifetime of the closure
	// and must be copied to be safely used elsewhere.
	GetProjectAircraft(projectName string, f func(int64, []*JSONAircraft) error) error
}

MapAccess provides access to the current map view

type MapHistoryUpdateScheduler

type MapHistoryUpdateScheduler interface {
	// UpdateHistory triggers the MapService to save
	// a new history file
	UpdateHistory(projects []string) error
}

MapHistoryUpdateScheduler defines an interface allowing AircraftMap trigger MapServices to save a new history file Used by AircraftMap

type MapProjectAircraftUpdateListener

type MapProjectAircraftUpdateListener struct {
	// contains filtered or unexported fields
}

MapProjectAircraftUpdateListener implements ProjectAircraftUpdateListener and dispatches notifications to the AircraftMap so they can be applied to the map.

func NewMapProjectAircraftUpdateListener

func NewMapProjectAircraftUpdateListener(m *AircraftMap) *MapProjectAircraftUpdateListener

NewMapProjectAircraftUpdateListener returns a new MapProjectAircraftUpdateListener

func (*MapProjectAircraftUpdateListener) LostAircraft

func (l *MapProjectAircraftUpdateListener) LostAircraft(p *Project, s *Sighting)

LostAircraft informs map about lost aircraft. Implements ProjectAircraftUpdateListener.LostAircraft

func (*MapProjectAircraftUpdateListener) NewAircraft

func (l *MapProjectAircraftUpdateListener) NewAircraft(p *Project, s *Sighting)

NewAircraft informs map about new aircraft. Implements ProjectAircraftUpdateListener.NewAircraft

func (*MapProjectAircraftUpdateListener) UpdatedAircraft

func (l *MapProjectAircraftUpdateListener) UpdatedAircraft(p *Project, s *Sighting)

UpdatedAircraft informs map about updated aircraft. Implements ProjectAircraftUpdateListener.UpdatedAircraft

type MapProjectStatusListener

type MapProjectStatusListener struct {
	// contains filtered or unexported fields
}

MapProjectStatusListener implements the ProjectStatusListener allowing tracker to notify us about new or closed projects

func NewMapProjectStatusListener

func NewMapProjectStatusListener(m *AircraftMap) *MapProjectStatusListener

NewMapProjectStatusListener creates a new *MapProjectStatusListener

func (*MapProjectStatusListener) Activated

func (p *MapProjectStatusListener) Activated(project *Project)

Activated - see ProjectStatusListener.Activated. This function informs the map about a new project to track.

func (*MapProjectStatusListener) Deactivated

func (p *MapProjectStatusListener) Deactivated(project *Project)

Deactivated - implements ProjectStatusListener.Activated. This function removes the data about this project from the map service.

type MapService

type MapService interface {
	// MapService returns the name of the backend
	MapService() string
	// RegisterRoutes allows the MapService to add
	// it's map related routes to the router
	RegisterRoutes(r *mux.Router) error
	// UpdateHistory is used to
	UpdateHistory(projNames []string) error
}

MapService is a contract for map backends.

type Options

type Options struct {
	Filter                    string
	Workers                   int
	SightingTimeout           time.Duration
	NearestAirportMaxDistance float64
	NearestAirportMaxAltitude int64

	OnGroundUpdateThreshold int64

	// LocationUpdateInterval is the system-wide default location update interval.
	// If a project has no LocationUpdateInterval configured, this value will be used.
	// By default, this is zero, so all location updates are accepted. It can be
	// configured with the Sightings.LocationUpdateInterval configuration option.
	LocationUpdateInterval time.Duration

	AirportGeocoder *geo.NearestAirportGeocoder
	Mailer          mailer.MailSender

	CountryCodes *iso3166.Store
	Allocations  ccode.CountryAllocationSearcher
	AircraftDb   *aircraftdb.Db
}

Options wraps options + interfaces for the Tracker type.

type Producer

type Producer interface {
	// Name for the producer
	Name() string
	// Start starts goroutines which poll or connect for messages and
	// writes them to the messages channel
	Start()
	// Stop sends the stop signal to the goroutines and waits for them
	// to finish.
	Stop()
}

Producer - this interface is exposed by Producer types. Such types are responsible for writing messages to the messages channel.

type Project

type Project struct {
	// Name of the project
	Name string
	// ShouldMap indicates whether the map should be built for this project
	ShouldMap bool
	// Project - the db record for this project
	Project *db.Project
	// Session - the db record for the project session
	Session *db.Session
	// Filter - a CEL expression for filtering aircraft (can be empty)
	Filter string
	// Program - a parsed CEL expression to evaluate later
	Program cel.Program
	// Features is the list of tracking features enabled in this project
	Features []Feature
	// NotifyEmail - the destination for email notifications
	NotifyEmail string
	// EmailNotifications - list of topics the project is subscribed to
	EmailNotifications []EmailNotification

	// ReopenSightings - whether to reopen a sighting if it was seen within `ReopenSightingsInterval`
	ReopenSightings bool
	// ReopenSightingsInterval is a duration within which a previously closed sighting can
	// be reopened
	ReopenSightingsInterval time.Duration
	// OnGroundUpdateThreshold - how many consecutive messages we receive with a new on_ground
	// flag before we accept it
	OnGroundUpdateThreshold int64

	// LocationUpdateInterval is used to set a minimum time between location updates.
	LocationUpdateInterval time.Duration
	// HasLocationUpdateInterval should be set to true if a custom LocationUpdateInterval
	// is set on the project. If this is false, the system-wide default is used.
	HasLocationUpdateInterval bool

	// Observations is a map of aircraft ICAO to it's state
	Observations map[string]*ProjectObservation
	// contains filtered or unexported fields
}

Project represents an active tracking project

func InitProject

func InitProject(cfg config.Project) (*Project, error)

InitProject initializes a project from its configuration or an error upon failure.

func (*Project) IsEmailNotificationEnabled

func (p *Project) IsEmailNotificationEnabled(n EmailNotification) bool

IsEmailNotificationEnabled returns whether the project has EmailNotification n enabled

func (*Project) IsFeatureEnabled

func (p *Project) IsFeatureEnabled(f Feature) bool

IsFeatureEnabled returns whether the project has Feature f enabled

type ProjectAircraftUpdateListener

type ProjectAircraftUpdateListener interface {
	// NewAircraft informs listener a new sighting was opened for a project
	NewAircraft(p *Project, s *Sighting)
	// UpdatedAircraft informs listener about an updated aircraft for a project
	UpdatedAircraft(p *Project, s *Sighting)
	// LostAircraft informs listener about a sighting which has closed for a project
	LostAircraft(p *Project, s *Sighting)
}

ProjectAircraftUpdateListener - this interface is used to communicate information about a projects aircraft sightings

type ProjectObservation

type ProjectObservation struct {
	// contains filtered or unexported fields
}

ProjectObservation contains information about a sighting from the point of view of a particular project.

func NewProjectObservation

func NewProjectObservation(p *Project, s *Sighting, msgTime time.Time) *ProjectObservation

NewProjectObservation initializes a ProjectObservation structure for this sighting & project pair

func (*ProjectObservation) AltitudeBarometric

func (o *ProjectObservation) AltitudeBarometric() int64

AltitudeBarometric returns the current barometric altitude

func (*ProjectObservation) AltitudeGeometric

func (o *ProjectObservation) AltitudeGeometric() int64

AltitudeGeometric returns the current barometric altitude

func (*ProjectObservation) CallSign

func (o *ProjectObservation) CallSign() string

CallSign returns the current callsign, or an empty string if unknown

func (*ProjectObservation) GetFlightTime

func (o *ProjectObservation) GetFlightTime() FlightTime

GetFlightTime creates a FlightTime structure containing calculated time information for the flight

func (*ProjectObservation) HaveAltitudeBarometric

func (o *ProjectObservation) HaveAltitudeBarometric() bool

HaveAltitudeBarometric returns true if the current barometric altitude is known

func (*ProjectObservation) HaveAltitudeGeometric

func (o *ProjectObservation) HaveAltitudeGeometric() bool

HaveAltitudeGeometric returns true if the current barometric altitude is known

func (*ProjectObservation) HaveCallSign

func (o *ProjectObservation) HaveCallSign() bool

HaveCallSign - returns true if the ProjectObservation has a current callsign set

func (*ProjectObservation) HaveLocation

func (o *ProjectObservation) HaveLocation() bool

HaveLocation returns true if the current location is known

func (*ProjectObservation) HaveSquawk

func (o *ProjectObservation) HaveSquawk() bool

HaveSquawk - returns true if the ProjectObservation has a current squawk set

func (*ProjectObservation) Location

func (o *ProjectObservation) Location() (float64, float64)

Location returns the current position

func (*ProjectObservation) SetAltitudeBarometric

func (o *ProjectObservation) SetAltitudeBarometric(alt int64) error

SetAltitudeBarometric updates the current barmetric altitude

func (*ProjectObservation) SetAltitudeGeometric

func (o *ProjectObservation) SetAltitudeGeometric(alt int64) error

SetAltitudeGeometric updates the current barmetric altitude

func (*ProjectObservation) SetCallSign

func (o *ProjectObservation) SetCallSign(callsign string, track bool, msgTime time.Time) error

SetCallSign updates the current callsign for the sighting, and if track is true, creates a callsign log to be written to the database.

func (*ProjectObservation) SetLocation

func (o *ProjectObservation) SetLocation(lat, lon float64, track bool, msgTime time.Time) error

SetLocation updates the current location for the sighting, and if track is true, creates a location log to be written to the database.

func (*ProjectObservation) SetSquawk

func (o *ProjectObservation) SetSquawk(squawk string, track bool, msgTime time.Time) error

SetSquawk updates the current squawk for the sighting, and if track is true, creates a squawk log to be written to the database.

func (*ProjectObservation) Squawk

func (o *ProjectObservation) Squawk() string

Squawk returns the current squawk, or an empty string if unknown

type ProjectStatusListener

type ProjectStatusListener interface {
	// Activate informs listener a new project was activated
	Activated(project *Project)
	// Deactivated informs listener a project was deactivated
	Deactivated(project *Project)
}

ProjectStatusListener - this interface is used to communicate status changes about a project

type Sighting

type Sighting struct {
	// State represents everything we know about the aircraft. It
	// is one of the structs filters operate on.
	State pb.State
	// Tags contains some meta information about the sighting.
	Tags SightingTags
	// contains filtered or unexported fields
}

Sighting represents an aircraft we are receiving messages about

func NewSighting

func NewSighting(icao string, now time.Time) *Sighting

NewSighting initializes a new sighting for aircraft with this ICAO

type SightingTags

type SightingTags struct {
	// IsInTakeoff - this is set to true if we observe the aircraft
	// transitioning from on_ground=true to on_ground=false.
	IsInTakeoff bool
}

SightingTags contains some meta information about the flight.

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker - this type is responsible for processing received messages and tracking aircraft

func New

func New(database db.Database, opt Options) (*Tracker, error)

New initializes a new Tracker, or an error if one occurs

func (*Tracker) AddProject

func (t *Tracker) AddProject(p *Project) error

AddProject accepts a new project and adds it to the tracker. Sends Activated event to ProjectStatusListeners

func (*Tracker) ProcessMessage

func (t *Tracker) ProcessMessage(project *Project, s *Sighting, now time.Time, msg *pb.Message) error

ProcessMessage is called to process the updated Sighting in the context of the provided project.

func (*Tracker) RegisterProjectAircraftUpdateListener

func (t *Tracker) RegisterProjectAircraftUpdateListener(l ProjectAircraftUpdateListener) error

RegisterProjectAircraftUpdateListener - accepts a new ProjectAircraftUpdateListener to use for aircraft updates

func (*Tracker) RegisterProjectStatusListener

func (t *Tracker) RegisterProjectStatusListener(l ProjectStatusListener) error

RegisterProjectStatusListener - accepts a new ProjectStatusListener to use for project status updates

func (*Tracker) Start

func (t *Tracker) Start(msgs chan *pb.Message)

Start takes the messages channel and launches consumer goroutines. It also starts the lost aircraft + database update goroutines.

func (*Tracker) Stop

func (t *Tracker) Stop() error

Stop begins the shutdown routine by signalling stop to goroutines, flushes state to disk, and closes open sightings cleanly.

func (*Tracker) UpdateStateFromMessage

func (t *Tracker) UpdateStateFromMessage(s *Sighting, msg *pb.Message, now time.Time) error

UpdateStateFromMessage takes msg and applies new or updated data to the sighting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL