make the column headers comma separated, too, so they align with the data
[fw/altos] / ao-tools / altosui / AltosCSV.java
index f12c034881143e863b7a86634d5516aba36798fd..07fa371f50e7c22bc6631a40acabb004fa5b1643 100644 (file)
@@ -44,6 +44,7 @@ public class AltosCSV {
         *      flight number
         *      callsign
         *      time (seconds since boost)
+        *      rssi
         *
         * Flight status
         *      state
@@ -74,6 +75,10 @@ public class AltosCSV {
         *      hour (0-23)
         *      minute (0-59)
         *      second (0-59)
+        *      from_pad_dist (m)
+        *      from_pad_azimuth (deg true)
+        *      from_pad_range (m)
+        *      from_pad_elevation (deg from horizon)
         *
         * GPS Sat data
         *      hdop
@@ -81,17 +86,18 @@ public class AltosCSV {
         */
 
        void write_general_header() {
-               out.printf("version serial flight call time");
+               out.printf("version,serial,flight,call,time,rssi");
        }
 
        void write_general(AltosRecord record) {
-               out.printf("%s,%d,%d,%s,%8.2f",
+               out.printf("%s,%d,%d,%s,%8.2f,%4d",
                           record.version, record.serial, record.flight, record.callsign,
-                          (double) (record.tick - boost_tick) / 100.0);
+                          (double) record.time,
+                          record.rssi);
        }
 
        void write_flight_header() {
-               out.printf("state state_name");
+               out.printf("state,state_name");
        }
 
        void write_flight(AltosRecord record) {
@@ -99,7 +105,7 @@ public class AltosCSV {
        }
 
        void write_basic_header() {
-               out.printf("acceleration pressure altitude height accel_speed baro_speed temperature battery_voltage drogue_voltage main_voltage");
+               out.printf("acceleration,pressure,altitude,height,accel_speed,baro_speed,temperature,battery_voltage,drogue_voltage,main_voltage");
        }
 
        void write_basic(AltosRecord record) {
@@ -117,7 +123,7 @@ public class AltosCSV {
        }
 
        void write_gps_header() {
-               out.printf("connected locked nsat latitude longitude altitude year month day hour minute second");
+               out.printf("connected,locked,nsat,latitude,longitude,altitude,year,month,day,hour,minute,second,pad_dist,pad_range,pad_az,pad_el");
        }
 
        void write_gps(AltosRecord record) {
@@ -125,7 +131,11 @@ public class AltosCSV {
                if (gps == null)
                        gps = new AltosGPS();
 
-               out.printf("%2d,%2d,%3d,%12.7f,%12.7f,%6d,%5d,%3d,%3d,%3d,%3d,%3d",
+               AltosGreatCircle from_pad = state.from_pad;
+               if (from_pad == null)
+                       from_pad = new AltosGreatCircle();
+
+               out.printf("%2d,%2d,%3d,%12.7f,%12.7f,%6d,%5d,%3d,%3d,%3d,%3d,%3d,%9.0f,%9.0f,%4.0f,%4.0f",
                           gps.connected?1:0,
                           gps.locked?1:0,
                           gps.nsat,
@@ -137,14 +147,18 @@ public class AltosCSV {
                           gps.day,
                           gps.hour,
                           gps.minute,
-                          gps.second);
+                          gps.second,
+                          from_pad.distance,
+                          state.range,
+                          from_pad.bearing,
+                          state.elevation);
        }
 
        void write_header() {
-               out.printf("# "); write_general_header();
-               out.printf(" "); write_flight_header();
-               out.printf(" "); write_basic_header();
-               out.printf(" "); write_gps_header();
+               out.printf("#"); write_general_header();
+               out.printf(","); write_flight_header();
+               out.printf(","); write_basic_header();
+               out.printf(","); write_gps_header();
                out.printf ("\n");
        }
 
@@ -205,7 +219,9 @@ public class AltosCSV {
                                write(record);
                        }
                } catch (IOException ie) {
+                       System.out.printf("IOException\n");
                } catch (ParseException pe) {
+                       System.out.printf("ParseException %s\n", pe.getMessage());
                }
        }
 
@@ -214,4 +230,8 @@ public class AltosCSV {
                out = new PrintStream(name);
                pad_records = new LinkedList<AltosRecord>();
        }
+
+       public AltosCSV(String in_string) throws FileNotFoundException {
+               this(new File(in_string));
+       }
 }