start and stop behaviour
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
bngsdk "github.com/ESilva15/gobngsdk"
|
||||
)
|
||||
|
||||
// This will implement the GameSink interface from the main package
|
||||
type BeamNG struct {
|
||||
SDK *bngsdk.BNGSDK
|
||||
}
|
||||
|
||||
@@ -160,6 +160,10 @@ func (i *IRacing) Stream() (<-chan telem.TelemetryData, error) {
|
||||
return i.streamCh, nil
|
||||
}
|
||||
|
||||
func (i *IRacing) StopStream() {
|
||||
i.streamCancel()
|
||||
}
|
||||
|
||||
func (i *IRacing) Subscribe(requestFields map[int16]telem.FieldID) {
|
||||
i.logger.Debug(fmt.Sprintf("Len Req: %d\n", len(requestFields)))
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package telemetry
|
||||
|
||||
type TelemetryProvider interface {
|
||||
StopStream()
|
||||
Stream() (<-chan TelemetryData, error)
|
||||
Subscribe(map[int16]FieldID)
|
||||
}
|
||||
|
||||
@@ -21,8 +21,10 @@ type StreamingCtrl struct {
|
||||
Internal chan string
|
||||
Run bool
|
||||
OnExit func()
|
||||
isRunning bool
|
||||
TelemServ *services.TelemetryService
|
||||
|
||||
// Stream State
|
||||
isRunning bool
|
||||
}
|
||||
|
||||
func NewStreamingCtrl(
|
||||
@@ -62,11 +64,8 @@ func (sc *StreamingCtrl) registerHooks() {
|
||||
|
||||
switch ev.Rune() {
|
||||
case 's':
|
||||
// Start
|
||||
sc.Start()
|
||||
case 'p':
|
||||
// Pause
|
||||
// sc.Stop()
|
||||
// Start - stop
|
||||
sc.StartStop()
|
||||
case 'u':
|
||||
// Update
|
||||
// NOTE: run the same routine for the form Update button here
|
||||
@@ -85,8 +84,15 @@ func (sc *StreamingCtrl) registerHooks() {
|
||||
}
|
||||
}
|
||||
|
||||
func (sc *StreamingCtrl) Start() {
|
||||
func (sc *StreamingCtrl) StartStop() {
|
||||
if sc.isRunning {
|
||||
sc.TelemServ.StopStream()
|
||||
sc.isRunning = false
|
||||
return
|
||||
}
|
||||
|
||||
stream := sc.TelemServ.StartStream()
|
||||
sc.isRunning = true
|
||||
|
||||
var isDrawing atomic.Bool
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
providerir "esdi/providers/iracing"
|
||||
"log/slog"
|
||||
|
||||
providerir "esdi/providers/iracing"
|
||||
|
||||
telemetry "esdi/telemetry"
|
||||
)
|
||||
|
||||
@@ -48,8 +49,13 @@ func (t *TelemetryService) SetProvider(provider string) *TelemetryService {
|
||||
func (t *TelemetryService) StartStream() <-chan telemetry.TelemetryData {
|
||||
stream, _ := t.ActiveProvider.Stream()
|
||||
|
||||
// Somewhere around here we have to tell the device service to also send data
|
||||
// NOTE: we don't want to just send data to the cdashdisplay. We want to support
|
||||
// multiple devices at the same time
|
||||
t.cdash.StreamData(stream)
|
||||
|
||||
return stream
|
||||
}
|
||||
|
||||
func (t *TelemetryService) StopStream() {
|
||||
t.ActiveProvider.StopStream()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user