New events api implementation

This commit is contained in:
2023-07-07 04:28:46 +03:00
parent 8c81bc8e24
commit 00762d173b
8 changed files with 428 additions and 566 deletions
+22 -1
View File
@@ -12,7 +12,11 @@ const headerHeight int = 4
const contactorsCount = 18
const connectorsCount = 6
func InitCliApp(events <-chan yabl.Packet) {
var connUI [connectorsCount + 1]*widgets.Paragraph
var contUI [contactorsCount + 1]*widgets.Paragraph
var contactorsErr *widgets.Paragraph
func InitCliApp(events <-chan *yabl.Event) {
if err := ui.Init(); err != nil {
log.Fatalf("failed to initialize termui: %v", err)
}
@@ -86,3 +90,20 @@ func InitCliApp(events <-chan yabl.Packet) {
}
}
}
func process(message *yabl.Event) {
if message == nil || message.Object == nil {
return
}
switch msg := message.Object.(type) {
case *yabl.ContactorInternalState:
updateContactorsView(msg)
case *yabl.PuPeriphery:
updateConnectorsView(msg)
case *yabl.PuPresentEnergy:
updateConnectorsView(msg)
case *yabl.ContactorInternalErrors:
updateContactorsStateView(msg)
}
}