TomMuc
October 13, 2017, 7:03pm
1
sorry - but i don’t find the the place where this is done. is this the delta between last and actual ‘messages’ divided through delta from last and actual ‘now’ in aircraft.json or stacked data over some seconds?
was looking in public_html/script.js but did not find the code?
obj
October 13, 2017, 7:23pm
2
tl;dr: it is measured over a 30 second sliding window
// 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;
var squawk = ac.squawk;
var plane = null;
1 Like
TomMuc
October 13, 2017, 7:32pm
3
obj:
tl;dr:
haha - no - not too long didn’t read - more td;tf ‘too dumb to find’
thanx!
TomMuc
October 16, 2017, 3:17pm
4
btw. was not just td;tf: but moreover to dumb to write short code - my solution was:
$message_rate_array[$ac_messages_total] = $ac_now;
foreach ($message_rate_array as $key => $value) {
if (time() - $value > 30) {
unset($message_rate_array[$key]);
}
}
$delta_message_number = max(array_keys($message_rate_array)) - min(array_keys($message_rate_array));
$delta_message_time = max($message_rate_array) - min($message_rate_array);
$delta_message_time > 0 ? $message_rate = $delta_message_number / $delta_message_time : $message_rate = 0;
but then saw your coding - and stole it
$message_rate_array[] = array('messages' => $ac_messages_total, 'time' => $ac_now);
if (time() - $message_rate_array[0]['time'] > 30) array_shift($message_rate_array);
$delta_message_number = $message_rate_array[count($message_rate_array) - 1]['messages'] - $message_rate_array[0]['messages'];
$delta_message_time = $message_rate_array[count($message_rate_array) - 1]['time'] - $message_rate_array[0]['time'];
$delta_message_time > 0 ? $message_rate = round($delta_message_number / $delta_message_time, '1') : $message_rate = 0;