sim

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LaunchAutomatic int32 = iota
	LaunchManual
)
View Source
const UnsetSTARSListIndex = 0

Variables

View Source
var (
	ErrAircraftAlreadyReleased         = errors.New("Aircraft already released")
	ErrATPADisabled                    = errors.New("ATPA is disabled system-wide")
	ErrBeaconMismatch                  = errors.New("Beacon code mismatch")
	ErrControllerAlreadySignedIn       = errors.New("Controller with that callsign already signed in")
	ErrDuplicateACID                   = errors.New("Duplicate ACID")
	ErrDuplicateBeacon                 = errors.New("Duplicate beacon code")
	ErrIllegalACID                     = errors.New("Illegal ACID")
	ErrIllegalACType                   = errors.New("Illegal aircraft type")
	ErrIllegalBeaconCode               = errors.New("Illegal beacon code")
	ErrIllegalFunction                 = errors.New("Illegal function")
	ErrIllegalScratchpad               = errors.New("Illegal scratchpad")
	ErrInvalidAbbreviatedFP            = errors.New("Invalid abbreviated flight plan")
	ErrInvalidDepartureController      = errors.New("Invalid departure controller")
	ErrInvalidRestrictionAreaIndex     = errors.New("Invalid restriction area index")
	ErrInvalidVolumeId                 = errors.New("Invalid ATPA volume ID")
	ErrNoMatchingFlight                = errors.New("No matching flight")
	ErrNoMatchingFlightPlan            = errors.New("No matching flight plan")
	ErrNoVFRAircraftForFlightFollowing = errors.New("No VFR aircraft available for flight following")
	ErrNotLaunchController             = errors.New("Not signed in as the launch controller")
	ErrTCPAlreadyConsolidated          = errors.New("TCP already consolidated - deconsolidate first")
	ErrTCPNotConsolidated              = errors.New("TCP is not consolidated")
	ErrTCWIsConsolidated               = errors.New("receiving TCW is a consolidated position")
	ErrTCWNotFound                     = errors.New("TCW not found")
	ErrTCWNotVacant                    = errors.New("receiving TCW has an associated TCP")
	ErrTooManyRestrictionAreas         = errors.New("Too many restriction areas specified")
	ErrTrackIsActive                   = errors.New("Track is already active")
	ErrTrackIsBeingHandedOff           = errors.New("Track is currently being handed off")
	ErrTrackIsNotActive                = errors.New("Track is not active")
	ErrUnknownAircraftType             = errors.New("Unknown aircraft type")
	ErrUnknownController               = errors.New("Unknown controller")
	ErrUnknownControllerFacility       = errors.New("Unknown controller facility")
	ErrVFRSimTookTooLong               = errors.New("VFR simulation took too long")
	ErrViolatedAirspace                = errors.New("Violated B/C airspace")
	ErrVolumeDisabled                  = errors.New("ATPA volume is disabled")
	ErrVolumeNot25nm                   = errors.New("ATPA volume not adapted for 2.5nm separation")
)
View Source
var ErrInvalidCommandSyntax = fmt.Errorf("invalid command syntax")

Functions

func CheckVideoMapManifest

func CheckVideoMapManifest(filename string, e *util.ErrorLogger)

func IsValidACID

func IsValidACID(acid string) bool

func PlausibleFinalAltitude

func PlausibleFinalAltitude(fp av.FlightPlan, perf av.AircraftPerformance, nmPerLongitude float32, magneticVariation float32,
	r *rand.Rand) int

func PrintVideoMaps

func PrintVideoMaps(path string, e *util.ErrorLogger)

Types

type ACID

type ACID string

type ATPAConfigOp added in v0.13.3

type ATPAConfigOp int
const (
	ATPAEnable ATPAConfigOp = iota
	ATPADisable
	ATPAEnableVolume
	ATPADisableVolume
	ATPAEnableReduced25
	ATPADisableReduced25
)

type ATPAVolumeState added in v0.13.3

type ATPAVolumeState struct {
	Disabled          bool
	Reduced25Disabled bool
}

type Aircraft

type Aircraft struct {
	// This is ADS-B callsign of the aircraft. Just because different the
	// callsign in the flight plan can be different across multiple STARS
	// facilities, so two different facilities can show different
	// callsigns; however, the ADS-B callsign is transmitted from the
	// aircraft and would be the same to all facilities.
	ADSBCallsign av.ADSBCallsign

	Squawk av.Squawk
	Mode   av.TransponderMode

	IdentStartTime, IdentEndTime time.Time

	FlightPlan   av.FlightPlan
	TypeOfFlight av.TypeOfFlight
	// For departures, after we first see them in the departure acquisition
	// volume, we set a time a bit in the future for the flight plan to
	// actually acquire to simulate the delay in that.
	DepartureFPAcquisitionTime time.Time

	Strip av.FlightStrip

	// State related to navigation.
	Nav nav.Nav

	// Arrival-related state
	STAR                string
	STARRunwayWaypoints map[string]av.WaypointArray
	GotContactTower     bool

	NASFlightPlan *NASFlightPlan

	HoldForRelease    bool
	Released          bool // only used for hold for release
	ReleaseTime       time.Time
	WaitingForLaunch  bool // for departures
	MissingFlightPlan bool

	GoAroundDistance *float32

	// Departure related state
	DepartureContactAltitude float32

	// The controller who gave approach clearance
	ApproachTCP TCP

	// Who had control when the fp disassociated due to an arrival filter.
	PreArrivalDropTCP TCP

	FirstSeen time.Time

	RequestedFlightFollowing bool
	// WaitingForGoAhead is set when a VFR aircraft has made an abbreviated
	// flight following request ("approach, N123AB, VFR request") and is
	// waiting for the controller to say "go ahead".
	WaitingForGoAhead bool

	EmergencyState *EmergencyState

	LastRadioTransmission time.Time
}

func (*Aircraft) ATPAVolume

func (ac *Aircraft) ATPAVolume() *av.ATPAVolume

func (*Aircraft) AircraftPerformance

func (ac *Aircraft) AircraftPerformance() av.AircraftPerformance

func (*Aircraft) Altitude

func (ac *Aircraft) Altitude() float32

func (*Aircraft) AltitudeOurDiscretion

func (ac *Aircraft) AltitudeOurDiscretion() *av.RadioTransmission

func (*Aircraft) ArrivalAirportElevation

func (ac *Aircraft) ArrivalAirportElevation() float32

func (*Aircraft) ArrivalAirportLocation

func (ac *Aircraft) ArrivalAirportLocation() math.Point2LL

func (*Aircraft) AssignAltitude

func (ac *Aircraft) AssignAltitude(altitude int, afterSpeed bool) *av.RadioTransmission

func (*Aircraft) AssignHeading

func (ac *Aircraft) AssignHeading(heading int, turn nav.TurnMethod) *av.RadioTransmission

func (*Aircraft) AssignSpeed

func (ac *Aircraft) AssignSpeed(speed int, afterAltitude bool) *av.RadioTransmission

func (*Aircraft) AssociateFlightPlan

func (ac *Aircraft) AssociateFlightPlan(fp *NASFlightPlan)

func (*Aircraft) AtFixCleared

func (ac *Aircraft) AtFixCleared(fix, approach string) *av.RadioTransmission

func (*Aircraft) CWT

func (ac *Aircraft) CWT() string

func (*Aircraft) CancelApproachClearance

func (ac *Aircraft) CancelApproachClearance() *av.RadioTransmission

func (*Aircraft) Check

func (ac *Aircraft) Check(lg *log.Logger)

func (*Aircraft) ClearedApproach

func (ac *Aircraft) ClearedApproach(id string, lg *log.Logger) (*av.RadioTransmission, error)

func (*Aircraft) ClearedStraightInApproach

func (ac *Aircraft) ClearedStraightInApproach(id string, lg *log.Logger) (*av.RadioTransmission, error)

func (*Aircraft) ClimbViaSID

func (ac *Aircraft) ClimbViaSID() *av.RadioTransmission

func (*Aircraft) ContactMessage

func (ac *Aircraft) ContactMessage(reportingPoints []av.ReportingPoint) *av.RadioTransmission

func (*Aircraft) ContactTower

func (ac *Aircraft) ContactTower(lg *log.Logger) *av.RadioTransmission

func (*Aircraft) CrossFixAt

func (ac *Aircraft) CrossFixAt(fix string, ar *av.AltitudeRestriction, speed int) *av.RadioTransmission

func (*Aircraft) DepartFixDirect

func (ac *Aircraft) DepartFixDirect(fixa, fixb string) *av.RadioTransmission

func (*Aircraft) DepartFixHeading

func (ac *Aircraft) DepartFixHeading(fix string, hdg int) *av.RadioTransmission

func (*Aircraft) DepartOnCourse

func (ac *Aircraft) DepartOnCourse(lg *log.Logger)

func (*Aircraft) DepartureAirportElevation

func (ac *Aircraft) DepartureAirportElevation() float32

func (*Aircraft) DepartureAirportLocation

func (ac *Aircraft) DepartureAirportLocation() math.Point2LL

func (*Aircraft) DescendViaSTAR

func (ac *Aircraft) DescendViaSTAR() *av.RadioTransmission

func (*Aircraft) DirectFix

func (ac *Aircraft) DirectFix(fix string) *av.RadioTransmission

func (*Aircraft) DisassociateFlightPlan

func (ac *Aircraft) DisassociateFlightPlan() *NASFlightPlan

func (*Aircraft) DistanceAlongRoute

func (ac *Aircraft) DistanceAlongRoute(fix string) (float32, error)

func (*Aircraft) DistanceToEndOfApproach

func (ac *Aircraft) DistanceToEndOfApproach() (float32, error)

func (*Aircraft) DivertToAirport added in v0.13.2

func (ac *Aircraft) DivertToAirport(ap string)

