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
- func (s *RaceStrategy) RecalculatePitLengthsForCarAndTrack(ctx context.Context, strat *entities.SavedStrategy) 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) CalculatePitLength(ctx context.Context, fuelRequired, energyRequired float64, changeTyres bool, ...) (int64, 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) ShouldChangeTyres(info entities.RaceInfo, stint *entities.Stint) bool
- 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
func (*RaceStrategy) RecalculatePitLengthsForCarAndTrack ¶ added in v0.22.0
func (s *RaceStrategy) RecalculatePitLengthsForCarAndTrack( ctx context.Context, strat *entities.SavedStrategy, ) error
RecalculatePitLengthsForCarAndTrack updates all pit stop durations in all strategies based on the specific car and track combination. User-adjusted pit lengths (via StintAdjustmentType_PitLength) are preserved. After updating pit durations, it recalculates time losses/gains for save strategies.
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) CalculatePitLength ¶ added in v0.22.0
func (s *Stint) CalculatePitLength( ctx context.Context, fuelRequired, energyRequired float64, changeTyres bool, info entities.RaceInfo, ) (int64, error)
CalculatePitLength calculates the pit stop duration for a stint. If car and track information is available in RaceInfo, it uses specific timings for that car/track combination. Otherwise, it falls back to average timings.
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) ShouldChangeTyres ¶ added in v0.22.0
ShouldChangeTyres determines if tires should be changed for this stint based on tyre change frequency and stint characteristics.
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
ShouldChangeTyres(entities.RaceInfo, *entities.Stint) bool
CalculatePitLength(context.Context, float64, float64, bool, entities.RaceInfo) (int64, 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