From 62342d7fca6fd08a1c1f51f9fc8ea25c7b187de2 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Fri, 25 Dec 2020 07:46:33 +0800 Subject: [PATCH 1/8] Added code to read in new config file data --- chasemapper/config.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/chasemapper/config.py b/chasemapper/config.py index f5ad670..add2034 100644 --- a/chasemapper/config.py +++ b/chasemapper/config.py @@ -138,6 +138,28 @@ def parse_config_file(filename): chase_config['selected_profile'] = "" chase_config['profiles'] = {} + + # Unit Selection + + chase_config['unitselection'] = config.get('units', 'unitselection') + chase_config['m_to_ft'] = config.get('units', 'm_to_ft') + chase_config['km_to_miles'] = config.get('units', 'km_to_miles') + chase_config['secs_to_mins'] = config.get('units', 'secs_to_mins') + chase_config['ms_to_knots'] = config.get('units', 'ms_to_knots') + chase_config['switch_miles_feet'] = config.get('units', 'switch_miles_feet') + + logging.info("Units: " + chase_config['unitselection']) + logging.info("m_to_f: " + chase_config['m_to_ft']) + logging.info("km_to_miles: " + chase_config['km_to_miles']) + logging.info("secs_to_mins: " + chase_config['secs_to_mins']) + logging.info("ms_to_knots: " + chase_config['ms_to_knots']) + logging.info("switch_miles_feet: " + chase_config['switch_miles_feet'] + " metres") + + + + + + for i in range(1,_profile_count+1): _profile_section = "profile_%d" % i try: From 5f9dc077abf5567e9661aaa010638cd372152d69 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Fri, 25 Dec 2020 07:48:46 +0800 Subject: [PATCH 2/8] Fix code to read in settings --- chasemapper/config.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chasemapper/config.py b/chasemapper/config.py index add2034..da4574b 100644 --- a/chasemapper/config.py +++ b/chasemapper/config.py @@ -141,19 +141,19 @@ def parse_config_file(filename): # Unit Selection - chase_config['unitselection'] = config.get('units', 'unitselection') - chase_config['m_to_ft'] = config.get('units', 'm_to_ft') - chase_config['km_to_miles'] = config.get('units', 'km_to_miles') - chase_config['secs_to_mins'] = config.get('units', 'secs_to_mins') - chase_config['ms_to_knots'] = config.get('units', 'ms_to_knots') - chase_config['switch_miles_feet'] = config.get('units', 'switch_miles_feet') + chase_config['unitselection'] = config.get('units', 'unitselection') + chase_config['m_to_ft'] = config.get('units', 'm_to_ft') + chase_config['km_to_miles'] = config.get('units', 'km_to_miles') + chase_config['secs_to_mins'] = config.get('units', 'secs_to_mins') + chase_config['ms_to_knots'] = config.get('units', 'ms_to_knots') + chase_config['switch_miles_feet'] = config.get('units', 'switch_miles_feet') - logging.info("Units: " + chase_config['unitselection']) - logging.info("m_to_f: " + chase_config['m_to_ft']) - logging.info("km_to_miles: " + chase_config['km_to_miles']) - logging.info("secs_to_mins: " + chase_config['secs_to_mins']) - logging.info("ms_to_knots: " + chase_config['ms_to_knots']) - logging.info("switch_miles_feet: " + chase_config['switch_miles_feet'] + " metres") + logging.info("Units: " + chase_config['unitselection']) + logging.info("m_to_f: " + chase_config['m_to_ft']) + logging.info("km_to_miles: " + chase_config['km_to_miles']) + logging.info("secs_to_mins: " + chase_config['secs_to_mins']) + logging.info("ms_to_knots: " + chase_config['ms_to_knots']) + logging.info("switch_miles_feet: " + chase_config['switch_miles_feet'] + " metres") From 907c98314009ba6eab558cd487fee032065425fb Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Fri, 25 Dec 2020 08:47:20 +0800 Subject: [PATCH 3/8] Summary bar working and tested on live data --- static/js/balloon.js | 52 ++++++++++++++++++++- static/js/tables.js | 106 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 3 deletions(-) diff --git a/static/js/balloon.js b/static/js/balloon.js index e4e5337..ae23317 100644 --- a/static/js/balloon.js +++ b/static/js/balloon.js @@ -109,6 +109,8 @@ function add_new_balloon(data){ } function updateSummaryDisplay(){ + + if (chase_config['unitselection'] == "imperial1") {updateSummaryDisplayImperial1() ; return ; } // else do everything in metric // Update the 'Payload Summary' display. var _summary_update = {id:1}; // See if there is any payload data. @@ -151,6 +153,54 @@ function updateSummaryDisplay(){ $("#summary_table").tabulator("redraw", true); } } +function updateSummaryDisplayImperial1(){ + + // Update the 'Payload Summary' display. + var _summary_update = {id:1}; + // See if there is any payload data. + if (balloon_positions.hasOwnProperty(balloon_currently_following) == true){ + // There is balloon data! + var _latest_telem = balloon_positions[balloon_currently_following].latest_data; + + _summary_update.alt = (_latest_telem.position[2]*chase_config['m_to_ft']).toFixed(0) + "ft (" + (_latest_telem.max_alt*chase_config['m_to_ft']).toFixed(0) + "ft)"; + var _speed = _latest_telem.speed*3.6 ; + _summary_update.speed = (_speed*chase_config['km_to_miles']).toFixed(0) + " mph"; + _summary_update.vel_v = (_latest_telem.vel_v*chase_config['m_to_ft']/chase_config['secs_to_mins']).toFixed(0) + " ft/min"; + + + if (chase_car_position.latest_data.length == 3){ + // We have a chase car position! Calculate relative position. + var _bal = {lat:_latest_telem.position[0], lon:_latest_telem.position[1], alt:_latest_telem.position[2]}; + var _car = {lat:chase_car_position.latest_data[0], lon:chase_car_position.latest_data[1], alt:chase_car_position.latest_data[2]}; + + var _look_angles = calculate_lookangles(_car, _bal); + + _summary_update.elevation = _look_angles.elevation.toFixed(0) + "°"; + _summary_update.azimuth = _look_angles.azimuth.toFixed(0) + "°"; + if (_look_angles.range > chase_config['switch_miles_feet']) { + _summary_update.range = (_look_angles.range*chase_config['km_to_miles']/1000).toFixed(1) + "miles"; + } else { + _summary_update.range = (_look_angles.range*chase_config['m_to_ft']).toFixed(1) + "ft"; + } + }else{ + // No Chase car position data - insert dummy values + _summary_update.azimuth = "---°"; + _summary_update.elevation = "--°"; + _summary_update.range = "----m"; + } + + }else{ + // No balloon data! + _summary_update = {id: 1, alt:'-----m', speed:'---kph', vel_v:'-.-m/s', azimuth:'---°', elevation:'--°', range:'----m'} + } + // Update table + $("#summary_table").tabulator("setData", [_summary_update]); + if (summary_enlarged == true){ + var row = $("#summary_table").tabulator("getRow", 1); + row.getElement().addClass("largeTableRow"); + $("#summary_table").tabulator("redraw", true); + } +} function handleTelemetry(data){ // Telemetry Event messages contain a dictionary of position data. @@ -345,4 +395,4 @@ function showBalloon(callsign){ } } -} \ No newline at end of file +} diff --git a/static/js/tables.js b/static/js/tables.js index bcf7dd2..ad1a164 100644 --- a/static/js/tables.js +++ b/static/js/tables.js @@ -145,9 +145,11 @@ function telemetryTableDialog(e, row){ divObj.dialog('open'); } + // Initialise tables function initTables(){ // Telemetry data table + if (chase_config['unitselection'] == "imperial1") {initTablesImperial1() ; return ; } // else do everything in metric $("#telem_table").tabulator({ layout:"fitData", layoutColumnsOnNewData:true, @@ -203,10 +205,68 @@ function initTables(){ $("#bearing_table").hide(); } +// Initialise tables in Imperial1 - Vertical velocity feet/min, Horizontal velocity Miles/hr, Range Miles then feet for Range < config setting +function initTablesImperial1(){ + // Telemetry data table + $("#telem_table").tabulator({ + layout:"fitData", + layoutColumnsOnNewData:true, + //selectable:1, // TODO... + columns:[ //Define Table Columns + {title:"Callsign", field:"callsign", headerSort:false}, + {title:"Time (Z)", field:"short_time", headerSort:false}, + {title:"Latitude", field:"lat", headerSort:false}, + {title:"Longitude", field:"lon", headerSort:false}, + {title:"Alt (ft)", field:"alt", headerSort:false}, + {title:"V_rate (ft/min)", field:"vel_v", headerSort:false}, + {title:"SNR", field:'snr', headerSort:false, visible:false}, + {title:"Aux", field:'aux', headerSort:false, visible:false} + ], + rowClick:function(e, row){telemetryTableDialog(e, row);}, + rowTap:function(e, row){telemetryTableDialog(e, row);} + + }); + + $("#summary_table").tabulator({ + layout:"fitData", + layoutColumnsOnNewData:true, + columns:[ //Define Table Columns + {title:"Alt (ft)", field:"alt", headerSort:false}, + {title:"Speed (mph)", field:"speed", headerSort:false}, + {title:"Asc Rate (ft/min)", field:"vel_v", headerSort:false}, + {title:"Azimuth", field:"azimuth", headerSort:false}, + {title:"Elevation", field:"elevation", headerSort:false}, + {title:"Range", field:"range", headerSort:false}, + ], + data:[{id: 1, alt:'-----ft', speed:'---mph', vel_v:'---ft/min', azimuth:'---°', elevation:'--°', range:'----miles'}], + rowClick:function(e, row){ + toggleSummarySize(); + }, + rowTap:function(e, row){ + toggleSummarySize(); + } + }); + + + $("#bearing_table").tabulator({ + layout:"fitData", + layoutColumnsOnNewData:true, + //selectable:1, // TODO... + columns:[ //Define Table Columns + {title:"Bearing", field:"bearing", headerSort:false}, + {title:"Score", field:'confidence', headerSort:false}, + {title:"Power", field:'power', headerSort:false} + ], + data:[{id: 1, bearing:0.0, confidence:0.0}] + }); + + $("#bearing_table").hide(); +} + function updateTelemetryTable(){ var telem_data = []; - + if (chase_config['unitselection'] == "imperial1") {initTablesImperial1() ; return ; } // else do everything in metric if (jQuery.isEmptyObject(balloon_positions)){ telem_data = [{callsign:'None'}]; }else{ @@ -244,4 +304,46 @@ function updateTelemetryTable(){ } $("#telem_table").tabulator("setData", telem_data); -} \ No newline at end of file +} + +function updateTelemetryTableImperial1(){ + var telem_data = []; + if (chase_config['unitselection'] == "imperial1") {initTablesImperial1() ; return ; } // else do everything in metric + if (jQuery.isEmptyObject(balloon_positions)){ + telem_data = [{callsign:'None'}]; + }else{ + for (balloon_call in balloon_positions){ + var balloon_call_data = Object.assign({},balloon_positions[balloon_call].latest_data); + var balloon_call_age = balloon_positions[balloon_call].age; + + // Modify some of the fields to fixed point values. + balloon_call_data.lat = balloon_call_data.position[0].toFixed(5); + balloon_call_data.lon = balloon_call_data.position[1].toFixed(5); + balloon_call_data.alt = (balloon_call_data.position[2]*chase_config['m_to_ft']).toFixed(1) + " (" + (balloon_call_data.max_alt*chase_config['m_to_ft']).toFixed(0) + ")" ; + balloon_call_data.vel_v = (balloon_call_data.vel_v*chase_config['m_to_ft']/chase_config['secs_to_mins']).toFixed(1); + + // Add in any extra data to the aux field. + balloon_call_data.aux = ""; + balloon_call_data.snr = ""; + + if (balloon_call_data.hasOwnProperty('bt')){ + if ((balloon_call_data.bt >= 0) && (balloon_call_data.bt < 65535)) { + balloon_call_data.aux += "BT " + new Date(balloon_call_data.bt*1000).toISOString().substr(11, 8) + " "; + $("#telem_table").tabulator("showColumn", "aux"); + } + } + + if (balloon_positions[balloon_call].hasOwnProperty('snr')){ + if (balloon_positions[balloon_call].snr > -255.0){ + balloon_call_data.snr = balloon_positions[balloon_call].snr.toFixed(1); + $("#telem_table").tabulator("showColumn", "snr"); + } + } + + // Update table + telem_data.push(balloon_call_data); + } + } + + $("#telem_table").tabulator("setData", telem_data); +} From f8549f346c2bb82e1aa432ed135dc03849cfb8de Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Fri, 25 Dec 2020 09:07:10 +0800 Subject: [PATCH 4/8] Summary bar tested at different ranges --- static/js/balloon.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/js/balloon.js b/static/js/balloon.js index ae23317..684c194 100644 --- a/static/js/balloon.js +++ b/static/js/balloon.js @@ -228,7 +228,11 @@ function handleTelemetry(data){ // Update Chase Car Speed if (document.getElementById("showCarSpeed").checked){ - $("#chase_car_speed").text( (chase_car_position.speed*3.6).toFixed(0) + " kph"); + if (chase_config['unitselection'] == "imperial1") { + $("#chase_car_speed").text( (chase_car_position.speed*3.6*chase_config['km_to_miles']).toFixed(0) + " mph"); + } else { + $("#chase_car_speed").text( (chase_car_position.speed*3.6).toFixed(0) + " kph"); + } $("#chase_car_speed_header").text("Chase Car Speed"); } else { $("#chase_car_speed").text(""); From 87c65d812474b3b2abf52db83e38534f34571032 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Fri, 25 Dec 2020 09:47:01 +0800 Subject: [PATCH 5/8] Added values into example config file and set fallbacks in config.py --- chasemapper/config.py | 23 +++++++++++++++++------ horusmapper.cfg.example | 27 +++++++++++++++++++++++++++ static/js/tables.js | 5 ++--- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/chasemapper/config.py b/chasemapper/config.py index da4574b..bd794ec 100644 --- a/chasemapper/config.py +++ b/chasemapper/config.py @@ -52,6 +52,17 @@ default_config = { 'bearing_weight': 1.0, 'bearing_color': 'black', 'bearing_custom_color': '#FF0000', + + # Unit selection + 'unitselection': 'metric', + 'm_to_ft': 3.28084, + 'km_to_miles' : 0.6213171, + 'secs_to_mins' : 0.016666, + 'ms_to_knots' : 1.94384, + 'switch_miles_feet' : 400, + + + } @@ -141,12 +152,12 @@ def parse_config_file(filename): # Unit Selection - chase_config['unitselection'] = config.get('units', 'unitselection') - chase_config['m_to_ft'] = config.get('units', 'm_to_ft') - chase_config['km_to_miles'] = config.get('units', 'km_to_miles') - chase_config['secs_to_mins'] = config.get('units', 'secs_to_mins') - chase_config['ms_to_knots'] = config.get('units', 'ms_to_knots') - chase_config['switch_miles_feet'] = config.get('units', 'switch_miles_feet') + chase_config['unitselection'] = config.get('units', 'unitselection', fallback='metric') + chase_config['m_to_ft'] = config.get('units', 'm_to_ft', fallback = '3.28084') + chase_config['km_to_miles'] = config.get('units', 'km_to_miles', fallback = '0.621371') + chase_config['secs_to_mins'] = config.get('units', 'secs_to_mins', fallback = '0.016666') + chase_config['ms_to_knots'] = config.get('units', 'ms_to_knots', fallback = '1.94384') + chase_config['switch_miles_feet'] = config.get('units', 'switch_miles_feet', fallback = '400') logging.info("Units: " + chase_config['unitselection']) logging.info("m_to_f: " + chase_config['m_to_ft']) diff --git a/horusmapper.cfg.example b/horusmapper.cfg.example index 6b02eb1..20f332d 100644 --- a/horusmapper.cfg.example +++ b/horusmapper.cfg.example @@ -200,3 +200,30 @@ bearing_color = black # Custom bearing color, in hexadecimal #RRGGBB bearing_custom_color = #FF0000 + + + +[units] + +# unitselection allows choice of metric - the default or imperial1 - horizontal miles and feet for short distances, horizontal miles per hour, vertical feet, vertical feet per minute + +unitselection = metric +# unitselection = imperial1 + + +# Imperial conversion factors + +m_to_ft = 3.28084 +km_to_miles = 0.621371 +secs_to_mins = 0.016666 +ms_to_knots = 1.94384 + +# Sensible choice of unit selection (all thresholds set in metric) + +# This is the threshold for switching from miles to feet, set in meters. +switch_miles_feet = 400 + + + + + diff --git a/static/js/tables.js b/static/js/tables.js index ad1a164..7c482a6 100644 --- a/static/js/tables.js +++ b/static/js/tables.js @@ -266,7 +266,7 @@ function initTablesImperial1(){ function updateTelemetryTable(){ var telem_data = []; - if (chase_config['unitselection'] == "imperial1") {initTablesImperial1() ; return ; } // else do everything in metric + if (chase_config['unitselection'] == "imperial1") {updateTelemetryTableImperial1() ; return ; } // else do everything in metric if (jQuery.isEmptyObject(balloon_positions)){ telem_data = [{callsign:'None'}]; }else{ @@ -277,7 +277,7 @@ function updateTelemetryTable(){ // Modify some of the fields to fixed point values. balloon_call_data.lat = balloon_call_data.position[0].toFixed(5); balloon_call_data.lon = balloon_call_data.position[1].toFixed(5); - balloon_call_data.alt = balloon_call_data.position[2].toFixed(1) + " (" + balloon_call_data.max_alt.toFixed(0) + ")" ; + balloon_call_data.alt = balloon_call_data.position[2].toFixed(0) + " (" + balloon_call_data.max_alt.toFixed(0) + ")" ; balloon_call_data.vel_v = balloon_call_data.vel_v.toFixed(1); // Add in any extra data to the aux field. @@ -308,7 +308,6 @@ function updateTelemetryTable(){ function updateTelemetryTableImperial1(){ var telem_data = []; - if (chase_config['unitselection'] == "imperial1") {initTablesImperial1() ; return ; } // else do everything in metric if (jQuery.isEmptyObject(balloon_positions)){ telem_data = [{callsign:'None'}]; }else{ From 2299c898218853529a110ba913498505cf57dc23 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Tue, 29 Dec 2020 16:15:40 +0800 Subject: [PATCH 6/8] Minor fixes to text formats --- static/js/balloon.js | 2 +- static/js/tables.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/balloon.js b/static/js/balloon.js index 684c194..16571d7 100644 --- a/static/js/balloon.js +++ b/static/js/balloon.js @@ -178,7 +178,7 @@ function updateSummaryDisplayImperial1(){ _summary_update.elevation = _look_angles.elevation.toFixed(0) + "°"; _summary_update.azimuth = _look_angles.azimuth.toFixed(0) + "°"; if (_look_angles.range > chase_config['switch_miles_feet']) { - _summary_update.range = (_look_angles.range*chase_config['km_to_miles']/1000).toFixed(1) + "miles"; + _summary_update.range = (_look_angles.range*chase_config['km_to_miles']/1000).toFixed(1) + " miles"; } else { _summary_update.range = (_look_angles.range*chase_config['m_to_ft']).toFixed(1) + "ft"; } diff --git a/static/js/tables.js b/static/js/tables.js index 7c482a6..29087e6 100644 --- a/static/js/tables.js +++ b/static/js/tables.js @@ -238,7 +238,7 @@ function initTablesImperial1(){ {title:"Elevation", field:"elevation", headerSort:false}, {title:"Range", field:"range", headerSort:false}, ], - data:[{id: 1, alt:'-----ft', speed:'---mph', vel_v:'---ft/min', azimuth:'---°', elevation:'--°', range:'----miles'}], + data:[{id: 1, alt:'-----ft', speed:'---mph', vel_v:'---ft/min', azimuth:'---°', elevation:'--°', range:'---- miles'}], rowClick:function(e, row){ toggleSummarySize(); }, From a65e07a6a57bcc67a6314e2e6ce091388a54c877 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Tue, 29 Dec 2020 16:18:18 +0800 Subject: [PATCH 7/8] Fixes to text formatting --- templates/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/index.html b/templates/index.html index 209e5e9..32226c8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -259,6 +259,8 @@ map.addControl(new L.Control.Layers(map_layers)); // Add map scale. + if (chase_config['unitselection'] == "imperial1") { L.control.scale({imperial: true, metric: false}).addTo(map) ;} + if (chase_config['unitselection'] == "metric") { L.control.scale({imperial: false, metric: true}).addTo(map) ;} L.control.scale({imperial: false}).addTo(map); // Add sidebar to map (where all of our controls are!) From 65a64878e742dcefc8cccf2532729b90ba55ea36 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Tue, 29 Dec 2020 16:26:22 +0800 Subject: [PATCH 8/8] Fix metric imperial scale bar --- templates/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 32226c8..e6bde0b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -261,7 +261,6 @@ // Add map scale. if (chase_config['unitselection'] == "imperial1") { L.control.scale({imperial: true, metric: false}).addTo(map) ;} if (chase_config['unitselection'] == "metric") { L.control.scale({imperial: false, metric: true}).addTo(map) ;} - L.control.scale({imperial: false}).addTo(map); // Add sidebar to map (where all of our controls are!) var sidebar = L.control.sidebar('sidebar').addTo(map);