sim

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LaunchAutomatic int32 = iota
	LaunchManual
)

Variables

View Source
var (
	ErrAircraftAlreadyReleased         = errors.New("Aircraft already released")
	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")
	ErrNoMatchingFlight                = errors.New("No matching flight")
	ErrNoMatchingFlightPlan            = errors.New("No matching flight plan")
	ErrNoMoreListIndices               = errors.New("No more list indices")
	ErrNoVFRAircraftForFlightFollowing = errors.New("No VFR aircraft available for flight following")
	ErrNotLaunchController             = errors.New("Not signed in as the launch controller")
	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")
	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")
)

Functions

func CheckVideoMapManifest added in v0.12.0

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

func IsValidACID added in v0.12.0

func IsValidACID(acid string) bool

func PrintVideoMaps added in v0.12.0

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

Types

type ACID

type ACID string

type Aircraft added in v0.12.0

type Aircraft struct {
	av.Aircraft

	STARSFlightPlan *STARSFlightPlan

	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
	ApproachController string

	// Who had control when the fp disassociated due to an arrival filter.
	PreArrivalDropController string

	InDepartureFilter bool

	FirstSeen time.Time

	RequestedFlightFollowing bool
}

func (*Aircraft) AssociateFlightPlan added in v0.12.0

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

func (*Aircraft) DisassociateFlightPlan added in v0.12.0

func (ac *Aircraft) DisassociateFlightPlan() *STARSFlightPlan

func (*Aircraft) IsAssociated added in v0.12.0

func (ac *Aircraft) IsAssociated() bool

func (*Aircraft) IsUnassociated added in v0.12.0

func (ac *Aircraft) IsUnassociated() bool

type AircraftDisplayState added in v0.12.0

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 added in v0.11.9

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

type CoordinationList added in v0.11.5

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

type DepartureAircraft added in v0.11.5

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 added in v0.11.9

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

	ExitRoutes map[string]*av.ExitRoute // copied from airport's  departure_routes
}

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 added in v0.11.9

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

func (*ERAMComputer) Update

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

type Event

type Event struct {
	Type                  EventType
	ADSBCallsign          av.ADSBCallsign
	ACID                  ACID
	FromController        string
	ToController          string // For radio transmissions, the controlling controller.
	Message               string
	RadioTransmissionType av.RadioTransmissionType       // For radio transmissions only
	LeaderLineDirection   *math.CardinalOrdinalDirection // SetGlobalLeaderLineEvent
}

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) 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
	ServerBroadcastMessageEvent
	GlobalMessageEvent
	AcknowledgedPointOutEvent
	RejectedPointOutEvent
	HandoffControlEvent
	SetGlobalLeaderLineEvent
	ForceQLEvent
	TransferAcceptedEvent
	TransferRejectedEvent
	RecalledPointOutEvent
	FlightPlanAssociatedEvent
	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 FilterRegion added in v0.12.0

type FilterRegion struct {
	av.AirspaceVolume
	InvertTest bool
}

func (FilterRegion) Inside added in v0.12.0

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

type FilterRegions added in v0.12.0

type FilterRegions []FilterRegion

func (FilterRegions) HaveId added in v0.12.0

func (r FilterRegions) HaveId(s string) bool

func (FilterRegions) Inside added in v0.12.0

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

type FutureChangeSquawk added in v0.11.8

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

type FutureControllerContact added in v0.11.7

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

type FutureOnCourse added in v0.11.7

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

type GlobalMessage

type GlobalMessage struct {
	Message        string
	FromController string
}

type Handoff

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

type HeadingArgs

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

type LaunchConfig

