irsdk

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SimStatusUrl       = "http://127.0.0.1:32034/get_sim_status?object=simStatus"
	DataValidEventName = "Local\\IRSDKDataValidEvent"
)
View Source
const (
	MemMapFileSize = 1164 * 1024
	MemMapFile     = "Local\\IRSDKMemMapFileName"

	IrsdkMaxBufs   = 3
	IrsdkMaxString = 32
	IrsdkMaxDesc   = 64
)
View Source
const (
	TrackWetnessUnknown = iota
	TrackWetnessDry
	TrackWetnessMostlyDry
	TrackWetnessVeryLightlyWet
	TrackWetnessLightlyWet
	TrackWetnessModeratelyWet
	TrackWetnessVeryWet
	TrackWetnessExtremeWet
)

Variables

View Source
var (
	ErrInvalidDataRequest = errors.New("Invalid data request")
	ErrNoMatchingDataType = errors.New("requested data type does not match iRacing data type")
)

Functions

func CheckIfSimIsRunning

func CheckIfSimIsRunning() bool

Types

type ApiConfig

type ApiConfig struct {
	WaitForSimTimeout int
}

type Flags

type Flags int64
const (
	FlagCheckered Flags = 1 << iota
	FlagWhite
	FlagGreen
	FlagYello
	FlagRed
	FlagBlue
	FlagDebris
	FlagCrossed
	FlagYellowWaving
	FlagOneLapToGreen
	FlagGreenHeld
	FlagTenToGo
	FlagFiveToGo
	FlagRandomWaving
	FlagCaution
	FlagCautionWaving

	// driver black flacks
	FlagBlack      Flags = 0x010000
	FlagDisqualify Flags = 0x020000
	FlagServicible Flags = 0x040000
	FlagFurled     Flags = 0x080000
	FlagRepair     Flags = 0x100000

	// start lights
	FlagStartHidden Flags = 0x10000000
	FlagStartReady  Flags = 0x20000000
	FlagStartSet    Flags = 0x40000000
	FlagStartGo     Flags = 0x80000000
)
type Header struct {
	Version           int32
	Status            int32
	TickRate          int32
	SessionInfoUpdate int32
	SessionInfoLen    int32
	SessionInfoOffset int32
	NumVars           int32
	VarOffsetHeader   int32
	NumBuf            int32
	BufLen            int32
	Pad               [2]int32
	VarBufs           [IrsdkMaxBufs]VarBuffer
}

type Irsdk

type Irsdk struct {
	SimIsRunning bool
	// contains filtered or unexported fields
}

func NewIrsdk

func NewIrsdk(opts ...Option) *Irsdk

func NewIrsdkWithFile

func NewIrsdkWithFile(f *os.File) *Irsdk

func (*Irsdk) Close

func (irsdk *Irsdk) Close()

func (*Irsdk) DumpHeaders

func (irsdk *Irsdk) DumpHeaders()

func (*Irsdk) GetBoolValue

func (irsdk *Irsdk) GetBoolValue(name string) (bool, error)

func (*Irsdk) GetBoolValues

func (irsdk *Irsdk) GetBoolValues(name string) ([]bool, error)

func (*Irsdk) GetData

func (irsdk *Irsdk) GetData() bool

returns true if new valid data is copied from iRacing telemetry to this Irdsk struct

func (*Irsdk) GetDataWithDataReadyTimeout added in v0.5.0

func (irsdk *Irsdk) GetDataWithDataReadyTimeout(dataReadyTimeout time.Duration) bool

returns true if new valid data is copied from iRacing telemetry to this Irdsk struct The call will wait up to dataReadyTimeout for new data to arrive

func (*Irsdk) GetDoubleValue

func (irsdk *Irsdk) GetDoubleValue(name string) (float64, error)

func (*Irsdk) GetDoubleValues

func (irsdk *Irsdk) GetDoubleValues(name string) ([]float64, error)

func (*Irsdk) GetFloatValue

func (irsdk *Irsdk) GetFloatValue(name string) (float32, error)

func (*Irsdk) GetFloatValues

func (irsdk *Irsdk) GetFloatValues(name string) ([]float32, error)

func (*Irsdk) GetIntValue

func (irsdk *Irsdk) GetIntValue(name string) (int32, error)

func (*Irsdk) GetIntValues

func (irsdk *Irsdk) GetIntValues(name string) ([]int32, error)

func (*Irsdk) GetLatestYaml

func (irsdk *Irsdk) GetLatestYaml() *yaml.IrsdkYaml

func (*Irsdk) GetValue

func (irsdk *Irsdk) GetValue(name string) (any, error)

func (*Irsdk) GetValueKeys

func (irsdk *Irsdk) GetValueKeys() []string

func (*Irsdk) GetVarHeaders added in v0.6.0

func (irsdk *Irsdk) GetVarHeaders() []VarHeader

func (*Irsdk) GetYaml

func (irsdk *Irsdk) GetYaml() (*yaml.IrsdkYaml, error)

func (*Irsdk) GetYamlString

func (irsdk *Irsdk) GetYamlString() string

func (*Irsdk) RepairedYaml added in v0.4.3

func (irsdk *Irsdk) RepairedYaml(s string) string

replaces the yaml team and user name with a quoted string these values are not quoted in the original yaml and most certainly cause issues

func (*Irsdk) WaitForValidData

func (irsdk *Irsdk) WaitForValidData() bool

func (*Irsdk) WriteDump

func (irsdk *Irsdk) WriteDump(w io.Writer) (int, error)

type MMap

type MMap []byte

type Option added in v0.5.0

type Option interface {
	// contains filtered or unexported methods
}

func WithWaitForValidDataTimeout added in v0.5.0

func WithWaitForValidDataTimeout(t time.Duration) Option

type SessionState

type SessionState int32
const (
	StateInvalid SessionState = iota
	StateGetInCar
	StateWarmup
	StateParadeLaps
	StateRacing
	StateCheckered
	StateCoolDown
)

type VarBuffer

type VarBuffer struct {
	TickCount int32
	BufOffset int32
	Pad       [2]int32
}

type VarHeader

type VarHeader struct {
	Type        VarType
	Offset      int32
	Count       int32
	CountAsTime bool
	Pad         [3]byte
	Name        [IrsdkMaxString]byte
	Desc        [IrsdkMaxDesc]byte
	Unit        [IrsdkMaxString]byte
}

type VarType

type VarType int32
const (
	// 1 byte
	IrsdkTypeChar VarType = iota
	IrsdkTypeBool
	// 4 bytes
	IrsdkTypeInt
	IrsdkTypeBitField
	IrsdkTypeFloat
	// 8 bytes
	IrsdkTypeDouble
	IrsdkTypeETCount
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL