X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=ao-tools%2Fao-postflight%2Fao-postflight.c;h=e5b556652b934be857a24f6da7d7b72999f72f1f;hb=4a9ded5b39ed08e13abc2cddba8b712f62b983f2;hp=cc9f64b484f92d6ea8ae3b7a9c2299001d1a9a09;hpb=ac4b8a73848f434999a532eab4665253c267c597;p=fw%2Faltos
diff --git a/ao-tools/ao-postflight/ao-postflight.c b/ao-tools/ao-postflight/ao-postflight.c
index cc9f64b4..e5b55665 100644
--- a/ao-tools/ao-postflight/ao-postflight.c
+++ b/ao-tools/ao-postflight/ao-postflight.c
@@ -39,6 +39,19 @@ static const char *state_names[] = {
"invalid"
};
+static const char *kml_state_colours[] = {
+ "FF000000",
+ "FF000000",
+ "FF000000",
+ "FF0000FF",
+ "FF4080FF",
+ "FF00FFFF",
+ "FFFF0000",
+ "FF00FF00",
+ "FF000000",
+ "FFFFFFFF"
+};
+
static int plot_colors[3][3] = {
{ 0, 0x90, 0 }, /* height */
{ 0xa0, 0, 0 }, /* speed */
@@ -161,8 +174,122 @@ merge_data(struct cc_perioddata *first, struct cc_perioddata *last, double split
return pd;
}
+static const char kml_header_start[] =
+ "\n"
+ "\n"
+ "\n"
+ " %s\n"
+ " \n";
+static const char kml_header_end[] =
+ " \n"
+ " 0\n";
+
+static const char kml_style_start[] =
+ " \n";
+
+static const char kml_placemark_start[] =
+ " \n"
+ " %s\n"
+ " #ao-flightstate-%s\n"
+ " \n"
+ " 1\n"
+ " absolute\n"
+ " \n";
+
+static const char kml_coord_fmt[] =
+ " %12.7f, %12.7f, %12.7f \n";
+
+static const char kml_placemark_end[] =
+ " \n"
+ " \n"
+ " \n";
+
+static const char kml_footer[] =
+ " \n"
+ " \n"
+ " \n"
+ "\n"
+ "\n";
+
+static unsigned
+gps_daytime(struct cc_gpselt *gps)
+{
+ return ((gps->hour * 60 +
+ gps->minute) * 60 +
+ gps->second) * 1000;
+}
+
+int
+daytime_hour(unsigned daytime)
+{
+ return daytime / 1000 / 60 / 60;
+}
+
+int
+daytime_minute(unsigned daytime)
+{
+ return (daytime / 1000 / 60) % 60;
+}
+
+int
+daytime_second(unsigned daytime)
+{
+ return (daytime / 1000) % 60;
+}
+
+int
+daytime_millisecond(unsigned daytime)
+{
+ return daytime % 1000;
+}
+
+static unsigned
+compute_daytime_ms(double time, struct cc_gpsdata *gps)
+{
+ int i;
+ unsigned gps_start_daytime, gps_stop_daytime;
+
+ if (time <= gps->data[0].time) {
+ gps_stop_daytime = gps_daytime(&gps->data[0]);
+ return gps_stop_daytime - (gps->data[0].time - time) * 10;
+ }
+ for (i = 0; i < gps->num - 1; i++)
+ if (time > gps->data[i].time)
+ break;
+ gps_start_daytime = gps_daytime(&gps->data[i]);
+ if (i == gps->num - 1) {
+ return gps_start_daytime + (time - gps->data[i].time) * 10;
+ } else {
+ unsigned gps_period_daytime;
+ double gps_period_time;
+ double time_since_start;
+
+ gps_stop_daytime = gps_daytime(&gps->data[i + 1]);
+
+ /* range of gps daytime values */
+ gps_period_daytime = gps_stop_daytime - gps_start_daytime;
+
+ /* range of gps time values */
+ gps_period_time = gps->data[i+1].time - gps->data[i].time;
+
+ /* sample time after first gps time */
+ time_since_start = time - gps->data[i].time;
+
+ return gps_start_daytime +
+ gps_period_daytime * time_since_start / gps_period_time;
+ }
+}
+
static void
-analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FILE *raw_file, char *plot_name, FILE *gps_file)
+analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file,
+ FILE *raw_file, char *plot_name, FILE *gps_file, FILE *kml_file)
{
double height;
double accel;
@@ -178,9 +305,34 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
double state_start, state_stop;
struct cc_flightcooked *cooked;
double apogee;
+ char buf[128];
- fprintf(summary_file, "Flight: %9d\nSerial: %9d\n",
- f->flight, f->serial);
+ if (kml_file) {
+ snprintf(buf, sizeof (buf), "AO Flight#%d S/N: %03d", f->flight, f->serial);
+ fprintf(kml_file, kml_header_start, buf);
+ }
+
+ fprintf(summary_file,
+ "Serial: %9d\n"
+ "Flight: %9d\n",
+ f->serial, f->flight);
+
+ if (f->year) {
+ snprintf(buf, sizeof (buf),
+ "Date: %04d-%02d-%02d\n",
+ f->year, f->month, f->day);
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
+ }
+ if (f->gps.num) {
+ snprintf(buf, sizeof (buf),
+ "Time: %2d:%02d:%02d\n",
+ f->gps.data[0].hour,
+ f->gps.data[0].minute,
+ f->gps.data[0].second);
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
+ }
boost_start = f->accel.data[0].time;
boost_stop = f->accel.data[f->accel.num-1].time;
for (i = 0; i < f->state.num; i++) {
@@ -201,10 +353,12 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
min_pres = f->pres.data[pres_i].value;
height = cc_barometer_to_altitude(min_pres) -
cc_barometer_to_altitude(f->ground_pres);
- fprintf(summary_file, "Max height: %9.2fm %9.2fft %9.2fs\n",
+ apogee = f->pres.data[pres_i].time;
+ snprintf(buf, sizeof (buf), "Max height: %9.2fm %9.2fft %9.2fs\n",
height, height * 100 / 2.54 / 12,
(f->pres.data[pres_i].time - boost_start) / 100.0);
- apogee = f->pres.data[pres_i].time;
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
}
cooked = cc_flight_cook(f);
@@ -212,9 +366,11 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
speed_i = cc_perioddata_max(&cooked->accel_speed, boost_start, boost_stop);
if (speed_i >= 0) {
speed = cooked->accel_speed.data[speed_i];
- fprintf(summary_file, "Max speed: %9.2fm/s %9.2fft/s %9.2fs\n",
+ snprintf(buf, sizeof (buf), "Max speed: %9.2fm/s %9.2fft/s %9.2fs\n",
speed, speed * 100 / 2.4 / 12.0,
(cooked->accel_speed.start + speed_i * cooked->accel_speed.step - boost_start) / 100.0);
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
}
}
accel_i = cc_timedata_min(&f->accel, boost_start, boost_stop);
@@ -222,11 +378,16 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
{
accel = cc_accelerometer_to_acceleration(f->accel.data[accel_i].value,
f->ground_accel);
- fprintf(summary_file, "Max accel: %9.2fm/s² %9.2fg %9.2fs\n",
+ snprintf(buf, sizeof (buf), "Max accel: %9.2fm/s² %9.2fg %9.2fs\n",
accel, accel / 9.80665,
(f->accel.data[accel_i].time - boost_start) / 100.0);
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
}
+ if (kml_file)
+ fprintf(kml_file, "%s", kml_header_end);
+
for (i = 0; i < f->state.num; i++) {
state = f->state.data[i].value;
state_start = f->state.data[i].time;
@@ -239,14 +400,23 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
fprintf(summary_file, "State: %s\n", state_names[state]);
fprintf(summary_file, "\tStart: %9.2fs\n", (state_start - boost_start) / 100.0);
fprintf(summary_file, "\tDuration: %9.2fs\n", (state_stop - state_start) / 100.0);
+ if (kml_file) {
+ fprintf(kml_file, kml_style_start, state_names[state], kml_state_colours[state]);
+ fprintf(kml_file, "\tState: %s\n", state_names[state]);
+ fprintf(kml_file, "\tStart: %9.2fs\n", (state_start - boost_start) / 100.0);
+ fprintf(kml_file, "\tDuration: %9.2fs\n", (state_stop - state_start) / 100.0);
+ }
+
accel_i = cc_timedata_min(&f->accel, state_start, state_stop);
if (accel_i >= 0)
{
accel = cc_accelerometer_to_acceleration(f->accel.data[accel_i].value,
f->ground_accel);
- fprintf(summary_file, "\tMax accel: %9.2fm/s² %9.2fg %9.2fs\n",
+ snprintf(buf, sizeof (buf), "\tMax accel: %9.2fm/s² %9.2fg %9.2fs\n",
accel, accel / 9.80665,
(f->accel.data[accel_i].time - boost_start) / 100.0);
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
}
if (cooked) {
@@ -263,11 +433,16 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
}
if (speed_i >= 0)
{
- fprintf(summary_file, "\tMax speed: %9.2fm/s %9.2fft/s %9.2fs\n",
+ snprintf(buf, sizeof (buf), "\tMax speed: %9.2fm/s %9.2fft/s %9.2fs\n",
speed, speed * 100 / 2.4 / 12.0,
(cooked->accel_speed.start + speed_i * cooked->accel_speed.step - boost_start) / 100.0);
- fprintf(summary_file, "\tAvg speed: %9.2fm/s %9.2fft/s\n",
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
+
+ snprintf(buf, sizeof (buf), "\tAvg speed: %9.2fm/s %9.2fft/s\n",
avg_speed, avg_speed * 100 / 2.4 / 12.0);
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
}
}
pres_i = cc_timedata_min(&f->pres, state_start, state_stop);
@@ -276,46 +451,84 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
min_pres = f->pres.data[pres_i].value;
height = cc_barometer_to_altitude(min_pres) -
cc_barometer_to_altitude(f->ground_pres);
- fprintf(summary_file, "\tMax height: %9.2fm %9.2fft %9.2fs\n",
+ snprintf(buf, sizeof (buf), "\tMax height: %9.2fm %9.2fft %9.2fs\n",
height, height * 100 / 2.54 / 12,
(f->pres.data[pres_i].time - boost_start) / 100.0);
+ fprintf(summary_file, "%s", buf);
+ if (kml_file) fprintf(kml_file, "%s", buf);
}
+ if (kml_file) fprintf(kml_file, "%s", kml_style_end);
}
if (cooked && detail_file) {
double max_height = 0;
int i;
double *times;
- fprintf(detail_file, "%9s %9s %9s %9s\n",
- "time", "height", "speed", "accel");
+ fprintf(detail_file, "%9s %9s %9s %9s %9s\n",
+ "time", "height", "speed", "accel", "daytime");
for (i = 0; i < cooked->pres_pos.num; i++) {
- double time = (cooked->accel_accel.start + i * cooked->accel_accel.step - boost_start) / 100.0;
+ double clock_time = cooked->accel_accel.start + i * cooked->accel_accel.step;
+ double time = (clock_time - boost_start) / 100.0;
double accel = cooked->accel_accel.data[i];
double pos = cooked->pres_pos.data[i];
double speed;
+ unsigned daytime;
if (cooked->pres_pos.start + cooked->pres_pos.step * i < apogee)
speed = cooked->accel_speed.data[i];
else
speed = cooked->pres_speed.data[i];
- fprintf(detail_file, "%9.2f %9.2f %9.2f %9.2f\n",
- time, pos, speed, accel);
+ if (f->gps.num)
+ daytime = compute_daytime_ms(clock_time, &f->gps);
+ else
+ daytime = 0;
+ fprintf(detail_file, "%9.2f %9.2f %9.2f %9.2f %02d:%02d:%02d.%03d\n",
+ time, pos, speed, accel,
+ daytime_hour(daytime),
+ daytime_minute(daytime),
+ daytime_second(daytime),
+ daytime_millisecond(daytime));
}
}
if (raw_file) {
- fprintf(raw_file, "%9s %9s %9s\n",
- "time", "height", "accel");
+ fprintf(raw_file, "%9s %9s %9s %9s\n",
+ "time", "height", "accel", "daytime");
for (i = 0; i < cooked->pres.num; i++) {
double time = cooked->pres.data[i].time;
double pres = cooked->pres.data[i].value;
double accel = cooked->accel.data[i].value;
- fprintf(raw_file, "%9.2f %9.2f %9.2f %9.2f\n",
- time, pres, accel);
+ unsigned daytime;
+ if (f->gps.num)
+ daytime = compute_daytime_ms(time, &f->gps);
+ else
+ daytime = 0;
+ fprintf(raw_file, "%9.2f %9.2f %9.2f %02d:%02d:%02d.%03d\n",
+ time, pres, accel,
+ daytime_hour(daytime),
+ daytime_minute(daytime),
+ daytime_second(daytime),
+ daytime_millisecond(daytime));
}
}
- if (gps_file) {
- int j = 0;
- fprintf(gps_file, "%9s %12s %12s %12s\n",
- "time", "lat", "lon", "alt");
+ if (gps_file || kml_file) {
+ int j = 0, baro_pos;
+ double baro_offset;
+ double baro = 0.0;
+ int state_idx = 0;
+
+ if (gps_file)
+ fprintf(gps_file, "%2s %2s %2s %9s %12s %12s %9s %8s %5s\n",
+ "hr", "mn", "sc",
+ "time", "lat", "lon", "alt", "baro", "nsat");
+ if (kml_file)
+ fprintf(kml_file, kml_placemark_start,
+ state_names[(int)f->state.data[state_idx].value],
+ state_names[(int)f->state.data[state_idx].value]);
+
+ if (f->gps.num)
+ baro_offset = f->gps.data[0].alt;
+ else
+ baro_offset = 0;
+ baro_pos = 0;
for (i = 0; i < f->gps.num; i++) {
int nsat = 0;
int k;
@@ -325,19 +538,70 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
break;
j++;
}
- fprintf(gps_file, "%12.7f %12.7f %12.7f %12.7f",
- (f->gps.data[i].time - boost_start) / 100.0,
- f->gps.data[i].lat,
- f->gps.data[i].lon,
- f->gps.data[i].alt);
+ if (cooked) {
+ while (baro_pos < cooked->pres_pos.num) {
+ double baro_time = cooked->accel_accel.start + baro_pos * cooked->accel_accel.step;
+ if (baro_time >= f->gps.data[i].time)
+ break;
+ baro_pos++;
+ }
+ if (baro_pos < cooked->pres_pos.num)
+ baro = cooked->pres_pos.data[baro_pos];
+ }
+ if (gps_file)
+ fprintf(gps_file, "%2d %2d %2d %12.7f %12.7f %12.7f %7.1f %7.1f",
+ f->gps.data[i].hour,
+ f->gps.data[i].minute,
+ f->gps.data[i].second,
+ (f->gps.data[i].time - boost_start) / 100.0,
+ f->gps.data[i].lat,
+ f->gps.data[i].lon,
+ f->gps.data[i].alt,
+ baro + baro_offset);
+
nsat = 0;
- for (k = 0; k < f->gps.sats[j].nsat; k++) {
- fprintf (gps_file, " %12.7f", (double) f->gps.sats[j].sat[k].c_n);
- if (f->gps.sats[j].sat[k].state == 0xbf)
- nsat++;
+ if (f->gps.sats) {
+ for (k = 0; k < f->gps.sats[j].nsat; k++) {
+ if (f->gps.sats[j].sat[k].svid != 0)
+ nsat++;
+ }
+ if (gps_file) {
+ fprintf(gps_file, " %4d", nsat);
+ for (k = 0; k < f->gps.sats[j].nsat; k++) {
+ if (f->gps.sats[j].sat[k].svid != 0) {
+ fprintf (gps_file, " %3d(%4.1f)",
+ f->gps.sats[j].sat[k].svid,
+ (double) f->gps.sats[j].sat[k].c_n);
+ }
+ }
+ fprintf(gps_file, "\n");
+ }
+ }
+
+ if (kml_file) {
+ snprintf(buf, sizeof (buf), kml_coord_fmt,
+ f->gps.data[i].lon,
+ f->gps.data[i].lat,
+ baro + baro_offset,
+ f->gps.data[i].alt,
+ (f->gps.data[i].time - boost_start) / 100.0,
+ nsat);
+ fprintf(kml_file, "%s", buf);
+ if (state_idx + 1 < f->state.num && f->state.data[state_idx + 1].time <= f->gps.data[i].time) {
+ state_idx++;
+ if (f->state.data[state_idx - 1].value != f->state.data[state_idx].value) {
+ fprintf(kml_file, "%s", kml_placemark_end);
+ fprintf(kml_file, kml_placemark_start,
+ state_names[(int)f->state.data[state_idx].value],
+ state_names[(int)f->state.data[state_idx].value]);
+ fprintf(kml_file, "%s", buf);
+ }
+ }
}
- fprintf(gps_file, " %d\n", nsat);
+
}
+ if (kml_file)
+ fprintf(kml_file, "%s", kml_footer);
}
if (cooked && plot_name) {
struct cc_perioddata *speed;
@@ -373,26 +637,70 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FI
}
static const struct option options[] = {
- { .name = "summary", .has_arg = 1, .val = 's' },
- { .name = "detail", .has_arg = 1, .val = 'd' },
- { .name = "plot", .has_arg = 1, .val = 'p' },
- { .name = "raw", .has_arg = 1, .val = 'r' },
- { .name = "gps", .has_arg = 1, .val = 'g' },
+ { .name = "summary", .has_arg = 2, .val = 's' },
+ { .name = "detail", .has_arg = 2, .val = 'd' },
+ { .name = "plot", .has_arg = 2, .val = 'p' },
+ { .name = "raw", .has_arg = 2, .val = 'r' },
+ { .name = "gps", .has_arg = 2, .val = 'g' },
+ { .name = "kml", .has_arg = 2, .val = 'k' },
+ { .name = "all", .has_arg = 0, .val = 'a' },
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
fprintf(stderr, "usage: %s\n"
+ "\t[--all] [-a]\n"
"\t[--summary=] [-s ]\n"
"\t[--detail=]\n"
"\t[--raw= -r -p ]\n"
"\t[--gps= -g ]\n"
+ "\t[--kml= -k ]\n"
"\t{flight-log} ...\n", program);
exit(1);
}
+char *
+replace_extension(char *file, char *extension)
+{
+ char *slash;
+ char *dot;
+ char *new;
+ int newlen;
+
+ slash = strrchr(file, '/');
+ dot = strrchr(file, '.');
+ if (!dot || (slash && dot < slash))
+ dot = file + strlen(file);
+ newlen = (dot - file) + strlen (extension) + 1;
+ new = malloc (newlen);
+ strncpy (new, file, dot - file);
+ new[dot-file] = '\0';
+ strcat (new, extension);
+ return new;
+}
+
+FILE *
+open_output(char *outname, char *inname, char *extension)
+{
+ char *o;
+ FILE *out;
+
+ if (outname)
+ o = outname;
+ else
+ o = replace_extension(inname, extension);
+ out = fopen(o, "w");
+ if (!out) {
+ perror (o);
+ exit(1);
+ }
+ if (o != outname)
+ free(o);
+ return out;
+}
+
int
main (int argc, char **argv)
{
@@ -401,6 +709,7 @@ main (int argc, char **argv)
FILE *detail_file = NULL;
FILE *raw_file = NULL;
FILE *gps_file = NULL;
+ FILE *kml_file = NULL;
int i;
int ret = 0;
struct cc_flightraw *raw;
@@ -412,62 +721,51 @@ main (int argc, char **argv)
char *raw_name = NULL;
char *plot_name = NULL;
char *gps_name = NULL;
+ char *kml_name = NULL;
+ int has_summary = 0;
+ int has_detail = 0;
+ int has_plot = 0;
+ int has_raw = 0;
+ int has_gps = 0;
+ int has_kml = 0;
+ char *this_plot_name = NULL;;
- while ((c = getopt_long(argc, argv, "s:d:p:r:g:", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "s:d:p:r:g:k:a", options, NULL)) != -1) {
switch (c) {
case 's':
summary_name = optarg;
+ has_summary = 1;
break;
case 'd':
detail_name = optarg;
+ has_detail = 1;
break;
case 'p':
plot_name = optarg;
+ has_plot = 1;
break;
case 'r':
raw_name = optarg;
+ has_raw = 1;
break;
case 'g':
gps_name = optarg;
+ has_gps = 1;
+ break;
+ case 'k':
+ kml_name = optarg;
+ has_kml = 1;
+ break;
+ case 'a':
+ has_summary = has_detail = has_plot = has_raw = has_gps = has_kml = 1;
break;
default:
usage(argv[0]);
break;
}
}
- summary_file = stdout;
- if (summary_name) {
- summary_file = fopen(summary_name, "w");
- if (!summary_file) {
- perror (summary_name);
- exit(1);
- }
- }
- if (detail_name) {
- if (summary_name && !strcmp (summary_name, detail_name))
- detail_file = summary_file;
- else {
- detail_file = fopen(detail_name, "w");
- if (!detail_file) {
- perror(detail_name);
- exit(1);
- }
- }
- }
- if (raw_name) {
- raw_file = fopen (raw_name, "w");
- if (!raw_file) {
- perror(raw_name);
- exit(1);
- }
- }
- if (gps_name) {
- gps_file = fopen(gps_name, "w");
- if (!gps_file) {
- perror(gps_name);
- exit(1);
- }
- }
+ if (!has_summary)
+ summary_file = stdout;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (!file) {
@@ -475,6 +773,22 @@ main (int argc, char **argv)
ret++;
continue;
}
+ if (has_summary && !summary_file)
+ summary_file = open_output(summary_name, argv[i], ".summary");
+ if (has_detail && !detail_file)
+ detail_file = open_output(detail_name, argv[i], ".detail");
+ if (has_plot) {
+ if (plot_name)
+ this_plot_name = plot_name;
+ else
+ this_plot_name = replace_extension(argv[i], ".plot");
+ }
+ if (has_raw && !raw_file)
+ raw_file = open_output(raw_name, argv[i], ".raw");
+ if (has_gps && !gps_file)
+ gps_file = open_output(gps_name, argv[i], ".gps");
+ if (has_kml && !kml_file)
+ kml_file = open_output(kml_name, argv[i], ".kml");
s = strstr(argv[i], "-serial-");
if (s)
serial = atoi(s + 8);
@@ -488,8 +802,26 @@ main (int argc, char **argv)
}
if (!raw->serial)
raw->serial = serial;
- analyse_flight(raw, summary_file, detail_file, raw_file, plot_name, gps_file);
+ analyse_flight(raw, summary_file, detail_file, raw_file, this_plot_name, gps_file, kml_file);
cc_flightraw_free(raw);
+ if (has_summary && !summary_name) {
+ fclose(summary_file); summary_file = NULL;
+ }
+ if (has_detail && !detail_name) {
+ fclose(detail_file); detail_file = NULL;
+ }
+ if (this_plot_name && this_plot_name != plot_name) {
+ free (this_plot_name); this_plot_name = NULL;
+ }
+ if (has_raw && !raw_name) {
+ fclose(raw_file); raw_file = NULL;
+ }
+ if (has_gps && !gps_name) {
+ fclose(gps_file); gps_file = NULL;
+ }
+ if (has_kml && !kml_name) {
+ fclose(kml_file); kml_file = NULL;
+ }
}
return ret;
}