From 72dcf4ba515f1197d20bfa6d261f62d6418f764b Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 14:16:06 +1000 Subject: [PATCH 01/10] fix crash --- js/tracker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/tracker.js b/js/tracker.js index 082c993..d0b361a 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -2591,18 +2591,18 @@ function addPosition(position) { var search_matches = vehicle.positions_ts.filter(searchPositions) - if (search_matches.length > 0 && search_matches[search_matches.length-1] >= search_ts - 5000) { + if (search_matches.length > 0 && search_matches[search_matches.length-1] >= search_ts - 5000 && vehicle.positions.length >= search_matches.length) { var search_match = search_matches[search_matches.length-1] var dtt = (curr_ts - search_match) / 1000; // calculate vertical rate - var rate = (position.gps_alt - vehicle.positions_alts[search_matches.length]) / dtt; + var rate = (position.gps_alt - vehicle.positions_alts[search_matches.length-1]) / dtt; if (!isNaN(rate) && isFinite(rate)) { vehicle.ascent_rate = 0.5 * rate + 0.5 * vehicle.ascent_rate; } // calculate horizontal rate - horizontal_rate_temp = new_latlng.distanceTo(vehicle.positions[search_matches.length]) / dtt; + horizontal_rate_temp = new_latlng.distanceTo(vehicle.positions[search_matches.length-1]) / dtt; if (!isNaN(horizontal_rate_temp) && isFinite(horizontal_rate_temp)) { vehicle.horizontal_rate = horizontal_rate_temp; } From 970eaa9efd2c30b7fd78a2b1d31c8ef46849d8ec Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 14:16:58 +1000 Subject: [PATCH 02/10] fix --- js/tracker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/tracker.js b/js/tracker.js index d0b361a..c0a01a2 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -2591,7 +2591,7 @@ function addPosition(position) { var search_matches = vehicle.positions_ts.filter(searchPositions) - if (search_matches.length > 0 && search_matches[search_matches.length-1] >= search_ts - 5000 && vehicle.positions.length >= search_matches.length) { + if (search_matches.length > 0 && search_matches[search_matches.length-1] >= search_ts - 5000) { var search_match = search_matches[search_matches.length-1] var dtt = (curr_ts - search_match) / 1000; From b25f69ace93478617f0dc2b61cc5eb8b8f73d573 Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 14:27:01 +1000 Subject: [PATCH 03/10] update parameters --- js/tracker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/tracker.js b/js/tracker.js index c0a01a2..f80adcd 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -2598,7 +2598,7 @@ function addPosition(position) { // calculate vertical rate var rate = (position.gps_alt - vehicle.positions_alts[search_matches.length-1]) / dtt; if (!isNaN(rate) && isFinite(rate)) { - vehicle.ascent_rate = 0.5 * rate + 0.5 * vehicle.ascent_rate; + vehicle.ascent_rate = 0.2 * rate + 0.8 * vehicle.ascent_rate; } // calculate horizontal rate @@ -2611,7 +2611,7 @@ function addPosition(position) { // calculate vertical rate var rate = (position.gps_alt - vehicle.curr_position.gps_alt) / dt; if (!isNaN(rate) && isFinite(rate)) { - vehicle.ascent_rate = 0.7 * rate + 0.3 * vehicle.ascent_rate; + vehicle.ascent_rate = 0.2 * rate + 0.8 * vehicle.ascent_rate; } // calculate horizontal rate From 4cc2aef39baff5b33f49e32f2d25b366fd46b019 Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 14:35:24 +1000 Subject: [PATCH 04/10] more efficient --- js/tracker.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/js/tracker.js b/js/tracker.js index f80adcd..684b8b1 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -2585,24 +2585,29 @@ function addPosition(position) { if(vehicle.num_positions > 0 && dt > 0) { var search_ts = new_ts - 10000 - function searchPositions(time) { - return time <= search_ts + function searchPositions(times) { + for (i = times.length; i >= 0; i--) { + if (times[i] <= search_ts) { + return times[i] + } + } + return null } - var search_matches = vehicle.positions_ts.filter(searchPositions) + var search_match = searchPositions(vehicle.positions_ts) + var search_index = vehicle.positions_ts.indexOf(search_match) - if (search_matches.length > 0 && search_matches[search_matches.length-1] >= search_ts - 5000) { - var search_match = search_matches[search_matches.length-1] + if (search_match != null && search_match >= search_ts - 5000) { var dtt = (curr_ts - search_match) / 1000; // calculate vertical rate - var rate = (position.gps_alt - vehicle.positions_alts[search_matches.length-1]) / dtt; + var rate = (position.gps_alt - vehicle.positions_alts[search_index]) / dtt; if (!isNaN(rate) && isFinite(rate)) { vehicle.ascent_rate = 0.2 * rate + 0.8 * vehicle.ascent_rate; } // calculate horizontal rate - horizontal_rate_temp = new_latlng.distanceTo(vehicle.positions[search_matches.length-1]) / dtt; + horizontal_rate_temp = new_latlng.distanceTo(vehicle.positions[search_index]) / dtt; if (!isNaN(horizontal_rate_temp) && isFinite(horizontal_rate_temp)) { vehicle.horizontal_rate = horizontal_rate_temp; } From 857256f45ced2e57c03afb0a0868a9e05398f85f Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 14:44:07 +1000 Subject: [PATCH 05/10] refresh receivers every 5 minutes --- js/tracker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/tracker.js b/js/tracker.js index 684b8b1..901a6a3 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -3242,6 +3242,7 @@ function refreshReceivers() { updateReceivers(response); }, complete: function(request, textStatus) { + periodical_receivers = setTimeout(function() {refreshReceivers(false)}, 60 * 5 * 1000); if (!offline.get("opt_hide_chase")) { refreshNewReceivers(true); } From c86db88ad04a61321d22ae3ca69cda6c6b80b5d5 Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 15:15:56 +1000 Subject: [PATCH 06/10] persistent callsigns --- js/tracker.js | 77 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/js/tracker.js b/js/tracker.js index 901a6a3..eb099f7 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -1372,38 +1372,66 @@ function updateVehicleInfo(vcallsign, newPosition) { var callsign_list = []; + var current_time = convert_time(newPosition.server_time) + + for(var i = 0; i < vehicle.receiver_info.length; i++){ + if (vehicle.receiver_info[i]["time"] < current_time - 10000) { + vehicle.receiver_info.splice(i,1); + } + } + + function addReceiver(callsign) { + if (vehicle.receiver_info.filter(function(e) { return e.callsign === callsign; }).length > 0) { + return + } + var temp_receiver = {callsign: callsign, time: current_time} + if(newPosition.callsign[callsign].hasOwnProperty('snr')){ + if(newPosition.callsign[callsign].snr){ + temp_receiver.snr = newPosition.callsign[rxcall].snr.toFixed(0) + } + } + if(newPosition.callsign[callsign].hasOwnProperty('rssi')){ + if(newPosition.callsign[callsign].rssi){ + temp_receiver.rssi = newPosition.callsign[rxcall].rssi.toFixed(0) + } + } + if(newPosition.callsign[callsign].hasOwnProperty('frequency')){ + if(newPosition.callsign[callsign].frequency){ + temp_receiver.frequency = newPosition.callsign[rxcall].frequency.toFixed(0) + } + } + vehicle.receiver_info.push(temp_receiver) + } + if($.type(newPosition.callsign) === "string"){ // Single callsign entry, as a string (chase cars) callsign_list = newPosition.callsign; } else { // Multiple callsigns, as an object for(var rxcall in newPosition.callsign){ - if(newPosition.callsign.hasOwnProperty(rxcall)) { - _new_call = rxcall; - tempFields = []; - if(newPosition.callsign[rxcall].hasOwnProperty('snr')){ - if(newPosition.callsign[rxcall].snr){ - tempFields.push(newPosition.callsign[rxcall].snr.toFixed(0) + " dB"); - } - } - if(newPosition.callsign[rxcall].hasOwnProperty('rssi')){ - if(newPosition.callsign[rxcall].rssi){ - tempFields.push(newPosition.callsign[rxcall].rssi.toFixed(0) + " dBm"); - } - } - if(newPosition.callsign[rxcall].hasOwnProperty('frequency')){ - if(newPosition.callsign[rxcall].frequency){ - tempFields.push(newPosition.callsign[rxcall].frequency + " MHz"); - } - } - if(tempFields.length > 0) { - _new_call += " (" + tempFields.join(", ") + ")"; - } - callsign_list.push(_new_call); // catch cases where there are no fields + addReceiver(rxcall) + } + + for(var receiver in vehicle.receiver_info){ + _new_call = vehicle.receiver_info[receiver].callsign; + tempFields = []; + if(vehicle.receiver_info[receiver].hasOwnProperty('snr')){ + tempFields.push(vehicle.receiver_info[receiver].snr + " dB"); + } + if(vehicle.receiver_info[receiver].hasOwnProperty('rssi')){ + tempFields.push(vehicle.receiver_info[receiver].rssi + " dBm"); } + if(vehicle.receiver_info[receiver].hasOwnProperty('frequency')){ + tempFields.push(vehicle.receiver_info[receiver].frequency + " MHz"); + } + if(tempFields.length > 0) { + _new_call += " (" + tempFields.join(", ") + ")"; + } + callsign_list.push(_new_call); // catch cases where there are no fields } + callsign_list = callsign_list.join(", "); - } +} var timeNow = new Date(); var timeSent = convert_time(newPosition.server_time); @@ -2483,7 +2511,8 @@ function addPosition(position) { graph_data: [], graph_yaxes: [], updated: false, - start_time: 2147483647000 + start_time: 2147483647000, + receiver_info: [] }; // deep copy yaxes config for graph From 84b7693e41cb4faa6399a00c76146bee5e3bd280 Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 15:25:16 +1000 Subject: [PATCH 07/10] Update sidebar layout --- js/tracker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/tracker.js b/js/tracker.js index eb099f7..d60b4f5 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -1375,7 +1375,7 @@ function updateVehicleInfo(vcallsign, newPosition) { var current_time = convert_time(newPosition.server_time) for(var i = 0; i < vehicle.receiver_info.length; i++){ - if (vehicle.receiver_info[i]["time"] < current_time - 10000) { + if (vehicle.receiver_info[i]["time"] < current_time - 15000) { vehicle.receiver_info.splice(i,1); } } @@ -1413,7 +1413,7 @@ function updateVehicleInfo(vcallsign, newPosition) { } for(var receiver in vehicle.receiver_info){ - _new_call = vehicle.receiver_info[receiver].callsign; + _new_call = "- " + vehicle.receiver_info[receiver].callsign; tempFields = []; if(vehicle.receiver_info[receiver].hasOwnProperty('snr')){ tempFields.push(vehicle.receiver_info[receiver].snr + " dB"); @@ -1430,7 +1430,7 @@ function updateVehicleInfo(vcallsign, newPosition) { callsign_list.push(_new_call); // catch cases where there are no fields } - callsign_list = callsign_list.join(", "); + callsign_list = callsign_list.join("
"); } var timeNow = new Date(); From 7d579db4eb3f3a181ff1e8bad39b54cec8d131ac Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 15:36:02 +1000 Subject: [PATCH 08/10] Increase stability --- js/tracker.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/tracker.js b/js/tracker.js index d60b4f5..f5b382d 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -1381,9 +1381,12 @@ function updateVehicleInfo(vcallsign, newPosition) { } function addReceiver(callsign) { - if (vehicle.receiver_info.filter(function(e) { return e.callsign === callsign; }).length > 0) { - return - } + for(var i = 0; i < vehicle.receiver_info.length; i++){ + if (vehicle.receiver_info[i]["callsign"] === callsign) { + vehicle.receiver_info[i]["time"] = current_time + return + } + } var temp_receiver = {callsign: callsign, time: current_time} if(newPosition.callsign[callsign].hasOwnProperty('snr')){ if(newPosition.callsign[callsign].snr){ @@ -1431,10 +1434,10 @@ function updateVehicleInfo(vcallsign, newPosition) { } callsign_list = callsign_list.join("
"); -} + } var timeNow = new Date(); - var timeSent = convert_time(newPosition.server_time); + var timeSent = convert_time(newPosition.gps_time); var timeChosen = null; if (timeSent > timeNow) { From 570e9661dd6fca7376e248a280b67ffea7e9c561 Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 15:50:08 +1000 Subject: [PATCH 09/10] update frequency and signal strength --- js/tracker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/tracker.js b/js/tracker.js index f5b382d..cea7855 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -1400,7 +1400,7 @@ function updateVehicleInfo(vcallsign, newPosition) { } if(newPosition.callsign[callsign].hasOwnProperty('frequency')){ if(newPosition.callsign[callsign].frequency){ - temp_receiver.frequency = newPosition.callsign[rxcall].frequency.toFixed(0) + temp_receiver.frequency = newPosition.callsign[rxcall].frequency.toFixed(4) } } vehicle.receiver_info.push(temp_receiver) From d3c2361ab1bf7094c80c77481e1acc3c19bb0e64 Mon Sep 17 00:00:00 2001 From: Uskompuf <22492406+Uskompuf@users.noreply.github.com> Date: Sun, 26 Jun 2022 15:50:25 +1000 Subject: [PATCH 10/10] update live --- js/tracker.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/tracker.js b/js/tracker.js index ec126c9..e56d6db 100644 --- a/js/tracker.js +++ b/js/tracker.js @@ -1384,6 +1384,21 @@ function updateVehicleInfo(vcallsign, newPosition) { for(var i = 0; i < vehicle.receiver_info.length; i++){ if (vehicle.receiver_info[i]["callsign"] === callsign) { vehicle.receiver_info[i]["time"] = current_time + if(newPosition.callsign[callsign].hasOwnProperty('snr')){ + if(newPosition.callsign[callsign].snr){ + vehicle.receiver_info[i].snr = newPosition.callsign[rxcall].snr.toFixed(0) + } + } + if(newPosition.callsign[callsign].hasOwnProperty('rssi')){ + if(newPosition.callsign[callsign].rssi){ + vehicle.receiver_info[i].rssi = newPosition.callsign[rxcall].rssi.toFixed(0) + } + } + if(newPosition.callsign[callsign].hasOwnProperty('frequency')){ + if(newPosition.callsign[callsign].frequency){ + vehicle.receiver_info[i].frequency = newPosition.callsign[rxcall].frequency.toFixed(4) + } + } return } }