func (*Aircraft) ExpectApproach

func (ac *Aircraft) ExpectApproach(id string, ap *av.Airport, lg *log.Logger) *av.RadioTransmission

func (*Aircraft) ExpediteClimb

func (ac *Aircraft) ExpediteClimb() *av.RadioTransmission

func (*Aircraft) ExpediteDescent

func (ac *Aircraft) ExpediteDescent() *av.RadioTransmission

func (*Aircraft) FlyPresentHeading

func (ac *Aircraft) FlyPresentHeading() *av.RadioTransmission

func (*Aircraft) GS

func (ac *Aircraft) GS() float32

func (*Aircraft) GetRadarTrack

func (ac *Aircraft) GetRadarTrack(now time.Time) av.RadarTrack

func (*Aircraft) GoAround

func (ac *Aircraft) GoAround() *av.RadioTransmission

func (*Aircraft) Heading

func (ac *Aircraft) Heading() float32

func (*Aircraft) HoldAtFix added in v0.13.0

func (ac *Aircraft) HoldAtFix(fix string, hold *av.Hold) *av.RadioTransmission

func (*Aircraft) IAS

func (ac *Aircraft) IAS() float32

func (*Aircraft) Ident

func (ac *Aircraft) Ident(now time.Time) *av.RadioTransmission

func (*Aircraft) InitializeArrival

func (ac *Aircraft) InitializeArrival(ap *av.Airport, arr *av.Arrival, nmPerLongitude float32, magneticVariation float32,
	model *wx.Model, simTime time.Time, lg *log.Logger) error

func (*Aircraft) InitializeDeparture

func (ac *Aircraft) InitializeDeparture(ap *av.Airport, departureAirport string, dep *av.Departure,
	runway string, exitRoute av.ExitRoute, nmPerLongitude float32, magneticVariation float32,
	model *wx.Model, simTime time.Time, lg *log.Logger) error

func (*Aircraft) InitializeFlightPlan

func (ac *Aircraft) InitializeFlightPlan(r av.FlightRules, acType, dep, arr string)

func (*Aircraft) InitializeOverflight

func (ac *Aircraft) InitializeOverflight(of *av.Overflight, nmPerLongitude float32,
	magneticVariation float32, model *wx.Model, simTime time.Time, lg *log.Logger) error

func (*Aircraft) InitializeVFRDeparture

func (ac *Aircraft) InitializeVFRDeparture(ap *av.Airport, wps av.WaypointArray,
	randomizeAltitudeRange bool, nmPerLongitude float32, magneticVariation float32, model *wx.Model,
	simTime time.Time, lg *log.Logger) error

func (*Aircraft) InterceptApproach

func (ac *Aircraft) InterceptApproach(lg *log.Logger) *av.RadioTransmission

func (*Aircraft) IsAirborne

func (ac *Aircraft) IsAirborne() bool

func (*Aircraft) IsArrival

func (ac *Aircraft) IsArrival() bool

func (*Aircraft) IsAssociated

func (ac *Aircraft) IsAssociated() bool

func (*Aircraft) IsDeparture

func (ac *Aircraft) IsDeparture() bool

func (*Aircraft) IsOverflight

func (ac *Aircraft) IsOverflight() bool

func (*Aircraft) IsUnassociated

func (ac *Aircraft) IsUnassociated() bool

func (*Aircraft) MVAsApply

func (ac *Aircraft) MVAsApply() bool

func (*Aircraft) MagneticVariation

func (ac *Aircraft) MagneticVariation() float32

func (*Aircraft) MaintainMaximumForward

func (ac *Aircraft) MaintainMaximumForward() *av.RadioTransmission

func (*Aircraft) MaintainSlowestPractical

func (ac *Aircraft) MaintainSlowestPractical() *av.RadioTransmission

func (*Aircraft) NavSummary

func (ac *Aircraft) NavSummary(model *wx.Model, simTime time.Time, lg *log.Logger) string

func (*Aircraft) NmPerLongitude

func (ac *Aircraft) NmPerLongitude() float32

func (*Aircraft) OnApproach

func (ac *Aircraft) OnApproach(checkAltitude bool) bool

func (*Aircraft) OnExtendedCenterline

func (ac *Aircraft) OnExtendedCenterline(maxNmDeviation float32) bool

func (*Aircraft) PilotMixUp added in v0.13.2

func (ac *Aircraft) PilotMixUp() *av.RadioTransmission

func (*Aircraft) Position

func (ac *Aircraft) Position() math.Point2LL

func (*Aircraft) ResumeOwnNavigation

func (ac *Aircraft) ResumeOwnNavigation() *av.RadioTransmission

func (*Aircraft) RouteIncludesFix

func (ac *Aircraft) RouteIncludesFix(fix string) bool

func (*Aircraft) SayAltitude

func (ac *Aircraft) SayAltitude() *av.RadioTransmission

func (*Aircraft) SayHeading

func (ac *Aircraft) SayHeading() *av.RadioTransmission

func (*Aircraft) SaySpeed

func (ac *Aircraft) SaySpeed() *av.RadioTransmission

func (*Aircraft) TAS

func (ac *Aircraft) TAS() float32

func (*Aircraft) TurnLeft

func (ac *Aircraft) TurnLeft(deg int) *av.RadioTransmission

func (*Aircraft) TurnRight

func (ac *Aircraft) TurnRight(deg int) *av.RadioTransmission

func (*Aircraft) Update

func (ac *Aircraft) Update(model *wx.Model, simTime time.Time, bravo *av.AirspaceGrid, lg *log.Logger) *av.Waypoint

func (*Aircraft) Waypoints

func (ac *Aircraft) Waypoints() []av.Waypoint

func (*Aircraft) WillDoAirwork

func (ac *Aircraft) WillDoAirwork() bool

type AircraftDisplayState

type AircraftDisplayState struct {
	Spew        string // for debugging
	FlightState string // for display when paused
}

type AirspaceAwareness

type AirspaceAwareness struct {
	Fix                 []string `json:"fixes"`
	AltitudeRange       [2]int   `json:"altitude_range"`
	ReceivingController string   `json:"receiving_controller"`
	AircraftType        []string `json:"aircraft_type"`
}

type ArrivalRunway

type ArrivalRunway struct {
	Airport string `json:"airport"`
	Runway  string `json:"runway"`
}

type CIDAllocator added in v0.13.0

type CIDAllocator struct {
	List [7]map[string]interface{}
}

CIDAllocator manages allocation of unique three-character CIDs.

func NewCIDAllocator added in v0.13.0

func NewCIDAllocator() *CIDAllocator

func (*CIDAllocator) Allocate added in v0.13.0

func (c *CIDAllocator) Allocate() (string, error)

Allocate returns the next Available CID.

func (*CIDAllocator) Release added in v0.13.0

func (c *CIDAllocator) Release(cid string)

Release frees a CID so it can be reused.

type CommonState added in v0.13.3

type CommonState struct {
	DynamicState

	Airports          map[string]*av.Airport
	Controllers       map[ControlPosition]*av.Controller
	DepartureAirports map[string]interface{}
	ArrivalAirports   map[string]interface{}
	Fixes             map[string]math.Point2LL
	VFRRunways        map[string]av.Runway // assume just one runway per airport

	ConfigurationId string // Short identifier for the configuration (from ControllerConfiguration.ConfigId)

	Airspace map[ControlPosition]map[string][]av.ControllerAirspaceVolume // position -> vol name -> definition

	DepartureRunways []DepartureRunway
	ArrivalRunways   []ArrivalRunway
	InboundFlows     map[string]*av.InboundFlow
	Emergencies      []Emergency

	Center                    math.Point2LL
	Range                     float32
	ScenarioDefaultVideoMaps  []string
	ScenarioDefaultVideoGroup string

	FacilityAdaptation FacilityAdaptation

	Facility          string
	MagneticVariation float32
	NmPerLongitude    float32
	PrimaryAirport    string

	SimDescription string

	PrivilegedTCWs map[TCW]bool // TCWs with elevated privileges (can control any aircraft)
	Observers      map[TCW]bool // TCWs connected as observers (no position)

	VideoMapLibraryHash []byte
}

CommonState represents the sim state that is both used server side and client-side.

func (*CommonState) FindAirportForATPAVolume added in v0.13.3

func (ss *CommonState) FindAirportForATPAVolume(volumeId string) string

FindAirportForATPAVolume returns the airport ICAO code that contains the given volume ID

func (*CommonState) GetPositionsForTCW added in v0.13.3

func (ss *CommonState) GetPositionsForTCW(tcw TCW) []ControlPosition

func (*CommonState) IsATPAVolume25nmEnabled added in v0.13.3

func (ss *CommonState) IsATPAVolume25nmEnabled(volumeId string) bool

IsATPAVolume25nmEnabled checks if 2.5nm reduced separation is enabled for the volume

func (*CommonState) IsATPAVolumeDisabled added in v0.13.3

func (ss *CommonState) IsATPAVolumeDisabled(volumeId string) bool

IsATPAVolumeDisabled checks if the given ATPA volume is disabled

func (*CommonState) IsExternalController added in v0.13.3

func (ss *CommonState) IsExternalController(pos ControlPosition) bool

func (*CommonState) IsLocalController added in v0.13.3

func (ss *CommonState) IsLocalController(pos ControlPosition) bool

func (*CommonState) Locate added in v0.13.3

func (ss *CommonState) Locate(s string) (math.Point2LL, bool)

func (*CommonState) PrimaryPositionForTCW added in v0.13.3

func (ss *CommonState) PrimaryPositionForTCW(tcw TCW) ControlPosition

PrimaryPositionForTCW returns the primary position for the given TCW. Returns the TCW as position if no consolidation state exists or if Primary is empty.

func (*CommonState) ResolveController added in v0.13.3

