diff --git a/dump1090.c b/dump1090.c index 8d7c8ca..1d22a5d 100644 --- a/dump1090.c +++ b/dump1090.c @@ -604,8 +604,8 @@ static void display_stats(void) { } printf("%d total usable messages\n", - Modes.stat_demod.goodcrc + Modes.stat_demod_phasecorrected.goodcrc + - Modes.stat_demod.fixed + Modes.stat_demod_phasecorrected.fixed); + Modes.stat_messages_total); + fflush(stdout); Modes.stat_cputime.tv_sec = 0; @@ -622,6 +622,8 @@ static void display_stats(void) { Modes.stat_DF_Type_Corrected = Modes.stat_out_of_phase = 0; + Modes.stat_messages_total = 0; + for (j = 0; j < MODES_MAX_PHASE_STATS; j++) { Modes.stat_preamble_phase[j] = 0; } diff --git a/dump1090.h b/dump1090.h index 00978fd..49c096a 100644 --- a/dump1090.h +++ b/dump1090.h @@ -394,6 +394,9 @@ struct { // Internal state unsigned int stat_blocks_dropped; struct timespec stat_cputime; + + // total messages: + unsigned int stat_messages_total; } Modes; // The struct we use to store information about a decoded message. diff --git a/mode_s.c b/mode_s.c index 40e4111..ea5a086 100644 --- a/mode_s.c +++ b/mode_s.c @@ -2381,6 +2381,8 @@ void detectModeS_oversample(uint16_t *m, uint32_t mlen) { // void useModesMessage(struct modesMessage *mm) { if ((Modes.check_crc == 0) || (mm->crcok) || (mm->correctedbits)) { // not checking, ok or fixed + ++Modes.stat_messages_total; + // If we are decoding, track aircraft interactiveReceiveData(mm); diff --git a/net_io.c b/net_io.c index 2918fba..4520edf 100644 --- a/net_io.c +++ b/net_io.c @@ -676,8 +676,9 @@ char *generateAircraftJson(int *len) { p += snprintf(p, end-p, "{ \"now\" : %d,\n" + " \"messages\" : %u,\n" " \"aircraft\" : [", - (int)now); + (int)now, Modes.stat_messages_total); while(a) { if (a->modeACflags & MODEAC_MSG_FLAG) { // skip any fudged ICAO records Mode A/C diff --git a/public_html/gmap.html b/public_html/gmap.html index 68a582f..b9fff8d 100644 --- a/public_html/gmap.html +++ b/public_html/gmap.html @@ -74,7 +74,7 @@ Aircraft (total): n/a -   + Messages: n/a/sec diff --git a/public_html/script.js b/public_html/script.js index 9a3c561..4e19b89 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -36,6 +36,8 @@ var LastReceiverTimestamp = null; var StaleReceiverCount = 0; var FetchPending = null; +var MessageCountHistory = []; + var NBSP='\u00a0'; var DEGREES='\u00b0' @@ -53,6 +55,19 @@ function fetchData() { // Loop through all the planes in the data packet var now = data.now; var acs = data.aircraft; + + // Detect stats reset + if (MessageCountHistory.length > 0 && MessageCountHistory[MessageCountHistory.length-1].messages > data.messages) { + MessageCountHistory = [{'time' : MessageCountHistory[MessageCountHistory.length-1].time, + 'messages' : 0}]; + } + + // Note the message count in the history + MessageCountHistory.push({ 'time' : now, 'messages' : data.messages}); + // .. and clean up any old values + if ((now - MessageCountHistory[0].time) > 30) + MessageCountHistory.shift(); + for (var j=0; j < acs.length; j++) { var ac = acs[j]; var hex = ac.hex; @@ -460,6 +475,20 @@ function refreshSelected() { $('#dump1090_total_ac').text(TrackedAircraft); $('#dump1090_total_ac_positions').text(TrackedAircraftPositions); $('#dump1090_total_history').text(TrackedHistorySize); + + var message_rate = null; + if (MessageCountHistory.length > 1) { + var message_time_delta = MessageCountHistory[MessageCountHistory.length-1].time - MessageCountHistory[0].time; + var message_count_delta = MessageCountHistory[MessageCountHistory.length-1].messages - MessageCountHistory[0].messages; + if (message_time_delta > 0) + message_rate = message_count_delta / message_time_delta; + } + + if (message_rate !== null) + $('#dump1090_message_rate').text(message_rate.toFixed(1)); + else + $('#dump1090_message_rate').text("n/a"); + return; }