diff options
| author | Keith Packard <keithp@keithp.com> | 2011-08-10 14:08:21 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2011-08-10 14:08:21 -0700 | 
| commit | 9e1487b1a5db0afd1d23c86d82c60b1c1a62aab0 (patch) | |
| tree | ab00e263739cacb14a09a63b650639a28fe4fe3f /altosui/AltosLanded.java | |
| parent | 6ac604d11de44cd824f09e4b467264a2b74be7bd (diff) | |
altosui: Add a 'Graph Flight' button to the 'landed'  tab
This lets you see the results of a flight as soon as the rocket lands
using the telemetry data.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosLanded.java')
| -rw-r--r-- | altosui/AltosLanded.java | 59 | 
1 files changed, 57 insertions, 2 deletions
| diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index d5c8e434..47aca29d 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -28,7 +28,7 @@ import java.text.*;  import java.util.prefs.*;  import java.util.concurrent.LinkedBlockingQueue; -public class AltosLanded extends JComponent implements AltosFlightDisplay { +public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener {  	GridBagLayout	layout;  	Font		label_font;  	Font		value_font; @@ -214,11 +214,51 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay {  		height.show(state, crc_errors);  		speed.show(state, crc_errors);  		accel.show(state, crc_errors); +		if (reader.backing_file() != null) +			graph.setEnabled(true);  	} -	public AltosLanded() { +	JButton	graph; +	AltosFlightReader reader; + +	public void actionPerformed(ActionEvent e) { +		String	cmd = e.getActionCommand(); + +		if (cmd.equals("graph")) { +			File	file = reader.backing_file(); +			if (file != null) { +				String	filename = file.getName(); +				try { +					AltosRecordIterable records = null; +					if (filename.endsWith("eeprom")) { +						FileInputStream in = new FileInputStream(file); +						records = new AltosEepromIterable(in); +					} else if (filename.endsWith("telem")) { +						FileInputStream in = new FileInputStream(file); +						records = new AltosTelemetryIterable(in); +					} else { +						throw new FileNotFoundException(); +					} +					try { +						new AltosGraphUI(records); +					} catch (InterruptedException ie) { +					} catch (IOException ie) { +					} +				} catch (FileNotFoundException fe) { +					JOptionPane.showMessageDialog(null, +								      filename, +								      "Cannot open file", +								      JOptionPane.ERROR_MESSAGE); +				} +			} +		} +	} + +	public AltosLanded(AltosFlightReader in_reader) {  		layout = new GridBagLayout(); +		reader = in_reader; +  		label_font = new Font("Dialog", Font.PLAIN, 22);  		value_font = new Font("Monospaced", Font.PLAIN, 22);  		setLayout(layout); @@ -231,5 +271,20 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay {  		height = new Height(layout, 4);  		speed = new Speed(layout, 5);  		accel = new Accel(layout, 6); + +		graph = new JButton ("Graph Flight"); +		graph.setActionCommand("graph"); +		graph.addActionListener(this); +		graph.setEnabled(false); + +		GridBagConstraints	c = new GridBagConstraints(); + +		c.gridx = 0; c.gridy = 7; +		c.insets = new Insets(10, 10, 10, 10); +		c.anchor = GridBagConstraints.WEST; +		c.weightx = 0; +		c.weighty = 0; +		c.fill = GridBagConstraints.VERTICAL; +		add(graph, c);  	}  } | 