type LaunchConfig struct {
	// Controller is the controller in charge of the launch settings; if empty then
	// launch control may be taken by any signed in controller.
	Controller string
	// LaunchManual or LaunchAutomatic
	Mode int32

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

	VFRDepartureRateScale   float32
	VFRAirports             map[string]*av.Airport
	VFFRequestRate          int32
	HaveVFRReportingRegions bool

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

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

type NewSimConfiguration

type NewSimConfiguration struct {
	TRACON      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[string]*av.Controller
	PrimaryController  string
	ControllerAirspace map[string][]string
	VirtualControllers []string
	MultiControllers   av.SplitConfiguration
	SignOnPositions    map[string]*av.Controller

	TFRs                    []av.TFR
	LiveWeather             bool
	Wind                    av.Wind
	STARSFacilityAdaptation STARSFacilityAdaptation
	IsLocal                 bool

	ReportingPoints   []av.ReportingPoint
	MagneticVariation float32
	NmPerLongitude    float32
	Center            math.Point2LL
	Range             float32
	DefaultMaps       []string
	Airspace          av.Airspace
}

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

type PointOut

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

type RedirectedHandoff added in v0.12.0

type RedirectedHandoff struct {
	OriginalOwner string   // Controller callsign
	Redirector    []string // Controller callsign
	RedirectedTo  string   // Controller callsign
}

func (*RedirectedHandoff) AddRedirector added in v0.12.0

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

func (*RedirectedHandoff) GetLastRedirector added in v0.12.0

func (rd *RedirectedHandoff) GetLastRedirector() string

func (*RedirectedHandoff) ShouldFallbackToHandoff added in v0.12.0

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

func (*RedirectedHandoff) ShowRDIndicator added in v0.12.0

func (rd *RedirectedHandoff) ShowRDIndicator(callsign string, RDIndicatorEnd time.Time) bool

type ReleaseDeparture added in v0.12.0

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

type RunwayLaunchState added in v0.11.9

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

	VFRAttempts  int
	VFRSuccesses int
}

func (RunwayLaunchState) Dump added in v0.12.0

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

type STARSComputer

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

func (*STARSComputer) AddHeldDeparture added in v0.11.5

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

func (*STARSComputer) CreateFlightPlan added in v0.12.0

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

func (*STARSComputer) GetReleaseDepartures added in v0.11.5

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

func (*STARSComputer) ReleaseDeparture added in v0.11.5

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

func (*STARSComputer) Update

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

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 STARSFacilityAdaptation

