parent
6521b707dd
commit
3c46e309e0
@ -1,10 +1,42 @@ |
|||||||
github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc= |
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= |
||||||
github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY= |
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= |
||||||
github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o= |
github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg= |
||||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= |
github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5y65J2H8Y= |
||||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= |
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= |
||||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= |
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= |
||||||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840= |
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= |
||||||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= |
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= |
||||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= |
github.com/rivo/tview v0.0.0-20230621164836-6cc0565babaf h1:IchpMMtnfvzg7T3je672bP1nKWz1M4tW3kMZT6CbgoM= |
||||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
github.com/rivo/tview v0.0.0-20230621164836-6cc0565babaf/go.mod h1:nVwGv4MP47T0jvlk7KuTTjjuSmrGO4JF0iaiNt4bufE= |
||||||
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= |
||||||
|
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= |
||||||
|
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= |
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= |
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= |
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= |
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= |
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||||
|
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= |
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= |
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= |
||||||
|
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= |
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= |
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= |
||||||
|
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= |
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= |
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= |
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= |
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||||
|
@ -0,0 +1,140 @@ |
|||||||
|
package ui |
||||||
|
|
||||||
|
import ( |
||||||
|
"cli-mon/yabl" |
||||||
|
"fmt" |
||||||
|
"github.com/gdamore/tcell/v2" |
||||||
|
"github.com/rivo/tview" |
||||||
|
) |
||||||
|
|
||||||
|
const connectorCount = 6 |
||||||
|
|
||||||
|
type cTable struct { |
||||||
|
tview.Table |
||||||
|
voltageBefore [connectorCount + 1]*tview.TableCell |
||||||
|
voltageAfter [connectorCount + 1]*tview.TableCell |
||||||
|
presentCurrent [connectorCount + 1]*tview.TableCell |
||||||
|
connectorInsert [connectorCount + 1]*tview.TableCell |
||||||
|
contactorClosed [connectorCount + 1]*tview.TableCell |
||||||
|
connectorLocked [connectorCount + 1]*tview.TableCell |
||||||
|
cpLevel [connectorCount + 1]*tview.TableCell |
||||||
|
isolationState [connectorCount + 1]*tview.TableCell |
||||||
|
chargingAllowed [connectorCount + 1]*tview.TableCell |
||||||
|
pwmEnabled [connectorCount + 1]*tview.TableCell |
||||||
|
cpAccurate [connectorCount + 1]*tview.TableCell |
||||||
|
debugModeOn [connectorCount + 1]*tview.TableCell |
||||||
|
debugContactorOutOn [connectorCount + 1]*tview.TableCell |
||||||
|
boardReady [connectorCount + 1]*tview.TableCell |
||||||
|
} |
||||||
|
|
||||||
|
func (t *cTable) updatePU(id uint, field yabl.FName, value any) { |
||||||
|
var view *tview.TableCell |
||||||
|
|
||||||
|
switch field { |
||||||
|
case yabl.FVoltageBefore: |
||||||
|
view = t.voltageBefore[id] |
||||||
|
case yabl.FVoltageAfter: |
||||||
|
view = t.voltageAfter[id] |
||||||
|
case yabl.FPresentCurrent: |
||||||
|
view = t.presentCurrent[id] |
||||||
|
case yabl.FConnectorInsert: |
||||||
|
view = t.connectorInsert[id] |
||||||
|
case yabl.FContactorOn: |
||||||
|
view = t.contactorClosed[id] |
||||||
|
case yabl.FConnectorLocked: |
||||||
|
view = t.connectorLocked[id] |
||||||
|
case yabl.FCpLineLevel: |
||||||
|
view = t.cpLevel[id] |
||||||
|
case yabl.FIsolationState: |
||||||
|
view = t.isolationState[id] |
||||||
|
case yabl.FChargingAllowed: |
||||||
|
view = t.chargingAllowed[id] |
||||||
|
case yabl.FPwmEnabled: |
||||||
|
view = t.pwmEnabled[id] |
||||||
|
case yabl.FCpLineVoltage: |
||||||
|
view = t.cpAccurate[id] |
||||||
|
case yabl.FDebugModeOn: |
||||||
|
view = t.debugModeOn[id] |
||||||
|
case yabl.FDebugContactorOutputOn: |
||||||
|
view = t.debugContactorOutOn[id] |
||||||
|
} |
||||||
|
|
||||||
|
if view != nil { |
||||||
|
view.SetText(fmt.Sprintf("%v", value)) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
func (t *cTable) updatePuErrors(obj *yabl.PuErrors) { |
||||||
|
id := obj.GetUnitId() |
||||||
|
ready := t.boardReady[id] |
||||||
|
ready.SetText(fmt.Sprintf("%v", obj.BoardReady)) |
||||||
|
|
||||||
|
if *obj.BoardReady != yabl.BOARD_READY_OK { |
||||||
|
ready.SetBackgroundColor(tcell.ColorDarkRed) |
||||||
|
} else { |
||||||
|
ready.SetBackgroundColor(tcell.ColorDefault) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
func newConnectorsGrid() *cTable { |
||||||
|
t := &cTable{} |
||||||
|
t.Box = tview.NewBox() |
||||||
|
t.SetBorderColor(tview.Styles.GraphicsColor) |
||||||
|
t.SetSeparator(' ') |
||||||
|
t.SetContent(nil) |
||||||
|
t.SetTitle("Connectors") |
||||||
|
t.SetBorders(true) |
||||||
|
t.SetBorder(true) |
||||||
|
|
||||||
|
t.SetCell(1, 0, tview.NewTableCell("voltageBefore")) |
||||||
|
t.SetCell(2, 0, tview.NewTableCell("voltageAfter")) |
||||||
|
t.SetCell(3, 0, tview.NewTableCell("presentCurrent")) |
||||||
|
t.SetCell(4, 0, tview.NewTableCell("connectorInsert")) |
||||||
|
t.SetCell(5, 0, tview.NewTableCell("contactorClosed")) |
||||||
|
t.SetCell(6, 0, tview.NewTableCell("connectorLocked")) |
||||||
|
t.SetCell(7, 0, tview.NewTableCell("cpLevel")) |
||||||
|
t.SetCell(8, 0, tview.NewTableCell("isolationState")) |
||||||
|
t.SetCell(9, 0, tview.NewTableCell("chargingAllowed")) |
||||||
|
t.SetCell(10, 0, tview.NewTableCell("pwmEnabled")) |
||||||
|
t.SetCell(11, 0, tview.NewTableCell("cpAccurate")) |
||||||
|
t.SetCell(12, 0, tview.NewTableCell("debugModeOn")) |
||||||
|
t.SetCell(13, 0, tview.NewTableCell("debugContactorOutOn")) |
||||||
|
t.SetCell(14, 0, tview.NewTableCell("boardReady")) |
||||||
|
|
||||||
|
for i := 1; i <= 6; i++ { |
||||||
|
t.SetCell(0, i, tview.NewTableCell(fmt.Sprintf("Connector %d", i)).SetExpansion(2)) |
||||||
|
|
||||||
|
t.voltageBefore[i] = tview.NewTableCell("") |
||||||
|
t.voltageAfter[i] = tview.NewTableCell("") |
||||||
|
t.presentCurrent[i] = tview.NewTableCell("") |
||||||
|
t.connectorInsert[i] = tview.NewTableCell("") |
||||||
|
t.contactorClosed[i] = tview.NewTableCell("") |
||||||
|
t.connectorLocked[i] = tview.NewTableCell("") |
||||||
|
t.cpLevel[i] = tview.NewTableCell("") |
||||||
|
t.isolationState[i] = tview.NewTableCell("") |
||||||
|
t.chargingAllowed[i] = tview.NewTableCell("") |
||||||
|
t.pwmEnabled[i] = tview.NewTableCell("") |
||||||
|
t.cpAccurate[i] = tview.NewTableCell("") |
||||||
|
t.debugModeOn[i] = tview.NewTableCell("") |
||||||
|
t.debugContactorOutOn[i] = tview.NewTableCell("") |
||||||
|
t.boardReady[i] = tview.NewTableCell("") |
||||||
|
|
||||||
|
t.SetCell(1, i, t.voltageBefore[i]) |
||||||
|
t.SetCell(2, i, t.voltageAfter[i]) |
||||||
|
t.SetCell(3, i, t.presentCurrent[i]) |
||||||
|
t.SetCell(4, i, t.connectorInsert[i]) |
||||||
|
t.SetCell(5, i, t.contactorClosed[i]) |
||||||
|
t.SetCell(6, i, t.connectorLocked[i]) |
||||||
|
t.SetCell(7, i, t.cpLevel[i]) |
||||||
|
t.SetCell(8, i, t.isolationState[i]) |
||||||
|
t.SetCell(9, i, t.chargingAllowed[i]) |
||||||
|
t.SetCell(10, i, t.pwmEnabled[i]) |
||||||
|
t.SetCell(11, i, t.cpAccurate[i]) |
||||||
|
t.SetCell(12, i, t.debugModeOn[i]) |
||||||
|
t.SetCell(13, i, t.debugContactorOutOn[i]) |
||||||
|
t.SetCell(14, i, t.boardReady[i]) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
return t |
||||||
|
} |
@ -1,235 +0,0 @@ |
|||||||
package ui |
|
||||||
|
|
||||||
import ( |
|
||||||
"cli-mon/yabl" |
|
||||||
"fmt" |
|
||||||
ui "github.com/gizak/termui/v3" |
|
||||||
"github.com/gizak/termui/v3/widgets" |
|
||||||
) |
|
||||||
|
|
||||||
func newHeader() *widgets.Paragraph { |
|
||||||
widget := widgets.NewParagraph() |
|
||||||
widget.Text = "Press q to quit, Press <Left> or <Right> to switch tabs" |
|
||||||
widget.SetRect(0, 0, 50, 1) |
|
||||||
widget.Border = false |
|
||||||
widget.TextStyle.Bg = ui.ColorBlue |
|
||||||
return widget |
|
||||||
} |
|
||||||
|
|
||||||
func newConnectorsView() *ui.Grid { |
|
||||||
grid := ui.NewGrid() |
|
||||||
|
|
||||||
termWidth, termHeight := ui.TerminalDimensions() |
|
||||||
grid.SetRect(0, headerHeight, termWidth, termHeight) |
|
||||||
|
|
||||||
var conn [connectorsCount + 1]*widgets.Paragraph //ui.GridItem
|
|
||||||
|
|
||||||
for i := 0; i <= connectorsCount; i++ { |
|
||||||
p := widgets.NewParagraph() |
|
||||||
p.Text = fmt.Sprintf("No data: #%2.d", i) |
|
||||||
p.Title = fmt.Sprintf("Connector: #%2.d", i) |
|
||||||
//p.SetRect(0, 0, 50, 30)
|
|
||||||
p.TextStyle.Bg = ui.ColorBlue |
|
||||||
p.TextStyle.Fg = ui.ColorWhite |
|
||||||
p.BorderStyle.Fg = ui.ColorYellow |
|
||||||
p.Border = true |
|
||||||
|
|
||||||
connUI[i] = p |
|
||||||
conn[i] = p //ui.NewCol(1.0/6, p)
|
|
||||||
} |
|
||||||
|
|
||||||
grid.Set( |
|
||||||
ui.NewRow( |
|
||||||
1.0/2, |
|
||||||
ui.NewCol(1.0/4, conn[1]), |
|
||||||
ui.NewCol(1.0/4, conn[2]), |
|
||||||
ui.NewCol(1.0/4, conn[3]), |
|
||||||
ui.NewCol(1.0/4, conn[4]), |
|
||||||
), |
|
||||||
ui.NewRow( |
|
||||||
1.0/2, |
|
||||||
ui.NewCol(1.0/4, conn[5]), |
|
||||||
ui.NewCol(1.0/4, conn[6]), |
|
||||||
ui.NewCol(1.0/4, conn[0]), |
|
||||||
), |
|
||||||
) |
|
||||||
|
|
||||||
return grid |
|
||||||
} |
|
||||||
|
|
||||||
func newContactorsView() *ui.Grid { |
|
||||||
grid := ui.NewGrid() |
|
||||||
|
|
||||||
termWidth, termHeight := ui.TerminalDimensions() |
|
||||||
grid.SetRect(0, headerHeight, termWidth, termHeight) |
|
||||||
|
|
||||||
var cont [contactorsCount + 1]ui.GridItem |
|
||||||
|
|
||||||
//var contactors = make([]ui.GridItem, contactorsCount)
|
|
||||||
for i := 1; i <= contactorsCount; i++ { |
|
||||||
p := widgets.NewParagraph() |
|
||||||
p.Text = fmt.Sprintf("No data: #%2.d", i) |
|
||||||
p.Title = fmt.Sprintf("Contactor: #%2.d", i) |
|
||||||
p.Border = false |
|
||||||
p.TextStyle.Bg = ui.ColorBlue |
|
||||||
p.TextStyle.Fg = ui.ColorWhite |
|
||||||
p.BorderStyle.Fg = ui.ColorYellow |
|
||||||
p.Border = true |
|
||||||
|
|
||||||
contUI[i] = p |
|
||||||
cont[i] = ui.NewCol(1.0/6, p) |
|
||||||
} |
|
||||||
|
|
||||||
grid.Set( |
|
||||||
ui.NewRow( |
|
||||||
1.0/3, |
|
||||||
cont[1], |
|
||||||
cont[2], |
|
||||||
cont[3], |
|
||||||
cont[4], |
|
||||||
cont[5], |
|
||||||
cont[6], |
|
||||||
), |
|
||||||
ui.NewRow( |
|
||||||
1.0/3, |
|
||||||
cont[7], |
|
||||||
cont[8], |
|
||||||
cont[9], |
|
||||||
cont[10], |
|
||||||
cont[11], |
|
||||||
cont[12], |
|
||||||
), |
|
||||||
ui.NewRow( |
|
||||||
1.0/3, |
|
||||||
cont[13], |
|
||||||
cont[14], |
|
||||||
cont[15], |
|
||||||
cont[16], |
|
||||||
cont[17], |
|
||||||
cont[18], |
|
||||||
)) |
|
||||||
|
|
||||||
//ui.NewRow(1, ui.InterfaceSlice(contactors)...)
|
|
||||||
grid.Set() |
|
||||||
|
|
||||||
return grid |
|
||||||
} |
|
||||||
|
|
||||||
func newContactorsErrView() *widgets.Paragraph { |
|
||||||
p := widgets.NewParagraph() |
|
||||||
p.Text = "No data\n" |
|
||||||
p.Title = "Contactors Errors" |
|
||||||
p.SetRect(5, 5, 55, 15) |
|
||||||
p.BorderStyle.Fg = ui.ColorYellow |
|
||||||
|
|
||||||
return p |
|
||||||
} |
|
||||||
|
|
||||||
func updateContactorsView(msg *yabl.ContactorInternalState) { |
|
||||||
|
|
||||||
p := contUI[msg.GetUnitId()] |
|
||||||
s := msg |
|
||||||
|
|
||||||
if s == nil || p == nil { |
|
||||||
return |
|
||||||
} |
|
||||||
|
|
||||||
p.Text = fmt.Sprintf( |
|
||||||
"BoardReady: %s\nContactorOn: %s\nUnexpectedState: %s\nIsolated: %s\nDebug: %s", |
|
||||||
s.ContactorReady, |
|
||||||
s.ContactorOn, |
|
||||||
s.UnexpectedState, |
|
||||||
s.Isolated, |
|
||||||
s.DebugEnabled) |
|
||||||
|
|
||||||
if s.ContactorReady != nil && *s.ContactorReady == yabl.BOARD_READY_OK { |
|
||||||
p.TextStyle.Bg = ui.ColorClear |
|
||||||
} else { |
|
||||||
p.TextStyle.Bg = ui.ColorRed |
|
||||||
} |
|
||||||
|
|
||||||
if s.ContactorOn != nil && *s.ContactorOn == yabl.ON { |
|
||||||
p.TitleStyle.Bg = ui.ColorBlue |
|
||||||
} else { |
|
||||||
p.TitleStyle.Bg = ui.ColorClear |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
var connectorsState [connectorsCount + 1]*yabl.PuPeriphery |
|
||||||
var connectorsEnergy [connectorsCount + 1]*yabl.PuPresentEnergy |
|
||||||
|
|
||||||
func updateConnectorsView(action yabl.Action) { |
|
||||||
if action == nil { |
|
||||||
return |
|
||||||
} |
|
||||||
|
|
||||||
var unitId = action.GetUnitId() |
|
||||||
|
|
||||||
switch msg := action.(type) { |
|
||||||
case *yabl.PuPeriphery: |
|
||||||
connectorsState[unitId] = msg |
|
||||||
case *yabl.PuPresentEnergy: |
|
||||||
connectorsEnergy[unitId] = msg |
|
||||||
} |
|
||||||
|
|
||||||
p := connUI[unitId] |
|
||||||
s := connectorsState[unitId] |
|
||||||
e := connectorsEnergy[unitId] |
|
||||||
|
|
||||||
if s == nil || e == nil { |
|
||||||
return |
|
||||||
} |
|
||||||
|
|
||||||
fstring := "ConnectorInsert %s\n" + |
|
||||||
"ContactorOn %s\n" + |
|
||||||
"ConnectorLocked %s\n" + |
|
||||||
"LineLevel %s\n" + |
|
||||||
"IsolationState %s\n" + |
|
||||||
"ChargingAllowed %s\n" + |
|
||||||
"PwmEnabled %s\n" + |
|
||||||
"CpLineVoltage %s\n" + |
|
||||||
"V2GMode %s\n" + |
|
||||||
"VoltageBefore %s\n" + |
|
||||||
"VoltageAfter %s\n" + |
|
||||||
"PresentCurrent %s" |
|
||||||
|
|
||||||
p.Text = fmt.Sprintf( |
|
||||||
fstring, |
|
||||||
s.ConnectorInsert, |
|
||||||
s.ContactorOn, |
|
||||||
s.ConnectorLocked, |
|
||||||
s.CpLineLevel, |
|
||||||
s.IsolationState, |
|
||||||
s.ChargingAllowed, |
|
||||||
s.PwmEnabled, |
|
||||||
s.CpLineVoltage, |
|
||||||
e.V2GMode, |
|
||||||
e.VoltageBefore, |
|
||||||
e.VoltageAfter, |
|
||||||
e.PresentCurrent) |
|
||||||
} |
|
||||||
|
|
||||||
func updateContactorsStateView(e *yabl.ContactorInternalErrors) { |
|
||||||
p := contactorsErr |
|
||||||
|
|
||||||
if e == nil { |
|
||||||
return |
|
||||||
} |
|
||||||
|
|
||||||
p.Text = fmt.Sprintf( |
|
||||||
"BoardReady: %s\nOtherError: %s\nGroupChanged: %s\nUnexpectedFormation: %s\nCpuNotReady: %s\nPuNotReady: %s\nDebug: %s", |
|
||||||
e.BoardReady, |
|
||||||
e.OtherError, |
|
||||||
e.ContactorGroupChanged, |
|
||||||
e.UnexpectedFormation, |
|
||||||
e.CpuNotReady, |
|
||||||
e.PuNotReady, |
|
||||||
e.Debug, |
|
||||||
) |
|
||||||
|
|
||||||
if e.BoardReady != nil && *e.BoardReady == yabl.BOARD_READY_OK { |
|
||||||
p.TextStyle.Bg = ui.ColorClear |
|
||||||
} else { |
|
||||||
p.TextStyle.Bg = ui.ColorRed |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue