Skip to content

Commit

Permalink
Merge pull request cyoung#48 from TomBric/master
Browse files Browse the repository at this point in the history
Several minor changes implemented in radar

    display when altitude is based on ADSB estimation
    per default sound is off (browser requirement to have any interaction before playing sound)
    limitation of displayed targets down to 20 secs
    parameter in source code better visible for toggling traces off
    small error corrections if radar value not yet set
  • Loading branch information
b3nn0 authored Jun 5, 2020
2 parents d36ebf7 + a400437 commit fb5b3d0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
6 changes: 3 additions & 3 deletions web/js/svg.min.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions web/plates/js/radar-help.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="section text-left help-page">
<p>The <strong>Radar</strong> page provides a radar-like view of all aircraft seen within a specified <strong>range</strong> and a specified <strong>altitude difference</strong>. Range and altitude difference can be modified by pressing the buttons left and right of the radar.
<p>Aircraft where a valid position is received (ADS-B or OGN if available) are displayed as red aircraft symbols in the direction and distance to the own aircraft. Additionally the altitude difference (in 100 ft) to own altitude with corresponding plus and minus is printed in front of the airplane symbol. If the received traffic report of this aircraft shows "ascending" or "descending", an arrow up or down is added. </p>
<p>If Statux does not receive valid position reports of aircrafts (e.g. only Mode-S without ADSB-OUT) a <strong>green circle</strong> is displayed for this aircraft. The radius of the circle depends on the <strong>signal level</strong> of the received transmission (calculated via an exponential moving average function). Please be aware: The radius of the green circles is a <strong>rough estimation</strong> of the distance of the aircraft!. <strong>Do not expect of displaying a valid distance</strong>, since the signal level depends on many factors (antennas etc.). Nevertheless it may help you to watch out for aircraft nearby.</p>
<p>Along the green circle you will also notice numbers, which show the altitude difference (plus or minus) to your own aircraft, followed by arrow up or down if the aircraft sends vertical speeds</p>
<p>An aircraft is removed from the radar, if it is outside the range, or if there is no transmission received within the last 20 seconds.</p>
<p>The aircraft in the <strong>middle</strong> is a symbol for your own aircraft. Right below the own aircraft the current flight-level is displayed. This level is received from barometric measurement, if your stratux is equipped with it. If not, the flight level is depending on the GPS altitude or estimated by ADSB transmissions of other aircraft. Be aware that in both cases the altitude difference to other aircraft may be wrong because their position reports are based on barometric measurement. A barometric sensor is therefore absolutely recommended!</p>
<p>A short <strong>beep sound</strong> is played whenever an aircraft is within the inner circle range.</p>
<p><strong>"BpSp/Beep/Spch/SnOff"</strong> toogles between different sound outputs. Default is Beep (5x) and a spoken warning, alternatively only Beep, only Speech or silence. If speech is switched on, a warning e.g. "Traffic at 10 o'clock plus 500 feet" is spoken, whenever an aircraft enters the inner circle.</p>
<p><strong>"F/S"</strong> toggles full screen mode, which displays the radar in maximum screen size (landscape format recommended). </p>
</div>
46 changes: 32 additions & 14 deletions web/plates/js/radar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
angular.module('appControllers').controller('RadarCtrl', RadarCtrl); // get the main module contollers set
RadarCtrl.$inject = ['$rootScope', '$scope', '$state', '$http', '$interval']; // Inject my dependencies

//------------------ General Options ------------
var soundType = 3; // speech and sound output, 0=beep+speech (default) 1=Beep 2=Speech 3=Snd Off

const showTraces = 1; // show traces of planes
// const showTraces = 0; // do not show trace route of planes

const cutoff = 20; // time in seconds how long a plane is displayed after last packet,
// stratux uses 59 secs in traffic display

//-------------------------------------------------
var Lat;
var Long;

Expand All @@ -22,7 +32,6 @@ var minimalCircle = 25; //minimal circle in pixel around center ist distance is
var radar; // global RadarRenderer
var posangle = Math.PI; //global var for angle position of text

var soundType = 0; // speech and sound output, 0=beep+speech (default) 1=Beep 2=Speech 3=Snd Off
var synth; // global speechSynthesis variable