type STARSFacilityAdaptation struct {
	AirspaceAwareness   []AirspaceAwareness               `json:"airspace_awareness"`
	ForceQLToSelf       bool                              `json:"force_ql_self"`
	AllowLongScratchpad bool                              `json:"allow_long_scratchpad"`
	VideoMapNames       []string                          `json:"stars_maps"`
	VideoMapLabels      map[string]string                 `json:"map_labels"`
	ControllerConfigs   map[string]*STARSControllerConfig `json:"controller_configs"`
	RadarSites          map[string]*av.RadarSite          `json:"radar_sites"`
	Center              math.Point2LL                     `json:"-"`
	CenterString        string                            `json:"center"`
	Range               float32                           `json:"range"`
	Scratchpads         map[string]string                 `json:"scratchpads"`
	SignificantPoints   map[string]SignificantPoint       `json:"significant_points"`
	Altimeters          []string                          `json:"altimeters"`

	// Airpsace filters
	Filters struct {
		ArrivalAcquisition   FilterRegions `json:"arrival_acquisition"`
		ArrivalDrop          FilterRegions `json:"arrival_drop"`
		DepartureAcquisition FilterRegions `json:"departure_acquisition"`
		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"`

	MonitoredBeaconCodeBlocksString *string `json:"beacon_code_blocks"`
	MonitoredBeaconCodeBlocks       []av.Squawk

	VideoMapFile      string                        `json:"video_map_file"`
	CoordinationFixes map[string]av.AdaptationFixes `json:"coordination_fixes"`
	SingleCharAIDs    map[string]string             `json:"single_char_aids"` // Char to airport
	KeepLDB           bool                          `json:"keep_ldb"`
	FullLDBSeconds    int                           `json:"full_ldb_seconds"`

	SSRCodes av.LocalSquawkCodePoolSpecifier `json:"ssr_codes"`

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

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

	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"`

	FDB struct {
		DisplayRequestedAltitude bool `json:"display_requested_altitude"`
	} `json:"fdb"`

	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"`

	CustomSPCs []string `json:"custom_spcs"`

	CoordinationLists []CoordinationList   `json:"coordination_lists"`
	RestrictionAreas  []av.RestrictionArea `json:"restriction_areas"`
	UseLegacyFont     bool                 `json:"use_legacy_font"`
}

func (STARSFacilityAdaptation) CheckScratchpad added in v0.12.0

func (fa STARSFacilityAdaptation) CheckScratchpad(sp string) bool

func (*STARSFacilityAdaptation) PostDeserialize

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

type STARSFlightPlan

type STARSFlightPlan struct {
	ACID                  ACID
	EntryFix              string
	ExitFix               string
	ExitFixIsIntermediate bool
	Rules                 av.FlightRules
	CoordinationTime      time.Time
	PlanType              STARSFlightPlanType

	AssignedSquawk av.Squawk

	TrackingController     string // Who has the radar track
	ControllingController  string // Who has control; not necessarily the same as TrackingController
	HandoffTrackController string // Handoff offered but not yet accepted
	LastLocalController    string // (May be the current controller.)

	AircraftCount   int
	AircraftType    string
	EquipmentSuffix string

	TypeOfFlight av.TypeOfFlight

	AssignedAltitude      int
	RequestedAltitude     int
	PilotReportedAltitude int

	Scratchpad          string
	SecondaryScratchpad string

	RNAV bool

	Location math.Point2LL

	PointOutHistory             []string
	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 string

	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 (*STARSFlightPlan) Update added in v0.12.0

func (fp *STARSFlightPlan) Update(spec STARSFlightPlanSpecifier, localPool *av.LocalSquawkCodePool,
	nasPool *av.EnrouteSquawkCodePool) (err error)

type STARSFlightPlanSpecifier added in v0.12.0

type STARSFlightPlanSpecifier 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[STARSFlightPlanType]

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

	TrackingController util.Optional[string]

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

	TypeOfFlight util.Optional[av.TypeOfFlight]

	AssignedAltitude      util.Optional[int]
	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 (STARSFlightPlanSpecifier) GetFlightPlan added in v0.12.0

type STARSFlightPlanType added in v0.12.0

type STARSFlightPlanType int
const (
	UnknownFlightPlanType STARSFlightPlanType = 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 SignificantPoint added in v0.11.5

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 *State

	Aircraft map[av.ADSBCallsign]*Aircraft

	SignOnPositions map[string]*av.Controller

	STARSComputer *STARSComputer
	ERAMComputer  *ERAMComputer

	LocalCodePool *av.LocalSquawkCodePool

	GenerationIndex int // for sequencing StateUpdates

	VFRReportingPoints []av.VFRReportingPoint

	// 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

	FutureControllerContacts []FutureControllerContact
	FutureOnCourse           []FutureOnCourse
	FutureSquawkChanges      []FutureChangeSquawk

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

	Instructors map[string]bool

	Rand *rand.Rand
	// contains filtered or unexported fields
}

func NewSim

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

func (*Sim) AcceptHandoff

func (s *Sim) AcceptHandoff(tcp string, acid ACID) error

func (*Sim) AcceptRedirectedHandoff

func (s *Sim) AcceptRedirectedHandoff(tcp string, acid ACID) error

func (*Sim) AcknowledgePointOut

func (s *Sim) AcknowledgePointOut(tcp string, acid ACID) error

func (*Sim) Activate

func (s *Sim) Activate(lg *log.Logger)

func (*Sim) ActivateFlightPlan added in v0.12.0

func (s *Sim) ActivateFlightPlan(tcp string, callsign av.ADSBCallsign, acid ACID,
	spec *STARSFlightPlanSpecifier) error

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

func (*Sim) ActiveControllers added in v0.11.9

func (s *Sim) ActiveControllers() []string

func (*Sim) AltitudeOurDiscretion added in v0.12.0

func (s *Sim) AltitudeOurDiscretion(tcp string, callsign av.ADSBCallsign) error

func (*Sim) AssignAltitude

func (s *Sim) AssignAltitude(tcp string, 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(tcp string, callsign av.ADSBCallsign, speed int, afterAltitude bool) error

func (*Sim) AssociateFlightPlan added in v0.12.0

func (s *Sim) AssociateFlightPlan(callsign av.ADSBCallsign, spec STARSFlightPlanSpecifier) error

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

func (*Sim) AtFixCleared

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

func (*Sim) CallsignForACID added in v0.12.0

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

func (*Sim) CancelApproachClearance

func (s *Sim) CancelApproachClearance(tcp string, callsign av.ADSBCallsign) error

func (*Sim) CancelHandoff

func (s *Sim) CancelHandoff(tcp string, acid ACID) error

func (*Sim) ChangeControlPosition

func (s *Sim) ChangeControlPosition(fromTCP, toTCP string, keepTracks bool) error

func (*Sim) ChangeSquawk

func (s *Sim) ChangeSquawk(tcp string, callsign av.ADSBCallsign, sq av.Squawk) error

func (*Sim) ChangeTransponderMode added in v0.11.9

func (s *Sim) ChangeTransponderMode(tcp string, callsign av.ADSBCallsign, mode av.TransponderMode) error

func (*Sim) ClearedApproach

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

func (*Sim) ClimbViaSID

func (s *Sim) ClimbViaSID(tcp string, callsign av.ADSBCallsign) error

func (*Sim) ContactController added in v0.12.0

func (s *Sim) ContactController(tcp string, acid ACID, toTCP string) error

func (*Sim) ContactTower

func (s *Sim) ContactTower(tcp string, callsign av.ADSBCallsign) error

func (*Sim) ContactTrackingController added in v0.12.0

func (s *Sim) ContactTrackingController(tcp string, acid ACID) error

func (*Sim) CreateArrival

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

func (*Sim) CreateFlightPlan added in v0.12.0

func (s *Sim) CreateFlightPlan(tcp string, spec STARSFlightPlanSpecifier) error

func (*Sim) CreateIFRDeparture added in v0.11.9

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

func (*Sim) CreateOverflight added in v0.11.2

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

func (*Sim) CreateRestrictionArea added in v0.11.6

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

func (*Sim) CreateVFRDeparture added in v0.11.9

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(tcp string, callsign av.ADSBCallsign, fix string, ar *av.AltitudeRestriction, speed int) error

func (*Sim) DeleteAircraft

func (s *Sim) DeleteAircraft(tcp string, callsign av.ADSBCallsign) error

func (*Sim) DeleteAircraftSlice added in v0.12.0

func (s *Sim) DeleteAircraftSlice(tcp string, aircraft []Aircraft) error

func (*Sim) DeleteAllAircraft

func (s *Sim) DeleteAllAircraft(tcp string) error

func (*Sim) DeleteFlightPlan added in v0.12.0

func (s *Sim) DeleteFlightPlan(tcp string, acid ACID) error

func (*Sim) DeleteRestrictionArea added in v0.11.6

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

func (*Sim) DepartFixDirect

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

func (*Sim) DepartFixHeading

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

func (*Sim) DescendViaSTAR

func (s *Sim) DescendViaSTAR(tcp string, callsign av.ADSBCallsign) error

func (*Sim) DirectFix

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

func (*Sim) ExpectApproach

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

func (*Sim) ExpediteClimb

func (s *Sim) ExpediteClimb(tcp string, callsign av.ADSBCallsign) error

func (*Sim) ExpediteDescent

func (s *Sim) ExpediteDescent(tcp string, callsign av.ADSBCallsign) error

func (*Sim) FastForward added in v0.12.0

func (s *Sim) FastForward(tcp string) error

func (*Sim) ForceQL

func (s *Sim) ForceQL(tcp string, acid ACID, controller string) error

func (*Sim) GetAircraftDisplayState added in v0.12.0

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

func (*Sim) GetAvailableCoveredPositions added in v0.11.9

func (s *Sim) GetAvailableCoveredPositions() (map[string]av.Controller, map[string]av.Controller)

func (*Sim) GetFlightPlanForACID added in v0.12.0

func (s *Sim) GetFlightPlanForACID(acid ACID) (*STARSFlightPlan, bool)

bool indicates whether it's active

func (*Sim) GetSerializeSim added in v0.11.9

func (s *Sim) GetSerializeSim() Sim

func (*Sim) GetStateUpdate added in v0.12.0

func (s *Sim) GetStateUpdate(tcp string, update *StateUpdate)

func (*Sim) GlobalMessage

func (s *Sim) GlobalMessage(tcp, message string) error

func (*Sim) GoAround

func (s *Sim) GoAround(tcp string, callsign av.ADSBCallsign) error

func (*Sim) HandoffTrack

func (s *Sim) HandoffTrack(tcp string, acid ACID, toTCP string) error

func (*Sim) Ident

func (s *Sim) Ident(tcp string, callsign av.ADSBCallsign) error

func (*Sim) IdleTime

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

func (*Sim) InterceptLocalizer

func (s *Sim) InterceptLocalizer(tcp string, 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(tcp string, callsign av.ADSBCallsign) error

func (*Sim) MaintainSlowestPractical

func (s *Sim) MaintainSlowestPractical(tcp string, callsign av.ADSBCallsign) error

func (*Sim) ModifyFlightPlan added in v0.12.0

func (s *Sim) ModifyFlightPlan(tcp string, acid ACID, spec STARSFlightPlanSpecifier) error

func (*Sim) PointOut

func (s *Sim) PointOut(fromTCP string, acid ACID, toTCP string) error

func (*Sim) PostEvent

func (s *Sim) PostEvent(e Event)

func (*Sim) Prespawn added in v0.11.9

func (s *Sim) Prespawn()

func (*Sim) RadarServicesTerminated added in v0.12.0

func (s *Sim) RadarServicesTerminated(tcp string, callsign av.ADSBCallsign) error

func (*Sim) RecallPointOut added in v0.11.8

func (s *Sim) RecallPointOut(tcp string, acid ACID) error

func (*Sim) RedirectHandoff

func (s *Sim) RedirectHandoff(tcp string, acid ACID, controller string) error

func (*Sim) RejectPointOut

func (s *Sim) RejectPointOut(tcp string, acid ACID) error

func (*Sim) ReleaseDeparture added in v0.11.5

func (s *Sim) ReleaseDeparture(tcp string, callsign av.ADSBCallsign) error

func (*Sim) RepositionTrack added in v0.12.0

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

func (*Sim) RequestFlightFollowing added in v0.12.0

func (s *Sim) RequestFlightFollowing() error

func (*Sim) ResumeOwnNavigation added in v0.12.0

func (s *Sim) ResumeOwnNavigation(tcp string, callsign av.ADSBCallsign) error

func (*Sim) SayAltitude

func (s *Sim) SayAltitude(tcp string, callsign av.ADSBCallsign) error

func (*Sim) SayHeading

func (s *Sim) SayHeading(tcp string, callsign av.ADSBCallsign) error

func (*Sim) SaySpeed

func (s *Sim) SaySpeed(tcp string, callsign av.ADSBCallsign) error

func (*Sim) SetLaunchConfig

func (s *Sim) SetLaunchConfig(tcp string, lc LaunchConfig) error

func (*Sim) SetSimRate

func (s *Sim) SetSimRate(tcp string, rate float32) error

func (*Sim) SignOff

func (s *Sim) SignOff(tcp string) error

func (*Sim) SignOn

func (s *Sim) SignOn(tcp string, instructor bool) (*State, error)

func (*Sim) TakeOrReturnLaunchControl

func (s *Sim) TakeOrReturnLaunchControl(tcp string) error

func (*Sim) TogglePause

func (s *Sim) TogglePause(tcp string) error

func (*Sim) Update

func (s *Sim) Update()

func (*Sim) UpdateRestrictionArea added in v0.11.6

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

type State

type State struct {
	Tracks map[av.ADSBCallsign]*Track

	// Unassociated ones, including unsupported DBs
	UnassociatedFlightPlans []*STARSFlightPlan

	ACFlightPlans map[av.ADSBCallsign]av.FlightPlan // needed for flight strips...

	Airports          map[string]*av.Airport
	DepartureAirports map[string]*av.Airport
	ArrivalAirports   map[string]*av.Airport
	Fixes             map[string]math.Point2LL
	VFRRunways        map[string]av.Runway // assume just one runway per airport
	ReleaseDepartures []ReleaseDeparture

	// Signed in human controllers + virtual controllers
	Controllers      map[string]*av.Controller
	HumanControllers []string

	PrimaryController string
	MultiControllers  av.SplitConfiguration
	UserTCP           string
	Airspace          map[string]map[string][]av.ControllerAirspaceVolume // ctrl id -> vol name -> definition

	GenerationIndex int

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

	Center                   math.Point2LL
	Range                    float32
	ScenarioDefaultVideoMaps []string
	UserRestrictionAreas     []av.RestrictionArea

	STARSFacilityAdaptation STARSFacilityAdaptation

	TRACON            string
	MagneticVariation float32
	NmPerLongitude    float32
	PrimaryAirport    string

	METAR map[string]*av.METAR
	Wind  av.Wind

	TotalIFR, TotalVFR int

	Paused         bool
	SimRate        float32
	SimDescription string
	SimTime        time.Time // this is our fake time--accounting for pauses & simRate..

	QuickFlightPlanIndex int // for auto ACIDs for quick ACID flight plan 5-145

	Instructors map[string]bool

	VideoMapLibraryHash []byte

	// Set in State returned by GetStateForController
	ControllerVideoMaps                 []string
	ControllerDefaultVideoMaps          []string
	ControllerMonitoredBeaconCodeBlocks []av.Squawk
}

State serves two purposes: first, the Sim object holds one to organize assorted information about the world state that it updates as part of the simulation. Second, an instance of it is given to clients when they join a sim. As the sim runs, the client's State is updated roughly once a second. Clients can then use the State as a read-only reference for assorted information they may need (the state of aircraft in the sim, etc.)

func (*State) AmInstructor added in v0.11.7

func (ss *State) AmInstructor() bool

func (*State) AverageWindVector

func (ss *State) AverageWindVector() [2]float32

func (*State) BeaconCodeInUse added in v0.12.0

func (ss *State) BeaconCodeInUse(sq av.Squawk) bool

func (*State) FacilityFromController

func (ss *State) FacilityFromController(callsign string) (string, bool)

func (*State) FindMatchingFlightPlan added in v0.12.0

func (ss *State) FindMatchingFlightPlan(s string) *STARSFlightPlan

func (*State) GetAllReleaseDepartures added in v0.11.6

func (ss *State) GetAllReleaseDepartures() []ReleaseDeparture

func (*State) GetConsolidatedPositions added in v0.11.7

func (ss *State) GetConsolidatedPositions(id string) []string

func (*State) GetFlightPlanForACID added in v0.12.0

func (ss *State) GetFlightPlanForACID(acid ACID) *STARSFlightPlan

FOOTGUN: this should not be called from server-side code, since Tracks isn't initialized there. FIXME FIXME FIXME

func (*State) GetInitialCenter

func (ss *State) GetInitialCenter() math.Point2LL

func (*State) GetInitialRange

func (ss *State) GetInitialRange() float32

func (*State) GetOurTrackByACID added in v0.12.0

func (ss *State) GetOurTrackByACID(acid ACID) (*Track, bool)

func (*State) GetOurTrackByCallsign added in v0.12.0

func (ss *State) GetOurTrackByCallsign(callsign av.ADSBCallsign) (*Track, bool)

func (*State) GetRegularReleaseDepartures added in v0.11.6

func (ss *State) GetRegularReleaseDepartures() []ReleaseDeparture

func (*State) GetSTARSReleaseDepartures added in v0.11.6

func (ss *State) GetSTARSReleaseDepartures() []ReleaseDeparture

func (*State) GetStateForController

func (s *State) GetStateForController(tcp string) *State

func (*State) GetTrackByACID added in v0.12.0

func (ss *State) GetTrackByACID(acid ACID) (*Track, bool)

func (*State) GetTrackByCallsign added in v0.12.0

func (ss *State) GetTrackByCallsign(callsign av.ADSBCallsign) (*Track, bool)

func (*State) GetWindVector

func (ss *State) GetWindVector(p math.Point2LL, alt float32) [2]float32

func (*State) IsExternalController added in v0.12.0

func (ss *State) IsExternalController(tcp string) bool

func (*State) IsLocalController added in v0.12.0

func (ss *State) IsLocalController(tcp string) bool

func (*State) Locate

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

func (*State) ResolveController added in v0.12.0

func (ss *State) ResolveController(tcp string) string

type StateUpdate added in v0.12.0

type StateUpdate struct {
	GenerationIndex         int
	Tracks                  map[av.ADSBCallsign]*Track
	UnassociatedFlightPlans []*STARSFlightPlan
	ACFlightPlans           map[av.ADSBCallsign]av.FlightPlan
	ReleaseDepartures       []ReleaseDeparture

	Controllers      map[string]*av.Controller
	HumanControllers []string

	Time time.Time

	LaunchConfig LaunchConfig

	UserRestrictionAreas []av.RestrictionArea

	SimIsPaused          bool
	SimRate              float32
	TotalIFR, TotalVFR   int
	Events               []Event
	Instructors          map[string]bool
	QuickFlightPlanIndex int
}

func (*StateUpdate) Apply added in v0.12.0

func (su *StateUpdate) Apply(state *State, eventStream *EventStream)

type Track added in v0.12.0

type Track struct {
	av.RadarTrack

	FlightPlan *STARSFlightPlan

	// 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
	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) HandingOffTo added in v0.12.0

func (t *Track) HandingOffTo(tcp string) bool

func (*Track) IsArrival added in v0.12.0

func (t *Track) IsArrival() bool

func (*Track) IsAssociated added in v0.12.0

func (t *Track) IsAssociated() bool

func (*Track) IsDeparture added in v0.12.0

func (t *Track) IsDeparture() bool

func (*Track) IsOverflight added in v0.12.0

func (t *Track) IsOverflight() bool

func (*Track) IsUnassociated added in v0.12.0

func (t *Track) IsUnassociated() bool

func (*Track) IsUnsupportedDB added in v0.12.0

func (t *Track) IsUnsupportedDB() bool

type VideoMap added in v0.12.0

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

	CommandBuffer renderer.CommandBuffer
}

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

type VideoMapLibrary added in v0.12.0

type VideoMapLibrary struct {
	Maps []VideoMap
}

This should match VideoMapLibrary in dat2vice

func HashCheckLoadVideoMap added in v0.12.0

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 added in v0.12.0

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

type VideoMapManifest added in v0.12.0

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 added in v0.12.0

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

func (VideoMapManifest) HasMap added in v0.12.0

func (v VideoMapManifest) HasMap(s string) bool

func (VideoMapManifest) Hash added in v0.12.0

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

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

Jump to

Keyboard shortcuts

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