func (ss *CommonState) ResolveController(pos ControlPosition) ControlPosition

func (*CommonState) TCWControlsPosition added in v0.13.3

func (ss *CommonState) TCWControlsPosition(tcw TCW, pos ControlPosition) bool

TCWControlsPosition returns true if the given TCW controls the specified position (either as primary or as a secondary position).

func (*CommonState) TCWControlsTrack added in v0.13.3

func (ss *CommonState) TCWControlsTrack(tcw TCW, track *Track) bool

TCWControlsTrack returns true if the given TCW owns the track. Track ownership is determined by the OwningTCW field, which is set when the track is accepted/spawned and updated during full consolidation.

func (*CommonState) TCWForPosition added in v0.13.3

func (ss *CommonState) TCWForPosition(pos ControlPosition) TCW

func (*CommonState) TCWIsObserver added in v0.13.3

func (ss *CommonState) TCWIsObserver(tcw TCW) bool

func (*CommonState) TCWIsPrivileged added in v0.13.3

func (ss *CommonState) TCWIsPrivileged(tcw TCW) bool

type ConsolidationType added in v0.13.3

type ConsolidationType int
const (
	ConsolidationBasic ConsolidationType = iota
	ConsolidationFull
)

type ControlCommandsResult added in v0.13.0

type ControlCommandsResult struct {
	RemainingInput string
	Error          error
}

type ControlPosition added in v0.13.3

type ControlPosition = av.ControlPosition

ControlPosition is an alias for av.ControlPosition for convenience.

type ControllerAssignments added in v0.13.3

type ControllerAssignments struct {
	InboundAssignments   map[string]TCP `json:"inbound_assignments"`
	DepartureAssignments map[string]TCP `json:"departure_assignments"`
}

ControllerAssignments defines which controller handles each inbound/departure flow. This is separate from the consolidation hierarchy (PositionConsolidation).

type ControllerConfiguration added in v0.13.3

type ControllerConfiguration struct {
	// ConfigId references a configuration in stars_config.configurations that defines
	// the inbound and departure assignments for this scenario.
	ConfigId string `json:"config_id"`

	// DefaultConsolidation defines the consolidation tree. Each key is a parent TCP, and its value is the list
	// of TCPs consolidated into it.  Example: {"1A": ["1B", "1C"], "1C": ["1D"]} means 1B and 1C
	// consolidated into 1A, and 1D consolidated into 1C (and transitively into 1A).
	DefaultConsolidation PositionConsolidation `json:"default_consolidation"`

	// InboundAssignments maps inbound flow names to the TCP that handles them.
	// This is populated from the referenced configuration during post-deserialization.
	InboundAssignments map[string]TCP `json:"-"`

	// DepartureAssignments maps departure specifiers to the TCP that handles them.  Keys can be:
	// airport only ("KJFK"), airport/runway ("KJFK/22R"), or airport/SID ("KJFK/SKORR5"). It is not
	// allowed to mix different specifier types for the same airport within a configuration.
	// This is populated from the referenced configuration during post-deserialization.
	DepartureAssignments map[string]TCP `json:"-"`
}

ControllerConfiguration defines the consolidation hierarchy for a scenario.

func (*ControllerConfiguration) AllPositions added in v0.13.3

func (cc *ControllerConfiguration) AllPositions() []TCP

AllPositions returns all TCPs defined in this configuration

func (*ControllerConfiguration) RootPosition added in v0.13.3

func (cc *ControllerConfiguration) RootPosition() (TCP, error)

RootPosition returns the root TCP of the consolidation tree, or empty string if not found.

func (*ControllerConfiguration) Validate added in v0.13.3

func (cc *ControllerConfiguration) Validate(controlPositions map[TCP]*av.Controller, e *util.ErrorLogger)

Validate checks the configuration for errors

type CoordinationList

type CoordinationList struct {
	Name          string   `json:"name"`
	Id            string   `json:"id"`
	Airports      []string `json:"airports"`
	YellowEntries bool     `json:"yellow_entries"`
	Format        string   `json:"format"`
}

type DepartureAircraft

type DepartureAircraft struct {
	ADSBCallsign  av.ADSBCallsign
	MinSeparation time.Duration // How long after takeoff it will be at ~6000' and airborne
	SpawnTime     time.Time     // when it was first spawned
	LaunchTime    time.Time     // when it was actually launched; used for wake turbulence separation, etc.

	// When they're ready to leave the gate
	ReadyDepartGateTime time.Time

	// HFR-only.
	ReleaseRequested   bool
	ReleaseDelay       time.Duration // minimum wait after release before the takeoff roll
	RequestReleaseTime time.Time
}

DepartureAircraft represents a departing aircraft, either still on the ground or recently-launched.

type DepartureRunway

type DepartureRunway struct {
	Airport     string `json:"airport"`
	Runway      string `json:"runway"`
	Category    string `json:"category,omitempty"`
	DefaultRate int    `json:"rate"`
}

type DerivedState added in v0.13.3

type DerivedState struct {
	Tracks                  map[av.ADSBCallsign]*Track
	UnassociatedFlightPlans []*NASFlightPlan // Unassociated ones, including unsupported DBs
	ReleaseDepartures       []ReleaseDeparture
}

DerivedState collects state used on the client-side that is derived from Sim state that is not shared with the client.

type DynamicState added in v0.13.3

type DynamicState struct {
	GenerationIndex int

	CurrentConsolidation map[TCW]*TCPConsolidation

	SimTime time.Time // this is our fake time--accounting for pauses & simRate..

	METAR map[string]wx.METAR

	LaunchConfig LaunchConfig

	UserRestrictionAreas []av.RestrictionArea

	Paused  bool
	SimRate float32

	ATPAEnabled     bool                                   // True if ATPA is enabled system-wide
	ATPAVolumeState map[string]map[string]*ATPAVolumeState // airport -> volumeId -> state
}

DynamicState is the subset of CommonState that is sent to the user once a second as the Sim executes. In this way, we limit network traffic to what is actually changing and only send the static information in CommonState once, when the Sim starts.

type ERAMComputer

type ERAMComputer struct {
	SquawkCodePool *av.EnrouteSquawkCodePool
	Identifier     string
	Adaptation     av.ERAMAdaptation
}

func (*ERAMComputer) CreateSquawk

func (ec *ERAMComputer) CreateSquawk() (av.Squawk, error)

func (*ERAMComputer) ReturnSquawk

func (ec *ERAMComputer) ReturnSquawk(code av.Squawk) error

func (*ERAMComputer) Update

func (ec *ERAMComputer) Update(s *Sim)

type ERAMMap added in v0.13.0

type ERAMMap struct {
	BcgName    string
	LabelLine1 string
	LabelLine2 string
	Name       string
	Lines      [][]math.Point2LL
}

type ERAMMapGroup added in v0.13.0

type ERAMMapGroup struct {
	Maps       []ERAMMap
	LabelLine1 string
	LabelLine2 string
}

type ERAMMapGroups added in v0.13.0

type ERAMMapGroups map[string]ERAMMapGroup

type Emergency added in v0.13.2

type Emergency struct {
	Name               string `json:"name"`
	ApplicableToString string `json:"applicable_to"`
	ApplicableTo       EmergencyApplicability
	Weight             float32          `json:"weight"`
	Stages             []EmergencyStage `json:"stages"`
}

type EmergencyApplicability added in v0.13.2

type EmergencyApplicability int
const (
	EmergencyApplicabilityDeparture EmergencyApplicability = 1 << iota
	EmergencyApplicabilityArrival
	EmergencyApplicabilityExternal
	EmergencyApplicabilityApproach
)

func (EmergencyApplicability) Applies added in v0.13.2

func (ea EmergencyApplicability) Applies(ac *Aircraft, humanController bool) bool

Returns weight for this emergency type given the aircraft. Returns 0 if not applicable.

func (EmergencyApplicability) String added in v0.13.2

func (ea EmergencyApplicability) String() string

type EmergencyStage added in v0.13.2

type EmergencyStage struct {
	Transmission        string `json:"transmission"`
	DurationMinutes     [2]int `json:"duration_minutes"`
	RequestReturn       bool   `json:"request_return"`
	StopClimb           bool   `json:"stop_climb"`
	Checklists          bool   `json:"checklists"`
	RequestEquipment    bool   `json:"request_equipment"`
	RequestDelayVectors bool   `json:"request_delay_vectors"`
	DeclareEmergency    bool   `json:"declare_emergency"`
}

EmergencyStage represents a stage in an emergency's progression.

type EmergencyState added in v0.13.2

type EmergencyState struct {
	Emergency      *Emergency
	CurrentStage   int
	NextUpdateTime time.Time
}

EmergencyState tracks the current state of an aircraft's emergency.

type Event

type Event struct {
	Type                  EventType
	ADSBCallsign          av.ADSBCallsign
	ACID                  ACID
	FromController        ControlPosition
	ToController          ControlPosition // For radio transmissions, the controlling controller.
	WrittenText           string
	SpokenText            string
	RadioTransmissionType av.RadioTransmissionType       // For radio transmissions only
	LeaderLineDirection   *math.CardinalOrdinalDirection // SetGlobalLeaderLineEvent
	WaypointInfo          []math.Point2LL
}

func (Event) LogValue

func (e Event) LogValue() slog.Value

func (*Event) String

func (e *Event) String() string

type EventStream

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

EventStream provides a basic pub/sub event interface that allows any part of the system to post an event to the stream and other parts to subscribe and receive messages from the stream. It is the backbone for communicating events, world updates, and user actions across the various parts of the system.

func NewEventStream

func NewEventStream(lg *log.Logger) *EventStream

func (*EventStream) Destroy

func (e *EventStream) Destroy()

func (*EventStream) LogValue

func (e *EventStream) LogValue() slog.Value

implements slog.LogValuer

func (*EventStream) Post

