New events api implementation
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user