Documentation
¶
Overview ¶
Package radar implements mid-level logic for Ground-Controlled Interception (GCI).
Index ¶
- type FadedCallback
- type Radar
- func (r *Radar) Bullseye(coalition coalitions.Coalition) orb.Point
- func (r *Radar) Declination(p orb.Point) unit.Angle
- func (r *Radar) FindByCoalition(coalition coalitions.Coalition) []*trackfiles.Trackfile
- func (r *Radar) FindCallsign(callsign string, coalition coalitions.Coalition) (string, *trackfiles.Trackfile)
- func (r *Radar) FindNearbyGroupsWithBRAA(origin, interest orb.Point, minAltitude, maxAltitude, radius unit.Length, ...) []brevity.Group
- func (r *Radar) FindNearbyGroupsWithBullseye(interest orb.Point, minAltitude, maxAltitude, radius unit.Length, ...) []brevity.Group
- func (r *Radar) FindNearestGroupInSector(origin orb.Point, minAltitude, maxAltitude, length unit.Length, ...) brevity.Group
- func (r *Radar) FindNearestGroupWithBRAA(origin orb.Point, minAltitude unit.Length, maxAltitude unit.Length, ...) brevity.Group
- func (r *Radar) FindNearestGroupWithBullseye(origin orb.Point, minAltitude, maxAltitude, radius unit.Length, ...) brevity.Group
- func (r *Radar) FindNearestTrackfile(origin orb.Point, minAltitude unit.Length, maxAltitude unit.Length, ...) *trackfiles.Trackfile
- func (r *Radar) FindUnit(id uint64) *trackfiles.Trackfile
- func (r *Radar) Merges(coalition coalitions.Coalition) map[brevity.Group][]*trackfiles.Trackfile
- func (r *Radar) Picture(radius unit.Length, coalition coalitions.Coalition, ...) (int, []brevity.Group)
- func (r *Radar) Projection() projections.Projection
- func (r *Radar) Run(ctx context.Context, wg *sync.WaitGroup)
- func (r *Radar) SetBullseye(bullseye orb.Point, coalition coalitions.Coalition)
- func (r *Radar) SetFadedCallback(callback FadedCallback)
- func (r *Radar) SetMissionTime(t time.Time)
- func (r *Radar) SetRemovedCallback(callback RemovedCallback)
- func (r *Radar) SetStartedCallback(callback StartedCallback)
- func (r *Radar) Threats(coalition coalitions.Coalition) map[brevity.Group][]uint64
- func (r *Radar) WaitUntilFadesResolve(ctx context.Context)
- type RemovedCallback
- type StartedCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FadedCallback ¶
FadedCallback is a callback function that is called when a group has not been updated by sensors for a timeout period. The group and its coalition are provided.
type Radar ¶
type Radar struct {
// contains filtered or unexported fields
}
Radar consumes updates from the simulation, keeps track of each aircraft as a trackfile, and provides functions to collect the aircraft into groups.
func New ¶
func New(coalition coalitions.Coalition, starts <-chan sim.Started, updates <-chan sim.Updated, fades <-chan sim.Faded, mandatoryThreatRadius unit.Length, enableTerrainDetection bool) *Radar
New creates a radar scope that consumes updates from the provided channels. When enableTerrainDetection is true, SetBullseye will detect the closest DCS terrain and use its Transverse Mercator projection for spatial calculations. When false, spherical Earth calculations are used.
func (*Radar) Bullseye ¶
func (r *Radar) Bullseye(coalition coalitions.Coalition) orb.Point
Bullseye returns the bullseye point for the given coalition.
func (*Radar) Declination ¶
Declination returns the magnetic declination at the given point, at the time provided in SetMissionTime.
func (*Radar) FindByCoalition ¶ added in v1.3.0
func (r *Radar) FindByCoalition(coalition coalitions.Coalition) []*trackfiles.Trackfile
FindByCoalition returns all trackfiles on the given coalition.
func (*Radar) FindCallsign ¶
func (r *Radar) FindCallsign(callsign string, coalition coalitions.Coalition) (string, *trackfiles.Trackfile)
FindCallsign returns the trackfile on the given coalition that mosty closely matches the given callsign, or nil if no closely matching trackfile was found. The first return value is the callsign of the trackfile, and the second is the trackfile itself. The returned callsign may differ from the input callsign!
func (*Radar) FindNearbyGroupsWithBRAA ¶
func (r *Radar) FindNearbyGroupsWithBRAA(origin, interest orb.Point, minAltitude, maxAltitude, radius unit.Length, coalition coalitions.Coalition, filter brevity.ContactCategory, excludedIDs []uint64) []brevity.Group
FindNearbyGroupsWithBRAA returns all groups within the given radius of the given point of interest, within the given altitude block, filtered by the given coalition and contact category. Any given unit IDs are excluded from the search. Each group has BRAA set relative to the given origin. The groups are ordered by increasing distance from the point of interest.
func (*Radar) FindNearbyGroupsWithBullseye ¶
func (r *Radar) FindNearbyGroupsWithBullseye(interest orb.Point, minAltitude, maxAltitude, radius unit.Length, coalition coalitions.Coalition, filter brevity.ContactCategory, excludedIDs []uint64) []brevity.Group
FindNearbyGroupsWithBullseye returns all groups within the given radius of the given point of interest, within the given altitude block, filtered by the given coalition and contact category. Any given unit IDs are excluded from the search. Each group has Bullseye set relative to the point provided in SetBullseye. The groups are ordered by increasing distance from the point of interest.
func (*Radar) FindNearestGroupInSector ¶
func (r *Radar) FindNearestGroupInSector(origin orb.Point, minAltitude, maxAltitude, length unit.Length, bearing bearings.Bearing, arc unit.Angle, coalition coalitions.Coalition, filter brevity.ContactCategory) brevity.Group
FindNearestGroupInSector returns the nearest group to the given origin within a 2D sector defined by the given origin, length, bearing and arc, within the given altitude block, filtered by the given coalition and contact category. The group has BRAA set relative to the given origin. Returns nil if no group was found.
func (*Radar) FindNearestGroupWithBRAA ¶
func (r *Radar) FindNearestGroupWithBRAA( origin orb.Point, minAltitude unit.Length, maxAltitude unit.Length, radius unit.Length, coalition coalitions.Coalition, filter brevity.ContactCategory, ) brevity.Group
FindNearestGroupWithBRAA returns the nearest group to the given origin (up to the given radius), within the given altitude block, filtered by the given coalition and contact category. The group has BRAA set relative to the given origin. Returns nil if no group was found.
func (*Radar) FindNearestGroupWithBullseye ¶
func (r *Radar) FindNearestGroupWithBullseye(origin orb.Point, minAltitude, maxAltitude, radius unit.Length, coalition coalitions.Coalition, filter brevity.ContactCategory) brevity.Group
FindNearestGroupWithBullseye returns the nearest group to the given origin (up to the given distance), within a 2D circular sector defined by the given origin ,radius, bearing and arc, within the given altitude block, filtered by the given coalition and contact category. The group has BRAA set relative to the given origin. Returns nil if no group was found.
func (*Radar) FindNearestTrackfile ¶ added in v0.13.4
func (r *Radar) FindNearestTrackfile( origin orb.Point, minAltitude unit.Length, maxAltitude unit.Length, radius unit.Length, coalition coalitions.Coalition, filter brevity.ContactCategory, ) *trackfiles.Trackfile
FindNearestTrackfile returns the nearest trackfile to the given origin (up to the given radius), within the given altitude block, filtered by the given coalition and contact category. Returns nil if no trackfile was found.
func (*Radar) FindUnit ¶
func (r *Radar) FindUnit(id uint64) *trackfiles.Trackfile
FindUnit returns the trackfile for the given unit ID, or nil if no trackfile was found.
func (*Radar) Merges ¶ added in v0.4.0
func (r *Radar) Merges(coalition coalitions.Coalition) map[brevity.Group][]*trackfiles.Trackfile
Merges returns a map of hostile groups of the given coalition to friendly trackfiles.
func (*Radar) Picture ¶ added in v0.14.0
func (r *Radar) Picture(radius unit.Length, coalition coalitions.Coalition, filter brevity.ContactCategory) (int, []brevity.Group)
Picture returns a picture of the radar scope anchored at the center point, within the given radius, filtered by the given coalition and contact category. The first return value is the total number of groups and the second is a slice of up to 3 high priority groups. Each group has Bullseye set relative to the point provided in SetBullseye.
func (*Radar) Projection ¶ added in v1.8.0
func (r *Radar) Projection() projections.Projection
Projection returns the current Transverse Mercator projection. This projection should be used for distance and bearing calculations to improve accuracy at extreme latitudes. Returns nil if terrain detection is disabled or no projection has been set. Callers should handle a nil return by falling back to spherical Earth calculations.
func (*Radar) Run ¶
Run consumes updates from the simulation channels until the context is cancelled.
func (*Radar) SetBullseye ¶
func (r *Radar) SetBullseye(bullseye orb.Point, coalition coalitions.Coalition)
SetBullseye updates the bullseye point for the given coalition. The bullseye point is the reference point for polar coordinates provided in [Group.Bullseye]. When terrain detection is enabled, this also detects the closest DCS terrain and updates the Transverse Mercator projection used for spatial calculations.
func (*Radar) SetFadedCallback ¶
func (r *Radar) SetFadedCallback(callback FadedCallback)
SetFadedCallback sets the callback function to be called when a trackfile fades.
func (*Radar) SetMissionTime ¶
SetMissionTime updates the mission time. The mission time is used for computing magnetic declination.
func (*Radar) SetRemovedCallback ¶ added in v0.4.0
func (r *Radar) SetRemovedCallback(callback RemovedCallback)
SetRemovedCallback sets the callback function that is called when a trackfile is removed.
func (*Radar) SetStartedCallback ¶ added in v0.6.2
func (r *Radar) SetStartedCallback(callback StartedCallback)
SetStartedCallback sets the callback function that is called when a new mission is started.
func (*Radar) Threats ¶
Threats returns a map of threat groups of the given coalition to threatened object IDs.
func (*Radar) WaitUntilFadesResolve ¶ added in v0.8.1
WaitUntilFadesResolve blocks until all fade events have been processed, or the context is cancelled.
type RemovedCallback ¶ added in v0.4.0
type RemovedCallback func(trackfile *trackfiles.Trackfile)
RemovedCallback is a callback function that is called when a trackfile is aged out and removed. A copy of the trackfile is provided.
type StartedCallback ¶ added in v0.6.2
type StartedCallback func()
StartedCallback is a callback function that is called when a new mission is started.