sim

package
v0.11.10 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitiatedTrackEvent = iota
	DroppedTrackEvent
	PushedFlightStripEvent
	PointOutEvent
	OfferedHandoffEvent
	AcceptedHandoffEvent
	AcceptedRedirectedHandoffEvent
	CanceledHandoffEvent
	RejectedHandoffEvent
	RadioTransmissionEvent
	StatusMessageEvent
	ServerBroadcastMessageEvent
	GlobalMessageEvent
	AcknowledgedPointOutEvent
	RejectedPointOutEvent
	IdentEvent
	HandoffControlEvent
	SetGlobalLeaderLineEvent
	TrackClickedEvent
	ForceQLEvent
	TransferAcceptedEvent
	TransferRejectedEvent
	RecalledPointOutEvent
	NumEventTypes
)
View Source
const (
	Unset             = iota // Have this so we can catch unset types.
	Plan                     // Both STARS & ERAM send this.
	Amendment                // ERAM (STARS?)
	Cancellation             // ERAM (STARS?)
	RequestFlightPlan        // STARS
	DepartureDM              // STARS
	BeaconTerminate          // STARS

	InitiateTransfer     // When handoff gets sent. Sends the flightplan, contains track location
	AcceptRecallTransfer // Accept/ recall handoff

)

Message types sent from either ERAM or STARS

View Source
const (
	DepartureTime  = "P"
	ArrivalTime    = "A"
	OverflightTime = "E"
)
View Source
const (
	ACID = iota
	BCN
	ControllingPosition
	TypeOfFlight // Figure out this
	SC1
	SC2
	AircraftType
	RequestedALT
	Rules
	DepartureAirport // Specified with type of flight (maybe)
	Errors
)
View Source
const (
	LaunchAutomatic = iota
	LaunchManual
)
View Source
const STARSTriangleCharacter = string(rune(0x80))

FIXME: yuck, duplicated here

View Source
const TransmitFPMessageTime = 30 * time.Minute

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")
	ErrIllegalACID                 = errors.New("Illegal ACID")
	ErrIllegalACType               = errors.New("Illegal aircraft type")
	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")
	ErrNotLaunchController         = errors.New("Not signed in as the launch controller")
	ErrTooManyRestrictionAreas     = errors.New("Too many restriction areas specified")
	ErrUnknownController           = errors.New("Unknown controller")
	ErrUnknownControllerFacility   = errors.New("Unknown controller facility")
	ErrViolatedAirspace            = errors.New("Violated B/C airspace")
	ErrVFRSimTookTooLong           = errors.New("VFR simulation took too long")
)

Functions

func MakeSTARSFlightPlanFromAbbreviated

func MakeSTARSFlightPlanFromAbbreviated(abbr string, stars *STARSComputer, facilityAdaptation av.STARSFacilityAdaptation) (*av.STARSFlightPlan, error)

Types

type AbbreviatedFPFields

type AbbreviatedFPFields struct {
	ACID                string
	BCN                 av.Squawk
	ControllingPosition string
	TypeOfFlight        string // Figure out this
	SC1                 string
	SC2                 string
	AircraftType        string
	RequestedALT        string
	Rules               av.FlightRules
	DepartureAirport    string // Specified with type of flight (maybe)

	// TODO: why is there an error stored here (vs just returned from the
	// parsing function)?
	Error error
}

func ParseAbbreviatedFPFields

func ParseAbbreviatedFPFields(facilityAdaptation av.STARSFacilityAdaptation, fields []string) AbbreviatedFPFields

type AircraftDataMessage

type AircraftDataMessage struct {
	DepartureLocation string // Only for departures.
	ArrivalLocation   string // Only for arrivals. I think this is made up, but I don't know where to get the arrival info from.
	NumberOfAircraft  int    // Default this at one for now.
	AircraftType      string // A20N, B737, etc.

	// V = VFR (not heavy jet),
	// H = Heavy,
	// W = Heavy + VFR,
	// U = Heavy + OTP.
	AircraftCategory string
	Equipment        string // /L, /G, /A, etc
}