var AltDiffThreshold; // in 100 feet display value
Expand Down Expand Up @@ -72,15 +81,24 @@ function RadarCtrl($rootScope, $scope, $state, $http, $interval) {
var gps_time = Date.parse(situation.GPSLastGPSTimeStratuxTime);
if (gps_time - press_time < 1000) { //pressure is ok
BaroAltitude = Math.round(situation.BaroPressureAltitude.toFixed(0));
$scope.BaroAltValid = 'Baro';
if (situation.BaroSourceType != 4 ) { //not estimated, but from valid source
$scope.BaroAltValid = 'Baro';
} else { // adsb estimated
$scope.BaroAltValid = 'AdsbEstimated';
}
} else {
var gps_horizontal_accuracy = situation.GPSHorizontalAccuracy.toFixed(1);
if (gps_horizontal_accuracy > 19999) { //no valid gps signal
$scope.BaroAltValid = 'Invalid';
BaroAltitude = -100000; // marks invalid value
} else {
$scope.BaroAltValid = 'GPS';
BaroAltitude = situation.GPSAltitudeMSL.toFixed(1);
if (situation.BaroSourceType == 4 ) { //no pressure, but ADSB estimated
$scope.BaroAltValid = 'AdsbEstimated';
BaroAltitude = Math.round(situation.BaroPressureAltitude.toFixed(0));
} else {
$scope.BaroAltValid = 'GPS';
BaroAltitude = situation.GPSAltitudeMSL.toFixed(1);
}
}
}
var gps_horizontal_accuracy = situation.GPSHorizontalAccuracy.toFixed(1);
Expand Down Expand Up @@ -252,12 +270,14 @@ function RadarCtrl($rootScope, $scope, $state, $http, $interval) {
traffic.planetext = radar.rScreen.text(vorzeichen + Math.abs(altDiff) + pfeil).move(distx + 17, disty - 10).rotate(GPSCourse, distx, disty).addClass('textPlane');
traffic.planespeed = radar.rScreen.text(traffic.nspeed + 'kts').move(distx + 17, disty).rotate(GPSCourse, distx, disty).addClass('textPlaneSmall');
traffic.planetail = radar.rScreen.text(traffic.tail).move(distx + 17, disty + 10).rotate(GPSCourse, distx, disty).addClass('textPlaneReg');
if (!traffic.trace) {
if ( showTraces ) {
if (!traffic.trace) {
traffic.trace = radar.rScreen.polyline([[distx, disty]]).addClass('trace');
} else {
} else {
var points = traffic.trace.attr('points');
points += ' ' + [distx, disty];
traffic.trace.attr('points', points);
}
}
} else { // if airplane is outside of radarscreen
if (traffic.trace) { //remove trace when aircraft gets out of range
Expand Down Expand Up @@ -451,7 +471,7 @@ function RadarCtrl($rootScope, $scope, $state, $http, $interval) {

sit_socket.onmessage = function(msg) {
ownSituation(msg.data);
radar.update();
if (radar) radar.update();
};
}

Expand All @@ -478,9 +498,9 @@ function RadarCtrl($rootScope, $scope, $state, $http, $interval) {
/* boardtemp is celcius to tenths */
$scope.CPUTemp = boardtemp.toFixed(1);
}
radar.update();
if (radar) radar.update();
}, function(response) {
radar.update(); // just update, if status gets error
if (radar) radar.update(); // just update, if status gets error
});
}, 500, 0, false);

