From 57197c55eb08c0adefe4e9ae0153a235054eeaed Mon Sep 17 00:00:00 2001 From: AvSquirrel Date: Tue, 3 May 2016 04:40:51 +0000 Subject: [PATCH] Split out traffic source from DEBUG. Fix panic closing closed channel. --- main/datalog.go | 4 +--- main/gen_gdl90.go | 29 +++++++++++++++-------------- main/managementinterface.go | 2 ++ main/traffic.go | 4 ++-- web/plates/js/settings.js | 4 ++-- web/plates/settings.html | 10 ++++++++-- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/main/datalog.go b/main/datalog.go index 0c062361..3391611d 100644 --- a/main/datalog.go +++ b/main/datalog.go @@ -46,7 +46,6 @@ type StratuxStartup struct { var dataLogStarted bool var dataLogReadyToWrite bool -//var dataLogInShutdown bool var stratuxStartupID int64 var dataLogTimestamps []StratuxTimestamp var dataLogCurTimestamp int64 // Current timestamp bucket. This is an index on dataLogTimestamps which is not necessarily the db id. @@ -369,7 +368,6 @@ func dataLogWriter(db *sql.DB) { select { case r := <-dataLogWriteChan: // Accept timestamped row. - //log.Printf("Accepting timestamped row from dataLogWriteChan\n") rowsQueuedForWrite = append(rowsQueuedForWrite, r) case <-writeTicker.C: // for i := 0; i < 1000; i++ { @@ -411,7 +409,6 @@ func dataLogWriter(db *sql.DB) { case <-shutdownDataLogWriter: // Received a message on the channel to initiate a graceful shutdown, and to command dataLog() to shut down log.Printf("datalog.go: dataLogWriter() received shutdown message with rowsQueuedForWrite = %d\n", len(rowsQueuedForWrite)) shutdownDataLog <- true - defer close(shutdownDataLog) return } } @@ -499,6 +496,7 @@ func dataLog() { } } log.Printf("datalog.go: dataLog() shutting down\n") + close(shutdownDataLog) } /* diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 9a0c8d18..2534f06f 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -962,16 +962,17 @@ func getProductNameFromId(product_id int) string { } type settings struct { - UAT_Enabled bool - ES_Enabled bool - GPS_Enabled bool - NetworkOutputs []networkConnection - AHRS_Enabled bool - DEBUG bool - ReplayLog bool - PPM int - OwnshipModeS string - WatchList string + UAT_Enabled bool + ES_Enabled bool + GPS_Enabled bool + NetworkOutputs []networkConnection + AHRS_Enabled bool + DisplayTrafficSource bool + DEBUG bool + ReplayLog bool + PPM int + OwnshipModeS string + WatchList string } type status struct { @@ -1021,6 +1022,7 @@ func defaultSettings() { } globalSettings.AHRS_Enabled = false globalSettings.DEBUG = false + globalSettings.DisplayTrafficSource = false globalSettings.ReplayLog = false //TODO: 'true' for debug builds. globalSettings.OwnshipModeS = "F00000" } @@ -1190,15 +1192,14 @@ var sigs = make(chan os.Signal, 1) // Signal catch channel (shutdown). func gracefulShutdown() { // Shut down SDRs. sdrKill() - //TODO: Any other graceful shutdown functions. // Shut down data logging. if dataLogStarted { closeDataLog() - //log.Printf("Waiting for log file to close\n") - //time.Sleep(3*time.Second) // FIXME } - // shutdownDataLog <- true + + //TODO: Any other graceful shutdown functions. + os.Exit(1) } diff --git a/main/managementinterface.go b/main/managementinterface.go index 1e5f8ea8..a01d5810 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -205,6 +205,8 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) { globalSettings.AHRS_Enabled = val.(bool) case "DEBUG": globalSettings.DEBUG = val.(bool) + case "DisplayTrafficSource": + globalSettings.DisplayTrafficSource = val.(bool) case "ReplayLog": v := val.(bool) if v != globalSettings.ReplayLog { // Don't mark the files unless there is a change. diff --git a/main/traffic.go b/main/traffic.go index 0711e958..7b69bbca 100644 --- a/main/traffic.go +++ b/main/traffic.go @@ -400,7 +400,7 @@ func parseDownlinkReport(s string, signalLevel int) { } // This is a hack to show the source of the traffic on moving maps. - if globalSettings.DEBUG { + if globalSettings.DisplayTrafficSource { type_code := " " switch ti.TargetType { case TARGET_TYPE_ADSB: @@ -839,7 +839,7 @@ func esListen() { // This is a hack to show the source of the traffic on moving maps. - if globalSettings.DEBUG { + if globalSettings.DisplayTrafficSource { type_code := " " switch ti.TargetType { case TARGET_TYPE_ADSB: diff --git a/web/plates/js/settings.js b/web/plates/js/settings.js index e9ba7ef1..343adc6b 100755 --- a/web/plates/js/settings.js +++ b/web/plates/js/settings.js @@ -6,7 +6,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $scope.$parent.helppage = 'plates/settings-help.html'; - var toggles = ['UAT_Enabled', 'ES_Enabled', 'GPS_Enabled', 'AHRS_Enabled', 'DEBUG', 'ReplayLog']; // DEBUG is 'DspTrafficSrc' + var toggles = ['UAT_Enabled', 'ES_Enabled', 'GPS_Enabled', 'AHRS_Enabled', 'DisplayTrafficSource', 'DEBUG', 'ReplayLog']; var settings = {}; for (i = 0; i < toggles.length; i++) { settings[toggles[i]] = undefined; @@ -21,7 +21,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $scope.ES_Enabled = settings.ES_Enabled; $scope.GPS_Enabled = settings.GPS_Enabled; $scope.AHRS_Enabled = settings.AHRS_Enabled; - $scope.PowerSave = settings.PowerSave + $scope.DisplayTrafficSource = settings.DisplayTrafficSource; $scope.DEBUG = settings.DEBUG; $scope.ReplayLog = settings.ReplayLog; $scope.PPM = settings.PPM; diff --git a/web/plates/settings.html b/web/plates/settings.html index ad7bf9d6..40922d92 100755 --- a/web/plates/settings.html +++ b/web/plates/settings.html @@ -37,13 +37,19 @@
Diagnostics
- + +
+ +
+
+
+
- +