-
Notifications
You must be signed in to change notification settings - Fork 1
/
stats.c
51 lines (41 loc) · 1.09 KB
/
stats.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* stats.c -- ADS-B Radio statistics gathering and sending
* Author: Michael J. Tubby B.Sc. MIET [email protected]
*
* ABSTRACT
*
* Deal with sending ADS-B radio stats periodically to the aggregator.
*
* These stats are primiarily about what we have observed on the radio
* channel in terms of messages and counts
*
*/
#include <string.h>
#include <time.h>
#include "radar.h"
static int interval;
static int countdown;
void stats_init(int ival)
{
if (ival) {
time_t ts = time(NULL);
memset(&stats, 0, sizeof(stats_t));
stats.start = (uint32_t)ts;
interval = ival;
countdown = ival / 2;
} else {
countdown = 0;
}
}
void stats_second(void)
{
if (countdown) {
--countdown;
if (!countdown) {
time_t ts = time(NULL);
stats.now = (uint32_t)ts;
radar_send_stats();
countdown = interval;
}
}
}