X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosCSV.java;h=cf649db0d06b781563f63ece4efabe22da60daec;hp=df98b2b45f8f381bf22bf55e932dbf51c52dfafa;hb=74d5dea5d5ef91db823018b631613d15c6da085d;hpb=f01096c4b42f9a4720ed0414826c2a283a992545 diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index df98b2b4..cf649db0 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -31,9 +31,9 @@ public class AltosCSV implements AltosWriter { LinkedList pad_records; AltosState state; - static final int ALTOS_CSV_VERSION = 2; + static final int ALTOS_CSV_VERSION = 3; - /* Version 2 format: + /* Version 3 format: * * General info * version number @@ -60,7 +60,7 @@ public class AltosCSV implements AltosWriter { * drogue (V) * main (V) * - * GPS data + * GPS data (if available) * connected (1/0) * locked (1/0) * nsat (used for solution) @@ -81,6 +81,13 @@ public class AltosCSV implements AltosWriter { * * GPS Sat data * C/N0 data for all 32 valid SDIDs + * + * Companion data + * companion_id (1-255. 10 is TeleScience) + * time of last companion data (seconds since boost) + * update_period (0.1-2.55 minimum telemetry interval) + * channels (0-12) + * channel data for all 12 possible channels */ void write_general_header() { @@ -179,12 +186,42 @@ public class AltosCSV implements AltosWriter { } } - void write_header() { + void write_companion_header() { + out.printf("companion_id,companion_time,companion_update,companion_channels"); + for (int i = 0; i < 12; i++) + out.printf(",companion_%02d", i); + } + + void write_companion(AltosRecord record) { + AltosRecordCompanion companion = record.companion; + + int channels_written = 0; + if (companion == null) { + out.printf("0,0,0,0"); + } else { + out.printf("%3d,%5.2f,%5.2f,%2d", + companion.board_id, + (companion.tick - boost_tick) / 100.0, + companion.update_period / 100.0, + companion.channels); + for (; channels_written < companion.channels; channels_written++) + out.printf(",%5d", companion.companion_data[channels_written]); + } + for (; channels_written < 12; channels_written++) + out.printf(",0"); + } + + void write_header(boolean gps, boolean companion) { out.printf("#"); write_general_header(); out.printf(","); write_flight_header(); out.printf(","); write_basic_header(); - out.printf(","); write_gps_header(); - out.printf(","); write_gps_sat_header(); + if (gps) { + out.printf(","); write_gps_header(); + out.printf(","); write_gps_sat_header(); + } + if (companion) { + out.printf(","); write_companion_header(); + } out.printf ("\n"); } @@ -192,9 +229,16 @@ public class AltosCSV implements AltosWriter { state = new AltosState(record, state); write_general(record); out.printf(","); write_flight(record); out.printf(","); - write_basic(record); out.printf(","); - write_gps(record); out.printf(","); - write_gps_sat(record); + write_basic(record); + if (record.gps != null) { + out.printf(","); + write_gps(record); out.printf(","); + write_gps_sat(record); + } + if (record.companion != null) { + out.printf(","); + write_companion(record); + } out.printf ("\n"); } @@ -205,8 +249,10 @@ public class AltosCSV implements AltosWriter { } public void write(AltosRecord record) { + if (record.state == Altos.ao_flight_startup) + return; if (!header_written) { - write_header(); + write_header(record.gps != null, record.companion != null); header_written = true; } if (!seen_boost) { @@ -240,12 +286,16 @@ public class AltosCSV implements AltosWriter { write(r); } - public AltosCSV(File in_name) throws FileNotFoundException { + public AltosCSV(PrintStream in_out, File in_name) { name = in_name; - out = new PrintStream(name); + out = in_out; pad_records = new LinkedList(); } + public AltosCSV(File in_name) throws FileNotFoundException { + this(new PrintStream(in_name), in_name); + } + public AltosCSV(String in_string) throws FileNotFoundException { this(new File(in_string)); }