| 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 |
#include "dump1090.h" |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
static int convert_altitude(int ft) |
| 57 |
{ |
| 58 |
if (Modes.metric) |
| 59 |
return (ft * 0.3048); |
| 60 |
else |
| 61 |
return ft; |
| 62 |
} |
| 63 |
|
| 64 |
static int convert_speed(int kts) |
| 65 |
{ |
| 66 |
if (Modes.metric) |
| 67 |
return (kts * 1.852); |
| 68 |
else |
| 69 |
return kts; |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
void interactiveShowData(void) { |
| 78 |
struct aircraft *a = Modes.aircrafts; |
| 79 |
static uint64_t next_update; |
| 80 |
uint64_t now = mstime(); |
| 81 |
int count = 0; |
| 82 |
char progress; |
| •83 |
char spinner[] = "|/-\\"; |
| 84 |
|
| 85 |
|
| 86 |
if (now < next_update) |
| 87 |
return; |
| 88 |
|
| 89 |
next_update = now + MODES_INTERACTIVE_REFRESH_TIME; |
| 90 |
|
| 91 |
progress = spinner[(now/1000)%4]; |
| 92 |
|
| 93 |
#ifndef _WIN32 |
| 94 |
printf("\x1b[H\x1b[2J"); |
| 95 |
#else |
| 96 |
cls(); |
| 97 |
#endif |
| 98 |
|
| 99 |
if (Modes.interactive_rtl1090 == 0) { |
| 100 |
printf ( |
| 101 |
" Hex Mode Sqwk Flight Alt Spd Hdg Lat Long RSSI Msgs Ti%c\n", progress); |
| 102 |
} else { |
| 103 |
printf ( |
| 104 |
" Hex Flight Alt V/S GS TT SSR G*456^ Msgs Seen %c\n", progress); |
| 105 |
} |
| 106 |
printf( |
| 107 |
"-------------------------------------------------------------------------------\n"); |
| 108 |
|
| 109 |
while(a && (count < Modes.interactive_rows)) { |
| 110 |
|
| 111 |
if ((now - a->seen) < Modes.interactive_display_ttl) |
| 112 |
{ |
| 113 |
int msgs = a->messages; |
| 114 |
int flags = a->modeACflags; |
| 115 |
|
| 116 |
if ( (((flags & (MODEAC_MSG_FLAG )) == 0 ) && (msgs > 1 ) ) |
| 117 |
|| (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEA_ONLY)) == MODEAC_MSG_MODEA_ONLY) && (msgs > 4 ) ) |
| 118 |
|| (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEC_OLD )) == 0 ) && (msgs > 127) ) |
| 119 |
) { |
| 120 |
char strSquawk[5] = " "; |
| •121 |
char strFl[12] = " "; |
| 122 |
char strTt[5] = " "; |
| 123 |
char strGs[5] = " "; |
| 124 |
|
| 125 |
if (trackDataValid(&a->squawk_valid)) { |
| 126 |
snprintf(strSquawk,5,"%04x", a->squawk); |
| 127 |
} |
| 128 |
|
| 129 |
if (trackDataValid(&a->speed_valid)) { |
| 130 |
snprintf (strGs, 5,"%3d", convert_speed(a->speed)); |
| 131 |
} |
| 132 |
|
| 133 |
if (trackDataValid(&a->heading_valid)) { |
| 134 |
snprintf (strTt, 5,"%03d", a->heading); |
| 135 |
} |
| 136 |
|
| 137 |
if (msgs > 99999) { |
| 138 |
msgs = 99999; |
| 139 |
} |
| 140 |
|
| 141 |
if (Modes.interactive_rtl1090) { |
| 142 |
if (trackDataValid(&a->altitude_valid)) { |
| •143 |
snprintf(strFl,11,"F%03d",((a->altitude+50)/100)); |
| 144 |
} |
| 145 |
printf("%06x %-8s %-4s %-3s %-3s %4s %-6d %-2.0f\n", |
| 146 |
a->addr, a->callsign, strFl, strGs, strTt, strSquawk, msgs, (now - a->seen)/1000.0); |
| 147 |
|
| 148 |
} else { |
| 149 |
char strMode[5] = " "; |
| 150 |
char strLat[8] = " "; |
| 151 |
char strLon[9] = " "; |
| 152 |
double * pSig = a->signalLevel; |
| 153 |
double signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] + |
| 154 |
pSig[4] + pSig[5] + pSig[6] + pSig[7]) / 8.0; |
| 155 |
|
| 156 |
if ((flags & MODEAC_MSG_FLAG) == 0) { |
| 157 |
strMode[0] = 'S'; |
| 158 |
} else if (flags & MODEAC_MSG_MODEA_ONLY) { |
| 159 |
strMode[0] = 'A'; |
| 160 |
} |
| 161 |
if (flags & MODEAC_MSG_MODEA_HIT) {strMode[2] = 'a';} |
| 162 |
if (flags & MODEAC_MSG_MODEC_HIT) {strMode[3] = 'c';} |
| 163 |
|
| 164 |
if (trackDataValid(&a->position_valid)) { |
| 165 |
snprintf(strLat, 8,"%7.03f", a->lat); |
| 166 |
snprintf(strLon, 9,"%8.03f", a->lon); |
| 167 |
} |
| 168 |
|
| 169 |
if (trackDataValid(&a->airground_valid) && a->airground == AG_GROUND) { |
| 170 |
snprintf(strFl, 7," grnd"); |
| 171 |
} else if (Modes.use_gnss && trackDataValid(&a->altitude_gnss_valid)) { |
| 172 |
snprintf(strFl, 7, "%5dH", convert_altitude(a->altitude_gnss)); |
| 173 |
} else if (trackDataValid(&a->altitude_valid)) { |
| 174 |
snprintf(strFl, 7, "%5d ", convert_altitude(a->altitude)); |
| 175 |
} |
| 176 |
|
| 177 |
printf("%s%06X %-4s %-4s %-8s %6s %3s %3s %7s %8s %5.1f %5d %2.0f\n", |
| 178 |
(a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : " ", (a->addr & 0xffffff), |
| 179 |
strMode, strSquawk, a->callsign, strFl, strGs, strTt, |
| 180 |
strLat, strLon, 10 * log10(signalAverage), msgs, (now - a->seen)/1000.0); |
| 181 |
} |
| 182 |
count++; |
| 183 |
} |
| 184 |
} |
| 185 |
a = a->next; |
| 186 |
} |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|