func (e *EventStream) Post(event Event)

Post adds an event to the event stream. The type used to encode the event is arbitrary; it's up to the EventStream users to establish conventions.

func (*EventStream) Subscribe

func (e *EventStream) Subscribe() *EventsSubscription

Subscribe registers a new subscriber to the stream and returns an EventSubscriberId for the subscriber that can then be passed to other EventStream methods.

type EventSubscriberId

type EventSubscriberId int

type EventType

type EventType int
const (
	PushedFlightStripEvent EventType = iota
	PointOutEvent
	OfferedHandoffEvent
	AcceptedHandoffEvent
	AcceptedRedirectedHandoffEvent
	CanceledHandoffEvent
	RejectedHandoffEvent
	RadioTransmissionEvent
	StatusMessageEvent
	ErrorMessageEvent
	ServerBroadcastMessageEvent
	GlobalMessageEvent
	AcknowledgedPointOutEvent
	RejectedPointOutEvent
	HandoffControlEvent
	SetGlobalLeaderLineEvent
	ForceQLEvent
	TransferAcceptedEvent
	TransferRejectedEvent
	RecalledPointOutEvent
	FlightPlanAssociatedEvent
	FixCoordinatesEvent
	NumEventTypes
)

func (EventType) String

func (t EventType) String() string

type EventsSubscription

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

func (*EventsSubscription) Get

func (e *EventsSubscription) Get() []Event

Get returns all of the events from the stream since the last time Get was called with the given id. Note that events before an id was created with Subscribe are never reported for that id.

func (*EventsSubscription) LogValue

func (e *EventsSubscription) LogValue() slog.Value

func (*EventsSubscription) PostEvent

func (e *EventsSubscription) PostEvent(event Event)

func (*EventsSubscription) Unsubscribe

func (e *EventsSubscription) Unsubscribe()

Unsubscribe removes a subscriber from the subscriber list

type FacilityAdaptation added in v0.13.0

type FacilityAdaptation struct {
	// Configurations maps config IDs (max 3 chars) to controller assignments.
	// These define which TCP handles each inbound flow and departure airport/runway/SID.
	Configurations map[string]*ControllerAssignments `json:"configurations"`

	AirspaceAwareness   []AirspaceAwareness                        `json:"airspace_awareness" scope:"stars"`
	ForceQLToSelf       bool                                       `json:"force_ql_self" scope:"stars"`
	AllowLongScratchpad bool                                       `json:"allow_long_scratchpad" scope:"stars"`
	VideoMapNames       []string                                   `json:"stars_maps" scope:"stars"`
	ERAMMapNames        map[string][]string                        `json:"eram_maps" scope:"eram"`
	VideoMapLabels      map[string]string                          `json:"map_labels"`
	ControllerConfigs   map[ControlPosition]*STARSControllerConfig `json:"controller_configs"`
	RadarSites          map[string]*av.RadarSite                   `json:"radar_sites" scope:"stars"`
	Center              math.Point2LL                              `json:"-"`
	CenterString        string                                     `json:"center"`
	MaxDistance         float32                                    `json:"max_distance"` // Distance from center where aircraft get culled from (default 125nm)
	Range               float32                                    `json:"range"`
	Scratchpads         map[string]string                          `json:"scratchpads" scope:"stars"`
	SignificantPoints   map[string]SignificantPoint                `json:"significant_points" scope:"stars"`
	Altimeters          []string                                   `json:"altimeters"`

	// Airpsace filters
	Filters struct {
		AutoAcquisition FilterRegions `json:"auto_acquisition"`
		ArrivalDrop     FilterRegions `json:"arrival_drop"`
		Departure       FilterRegions `json:"departure"`
		InhibitCA       FilterRegions `json:"inhibit_ca"`
		InhibitMSAW     FilterRegions `json:"inhibit_msaw"`
		Quicklook       FilterRegions `json:"quicklook"`
		SecondaryDrop   FilterRegions `json:"secondary_drop"`
		SurfaceTracking FilterRegions `json:"surface_tracking"`
		VFRInhibit      FilterRegions `json:"vfr_inhibit"`
	} `json:"filters" scope:"stars"` //Should this be STARS or justy parts of it?

	MonitoredBeaconCodeBlocksString  *string
	MonitoredBeaconCodeBlocks        []av.Squawk
	UntrackedPositionSymbolOverrides struct {
		CodeRangesString string         `json:"beacon_codes"`
		CodeRanges       [][2]av.Squawk // inclusive
		Symbol           string         `json:"symbol"`
	} `json:"untracked_position_symbol_overrides" scope:"stars"`

	VideoMapFile      string                        `json:"video_map_file"`
	CoordinationFixes map[string]av.AdaptationFixes `json:"coordination_fixes" scope:"stars"`
	SingleCharAIDs    map[string]string             `json:"single_char_aids" scope:"stars"` // Char to airport. TODO: Check if this is for ERAM as well.
	KeepLDB           bool                          `json:"keep_ldb" scope:"stars"`
	FullLDBSeconds    int                           `json:"full_ldb_seconds" scope:"stars"`

	SSRCodes av.LocalSquawkCodePoolSpecifier `json:"ssr_codes" scope:"stars"`

	HandoffAcceptFlashDuration int  `json:"handoff_acceptance_flash_duration" scope:"stars"`
	DisplayHOFacilityOnly      bool `json:"display_handoff_facility_only" scope:"stars"`
	HOSectorDisplayDuration    int  `json:"handoff_sector_display_duration" scope:"stars"`

	AirportCodes map[string]string `json:"airport_codes" scope:"eram"`

	FlightPlan struct {
		QuickACID          string            `json:"quick_acid"`
		ACIDExpansions     map[string]string `json:"acid_expansions"`
		ModifyAfterDisplay bool              `json:"modify_after_display"`
	} `json:"flight_plan" scope:"stars"`

	PDB struct {
		ShowScratchpad2   bool `json:"show_scratchpad2"`
		HideGroundspeed   bool `json:"hide_gs"`
		ShowAircraftType  bool `json:"show_aircraft_type"`
		SplitGSAndCWT     bool `json:"split_gs_and_cwt"`
		DisplayCustomSPCs bool `json:"display_custom_spcs"`
	} `json:"pdb" scope:"stars"`

	FDB struct {
		DisplayRequestedAltitude bool `json:"display_requested_altitude"`
		Scratchpad2OnLine3       bool `json:"scratchpad2_on_line3"`
	} `json:"fdb" scope:"stars"`

	Scratchpad1 struct {
		DisplayExitFix     bool `json:"display_exit_fix"`
		DisplayExitFix1    bool `json:"display_exit_fix_1"`
		DisplayExitGate    bool `json:"display_exit_gate"`
		DisplayAltExitGate bool `json:"display_alternate_exit_gate"`
	} `json:"scratchpad1" scope:"stars"`

	CustomSPCs []string `json:"custom_spcs"`

	CoordinationLists []CoordinationList `json:"coordination_lists" scope:"stars"`
	VFRList           struct {
		Format string `json:"format"`
	} `json:"vfr_list" scope:"stars"`
	TABList struct {
		Format string `json:"format"`
	} `json:"tab_list" scope:"stars"`
	CoastSuspendList struct {
		Format string `json:"format"`
	} `json:"coast_suspend_list" scope:"stars"`
	MCISuppressionList struct {
		Format string `json:"format"`
	} `json:"mci_suppression_list" scope:"stars"`
	TowerList struct {
		Format string `json:"format"`
	} `json:"tower_list" scope:"stars"`
	RestrictionAreas  []av.RestrictionArea `json:"restriction_areas" scope:"stars"`
	UseLegacyFont     bool                 `json:"use_legacy_font" scope:"stars"`
	DisplayRNAVSymbol bool                 `json:"display_rnav_symbol"`
}

func (FacilityAdaptation) CheckScratchpad added in v0.13.0

func (fa FacilityAdaptation) CheckScratchpad(sp string) bool

func (*FacilityAdaptation) PostDeserialize added in v0.13.0

func (fa *FacilityAdaptation) PostDeserialize(loc av.Locator, controlledAirports []string, allAirports []string, e *util.ErrorLogger)

type FilterRegion

type FilterRegion struct {
	av.AirspaceVolume
	InvertTest bool
}

func (FilterRegion) Inside

func (r FilterRegion) Inside(p math.Point2LL, alt int) bool

type FilterRegions

type FilterRegions []FilterRegion

func (FilterRegions) HaveId

func (r FilterRegions) HaveId(s string) bool

func (FilterRegions) Inside

func (r FilterRegions) Inside(p math.Point2LL, alt int) bool

type FlightPlanSpecifier added in v0.13.0

type FlightPlanSpecifier struct {
	ACID                  util.Optional[ACID]
	EntryFix              util.Optional[string]
	ExitFix               util.Optional[string]
	ExitFixIsIntermediate util.Optional[bool]
	Rules                 util.Optional[av.FlightRules]
	CoordinationTime      util.Optional[time.Time]
	PlanType              util.Optional[NASFlightPlanType]

	SquawkAssignment         util.Optional[string]
	ImplicitSquawkAssignment util.Optional[av.Squawk] // only used when taking the track's current code

	TrackingController util.Optional[ControlPosition]

	AircraftCount   util.Optional[int]
	AircraftType    util.Optional[string]
	EquipmentSuffix util.Optional[string]

	TypeOfFlight util.Optional[av.TypeOfFlight]

	AssignedAltitude      util.Optional[int]
	InterimAlt            util.Optional[int]
	InterimType           util.Optional[string]
	AltitudeBlock         util.Optional[[2]int]
	ControllerReportedAlt util.Optional[int]
	VFROTP                util.Optional[bool]
	RequestedAltitude     util.Optional[int]
	PilotReportedAltitude util.Optional[int]

	Scratchpad          util.Optional[string]
	SecondaryScratchpad util.Optional[string]

	RNAV       util.Optional[bool]
	RNAVToggle util.Optional[bool]

	Location util.Optional[math.Point2LL]

	PointOutHistory             util.Optional[[]string]
	InhibitModeCAltitudeDisplay util.Optional[bool]
	SPCOverride                 util.Optional[string]
	DisableMSAW                 util.Optional[bool]
	DisableCA                   util.Optional[bool]
	MCISuppressedCode           util.Optional[av.Squawk]
	GlobalLeaderLineDirection   util.Optional[*math.CardinalOrdinalDirection]
	QuickFlightPlan             util.Optional[bool]
	HoldState                   util.Optional[bool]
	Suspended                   util.Optional[bool]
	CoastSuspendIndex           util.Optional[int]

	InhibitACTypeDisplay      util.Optional[bool]
	ForceACTypeDisplayEndTime util.Optional[time.Time]
}

