From a949bda34f560f9d079e7731473da8ac044f66be Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Mon, 24 Oct 2016 15:38:05 -0400 Subject: [PATCH] Add mySituation uibroadcast. --- main/managementinterface.go | 4 ++++ main/ry835ai.go | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/main/managementinterface.go b/main/managementinterface.go index 78f7a57b..f5102e87 100755 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -36,6 +36,9 @@ type SettingMessage struct { var weatherUpdate *uibroadcaster var trafficUpdate *uibroadcaster +// Situation updates channel. +var situationUpdate *uibroadcaster + /* The /weather websocket starts off by sending the current buffer of weather messages, then sends updates as they are received. */ @@ -511,6 +514,7 @@ func viewLogs(w http.ResponseWriter, r *http.Request) { func managementInterface() { weatherUpdate = NewUIBroadcaster() trafficUpdate = NewUIBroadcaster() + situationUpdate = NewUIBroadcaster() http.HandleFunc("/", defaultServer) http.Handle("/logs/", http.StripPrefix("/logs/", http.FileServer(http.Dir("/var/log")))) diff --git a/main/ry835ai.go b/main/ry835ai.go index 715740bb..5343b52e 100644 --- a/main/ry835ai.go +++ b/main/ry835ai.go @@ -456,6 +456,15 @@ func calculateNACp(accuracy float32) uint8 { return ret } +/* + registerSituationUpdate(). + Called whenever there is a change in mySituation. +*/ +func registerSituationUpdate() { + logSituation() + situationUpdate.SendJSON(mySituation) +} + /* processNMEALine parses NMEA-0183 formatted strings against several message types. @@ -472,7 +481,7 @@ func processNMEALine(l string) (sentenceUsed bool) { defer func() { if sentenceUsed || globalSettings.DEBUG { - logSituation() + registerSituationUpdate() } mySituation.mu_GPS.Unlock() }()