diff --git a/test/mtk_config.sh b/test/mtk_config.sh old mode 100644 new mode 100755 diff --git a/web/plates/js/traffic.js b/web/plates/js/traffic.js index 56711a74..18eda13a 100755 --- a/web/plates/js/traffic.js +++ b/web/plates/js/traffic.js @@ -6,9 +6,10 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) { $scope.$parent.helppage = 'plates/traffic-help.html'; $scope.data_list = []; + $scope.data_list_invalid = []; + - function utcTimeString(epoc) { var time = ""; @@ -23,6 +24,7 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) { time += "Z"; return time; } +/* function dmsString(val) { return [0 | val, @@ -32,17 +34,37 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) { 0 | val * 60 % 1 * 60, '"'].join(''); } +*/ +// chop off seconds for space + function dmsString(val) { + var deg; + var min; + deg = 0 | val; + min = 0 | (val < 0 ? val = -val : val) % 1 * 60; + + return [deg*deg < 100 ? "0" + deg : deg, + '° ', + min < 10 ? "0" + min : min, + "' "].join(''); + } + function setAircraft(obj, new_traffic) { new_traffic.icao_int = obj.Icao_addr; new_traffic.targettype = obj.TargetType; - new_traffic.signal = obj.SignalLevel.toFixed(2); + new_traffic.signal = obj.SignalLevel; new_traffic.addr_symb ='\u2708'; if (new_traffic.targettype > 3) { new_traffic.addr_symb ='\ud83d\udce1'; } new_traffic.icao = obj.Icao_addr.toString(16).toUpperCase(); new_traffic.tail = obj.Tail; + if (obj.Squawk == 0) { + new_traffic.squawk = "----"; + } else { + new_traffic.squawk = obj.Squawk; + } + new_traffic.addr_type = obj.Addr_type; new_traffic.lat = dmsString(obj.Lat); new_traffic.lon = dmsString(obj.Lng); var n = Math.round(obj.Alt / 25) * 25; @@ -58,8 +80,11 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) { new_traffic.vspeed = Math.round(obj.Vvel / 100) * 100 var timestamp = Date.parse(obj.Timestamp); new_traffic.time = utcTimeString(timestamp); - new_traffic.age = (Math.round(obj.Age * 10)/10).toFixed(1); + new_traffic.age = obj.Age; + new_traffic.ageLastAlt = obj.AgeLastAlt; new_traffic.src = obj.Last_source; // 1=ES, 2=UAT + new_traffic.bearing = Math.round(obj.Bearing); // degrees true + new_traffic.dist = (obj.Distance/1852); // nautical miles // return new_aircraft; } @@ -101,9 +126,11 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) { var message = JSON.parse(msg.data); $scope.raw_data = angular.toJson(msg.data, true); - if (message.Position_valid) { + + // we need to use an array so AngularJS can perform sorting; it also means we need to loop to find an aircraft in the traffic set var found = false; + var foundInvalid = false; for (var i = 0, len = $scope.data_list.length; i < len; i++) { if ($scope.data_list[i].icao_int === message.Icao_addr) { setAircraft(message, $scope.data_list[i]); @@ -111,13 +138,39 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) { break; } } - if (!found) { + + for (var i = 0, len = $scope.data_list_invalid.length; i < len; i++) { + if ($scope.data_list_invalid[i].icao_int === message.Icao_addr) { + setAircraft(message, $scope.data_list_invalid[i]); + foundInvalid = true; + break; + } + } + + if ((!found) && (message.Position_valid)) { var new_traffic = {}; setAircraft(message, new_traffic); - $scope.data_list.unshift(new_traffic); // add to start of array + $scope.data_list.unshift(new_traffic); // add to start of main array if position is valid and removed from the invalid array + for (var i = 0, len = $scope.data_list_invalid.length; i < len; i++) { + if ($scope.data_list_invalid[i].icao_int === message.Icao_addr) { + $scope.data_list_invalid.splice(i, 1); + } + } + + } else if ((!foundInvalid) && (!message.Position_valid)) { + + var new_traffic = {}; + setAircraft(message, new_traffic); + $scope.data_list_invalid.unshift(new_traffic); // otherwise add to start of invalid array } + $scope.$apply(); - } + + + + + + }; } @@ -137,20 +190,23 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) { var tempLocalClock = new Date; $scope.LocalClock = tempLocalClock.toUTCString(); $scope.SecondsFast = (tempClock-tempLocalClock)/1000; + + $scope.GPS_connected = globalStatus.GPS_connected; }, function (response) { // nop }); }, 500, 0, false); - - - + + + // perform cleanup every 10 seconds var clearStaleTraffic = $interval(function () { - // remove stale aircraft = anything more than 59 seconds without an update + // remove stale aircraft = anything more than 59 seconds without a position update var dirty = false; + var dirtyInvalid = false; var cutoff =59; for (var i = len = $scope.data_list.length; i > 0; i--) { @@ -163,6 +219,17 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) { $scope.raw_data = ""; $scope.$apply(); } + + for (var i = len = $scope.data_list_invalid.length; i > 0; i--) { + if (($scope.data_list_invalid[i - 1].age >= cutoff) || ($scope.data_list_invalid[i - 1].ageLastAlt >= cutoff)) { + $scope.data_list_invalid.splice(i - 1, 1); + dirtyInvalid = true; + } + } + if (dirtyInvalid) { + $scope.raw_data = ""; + $scope.$apply(); + } }, (1000 * 10), 0, false); diff --git a/web/plates/traffic-help.html b/web/plates/traffic-help.html index b6122370..758511e1 100755 --- a/web/plates/traffic-help.html +++ b/web/plates/traffic-help.html @@ -1,17 +1,25 @@
-

The Traffic page provides a list of all aircraft position reports received within the last 60 seconds. Each time a new aircraft is reported, it is added to the list. Each time a new report is received for an existing aircraft, the list is updated. If a report for an aircraft has not been received within the last 60 seconds, the aircraft is removed from the list.

+

The Traffic page provides a list of all aircraft position reports received within the last 60 seconds. Each time a new aircraft is detected, it is added to the list. Each time a new report is received for an existing aircraft, the list is updated. If a valid position for an aircraft has not been received within the last 60 seconds, the aircraft is removed from the list.

For each aircraft, the list includes the following details:

-
\ No newline at end of file diff --git a/web/plates/traffic.html b/web/plates/traffic.html index 4fff4dbf..4c5dc501 100755 --- a/web/plates/traffic.html +++ b/web/plates/traffic.html @@ -1,66 +1,133 @@
- Traffic + ADS-B and TIS-B Traffic {{ConnectState}} {{ConnectState}}
+
-
- Flight - Speed - Altitude  - Course +
+ Callsign + Code + Squawk + Location + Dist + Bearing
-
-   - Location - Power (dB) - Age + +
+ Altitude  + Speed + Course + Power + Age
- -
+ +
-
+
- {{aircraft.addr_symb}} {{aircraft.tail}} - {{aircraft.addr_symb}} {{aircraft.icao}} + {{aircraft.addr_symb}} {{aircraft.tail}} + {{aircraft.addr_symb}} [--N/A--] + + + {{aircraft.icao}}{{aircraft.addr_type == 3 ? " (TFID)" : ""}} + 000{{aircraft.squawk}} + + {{aircraft.lat}} {{aircraft.lon}} + {{aircraft.dist.toFixed(1)}}NM + {{aircraft.bearing}}° - {{aircraft.speed}} KTS +
+
{{aircraft.alt}} {{aircraft.vspeed}} {{0-aircraft.vspeed}} - 00{{aircraft.heading}}° -
-
-   - {{aircraft.lat}} {{aircraft.lon}} - {{aircraft.signal}} - - {{aircraft.age}}s + {{aircraft.speed}}KTS + 00{{aircraft.heading}}° + {{aircraft.signal.toFixed(2)}}dB + {{aircraft.age.toFixed(1)}}s
- +
+ +
+
+ Basic Mode S and No-Position Messages +
+ +
+
+
+ Callsign + Code + Squawk +
+ +
+ Altitude  + Speed + Course + Power + Age +
+
+ +
+
+
+ + {{aircraft.addr_symb}} {{aircraft.tail}} + {{aircraft.addr_symb}} [--N/A--] + + {{aircraft.icao}}{{aircraft.addr_type == 3 ? " (TFID)" : ""}} + 000{{aircraft.squawk}} +
+ +
+ {{aircraft.alt}} + + {{aircraft.vspeed}} + {{0-aircraft.vspeed}} + + {{aircraft.speed}}KTS + 00{{aircraft.heading}}° + {{aircraft.signal.toFixed(2)}}dB + {{aircraft.ageLastAlt.toFixed(1)}}s +
+
+
+ +