Modified the test a bit, gonna just merge whatever I have now and do work on the ESDI instead

This commit is contained in:
2025-01-16 23:41:42 +00:00
parent c5ff9f95c9
commit fa7f0b73ee
+32 -5
View File
@@ -12,7 +12,21 @@ import (
type StandingsLine struct { type StandingsLine struct {
CarIdx int CarIdx int
LapPct float32 LapPct float32
Lap int32
DriverName string DriverName string
EstTime float32
TimeBehind float32
}
func lapTimeRepresentation(t float32) string {
if t < 0 {
t = 0
}
wholeSeconds := int64(t)
lapTime := time.Unix(wholeSeconds, int64((t-float32(wholeSeconds))*1e9))
return lapTime.Format("04:05.000")
} }
func TestFunctionality(t *testing.T) { func TestFunctionality(t *testing.T) {
@@ -42,9 +56,13 @@ func TestFunctionality(t *testing.T) {
if _, ok := i.Vars.Vars["CarIdxPosition"]; !ok { if _, ok := i.Vars.Vars["CarIdxPosition"]; !ok {
log.Fatal("Field `CarIdxPosition` doesn't exist") log.Fatal("Field `CarIdxPosition` doesn't exist")
} }
driversPositions := i.Vars.Vars["CarIdxLapDistPct"].Value.([]float32) driversLapDistPct := i.Vars.Vars["CarIdxLapDistPct"].Value.([]float32)
driversEstTime := i.Vars.Vars["CarIdxEstTime"].Value.([]float32)
driversLap := i.Vars.Vars["CarIdxLap"].Value.([]int32)
// driversBehind := i.Vars.Vars["CarIdxF2Time"].Value.([]float32)
drivers := i.SessionInfo.DriverInfo.Drivers drivers := i.SessionInfo.DriverInfo.Drivers
myIdx := i.SessionInfo.DriverInfo.DriverCarIdx
standings := make([]StandingsLine, len(drivers)) standings := make([]StandingsLine, len(drivers))
@@ -56,18 +74,27 @@ func TestFunctionality(t *testing.T) {
standings[k] = StandingsLine{ standings[k] = StandingsLine{
CarIdx: k, CarIdx: k,
LapPct: float32(driversPositions[k]), LapPct: driversLapDistPct[k],
DriverName: drivers[k].UserName, DriverName: drivers[k].UserName,
EstTime: driversEstTime[k],
Lap: driversLap[k],
TimeBehind: driversEstTime[myIdx],
} }
} }
sort.Slice(standings, func(i int, j int) bool { sort.Slice(standings, func(i int, j int) bool {
if standings[i].Lap > int32(standings[j].Lap) {
return true
}
return standings[i].LapPct >= standings[j].LapPct return standings[i].LapPct >= standings[j].LapPct
}) })
for p, v := range standings { fmt.Printf("%v\n", driversEstTime)
fmt.Printf("[%d] %s %f\n", p + 1, v.DriverName, v.LapPct) // for p, v := range standings {
} // fmt.Printf("[%2d] %-30s %13f %13f\n",
// p+1, v.DriverName, v.LapPct, driversEstTime[p] - driversEstTime[myIdx])
// }
<-mainLoopTicker.C <-mainLoopTicker.C
} }