import java.util.*;
import java.text.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosEepromDownload implements Runnable {
AltosGPS gps = state.gps;
if (gps != null &&
- gps.year != AltosRecord.MISSING &&
- gps.month != AltosRecord.MISSING &&
- gps.day != AltosRecord.MISSING)
+ gps.year != AltosLib.MISSING &&
+ gps.month != AltosLib.MISSING &&
+ gps.day != AltosLib.MISSING)
{
eeprom_name = new AltosFile(gps.year, gps.month, gps.day,
state.serial, state.flight, "eeprom");
eeprom_file = new FileWriter(eeprom_name);
if (eeprom_file != null) {
- monitor.set_file(eeprom_name.getName());
+ monitor.set_filename(eeprom_name.getName());
FlushPending();
eeprom_pending = null;
}
}
}
- void CaptureEeprom(AltosEepromChunk eechunk, int log_format) throws IOException {
+ void CaptureEeprom(AltosEepromChunk eechunk, int log_format) throws IOException, ParseException {
boolean any_valid = false;
+ boolean got_flight = false;
int record_length = 8;
state.set_serial(flights.config_data.serial);
+ monitor.set_serial(flights.config_data.serial);
for (int i = 0; i < AltosEepromChunk.chunk_size && !done; i += record_length) {
- AltosEeprom r = eechunk.eeprom(i, log_format);
+ AltosEeprom r = eechunk.eeprom(i, log_format, state);
+
+ if (r == null)
+ continue;
record_length = r.record_length();
r.update_state(state);
+ if (!got_flight && state.flight != AltosLib.MISSING)
+ monitor.set_flight(state.flight);
+
/* Monitor state transitions to update display */
if (state.state != AltosLib.ao_flight_invalid &&
state.state <= AltosLib.ao_flight_landed)
CheckFile(false);
}
- void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException {
+ void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException, ParseException {
int block, state_block = 0;
int log_format = flights.config_data.log_format;
parse_exception = null;
if (log.selected) {
monitor.reset();
- CaptureLog(log);
+ try {
+ CaptureLog(log);
+ } catch (ParseException e) {
+ parse_exception = e;
+ }
}
if (parse_exception != null) {
failed = true;
serial_line.device.toShortString(),
JOptionPane.ERROR_MESSAGE);
} catch (InterruptedException ie) {
- System.out.printf("download interrupted\n");
+ show_message(String.format("Connection to \"%s\" interrupted",
+ serial_line.device.toShortString()),
+ "Connection Interrupted",
+ JOptionPane.ERROR_MESSAGE);
} catch (TimeoutException te) {
show_message(String.format("Connection to \"%s\" failed",
serial_line.device.toShortString()),
flights = given_flights;
success = false;
- monitor = new AltosEepromMonitor(frame, Altos.ao_flight_boost, Altos.ao_flight_landed);
- monitor.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (eeprom_thread != null)
- eeprom_thread.interrupt();
- }
- });
+ monitor = new AltosEepromMonitorUI(given_frame);
+ monitor.set_states(Altos.ao_flight_boost, Altos.ao_flight_landed);
+
+ monitor.set_thread(eeprom_thread);
}
}