func (FlightPlanSpecifier) GetFlightPlan added in v0.13.0

func (s FlightPlanSpecifier) GetFlightPlan(localPool *av.LocalSquawkCodePool,
	nasPool *av.EnrouteSquawkCodePool) (NASFlightPlan, error)

func (*FlightPlanSpecifier) Merge added in v0.13.3

func (s *FlightPlanSpecifier) Merge(other FlightPlanSpecifier)

Merge incorporates set fields from other into s. Fields set in other take precedence.

type FutureChangeSquawk

type FutureChangeSquawk struct {
	ADSBCallsign av.ADSBCallsign
	Code         av.Squawk
	Mode         av.TransponderMode
	Time         time.Time
}

type FutureControllerContact

type FutureControllerContact struct {
	ADSBCallsign av.ADSBCallsign
	TCP          TCP
	Time         time.Time
}

type FutureEmergencyUpdate added in v0.13.2

type FutureEmergencyUpdate struct {
	ADSBCallsign av.ADSBCallsign
	Time         time.Time
}

FutureEmergencyUpdate represents a scheduled emergency progression update.

type FutureOnCourse

type FutureOnCourse struct {
	ADSBCallsign av.ADSBCallsign
	Time         time.Time
}

type Handoff

type Handoff struct {
	AutoAcceptTime    time.Time
	ReceivingFacility string // only for auto accept
}

type HeadingArgs

type HeadingArgs struct {
	TCW          TCW
	ADSBCallsign av.ADSBCallsign
	Heading      int
	Present      bool
	LeftDegrees  int
	RightDegrees int
	Turn         nav.TurnMethod
}

type LaunchConfig

type LaunchConfig struct {
	// Controller is the TCW in charge of the launch settings; if empty then
	// launch control may be taken by any signed in controller.
	Controller TCW
	// LaunchManual or LaunchAutomatic, separate for each aircraft type
	DepartureMode  int32
	ArrivalMode    int32
	OverflightMode int32

	GoAroundRate float32
	// airport -> runway -> category -> rate
	DepartureRates     map[string]map[string]map[string]float32
	DepartureRateScale float32

	VFRDepartureRateScale   float32
	VFRAirportRates         map[string]int // name -> VFRRateSum()
	VFFRequestRate          int32
	HaveVFRReportingRegions bool

	// inbound flow -> airport / "overflights" -> rate
	InboundFlowRates            map[string]map[string]float32
	InboundFlowRateScale        float32
	ArrivalPushes               bool
	ArrivalPushFrequencyMinutes int
	ArrivalPushLengthMinutes    int

	EmergencyAircraftRate float32 // Aircraft per hour
}

LaunchConfig collects settings related to launching aircraft in the sim; it's passed back and forth between client and server: server provides them so client can draw the UI for what's available, then client returns one back when launching.

func MakeLaunchConfig

func MakeLaunchConfig(dep []DepartureRunway, vfrRateScale float32, vfrAirports map[string]*av.Airport,
	inbound map[string]map[string]int, haveVFRReportingRegions bool) LaunchConfig

func (*LaunchConfig) CheckRateLimits

func (lc *LaunchConfig) CheckRateLimits(limit float32) bool

CheckRateLimits returns true if both total departure rates and total inbound flow rates sum to less than the provided limit (aircraft per hour)

func (*LaunchConfig) ClampRates

func (lc *LaunchConfig) ClampRates(limit float32)

ClampRates adjusts the rate scale variables to ensure the total launch rate does not exceed the given limit (aircraft per hour)

func (*LaunchConfig) HaveArrivals added in v0.13.3

func (lc *LaunchConfig) HaveArrivals() bool

func (*LaunchConfig) HaveDepartures added in v0.13.3

func (lc *LaunchConfig) HaveDepartures() bool

func (*LaunchConfig) HaveOverflights added in v0.13.3

func (lc *LaunchConfig) HaveOverflights() bool

func (*LaunchConfig) TotalArrivalRate

func (lc *LaunchConfig) TotalArrivalRate() float32

TotalArrivalRate returns the total arrival rate (aircraft per hour) excluding overflights

func (*LaunchConfig) TotalDepartureRate

func (lc *LaunchConfig) TotalDepartureRate() float32

TotalDepartureRate returns the total departure rate (aircraft per hour) for all airports and runways

func (*LaunchConfig) TotalInboundFlowRate

func (lc *LaunchConfig) TotalInboundFlowRate() float32

TotalInboundFlowRate returns the total inbound flow rate (aircraft per hour) for all flows

func (*LaunchConfig) TotalOverflightRate

func (lc *LaunchConfig) TotalOverflightRate() float32

TotalOverflightRate returns the total overflight rate (aircraft per hour)

type NASFlightPlan added in v0.13.0

type NASFlightPlan struct {
	ACID                  ACID
	CID                   string
	EntryFix              string
	ExitFix               string
	ArrivalAirport        string // Technically not a string, but until the NAS system is fully integrated, we'll need this.
	ExitFixIsIntermediate bool
	Rules                 av.FlightRules
	CoordinationTime      time.Time
	PlanType              NASFlightPlanType

	AssignedSquawk av.Squawk

	TrackingController    ControlPosition // Who has the radar track
	ControllingController ControlPosition // Who has control; not necessarily the same as TrackingController
	HandoffController     ControlPosition // Handoff offered but not yet accepted
	LastLocalController   ControlPosition // (May be the current controller.)
	OwningTCW             TCW             // TCW that owns this track

	AircraftCount   int
	AircraftType    string
	EquipmentSuffix string

	TypeOfFlight av.TypeOfFlight

	AssignedAltitude      int
	PerceivedAssigned     int // what the previous controller would put into the hard alt, even though the aircraft is descending via a STAR.
	InterimAlt            int
	InterimType           int
	AltitudeBlock         [2]int
	ControllerReportedAlt int
	VFROTP                bool

	RequestedAltitude     int
	PilotReportedAltitude int

	Scratchpad          string
	SecondaryScratchpad string

	PriorScratchpad          string
	PriorSecondaryScratchpad string

	RNAV bool

	Location math.Point2LL
	Route    string

	PointOutHistory             []ControlPosition
	InhibitModeCAltitudeDisplay bool
	SPCOverride                 string
	DisableMSAW                 bool
	DisableCA                   bool
	MCISuppressedCode           av.Squawk
	GlobalLeaderLineDirection   *math.CardinalOrdinalDirection
	QuickFlightPlan             bool
	HoldState                   bool
	Suspended                   bool
	CoastSuspendIndex           int

	// FIXME: the following are all used internally by NAS code. It's
	// convenient to have them here but this stuff should just be managed
	// internally there.
	ListIndex int

	// First controller in the local facility to get the track: used both
	// for /ho and for departures
	InboundHandoffController ControlPosition

	CoordinationFix     string
	ContainedFacilities []string
	RedirectedHandoff   RedirectedHandoff

	InhibitACTypeDisplay      bool
	ForceACTypeDisplayEndTime time.Time
	CWTCategory               string

	// After fps are dropped, we hold on to them for a bit before they're
	// actually deleted.
	DeleteTime time.Time

	// Used so that such FPs can associate regardless of acquisition filters.
	ManuallyCreated bool
}

func (*NASFlightPlan) Update added in v0.13.0

func (fp *NASFlightPlan) Update(spec FlightPlanSpecifier, sim *Sim) (err error)

type NASFlightPlanType added in v0.13.0

type NASFlightPlanType int
const (
	UnknownFlightPlanType NASFlightPlanType = iota

	// Flight plan received from a NAS ARTCC.  This is a flight plan that
	// has been sent over by an overlying ERAM facility.
	RemoteEnroute

	// Flight plan received from an adjacent terminal facility This is a
	// flight plan that has been sent over by another STARS facility.
	RemoteNonEnroute

	// VFR interfacility flight plan entered locally for which the NAS
	// ARTCC has not returned a flight plan This is a flight plan that is
	// made by a STARS facility that gets a NAS code.
	LocalEnroute

	// Flight plan entered by TCW or flight plan from an adjacent terminal
	// that has been handed off to this STARS facility This is a flight
	// plan that is made at a STARS facility and gets a local code.
	LocalNonEnroute
)

Flight plan types (STARS)

type NewSimConfiguration

type NewSimConfiguration struct {
	Facility    string
	Description string

	Airports           map[string]*av.Airport
	PrimaryAirport     string
	DepartureRunways   []DepartureRunway
	ArrivalRunways     []ArrivalRunway
	InboundFlows       map[string]*av.InboundFlow
	LaunchConfig       LaunchConfig
	Fixes              map[string]math.Point2LL
	VFRReportingPoints []av.VFRReportingPoint

	ControlPositions        map[TCP]*av.Controller
	ControllerAirspace      map[TCP][]string
	VirtualControllers      []TCP
	ControllerConfiguration *ControllerConfiguration

	TFRs               []av.TFR
	FacilityAdaptation FacilityAdaptation

	EnforceUniqueCallsignSuffix bool

	ReportingPoints   []av.ReportingPoint
	MagneticVariation float32
	NmPerLongitude    float32
	StartTime         time.Time
	WindSpecifier     *wx.WindSpecifier
	Center            math.Point2LL
	Range             float32
	DefaultMaps       []string
	DefaultMapGroup   string
	Airspace          av.Airspace

	PilotErrorInterval float32

	WXProvider wx.Provider

	Emergencies []Emergency
}

