add OwnshipModeS to UI and maintain consistent format for storage; also tweaked 'settings' page field validation

pull/73/head
bradanlane 2015-10-06 18:31:20 -04:00
rodzic 34f55beb04
commit 30abcb82ee
7 zmienionych plików z 153 dodań i 119 usunięć

Wyświetl plik

@ -177,9 +177,10 @@ func makeOwnshipReport() bool {
msg[1] = 0x01 // Alert status, address type. msg[1] = 0x01 // Alert status, address type.
msg[2] = byte((globalSettings.OwnshipModeS >> 16) & 0xFF) // Mode S address. code, _ := hex.DecodeString(globalSettings.OwnshipModeS)
msg[3] = byte((globalSettings.OwnshipModeS >> 8) & 0xFF) // Mode S address. msg[2] = code[0] // Mode S address.
msg[4] = byte(globalSettings.OwnshipModeS & 0xFF) // Mode S address. msg[3] = code[1] // Mode S address.
msg[4] = code[2] // Mode S address.
tmp := makeLatLng(mySituation.Lat) tmp := makeLatLng(mySituation.Lat)
msg[5] = tmp[0] // Latitude. msg[5] = tmp[0] // Latitude.
@ -684,7 +685,7 @@ type settings struct {
DEBUG bool DEBUG bool
ReplayLog bool // Startup only option. Cannot be changed during runtime. ReplayLog bool // Startup only option. Cannot be changed during runtime.
PPM int PPM int
OwnshipModeS int32 OwnshipModeS string
WatchList string WatchList string
} }

Wyświetl plik

@ -2,12 +2,13 @@ package main
import ( import (
"encoding/json" "encoding/json"
"encoding/hex"
"strings"
"fmt" "fmt"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
"io" "io"
"log" "log"
"net/http" "net/http"
"strconv"
"time" "time"
) )
@ -159,15 +160,17 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) {
globalSettings.WatchList = val.(string) globalSettings.WatchList = val.(string)
case "OwnshipModeS": case "OwnshipModeS":
// Expecting a hex string less than 6 characters (24 bits) long. // Expecting a hex string less than 6 characters (24 bits) long.
hexc := val.(string) if len(val.(string)) > 6 { // Too long.
if len(hexc) > 6 { // Too long.
continue continue
} }
i, err := strconv.ParseInt(hexc, 16, 32) vals := strings.ToUpper(val.(string))
if err != nil { // Number not valid. hexn, _ := hex.DecodeString(vals)
hexs := strings.ToUpper(hex.EncodeToString(hexn))
if vals != hexs { // Number not valid.
log.Printf("handleSettingsSetRequest:OwnshipModeS: %s != %s\n", vals, hexs)
continue continue
} }
globalSettings.OwnshipModeS = int32(i) globalSettings.OwnshipModeS = vals
default: default:
log.Printf("handleSettingsSetRequest:json: unrecognized key:%s\n", key) log.Printf("handleSettingsSetRequest:json: unrecognized key:%s\n", key)
} }

Wyświetl plik

