Display message rate (30 sec average) on the webmap.

(cherry picked from commit 848af78be685c6e2a26d0b30e9f385696201a2c4)
This commit is contained in:
Oliver Jowett 2015-01-13 19:10:55 +00:00
parent 41d8a79041
commit 72bfc31458
6 changed files with 41 additions and 4 deletions

View file

@ -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;
}

View file

@ -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.

View file

@ -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);

View file

@ -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

View file

@ -74,7 +74,7 @@
<tr class="infoblock_body">
<td>Aircraft (total): <span id="dump1090_total_ac">n/a</span></td>
<td>&nbsp;</td>
<td>Messages: <span id="dump1090_message_rate">n/a</span>/sec</td>
</tr>
<tr class="infoblock_body">

View file

@ -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;
}