NewSimConfiguration collects all of the information required to create a new Sim

type PilotSpeech

type PilotSpeech struct {
	Callsign av.ADSBCallsign
	Type     av.RadioTransmissionType
	Text     string
	MP3      []byte
}

type PointOut

type PointOut struct {
	FromController ControlPosition
	ToController   ControlPosition
	AcceptTime     time.Time
}

type PositionConsolidation added in v0.13.3

type PositionConsolidation map[TCP][]TCP

func (PositionConsolidation) AllPositions added in v0.13.3

func (pc PositionConsolidation) AllPositions() []TCP

func (PositionConsolidation) RootPosition added in v0.13.3

func (pc PositionConsolidation) RootPosition() (TCP, error)

GetRootPosition returns the root TCP of the consolidation tree (the one that has all others transitively consolidated into it).

type RedirectedHandoff

type RedirectedHandoff struct {
	OriginalOwner ControlPosition   // Controller position
	Redirector    []ControlPosition // Redirecting controllers
	RedirectedTo  ControlPosition
}

func (*RedirectedHandoff) AddRedirector

func (rd *RedirectedHandoff) AddRedirector(ctrl *av.Controller)

func (*RedirectedHandoff) GetLastRedirector

func (rd *RedirectedHandoff) GetLastRedirector() ControlPosition

func (*RedirectedHandoff) ShouldFallbackToHandoff

func (rd *RedirectedHandoff) ShouldFallbackToHandoff(ctrl, octrl ControlPosition) bool

func (*RedirectedHandoff) ShowRDIndicator

func (rd *RedirectedHandoff) ShowRDIndicator(pos ControlPosition, RDIndicatorEnd time.Time) bool

type ReleaseDeparture

type ReleaseDeparture struct {
	ADSBCallsign        av.ADSBCallsign
	DepartureAirport    string
	DepartureController ControlPosition
	Released            bool
	Squawk              av.Squawk
	ListIndex           int
	AircraftType        string
	Exit                string
}

type RunwayLaunchState

type RunwayLaunchState struct {
	IFRSpawnRate float32
	VFRSpawnRate float32

	// For each runway, when to create the next departing aircraft, based
	// on the runway departure rate. The actual time an aircraft is
	// launched may be later, e.g. if we need longer for wake turbulence
	// separation, etc.
	NextIFRSpawn time.Time
	NextVFRSpawn time.Time

	// At the gate, flight plan filed (if IFR), not yet ready to go
	Gate []DepartureAircraft
	// Ready to go, in hold for release purgatory.
	Held []DepartureAircraft
	// Ready to go.
	ReleasedIFR []DepartureAircraft
	ReleasedVFR []DepartureAircraft
	// Sequenced departures, pulled from Released. These are launched in-order.
	Sequenced []DepartureAircraft

	LastDeparture          *DepartureAircraft
	LastArrivalLandingTime time.Time      // when the last arrival landed on this runway
	LastArrivalFlightRules av.FlightRules // flight rules of the last arrival that landed

	VFRAttempts  int
	VFRSuccesses int
}

func (RunwayLaunchState) Dump

func (rls RunwayLaunchState) Dump(airport string, runway string, now time.Time)

type STARSComputer

type STARSComputer struct {
	Identifier       string
	FlightPlans      []*NASFlightPlan
	HoldForRelease   []*Aircraft
	AvailableIndices []int
}

func (*STARSComputer) AddHeldDeparture

func (sc *STARSComputer) AddHeldDeparture(ac *Aircraft)

func (*STARSComputer) CreateFlightPlan

func (sc *STARSComputer) CreateFlightPlan(fp NASFlightPlan) (NASFlightPlan, error)

func (*STARSComputer) GetReleaseDepartures

func (sc *STARSComputer) GetReleaseDepartures() []*Aircraft

func (*STARSComputer) ReleaseDeparture

func (sc *STARSComputer) ReleaseDeparture(callsign av.ADSBCallsign) error

func (*STARSComputer) Update

func (sc *STARSComputer) Update(s *Sim)

Note: called with Sim holding its mutex, so we can access its members here.

type STARSControllerConfig

type STARSControllerConfig struct {
	VideoMapNames                   []string      `json:"video_maps"`
	DefaultMaps                     []string      `json:"default_maps"`
	Center                          math.Point2LL `json:"-"`
	CenterString                    string        `json:"center"`
	Range                           float32       `json:"range"`
	MonitoredBeaconCodeBlocksString *string       `json:"beacon_code_blocks"`
	MonitoredBeaconCodeBlocks       []av.Squawk
	FlightFollowingAirspace         []av.AirspaceVolume `json:"flight_following_airspace"`
}

type SecondaryTCP added in v0.13.3

type SecondaryTCP struct {
	TCP  TCP
	Type ConsolidationType
}

SecondaryTCP represents a position that is consolidated to another position.

type SignificantPoint

type SignificantPoint struct {
	Name         string        // JSON comes in as a map from name to SignificantPoint; we set this.
	ShortName    string        `json:"short_name"`
	Abbreviation string        `json:"abbreviation"`
	Description  string        `json:"description"`
	Location     math.Point2LL `json:"location"`
}

type Sim

type Sim struct {
	State *CommonState

	Aircraft map[av.ADSBCallsign]*Aircraft

	ControlPositions     map[TCP]*av.Controller
	VirtualControllers   []TCP
	InboundAssignments   map[string]TCP // Inbound flow name -> TCP responsible
	DepartureAssignments map[string]TCP // Departure specifier -> TCP responsible

	STARSComputer *STARSComputer
	ERAMComputer  *ERAMComputer

	LocalCodePool *av.LocalSquawkCodePool
	CIDAllocator  *CIDAllocator

	TotalIFR, TotalVFR           int
	QuickFlightPlanIndex         int
	ScenarioDefaultConsolidation PositionConsolidation

	VFRReportingPoints []av.VFRReportingPoint

	METAR map[string][]wx.METAR

	// Airport -> runway -> state
	DepartureState map[string]map[string]*RunwayLaunchState
	// Key is inbound flow group name
	NextInboundSpawn map[string]time.Time
	NextVFFRequest   time.Time

	Handoffs  map[ACID]Handoff
	PointOuts map[ACID]PointOut

	ReportingPoints []av.ReportingPoint

	EnforceUniqueCallsignSuffix bool

	FutureControllerContacts []FutureControllerContact
	FutureOnCourse           []FutureOnCourse
	FutureSquawkChanges      []FutureChangeSquawk
	FutureEmergencyUpdates   []FutureEmergencyUpdate

	NextEmergencyTime time.Time

	PilotErrorInterval time.Duration
	LastPilotError     time.Time

	NextPushStart time.Time // both w.r.t. sim time
	PushEnd       time.Time

	Rand *rand.Rand

	SquawkWarnedACIDs map[ACID]interface{} // Warn once in CheckLeaks(); don't spam the logs
	// contains filtered or unexported fields
}

func NewSim

func NewSim(config NewSimConfiguration, manifest *VideoMapManifest, lg *log.Logger) *Sim

func (*Sim) AcceptHandoff

func (s *Sim) AcceptHandoff(tcw TCW, acid ACID) error

func (*Sim) AcceptRedirectedHandoff

func (s *Sim) AcceptRedirectedHandoff(tcw TCW, acid ACID) error

func (*Sim) AcknowledgePointOut

func (s *Sim) AcknowledgePointOut(tcw TCW, acid ACID) error

func (*Sim) Activate

func (s *Sim) Activate(lg *log.Logger, provider wx.Provider)

func (*Sim) ActivateFlightPlan

func (s *Sim) ActivateFlightPlan(tcw TCW, callsign av.ADSBCallsign, acid ACID, spec *FlightPlanSpecifier) error

Flight plan for acid must already exist; spec gives optional amendments.

func (*Sim) AllScenarioPositions added in v0.13.3

func (s *Sim) AllScenarioPositions() []TCP

AllScenarioPositions returns all positions defined in the scenario's default consolidation.

func (*Sim) AltitudeOurDiscretion

func (s *Sim) AltitudeOurDiscretion(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) AssignAltitude

func (s *Sim) AssignAltitude(tcw TCW, callsign av.ADSBCallsign, altitude int, afterSpeed bool) error

func (*Sim) AssignHeading

func (s *Sim) AssignHeading(hdg *HeadingArgs) error

func (*Sim) AssignSpeed

func (s *Sim) AssignSpeed(tcw TCW, callsign av.ADSBCallsign, speed int, afterAltitude bool) error

func (*Sim) AssociateFlightPlan

func (s *Sim) AssociateFlightPlan(tcw TCW, callsign av.ADSBCallsign, spec FlightPlanSpecifier) error

Associate the specified flight plan with the track. Flight plan for ACID must not already exist.

func (*Sim) AtFixCleared

func (s *Sim) AtFixCleared(tcw TCW, callsign av.ADSBCallsign, fix, approach string) error

func (*Sim) CallsignForACID

func (s *Sim) CallsignForACID(acid ACID) (av.ADSBCallsign, bool)

func (*Sim) CancelApproachClearance

func (s *Sim) CancelApproachClearance(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) CancelHandoff

func (s *Sim) CancelHandoff(tcw TCW, acid ACID) error

func (*Sim) ChangeSquawk

func (s *Sim) ChangeSquawk(tcw TCW, callsign av.ADSBCallsign, sq av.Squawk) error

