Skip to content

Commit

Permalink
Support weather information
Browse files Browse the repository at this point in the history
Fixes #30
  • Loading branch information
mpapenbr committed Mar 23, 2024
1 parent 8cb4754 commit 96cd6aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
25 changes: 17 additions & 8 deletions internal/processor/cardata.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,14 @@ func (co *carOut) UpdatePost(cd *CarData) {}

// contains data extracted from irsdk that needs to be processed by the carState
type carWorkData struct {
carIdx int32
trackPos float64
pos int32
pic int32
lap int32
lc int32
pit bool
carIdx int32
trackPos float64
pos int32
pic int32
lap int32
lc int32
pit bool
tireCompound int32
}

// CarData is a struct that contains the logic to process data for a single car data.
Expand All @@ -201,6 +202,7 @@ type CarData struct {
speed float64
interval float64
gap float64
tireCompound int
currentState carState
laptiming *CarLaptiming
carDriverProc *CarDriverProc
Expand Down Expand Up @@ -279,6 +281,7 @@ func (cd *CarData) prepareMsgData() {
cd.laptiming.sectors[i].duration.marker,
}
}
cd.msgData["tireCompound"] = cd.tireCompound

cd.msgData["userName"] = cd.carDriverProc.GetCurrentDriver(cd.carIdx).UserName
cd.msgData["teamName"] = cd.carDriverProc.GetCurrentDriver(cd.carIdx).TeamName
Expand Down Expand Up @@ -333,7 +336,12 @@ func (cd *CarData) extractIrsdkData(api *irsdk.Irsdk) *carWorkData {
cw.lap = justValue(api.GetValue("CarIdxLap")).([]int32)[cd.carIdx]
cw.lc = justValue(api.GetValue("CarIdxLapCompleted")).([]int32)[cd.carIdx]
cw.pit = justValue(api.GetValue("CarIdxOnPitRoad")).([]bool)[cd.carIdx]

cw.tireCompound = justValue(api.GetValue("CarIdxTireCompound")).([]int32)[cd.carIdx]
// maybe put this into the CarStint?
// value not unique
// when wet race: 0=DRY, 1=WET (EventID 314)
// when dry: 0=hard, 1=medium, 2=soft (F1, EventID 315)
// when dry: 0=primary, 1=alternate (IR 18, EventId 316)
return &cw
}

Expand All @@ -343,6 +351,7 @@ func (cd *CarData) copyWorkData(cw *carWorkData) {
cd.pic = int(cw.pic)
cd.lap = int(cw.lap)
cd.lc = int(cw.lc)
cd.tireCompound = int(cw.tireCompound)
cd.dist = 0
cd.interval = 0
}
1 change: 1 addition & 0 deletions internal/processor/cars.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var baseAttributes = []string{
"stintLap",
"last",
"best",
"tireCompound",
}

//nolint:makezero // false positive?
Expand Down
6 changes: 6 additions & 0 deletions internal/processor/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func SessionManifest() []string {
"trackTemp",
"windDir",
"windVel",
"trackWetness",
"weatherDeclaredWet",
"precipitation",
}
}

Expand Down Expand Up @@ -53,6 +56,9 @@ func (s *SessionProc) CreateOutput() GenericMessage {
msg["trackTemp"] = justValue(s.api.GetValue("TrackTemp"))
msg["windDir"] = justValue(s.api.GetValue("WindDir"))
msg["windVel"] = justValue(s.api.GetValue("WindVel"))
msg["precipitation"] = justValue(s.api.GetValue("Precipitation"))
msg["trackWetness"] = justValue(s.api.GetValue("TrackWetness"))
msg["weatherDeclaredWet"] = justValue(s.api.GetValue("WeatherDeclardWet"))
state, _ := s.api.GetIntValue("SessionState")
flags, _ := s.api.GetIntValue("SessionFlags")
msg["flagState"] = computeFlagState(state, int64(flags))
Expand Down

0 comments on commit 96cd6aa

Please sign in to comment.