kopia lustrzana https://github.com/cyoung/stratux
Split out traffic source from DEBUG. Fix panic closing closed channel.
rodzic
5478cdaeb8
commit
57197c55eb
|
@ -46,7 +46,6 @@ type StratuxStartup struct {
|
||||||
var dataLogStarted bool
|
var dataLogStarted bool
|
||||||
var dataLogReadyToWrite bool
|
var dataLogReadyToWrite bool
|
||||||
|
|
||||||
//var dataLogInShutdown bool
|
|
||||||
var stratuxStartupID int64
|
var stratuxStartupID int64
|
||||||
var dataLogTimestamps []StratuxTimestamp
|
var dataLogTimestamps []StratuxTimestamp
|
||||||
var dataLogCurTimestamp int64 // Current timestamp bucket. This is an index on dataLogTimestamps which is not necessarily the db id.
|
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 {
|
select {
|
||||||
case r := <-dataLogWriteChan:
|
case r := <-dataLogWriteChan:
|
||||||
// Accept timestamped row.
|
// Accept timestamped row.
|
||||||
//log.Printf("Accepting timestamped row from dataLogWriteChan\n")
|
|
||||||
rowsQueuedForWrite = append(rowsQueuedForWrite, r)
|
rowsQueuedForWrite = append(rowsQueuedForWrite, r)
|
||||||
case <-writeTicker.C:
|
case <-writeTicker.C:
|
||||||
// for i := 0; i < 1000; i++ {
|
// 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
|
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))
|
log.Printf("datalog.go: dataLogWriter() received shutdown message with rowsQueuedForWrite = %d\n", len(rowsQueuedForWrite))
|
||||||
shutdownDataLog <- true
|
shutdownDataLog <- true
|
||||||
defer close(shutdownDataLog)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,6 +496,7 @@ func dataLog() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("datalog.go: dataLog() shutting down\n")
|
log.Printf("datalog.go: dataLog() shutting down\n")
|
||||||
|
close(shutdownDataLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -962,16 +962,17 @@ func getProductNameFromId(product_id int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type settings struct {
|
type settings struct {
|
||||||
UAT_Enabled bool
|
UAT_Enabled bool
|
||||||
ES_Enabled bool
|
ES_Enabled bool
|
||||||
GPS_Enabled bool
|
GPS_Enabled bool
|
||||||
NetworkOutputs []networkConnection
|
NetworkOutputs []networkConnection
|
||||||
AHRS_Enabled bool
|
AHRS_Enabled bool
|
||||||
DEBUG bool
|
DisplayTrafficSource bool
|
||||||
ReplayLog bool
|
DEBUG bool
|
||||||
PPM int
|
ReplayLog bool
|
||||||
OwnshipModeS string
|
PPM int
|
||||||
WatchList string
|
OwnshipModeS string
|
||||||
|
WatchList string
|
||||||
}
|
}
|
||||||
|
|
||||||
type status struct {
|
type status struct {
|
||||||
|
@ -1021,6 +1022,7 @@ func defaultSettings() {
|
||||||
}
|
}
|
||||||
globalSettings.AHRS_Enabled = false
|
globalSettings.AHRS_Enabled = false
|
||||||
globalSettings.DEBUG = false
|
globalSettings.DEBUG = false
|
||||||
|
globalSettings.DisplayTrafficSource = false
|
||||||
globalSettings.ReplayLog = false //TODO: 'true' for debug builds.
|
globalSettings.ReplayLog = false //TODO: 'true' for debug builds.
|
||||||
globalSettings.OwnshipModeS = "F00000"
|
globalSettings.OwnshipModeS = "F00000"
|
||||||
}
|
}
|
||||||
|
@ -1190,15 +1192,14 @@ var sigs = make(chan os.Signal, 1) // Signal catch channel (shutdown).
|
||||||
func gracefulShutdown() {
|
func gracefulShutdown() {
|
||||||
// Shut down SDRs.
|
// Shut down SDRs.
|
||||||
sdrKill()
|
sdrKill()
|
||||||
//TODO: Any other graceful shutdown functions.
|
|
||||||
|
|
||||||
// Shut down data logging.
|
// Shut down data logging.
|
||||||
if dataLogStarted {
|
if dataLogStarted {
|
||||||
closeDataLog()
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,8 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) {
|
||||||
globalSettings.AHRS_Enabled = val.(bool)
|
globalSettings.AHRS_Enabled = val.(bool)
|
||||||
case "DEBUG":
|
case "DEBUG":
|
||||||
globalSettings.DEBUG = val.(bool)
|
globalSettings.DEBUG = val.(bool)
|
||||||
|
case "DisplayTrafficSource":
|
||||||
|
globalSettings.DisplayTrafficSource = val.(bool)
|
||||||
case "ReplayLog":
|
case "ReplayLog":
|
||||||
v := val.(bool)
|
v := val.(bool)
|
||||||
if v != globalSettings.ReplayLog { // Don't mark the files unless there is a change.
|
if v != globalSettings.ReplayLog { // Don't mark the files unless there is a change.
|
||||||
|
|
|
@ -400,7 +400,7 @@ func parseDownlinkReport(s string, signalLevel int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a hack to show the source of the traffic on moving maps.
|
// This is a hack to show the source of the traffic on moving maps.
|
||||||
if globalSettings.DEBUG {
|
if globalSettings.DisplayTrafficSource {
|
||||||
type_code := " "
|
type_code := " "
|
||||||
switch ti.TargetType {
|
switch ti.TargetType {
|
||||||
case TARGET_TYPE_ADSB:
|
case TARGET_TYPE_ADSB:
|
||||||
|
@ -839,7 +839,7 @@ func esListen() {
|
||||||
|
|
||||||
// This is a hack to show the source of the traffic on moving maps.
|
// This is a hack to show the source of the traffic on moving maps.
|
||||||
|
|
||||||
if globalSettings.DEBUG {
|
if globalSettings.DisplayTrafficSource {
|
||||||
type_code := " "
|
type_code := " "
|
||||||
switch ti.TargetType {
|
switch ti.TargetType {
|
||||||
case TARGET_TYPE_ADSB:
|
case TARGET_TYPE_ADSB:
|
||||||
|
|
|
@ -6,7 +6,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
|
||||||
|
|
||||||
$scope.$parent.helppage = 'plates/settings-help.html';
|
$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 = {};
|
var settings = {};
|
||||||
for (i = 0; i < toggles.length; i++) {
|
for (i = 0; i < toggles.length; i++) {
|
||||||
settings[toggles[i]] = undefined;
|
settings[toggles[i]] = undefined;
|
||||||
|
@ -21,7 +21,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
|
||||||
$scope.ES_Enabled = settings.ES_Enabled;
|
$scope.ES_Enabled = settings.ES_Enabled;
|
||||||
$scope.GPS_Enabled = settings.GPS_Enabled;
|
$scope.GPS_Enabled = settings.GPS_Enabled;
|
||||||
$scope.AHRS_Enabled = settings.AHRS_Enabled;
|
$scope.AHRS_Enabled = settings.AHRS_Enabled;
|
||||||
$scope.PowerSave = settings.PowerSave
|
$scope.DisplayTrafficSource = settings.DisplayTrafficSource;
|
||||||
$scope.DEBUG = settings.DEBUG;
|
$scope.DEBUG = settings.DEBUG;
|
||||||
$scope.ReplayLog = settings.ReplayLog;
|
$scope.ReplayLog = settings.ReplayLog;
|
||||||
$scope.PPM = settings.PPM;
|
$scope.PPM = settings.PPM;
|
||||||
|
|
|
@ -37,13 +37,19 @@
|
||||||
<div class="panel-heading">Diagnostics</div>
|
<div class="panel-heading">Diagnostics</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-7">Traffic Markings</label>
|
<label class="control-label col-xs-7">Show Traffic Source in Callsign</label>
|
||||||
|
<div class="col-xs-5">
|
||||||
|
<ui-switch ng-model='DisplayTrafficSource' settings-change></ui-switch>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-7">Verbose Message Log</label>
|
||||||
<div class="col-xs-5">
|
<div class="col-xs-5">
|
||||||
<ui-switch ng-model='DEBUG' settings-change></ui-switch>
|
<ui-switch ng-model='DEBUG' settings-change></ui-switch>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-7">Record Logs</label>
|
<label class="control-label col-xs-7">Record Replay Logs</label>
|
||||||
<div class="col-xs-5">
|
<div class="col-xs-5">
|
||||||
<ui-switch ng-model='ReplayLog' settings-change></ui-switch>
|
<ui-switch ng-model='ReplayLog' settings-change></ui-switch>
|
||||||
</div>
|
</div>
|
||||||
|
|
Ładowanie…
Reference in New Issue