func (*Sim) ChangeTransponderMode

func (s *Sim) ChangeTransponderMode(tcw TCW, callsign av.ADSBCallsign, mode av.TransponderMode) error

func (*Sim) CheckLeaks

func (s *Sim) CheckLeaks()

Make sure we're not leaking beacon codes or list indices.

func (*Sim) ClearedApproach

func (s *Sim) ClearedApproach(tcw TCW, callsign av.ADSBCallsign, approach string, straightIn bool) error

func (*Sim) ClimbViaSID

func (s *Sim) ClimbViaSID(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) ConfigureATPA added in v0.13.3

func (s *Sim) ConfigureATPA(op ATPAConfigOp, volumeId string) (string, error)

func (*Sim) ConsolidateRadioEventsForTCW added in v0.13.3

func (s *Sim) ConsolidateRadioEventsForTCW(tcw TCW, events []Event) []Event

ConsolidateRadioEventsForTCW processes events for TTS, consolidating radio transmissions and adding callsign/controller prefixes. This is the public API for the server to process TTS events from a separate subscription.

func (*Sim) ConsolidateTCP added in v0.13.3

func (s *Sim) ConsolidateTCP(receivingTCW TCW, sendingTCP TCP, consType ConsolidationType) error

ConsolidateTCP consolidates sendingTCP to the receivingTCW's keyboard. (3.11.1 and 3.11.3) ConsolidationFull transfers active tracks and allows moving already-consolidated positions. ConsolidationBasic only consolidates inactive/future and rejects already-consolidated positions.

func (*Sim) ContactController

func (s *Sim) ContactController(tcw TCW, acid ACID, toTCP TCP) error

func (*Sim) ContactTower

func (s *Sim) ContactTower(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) ContactTrackingController

func (s *Sim) ContactTrackingController(tcw TCW, acid ACID) error

func (*Sim) CreateArrival

func (s *Sim) CreateArrival(arrivalGroup string, arrivalAirport string) (*Aircraft, error)

func (*Sim) CreateFlightPlan

func (s *Sim) CreateFlightPlan(tcw TCW, spec FlightPlanSpecifier) error

func (*Sim) CreateIFRDeparture

func (s *Sim) CreateIFRDeparture(departureAirport, runway, category string) (*Aircraft, error)

func (*Sim) CreateOverflight

func (s *Sim) CreateOverflight(group string) (*Aircraft, error)

func (*Sim) CreateRestrictionArea

func (s *Sim) CreateRestrictionArea(ra av.RestrictionArea) (int, error)

func (*Sim) CreateVFRDeparture

func (s *Sim) CreateVFRDeparture(departureAirport string) (*Aircraft, error)

Note that this may fail without an error if it's having trouble finding a route.

func (*Sim) CrossFixAt

func (s *Sim) CrossFixAt(tcw TCW, callsign av.ADSBCallsign, fix string, ar *av.AltitudeRestriction, speed int) error

func (*Sim) DeconsolidateTCP added in v0.13.3

func (s *Sim) DeconsolidateTCP(tcw TCW, tcp TCP) error

DeconsolidateTCP returns a secondary TCP to its default keyboard. If tcp is empty, it means the user wants to deconsolidate their own TCW's TCP back to themselves (e.g., user at TCW "1A" wants TCP "1A" returned to them). If tcp is specified, that TCP is deconsolidated back to its default TCW.

func (*Sim) DeleteAircraft

func (s *Sim) DeleteAircraft(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) DeleteAircraftSlice

func (s *Sim) DeleteAircraftSlice(tcw TCW, aircraft []Aircraft) error

func (*Sim) DeleteAllAircraft

func (s *Sim) DeleteAllAircraft(tcw TCW) error

func (*Sim) DeleteFlightPlan

func (s *Sim) DeleteFlightPlan(tcw TCW, acid ACID) error

func (*Sim) DeleteRestrictionArea

func (s *Sim) DeleteRestrictionArea(idx int) error

func (*Sim) DepartFixDirect

func (s *Sim) DepartFixDirect(tcw TCW, callsign av.ADSBCallsign, fixa string, fixb string) error

func (*Sim) DepartFixHeading

func (s *Sim) DepartFixHeading(tcw TCW, callsign av.ADSBCallsign, fix string, heading int) error

func (*Sim) DescendViaSTAR

func (s *Sim) DescendViaSTAR(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) Destroy

func (s *Sim) Destroy()

func (*Sim) DirectFix

func (s *Sim) DirectFix(tcw TCW, callsign av.ADSBCallsign, fix string) error

func (*Sim) ExpectApproach

func (s *Sim) ExpectApproach(tcw TCW, callsign av.ADSBCallsign, approach string) error

func (*Sim) ExpediteClimb

func (s *Sim) ExpediteClimb(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) ExpediteDescent

func (s *Sim) ExpediteDescent(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) FastForward

func (s *Sim) FastForward()

func (*Sim) FlightPlanDirect added in v0.13.0

func (s *Sim) FlightPlanDirect(tcp TCP, fix string, acid ACID) error

TODO: Migrate to ERAM computer.

func (*Sim) ForceQL

func (s *Sim) ForceQL(tcw TCW, acid ACID, controller TCP) error

func (*Sim) GetAircraftDisplayState

func (s *Sim) GetAircraftDisplayState(callsign av.ADSBCallsign) (AircraftDisplayState, error)

func (*Sim) GetControllerVideoMaps added in v0.13.3

func (s *Sim) GetControllerVideoMaps(tcw TCW) (videoMaps, defaultMaps []string, beaconCodes []av.Squawk)

GetControllerVideoMaps returns the video map configuration for the given TCW. Returns controller-specific config if available, otherwise facility defaults.

func (*Sim) GetCurrentConsolidation added in v0.13.3

func (s *Sim) GetCurrentConsolidation() map[TCW]*TCPConsolidation

func (*Sim) GetDepartureController added in v0.13.3

func (s *Sim) GetDepartureController(airport, runway, sid string) TCP

GetDepartureController returns the TCP responsible for a departure given the airport, runway, and SID. Checks in order: airport/SID, airport/runway, airport only.

func (*Sim) GetFlightPlanForACID

func (s *Sim) GetFlightPlanForACID(acid ACID) (*NASFlightPlan, *Aircraft, bool)

*Aircraft may be nil. bool indicates whether the flight plan is active.

func (*Sim) GetPositionsForTCW added in v0.13.3

func (s *Sim) GetPositionsForTCW(tcw TCW) []ControlPosition

GetConsolidatedPositions returns all positions controlled by a TCW

func (*Sim) GetSerializeSim

func (s *Sim) GetSerializeSim() Sim

func (*Sim) GetStateUpdate

func (s *Sim) GetStateUpdate() StateUpdate

func (*Sim) GetTrafficCounts added in v0.13.3

func (s *Sim) GetTrafficCounts() (ifr, vfr int)

GetTrafficCounts returns the current IFR and VFR traffic counts.

func (*Sim) GetUserState added in v0.13.3

func (s *Sim) GetUserState() *UserState

GetUserState returns a deep copy of the simulation state for a client. Server-only fields (like Airport.Departures) are pruned to reduce bandwidth.

func (*Sim) GlobalMessage

func (s *Sim) GlobalMessage(tcw TCW, message string)

func (*Sim) GoAhead added in v0.13.3

func (s *Sim) GoAhead(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) GoAround

func (s *Sim) GoAround(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) HandoffTrack

func (s *Sim) HandoffTrack(tcw TCW, acid ACID, toTCP TCP) error

func (*Sim) HoldAtFix added in v0.13.0

func (s *Sim) HoldAtFix(tcw TCW, callsign av.ADSBCallsign, fix string, hold *av.Hold) error

func (*Sim) Ident

func (s *Sim) Ident(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) IdleTime

func (s *Sim) IdleTime() time.Duration

func (*Sim) InterceptLocalizer

func (s *Sim) InterceptLocalizer(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) LaunchAircraft

func (s *Sim) LaunchAircraft(ac Aircraft, departureRunway string)

func (*Sim) LogValue

func (s *Sim) LogValue() slog.Value

func (*Sim) MaintainMaximumForward

func (s *Sim) MaintainMaximumForward(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) MaintainSlowestPractical

func (s *Sim) MaintainSlowestPractical(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) ModifyFlightPlan

func (s *Sim) ModifyFlightPlan(tcw TCW, acid ACID, spec FlightPlanSpecifier) error

func (*Sim) PilotMixUp added in v0.13.2

func (s *Sim) PilotMixUp(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) PointOut

func (s *Sim) PointOut(fromTCW TCW, acid ACID, toTCP TCP) error

func (*Sim) PostEvent

func (s *Sim) PostEvent(e Event)

func (*Sim) Prespawn

func (s *Sim) Prespawn()

func (*Sim) RadarServicesTerminated

func (s *Sim) RadarServicesTerminated(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) RecallPointOut

func (s *Sim) RecallPointOut(tcw TCW, acid ACID) error

func (*Sim) RedirectHandoff

func (s *Sim) RedirectHandoff(tcw TCW, acid ACID, controller TCP) error

func (*Sim) RejectPointOut

func (s *Sim) RejectPointOut(tcw TCW, acid ACID) error

func (*Sim) ReleaseDeparture

func (s *Sim) ReleaseDeparture(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) ReplayScenario added in v0.13.0

func (s *Sim) ReplayScenario(waypointCommands string, durationSpec string, lg *log.Logger) error

func (*Sim) RepositionTrack

func (s *Sim) RepositionTrack(tcw TCW, acid ACID, callsign av.ADSBCallsign, p math.Point2LL) error

func (*Sim) RequestFlightFollowing

func (s *Sim) RequestFlightFollowing() error

func (*Sim) ResumeOwnNavigation

