Add --throttle option.

This gives access to the existing throttling behaviour when reading
from a file with --interactive, without needing to actually have
--interactive.

This is useful when testing, as without --throttle samples will be
processsed much faster than real-time, which can produce different
results with e.g. aircraft/filter expiry times and position/speed checks.
This commit is contained in:
Oliver Jowett 2015-06-18 11:24:01 +01:00
parent 21bdc45bf0
commit e7e9cecc1a
2 changed files with 7 additions and 3 deletions

View file

@ -558,7 +558,7 @@ void readDataFromFile(void) {
// Convert the new data
convert_samples(readbuf, &outbuf->data[Modes.trailing_samples], slen, &outbuf->total_power);
if (Modes.interactive) {
if (Modes.throttle) {
// Wait until we are allowed to release this buffer to the main thread
while (clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &next_buffer_delivery, NULL) == EINTR)
;
@ -670,7 +670,8 @@ void showHelp(void) {
"--freq <hz> Set frequency (default: 1090 Mhz)\n"
"--ifile <filename> Read data from file (use '-' for stdin)\n"
"--iformat <format> Sample format for --ifile: UC8 (default), SC16, or SC16Q11\n"
"--interactive Interactive mode refreshing data on screen\n"
"--throttle When reading from a file, play back in realtime, not at max speed\n"
"--interactive Interactive mode refreshing data on screen. Implies --throttle\n"
"--interactive-rows <num> Max number of rows in interactive mode (default: 15)\n"
"--interactive-ttl <sec> Remove from list if idle for <sec> (default: 60)\n"
"--interactive-rtl1090 Display flight table in RTL1090 format\n"
@ -997,7 +998,9 @@ int main(int argc, char **argv) {
} else if (!strcmp(argv[j],"--aggressive")) {
Modes.nfix_crc = MODES_MAX_BITERRORS;
} else if (!strcmp(argv[j],"--interactive")) {
Modes.interactive = 1;
Modes.interactive = Modes.throttle = 1;
} else if (!strcmp(argv[j],"--throttle")) {
Modes.throttle = 1;
} else if (!strcmp(argv[j],"--interactive-rows") && more) {
Modes.interactive_rows = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--interactive-ttl") && more) {

View file

@ -339,6 +339,7 @@ struct { // Internal state
char *json_dir; // Path to json base directory, or NULL not to write json.
uint64_t json_interval; // Interval between rewriting the json aircraft file, in milliseconds; also the advertised map refresh interval
int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact
int throttle; // When reading from a file, throttle file playback to realtime?
int json_aircraft_history_next;
struct {