type ArrivalRunway added in v0.11.9

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

type DepartureAircraft added in v0.11.5

type DepartureAircraft struct {
	Callsign      string
	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.

	// HFR-only.
	AddedToList        bool
	ReleaseRequested   bool
	ReleaseDelay       time.Duration // minimum wait after release before the takeoff roll
	AddToHFRListTime   time.Time
	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 {
	STARSComputers   map[string]*STARSComputer
	ReceivedMessages []FlightPlanMessage
	FlightPlans      map[av.Squawk]*av.STARSFlightPlan
	TrackInformation map[string]*TrackInformation
	SquawkCodePool   *av.SquawkCodePool
	// This is shared among all STARS computers for our facility; we keep a
	// copy in ERAMComputer so that when we deserialize after loading a
	// saved sim, we are still sharing the same one.
	STARSCodePool *av.SquawkCodePool
	Identifier    string
	Adaptation    av.ERAMAdaptation
	// contains filtered or unexported fields
}

func MakeERAMComputer

func MakeERAMComputer(fac string, adapt av.ERAMAdaptation, starsBeaconBank int, eramComputers *ERAMComputers) *ERAMComputer

func (*ERAMComputer) Activate added in v0.11.2

func (comp *ERAMComputer) Activate(ec *ERAMComputers)

func (*ERAMComputer) AdaptationFixForAltitude

func (ec *ERAMComputer) AdaptationFixForAltitude(fix string, altitude string) *av.AdaptationFix

func (*ERAMComputer) AddDeparture

func (comp *ERAMComputer) AddDeparture(fp *av.FlightPlan, tracon string, simTime time.Time)

func (*ERAMComputer) AddFlightPlan

func (comp *ERAMComputer) AddFlightPlan(plan *av.STARSFlightPlan)

func (*ERAMComputer) AddTrackInformation

func (comp *ERAMComputer) AddTrackInformation(callsign string, trk TrackInformation)

func (*ERAMComputer) CompletelyDeleteAircraft

func (comp *ERAMComputer) CompletelyDeleteAircraft(ac *av.Aircraft)

func (*ERAMComputer) CreateSquawk

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

For NAS codes

func (*ERAMComputer) DropTrack

func (comp *ERAMComputer) DropTrack(ac *av.Aircraft) error

func (*ERAMComputer) FixForRouteAndAltitude

func (ec *ERAMComputer) FixForRouteAndAltitude(route string, altitude string) *av.AdaptationFix

func (*ERAMComputer) HandoffTrack

func (comp *ERAMComputer) HandoffTrack(ac *av.Aircraft, from, to *av.Controller, simTime time.Time) error

func (*ERAMComputer) InitiateTrack

func (comp *ERAMComputer) InitiateTrack(callsign string, controller string, fp *av.STARSFlightPlan) error

func (*ERAMComputer) ReturnSquawk added in v0.11.9

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

func (*ERAMComputer) SendFlightPlan

func (comp *ERAMComputer) SendFlightPlan(fp *av.STARSFlightPlan, tracon string, simTime time.Time) error

For individual plans being sent.

func (*ERAMComputer) SendFlightPlans

func (comp *ERAMComputer) SendFlightPlans(tracon string, simTime time.Time, lg *log.Logger)

func (*ERAMComputer) SendMessageToERAM

func (comp *ERAMComputer) SendMessageToERAM(facility string, msg FlightPlanMessage) error

func (*ERAMComputer) SendMessageToSTARSFacility

func (comp *ERAMComputer) SendMessageToSTARSFacility(facility string, msg FlightPlanMessage) error

Sends a message, whether that be a flight plan or any other message type to a STARS computer. The STARS computer will sort messages by itself

func (*ERAMComputer) SortMessages

func (comp *ERAMComputer) SortMessages(simTime time.Time, lg *log.Logger)

func (*ERAMComputer) Update

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

type ERAMComputers

type ERAMComputers struct {
	Computers map[string]*ERAMComputer
}

func MakeERAMComputers

func MakeERAMComputers(starsBeaconBank int, lg *log.Logger) *ERAMComputers

func (*ERAMComputers) Activate

func (ec *ERAMComputers) Activate()

func (*ERAMComputers) AddArrival

func (ec *ERAMComputers) AddArrival(ac *av.Aircraft, facility string, fa av.STARSFacilityAdaptation, simTime time.Time) error

func (*ERAMComputers) CompletelyDeleteAircraft

func (ec *ERAMComputers) CompletelyDeleteAircraft(ac *av.Aircraft)

func (ERAMComputers) DumpMap

func (e ERAMComputers) DumpMap()

For debugging purposes

func (*ERAMComputers) FacilityComputers

func (ec *ERAMComputers) FacilityComputers(fac string) (*ERAMComputer, *STARSComputer, error)

If given an ARTCC, returns the corresponding ERAMComputer; if given a TRACON, returns both the associated ERMANComputer and STARSComputer

func (ERAMComputers) GetSTARSFlightPlan

func (ec ERAMComputers) GetSTARSFlightPlan(tracon string, identifier string) (*av.STARSFlightPlan, error)

identifier can be bcn or callsign

func (*ERAMComputers) HandoffTrack

func (ec *ERAMComputers) HandoffTrack(ac *av.Aircraft, from, to string, controllers map[string]*av.Controller, simTime time.Time) error

func (*ERAMComputers) SetScratchpad

func (ec *ERAMComputers) SetScratchpad(callsign, facility, scratchpad string) error

func (*ERAMComputers) SetSecondaryScratchpad

func (ec *ERAMComputers) SetSecondaryScratchpad(callsign, facility, scratchpad string) error

func (ERAMComputers) Update

func (ec ERAMComputers) Update(s *Sim)

Give the computers a chance to sort through their received messages and do assorted housekeeping.

type ERAMTrackInfo

type ERAMTrackInfo struct {
	Location          math.Point2LL
	Owner             string
	HandoffController string
}

type Event

type Event struct {
	Type                  EventType
	Callsign              string
	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

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 FlightPlanMessage

type FlightPlanMessage struct {
	SourceID         string // LLLdddd e.g. ZCN2034 (ZNY at 2034z)
	MessageType      int
	FlightID         string // ddaLa(a)(a)(a)(a)(a)ECID (3 chars start w/ digit), Aircraft ID (2-7 chars start with letter)
	AircraftData     AircraftDataMessage
	BCN              av.Squawk
	CoordinationFix  string
	CoordinationTime av.CoordinationTime

	// Altitude will either be requested (cruise altitude) for departures,
	// or the assigned altitude for arrivals.  ERAM has the ability to
	// assign interm alts (and is used much more than STARS interm alts)
	// with `QQ`.  This interim altiude gets sent down to the STARS
	// computer instead of the cruising altitude. If no interim altitude is
	// set, use the cruise altitude (check this) Examples of altitudes
	// could be 310, VFR/170, VFR, 170B210 (block altitude), etc.
	Altitude string
	Route    string

	TrackInformation // For track messages
}

func FlightPlanDepartureMessage

func FlightPlanDepartureMessage(fp av.FlightPlan, sendingFacility string, simTime time.Time) FlightPlanMessage

Prepare the message to sent to a STARS facility after a RF message

func MakeFlightPlanMessage added in v0.11.9

func MakeFlightPlanMessage(fp *av.STARSFlightPlan) FlightPlanMessage

func (FlightPlanMessage) FlightPlan

func (s FlightPlanMessage) FlightPlan() *av.STARSFlightPlan

Converts the message to a STARS flight plan.

type FutureChangeSquawk added in v0.11.8

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

type FutureControllerContact added in v0.11.7

type FutureControllerContact struct {
	Callsign string
	TCP      string
	Time     time.Time
}

type FutureOnCourse added in v0.11.7

type FutureOnCourse struct {
	Callsign string
	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
	Callsign     string
	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 int

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

	VFRDepartureRateScale float32
	VFRAirports           map[string]*av.Airport

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

	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 av.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 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

	// Aircraft flow through two or three of the following lists.
	// Hold for release purgatory.
	Held []DepartureAircraft
	// Released, either manually from Held, or VFR, or if there is no HFR
	// at the airport, IFR departures go here initially.
	Released []DepartureAircraft
	// Sequenced departures, pulled from Released. These are launched in-order.
	Sequenced []DepartureAircraft

	BufferReleased bool

	LastDeparture *DepartureAircraft

	VFRAttempts  int
	VFRSuccesses int
}

type STARSComputer

type STARSComputer struct {
	Identifier        string
	ContainedPlans    map[av.Squawk]*av.STARSFlightPlan
	ReceivedMessages  []FlightPlanMessage
	TrackInformation  map[string]*TrackInformation
	ERAMInbox         *[]FlightPlanMessage            // The address of the overlying ERAM's message inbox.
	STARSInbox        map[string]*[]FlightPlanMessage // Other STARS Facilities' inboxes
	UnsupportedTracks []UnsupportedTrack
	SquawkCodePool    *av.SquawkCodePool
	HoldForRelease    []*av.Aircraft
}

func MakeSTARSComputer

func MakeSTARSComputer(id string, sq *av.SquawkCodePool) *STARSComputer

func (*STARSComputer) AcceptHandoff

func (comp *STARSComputer) AcceptHandoff(ac *av.Aircraft, ctrl *av.Controller,
	controllers map[string]*av.Controller, adaptation av.STARSFacilityAdaptation, simTime time.Time) error

func (*STARSComputer) AcceptRedirectedHandoff

func (comp *STARSComputer) AcceptRedirectedHandoff(ac *av.Aircraft, ctrl *av.Controller) error

func (*STARSComputer) AcknowledgePointOut

func (comp *STARSComputer) AcknowledgePointOut(callsign, controller string) error

func (*STARSComputer) Activate added in v0.11.2

func (comp *STARSComputer) Activate(pool *av.SquawkCodePool)

func (*STARSComputer) AddFlightPlan

func (comp *STARSComputer) AddFlightPlan(plan *av.STARSFlightPlan)

func (*STARSComputer) AddHeldDeparture added in v0.11.5

func (comp *STARSComputer) AddHeldDeparture(ac *av.Aircraft)

func (*STARSComputer) AddTrackInformation

func (comp *STARSComputer) AddTrackInformation(callsign string, info TrackInformation)

func (*STARSComputer) AddUnsupportedTrack

func (comp *STARSComputer) AddUnsupportedTrack(ut UnsupportedTrack)

func (*STARSComputer) AssociateFlightPlans

func (comp *STARSComputer) AssociateFlightPlans(s *Sim)

func (*STARSComputer) AutoAssociateFP

func (comp *STARSComputer) AutoAssociateFP(ac *av.Aircraft, fp *av.STARSFlightPlan)

func (*STARSComputer) AutomatedAcceptHandoff

func (comp *STARSComputer) AutomatedAcceptHandoff(ac *av.Aircraft, controller string,
	receivingSTARS *STARSComputer, controllers map[string]*av.Controller, simTime time.Time) error

func (*STARSComputer) CancelHandoff

func (comp *STARSComputer) CancelHandoff(ac *av.Aircraft, ctrl *av.Controller,
	controllers map[string]*av.Controller, simTime time.Time) error

func (*STARSComputer) CompletelyDeleteAircraft

func (comp *STARSComputer) CompletelyDeleteAircraft(ac *av.Aircraft)

func (*STARSComputer) CreateSquawk

func (comp *STARSComputer) CreateSquawk() (av.Squawk, error)

For local codes

func (*STARSComputer) DropTrack

func (comp *STARSComputer) DropTrack(ac *av.Aircraft) error

func (*STARSComputer) GetFlightPlan

func (comp *STARSComputer) GetFlightPlan(identifier string) (*av.STARSFlightPlan, error)

func (*STARSComputer) GetReleaseDepartures added in v0.11.5

func (comp *STARSComputer) GetReleaseDepartures() []*av.Aircraft

func (*STARSComputer) HandoffControl

func (comp *STARSComputer) HandoffControl(callsign string, nextController string) error

func (*STARSComputer) HandoffTrack

func (comp *STARSComputer) HandoffTrack(callsign string, from *av.Controller, to *av.Controller, simTime time.Time) error

func (*STARSComputer) InitiateTrack

func (comp *STARSComputer) InitiateTrack(callsign string, controller string, fp *av.STARSFlightPlan, haveControl bool) error

func (*STARSComputer) LookupTrackIndex

func (comp *STARSComputer) LookupTrackIndex(idx int) *TrackInformation

func (*STARSComputer) PointOut

func (comp *STARSComputer) PointOut(callsign, toController string) error

func (*STARSComputer) RecallPointOut added in v0.11.8

func (comp *STARSComputer) RecallPointOut(callsign, controller string) error

func (*STARSComputer) RedirectHandoff

func (comp *STARSComputer) RedirectHandoff(ac *av.Aircraft, ctrl, octrl *av.Controller) error

func (*STARSComputer) RejectPointOut

func (comp *STARSComputer) RejectPointOut(callsign, controller string) error

func (*STARSComputer) ReleaseDeparture added in v0.11.5

func (comp *STARSComputer) ReleaseDeparture(callsign string) error

func (*STARSComputer) RequestFlightPlan

func (comp *STARSComputer) RequestFlightPlan(bcn av.Squawk, simTime time.Time)

func (*STARSComputer) ReturnSquawk added in v0.11.9

func (comp *STARSComputer) ReturnSquawk(code av.Squawk) error

func (*STARSComputer) SendToOverlyingERAMFacility

func (comp *STARSComputer) SendToOverlyingERAMFacility(msg FlightPlanMessage)

func (*STARSComputer) SendTrackInfo

func (comp *STARSComputer) SendTrackInfo(receivingFacility string, msg FlightPlanMessage, simTime time.Time)

func (*STARSComputer) SortReceivedMessages

func (comp *STARSComputer) SortReceivedMessages(e *EventStream)

Sorting the STARS messages. This will store flight plans with FP messages, change flight plans with AM messages, cancel flight plans with CX messages, etc.

func (*STARSComputer) Update

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

func (*STARSComputer) UpdateAssociatedFlightPlans

func (comp *STARSComputer) UpdateAssociatedFlightPlans(aircraft []*av.Aircraft)

type Sim

type Sim struct {
	State *State

	SignOnPositions map[string]*av.Controller

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

	Handoffs map[string]Handoff
	// a/c callsign -> PointOut
	PointOuts map[string]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
	// contains filtered or unexported fields
}

func NewSim

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

func (*Sim) AcceptHandoff

func (s *Sim) AcceptHandoff(tcp, callsign string) error

func (*Sim) AcceptRedirectedHandoff

func (s *Sim) AcceptRedirectedHandoff(tcp, callsign string) error

func (*Sim) AcknowledgePointOut

func (s *Sim) AcknowledgePointOut(tcp, callsign string) error

func (*Sim) Activate

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

func (*Sim) ActiveControllers added in v0.11.9

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

func (*Sim) AssignAltitude

func (s *Sim) AssignAltitude(tcp, callsign string, altitude int, afterSpeed bool) error

func (*Sim) AssignHeading

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

func (*Sim) AssignSpeed

func (s *Sim) AssignSpeed(tcp, callsign string, speed int, afterAltitude bool) error

func (*Sim) AtFixCleared

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

func (*Sim) AutoAssociateFP

func (s *Sim) AutoAssociateFP(tcp, callsign string, fp *av.STARSFlightPlan) error

func (*Sim) CancelApproachClearance

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

func (*Sim) CancelHandoff

func (s *Sim) CancelHandoff(tcp, callsign string) error

func (*Sim) ChangeControlPosition

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

func (*Sim) ChangeSquawk

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

func (*Sim) ChangeTransponderMode added in v0.11.9

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

func (*Sim) ClearedApproach

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

func (*Sim) ClimbViaSID

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

func (*Sim) ContactTower

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

func (*Sim) CreateArrival

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

func (*Sim) CreateIFRDeparture added in v0.11.9

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

func (*Sim) CreateOverflight added in v0.11.2

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

func (*Sim) CreateRestrictionArea added in v0.11.6

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

func (*Sim) CreateUnsupportedTrack

func (s *Sim) CreateUnsupportedTrack(tcp, callsign string, ut *UnsupportedTrack) error

func (*Sim) CreateVFRDeparture added in v0.11.9

func (s *Sim) CreateVFRDeparture(departureAirport string) (*av.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, callsign, fix string, ar *av.AltitudeRestriction, speed int) error

func (*Sim) DeleteAircraft

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

func (*Sim) DeleteAllAircraft

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

func (*Sim) DeleteRestrictionArea added in v0.11.6

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

func (*Sim) DepartFixDirect

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

func (*Sim) DepartFixHeading

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

func (*Sim) DescendViaSTAR

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

func (*Sim) DirectFix

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

func (*Sim) DropTrack

func (s *Sim) DropTrack(tcp, callsign string) error

func (*Sim) ExpectApproach

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

func (*Sim) ExpediteClimb

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

func (*Sim) ExpediteDescent

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

func (*Sim) ForceQL

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

func (*Sim) GetAvailableCoveredPositions added in v0.11.9

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

func (*Sim) GetSerializeSim added in v0.11.9

func (s *Sim) GetSerializeSim() Sim

func (*Sim) GetWorldUpdate

func (s *Sim) GetWorldUpdate(tcp string, update *WorldUpdate, localServer bool)

func (*Sim) GlobalMessage

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

func (*Sim) GoAround

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

func (*Sim) HandoffControl

func (s *Sim) HandoffControl(tcp, callsign string) error

func (*Sim) HandoffTrack

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

func (*Sim) Ident

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

func (*Sim) IdleTime

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

func (*Sim) InitiateTrack

func (s *Sim) InitiateTrack(tcp, callsign string, fp *av.STARSFlightPlan) error

func (*Sim) InterceptLocalizer

func (s *Sim) InterceptLocalizer(tcp, callsign string) error

func (*Sim) LaunchAircraft

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

func (*Sim) LogValue

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

func (*Sim) MaintainMaximumForward

func (s *Sim) MaintainMaximumForward(tcp, callsign string) error

func (*Sim) MaintainSlowestPractical

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

func (*Sim) PointOut

func (s *Sim) PointOut(fromTCP, callsign, 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) RecallPointOut added in v0.11.8

func (s *Sim) RecallPointOut(tcp, callsign string) error

func (*Sim) RedirectHandoff

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

func (*Sim) RejectPointOut

func (s *Sim) RejectPointOut(tcp, callsign string) error

func (*Sim) ReleaseDeparture added in v0.11.5

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

func (*Sim) ResolveController

func (s *Sim) ResolveController(tcp string) string

func (*Sim) SayAltitude

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

func (*Sim) SayHeading

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

func (*Sim) SaySpeed

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

func (*Sim) SetGlobalLeaderLine

func (s *Sim) SetGlobalLeaderLine(tcp, callsign string, dir *math.CardinalOrdinalDirection) error

func (*Sim) SetLaunchConfig

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

func (*Sim) SetPilotReportedAltitude added in v0.11.9

func (s *Sim) SetPilotReportedAltitude(tcp, callsign string, altitude int) error

func (*Sim) SetScratchpad

func (s *Sim) SetScratchpad(tcp, callsign, scratchpad string) error

func (*Sim) SetSecondaryScratchpad

func (s *Sim) SetSecondaryScratchpad(tcp, callsign, scratchpad string) error

func (*Sim) SetSimRate

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

func (*Sim) SetTemporaryAltitude

func (s *Sim) SetTemporaryAltitude(tcp, callsign string, altitude int) 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) ToggleDisplayModeCAltitude added in v0.11.9

func (s *Sim) ToggleDisplayModeCAltitude(tcp, callsign string) error

func (*Sim) TogglePause

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

func (*Sim) ToggleSPCOverride

func (s *Sim) ToggleSPCOverride(tcp, callsign, spc 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

func (*Sim) UploadFlightPlan

func (s *Sim) UploadFlightPlan(tcp string, planType int, plan *av.STARSFlightPlan) error

type State

type State struct {
	Aircraft          map[string]*av.Aircraft
	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

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

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

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

	ERAMComputers           *ERAMComputers
	STARSFacilityAdaptation av.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..

	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) Activate

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

func (*State) AircraftFromCallsignSuffix added in v0.11.7

func (ss *State) AircraftFromCallsignSuffix(suffix string, instructor bool) []*av.Aircraft

Returns all aircraft that match the given suffix. If instructor is true, returns all matching aircraft; otherwise only ones under the current controller's control are considered for matching.

func (*State) AmInstructor added in v0.11.7

func (ss *State) AmInstructor() bool

func (*State) AverageWindVector

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

func (*State) DeleteAircraft

func (ss *State) DeleteAircraft(ac *av.Aircraft)

func (*State) DepartureController

func (ss *State) DepartureController(ac *av.Aircraft, lg *log.Logger) string

func (*State) ERAMComputer

func (ss *State) ERAMComputer() *ERAMComputer

func (*State) FacilityFromController

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

func (*State) GetAllReleaseDepartures added in v0.11.6

func (ss *State) GetAllReleaseDepartures() []*av.Aircraft

func (*State) GetConsolidatedPositions added in v0.11.7

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

func (*State) GetInitialCenter

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

func (*State) GetInitialRange

func (ss *State) GetInitialRange() float32

func (*State) GetRegularReleaseDepartures added in v0.11.6

func (ss *State) GetRegularReleaseDepartures() []*av.Aircraft

func (*State) GetSTARSReleaseDepartures added in v0.11.6

func (ss *State) GetSTARSReleaseDepartures() []*av.Aircraft

func (*State) GetStateForController

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

func (*State) GetWindVector

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

func (*State) InhibitCAVolumes

func (ss *State) InhibitCAVolumes() []av.AirspaceVolume

func (*State) IsArrival added in v0.11.2

func (s *State) IsArrival(ac *av.Aircraft) bool

func (*State) IsDeparture added in v0.11.2

func (s *State) IsDeparture(ac *av.Aircraft) bool

func (*State) IsIntraFacility added in v0.11.2

func (s *State) IsIntraFacility(ac *av.Aircraft) bool

func (*State) IsOverflight added in v0.11.2

func (s *State) IsOverflight(ac *av.Aircraft) bool

func (*State) Locate

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

func (*State) STARSComputer

func (ss *State) STARSComputer() *STARSComputer

type TrackInformation

type TrackInformation struct {
	Identifier        string
	TrackOwner        string
	HandoffController string
	FlightPlan        *av.STARSFlightPlan
	PointOut          string
	PointOutHistory   []string
	RedirectedHandoff av.RedirectedHandoff
	SP1               string
	SP2               string
	AutoAssociateFP   bool // If it's white or not
}

func (TrackInformation) HandingOffTo added in v0.11.2

func (trk TrackInformation) HandingOffTo(ctrl string) bool

type UnsupportedTrack

type UnsupportedTrack struct {
	TrackLocation     math.Point2LL
	Owner             string
	HandoffController string
	FlightPlan        *av.STARSFlightPlan
}

type WorldUpdate

type WorldUpdate struct {
	Aircraft         map[string]*av.Aircraft
	Controllers      map[string]*av.Controller
	HumanControllers []string

	Time time.Time

	ERAMComputers *ERAMComputers

	LaunchConfig LaunchConfig

	UserRestrictionAreas []av.RestrictionArea

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

Jump to

Keyboard shortcuts

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