func (s *Sim) ResumeOwnNavigation(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) RunAircraftControlCommands added in v0.13.0

func (s *Sim) RunAircraftControlCommands(tcw TCW, callsign av.ADSBCallsign, commandStr string) ControlCommandsResult

RunAircraftControlCommands executes a space-separated string of control commands for an aircraft. Returns the remaining unparsed input and any error that occurred. This is the core command execution logic shared by the dispatcher and automated test code.

func (*Sim) SayAltitude

func (s *Sim) SayAltitude(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) SayHeading

func (s *Sim) SayHeading(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) SaySpeed

func (s *Sim) SaySpeed(tcw TCW, callsign av.ADSBCallsign) error

func (*Sim) ScenarioRootPosition added in v0.13.3

func (s *Sim) ScenarioRootPosition() TCP

ScenarioRootPosition returns the root position from the scenario's default consolidation.

func (*Sim) SendRouteCoordinates added in v0.13.0

func (s *Sim) SendRouteCoordinates(tcw TCW, acid ACID) error

TODO: Migrate to ERAM computer.

func (*Sim) SetLaunchConfig

func (s *Sim) SetLaunchConfig(tcw TCW, lc LaunchConfig) error

func (*Sim) SetPausedByServer added in v0.13.3

func (s *Sim) SetPausedByServer(paused bool)

SetPausedByServer allows the server to pause/unpause the sim when humans connect or disconnect.

func (*Sim) SetPrivilegedTCW added in v0.13.3

func (s *Sim) SetPrivilegedTCW(tcw TCW, privileged bool)

SetPrivilegedTCW sets or clears privileged (instructor) status for a TCW. Privileged TCWs can control any aircraft regardless of which position owns it.

func (*Sim) SetSimRate

func (s *Sim) SetSimRate(tcw TCW, rate float32) error

func (*Sim) SetWaypointCommands added in v0.13.0

func (s *Sim) SetWaypointCommands(tcw TCW, commands string) error

func (*Sim) ShouldTriggerPilotMixUp added in v0.13.2

func (s *Sim) ShouldTriggerPilotMixUp(callsign av.ADSBCallsign) bool

func (*Sim) SignOn

func (s *Sim) SignOn(tcw TCW, tcps []TCP) (*UserState, *EventsSubscription, error)

SignOn returns state and event subscription for a controller at the given TCW and consolidates the provided TCPs.

func (*Sim) Step

func (s *Sim) Step(elapsed time.Duration) bool

Step advances the simulation by the given elapsed time duration. This method encapsulates the core simulation stepping logic that was previously inline in Update().

func (*Sim) Subscribe added in v0.13.3

func (s *Sim) Subscribe() *EventsSubscription

Subscribe creates a new event subscription for this simulation. The caller is responsible for calling Unsubscribe when done.

func (*Sim) TCWCanCommandAircraft added in v0.13.3

func (s *Sim) TCWCanCommandAircraft(tcw TCW, fp *NASFlightPlan) bool

TCWCanCommandAircraft returns true if the TCW can issue ATC commands to an aircraft (altitude, heading, speed, etc.). This is true if the TCW is privileged, owns the track, or controls the ControllingController position.

func (*Sim) TCWCanModifyFlightPlan added in v0.13.3

func (s *Sim) TCWCanModifyFlightPlan(tcw TCW, fp *NASFlightPlan) bool

TCWCanModifyFlightPlan returns true if the TCW can access/modify flight plan fields. Checks if TCW controls the owner's position (consolidation-aware). This is true if the TCW is privileged, owns the track, or controls the position that owns the track.

func (*Sim) TCWCanModifyTrack added in v0.13.3

func (s *Sim) TCWCanModifyTrack(tcw TCW, fp *NASFlightPlan) bool

TCWCanModifyTrack returns true if the TCW can modify the track itself (delete, reposition). This is true if the TCW is privileged, owns the track, or controls the TrackingController position.

func (*Sim) TCWControlsPosition added in v0.13.3

func (s *Sim) TCWControlsPosition(tcw TCW, pos ControlPosition) bool

TCWControlsPosition returns true if the given TCW controls the specified position. Thread-safe wrapper around State.TCWControlsPosition.

func (*Sim) TCWForPosition added in v0.13.3

func (s *Sim) TCWForPosition(pos ControlPosition) TCW

func (*Sim) TakeOrReturnLaunchControl

func (s *Sim) TakeOrReturnLaunchControl(tcw TCW) error

func (*Sim) TogglePause

func (s *Sim) TogglePause()

func (*Sim) TriggerEmergency added in v0.13.2

func (s *Sim) TriggerEmergency(name string)

func (*Sim) Update

func (s *Sim) Update()

func (*Sim) UpdateRestrictionArea

func (s *Sim) UpdateRestrictionArea(idx int, ra av.RestrictionArea) error

type StateUpdate

type StateUpdate struct {
	DynamicState
	DerivedState
}

StateUpdate encapsulates the simulation state data sent from server to client each tick.

type TCP added in v0.13.3

type TCP = ControlPosition

TCP is an alias for ControlPosition, provided for clarity in STARS-specific code. Use TCP when the code is explicitly STARS-related; use ControlPosition for code that handles both STARS and ERAM controllers.

type TCPConsolidation added in v0.13.3

type TCPConsolidation struct {
	PrimaryTCP    TCP
	SecondaryTCPs []SecondaryTCP
}

TCPConsolidation tracks the consolidation state for a single TCW (terminal controller workstation). A TCW may have a primary position and zero or more secondary positions consolidated to it. TCW entries persist regardless of whether a human is signed in - they represent physical workstations. This is STARS-specific functionality.

func (*TCPConsolidation) ControlsPosition added in v0.13.3

func (tc *TCPConsolidation) ControlsPosition(pos ControlPosition) bool

ControlsPosition returns true if this TCW controls the given position (either as primary or as one of its secondary positions).

func (*TCPConsolidation) OwnedPositions added in v0.13.3

func (tc *TCPConsolidation) OwnedPositions() []ControlPosition

OwnedPositions returns all positions controlled by this TCW (primary + all secondaries).

type TCW added in v0.13.3

type TCW string

TCW is a Terminal Controller Workstation identifier - a physical display and keyboard. A TCW can control zero, one, or more positions. This is STARS-specific; ERAM does not have the same consolidation model. For ERAM for now this is the same as the position the user is covering.

type TTSProvider

type TTSProvider interface {
	GetAllVoices() TTSVoicesFuture
	TextToSpeech(voice Voice, text string) TTSSpeechFuture
}

type TTSSpeechFuture

type TTSSpeechFuture struct {
	Mp3Ch <-chan []byte
	ErrCh <-chan error
}

type TTSVoicesFuture

type TTSVoicesFuture struct {
	VoicesCh <-chan []Voice
	ErrCh    <-chan error
}

type Track

type Track struct {
	av.RadarTrack

	FlightPlan *NASFlightPlan

	// Sort of hacky to carry these along here but it's convenient...
	DepartureAirport          string
	DepartureAirportElevation float32
	DepartureAirportLocation  math.Point2LL
	ArrivalAirport            string
	ArrivalAirportElevation   float32
	ArrivalAirportLocation    math.Point2LL
	FiledRoute                string
	FiledAltitude             int
	OnExtendedCenterline      bool
	OnApproach                bool
	ATPAVolume                *av.ATPAVolume
	MVAsApply                 bool
	HoldForRelease            bool
	MissingFlightPlan         bool
	Route                     []math.Point2LL
	IsTentative               bool // first 5 seconds after first contact
}

func (*Track) IsArrival

func (t *Track) IsArrival() bool

func (*Track) IsAssociated

func (t *Track) IsAssociated() bool

func (*Track) IsDeparture

func (t *Track) IsDeparture() bool

func (*Track) IsOverflight

func (t *Track) IsOverflight() bool

func (*Track) IsUnassociated

func (t *Track) IsUnassociated() bool

func (*Track) IsUnsupportedDB

func (t *Track) IsUnsupportedDB() bool

type UserState added in v0.13.3

type UserState struct {
	CommonState
	DerivedState
}

UserState is the simulation-related state provided to a user on the client-side.

type VideoMap

type VideoMap struct {
	Label       string // for DCB
	Group       int    // 0 -> A, 1 -> B
	Name        string // For maps system list
	Id          int
	Category    int
	Restriction struct {
		Id        int
		Text      [2]string
		TextBlink bool
		HideText  bool
	}
	Color int
	Lines [][]math.Point2LL
}

Note: this should match ViceMapSpec/VideoMap in crc2vice/dat2vice. (crc2vice doesn't support all of these, though.)

type VideoMapLibrary

type VideoMapLibrary struct {
	Maps          []VideoMap
	ERAMMapGroups ERAMMapGroups
}

This should match VideoMapLibrary in dat2vice

func HashCheckLoadVideoMap

func HashCheckLoadVideoMap(path string, wantHash []byte) (*VideoMapLibrary, error)

Loads the specified video map file, though only if its hash matches the provided hash. Returns an error otherwise.

func LoadVideoMapLibrary

func LoadVideoMapLibrary(path string) (*VideoMapLibrary, error)

type VideoMapManifest

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

VideoMapManifest stores which maps are available in a video map file and is also able to provide the video map file's hash.

func LoadVideoMapManifest

func LoadVideoMapManifest(filename string) (*VideoMapManifest, error)

func (VideoMapManifest) HasMap

func (v VideoMapManifest) HasMap(s string) bool

func (VideoMapManifest) HasMapGroup added in v0.13.0

func (v VideoMapManifest) HasMapGroup(s string) bool

func (VideoMapManifest) Hash

func (v VideoMapManifest) Hash() ([]byte, error)

Hash returns a hash of the underlying video map file (i.e., not the manifest!)

type Voice

type Voice string

Jump to

Keyboard shortcuts

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