Add satellite status to GPS UI page

pull/412/head
AvSquirrel 2016-05-07 06:14:36 +00:00
rodzic 34791c638a
commit 34e4ff2dd0
3 zmienionych plików z 70 dodań i 1 usunięć

Wyświetl plik

@ -5,6 +5,7 @@ var URL_SETTINGS_SET = "http://" + URL_HOST_BASE + "/setSettings";
var URL_GPS_GET = "http://" + URL_HOST_BASE + "/getSituation";
var URL_TOWERS_GET = "http://" + URL_HOST_BASE + "/getTowers"
var URL_STATUS_GET = "http://" + URL_HOST_BASE + "/getStatus"
var URL_SATELLITES_GET = "http://" + URL_HOST_BASE + "/getSatellites"
var URL_STATUS_WS = "ws://" + URL_HOST_BASE + "/status"
var URL_TRAFFIC_WS = "ws://" + URL_HOST_BASE + "/traffic";
var URL_WEATHER_WS = "ws://" + URL_HOST_BASE + "/weather";

Wyświetl plik

@ -54,6 +54,34 @@
</div>
</div>
</div>
<div class="col-sm-12">
<div class="col-sm-6">
<div class="panel panel-default">
<div class="panel-heading">
<span class="panel_label">GPS Satellites</span>
</div>
<div class="panel-body towers-page">
<div class="row">
<span class="col-xs-2"><strong>Satellite ID</strong></span>
<span class="col-xs-2 text-right"><strong>NMEA Code</strong></span>
<span class="col-xs-2 text-right"><strong>Elevation</strong></span>
<span class="col-xs-2 text-right"><strong>Azimuth</strong></span>
<span class="col-xs-2 text-right"><strong>Signal</strong></span>
</div>
<div class="row" ng-repeat="satellite in data_list | orderBy: 'SatelliteNMEA'">
<div class="separator"></div>
<span class="col-xs-2">{{satellite.SatelliteID}}</span>
<span class="col-xs-2 text-right">{{satellite.SatelliteNMEA}}</span>
<span class="col-xs-2 text-right">{{satellite.Elevation}}</span>
<span class="col-xs-2 text-right">{{satellite.Azimuth}}</span>
<span class="col-xs-2 text-right">{{satellite.Signal < 1 ? "---" : satellite.Signal}}</span>
</div>
</div>
</div>
</div>
</div>
<!--
<div class="col-sm-12">
<div class="panel panel-default">

Wyświetl plik

@ -4,7 +4,8 @@ GPSCtrl.$inject = ['$rootScope', '$scope', '$state', '$http', '$interval']; // I
// create our controller function with all necessary logic
function GPSCtrl($rootScope, $scope, $state, $http, $interval) {
$scope.$parent.helppage = 'plates/gps-help.html';
$scope.data_list = [];
var status = {};
var display_area_size = -1;
@ -106,9 +107,48 @@ function GPSCtrl($rootScope, $scope, $state, $http, $interval) {
});
};
function getSatellites() {
// Simple GET request example (note: response is asynchronous)
$http.get(URL_SATELLITES_GET).
then(function (response) {
loadSatellites(response.data);
}, function (response) {
$scope.raw_data = "error getting satellite data";
});
};
function setSatellite(obj, new_satellite) {
new_satellite.SatelliteNMEA = obj.SatelliteNMEA;
new_satellite.SatelliteID = obj.SatelliteID; // Formatted code indicating source and PRN code. e.g. S138==WAAS satellite 138, G2==GPS satellites 2
new_satellite.Elevation = obj.Elevation; // Angle above local horizon, -xx to +90
new_satellite.Azimuth = obj.Azimuth; // Bearing (degrees true), 0-359
new_satellite.Signal = obj.Signal; // Signal strength, 0 - 99; -99 indicates no reception
//new_satellite.Type = obj.Type;
}
function loadSatellites(data) {
if (($scope === undefined) || ($scope === null))
return; // we are getting called once after clicking away from the status page
var satellites = data; // it seems the json was already converted to an object list by the http request
$scope.raw_data = angular.toJson(data, true);
$scope.data_list.length = 0; // clear array
// we need to use an array so AngularJS can perform sorting; it also means we need to loop to find a tower in the towers set
for (var key in satellites) {
//if (satellites[key].Messages_last_minute > 0) {
var new_satellite = {};
setSatellite(satellites[key], new_satellite);
$scope.data_list.push(new_satellite); // add to start of array
//}
}
// $scope.$apply();
}
var updateStatus = $interval(function () {
// refresh GPS/AHRS status once each half second (aka polling)
getStatus();
getSatellites();
}, (1 * 500), 0, false);
$state.get('gps').onEnter = function () {