start and stop behaviour

This commit is contained in:
2026-06-23 10:23:14 +01:00
parent 1614675e9d
commit a28f996330
5 changed files with 26 additions and 10 deletions
+13 -7
View File
@@ -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
+8 -2
View File
@@ -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()
}