@ -14,6 +14,7 @@ function SettingsCtrl($rootScope, $scope, $state, $http) {
function loadSettings(data) { function loadSettings(data) {
settings = angular.fromJson(data); settings = angular.fromJson(data);
// consider using angular.extend()
$scope.rawSettings = angular.toJson(data, true); $scope.rawSettings = angular.toJson(data, true);
$scope.UAT_Enabled = settings.UAT_Enabled; $scope.UAT_Enabled = settings.UAT_Enabled;
$scope.ES_Enabled = settings.ES_Enabled; $scope.ES_Enabled = settings.ES_Enabled;
@ -23,13 +24,14 @@ function SettingsCtrl($rootScope, $scope, $state, $http) {
$scope.ReplayLog = settings.ReplayLog; $scope.ReplayLog = settings.ReplayLog;
$scope.PPM = settings.PPM; $scope.PPM = settings.PPM;
$scope.WatchList = settings.WatchList; $scope.WatchList = settings.WatchList;
$scope.OwnshipModeS = settings.OwnshipModeS;
} }
function getSettings() { function getSettings() {
// Simple GET request example (note: responce is asynchronous) // Simple GET request example (note: responce is asynchronous)
$http.get(URL_SETTINGS_GET). $http.get(URL_SETTINGS_GET).
then(function (response) { then(function (response) {
loadSettings (response.data); loadSettings(response.data);
// $scope.$apply(); // $scope.$apply();
}, function (response) { }, function (response) {
$scope.rawSettings = "error getting settings"; $scope.rawSettings = "error getting settings";
@ -44,7 +46,7 @@ function SettingsCtrl($rootScope, $scope, $state, $http) {
// Simple POST request example (note: responce is asynchronous) // Simple POST request example (note: responce is asynchronous)
$http.post(URL_SETTINGS_SET, msg). $http.post(URL_SETTINGS_SET, msg).
then(function (response) { then(function (response) {
loadSettings (response.data); loadSettings(response.data);
// $scope.$apply(); // $scope.$apply();
}, function (response) { }, function (response) {
$scope.rawSettings = "error setting settings"; $scope.rawSettings = "error setting settings";
@ -70,28 +72,39 @@ function SettingsCtrl($rootScope, $scope, $state, $http) {
} }
} }
if (dirty) { if (dirty) {
console.log(angular.toJson(newsettings)); // console.log(angular.toJson(newsettings));
setSettings(angular.toJson(newsettings)); setSettings(angular.toJson(newsettings));
} }
}); });
$scope.updatewatchlist = function() { $scope.updateppm = function () {
if (($scope.WatchList !== undefined) && ($scope.WatchList !== null) && $scope.WatchList !== settings["WatchList"]) { if (($scope.PPM !== undefined) && ($scope.PPM !== null) && ($scope.PPM !== settings["PPM"])) {
settings["WatchList"] = $scope.WatchList.toUpperCase();
newsettings = {
"WatchList": $scope.WatchList.toUpperCase()
};
console.log(angular.toJson(newsettings));
setSettings(angular.toJson(newsettings));
}
};
$scope.updateppm = function() {
if (($scope.PPM !== undefined) && ($scope.PPM !== null) && $scope.PPM !== settings["PPM"]) {
settings["PPM"] = parseInt($scope.PPM); settings["PPM"] = parseInt($scope.PPM);
newsettings = { newsettings = {
"PPM": parseInt($scope.PPM) "PPM": parseInt($scope.PPM)
}; };
console.log(angular.toJson(newsettings)); // console.log(angular.toJson(newsettings));
setSettings(angular.toJson(newsettings));
}
};
$scope.updatewatchlist = function () {
if ($scope.WatchList !== settings["WatchList"]) {
settings["WatchList"] = $scope.WatchList.toUpperCase();
newsettings = {
"WatchList": $scope.WatchList.toUpperCase()
};
// console.log(angular.toJson(newsettings));
setSettings(angular.toJson(newsettings));
}
};
$scope.updatemodes = function () {
if ($scope.OwnshipModeS !== settings["OwnshipModeS"]) {
settings["OwnshipModeS"] = $scope.OwnshipModeS.toUpperCase();
newsettings = {
"OwnshipModeS": $scope.OwnshipModeS.toUpperCase()
};
// console.log(angular.toJson(newsettings));
setSettings(angular.toJson(newsettings)); setSettings(angular.toJson(newsettings));
} }
}; };

Wyświetl plik

@ -24,7 +24,7 @@ function StatusCtrl($rootScope, $scope, $state, $http) {
socket.onclose = function (msg) { socket.onclose = function (msg) {
// $scope.ConnectStyle = "label-danger"; // $scope.ConnectStyle = "label-danger";
$scope.ConnectState = "Closed"; $scope.ConnectState = "Disconnected";
$scope.$apply(); $scope.$apply();
setTimeout(connect, 1000); setTimeout(connect, 1000);
}; };

Wyświetl plik

@ -10,6 +10,8 @@ function WeatherCtrl($rootScope, $scope, $state, $http, $interval) {
$scope.$parent.helppage = 'plates/weather-help.html'; $scope.$parent.helppage = 'plates/weather-help.html';
$scope.data_list = []; $scope.data_list = [];
$scope.watch_list = []; $scope.watch_list = [];
$scope.data_count = 0;
$scope.watch_count = 0;
function updateWatchList() { function updateWatchList() {
$scope.watching = CONF_WATCHLIST; $scope.watching = CONF_WATCHLIST;

Wyświetl plik

@ -12,9 +12,17 @@
</ul> </ul>
<p>The <strong>Configuration</strong> section lets you adjust the default operation of your Stratux device.</p> <p>The <strong>Configuration</strong> section lets you adjust the default operation of your Stratux device.</p>
<ul> <ul class="list-simple">
<li>The SDR (software defined radio) receiver support error correction. From the Raspberry Pi, you may use the command <code>kal -g 48 -s GSM850</code> to scan for available channels in your area. Then use the command <code>kal -g 48 -c <em>channel#</em></code> to calculate the PPM. <div class="text-warning">NOTE: You will need to perform all commands as <code>root</code> by issuing the command: <code>sudo su -</code>. You will need to stop the Stratux software before running the calibration process. You can stop all of the Stratux processes with the command: <code>pkill screen</code>.</div></li> <li>To avoid having your own aircraft appear as traffic, and scare the bejeezus our of you, you may provide your <strong>Mode S code</strong>. You can find this value in the FAA N-Number Registry for your aircraft. You should use the hexadecimal value (not the octal value) for this setting. No validation is done so please ensure you enter your valide Mode S value.
<li>The <strong>Weather</strong> page uses a user-defined <em>watch list</em> to filter the large volume of ADS-B weather messages for display. Define a list of identifiers (airport, VOR, etc) separated by a spaces. For example <code>KBOS EEN LAH LKP</code>. You may change this list at any time and the <strong>Weather</strong> page will start watching for the updated list immediately.</li> </li>
<li>The <strong>Weather</strong> page uses a user-defined <strong>Watch List</strong> to filter the large volume of ADS-B weather messages for display. Define a list of identifiers (airport, VOR, etc) separated by a spaces. For example <code>KBOS EEN LAH LKP</code>. You may change this list at any time and the <strong>Weather</strong> page will start watching for the updated list immediately.
<br/>
<span class="text-warning">NOTE: To save your changes, you must either tap somehwere else on the page or hit <code>ENTER</code> or <code>RETURN</code> or <code>GO</code> (or whatever your keyboard indicates).</span>
</li>
<li>The SDR (software defined radio) receiver support an adjustment in the form of a <strong>PPM Correction</strong>. From the Raspberry Pi, you may use the command <code>kal -g 48 -s GSM850</code> to scan for available channels in your area. Then use the command <code>kal -g 48 -c <em>channel#</em></code> to calculate the PPM.
<br/>
<span class="text-warning">NOTE: You will need to perform all commands as <code>root</code> by issuing the command: <code>sudo su -</code>. You will need to stop the Stratux software before running the calibration process. You can stop all of the Stratux processes with the command: <code>pkill screen</code>.</span>
</li>
<li>Addiitonal settings will be added in future releases.</li> <li>Addiitonal settings will be added in future releases.</li>
</ul> </ul>
</div> </div>

Wyświetl plik

@ -56,17 +56,24 @@
<div class="panel-heading">Configuration</div> <div class="panel-heading">Configuration</div>
<div class="panel-body"> <div class="panel-body">
<div class="form-group reset-flow"> <div class="form-group reset-flow">
<label class="control-label col-xs-5">PPM Correction</label> <label class="control-label col-xs-5">Mode S Code (Hex)</label>
<form name="ppmForm" ng-submit="updateppm()" novalidate> <form name="modeForm" ng-submit="updatemodes()" novalidate>
<!-- type="number" not supported except on mobile --> <!-- type="number" not supported except on mobile -->
<input class="col-xs-7" type="number_format" required ng-model="PPM" placeholder="integer" /> <input class="col-xs-7" type="string" required ng-model="OwnshipModeS" placeholder="FAA HEX code" ng-blur="updatemodes()" />
</form> </form>
</div> </div>
<div class="form-group reset-flow"> <div class="form-group reset-flow">
<label class="control-label col-xs-5">Watch List</label> <label class="control-label col-xs-5">Watch List</label>
<form name="ppmForm" ng-submit="updatewatchlist()" novalidate> <form name="watchForm" ng-submit="updatewatchlist()" novalidate>
<!-- type="number" not supported except on mobile --> <!-- type="number" not supported except on mobile -->
<input class="col-xs-7" type="string" required ng-model="WatchList" placeholder="space delimeted identifiers" /> <input class="col-xs-7" type="string" required ng-model="WatchList" placeholder="space delimeted identifiers" ng-blur="updatewatchlist()" />
</form>
</div>
<div class="form-group reset-flow">
<label class="control-label col-xs-5">PPM Correction</label>
<form name="ppmForm" ng-submit="updateppm()" novalidate>
<!-- type="number" not supported except on mobile -->
<input class="col-xs-7" type="number_format" required ng-model="PPM" placeholder="integer" ng-blur="updateppm()" />
</form> </form>
</div> </div>
</div> </div>
@ -75,7 +82,7 @@
</div> </div>
<!-- <!--
<div class="col-sm-12"> ssh<div class="col-sm-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">Raw Configuration</div> <div class="panel-heading">Raw Configuration</div>
<div class="panel-body"> <div class="panel-body">