altosui: remove un-used imports
[fw/altos] / altosui / AltosCSV.java
index 9ec21bef107aa9e2bd35fe0465964ca8e8357731..f8cc1ed6b1d12240a34ee74a7b28bfbc1018564c 100644 (file)
 
 package altosui;
 
-import java.lang.*;
 import java.io.*;
-import java.text.*;
 import java.util.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosCSV implements AltosWriter {
        File                    name;
@@ -31,7 +30,7 @@ public class AltosCSV implements AltosWriter {
        LinkedList<AltosRecord> pad_records;
        AltosState              state;
 
-       static final int ALTOS_CSV_VERSION = 4;
+       static final int ALTOS_CSV_VERSION = 5;
 
        /* Version 4 format:
         *
@@ -61,6 +60,17 @@ public class AltosCSV implements AltosWriter {
         *      drogue (V)
         *      main (V)
         *
+        * Advanced sensors (if available)
+        *      accel_x (m/s²)
+        *      accel_y (m/s²)
+        *      accel_z (m/s²)
+        *      gyro_x (d/s)
+        *      gyro_y (d/s)
+        *      gyro_z (d/s)
+        *      mag_x (g)
+        *      mag_y (g)
+        *      mag_z (g)
+        *
         * GPS data (if available)
         *      connected (1/0)
         *      locked (1/0)
@@ -129,6 +139,24 @@ public class AltosCSV implements AltosWriter {
                           record.main_voltage());
        }
 
+       void write_advanced_header() {
+               out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z");
+       }
+
+       void write_advanced(AltosRecord record) {
+               AltosIMU        imu = record.imu();
+               AltosMag        mag = record.mag();
+
+               if (imu == null)
+                       imu = new AltosIMU();
+               if (mag == null)
+                       mag = new AltosMag();
+               out.printf("%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d",
+                          imu.accel_x, imu.accel_y, imu.accel_z,
+                          imu.gyro_x, imu.gyro_y, imu.gyro_z,
+                          mag.x, mag.y, mag.z);
+       }
+
        void write_gps_header() {
                out.printf("connected,locked,nsat,latitude,longitude,altitude,year,month,day,hour,minute,second,pad_dist,pad_range,pad_az,pad_el,hdop");
        }
@@ -212,10 +240,12 @@ public class AltosCSV implements AltosWriter {
                        out.printf(",0");
        }
 
-       void write_header(boolean gps, boolean companion) {
+       void write_header(boolean advanced, boolean gps, boolean companion) {
                out.printf("#"); write_general_header();
                out.printf(","); write_flight_header();
                out.printf(","); write_basic_header();
+               if (advanced)
+                       out.printf(","); write_advanced_header();
                if (gps) {
                        out.printf(","); write_gps_header();
                        out.printf(","); write_gps_sat_header();
@@ -230,7 +260,9 @@ public class AltosCSV implements AltosWriter {
                state = new AltosState(record, state);
                write_general(record); out.printf(",");
                write_flight(record); out.printf(",");
-               write_basic(record);
+               write_basic(record); out.printf(",");
+               if (record.imu() != null || record.mag() != null)
+                       write_advanced(record);
                if (record.gps != null) {
                        out.printf(",");
                        write_gps(record); out.printf(",");
@@ -253,7 +285,8 @@ public class AltosCSV implements AltosWriter {
                if (record.state == Altos.ao_flight_startup)
                        return;
                if (!header_written) {
-                       write_header(record.gps != null, record.companion != null);
+                       write_header(record.imu() != null || record.mag() != null,
+                                    record.gps != null, record.companion != null);
                        header_written = true;
                }
                if (!seen_boost) {