Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f569f46499 | ||
|
|
c185289c74 | ||
|
|
34f14e8dc0 | ||
|
|
52056a7da3 |
@@ -1 +1,2 @@
|
|||||||
*.bin
|
*.bin
|
||||||
|
*.work*
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ To start replaying:
|
|||||||
`BeamNGMockOg replay [--loop] -a 127.0.0.1 -p 4443 -i sunburstManual.bin`
|
`BeamNGMockOg replay [--loop] -a 127.0.0.1 -p 4443 -i sunburstManual.bin`
|
||||||
- `loop` allows the replay functionality to keep replaying the same data file
|
- `loop` allows the replay functionality to keep replaying the same data file
|
||||||
|
|
||||||
|
|
||||||
To start recording:
|
To start recording:
|
||||||
`BeamNGMockOg record -a 127.0.0.1 -p 4443 -o sunburstDCT.bin`
|
`BeamNGMockOg record -a 127.0.0.1 -p 4443 -o sunburstDCT.bin`
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ To start recording:
|
|||||||
Use `tcpdump` to listen to the socket and check if data is coming through:
|
Use `tcpdump` to listen to the socket and check if data is coming through:
|
||||||
`tcpdump -i any udp port <port> -X`
|
`tcpdump -i any udp port <port> -X`
|
||||||
|
|
||||||
|
|
||||||
### Benchmark
|
### Benchmark
|
||||||
Run with:
|
Run with:
|
||||||
`go test ./mockserver -bench=BenchmarkReplayAsync -benchmem -benchtime=1x -memprofile=mem.pprof`
|
`go test ./mockserver -bench=BenchmarkReplayAsync -benchmem -benchtime=1x -memprofile=mem.pprof`
|
||||||
@@ -33,16 +35,10 @@ Analyze the output with:
|
|||||||
or
|
or
|
||||||
`go tool pprof -http=:8080 mem.pprof`
|
`go tool pprof -http=:8080 mem.pprof`
|
||||||
|
|
||||||
#### Previous results:
|
|
||||||
goos: linux
|
|
||||||
goarch: amd64
|
|
||||||
pkg: github.com/ESilva15/BeamNGMockOg/mockserver
|
|
||||||
cpu: AMD Ryzen 5 5600G with Radeon Graphics
|
|
||||||
BenchmarkReplayAsync-12 1 109433574741 ns/op 4533008 B/op 66059 allocs/op
|
|
||||||
PASS
|
|
||||||
ok github.com/ESilva15/BeamNGMockOg/mockserver 109.438s
|
|
||||||
|
|
||||||
#### Current results
|
#### Previous results:
|
||||||
|
Note: this were made before introducing the real time visualizer
|
||||||
|
```
|
||||||
goos: linux
|
goos: linux
|
||||||
goarch: amd64
|
goarch: amd64
|
||||||
pkg: github.com/ESilva15/BeamNGMockOg/mockserver
|
pkg: github.com/ESilva15/BeamNGMockOg/mockserver
|
||||||
@@ -50,3 +46,16 @@ cpu: AMD Ryzen 5 5600G with Radeon Graphics
|
|||||||
BenchmarkReplayAsync-12 1 109433931841 ns/op 356088 B/op 13272 allocs/op
|
BenchmarkReplayAsync-12 1 109433931841 ns/op 356088 B/op 13272 allocs/op
|
||||||
PASS
|
PASS
|
||||||
ok github.com/ESilva15/BeamNGMockOg/mockserver 109.440s
|
ok github.com/ESilva15/BeamNGMockOg/mockserver 109.440s
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Current results
|
||||||
|
```
|
||||||
|
goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
pkg: github.com/ESilva15/BeamNGMockOg/mockserver
|
||||||
|
cpu: AMD Ryzen 7 5800X3D 8-Core Processor
|
||||||
|
BenchmarkReplayAsync-16 1 109433890158 ns/op 1673128 B/op 112986 allocs/op
|
||||||
|
PASS
|
||||||
|
ok github.com/ESilva15/BeamNGMockOg/mockserver 109.439s
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
module github.com/ESilva15/BeamNGMockOg
|
module github.com/ESilva15/BeamNGMockOg
|
||||||
|
|
||||||
replace github.com/ESilva15/gobngsdk => ../pkg/bngsdk
|
|
||||||
|
|
||||||
go 1.23.2
|
go 1.23.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ESilva15/gobngsdk v0.0.0-00010101000000-000000000000
|
github.com/ESilva15/gobngsdk v1.1.3
|
||||||
github.com/spf13/cobra v1.10.1
|
github.com/spf13/cobra v1.10.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
github.com/ESilva15/gobngsdk v0.0.2 h1:N6stNOE14Wg80BAZMFu/Qd9Qa/J0DmExCfdPoDf7lco=
|
github.com/ESilva15/gobngsdk v1.1.3 h1:CFaz2KjHKnBLrQuEN1QHOd1761cWM/rmTwLpSLrgbe4=
|
||||||
github.com/ESilva15/gobngsdk v0.0.2/go.mod h1:cKLaZRgM0tGGXDvosaSjHnxeyC5Y6rg7zCLqEUJnOzw=
|
github.com/ESilva15/gobngsdk v1.1.3/go.mod h1:cKLaZRgM0tGGXDvosaSjHnxeyC5Y6rg7zCLqEUJnOzw=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
|
|||||||
+18
-26
@@ -6,7 +6,6 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ import (
|
|||||||
|
|
||||||
type recorderViewData struct {
|
type recorderViewData struct {
|
||||||
TotalBytes int
|
TotalBytes int
|
||||||
Data []byte
|
SDK *bngsdk.BeamNGSDK
|
||||||
}
|
}
|
||||||
|
|
||||||
type Recorder struct {
|
type Recorder struct {
|
||||||
@@ -65,10 +64,10 @@ func (r *Recorder) record(ctx context.Context) {
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case data := <-r.recorderCh:
|
case data := <-r.recorderCh:
|
||||||
r.mut.RLock()
|
r.mut.Lock()
|
||||||
err := binary.Write(r.OutputFile, binary.LittleEndian, data)
|
err := binary.Write(r.OutputFile, binary.LittleEndian, r.SDK.Data)
|
||||||
r.TotalBytes += len(data)
|
r.TotalBytes += len(data)
|
||||||
r.mut.RUnlock()
|
r.mut.Unlock()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// NOTE: find a way of logging this somehow
|
// NOTE: find a way of logging this somehow
|
||||||
@@ -78,37 +77,31 @@ func (r *Recorder) record(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Recorder) view(ctx context.Context) {
|
func (r *Recorder) view(ctx context.Context) {
|
||||||
var s strings.Builder
|
var buf bytes.Buffer
|
||||||
var nBytes int
|
var nBytes int
|
||||||
var bytesReader bytes.Reader
|
|
||||||
og := bngsdk.Outgauge{}
|
buf.Grow(2048)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case viewData := <-r.viewCh:
|
case viewData := <-r.viewCh:
|
||||||
s.Reset()
|
buf.Reset()
|
||||||
fmt.Fprintf(os.Stdout, "\x1b[2J\x1b[H")
|
buf.WriteString("\x1b[2J\x1b[H")
|
||||||
|
fmt.Fprintf(&buf, "\x1b]0;%s - Recording ", ProgramName)
|
||||||
|
stringifyRecordingProgress(&buf, nBytes)
|
||||||
|
fmt.Fprintf(&buf, "\x07")
|
||||||
|
|
||||||
|
stringifyRecordingProgress(&buf, nBytes)
|
||||||
|
fmt.Fprintf(&buf, "\n\n")
|
||||||
|
|
||||||
r.viewDataMut.RLock()
|
r.viewDataMut.RLock()
|
||||||
nBytes = viewData.TotalBytes
|
nBytes = viewData.TotalBytes
|
||||||
|
stringifyOutgaugeData(&buf, &r.SDK)
|
||||||
r.viewDataMut.RUnlock()
|
r.viewDataMut.RUnlock()
|
||||||
|
|
||||||
stringifyRecordingProgress(&s, nBytes)
|
_, _ = buf.WriteTo(os.Stdout)
|
||||||
fmt.Fprintf(&s, "\n\n")
|
|
||||||
|
|
||||||
bytesReader.Reset(viewData.Data)
|
|
||||||
err := binary.Read(&bytesReader, binary.LittleEndian, &og)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(&s, "\n\nFAILED TO PARSE DATA\nError: %+v\n\n", err)
|
|
||||||
fmt.Fprint(os.Stdout, s.String())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
stringifyOutgaugeData(&s, &og)
|
|
||||||
|
|
||||||
fmt.Fprint(os.Stdout, s.String())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,7 +125,6 @@ func (r *Recorder) Record(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.viewData.TotalBytes = r.TotalBytes
|
r.viewData.TotalBytes = r.TotalBytes
|
||||||
r.viewData.Data = r.SDK.Buffer
|
|
||||||
|
|
||||||
// Send the data to the view
|
// Send the data to the view
|
||||||
select {
|
select {
|
||||||
@@ -142,7 +134,7 @@ func (r *Recorder) Record(ctx context.Context) error {
|
|||||||
// Dropped the frame!
|
// Dropped the frame!
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the data to the UDP socket
|
// Write the data to the file
|
||||||
select {
|
select {
|
||||||
case r.recorderCh <- r.SDK.Buffer:
|
case r.recorderCh <- r.SDK.Buffer:
|
||||||
// Sent the data
|
// Sent the data
|
||||||
|
|||||||
+30
-25
@@ -9,7 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -18,13 +17,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ViewData struct {
|
type ViewData struct {
|
||||||
Data []byte
|
SDK *bngsdk.BeamNGSDK
|
||||||
SizeRead int64
|
SizeRead int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replayer does the replaying
|
// Replayer does the replaying
|
||||||
// Should we make a "player" struct that can record and replay?
|
// Should we make a "player" struct that can record and replay?
|
||||||
type Replayer struct {
|
type Replayer struct {
|
||||||
|
SDK bngsdk.BeamNGSDK
|
||||||
DataSourcePath string
|
DataSourcePath string
|
||||||
Socket *UDPTransport
|
Socket *UDPTransport
|
||||||
|
|
||||||
@@ -33,8 +33,7 @@ type Replayer struct {
|
|||||||
socketCh chan []byte
|
socketCh chan []byte
|
||||||
|
|
||||||
// Mut
|
// Mut
|
||||||
mut sync.RWMutex
|
mut sync.RWMutex
|
||||||
data []byte
|
|
||||||
|
|
||||||
// View
|
// View
|
||||||
viewData ViewData
|
viewData ViewData
|
||||||
@@ -48,11 +47,14 @@ func NewReplayer(address string, port int, fp string) (*Replayer, error) {
|
|||||||
|
|
||||||
replayer := &Replayer{
|
replayer := &Replayer{
|
||||||
DataSourcePath: fp,
|
DataSourcePath: fp,
|
||||||
Socket: udp,
|
SDK: bngsdk.BeamNGSDK{
|
||||||
data: make([]byte, unsafe.Sizeof(bngsdk.Outgauge{})),
|
Data: bngsdk.Outgauge{},
|
||||||
viewData: ViewData{},
|
Buffer: make([]byte, unsafe.Sizeof(bngsdk.Outgauge{})),
|
||||||
dataViewCh: make(chan ViewData, 1),
|
},
|
||||||
socketCh: make(chan []byte, 1),
|
Socket: udp,
|
||||||
|
viewData: ViewData{},
|
||||||
|
dataViewCh: make(chan ViewData, 1),
|
||||||
|
socketCh: make(chan []byte, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
return replayer, nil
|
return replayer, nil
|
||||||
@@ -66,10 +68,10 @@ func (r *Replayer) renderToTerminal(ctx context.Context) {
|
|||||||
// return fmt.Errorf("error stating file: %v", err)
|
// return fmt.Errorf("error stating file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: temporary until I make a better view
|
var buf bytes.Buffer
|
||||||
var s strings.Builder
|
|
||||||
var bytesReader bytes.Reader
|
var bytesReader bytes.Reader
|
||||||
og := bngsdk.Outgauge{}
|
|
||||||
|
buf.Grow(2048)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@@ -77,23 +79,25 @@ func (r *Replayer) renderToTerminal(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
case data := <-r.dataViewCh:
|
case data := <-r.dataViewCh:
|
||||||
// Reset to the start of the terminal
|
// Reset to the start of the terminal
|
||||||
s.Reset()
|
percent := int(float64(data.SizeRead) / float64(fileInfo.Size()) * 100)
|
||||||
fmt.Fprintf(os.Stdout, "\x1b[2J\x1b[H")
|
|
||||||
|
|
||||||
bytesReader.Reset(data.Data)
|
buf.Reset()
|
||||||
err := binary.Read(&bytesReader, binary.LittleEndian, &og)
|
buf.WriteString("\x1b[2J\x1b[H")
|
||||||
|
fmt.Fprintf(&buf, "\x1b]0;%s - Replaying %d%%\x07", ProgramName, percent)
|
||||||
|
|
||||||
|
bytesReader.Reset(data.SDK.Buffer)
|
||||||
|
err := binary.Read(&bytesReader, binary.LittleEndian, &r.SDK.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(&s, "FAILED TO PARSE DATA\nError: %+v", err)
|
fmt.Fprintf(&buf, "FAILED TO PARSE DATA\nError: %+v", err)
|
||||||
fmt.Fprint(os.Stdout, s.String())
|
_, _ = buf.WriteTo(os.Stdout)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
percent := int(float64(data.SizeRead) / float64(fileInfo.Size()) * 100)
|
fmt.Fprintf(&buf, "Replayed: %d%%\n", percent)
|
||||||
fmt.Fprintf(&s, "Replayed: %d%%\n", percent)
|
|
||||||
|
|
||||||
stringifyOutgaugeData(&s, &og)
|
stringifyOutgaugeData(&buf, data.SDK)
|
||||||
|
|
||||||
fmt.Fprint(os.Stdout, s.String())
|
buf.WriteTo(os.Stdout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +143,7 @@ func (r *Replayer) Replay(ctx context.Context, loop bool) error {
|
|||||||
|
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
r.mut.Lock()
|
r.mut.Lock()
|
||||||
err := reader.Next(r.data)
|
err := reader.Next(r.SDK.Buffer)
|
||||||
r.mut.Unlock()
|
r.mut.Unlock()
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
@@ -159,7 +163,8 @@ func (r *Replayer) Replay(ctx context.Context, loop bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r.viewData.Data = r.data
|
// NOTE: Really like this???
|
||||||
|
r.viewData.SDK = &r.SDK
|
||||||
r.viewData.SizeRead = reader.TotalRead
|
r.viewData.SizeRead = reader.TotalRead
|
||||||
|
|
||||||
// Send the data to the view
|
// Send the data to the view
|
||||||
@@ -172,7 +177,7 @@ func (r *Replayer) Replay(ctx context.Context, loop bool) error {
|
|||||||
|
|
||||||
// Send the data to the UDP socket
|
// Send the data to the UDP socket
|
||||||
select {
|
select {
|
||||||
case r.socketCh <- r.data:
|
case r.socketCh <- r.SDK.Buffer:
|
||||||
// Sent the data
|
// Sent the data
|
||||||
default:
|
default:
|
||||||
// Dropped the frame!
|
// Dropped the frame!
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const ProgramName = "TelemetryMockerserver"
|
||||||
|
|
||||||
type Transport interface {
|
type Transport interface {
|
||||||
Send(data []byte) error
|
Send(data []byte) error
|
||||||
Close() error
|
Close() error
|
||||||
|
|||||||
+50
-50
@@ -1,8 +1,8 @@
|
|||||||
package mockserver
|
package mockserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
bngsdk "github.com/ESilva15/gobngsdk"
|
bngsdk "github.com/ESilva15/gobngsdk"
|
||||||
)
|
)
|
||||||
@@ -14,7 +14,7 @@ const (
|
|||||||
GiB
|
GiB
|
||||||
)
|
)
|
||||||
|
|
||||||
func stringifyRecordingProgress(s *strings.Builder, nBytes int) {
|
func stringifyRecordingProgress(s *bytes.Buffer, nBytes int) {
|
||||||
if nBytes < KiB {
|
if nBytes < KiB {
|
||||||
fmt.Fprintf(s, "%d B", nBytes)
|
fmt.Fprintf(s, "%d B", nBytes)
|
||||||
} else if nBytes < MiB {
|
} else if nBytes < MiB {
|
||||||
@@ -26,64 +26,64 @@ func stringifyRecordingProgress(s *strings.Builder, nBytes int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringifyOutgaugeData(s *strings.Builder, og *bngsdk.Outgauge) {
|
func stringifyOutgaugeData(s *bytes.Buffer, sdk *bngsdk.BeamNGSDK) {
|
||||||
// NOTE: write a string serialization function on the SDK itself
|
// NOTE: write a string serialization function on the SDK itself
|
||||||
fmt.Fprint(s, "Outgauge {\n")
|
fmt.Fprint(s, "Outgauge {\n")
|
||||||
fmt.Fprintf(s, " Time: %d ms\n", og.Time)
|
fmt.Fprintf(s, " Time: %d ms\n", sdk.Data.Time)
|
||||||
fmt.Fprintf(s, " Car: %s\n", og.Car)
|
fmt.Fprintf(s, " Car: %s\n", sdk.Data.Car)
|
||||||
fmt.Fprintf(s, " Flags: %b\n", og.Flags)
|
fmt.Fprintf(s, " Flags: %b\n", sdk.Data.Flags)
|
||||||
fmt.Fprintf(s, " Gear: %d\n", og.Gear)
|
fmt.Fprintf(s, " Gear: %d\n", sdk.Data.Gear)
|
||||||
fmt.Fprintf(s, " Plid: %d\n", og.Plid)
|
fmt.Fprintf(s, " Plid: %d\n", sdk.Data.Plid)
|
||||||
fmt.Fprintf(s, " Speed: %f m/s\n", og.Speed)
|
fmt.Fprintf(s, " Speed: %f m/s\n", sdk.Data.Speed)
|
||||||
fmt.Fprintf(s, " RPM: %f RPM\n", og.RPM)
|
fmt.Fprintf(s, " RPM: %f RPM\n", sdk.Data.RPM)
|
||||||
fmt.Fprintf(s, " Turbo: %f Bar\n", og.Turbo)
|
fmt.Fprintf(s, " Turbo: %f Bar\n", sdk.Data.Turbo)
|
||||||
fmt.Fprintf(s, " EngTemp: %f °C\n", og.EngTemp)
|
fmt.Fprintf(s, " EngTemp: %f °C\n", sdk.Data.EngTemp)
|
||||||
fmt.Fprintf(s, " Fuel: %f\n", og.Fuel)
|
fmt.Fprintf(s, " Fuel: %f\n", sdk.Data.Fuel)
|
||||||
fmt.Fprintf(s, " OilPressure: %f Bar\n", og.OilPressure)
|
fmt.Fprintf(s, " OilPressure: %f Bar\n", sdk.Data.OilPressure)
|
||||||
fmt.Fprintf(s, " OilTemp: %f °C\n", og.OilTemp)
|
fmt.Fprintf(s, " OilTemp: %f °C\n", sdk.Data.OilTemp)
|
||||||
fmt.Fprintf(s, " DashLights: %b\n", og.DashLights)
|
fmt.Fprintf(s, " DashLights: %b\n", sdk.Data.DashLights)
|
||||||
fmt.Fprintf(s, " ShowLights: %b\n", og.ShowLights)
|
fmt.Fprintf(s, " ShowLights: %b\n", sdk.Data.ShowLights)
|
||||||
fmt.Fprintf(s, " Throttle: %f\n", og.Throttle)
|
fmt.Fprintf(s, " Throttle: %f\n", sdk.Data.Throttle)
|
||||||
fmt.Fprintf(s, " Brakes: %f\n", og.Brake)
|
fmt.Fprintf(s, " Brakes: %f\n", sdk.Data.Brake)
|
||||||
fmt.Fprintf(s, " Clutch: %f\n", og.Clutch)
|
fmt.Fprintf(s, " Clutch: %f\n", sdk.Data.Clutch)
|
||||||
fmt.Fprintf(s, " Display1: %s\n", og.Display1)
|
fmt.Fprintf(s, " Display1: %s\n", sdk.Data.Display1)
|
||||||
fmt.Fprintf(s, " Display2: %s\n", og.Display2)
|
fmt.Fprintf(s, " Display2: %s\n", sdk.Data.Display2)
|
||||||
fmt.Fprintf(s, " ID: %d\n", og.Display2)
|
fmt.Fprintf(s, " ID: %d\n", sdk.Data.ID)
|
||||||
fmt.Fprint(s, "}\n\n")
|
fmt.Fprint(s, "}\n\n")
|
||||||
|
|
||||||
fmt.Fprint(s, "DashLights {\n")
|
fmt.Fprint(s, "DashLights {\n")
|
||||||
fmt.Fprintf(s, " DL_SHIFT: %t\n", og.DashLights&bngsdk.DL_SHIFT != 0)
|
fmt.Fprintf(s, " DL_SHIFT: %t\n", sdk.HasShiftLight())
|
||||||
fmt.Fprintf(s, " DL_FULLBEAM: %t\n", og.DashLights&bngsdk.DL_FULLBEAM != 0)
|
fmt.Fprintf(s, " DL_FULLBEAM: %t\n", sdk.HasHighBeamLight())
|
||||||
fmt.Fprintf(s, " DL_HANDBRAKE: %t\n", og.DashLights&bngsdk.DL_HANDBRAKE != 0)
|
fmt.Fprintf(s, " DL_HANDBRAKE: %t\n", sdk.HasHandbrakeLight())
|
||||||
fmt.Fprintf(s, " DL_PITSPEED: %t\n", og.DashLights&bngsdk.DL_PITSPEED != 0)
|
fmt.Fprintf(s, " DL_PITSPEED: %t\n", sdk.HasPitspeed())
|
||||||
fmt.Fprintf(s, " DL_TC: %t\n", og.DashLights&bngsdk.DL_TC != 0)
|
fmt.Fprintf(s, " DL_TC: %t\n", sdk.HasTractionControlLight())
|
||||||
fmt.Fprintf(s, " DL_SIGNAL_L: %t\n", og.DashLights&bngsdk.DL_SIGNAL_L != 0)
|
fmt.Fprintf(s, " DL_SIGNAL_L: %t\n", sdk.HasLeftIndicatorLight())
|
||||||
fmt.Fprintf(s, " DL_SIGNAL_R: %t\n", og.DashLights&bngsdk.DL_SIGNAL_R != 0)
|
fmt.Fprintf(s, " DL_SIGNAL_R: %t\n", sdk.HasRightIndicatorLight())
|
||||||
fmt.Fprintf(s, " DL_SIGNAL_ANY: %t\n", og.DashLights&bngsdk.DL_SIGNAL_ANY != 0)
|
fmt.Fprintf(s, " DL_SIGNAL_ANY: %t\n", sdk.HasAnyIndicatorLight())
|
||||||
fmt.Fprintf(s, " DL_OILWARN: %t\n", og.DashLights&bngsdk.DL_OILWARN != 0)
|
fmt.Fprintf(s, " DL_OILWARN: %t\n", sdk.HasOilLight())
|
||||||
fmt.Fprintf(s, " DL_BATTERY: %t\n", og.DashLights&bngsdk.DL_BATTERY != 0)
|
fmt.Fprintf(s, " DL_BATTERY: %t\n", sdk.HasBatteryLight())
|
||||||
fmt.Fprintf(s, " DL_ABS: %t\n", og.DashLights&bngsdk.DL_ABS != 0)
|
fmt.Fprintf(s, " DL_ABS: %t\n", sdk.HasABSLight())
|
||||||
fmt.Fprintf(s, " DL_SPARE: %t\n", og.DashLights&bngsdk.DL_SPARE != 0)
|
fmt.Fprintf(s, " DL_SPARE: %t\n", sdk.Data.DashLights&bngsdk.DL_SPARE != 0)
|
||||||
fmt.Fprint(s, "}\n\n")
|
fmt.Fprint(s, "}\n\n")
|
||||||
|
|
||||||
fmt.Fprint(s, "ShowLights {\n") // Fixed typo "ShowLigths"
|
fmt.Fprint(s, "ShowLights {\n") // Fixed typo "ShowLigths"
|
||||||
fmt.Fprintf(s, " DL_SHIFT: %t\n", og.ShowLights&bngsdk.DL_SHIFT != 0)
|
fmt.Fprintf(s, " DL_SHIFT: %t\n", sdk.ShiftLight())
|
||||||
fmt.Fprintf(s, " DL_FULLBEAM: %t\n", og.ShowLights&bngsdk.DL_FULLBEAM != 0)
|
fmt.Fprintf(s, " DL_FULLBEAM: %t\n", sdk.HighBeam())
|
||||||
fmt.Fprintf(s, " DL_HANDBRAKE: %t\n", og.ShowLights&bngsdk.DL_HANDBRAKE != 0)
|
fmt.Fprintf(s, " DL_HANDBRAKE: %t\n", sdk.Handbrake())
|
||||||
fmt.Fprintf(s, " DL_PITSPEED: %t\n", og.ShowLights&bngsdk.DL_PITSPEED != 0)
|
fmt.Fprintf(s, " DL_PITSPEED: %t\n", sdk.Pitspeed())
|
||||||
fmt.Fprintf(s, " DL_TC: %t\n", og.ShowLights&bngsdk.DL_TC != 0)
|
fmt.Fprintf(s, " DL_TC: %t\n", sdk.TractionControl())
|
||||||
fmt.Fprintf(s, " DL_SIGNAL_L: %t\n", og.ShowLights&bngsdk.DL_SIGNAL_L != 0)
|
fmt.Fprintf(s, " DL_SIGNAL_L: %t\n", sdk.LeftIndicator())
|
||||||
fmt.Fprintf(s, " DL_SIGNAL_R: %t\n", og.ShowLights&bngsdk.DL_SIGNAL_R != 0)
|
fmt.Fprintf(s, " DL_SIGNAL_R: %t\n", sdk.RightIndicator())
|
||||||
fmt.Fprintf(s, " DL_SIGNAL_ANY: %t\n", og.ShowLights&bngsdk.DL_SIGNAL_ANY != 0)
|
fmt.Fprintf(s, " DL_SIGNAL_ANY: %t\n", sdk.AnyIndicator())
|
||||||
fmt.Fprintf(s, " DL_OILWARN: %t\n", og.ShowLights&bngsdk.DL_OILWARN != 0)
|
fmt.Fprintf(s, " DL_OILWARN: %t\n", sdk.OilLight())
|
||||||
fmt.Fprintf(s, " DL_BATTERY: %t\n", og.ShowLights&bngsdk.DL_BATTERY != 0)
|
fmt.Fprintf(s, " DL_BATTERY: %t\n", sdk.BatteryLight())
|
||||||
fmt.Fprintf(s, " DL_ABS: %t\n", og.ShowLights&bngsdk.DL_ABS != 0)
|
fmt.Fprintf(s, " DL_ABS: %t\n", sdk.ABS())
|
||||||
fmt.Fprintf(s, " DL_SPARE: %t\n", og.ShowLights&bngsdk.DL_SPARE != 0)
|
fmt.Fprintf(s, " DL_SPARE: %t\n", sdk.Data.ShowLights&bngsdk.DL_SPARE != 0)
|
||||||
fmt.Fprint(s, "}\n\n")
|
fmt.Fprint(s, "}\n\n")
|
||||||
|
|
||||||
fmt.Fprint(s, "Flags {\n")
|
fmt.Fprint(s, "Flags {\n")
|
||||||
fmt.Fprintf(s, " OG_TURBO (Has Turbo): %t\n", og.Flags&bngsdk.OG_TURBO != 0)
|
fmt.Fprintf(s, " OG_TURBO (Has Turbo): %t\n", sdk.HasTurbo())
|
||||||
fmt.Fprintf(s, " OG_KM (Is Metric): %t\n", og.Flags&bngsdk.OG_KM != 0)
|
fmt.Fprintf(s, " OG_KM (Is Metric): %t\n", sdk.PrefersKm())
|
||||||
fmt.Fprintf(s, " OG_BAR (Pressure): %t\n", og.Flags&bngsdk.OG_BAR != 0)
|
fmt.Fprintf(s, " OG_BAR (Pressure): %t\n", sdk.PrefersBAR())
|
||||||
fmt.Fprint(s, "}")
|
fmt.Fprint(s, "}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user