Documentation
¶
Index ¶
- type EventPublisher
- type Pitstop
- type PitstopService
- type RaceProgress
- type RaceStrategy
- func (s *RaceStrategy) AdjustStintsToFitRaceLength(ctx context.Context, info entities.RaceInfo, strat *entities.PitStrat, ...)
- func (s *RaceStrategy) CalculateLastLapTiming(info entities.RaceInfo, pitStrat *entities.PitStrat)
- func (s *RaceStrategy) CalculateMaxTimeLoss(saveStrat, flatoutStrat *entities.PitStrat)
- func (s *RaceStrategy) DefaultTrackLayoutFallback(ctx context.Context, info *entities.RaceInfo) error
- func (s *RaceStrategy) EnsurePitLength(info *entities.RaceInfo)
- func (s *RaceStrategy) FetchStrategy(ctx context.Context, id, userID uuid.UUID, passphrase string) (*entities.SavedStrategy, error)
- func (s *RaceStrategy) FetchStrategyCarAndLocation(ctx context.Context, strategyID uuid.UUID) (*entities.Car, *entities.Track, *entities.TrackLayout, error)
- func (s *RaceStrategy) GeneratePitStrategies(ctx context.Context, strat *entities.RaceStrategy) error
- type Setup
- func (s *Setup) CanUserUpdate(setup *entities.Setup, user *entities.User) bool
- func (s *Setup) NormalizeForUpdate(reqSetup, savedSetup *entities.Setup)
- func (s *Setup) SetUser(setup *entities.Setup, user *entities.User)
- func (s *Setup) ShouldUpdateFileContent(setup *entities.Setup) bool
- func (s *Setup) StoreSetupFile(ctx context.Context, setup *entities.Setup, opts ...postgresdb.ExecOption) error
- type Stint
- func (s *Stint) ApplyStintAdjustment(ctx context.Context, strat *entities.SavedStrategy, ...) error
- func (s *Stint) CreateStint(ctx context.Context, stintLaps, saveLaps float64, info entities.RaceInfo, ...) entities.Stint
- func (s *Stint) ExtendShortStints(ctx context.Context, info entities.RaceInfo, strat *entities.PitStrat, ...)
- func (s *Stint) ShortenStints(ctx context.Context, info entities.RaceInfo, strat *entities.PitStrat, ...)
- func (s *Stint) UpdateCompleteLaps(ctx context.Context, strat *entities.SavedStrategy, stint *entities.Stint, ...) float64
- type StintService
- type Track
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventPublisher ¶
type Pitstop ¶
type Pitstop struct {
// contains filtered or unexported fields
}
func NewPitstop ¶
func NewPitstop( pitParamsRepo repositories.PitParameters, ) *Pitstop
func (*Pitstop) AveragePitLength ¶
func (p *Pitstop) AveragePitLength(ctx context.Context, pitDetails entities.PitstopDetails) (int64, error)
AveragePitLength calculates the averate pit length for the given pitDetails pit services, across all race classes, including pit lane drive loss on all tracks and layouts.
type PitstopService ¶
type RaceProgress ¶
type RaceProgress struct {
// contains filtered or unexported fields
}
func NewRaceProgress ¶
func NewRaceProgress( stintSvc StintService, ) *RaceProgress
func (*RaceProgress) UpdateStrategyWithRaceProgress ¶
func (p *RaceProgress) UpdateStrategyWithRaceProgress( ctx context.Context, strat *entities.SavedStrategy, progress *entities.RaceProgress, )
type RaceStrategy ¶
type RaceStrategy struct {
// contains filtered or unexported fields
}
func NewRaceStrategy ¶
func NewRaceStrategy( stratRepo repositories.Strategy, carRepo repositories.Car, trackRepo repositories.Track, trackLayoutRepo repositories.TrackLayout, stintSvc StintService, ) *RaceStrategy
func (*RaceStrategy) AdjustStintsToFitRaceLength ¶ added in v0.21.0
func (s *RaceStrategy) AdjustStintsToFitRaceLength( ctx context.Context, info entities.RaceInfo, strat *entities.PitStrat, progress *entities.RaceProgress, )
AdjustStintsToFitRaceLength after applying changes to stints from race progress or manual edits, we may need to adjust the rest so that they still fit the race length.
func (*RaceStrategy) CalculateLastLapTiming ¶ added in v0.21.0
func (s *RaceStrategy) CalculateLastLapTiming( info entities.RaceInfo, pitStrat *entities.PitStrat, )
CalculateLastLapTiming calculates when the last lap will begin for this strategy and whether a safe lap should be recommended based on the timing margin. Safe lap is recommended if the last lap starts with >= 2/3 of lap time remaining.
func (*RaceStrategy) CalculateMaxTimeLoss ¶
func (s *RaceStrategy) CalculateMaxTimeLoss(saveStrat, flatoutStrat *entities.PitStrat)
CalculateMaxTimeLoss that the driver is allowed to lose per lap when driving in fuel saving mode, to save enough fuel in the race to avoiding having to take a pit stop for the savedStint.
func (*RaceStrategy) DefaultTrackLayoutFallback ¶
func (*RaceStrategy) EnsurePitLength ¶
func (s *RaceStrategy) EnsurePitLength(info *entities.RaceInfo)
func (*RaceStrategy) FetchStrategy ¶
func (s *RaceStrategy) FetchStrategy( ctx context.Context, id, userID uuid.UUID, passphrase string, ) (*entities.SavedStrategy, error)
func (*RaceStrategy) FetchStrategyCarAndLocation ¶
func (*RaceStrategy) GeneratePitStrategies ¶
func (s *RaceStrategy) GeneratePitStrategies( ctx context.Context, strat *entities.RaceStrategy, ) error
type Setup ¶
type Setup struct {
// contains filtered or unexported fields
}
func NewSetup ¶
func NewSetup( setupStore repositories.SetupStorage, ) *Setup
func (*Setup) CanUserUpdate ¶
func (*Setup) NormalizeForUpdate ¶
NormalizeForUpdate sets required fields to the previous values if the update request is not setting them.
func (*Setup) ShouldUpdateFileContent ¶
func (*Setup) StoreSetupFile ¶
func (s *Setup) StoreSetupFile(ctx context.Context, setup *entities.Setup, opts ...postgresdb.ExecOption) error
type Stint ¶
type Stint struct {
// contains filtered or unexported fields
}
func NewStint ¶
func NewStint( carRepo repositories.Car, pitstopSvc PitstopService, ) *Stint
func (*Stint) ApplyStintAdjustment ¶
func (s *Stint) ApplyStintAdjustment( ctx context.Context, strat *entities.SavedStrategy, stintAdj *entities.StintAdjustment, ) error
func (*Stint) CreateStint ¶
func (*Stint) ExtendShortStints ¶ added in v0.21.0
func (s *Stint) ExtendShortStints( ctx context.Context, info entities.RaceInfo, strat *entities.PitStrat, missingLaps float64, )
ExtendShortStints extends stints to distribute missing laps across them.
func (*Stint) ShortenStints ¶ added in v0.21.0
func (*Stint) UpdateCompleteLaps ¶
func (s *Stint) UpdateCompleteLaps( ctx context.Context, strat *entities.SavedStrategy, stint *entities.Stint, lapsComplete, maxStintLaps float64, ) float64
UpdateCompleteLaps updates the stints with the number of complete laps and adjusts its length based on the remaining fuel/energy in the tank, as well as adjusting the fuel/energy target consumption.
type StintService ¶
type StintService interface {
UpdateCompleteLaps(context.Context, *entities.SavedStrategy, *entities.Stint, float64, float64) float64
CreateStint(context.Context, float64, float64, entities.RaceInfo, uint) entities.Stint
ApplyStintAdjustment(context.Context, *entities.SavedStrategy, *entities.StintAdjustment) error
ShortenStints(context.Context, entities.RaceInfo, *entities.PitStrat, float64)
ExtendShortStints(context.Context, entities.RaceInfo, *entities.PitStrat, float64)
}
type Track ¶
type Track struct {
// contains filtered or unexported fields
}
func NewTrack ¶
func NewTrack(trackLayoutRepo repositories.TrackLayout) *Track