diff --git a/module_templates/stdio/recv_adsb/recv_adsb.c b/module_templates/stdio/recv_adsb/recv_adsb.c index 6beaa02b3aa8a7ed5efda687ff5184ec10858996..57afb9084e7cb1f2d17ed6e8d02e03a8b4f7f459 100644 --- a/module_templates/stdio/recv_adsb/recv_adsb.c +++ b/module_templates/stdio/recv_adsb/recv_adsb.c @@ -1319,14 +1319,13 @@ good_preamble: /* Show the currently captured interactive data on screen. */ void interactiveShowData(void) { struct aircraft *a = Modes.aircrafts; + struct aircraft * before_a=0,*after_a = 0; time_t now = time(NULL); int count = 0; - //printf("\x1b[H\x1b[2J"); /* Clear the screen */ -/* printf( -"Hex Flight Altitude Speed Lat Lon Track Messages Seen %s\n" -"--------------------------------------------------------------------------------\n", - progress); -*/ + static time_t lastClearTime = 0; + static const int timeKeep=60; + if (lastClearTime==0) + lastClearTime = time(0); while(a ) { if (a->need_display) { @@ -1339,13 +1338,12 @@ void interactiveShowData(void) { speed *= 1.852; } fprintf(stdout,"source=adsb;destin=geomarker;function=update_icon;icon=flight;name=%s;lat=%f;lon=%f;rotate=%d;smooth=1;scale=%f\n", - a->hexaddr, a->lat, a->lon, a->track, (altitude/30000.0+1), - (int)(now - a->seen)); + a->hexaddr, a->lat, a->lon, a->track, (altitude/30000.0+1)); fprintf(stdout,"source=adsb;destin=geomarker;function=update_props;name=%s;LABEL=%s;Alt=%d;Speed=%d;lat=%f;lon=%f;track=%d;msgs=%ld;time=%d;\n", a->hexaddr, a->flight, altitude, speed, a->lat, a->lon, a->track, a->messages, - (int)(now - a->seen)); + (int)(now)); fflush(stdout); fprintf(stderr,"%-6s %-8s %-9d %-7d %-7.03f %-7.03f %-3d %-9ld %d sec\n", a->hexaddr, a->flight, altitude, speed, @@ -1356,6 +1354,32 @@ void interactiveShowData(void) { a = a->next; count++; } + if (lastClearTime + timeKeep < now) + { + lastClearTime = now; + a = Modes.aircrafts; + before_a = 0; + while (a) + { + after_a = a->next; + if (a->seen + timeKeep < now) + { + printf ("source=adsb;destin=geomarker;function=delete_marks;name0=%s;\n",a->hexaddr); + //delete node + if (before_a) + before_a->next = after_a; + else + Modes.aircrafts = after_a; + free(a); + a = after_a; + } + if (a) + { + before_a = a; + a = a->next; + } + } + } } /* When a new message is available, because it was decoded from the * RTL device, file, or received in the TCP input port, or any other @@ -1571,7 +1595,6 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) { aux = Modes.aircrafts; while(aux->next != a) aux = aux->next; /* Now we are a node before the aircraft to remove. */ - printf("function=delete_marks;name0=%s;\n",a->hexaddr); aux->next = aux->next->next; /* removed. */ /* Add on head */ a->next = Modes.aircrafts; diff --git a/module_templates/stdio/recv_adsb/recv_adsb.exe b/module_templates/stdio/recv_adsb/recv_adsb.exe index a4b97abbdec97dce0f5257d4ed6753537fb9c372..47e663aa848af5264288507b40afe0a4307dbf16 100644 Binary files a/module_templates/stdio/recv_adsb/recv_adsb.exe and b/module_templates/stdio/recv_adsb/recv_adsb.exe differ