From c2c4d515ef9cc2cae8a8f2803e9498bb0794c4ed Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 6 Oct 2010 16:25:49 -0700 Subject: [PATCH] altosui: Remove ability to graph data in .csv files There's no reason to support these files when the raw .eeprom or .telem files which generate them should be used instead. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosCsvReader.java | 113 -------------------- ao-tools/altosui/AltosGraphDataChooser.java | 5 +- ao-tools/altosui/AltosGraphUI.java | 21 ---- ao-tools/altosui/AltosUI.java | 4 - ao-tools/altosui/Makefile.am | 1 - 5 files changed, 1 insertion(+), 143 deletions(-) delete mode 100644 ao-tools/altosui/AltosCsvReader.java diff --git a/ao-tools/altosui/AltosCsvReader.java b/ao-tools/altosui/AltosCsvReader.java deleted file mode 100644 index 600788f4..00000000 --- a/ao-tools/altosui/AltosCsvReader.java +++ /dev/null @@ -1,113 +0,0 @@ - -// Copyright (c) 2010 Anthony Towns -// GPL v2 or later - -package altosui; - -import java.lang.UnsupportedOperationException; -import java.util.HashMap; -import java.util.NoSuchElementException; -import java.util.Iterator; -import java.io.*; -import com.csvreader.CsvReader; - -import altosui.AltosDataPoint; - -class AltosCsvReader implements Iterable -{ - public CsvReader csv; - public AltosDataPoint next = null; - - static protected String [] headers = "version serial flight call time rssi state state_name acceleration pressure altitude height accel_speed baro_speed temperature battery_voltage drogue_voltage main_voltage connected locked nsat latitude longitude altitude year month day hour minute second pad_dist pad_range pad_az pad_el".split(" "); - - AltosCsvReader(Reader stream) { - csv = new CsvReader(stream); - csv.setComment('#'); - csv.setUseComments(true); - csv.setHeaders(headers); - } - AltosCsvReader(String filename) throws FileNotFoundException { - csv = new CsvReader(filename); - csv.setComment('#'); - csv.setUseComments(true); - csv.setHeaders(headers); - } - - public Iterator iterator() { - return new Iterator() { - public void remove() { - throw new UnsupportedOperationException(); - } - public boolean hasNext() { - if (next == null) { - try { - if (csv.readRecord()) { - next = new CsvRow(); - } else { - close(); - return false; - } - } catch (IOException e) { - close(); - return false; - } - } - return true; - } - public AltosDataPoint next() { - if (!hasNext()) - throw new NoSuchElementException(); - AltosDataPoint res = next; - next = null; - return res; - } - }; - } - - public void close() { - csv.close(); - } - - private class CsvRow extends HashMap - implements AltosDataPoint - { - CsvRow() throws IOException { - for (int i = 0; i < headers.length; i++) { - this.put(headers[i], csv.get(headers[i]).trim()); - } - } - - private int intField(String name) { - return Integer.parseInt(get(name).trim()); - } - private double doubleField(String name) { - return Double.valueOf(get(name)).doubleValue(); - } - private String stringField(String name) { - return get(name); - } - - public int version() { return intField("version"); } - public int serial() { return intField("serial"); } - public int flight() { return intField("flight"); } - public String callsign() { return stringField("call"); } - public double time() { return doubleField("time"); } - public double rssi() { return doubleField("rssi"); } - - public int state() { return intField("state"); } - public String state_name() { return stringField("state_name"); } - - public double acceleration() { return doubleField("acceleration"); } - public double pressure() { return doubleField("pressure"); } - public double altitude() { return doubleField("altitude"); } - public double height() { return doubleField("height"); } - public double accel_speed() { return doubleField("accel_speed"); } - public double baro_speed() { return doubleField("baro_speed"); } - public double temperature() { return doubleField("temperature"); } - public double battery_voltage() { - return doubleField("battery_voltage"); - } - public double drogue_voltage() { return doubleField("drogue_voltage"); } - public double main_voltage() { return doubleField("main_voltage"); } - } -} diff --git a/ao-tools/altosui/AltosGraphDataChooser.java b/ao-tools/altosui/AltosGraphDataChooser.java index 667d99f7..caa14118 100644 --- a/ao-tools/altosui/AltosGraphDataChooser.java +++ b/ao-tools/altosui/AltosGraphDataChooser.java @@ -28,7 +28,6 @@ import java.text.*; import java.util.prefs.*; import altosui.AltosPreferences; -import altosui.AltosCsvReader; import altosui.AltosDataPointReader; import altosui.AltosEepromIterable; import altosui.AltosTelemetryIterable; @@ -62,8 +61,6 @@ public class AltosGraphDataChooser extends JFileChooser { } else if (filename.endsWith("telem")) { FileInputStream in = new FileInputStream(file); return new AltosDataPointReader(new AltosTelemetryIterable(in)); - } else if (filename.endsWith("csv")) { - return new AltosCsvReader(new FileReader(file)); } else { throw new FileNotFoundException(); } @@ -81,7 +78,7 @@ public class AltosGraphDataChooser extends JFileChooser { frame = in_frame; setDialogTitle("Select Flight Record File"); setFileFilter(new FileNameExtensionFilter("Flight data file", - "csv", "telem", "eeprom")); + "telem", "eeprom")); setCurrentDirectory(AltosPreferences.logdir()); } } diff --git a/ao-tools/altosui/AltosGraphUI.java b/ao-tools/altosui/AltosGraphUI.java index d945c333..25643c76 100644 --- a/ao-tools/altosui/AltosGraphUI.java +++ b/ao-tools/altosui/AltosGraphUI.java @@ -17,7 +17,6 @@ import org.jfree.chart.axis.AxisLocation; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; -import altosui.AltosCsvReader; import altosui.AltosDataPoint; import altosui.AltosGraphTime; @@ -228,26 +227,6 @@ public class AltosGraphUI extends JFrame return graph; } - - public static void main(String[] args) - throws java.io.FileNotFoundException, java.io.IOException - { - if (args.length < 1 || 2 < args.length) - { - System.out.println("Please specify telemetry csv"); - return; - } - - AltosCsvReader csv = new AltosCsvReader(args[0]); - if (args.length == 1) { - for (AltosGraph g : createGraphs(csv)) { - g.toPNG(); - } - } else { - int which = Integer.parseInt(args[1].trim()); - AltosGraphUI demo = new AltosGraphUI(csv, which); - } - } } /* gnuplot bits... diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index 71481519..28ed42fb 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -59,10 +59,6 @@ public class AltosUI extends JFrame { private AltosLog altos_log; private Box vbox; - private Font statusFont = new Font("SansSerif", Font.BOLD, 24); - private Font infoLabelFont = new Font("SansSerif", Font.PLAIN, 14); - private Font infoValueFont = new Font("Monospaced", Font.PLAIN, 14); - public AltosVoice voice = new AltosVoice(); public static boolean load_library(Frame frame) { diff --git a/ao-tools/altosui/Makefile.am b/ao-tools/altosui/Makefile.am index 4e2a5027..58c1517f 100644 --- a/ao-tools/altosui/Makefile.am +++ b/ao-tools/altosui/Makefile.am @@ -56,7 +56,6 @@ altosui_JAVA = \ AltosUI.java \ AltosWriter.java \ AltosDataPointReader.java \ - AltosCsvReader.java \ AltosDataPoint.java \ AltosGraph.java \ AltosGraphTime.java \ -- 2.30.2