accrace

package
v0.0.0-...-d7f5ba0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CarLocationUnknown  = accbroadcast.CarLocationUnknown
	CarLocationTrack    = accbroadcast.CarLocationTrack
	CarLocationPitLane  = accbroadcast.CarLocationPitLane
	CarLocationPitEntry = accbroadcast.CarLocationPitEntry
	CarLocationPitExit  = accbroadcast.CarLocationPitExit
	CarLocationPitBox   = 5
)
View Source
const (
	PracticeSession        SessionType = 0
	QualifyingSession                  = 4
	SuperpoleSession                   = 9
	RaceSession                        = 10
	HotlapSession                      = 11
	HotstintSession                    = 12
	HotlapSuperpoleSession             = 13
	ReplaySession                      = 14
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Car

type Car struct {
	CarId              int
	IsConnected        bool
	CarModel           *accdata.CarModel
	TeamName           string
	RaceNumber         int
	CurrentDriverIndex int
	Drivers            []*Driver
	IsInPit            bool
	Location           int // one of the CarLocation... constants
	Gear               int // R = -1,  N = 0,  1 = 1,  2 = 2,  ...
	SpeedKmh           int
	Position           int     // Official P/Q/R position (1-based)
	CupPosition        int     // Official P/Q/R position (1-based)
	TrackPosition      int     // Position on track (1-based)
	SplinePosition     float32 // Track position between 0.0 and 1.0
	Laps               int
	Delta              time.Duration // Realtime delta to best session lap
	BestSessionLap     *Lap
	LastLap            *Lap
	CurrentLap         *Lap
	// contains filtered or unexported fields
}

func NewCar

func NewCar(msg *accbroadcast.MsgEntryListCar) *Car

func (*Car) UpdateFromEntryList

func (c *Car) UpdateFromEntryList(msg *accbroadcast.MsgEntryListCar)

func (*Car) UpdateFromRealtime

func (c *Car) UpdateFromRealtime(msg *accbroadcast.MsgRealtimeCarUpdate, state *State)

type CarGap

type CarGap struct {
	CarId int

	Laps           int
	SplinePosition float32 // Track position between 0.0 and 1.0

	GapsAhead  map[int]time.Duration
	GapsBehind map[int]time.Duration
}

type Driver

type Driver struct {
	FirstName string
	LastName  string
	ShortName string
}

type Lap

type Lap struct {
	LapTime     time.Duration   // Negative duration indicates unknown time
	DriverIndex int             // Driver who drove the lap
	SplitTimes  []time.Duration // Always has 3 elements; negative durations indicate unknown times
	IsValid     bool
}

func NewLap

func NewLap(msg *accbroadcast.MsgLap) *Lap

type MiniCar

type MiniCar struct {
	CarId          int
	Gear           int
	SpeedKmh       int
	SplinePosition float32
	Delta_ms       time.Duration
	CurrentLap_ms  time.Duration
}

MiniCar is a subset of Car properties that are updated continuously

func NewMiniCar

func NewMiniCar(c *Car) *MiniCar

type PitEvent

type PitEvent struct {
	Car         *Car
	OldLocation int // One of the CarLocation... constants
	NewLocation int // One of the CarLocation... constants
}

type SessionType

type SessionType byte

func (SessionType) ToString

func (st SessionType) ToString() string

type State

type State struct {
	SessionType        SessionType
	TimeRemaining      time.Duration
	FocusedCarPosition int
	FocusedCarId       int
	FocusedBestLap     time.Duration
	FocusedLastLap     time.Duration
	FocusedCurrentLap  time.Duration
	FocusedLapDelta    time.Duration
	TrackGaps          []CarGap

	// Indexed on CarId
	Cars map[int]*Car

	SessionTypeUpdates   chan string
	TimeRemainingUpdates chan time.Duration
	FocusedCarUpdates    chan *Car
	PositionUpdates      chan int
	CarUpdates           chan *Car
	BestLapUpdates       chan time.Duration
	LastLapUpdates       chan time.Duration
	CurrentLapUpdates    chan time.Duration
	LapDeltaUpdates      chan time.Duration
	TrackGapUpdates      chan []CarGap
	MiniCarUpdates       chan *MiniCar

	PitEvents chan *PitEvent
	// contains filtered or unexported fields
}

func NewState

func NewState(client *accbroadcast.Client) *State

func (*State) Burst

func (s *State) Burst()

func (*State) Close

func (s *State) Close()

Jump to

Keyboard shortcuts

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