--- /dev/null
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_3;
+
+import java.io.*;
+import java.util.*;
+
+public class AltosCSV implements AltosWriter {
+ File name;
+ PrintStream out;
+ boolean header_written;
+ boolean seen_boost;
+ int boost_tick;
+ LinkedList<AltosState> pad_states;
+ AltosState state;
+
+ static final int ALTOS_CSV_VERSION = 5;
+
+ /* Version 4 format:
+ *
+ * General info
+ * version number
+ * serial number
+ * flight number
+ * callsign
+ * time (seconds since boost)
+ * clock (tick count / 100)
+ * rssi
+ * link quality
+ *
+ * Flight status
+ * state
+ * state name
+ *
+ * Basic sensors
+ * acceleration (m/s²)
+ * pressure (mBar)
+ * altitude (m)
+ * height (m)
+ * accelerometer speed (m/s)
+ * barometer speed (m/s)
+ * temp (°C)
+ * battery (V)
+ * 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)
+ * nsat (used for solution)
+ * latitude (°)
+ * longitude (°)
+ * altitude (m)
+ * year (e.g. 2010)
+ * month (1-12)
+ * day (1-31)
+ * 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)
+ * hdop
+ *
+ * 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() {
+ out.printf("version,serial,flight,call,time,clock,rssi,lqi");
+ }
+
+ void write_general(AltosState state) {
+ out.printf("%s, %d, %d, %s, %8.2f, %8.2f, %4d, %3d",
+ ALTOS_CSV_VERSION, state.serial, state.flight, state.callsign,
+ (double) state.time, (double) state.tick / 100.0,
+ state.rssi,
+ state.status & 0x7f);
+ }
+
+ void write_flight_header() {
+ out.printf("state,state_name");
+ }
+
+ void write_flight(AltosState state) {
+ out.printf("%d,%8s", state.state, state.state_name());
+ }
+
+ void write_basic_header() {
+ out.printf("acceleration,pressure,altitude,height,accel_speed,baro_speed,temperature,battery_voltage,drogue_voltage,main_voltage");
+ }
+
+ void write_basic(AltosState state) {
+ out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f",
+ state.acceleration(),
+ state.pressure(),
+ state.altitude(),
+ state.height(),
+ state.speed(),
+ state.speed(),
+ state.temperature,
+ state.battery_voltage,
+ state.apogee_voltage,
+ state.main_voltage);
+ }
+
+ void write_advanced_header() {
+ out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z");
+ }
+
+ void write_advanced(AltosState state) {
+ AltosIMU imu = state.imu;
+ AltosMag mag = state.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");
+ }
+
+ void write_gps(AltosState state) {
+ AltosGPS gps = state.gps;
+ if (gps == null)
+ gps = new AltosGPS();
+
+ AltosGreatCircle from_pad = state.from_pad;
+ if (from_pad == null)
+ from_pad = new AltosGreatCircle();
+
+ out.printf("%2d,%2d,%3d,%12.7f,%12.7f,%8.1f,%5d,%3d,%3d,%3d,%3d,%3d,%9.0f,%9.0f,%4.0f,%4.0f,%6.1f",
+ gps.connected?1:0,
+ gps.locked?1:0,
+ gps.nsat,
+ gps.lat,
+ gps.lon,
+ gps.alt,
+ gps.year,
+ gps.month,
+ gps.day,
+ gps.hour,
+ gps.minute,
+ gps.second,
+ from_pad.distance,
+ state.range,
+ from_pad.bearing,
+ state.elevation,
+ gps.hdop);
+ }
+
+ void write_gps_sat_header() {
+ for(int i = 1; i <= 32; i++) {
+ out.printf("sat%02d", i);
+ if (i != 32)
+ out.printf(",");
+ }
+ }
+
+ void write_gps_sat(AltosState state) {
+ AltosGPS gps = state.gps;
+ for(int i = 1; i <= 32; i++) {
+ int c_n0 = 0;
+ if (gps != null && gps.cc_gps_sat != null) {
+ for(int j = 0; j < gps.cc_gps_sat.length; j++)
+ if (gps.cc_gps_sat[j].svid == i) {
+ c_n0 = gps.cc_gps_sat[j].c_n0;
+ break;
+ }
+ }
+ out.printf ("%3d", c_n0);
+ if (i != 32)
+ out.printf(",");
+ }
+ }
+
+ 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(AltosState state) {
+ AltosCompanion companion = state.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 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();
+ }
+ if (companion) {
+ out.printf(","); write_companion_header();
+ }
+ out.printf ("\n");
+ }
+
+ void write_one(AltosState state) {
+ write_general(state); out.printf(",");
+ write_flight(state); out.printf(",");
+ write_basic(state); out.printf(",");
+ if (state.imu != null || state.mag != null)
+ write_advanced(state);
+ if (state.gps != null) {
+ out.printf(",");
+ write_gps(state); out.printf(",");
+ write_gps_sat(state);
+ }
+ if (state.companion != null) {
+ out.printf(",");
+ write_companion(state);
+ }
+ out.printf ("\n");
+ }
+
+ void flush_pad() {
+ while (!pad_states.isEmpty()) {
+ write_one (pad_states.remove());
+ }
+ }
+
+ public void write(AltosState state) {
+ if (state.state == AltosLib.ao_flight_startup)
+ return;
+ if (!header_written) {
+ write_header(state.imu != null || state.mag != null,
+ state.gps != null, state.companion != null);
+ header_written = true;
+ }
+ if (!seen_boost) {
+ if (state.state >= AltosLib.ao_flight_boost) {
+ seen_boost = true;
+ boost_tick = state.tick;
+ flush_pad();
+ }
+ }
+ if (seen_boost)
+ write_one(state);
+ else
+ pad_states.add(state);
+ }
+
+ public PrintStream out() {
+ return out;
+ }
+
+ public void close() {
+ if (!pad_states.isEmpty()) {
+ boost_tick = pad_states.element().tick;
+ flush_pad();
+ }
+ out.close();
+ }
+
+ public void write(AltosStateIterable states) {
+ states.write_comments(out());
+ for (AltosState state : states)
+ write(state);
+ }
+
+ public AltosCSV(PrintStream in_out, File in_name) {
+ name = in_name;
+ out = in_out;
+ pad_states = new LinkedList<AltosState>();
+ }
+
+ 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));
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_3;
+
+import java.io.*;
+
+public class AltosKML implements AltosWriter {
+
+ File name;
+ PrintStream out;
+ int flight_state = -1;
+ AltosState prev = null;
+ double gps_start_altitude;
+
+ static final String[] kml_state_colors = {
+ "FF000000",
+ "FF000000",
+ "FF000000",
+ "FF0000FF",
+ "FF4080FF",
+ "FF00FFFF",
+ "FFFF0000",
+ "FF00FF00",
+ "FF000000",
+ "FFFFFFFF"
+ };
+
+ static final String kml_header_start =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n" +
+ "<Document>\n" +
+ " <name>AO Flight#%d S/N: %03d</name>\n" +
+ " <description>\n";
+ static final String kml_header_end =
+ " </description>\n" +
+ " <open>0</open>\n";
+
+ static final String kml_style_start =
+ " <Style id=\"ao-flightstate-%s\">\n" +
+ " <LineStyle><color>%s</color><width>4</width></LineStyle>\n" +
+ " <BalloonStyle>\n" +
+ " <text>\n";
+
+ static final String kml_style_end =
+ " </text>\n" +
+ " </BalloonStyle>\n" +
+ " </Style>\n";
+
+ static final String kml_placemark_start =
+ " <Placemark>\n" +
+ " <name>%s</name>\n" +
+ " <styleUrl>#ao-flightstate-%s</styleUrl>\n" +
+ " <LineString>\n" +
+ " <tessellate>1</tessellate>\n" +
+ " <altitudeMode>absolute</altitudeMode>\n" +
+ " <coordinates>\n";
+
+ static final String kml_coord_fmt =
+ " %.7f,%.7f,%.7f <!-- alt %12.7f time %12.7f sats %d -->\n";
+
+ static final String kml_placemark_end =
+ " </coordinates>\n" +
+ " </LineString>\n" +
+ " </Placemark>\n";
+
+ static final String kml_footer =
+ "</Document>\n" +
+ "</kml>\n";
+
+ void start (AltosState record) {
+ out.printf(kml_header_start, record.flight, record.serial);
+ out.printf("Date: %04d-%02d-%02d\n",
+ record.gps.year, record.gps.month, record.gps.day);
+ out.printf("Time: %2d:%02d:%02d\n",
+ record.gps.hour, record.gps.minute, record.gps.second);
+ out.printf("%s", kml_header_end);
+ }
+
+ boolean started = false;
+
+ void state_start(AltosState state) {
+ String state_name = AltosLib.state_name(state.state);
+ out.printf(kml_style_start, state_name, kml_state_colors[state.state]);
+ out.printf("\tState: %s\n", state_name);
+ out.printf("%s", kml_style_end);
+ out.printf(kml_placemark_start, state_name, state_name);
+ }
+
+ void state_end(AltosState state) {
+ out.printf("%s", kml_placemark_end);
+ }
+
+ void coord(AltosState state) {
+ AltosGPS gps = state.gps;
+ double altitude;
+
+ if (state.height() != AltosLib.MISSING)
+ altitude = state.height() + gps_start_altitude;
+ else
+ altitude = gps.alt;
+ out.printf(kml_coord_fmt,
+ gps.lon, gps.lat,
+ altitude, (double) gps.alt,
+ state.time, gps.nsat);
+ }
+
+ void end() {
+ out.printf("%s", kml_footer);
+ }
+
+ public void close() {
+ if (prev != null) {
+ state_end(prev);
+ end();
+ prev = null;
+ }
+ }
+
+ public void write(AltosState state) {
+ AltosGPS gps = state.gps;
+
+ if (gps == null)
+ return;
+
+ if (gps.lat == AltosLib.MISSING)
+ return;
+ if (gps.lon == AltosLib.MISSING)
+ return;
+ if (!started) {
+ start(state);
+ started = true;
+ gps_start_altitude = gps.alt;
+ }
+ if (prev != null && prev.gps_sequence == state.gps_sequence)
+ return;
+ if (state.state != flight_state) {
+ flight_state = state.state;
+ if (prev != null) {
+ coord(state);
+ state_end(prev);
+ }
+ state_start(state);
+ }
+ coord(state);
+ prev = state;
+ }
+
+ public void write(AltosStateIterable states) {
+ for (AltosState state : states) {
+ if ((state.set & AltosState.set_gps) != 0)
+ write(state);
+ }
+ }
+
+ public AltosKML(File in_name) throws FileNotFoundException {
+ name = in_name;
+ out = new PrintStream(name);
+ }
+
+ public AltosKML(String in_string) throws FileNotFoundException {
+ this(new File(in_string));
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_3;
+
+public interface AltosWriter {
+
+ public void write(AltosState state);
+
+ public void write(AltosStateIterable states);
+
+ public void close();
+}
AltosConfigValues.java \
AltosConvert.java \
AltosCRCException.java \
+ AltosCSV.java \
AltosDebug.java \
AltosEeprom.java \
AltosEepromChunk.java \
AltosIdleMonitorListener.java \
AltosIgnite.java \
AltosIMU.java \
+ AltosKML.java \
AltosLine.java \
AltosLink.java \
AltosListenerState.java \
AltosSpeed.java \
AltosTemperature.java \
AltosAccel.java \
- AltosPyro.java
+ AltosPyro.java \
+ AltosWriter.java
JAR=altoslib_$(ALTOSLIB_VERSION).jar
+++ /dev/null
-/*
- * Copyright © 2010 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package altosui;
-
-import java.io.*;
-import java.util.*;
-import org.altusmetrum.altoslib_3.*;
-
-public class AltosCSV implements AltosWriter {
- File name;
- PrintStream out;
- boolean header_written;
- boolean seen_boost;
- int boost_tick;
- LinkedList<AltosState> pad_states;
- AltosState state;
-
- static final int ALTOS_CSV_VERSION = 5;
-
- /* Version 4 format:
- *
- * General info
- * version number
- * serial number
- * flight number
- * callsign
- * time (seconds since boost)
- * clock (tick count / 100)
- * rssi
- * link quality
- *
- * Flight status
- * state
- * state name
- *
- * Basic sensors
- * acceleration (m/s²)
- * pressure (mBar)
- * altitude (m)
- * height (m)
- * accelerometer speed (m/s)
- * barometer speed (m/s)
- * temp (°C)
- * battery (V)
- * 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)
- * nsat (used for solution)
- * latitude (°)
- * longitude (°)
- * altitude (m)
- * year (e.g. 2010)
- * month (1-12)
- * day (1-31)
- * 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)
- * hdop
- *
- * 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() {
- out.printf("version,serial,flight,call,time,clock,rssi,lqi");
- }
-
- void write_general(AltosState state) {
- out.printf("%s, %d, %d, %s, %8.2f, %8.2f, %4d, %3d",
- ALTOS_CSV_VERSION, state.serial, state.flight, state.callsign,
- (double) state.time, (double) state.tick / 100.0,
- state.rssi,
- state.status & 0x7f);
- }
-
- void write_flight_header() {
- out.printf("state,state_name");
- }
-
- void write_flight(AltosState state) {
- out.printf("%d,%8s", state.state, state.state_name());
- }
-
- void write_basic_header() {
- out.printf("acceleration,pressure,altitude,height,accel_speed,baro_speed,temperature,battery_voltage,drogue_voltage,main_voltage");
- }
-
- void write_basic(AltosState state) {
- out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f",
- state.acceleration(),
- state.pressure(),
- state.altitude(),
- state.height(),
- state.speed(),
- state.speed(),
- state.temperature,
- state.battery_voltage,
- state.apogee_voltage,
- state.main_voltage);
- }
-
- void write_advanced_header() {
- out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z");
- }
-
- void write_advanced(AltosState state) {
- AltosIMU imu = state.imu;
- AltosMag mag = state.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");
- }
-
- void write_gps(AltosState state) {
- AltosGPS gps = state.gps;
- if (gps == null)
- gps = new AltosGPS();
-
- AltosGreatCircle from_pad = state.from_pad;
- if (from_pad == null)
- from_pad = new AltosGreatCircle();
-
- out.printf("%2d,%2d,%3d,%12.7f,%12.7f,%8.1f,%5d,%3d,%3d,%3d,%3d,%3d,%9.0f,%9.0f,%4.0f,%4.0f,%6.1f",
- gps.connected?1:0,
- gps.locked?1:0,
- gps.nsat,
- gps.lat,
- gps.lon,
- gps.alt,
- gps.year,
- gps.month,
- gps.day,
- gps.hour,
- gps.minute,
- gps.second,
- from_pad.distance,
- state.range,
- from_pad.bearing,
- state.elevation,
- gps.hdop);
- }
-
- void write_gps_sat_header() {
- for(int i = 1; i <= 32; i++) {
- out.printf("sat%02d", i);
- if (i != 32)
- out.printf(",");
- }
- }
-
- void write_gps_sat(AltosState state) {
- AltosGPS gps = state.gps;
- for(int i = 1; i <= 32; i++) {
- int c_n0 = 0;
- if (gps != null && gps.cc_gps_sat != null) {
- for(int j = 0; j < gps.cc_gps_sat.length; j++)
- if (gps.cc_gps_sat[j].svid == i) {
- c_n0 = gps.cc_gps_sat[j].c_n0;
- break;
- }
- }
- out.printf ("%3d", c_n0);
- if (i != 32)
- out.printf(",");
- }
- }
-
- 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(AltosState state) {
- AltosCompanion companion = state.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 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();
- }
- if (companion) {
- out.printf(","); write_companion_header();
- }
- out.printf ("\n");
- }
-
- void write_one(AltosState state) {
- write_general(state); out.printf(",");
- write_flight(state); out.printf(",");
- write_basic(state); out.printf(",");
- if (state.imu != null || state.mag != null)
- write_advanced(state);
- if (state.gps != null) {
- out.printf(",");
- write_gps(state); out.printf(",");
- write_gps_sat(state);
- }
- if (state.companion != null) {
- out.printf(",");
- write_companion(state);
- }
- out.printf ("\n");
- }
-
- void flush_pad() {
- while (!pad_states.isEmpty()) {
- write_one (pad_states.remove());
- }
- }
-
- public void write(AltosState state) {
- if (state.state == Altos.ao_flight_startup)
- return;
- if (!header_written) {
- write_header(state.imu != null || state.mag != null,
- state.gps != null, state.companion != null);
- header_written = true;
- }
- if (!seen_boost) {
- if (state.state >= Altos.ao_flight_boost) {
- seen_boost = true;
- boost_tick = state.tick;
- flush_pad();
- }
- }
- if (seen_boost)
- write_one(state);
- else
- pad_states.add(state);
- }
-
- public PrintStream out() {
- return out;
- }
-
- public void close() {
- if (!pad_states.isEmpty()) {
- boost_tick = pad_states.element().tick;
- flush_pad();
- }
- out.close();
- }
-
- public void write(AltosStateIterable states) {
- states.write_comments(out());
- for (AltosState state : states)
- write(state);
- }
-
- public AltosCSV(PrintStream in_out, File in_name) {
- name = in_name;
- out = in_out;
- pad_states = new LinkedList<AltosState>();
- }
-
- 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));
- }
-}
+++ /dev/null
-/*
- * Copyright © 2010 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package altosui;
-
-import java.io.*;
-import org.altusmetrum.altoslib_3.*;
-
-public class AltosKML implements AltosWriter {
-
- File name;
- PrintStream out;
- int flight_state = -1;
- AltosState prev = null;
- double gps_start_altitude;
-
- static final String[] kml_state_colors = {
- "FF000000",
- "FF000000",
- "FF000000",
- "FF0000FF",
- "FF4080FF",
- "FF00FFFF",
- "FFFF0000",
- "FF00FF00",
- "FF000000",
- "FFFFFFFF"
- };
-
- static final String kml_header_start =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n" +
- "<Document>\n" +
- " <name>AO Flight#%d S/N: %03d</name>\n" +
- " <description>\n";
- static final String kml_header_end =
- " </description>\n" +
- " <open>0</open>\n";
-
- static final String kml_style_start =
- " <Style id=\"ao-flightstate-%s\">\n" +
- " <LineStyle><color>%s</color><width>4</width></LineStyle>\n" +
- " <BalloonStyle>\n" +
- " <text>\n";
-
- static final String kml_style_end =
- " </text>\n" +
- " </BalloonStyle>\n" +
- " </Style>\n";
-
- static final String kml_placemark_start =
- " <Placemark>\n" +
- " <name>%s</name>\n" +
- " <styleUrl>#ao-flightstate-%s</styleUrl>\n" +
- " <LineString>\n" +
- " <tessellate>1</tessellate>\n" +
- " <altitudeMode>absolute</altitudeMode>\n" +
- " <coordinates>\n";
-
- static final String kml_coord_fmt =
- " %.7f,%.7f,%.7f <!-- alt %12.7f time %12.7f sats %d -->\n";
-
- static final String kml_placemark_end =
- " </coordinates>\n" +
- " </LineString>\n" +
- " </Placemark>\n";
-
- static final String kml_footer =
- "</Document>\n" +
- "</kml>\n";
-
- void start (AltosState record) {
- out.printf(kml_header_start, record.flight, record.serial);
- out.printf("Date: %04d-%02d-%02d\n",
- record.gps.year, record.gps.month, record.gps.day);
- out.printf("Time: %2d:%02d:%02d\n",
- record.gps.hour, record.gps.minute, record.gps.second);
- out.printf("%s", kml_header_end);
- }
-
- boolean started = false;
-
- void state_start(AltosState state) {
- String state_name = Altos.state_name(state.state);
- out.printf(kml_style_start, state_name, kml_state_colors[state.state]);
- out.printf("\tState: %s\n", state_name);
- out.printf("%s", kml_style_end);
- out.printf(kml_placemark_start, state_name, state_name);
- }
-
- void state_end(AltosState state) {
- out.printf("%s", kml_placemark_end);
- }
-
- void coord(AltosState state) {
- AltosGPS gps = state.gps;
- double altitude;
-
- if (state.height() != AltosLib.MISSING)
- altitude = state.height() + gps_start_altitude;
- else
- altitude = gps.alt;
- out.printf(kml_coord_fmt,
- gps.lon, gps.lat,
- altitude, (double) gps.alt,
- state.time, gps.nsat);
- }
-
- void end() {
- out.printf("%s", kml_footer);
- }
-
- public void close() {
- if (prev != null) {
- state_end(prev);
- end();
- prev = null;
- }
- }
-
- public void write(AltosState state) {
- AltosGPS gps = state.gps;
-
- if (gps == null)
- return;
-
- if (gps.lat == AltosLib.MISSING)
- return;
- if (gps.lon == AltosLib.MISSING)
- return;
- if (!started) {
- start(state);
- started = true;
- gps_start_altitude = gps.alt;
- }
- if (prev != null && prev.gps_sequence == state.gps_sequence)
- return;
- if (state.state != flight_state) {
- flight_state = state.state;
- if (prev != null) {
- coord(state);
- state_end(prev);
- }
- state_start(state);
- }
- coord(state);
- prev = state;
- }
-
- public void write(AltosStateIterable states) {
- for (AltosState state : states) {
- if ((state.set & AltosState.set_gps) != 0)
- write(state);
- }
- }
-
- public AltosKML(File in_name) throws FileNotFoundException {
- name = in_name;
- out = new PrintStream(name);
- }
-
- public AltosKML(String in_string) throws FileNotFoundException {
- this(new File(in_string));
- }
-}
+++ /dev/null
-/*
- * Copyright © 2010 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package altosui;
-
-import org.altusmetrum.altoslib_3.*;
-
-
-public interface AltosWriter {
-
- public void write(AltosState state);
-
- public void write(AltosStateIterable states);
-
- public void close();
-}
AltosConfigureUI.java \
AltosConfigTD.java \
AltosConfigTDUI.java \
- AltosCSV.java \
AltosCSVUI.java \
AltosDescent.java \
AltosDeviceUIDialog.java \
AltosLaunch.java \
AltosLaunchUI.java \
AltosInfoTable.java \
- AltosKML.java \
AltosLanded.java \
AltosLed.java \
AltosLights.java \
AltosSiteMapCache.java \
AltosSiteMapTile.java \
AltosUI.java \
- AltosWriter.java \
AltosGraph.java \
AltosGraphDataPoint.java \
AltosGraphDataSet.java \