diff --git a/eventChannel.go b/eventChannel.go index 441ef6d..1afff41 100644 --- a/eventChannel.go +++ b/eventChannel.go @@ -16,6 +16,8 @@ import "git.wit.com/wit/gui" var mychannel chan *pb.Event +var currentMessage *pb.Event + func initChannel() { mychannel = make(chan *pb.Event) } @@ -23,16 +25,19 @@ func initChannel() { // func processEvents(mychannel chan *pb.Event) { func processEvents() { for { - message := <-mychannel - log.Println("processEvents() START on channel recieved a message = ", message) - if (message.Type == pb.Event_DEMO) { + currentMessage = <-mychannel + log.Println("processEvents() START on channel recieved a message = ", currentMessage) + if (currentMessage.Type == pb.Event_DEMO) { log.Println("processEvents() do Event DEMO") // figure out how to interact with the GUI here // go ui.Main(gui.SetupDemoUI) } else { + gui.Data.State = "bmath done" + /* count := countVMS(message) mh := addVmsTab(count) ReadReceivedData(message, mh) + */ } log.Println("processEvents() END on channel") } diff --git a/main.go b/main.go index 4ed616c..e92061e 100644 --- a/main.go +++ b/main.go @@ -7,9 +7,6 @@ import "time" import "github.com/gookit/config" -import "github.com/andlabs/ui" -import _ "github.com/andlabs/ui/winmanifest" - import "git.wit.com/wit/gui" // import "github.com/davecgh/go-spew/spew" @@ -63,26 +60,74 @@ func main() { go processEvents() go gorillaDial("v000185.testing.com.customers.wprod.wit.com:9000") + go watchGUI() gui.Data.Width = config.Int("width") gui.Data.Height = config.Int("height") + gui.Data.ButtonClickNew = buttonClickNew + // make this the main loop in an attempt to figure out the crashes // do not change this until the GUI is stable - ui.Main(setupCloudUI) - -/* - for account, _ := range config.StringMap("cloud") { - port := config.String("cloud." + account + ".port") - proto := config.String("cloud." + account + ".proto") - hostname := config.String("cloud." + account + ".hostname") - rows := config.Int("cloud." + account + ".rows") - fmt.Println(hostname, port, proto, rows) - - gui.AddTableTab(account, rows, parts) - - log.Println("Sleep for 10 seconds, then add next table") - time.Sleep(10 * 1000 * 1000 * 1000) - } -*/ + gui.GoMainWindow() +} + +func buttonClickNew(b *gui.ButtonMap) { + log.Println("buttonClickNew() b =", b) + log.Println("\tb.Name", b.Name) + log.Println("\tb.Note", b.Note) + + if (b.Note == "BACK") { + gui.Data.State = "splash" + } + if (b.Note == "BMATH") { + log.Println("\tTRIGGER BMATH HERE") + log.Println("\tTRIGGER BMATH HERE") + log.Println("\tTRIGGER BMATH HERE") + gui.Data.State = "bmath" + for { + log.Println("Sleep() in buttonClickNew() gui.Data.State =", gui.Data.State) + time.Sleep(200 * time.Millisecond) + if (gui.Data.State == "bmath done") { + count := countVMS(currentMessage) + mh := gui.AddVmsTab(count) + ReadReceivedData(currentMessage, mh) + return + } + } + } + if (gui.Data.State == "splash") { + gui.ShowAccountQuestionTab() + gui.Data.State = "account1" + return + } else if (gui.Data.State == "account1") { + gui.ShowAccountTab() + gui.Data.State = "main" + } else if (gui.Data.State == "main") { + gui.ShowMainTab() + gui.Data.State = "done" + } +} + +func watchGUI() { + log.Println("Sleep(2000)") + time.Sleep(2000 * time.Millisecond) + + for { + log.Println("Sleep() in watchGUI() gui.Data.State =", gui.Data.State) + time.Sleep(2000 * time.Millisecond) + + if (gui.Data.State == "bmath") { + log.Println("\tTRIGGERING BMATH HERE") + log.Println("\tTRIGGERING BMATH HERE") + log.Println("\tTRIGGERING BMATH HERE") + gorillaSendProtobuf() + } + if (gui.Data.State == "kill") { + log.Println("gui.State = kill") + log.Println("gui.State = kill") + log.Println("gui.State = kill") + os.Exit(0) + } + } }