first approach to implementing virtual binds

virtual binds will just be some middleware that sits between telemetry
primitives and computed values from it like dash lights and a fuel calc
This commit is contained in:
2026-05-31 07:22:06 +01:00
parent 691a51ae8b
commit 2cb30baf6a
4 changed files with 317 additions and 232 deletions
+24 -1
View File
@@ -123,13 +123,21 @@ func (i *IRacing) readData() {
return
}
// Read binded data
// Read 1 to 1 data
for _, b := range i.data.ActiveBinds {
v := i.SDK.Vars.Vars[b.Key].Value
b.Transform(v, &i.data.Values[b.ID])
}
// Set up virtual binds
i.logger.Debug("Entering virtual binds loop")
for _, vBind := range i.data.VirtualBinds {
// NOTE: delete the logs here, they are really bad
i.logger.Debug("Processing virtual binds")
vBind.Process(i.data)
}
i.data.PenultimateDataPoll = i.data.LastDataPoll
i.data.LastDataPoll = time.Now()
}
@@ -258,5 +266,20 @@ func (i *IRacing) Subscribe(requestFields map[int16]telem.FieldID) {
boundCheck[id] = true
}
// Subscribe to whatever we need of virtual binds I guess - we need to ensure
// the virtual binds fields are being read
needsRPMColour := false
for _, id := range requestFields {
if id == telem.RPMStateColour {
needsRPMColour = true
}
}
i.logger.Debug(fmt.Sprintf("Subscribing to virtual bind? %+v", needsRPMColour))
if needsRPMColour {
i.logger.Debug("Subscribing to virtual bind")
i.data.VirtualBinds = append(i.data.VirtualBinds, telem.NewRPMLights())
}
i.logger.Debug(fmt.Sprintf("Subscribed: %+v\n", i.data.ActiveBinds))
}