Files
esdi/sources/iracing/iracingSink.go
T
esilva c9086cae56 Setting the environment to handle multiple data sinks
im scaffolding it but first I recon I will make this transfer data to
the lcd and then we will take a look at making it pretty
2026-03-03 23:11:24 +00:00

46 lines
884 B
Go

package iracing
import (
"fmt"
"time"
"github.com/ESilva15/goirsdk"
)
// This will implement the GameSink interface from the main package
type IRacing struct {
SDK *goirsdk.IBT
}
const (
NAME = "iRacing"
)
func Init(f goirsdk.Reader, telemOut string, yamlOut string) (IRacing, error) {
var err error
sdk, err := goirsdk.Init(f, telemOut, yamlOut)
if err != nil {
return IRacing{}, err
}
return IRacing{SDK: sdk}, nil
}
func (i *IRacing) GetData(fieldName string) (interface{}, error) {
if val, ok := i.SDK.Vars.Vars[fieldName]; ok {
return val.Value, nil
}
return nil, fmt.Errorf("key `%s` doesn't exist", fieldName)
}
func (i *IRacing) UpdateData() error {
_, err := i.SDK.Update(100 * time.Millisecond)
return err
}
func (i *IRacing) GetSessionInfo() (interface{}, error) {
return i.SDK.SessionInfo, nil
}