added the form items to set the TelemetryField on UI windows
This commit is contained in:
+49
-25
@@ -1,29 +1,5 @@
|
||||
Windows:
|
||||
1:
|
||||
uiwindow:
|
||||
Dims:
|
||||
X0: 50
|
||||
Y0: 46
|
||||
Width: 117
|
||||
Height: 70
|
||||
Decor:
|
||||
BGColour: 4161
|
||||
FGColour: 65535
|
||||
TitleColour: 65535
|
||||
BorderColour: 63488
|
||||
TitleSize: 2
|
||||
TextSize: 6
|
||||
HasBorder: 1
|
||||
Padding: 0
|
||||
Opts:
|
||||
ShowID: 0
|
||||
WinType: 0
|
||||
PreviewValue: "234"
|
||||
Title: SPEEDO
|
||||
uidata:
|
||||
WID: 1
|
||||
TelemetryField: ""
|
||||
2:
|
||||
uiwindow:
|
||||
Dims:
|
||||
X0: 200
|
||||
@@ -44,6 +20,54 @@ Windows:
|
||||
WinType: 0
|
||||
PreviewValue: "4356"
|
||||
Title: TACHO
|
||||
uidata:
|
||||
WID: 1
|
||||
TelemetryField: RPM
|
||||
2:
|
||||
uiwindow:
|
||||
Dims:
|
||||
X0: 50
|
||||
Y0: 46
|
||||
Width: 117
|
||||
Height: 70
|
||||
Decor:
|
||||
BGColour: 4161
|
||||
FGColour: 65535
|
||||
TitleColour: 65535
|
||||
BorderColour: 63488
|
||||
TitleSize: 2
|
||||
TextSize: 6
|
||||
HasBorder: 1
|
||||
Padding: 0
|
||||
Opts:
|
||||
ShowID: 0
|
||||
WinType: 0
|
||||
PreviewValue: "234"
|
||||
Title: SPEEDO
|
||||
uidata:
|
||||
WID: 2
|
||||
TelemetryField: ""
|
||||
TelemetryField: Speed
|
||||
3:
|
||||
uiwindow:
|
||||
Dims:
|
||||
X0: 390
|
||||
Y0: 45
|
||||
Width: 50
|
||||
Height: 71
|
||||
Decor:
|
||||
BGColour: 4161
|
||||
FGColour: 65535
|
||||
TitleColour: 65535
|
||||
BorderColour: 63488
|
||||
TitleSize: 2
|
||||
TextSize: 6
|
||||
HasBorder: 1
|
||||
Padding: 0
|
||||
Opts:
|
||||
ShowID: 0
|
||||
WinType: 0
|
||||
PreviewValue: R
|
||||
Title: Box
|
||||
uidata:
|
||||
WID: 3
|
||||
TelemetryField: Gear
|
||||
|
||||
@@ -2,8 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"esdi/cmd"
|
||||
"esdi/telemetry"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/arl/statsviz"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -18,6 +22,17 @@ func main() {
|
||||
}),
|
||||
)
|
||||
|
||||
// Performance analysis
|
||||
mux := http.NewServeMux()
|
||||
statsviz.Register(mux)
|
||||
|
||||
go func() {
|
||||
http.ListenAndServe("localhost:8001", mux)
|
||||
}()
|
||||
|
||||
// Setting up some internal data structures
|
||||
telemetry.Init()
|
||||
|
||||
// Launches the cobra package stuff
|
||||
cmd.Execute(logger)
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ func (tf *TelemetryField) String() string {
|
||||
|
||||
type FieldID uint16
|
||||
|
||||
// We use FirstField to start the count on the fields the user can select
|
||||
// the first three will be for internal use
|
||||
const (
|
||||
FirstTimeStamp FieldID = iota
|
||||
PreviousTimeStamp
|
||||
@@ -121,6 +123,9 @@ func initFieldNamesMap() {
|
||||
|
||||
func GetFieldID(name string) (FieldID, bool) {
|
||||
id, ok := fieldNameToID[name]
|
||||
if ok {
|
||||
id = id - FirstField
|
||||
}
|
||||
return id, ok
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package controllers
|
||||
import (
|
||||
"esdi/cdashdisplay"
|
||||
helper "esdi/helpers"
|
||||
"esdi/telemetry"
|
||||
"esdi/tui/internal/services"
|
||||
"esdi/tui/internal/views"
|
||||
"fmt"
|
||||
@@ -212,6 +213,16 @@ func (lc *LayoutController) createWindow() {
|
||||
// the buttons for that purpuse
|
||||
func (lc *LayoutController) updateFormView(win *cdashdisplay.DesktopUIWindow) error {
|
||||
// OnSuccess we update our form to be an existing window form
|
||||
|
||||
lc.Messages <- fmt.Sprintf("Setting up window:\n%+v\n", win)
|
||||
|
||||
telemFieldID, ok := telemetry.GetFieldID(win.UIData.TelemetryField)
|
||||
if !ok {
|
||||
telemFieldID = 1000
|
||||
}
|
||||
|
||||
lc.Messages <- fmt.Sprintf("field id for: %s is %d\n", win.UIData.TelemetryField, telemFieldID)
|
||||
|
||||
err := lc.LayoutToolView.WindowCreatedSuccessfuly(win)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -51,7 +51,7 @@ func NewCDashDisplayWindowFormView() *CDashDisplayWindowFormView {
|
||||
view.TextSize.SetCurrentOption(0)
|
||||
|
||||
view.TelemetryField = tview.NewDropDown().SetLabel("Telemetry Field")
|
||||
for _, fieldName := range telemetry.FieldNames {
|
||||
for _, fieldName := range telemetry.FieldNames[3:] {
|
||||
view.TelemetryField.AddOption(fieldName, blankDropdownOptionCallback)
|
||||
}
|
||||
view.TelemetryField.SetCurrentOption(0)
|
||||
@@ -66,7 +66,8 @@ func NewCDashDisplayWindowFormView() *CDashDisplayWindowFormView {
|
||||
AddFormItem(view.ShowID).
|
||||
AddFormItem(view.WinType).
|
||||
AddFormItem(view.TitleSize).
|
||||
AddFormItem(view.TextSize)
|
||||
AddFormItem(view.TextSize).
|
||||
AddFormItem(view.TelemetryField)
|
||||
|
||||
view.Form.SetBorder(true).
|
||||
SetTitle("New Window Form").
|
||||
@@ -132,7 +133,7 @@ func (fv *WindowFormView) SetValues(win *cdashdisplay.DesktopUIWindow) {
|
||||
|
||||
telemFieldID, ok := telemetry.GetFieldID(win.UIData.TelemetryField)
|
||||
if !ok {
|
||||
telemFieldID = 0
|
||||
telemFieldID = 100
|
||||
}
|
||||
fv.Form.TelemetryField.SetCurrentOption(int(telemFieldID))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user