11var mission_id = 0 ;
22var position_id = 0 ;
3- var data_url = "https://api.v2.sondehub.org/datanew" ;
43var newdata_url = "https://api.v2.sondehub.org/sondes/telemetry" ;
54var olddata_url = "https://api.v2.sondehub.org/sondes" ;
65var receivers_url = "https://api.v2.sondehub.org/listeners/telemetry" ;
76var predictions_url = "https://api.v2.sondehub.org/predictions?vehicles=" ;
87var recovered_sondes_url = "https://api.v2.sondehub.org/recovered" ;
98
109var livedata = "wss://ws-reader.v2.sondehub.org/" ;
11- var client = new Paho . Client ( livedata , "SondeHub-Tracker" ) ;
10+ var clientID = "SondeHub-Tracker-" + Math . floor ( Math . random ( ) * 10000 ) ;
11+ var client = new Paho . Client ( livedata , clientID ) ;
1212var clientConnected = false ;
1313
1414var host_url = "" ;
@@ -1610,7 +1610,7 @@ function mapInfoBox_handle_path(event) {
16101610 p2_dist = p [ minidx ] . distanceTo ( target ) ;
16111611
16121612 var point = ( p1_dist < p2_dist ) ? p [ minidx - 1 ] : p [ minidx ] ;
1613- var id = ( p1_dist < p2_dist ) ? vehicle . positions_ids [ minidx - 1 ] : vehicle . positions_ids [ minidx ] ;
1613+ var id = ( p1_dist < p2_dist ) ? vehicle . positions_ts [ minidx - 1 ] : vehicle . positions_ts [ minidx ] ;
16141614
16151615 mapInfoBox . setContent ( "<img style='width:60px;height:20px' src='img/hab-spinner.gif' />" ) ;
16161616 mapInfoBox . setLatLng ( point ) ;
@@ -1620,30 +1620,31 @@ function mapInfoBox_handle_path(event) {
16201620} ;
16211621
16221622function mapInfoBox_handle_path_fetch ( id , vehicle ) {
1623- var url = data_url + "?mode=single&format=json&position_id=" + id ;
1623+ var date = new Date ( parseInt ( id ) ) . toISOString ( )
1624+ var url = newdata_url + "?duration=0&serial=" + vehicle . callsign + "&datetime=" + date ;
16241625
16251626 $ . getJSON ( url , function ( data ) {
1626- if ( 'positions' in data && data . positions . position . length === 0 ) {
1627+ if ( Object . keys ( data ) . length === 0 ) {
16271628 mapInfoBox . setContent ( "not found" ) ;
16281629 mapInfoBox . openOn ( map ) ;
16291630 return ;
16301631 }
16311632
1632- data = data . positions . position [ 0 ] ;
1633+ data = data [ vehicle . callsign ] [ date ] ;
16331634
16341635 div = document . createElement ( 'div' ) ;
16351636
16361637 html = "<div style='line-height:16px;position:relative;'>" ;
1637- html += "<div>" + data . vehicle + "<span style=''>(" + data . position_id + ")</span></div>" ;
1638+ html += "<div>" + data . serial + "<span style=''>(" + date + ")</span></div>" ;
16381639 html += "<hr style='margin:5px 0px'>" ;
1639- html += "<div style='margin-bottom:5px;'><b><i class='icon-location'></i> </b>" + roundNumber ( data . gps_lat , 5 ) + ', ' + roundNumber ( data . gps_lon , 5 ) + "</div>" ;
1640+ html += "<div style='margin-bottom:5px;'><b><i class='icon-location'></i> </b>" + roundNumber ( data . lat , 5 ) + ', ' + roundNumber ( data . lon , 5 ) + "</div>" ;
16401641
16411642 var imp = offline . get ( 'opt_imperial' ) ;
1642- var text_alt = Number ( ( imp ) ? Math . floor ( 3.2808399 * parseInt ( data . gps_alt ) ) : parseInt ( data . gps_alt ) ) . toLocaleString ( "us" ) ;
1643+ var text_alt = Number ( ( imp ) ? Math . floor ( 3.2808399 * parseInt ( data . alt ) ) : parseInt ( data . alt ) ) . toLocaleString ( "us" ) ;
16431644 text_alt += " " + ( ( imp ) ? 'ft' :'m' ) ;
16441645
16451646 html += "<div><b>Altitude: </b>" + text_alt + "</div>" ;
1646- html += "<div><b>Time: </b>" + formatDate ( stringToDateUTC ( data . gps_time ) ) + "</div>" ;
1647+ html += "<div><b>Time: </b>" + formatDate ( stringToDateUTC ( date ) ) + "</div>" ;
16471648
16481649 var value = vehicle . path_length ;
16491650
@@ -1658,38 +1659,53 @@ function mapInfoBox_handle_path_fetch(id,vehicle) {
16581659 html += "</div>" ;
16591660 html += "<div><b>Duration: </b>" + format_time_friendly ( vehicle . start_time , convert_time ( vehicle . curr_position . gps_time ) ) + "</div>" ;
16601661
1661- if ( Object . keys ( ( typeof data . data === "string" ) ?JSON . parse ( data . data ) :data . data ) . length ) {
1662- html += "<hr style='margin:5px 0px'>" ;
1663- html += habitat_data ( data . data , true ) ;
1664- }
1665-
1666- if ( data . vehicle . search ( / ( c h a s e ) / i) == - 1 ) {
1667- html += "<hr style='margin:0px;margin-top:5px'>" ;
1668- html += "<div style='font-size:11px;'>"
1669- var callsign_list = [ ]
1670- for ( var rxcall in data . callsign ) {
1671- if ( data . callsign . hasOwnProperty ( rxcall ) ) {
1672- _new_call = rxcall ;
1673- if ( data . callsign [ rxcall ] . hasOwnProperty ( 'snr' ) ) {
1674- if ( data . callsign [ rxcall ] . snr ) {
1675- _new_call += " (" + data . callsign [ rxcall ] . snr . toFixed ( 0 ) + " dB)" ;
1676- callsign_list . push ( _new_call )
1677- continue ;
1678- }
1679- }
1680- if ( data . callsign [ rxcall ] . hasOwnProperty ( 'rssi' ) ) {
1681- if ( data . callsign [ rxcall ] . rssi ) {
1682- _new_call += " (" + data . callsign [ rxcall ] . snr . toFixed ( 0 ) + " dBm)" ;
1683- callsign_list . push ( _new_call )
1684- continue ;
1685- }
1686- }
1687- callsign_list . push ( _new_call ) // catch cases where there is no SNR or RSSI
1688- }
1689- }
1690- callsign_list = callsign_list . join ( "<br /> " ) ;
1691- html += callsign_list + "</div>" ;
1662+ html += "<hr style='margin:5px 0px'>" ;
1663+
1664+ if ( data . hasOwnProperty ( "batt" ) ) {
1665+ html += "<div><b>Battery Voltage: </b>" + data . batt + " V</div>" ;
1666+ } ;
1667+ if ( data . hasOwnProperty ( "frequency" ) ) {
1668+ html += "<div><b>TX Frequency: </b>" + data . frequency + " MHz</div>" ;
1669+ } ;
1670+ if ( data . hasOwnProperty ( "humidity" ) ) {
1671+ html += "<div><b>Relative Humidity: </b>" + data . humidity + " %</div>" ;
1672+ } ;
1673+ if ( data . hasOwnProperty ( "manufacturer" ) ) {
1674+ html += "<div><b>Manufacturer: </b>" + data . manufacturer + "</div>" ;
1675+ } ;
1676+ if ( data . hasOwnProperty ( "sats" ) ) {
1677+ html += "<div><b>Satellites: </b>" + data . sats + "</div>" ;
1678+ } ;
1679+ if ( data . hasOwnProperty ( "temp" ) ) {
1680+ html += "<div><b>Temperature External: </b>" + data . temp + "°C</div>" ;
1681+ } ;
1682+ if ( data . hasOwnProperty ( "subtype" ) ) {
1683+ html += "<div><b>Sonde Type: </b>" + data . subtype + "</div>" ;
1684+ } else if ( data . hasOwnProperty ( "type" ) ) {
1685+ html += "<div><b>Sonde Type: </b>" + data . type + "</div>" ;
1686+ } ;
1687+ if ( data . hasOwnProperty ( "pressure" ) ) {
1688+ html += "<div><b>Pressure: </b>" + data . pressure + " Pa</div>" ;
1689+ } ;
1690+ if ( data . hasOwnProperty ( "xdata" ) ) {
1691+ html += "<div><b>XDATA: </b>" + data . xdata + "</div>" ;
1692+ } ;
1693+
1694+ html += "<hr style='margin:0px;margin-top:5px'>" ;
1695+ html += "<div style='font-size:11px;'>"
1696+ var callsign_list = [ ] ;
1697+ _new_call = vehicle . callsign ;
1698+ if ( data . hasOwnProperty ( 'snr' ) ) {
1699+ _new_call += " (" + data . snr . toFixed ( 0 ) + " dB)" ;
1700+ callsign_list . push ( _new_call )
1701+ } else if ( data . hasOwnProperty ( 'rssi' ) ) {
1702+ _new_call += " (" + data . snr . toFixed ( 0 ) + " dBm)" ;
1703+ callsign_list . push ( _new_call )
1704+ } else {
1705+ callsign_list . push ( _new_call )
16921706 }
1707+ callsign_list = callsign_list . join ( "<br /> " ) ;
1708+ html += callsign_list + "</div>" ;
16931709
16941710 div . innerHTML = html ;
16951711
@@ -2393,31 +2409,14 @@ function updateGraph(vcallsign, reset_selection) {
23932409
23942410 var series = vehicles [ vcallsign ] . graph_data ;
23952411
2396- // if we are drawing the plot for the fisrt time
2397- // and the dataset is too large, we set an initial selection of the last 7 days
2398- if ( ! plot_options . hasOwnProperty ( 'xaxis' ) ) {
2399- if ( series . length && series [ 0 ] . data . length > 4001 ) {
2400- var last = series [ 0 ] . data . length - 1 ;
2401- var end_a = series [ 0 ] . data [ last ] [ 0 ] ;
2402- var end_b = ( series [ 1 ] . data . length ) ? series [ 1 ] . data [ series [ 1 ] . data . length - 1 ] [ 0 ] : 0 ;
2403-
2404- plot_options . xaxis = {
2405- superzoom : 1 ,
2406- min : series [ 0 ] . data [ last - 4000 ] [ 0 ] ,
2407- max : Math . max ( end_a , end_b ) ,
2408- } ;
2409-
2410- }
2411- }
2412-
24132412 // replot graph, with this vehicle data, and this vehicles yaxes config
24142413 plot = $ . plot ( plot_holder , series , $ . extend ( plot_options , { yaxes :vehicles [ vcallsign ] . graph_yaxes } ) ) ;
24152414 graph_vehicle = follow_vehicle ;
24162415
24172416 vehicles [ vcallsign ] . graph_data_updated = false ;
24182417}
24192418
2420- var graph_gap_size_default = 180000 ; // 3 mins in milis
2419+ var graph_gap_size_default = 18000000 ; // 3 mins in milis
24212420var graph_gap_size_max = 31536000000 ;
24222421var graph_gap_size = offline . get ( 'opt_interpolate' ) ? graph_gap_size_max : graph_gap_size_default ;
24232422var graph_pad_size = 120000 ; // 2 min
@@ -2455,7 +2454,6 @@ function graphAddPosition(vcallsign, new_data) {
24552454 }
24562455 splice_idx = i + 1 ;
24572456
2458-
24592457 if ( i > - 1 ) {
24602458 // this is if new datum hits padded area
24612459 if ( ( xref [ i ] [ 1 ] === null && xref [ i ] [ 0 ] - 1 + ( graph_gap_size - graph_pad_size ) >= ts ) ) {
@@ -2671,7 +2669,7 @@ function formatData(data, live) {
26712669 dataTempEntry . data . burst_timer = data . burst_timer ;
26722670 }
26732671 if ( data . frequency ) {
2674- dataTempEntry . data . burst_timer = data . frequency ;
2672+ dataTempEntry . data . frequency = data . frequency ;
26752673 }
26762674 if ( data . humidity ) {
26772675 dataTempEntry . data . humidity = data . humidity ;
@@ -2735,7 +2733,7 @@ function formatData(data, live) {
27352733 dataTempEntry . data . burst_timer = data [ key ] [ i ] . burst_timer ;
27362734 }
27372735 if ( data [ key ] [ i ] . frequency ) {
2738- dataTempEntry . data . burst_timer = data [ key ] [ i ] . frequency ;
2736+ dataTempEntry . data . frequency = data [ key ] [ i ] . frequency ;
27392737 }
27402738 if ( data [ key ] [ i ] . humidity ) {
27412739 dataTempEntry . data . humidity = data [ key ] [ i ] . humidity ;
@@ -2819,7 +2817,7 @@ function formatData(data, live) {
28192817 dataTempEntry . data . burst_timer = data [ i ] . burst_timer ;
28202818 }
28212819 if ( data [ i ] . frequency ) {
2822- dataTempEntry . data . burst_timer = data [ i ] . frequency ;
2820+ dataTempEntry . data . frequency = data [ i ] . frequency ;
28232821 }
28242822 if ( data [ i ] . humidity ) {
28252823 dataTempEntry . data . humidity = data [ i ] . humidity ;
@@ -2938,7 +2936,6 @@ function liveData() {
29382936 function onConnectionLost ( responseObject ) {
29392937 if ( responseObject . errorCode !== 0 ) {
29402938 clientConnected = false ;
2941- console . log ( "yes" ) ;
29422939 refresh ( ) ;
29432940 }
29442941 } ;
@@ -3254,7 +3251,7 @@ function updateChase(r) {
32543251 last = r [ i ] [ s ]
32553252 if ( last . mobile == true ) {
32563253 var dataTempEntry = { } ;
3257- dataTempEntry . callsign = last . software_name ;
3254+ dataTempEntry . callsign = last . software_name + "-" + last . software_version ;
32583255 dataTempEntry . gps_alt = last . uploader_position [ 2 ] ;
32593256 dataTempEntry . gps_lat = last . uploader_position [ 0 ] ;
32603257 dataTempEntry . gps_lon = last . uploader_position [ 1 ] ;
0 commit comments