+ JFrame frame;
+ AltosSerial serial_line;
+ boolean remote;
+ Thread eeprom_thread;
+ AltosEepromMonitor monitor;
+
+ int flight;
+ int serial;
+ int year, month, day;
+ boolean want_file;
+ FileWriter eeprom_file;
+ LinkedList<String> eeprom_pending;
+
+ AltosEepromList flights;
+ ActionListener listener;
+ boolean success;
+ ParseException parse_exception;
+ String extension;
+
+ private void FlushPending() throws IOException {
+ for (String s : flights.config_data) {
+ eeprom_file.write(s);
+ eeprom_file.write('\n');
+ }
+
+ for (String s : eeprom_pending)
+ eeprom_file.write(s);
+ }
+
+ private void CheckFile(boolean force) throws IOException {
+ if (eeprom_file != null)
+ return;
+ if (force || (flight != 0 && want_file)) {
+ AltosFile eeprom_name;
+
+ if (extension == null)
+ extension = "data";
+ if (year != 0 && month != 0 && day != 0)
+ eeprom_name = new AltosFile(year, month, day, serial, flight, extension);
+ else
+ eeprom_name = new AltosFile(serial, flight, extension);
+
+ eeprom_file = new FileWriter(eeprom_name);
+ if (eeprom_file != null) {
+ monitor.set_file(eeprom_name.getName());
+ FlushPending();
+ eeprom_pending = null;
+ }
+ }
+ }
+
+ void Log(AltosEepromRecord r) throws IOException {
+ if (r.cmd != Altos.AO_LOG_INVALID) {
+ String log_line = String.format("%c %4x %4x %4x\n",
+ r.cmd, r.tick, r.a, r.b);
+ if (eeprom_file != null)
+ eeprom_file.write(log_line);
+ else
+ eeprom_pending.add(log_line);
+ }
+ }
+
+ void set_serial(int in_serial) {
+ serial = in_serial;
+ monitor.set_serial(serial);
+ }
+
+ void set_flight(int in_flight) {
+ flight = in_flight;
+ monitor.set_flight(flight);
+ }
+
+ boolean done;
+ int state;
+
+ void CaptureFull(AltosEepromChunk eechunk) throws IOException {
+ boolean any_valid = false;
+
+ extension = "eeprom";
+ set_serial(flights.config_data.serial);
+ for (int i = 0; i < AltosEepromChunk.chunk_size && !done; i += AltosEepromRecord.record_length) {