Expand All @@ -490,7 +510,6 @@ function RadarCtrl($rootScope, $scope, $state, $http, $interval) {
var clearStaleTraffic = $interval(function() {
// remove stale aircraft = anything more than x seconds without a position update

var cutoff = 59;
var cutTime = $scope.StratuxClock - cutoff * 1000;

// Clean up "valid position" table.
Expand All @@ -512,15 +531,14 @@ function RadarCtrl($rootScope, $scope, $state, $http, $interval) {

// Clean up "invalid position" table.
for (var i = $scope.data_list_invalid.length; i > 0; i--) {
//if (($scope.data_list_invalid[i - 1].timeVal < cutTime) || ($scope.data_list_invalid[i - 1].ageLastAlt < cutTime)) {
if ($scope.data_list_invalid[i - 1].Last_alt < cutTime) {
if ($scope.data_list_invalid[i - 1].circ) { // is displayed
$scope.data_list_invalid[i - 1].circ.remove().forget();
}
$scope.data_list_invalid.splice(i - 1, 1);
}
}
radar.update();
if (radar) radar.update();
}, (1000 * 10), 0, false);


Expand Down Expand Up @@ -552,7 +570,6 @@ function RadarCtrl($rootScope, $scope, $state, $http, $interval) {
$interval.cancel(clearStaleTraffic);
$interval.cancel(getClock);
};

radar = new RadarRenderer('radar_display', $scope, $http);

// Radar Controller tasks
Expand Down Expand Up @@ -826,9 +843,10 @@ function RadarRenderer(locationId, $scope, $http) {
var speech = radarAll.group().cx(-185).cy(-125);
speech.rect(40, 35).radius(10).cx(0).cy(0).addClass('zoom');
speech.text('Undef').cx(16).cy(0).addClass('tSmall');

displaySoundStatus(speech, soundType); //first time activation without synth speak
synth = window.speechSynthesis;
if (!synth) soundType = 1; // speech function not working, default now beep
displaySoundStatus(speech, soundType);

speech.on('click', function() {
switch (soundType) {
Expand Down
4 changes: 2 additions & 2 deletions web/plates/radar-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<p>Aircraft where a valid position is received (ADS-B or OGN if available) are displayed as red aircraft symbols in the direction and distance to the own aircraft. Additionally the altitude difference (in 100 ft) to own altitude with corresponding plus and minus is printed in front of the airplane symbol. If the received traffic report of this aircraft shows "ascending" or "descending", an arrow up or down is added. </p>
<p>If Statux does not receive valid position reports of aircrafts (e.g. only Mode-S without ADSB-OUT) a <strong>green circle</strong> is displayed for this aircraft. The radius of the circle depends on the <strong>signal level</strong> of the received transmission (calculated via an exponential moving average function). Please be aware: The radius of the green circles is a <strong>rough estimation</strong> of the distance of the aircraft!. <strong>Do not expect of displaying a valid distance</strong>, since the signal level depends on many factors (antennas etc.). Nevertheless it may help you to watch out for aircraft nearby.</p>
<p>Along the green circle you will also notice numbers, which show the altitude difference (plus or minus) to your own aircraft, followed by arrow up or down if the aircraft sends vertical speeds</p>
<p>An aircraft is removed from the radar, if it is outside the range, or if there is no transmission received within the last 60 seconds.</p>
<p>The aircraft in the <strong>middle</strong> is a symbol for your own aircraft. Right below the own aircraft the current flight-level is displayed. This level is received from barometric measurement, if your stratux is equipped with it. If not, the flight level is depending on the GPS altitude. Be aware that in this case the altitude difference to other aircraft may be wrong because their position reports are based on barometric measurement. A barometric sensor is therefore absolutely recommended!</p>
<p>An aircraft is removed from the radar, if it is outside the range, or if there is no transmission received within the last 20 seconds.</p>
<p>The aircraft in the <strong>middle</strong> is a symbol for your own aircraft. Right below the own aircraft the current flight-level is displayed. This level is received from barometric measurement, if your stratux is equipped with it. If not, the flight level is depending on the GPS altitude or estimated by ADSB transmissions of other aircraft. Be aware that in both cases the altitude difference to other aircraft may be wrong because their position reports are based on barometric measurement. A barometric sensor is therefore absolutely recommended!</p>
<p>A short <strong>beep sound</strong> is played whenever an aircraft is within the inner circle range.</p>
<p><strong>"BpSp/Beep/Spch/SnOff"</strong> toogles between different sound outputs. Default is Beep (5x) and a spoken warning, alternatively only Beep, only Speech or silence. If speech is switched on, a warning e.g. "Traffic at 10 o'clock plus 500 feet" is spoken, whenever an aircraft enters the inner circle.</p>
<p><strong>"F/S"</strong> toggles full screen mode, which displays the radar in maximum screen size (landscape format recommended). </p>
Expand Down
1 change: 1 addition & 0 deletions web/plates/radar.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<span ng-hide="ConnectState == 'Connected'" class="label label-danger">{{ConnectState}}</span>
<span ng-show="BaroAltValid == 'Baro'" class="label label-success">Baro-Alt</span>
<span ng-show="BaroAltValid == 'GPS'" class="label label-warning">No Baro-Alt, using GPS-Alt</span>
<span ng-show="BaroAltValid == 'AdsbEstimated'" class="label label-warning">No Baro-Alt, using ADSB</span>
<span ng-show="BaroAltValid == 'Invalid'" class="label label-danger">No Altitude!</span>
<span ng-show="GPSValid == 'Invalid'" class="label label-danger">No GPS!</span>
<span ng-show="CPUTemp < 70" class="label label-info">{{CPUTemp}}°C</span>
Expand Down

0 comments on commit fb5b3d0

Please sign in to comment.